Completed
Branch BUG-10209-session-encoding (73bea7)
by
unknown
194:52 queued 176:07
created
core/EE_Session.core.php 2 patches
Indentation   +109 added lines, -109 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,89 +444,89 @@  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
-         if ( ! is_array($session_data)) {
503
-             try {
504
-                 $session_data = maybe_unserialize($session_data);
505
-             } catch (Exception $e) {
506
-                 $msg = esc_html__(
507
-                     'An error occurred while attempting to unserialize the session data.',
508
-                     'event_espresso'
509
-                 );
510
-                 $msg .= WP_DEBUG
511
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
512
-                     : '';
513
-                 throw new InvalidSessionDataException($msg, 0, $e);
514
-             }
515
-         }
516
-         // just a check to make sure the session array is indeed an array
517
-         if ( ! is_array($session_data)) {
518
-             // no?!?! then something is wrong
519
-             $msg = esc_html__(
520
-                 'The session data is missing, invalid, or corrupted.',
521
-                 'event_espresso'
522
-             );
523
-             $msg .= WP_DEBUG
524
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
525
-                 : '';
526
-             throw new InvalidSessionDataException($msg);
527
-         }
528
-         return $session_data;
529
-     }
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
+		 if ( ! is_array($session_data)) {
503
+			 try {
504
+				 $session_data = maybe_unserialize($session_data);
505
+			 } catch (Exception $e) {
506
+				 $msg = esc_html__(
507
+					 'An error occurred while attempting to unserialize the session data.',
508
+					 'event_espresso'
509
+				 );
510
+				 $msg .= WP_DEBUG
511
+					 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
512
+					 : '';
513
+				 throw new InvalidSessionDataException($msg, 0, $e);
514
+			 }
515
+		 }
516
+		 // just a check to make sure the session array is indeed an array
517
+		 if ( ! is_array($session_data)) {
518
+			 // no?!?! then something is wrong
519
+			 $msg = esc_html__(
520
+				 'The session data is missing, invalid, or corrupted.',
521
+				 'event_espresso'
522
+			 );
523
+			 $msg .= WP_DEBUG
524
+				 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
525
+				 : '';
526
+			 throw new InvalidSessionDataException($msg);
527
+		 }
528
+		 return $session_data;
529
+	 }
530 530
 
531 531
 
532 532
 
@@ -740,9 +740,9 @@  discard block
 block discarded – undo
740 740
 		) {
741 741
 			return false;
742 742
 		}
743
-        // then serialize all of our session data
744
-        $session_data = serialize($this->_session_data);
745
-        // do we need to also encode it to avoid corrupted data when saved to the db?
743
+		// then serialize all of our session data
744
+		$session_data = serialize($this->_session_data);
745
+		// do we need to also encode it to avoid corrupted data when saved to the db?
746 746
 		$session_data = $this->_use_encryption ? $this->encryption->base64_string_encode( $session_data ) : $session_data;
747 747
 		// maybe save hash check
748 748
 		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
Please login to merge, or discard this patch.
Spacing   +168 added lines, -168 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
                  );
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
                      'event_espresso'
509 509
                  );
510 510
                  $msg .= WP_DEBUG
511
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
511
+                     ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
512 512
                      : '';
513 513
                  throw new InvalidSessionDataException($msg, 0, $e);
514 514
              }
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
                  'event_espresso'
522 522
              );
523 523
              $msg .= WP_DEBUG
524
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
524
+                 ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
525 525
                  : '';
526 526
              throw new InvalidSessionDataException($msg);
527 527
          }
@@ -541,12 +541,12 @@  discard block
 block discarded – undo
541 541
 	  */
542 542
 	protected function _generate_session_id() {
543 543
 		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
544
-		if ( isset( $_REQUEST[ 'EESID' ] ) ) {
545
-			$session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] );
544
+		if (isset($_REQUEST['EESID'])) {
545
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
546 546
 		} else {
547
-			$session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() );
547
+			$session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
548 548
 		}
549
-		return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id );
549
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
550 550
 	}
551 551
 
552 552
 
@@ -558,20 +558,20 @@  discard block
 block discarded – undo
558 558
 	  */
559 559
 	protected function _get_sid_salt() {
560 560
 		// was session id salt already saved to db ?
561
-		if ( empty( $this->_sid_salt ) ) {
561
+		if (empty($this->_sid_salt)) {
562 562
 			// no?  then maybe use WP defined constant
563
-			if ( defined( 'AUTH_SALT' ) ) {
563
+			if (defined('AUTH_SALT')) {
564 564
 				$this->_sid_salt = AUTH_SALT;
565 565
 			}
566 566
 			// if salt doesn't exist or is too short
567
-			if ( empty( $this->_sid_salt ) || strlen( $this->_sid_salt ) < 32 ) {
567
+			if (empty($this->_sid_salt) || strlen($this->_sid_salt) < 32) {
568 568
 				// create a new one
569
-				$this->_sid_salt = wp_generate_password( 64 );
569
+				$this->_sid_salt = wp_generate_password(64);
570 570
 			}
571 571
 			// and save it as a permanent session setting
572
-			$session_settings = get_option( 'ee_session_settings' );
573
-			$session_settings[ 'sid_salt' ] = $this->_sid_salt;
574
-			update_option( 'ee_session_settings', $session_settings );
572
+			$session_settings = get_option('ee_session_settings');
573
+			$session_settings['sid_salt'] = $this->_sid_salt;
574
+			update_option('ee_session_settings', $session_settings);
575 575
 		}
576 576
 		return $this->_sid_salt;
577 577
 	}
@@ -599,19 +599,19 @@  discard block
 block discarded – undo
599 599
 	  * @param bool $new_session
600 600
 	  * @return TRUE on success, FALSE on fail
601 601
 	  */
602
-	public function update( $new_session = FALSE ) {
603
-		$this->_session_data = isset( $this->_session_data )
604
-			&& is_array( $this->_session_data )
605
-			&& isset( $this->_session_data['id'])
602
+	public function update($new_session = FALSE) {
603
+		$this->_session_data = isset($this->_session_data)
604
+			&& is_array($this->_session_data)
605
+			&& isset($this->_session_data['id'])
606 606
 			? $this->_session_data
607 607
 			: NULL;
608
-		if ( empty( $this->_session_data )) {
608
+		if (empty($this->_session_data)) {
609 609
 			$this->_set_defaults();
610 610
 		}
611 611
 		$session_data = array();
612
-		foreach ( $this->_session_data as $key => $value ) {
612
+		foreach ($this->_session_data as $key => $value) {
613 613
 
614
-			switch( $key ) {
614
+			switch ($key) {
615 615
 
616 616
 				case 'id' :
617 617
 					// session ID
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
 				break;
630 630
 
631 631
 				case 'init_access' :
632
-					$session_data['init_access'] = absint( $value );
632
+					$session_data['init_access'] = absint($value);
633 633
 				break;
634 634
 
635 635
 				case 'last_access' :
@@ -639,7 +639,7 @@  discard block
 block discarded – undo
639 639
 
640 640
 				case 'expiration' :
641 641
 					// when the session expires
642
-					$session_data['expiration'] = ! empty( $this->_expiration )
642
+					$session_data['expiration'] = ! empty($this->_expiration)
643 643
 						? $this->_expiration
644 644
 						: $session_data['init_access'] + $this->_lifespan;
645 645
 				break;
@@ -651,11 +651,11 @@  discard block
 block discarded – undo
651 651
 
652 652
 				case 'pages_visited' :
653 653
 					$page_visit = $this->_get_page_visit();
654
-					if ( $page_visit ) {
654
+					if ($page_visit) {
655 655
 						// set pages visited where the first will be the http referrer
656
-						$this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit;
656
+						$this->_session_data['pages_visited'][$this->_time] = $page_visit;
657 657
 						// we'll only save the last 10 page visits.
658
-						$session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 );
658
+						$session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
659 659
 					}
660 660
 				break;
661 661
 
@@ -669,9 +669,9 @@  discard block
 block discarded – undo
669 669
 
670 670
 		$this->_session_data = $session_data;
671 671
 		// creating a new session does not require saving to the db just yet
672
-		if ( ! $new_session ) {
672
+		if ( ! $new_session) {
673 673
 			// ready? let's save
674
-			if ( $this->_save_session_to_db() ) {
674
+			if ($this->_save_session_to_db()) {
675 675
 				return TRUE;
676 676
 			} else {
677 677
 				return FALSE;
@@ -693,7 +693,7 @@  discard block
 block discarded – undo
693 693
 	  * @param string $location
694 694
 	  * @return mixed
695 695
 	  */
696
-	 public function update_on_redirect( $location ) {
696
+	 public function update_on_redirect($location) {
697 697
 		 $this->update();
698 698
 		 return $location;
699 699
 	}
@@ -705,9 +705,9 @@  discard block
 block discarded – undo
705 705
 	 * 	@return bool
706 706
 	 */
707 707
 	private function _create_espresso_session( ) {
708
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
708
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
709 709
 		// use the update function for now with $new_session arg set to TRUE
710
-		return  $this->update( TRUE ) ? TRUE : FALSE;
710
+		return  $this->update(TRUE) ? TRUE : FALSE;
711 711
 	}
712 712
 
713 713
 
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 				// OR an admin request that is NOT AJAX
735 735
 				|| (
736 736
 					is_admin()
737
-					&& ! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
737
+					&& ! (defined('DOING_AJAX') && DOING_AJAX)
738 738
 				)
739 739
 			)
740 740
 		) {
@@ -743,13 +743,13 @@  discard block
 block discarded – undo
743 743
         // then serialize all of our session data
744 744
         $session_data = serialize($this->_session_data);
745 745
         // do we need to also encode it to avoid corrupted data when saved to the db?
746
-		$session_data = $this->_use_encryption ? $this->encryption->base64_string_encode( $session_data ) : $session_data;
746
+		$session_data = $this->_use_encryption ? $this->encryption->base64_string_encode($session_data) : $session_data;
747 747
 		// maybe save hash check
748
-		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
749
-			set_transient( EE_Session::hash_check_prefix . $this->_sid, md5( $session_data ), $this->_lifespan );
748
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
749
+			set_transient(EE_Session::hash_check_prefix.$this->_sid, md5($session_data), $this->_lifespan);
750 750
 		}
751 751
 		// we're using the Transient API for storing session data, cuz it's so damn simple -> set_transient(  transient ID, data, expiry )
752
-		return set_transient( EE_Session::session_id_prefix . $this->_sid, $session_data, $this->_lifespan );
752
+		return set_transient(EE_Session::session_id_prefix.$this->_sid, $session_data, $this->_lifespan);
753 753
 	}
754 754
 
755 755
 
@@ -775,10 +775,10 @@  discard block
 block discarded – undo
775 775
 			'HTTP_FORWARDED',
776 776
 			'REMOTE_ADDR'
777 777
 		);
778
-		foreach ( $server_keys as $key ){
779
-			if ( isset( $_SERVER[ $key ] )) {
780
-				foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) {
781
-					if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) {
778
+		foreach ($server_keys as $key) {
779
+			if (isset($_SERVER[$key])) {
780
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
781
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) {
782 782
 						$visitor_ip = $ip;
783 783
 					}
784 784
 				}
@@ -797,32 +797,32 @@  discard block
 block discarded – undo
797 797
 	 *			@return string
798 798
 	 */
799 799
 	public function _get_page_visit() {
800
-		$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
800
+		$page_visit = home_url('/').'wp-admin/admin-ajax.php';
801 801
 		// check for request url
802
-		if ( isset( $_SERVER['REQUEST_URI'] )) {
802
+		if (isset($_SERVER['REQUEST_URI'])) {
803 803
 			$http_host = '';
804 804
 			$page_id = '?';
805 805
 			$e_reg = '';
806
-			$request_uri = esc_url( $_SERVER['REQUEST_URI'] );
807
-			$ru_bits = explode( '?', $request_uri );
806
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
807
+			$ru_bits = explode('?', $request_uri);
808 808
 			$request_uri = $ru_bits[0];
809 809
 			// check for and grab host as well
810
-			if ( isset( $_SERVER['HTTP_HOST'] )) {
811
-				$http_host = esc_url( $_SERVER['HTTP_HOST'] );
810
+			if (isset($_SERVER['HTTP_HOST'])) {
811
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
812 812
 			}
813 813
 			// check for page_id in SERVER REQUEST
814
-			if ( isset( $_REQUEST['page_id'] )) {
814
+			if (isset($_REQUEST['page_id'])) {
815 815
 				// rebuild $e_reg without any of the extra parameters
816
-				$page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&amp;';
816
+				$page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
817 817
 			}
818 818
 			// check for $e_reg in SERVER REQUEST
819
-			if ( isset( $_REQUEST['ee'] )) {
819
+			if (isset($_REQUEST['ee'])) {
820 820
 				// rebuild $e_reg without any of the extra parameters
821
-				$e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] );
821
+				$e_reg = 'ee='.esc_attr($_REQUEST['ee']);
822 822
 			}
823
-			$page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' );
823
+			$page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
824 824
 		}
825
-		return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : '';
825
+		return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
826 826
 
827 827
 	}
828 828
 
@@ -851,14 +851,14 @@  discard block
 block discarded – undo
851 851
 	  * @param string $function
852 852
 	  * @return void
853 853
 	  */
854
-	public function clear_session( $class = '', $function = '' ) {
854
+	public function clear_session($class = '', $function = '') {
855 855
 		//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>';
856
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
856
+		do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
857 857
 		$this->reset_cart();
858 858
 		$this->reset_checkout();
859 859
 		$this->reset_transaction();
860 860
 		// wipe out everything that isn't a default session datum
861
-		$this->reset_data( array_keys( $this->_session_data ));
861
+		$this->reset_data(array_keys($this->_session_data));
862 862
 		// reset initial site access time and the session expiration
863 863
 		$this->_set_init_access_and_expiration();
864 864
 		$this->_save_session_to_db();
@@ -873,42 +873,42 @@  discard block
 block discarded – undo
873 873
 	  * @param bool  $show_all_notices
874 874
 	  * @return TRUE on success, FALSE on fail
875 875
 	  */
876
-	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
876
+	public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) {
877 877
 		// if $data_to_reset is not in an array, then put it in one
878
-		if ( ! is_array( $data_to_reset ) ) {
879
-			$data_to_reset = array ( $data_to_reset );
878
+		if ( ! is_array($data_to_reset)) {
879
+			$data_to_reset = array($data_to_reset);
880 880
 		}
881 881
 		// nothing ??? go home!
882
-		if ( empty( $data_to_reset )) {
883
-			EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
882
+		if (empty($data_to_reset)) {
883
+			EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
884 884
 			return FALSE;
885 885
 		}
886 886
 		$return_value = TRUE;
887 887
 		// since $data_to_reset is an array, cycle through the values
888
-		foreach ( $data_to_reset as $reset ) {
888
+		foreach ($data_to_reset as $reset) {
889 889
 
890 890
 			// first check to make sure it is a valid session var
891
-			if ( isset( $this->_session_data[ $reset ] )) {
891
+			if (isset($this->_session_data[$reset])) {
892 892
 				// then check to make sure it is not a default var
893
-				if ( ! array_key_exists( $reset, $this->_default_session_vars )) {
893
+				if ( ! array_key_exists($reset, $this->_default_session_vars)) {
894 894
 					// remove session var
895
-					unset( $this->_session_data[ $reset ] );
896
-					if ( $show_all_notices ) {
897
-						EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
895
+					unset($this->_session_data[$reset]);
896
+					if ($show_all_notices) {
897
+						EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
898 898
 					}
899
-					$return_value = !isset($return_value) ? TRUE : $return_value;
899
+					$return_value = ! isset($return_value) ? TRUE : $return_value;
900 900
 
901 901
 				} else {
902 902
 					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
903
-					if ( $show_all_notices ) {
904
-						EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
903
+					if ($show_all_notices) {
904
+						EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
905 905
 					}
906 906
 					$return_value = FALSE;
907 907
 				}
908 908
 
909
-			} else if ( $show_all_notices ) {
909
+			} else if ($show_all_notices) {
910 910
 				// oops! that session var does not exist!
911
-				EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
911
+				EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
912 912
 				$return_value = FALSE;
913 913
 			}
914 914
 
@@ -928,8 +928,8 @@  discard block
 block discarded – undo
928 928
 	 *   @access public
929 929
 	 */
930 930
 	public function wp_loaded() {
931
-		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
932
-			$this->clear_session( __CLASS__, __FUNCTION__ );
931
+		if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) {
932
+			$this->clear_session(__CLASS__, __FUNCTION__);
933 933
 		}
934 934
 	}
935 935
 
@@ -954,24 +954,24 @@  discard block
 block discarded – undo
954 954
 	  */
955 955
 	 public function garbage_collection() {
956 956
 		 // only perform during regular requests
957
-		 if ( ! defined( 'DOING_AJAX') || ! DOING_AJAX ) {
957
+		 if ( ! defined('DOING_AJAX') || ! DOING_AJAX) {
958 958
 			 /** @type WPDB $wpdb */
959 959
 			 global $wpdb;
960 960
 			 // since transient expiration timestamps are set in the future, we can compare against NOW
961 961
 			 $expiration = time();
962
-			 $too_far_in_the_the_future = $expiration + ( $this->_lifespan * 2 );
962
+			 $too_far_in_the_the_future = $expiration + ($this->_lifespan * 2);
963 963
 			 // filter the query limit. Set to 0 to turn off garbage collection
964
-			 $expired_session_transient_delete_query_limit = absint( apply_filters( 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50 ));
964
+			 $expired_session_transient_delete_query_limit = absint(apply_filters('FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit', 50));
965 965
 			 // non-zero LIMIT means take out the trash
966
-			 if ( $expired_session_transient_delete_query_limit ) {
966
+			 if ($expired_session_transient_delete_query_limit) {
967 967
 				 //array of transient keys that require garbage collection
968 968
 				 $session_keys = array(
969 969
 					 EE_Session::session_id_prefix,
970 970
 					 EE_Session::hash_check_prefix,
971 971
 				 );
972
-				 foreach ( $session_keys as $session_key ) {
973
-					 $session_key = str_replace( '_', '\_', $session_key );
974
-					 $session_key = '\_transient\_timeout\_' . $session_key . '%';
972
+				 foreach ($session_keys as $session_key) {
973
+					 $session_key = str_replace('_', '\_', $session_key);
974
+					 $session_key = '\_transient\_timeout\_'.$session_key.'%';
975 975
 					 $SQL = "
976 976
 					SELECT option_name
977 977
 					FROM {$wpdb->options}
@@ -981,25 +981,25 @@  discard block
 block discarded – undo
981 981
 					OR option_value > {$too_far_in_the_the_future} )
982 982
 					LIMIT {$expired_session_transient_delete_query_limit}
983 983
 				";
984
-					 $expired_sessions = $wpdb->get_col( $SQL );
984
+					 $expired_sessions = $wpdb->get_col($SQL);
985 985
 					 // valid results?
986
-					 if ( ! $expired_sessions instanceof WP_Error && ! empty( $expired_sessions ) ) {
986
+					 if ( ! $expired_sessions instanceof WP_Error && ! empty($expired_sessions)) {
987 987
 						 // format array of results into something usable within the actual DELETE query's IN clause
988 988
 						 $expired = array();
989
-						 foreach ( $expired_sessions as $expired_session ) {
990
-							 $expired[ ] = "'" . $expired_session . "'";
991
-							 $expired[ ] = "'" . str_replace( 'timeout_', '', $expired_session ) . "'";
989
+						 foreach ($expired_sessions as $expired_session) {
990
+							 $expired[] = "'".$expired_session."'";
991
+							 $expired[] = "'".str_replace('timeout_', '', $expired_session)."'";
992 992
 						 }
993
-						 $expired = implode( ', ', $expired );
993
+						 $expired = implode(', ', $expired);
994 994
 						 $SQL = "
995 995
 						DELETE FROM {$wpdb->options}
996 996
 						WHERE option_name
997 997
 						IN ( $expired );
998 998
 					 ";
999
-						 $results = $wpdb->query( $SQL );
999
+						 $results = $wpdb->query($SQL);
1000 1000
 						 // if something went wrong, then notify the admin
1001
-						 if ( $results instanceof WP_Error && is_admin() ) {
1002
-							 EE_Error::add_error( $results->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
1001
+						 if ($results instanceof WP_Error && is_admin()) {
1002
+							 EE_Error::add_error($results->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
1003 1003
 						 }
1004 1004
 					 }
1005 1005
 				 }
@@ -1020,34 +1020,34 @@  discard block
 block discarded – undo
1020 1020
 	  * @param $data1
1021 1021
 	  * @return string
1022 1022
 	  */
1023
-	 private function find_serialize_error( $data1 ) {
1023
+	 private function find_serialize_error($data1) {
1024 1024
 		$error = "<pre>";
1025 1025
 		 $data2 = preg_replace_callback(
1026 1026
 			 '!s:(\d+):"(.*?)";!',
1027
-			 function ( $match ) {
1028
-				 return ( $match[1] === strlen( $match[2] ) )
1027
+			 function($match) {
1028
+				 return ($match[1] === strlen($match[2]))
1029 1029
 					 ? $match[0]
1030 1030
 					 : 's:'
1031
-					   . strlen( $match[2] )
1031
+					   . strlen($match[2])
1032 1032
 					   . ':"'
1033 1033
 					   . $match[2]
1034 1034
 					   . '";';
1035 1035
 			 },
1036 1036
 			 $data1
1037 1037
 		 );
1038
-		$max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 );
1039
-		$error .= $data1 . PHP_EOL;
1040
-		$error .= $data2 . PHP_EOL;
1041
-		for ( $i = 0; $i < $max; $i++ ) {
1042
-			if ( @$data1[ $i ] !== @$data2[ $i ] ) {
1043
-				$error .= "Difference " . @$data1[ $i ] . " != " . @$data2[ $i ] . PHP_EOL;
1044
-				$error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . " != " . ord( @$data2[ $i ] ) . PHP_EOL;
1045
-				$error .= "\t-> Line Number = $i" . PHP_EOL;
1046
-				$start = ( $i - 20 );
1047
-				$start = ( $start < 0 ) ? 0 : $start;
1038
+		$max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1039
+		$error .= $data1.PHP_EOL;
1040
+		$error .= $data2.PHP_EOL;
1041
+		for ($i = 0; $i < $max; $i++) {
1042
+			if (@$data1[$i] !== @$data2[$i]) {
1043
+				$error .= "Difference ".@$data1[$i]." != ".@$data2[$i].PHP_EOL;
1044
+				$error .= "\t-> ORD number ".ord(@$data1[$i])." != ".ord(@$data2[$i]).PHP_EOL;
1045
+				$error .= "\t-> Line Number = $i".PHP_EOL;
1046
+				$start = ($i - 20);
1047
+				$start = ($start < 0) ? 0 : $start;
1048 1048
 				$length = 40;
1049 1049
 				$point = $max - $i;
1050
-				if ( $point < 20 ) {
1050
+				if ($point < 20) {
1051 1051
 					$rlength = 1;
1052 1052
 					$rpoint = -$point;
1053 1053
 				} else {
@@ -1056,16 +1056,16 @@  discard block
 block discarded – undo
1056 1056
 				}
1057 1057
 				$error .= "\t-> Section Data1  = ";
1058 1058
 				$error .= substr_replace(
1059
-					substr( $data1, $start, $length ),
1060
-					"<b style=\"color:green\">{$data1[ $i ]}</b>",
1059
+					substr($data1, $start, $length),
1060
+					"<b style=\"color:green\">{$data1[$i]}</b>",
1061 1061
 					$rpoint,
1062 1062
 					$rlength
1063 1063
 				);
1064 1064
 				$error .= PHP_EOL;
1065 1065
 				$error .= "\t-> Section Data2  = ";
1066 1066
 				$error .= substr_replace(
1067
-					substr( $data2, $start, $length ),
1068
-					"<b style=\"color:red\">{$data2[ $i ]}</b>",
1067
+					substr($data2, $start, $length),
1068
+					"<b style=\"color:red\">{$data2[$i]}</b>",
1069 1069
 					$rpoint,
1070 1070
 					$rlength
1071 1071
 				);
Please login to merge, or discard this patch.
core/EE_Encryption.core.php 2 patches
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('No direct script access allowed');
3
+	exit('No direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 
29 29
 	/**
30 30
 	 * 	private constructor to prevent direct creation
31
-     *
31
+	 *
32 32
 	 */
33 33
   private function __construct() {
34 34
 		define( 'ESPRESSO_ENCRYPT', true );
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 
125 125
 	/**
126 126
 	 * encodes string with PHP's base64 encoding
127
-     *
127
+	 *
128 128
 	 * @source  http://php.net/manual/en/function.base64-encode.php
129 129
 	 * @param string $text_string
130 130
 	 * @internal param $string - the text to be encoded
@@ -136,14 +136,14 @@  discard block
 block discarded – undo
136 136
 			return $text_string;
137 137
 		}
138 138
 		// encode
139
-        return base64_encode ( $text_string );
139
+		return base64_encode ( $text_string );
140 140
 	}
141 141
 
142 142
 
143 143
 
144 144
 	/**
145 145
 	 * decodes string that has been encoded with PHP's base64 encoding
146
-     *
146
+	 *
147 147
 	 * @source  http://php.net/manual/en/function.base64-encode.php
148 148
 	 * @param string $encoded_string
149 149
 	 * @internal param $string - the text to be decoded
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 			return $encoded_string;
156 156
 		}
157 157
 		// decode
158
-        return base64_decode ( $encoded_string );
158
+		return base64_decode ( $encoded_string );
159 159
 	}
160 160
 
161 161
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 		// encode
177 177
 		$encoded_string = base64_encode ( $text_string );
178 178
 		// remove chars to make encoding more URL friendly
179
-        return strtr ( $encoded_string, '+/=', '-_,' );
179
+		return strtr ( $encoded_string, '+/=', '-_,' );
180 180
 	}
181 181
 
182 182
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
 		// replace previously removed characters
198 198
 		$encoded_string = strtr ( $encoded_string, '-_,', '+/=' );
199 199
 		// decode
200
-        return base64_decode ( $encoded_string );
200
+		return base64_decode ( $encoded_string );
201 201
 	}
202 202
 
203 203
 
@@ -211,8 +211,8 @@  discard block
 block discarded – undo
211 211
 	 */
212 212
 	private function m_encrypt  ( $text_string = '' ) {
213 213
 		// you give me nothing??? GET OUT !
214
-        if (empty($text_string)) {
215
-            return $text_string;
214
+		if (empty($text_string)) {
215
+			return $text_string;
216 216
 		}
217 217
 		// get the initialization vector size
218 218
 		$iv_size = mcrypt_get_iv_size ( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB );
@@ -220,7 +220,7 @@  discard block
 block discarded – undo
220 220
 		$iv = mcrypt_create_iv ( $iv_size, MCRYPT_RAND );
221 221
 		// encrypt it
222 222
 		$encrypted_text = mcrypt_encrypt ( MCRYPT_RIJNDAEL_256, $this->get_encryption_key(), $text_string, MCRYPT_MODE_ECB, $iv );
223
-        // trim and maybe encode
223
+		// trim and maybe encode
224 224
 		return function_exists('base64_encode') ? trim(base64_encode($encrypted_text)) : trim($encrypted_text);
225 225
 	}
226 226
 
@@ -235,12 +235,12 @@  discard block
 block discarded – undo
235 235
 	 */
236 236
 	private function m_decrypt  ( $encrypted_text = '' )  {
237 237
 		// you give me nothing??? GET OUT !
238
-        if (empty($encrypted_text)) {
239
-            return $encrypted_text;
238
+		if (empty($encrypted_text)) {
239
+			return $encrypted_text;
240 240
 		}
241 241
 		// decode
242
-        $encrypted_text = $this->valid_base_64($encrypted_text) ? base64_decode($encrypted_text) : $encrypted_text;
243
-        // get the initialization vector size
242
+		$encrypted_text = $this->valid_base_64($encrypted_text) ? base64_decode($encrypted_text) : $encrypted_text;
243
+		// get the initialization vector size
244 244
 		$iv_size = mcrypt_get_iv_size ( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB );
245 245
 		$iv = mcrypt_create_iv ( $iv_size, MCRYPT_RAND );
246 246
 		// decrypt it
@@ -261,8 +261,8 @@  discard block
 block discarded – undo
261 261
 	 */
262 262
 	private function acme_encrypt ( $text_string = '' ) {
263 263
 		// you give me nothing??? GET OUT !
264
-        if (empty($text_string)) {
265
-            return $text_string;
264
+		if (empty($text_string)) {
265
+			return $text_string;
266 266
 		}
267 267
 		$key_bits = str_split ( str_pad ( '', strlen( $text_string ), $this->get_encryption_key(), STR_PAD_RIGHT ));
268 268
 		$string_bits = str_split( $text_string );
@@ -270,15 +270,15 @@  discard block
 block discarded – undo
270 270
 			$temp = ord( $v ) + ord ( $key_bits[$k] );
271 271
 			$string_bits[$k] = chr ( $temp > 255 ? ( $temp - 256 ) : $temp );
272 272
 		}
273
-        return function_exists('base64_encode') ? base64_encode( implode( '', $string_bits ) ) : implode('', $string_bits);
273
+		return function_exists('base64_encode') ? base64_encode( implode( '', $string_bits ) ) : implode('', $string_bits);
274 274
 	}
275 275
 
276 276
 
277 277
 
278 278
 	/**
279
-     * decrypts data for acme servers that didn't bother to install PHP mcrypt
280
-     *
281
-     * @source   : http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
279
+	 * decrypts data for acme servers that didn't bother to install PHP mcrypt
280
+	 *
281
+	 * @source   : http://stackoverflow.com/questions/800922/how-to-encrypt-string-without-mcrypt-library-in-php
282 282
 	 * @param string $encrypted_text the text to be decrypted
283 283
 	 * @return string
284 284
 	 */
@@ -287,46 +287,46 @@  discard block
 block discarded – undo
287 287
 		if  ( empty($encrypted_text))  {
288 288
 			return $encrypted_text;
289 289
 		}
290
-        // decode the data ?
291
-        $encrypted_text = $this->valid_base_64($encrypted_text) ? base64_decode($encrypted_text) : $encrypted_text;
290
+		// decode the data ?
291
+		$encrypted_text = $this->valid_base_64($encrypted_text) ? base64_decode($encrypted_text) : $encrypted_text;
292 292
 		$key_bits = str_split ( str_pad ( '', strlen ( $encrypted_text ), $this->get_encryption_key(), STR_PAD_RIGHT ));
293 293
 		$string_bits = str_split ( $encrypted_text );
294 294
 		foreach ( $string_bits as $k => $v ) {
295 295
 			$temp = ord ( $v ) - ord ( $key_bits[$k] );
296 296
 			$string_bits[$k] = chr ( $temp < 0 ? ( $temp + 256 ) : $temp );
297 297
 		}
298
-        return implode( '', $string_bits );
298
+		return implode( '', $string_bits );
299 299
 	}
300 300
 
301 301
 
302 302
 
303
-    /**
304
-     * @see http://stackoverflow.com/questions/2556345/detect-base64-encoding-in-php#30231906
305
-     * @param $string
306
-     * @return bool
307
-     */
308
-    private function valid_base_64($string)
309
-    {
310
-        // ensure data is a string
311
-        if ( ! is_string($string) || ! function_exists('base64_decode')) {
312
-            return false;
313
-        }
314
-        $decoded = base64_decode($string, true);
315
-        // Check if there is no invalid character in string
316
-        if ( ! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
317
-            return false;
318
-        }
319
-        // Decode the string in strict mode and send the response
320
-        if ( ! base64_decode($string, true)) {
321
-            return false;
322
-        }
323
-        // Encode and compare it to original one
324
-        return base64_encode($decoded) === $string;
325
-    }
326
-
327
-
328
-
329
-    /**
303
+	/**
304
+	 * @see http://stackoverflow.com/questions/2556345/detect-base64-encoding-in-php#30231906
305
+	 * @param $string
306
+	 * @return bool
307
+	 */
308
+	private function valid_base_64($string)
309
+	{
310
+		// ensure data is a string
311
+		if ( ! is_string($string) || ! function_exists('base64_decode')) {
312
+			return false;
313
+		}
314
+		$decoded = base64_decode($string, true);
315
+		// Check if there is no invalid character in string
316
+		if ( ! preg_match('/^[a-zA-Z0-9\/\r\n+]*={0,2}$/', $string)) {
317
+			return false;
318
+		}
319
+		// Decode the string in strict mode and send the response
320
+		if ( ! base64_decode($string, true)) {
321
+			return false;
322
+		}
323
+		// Encode and compare it to original one
324
+		return base64_encode($decoded) === $string;
325
+	}
326
+
327
+
328
+
329
+	/**
330 330
 	 * generate random string
331 331
 	 * @source   : http://stackoverflow.com/questions/637278/what-is-the-best-way-to-generate-a-random-key-within-php
332 332
 	 * @access   public
Please login to merge, or discard this patch.
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
      *
32 32
 	 */
33 33
   private function __construct() {
34
-		define( 'ESPRESSO_ENCRYPT', true );
35
-		if ( ! function_exists( 'mcrypt_encrypt' ) ) {
34
+		define('ESPRESSO_ENCRYPT', true);
35
+		if ( ! function_exists('mcrypt_encrypt')) {
36 36
 			$this->_use_mcrypt = false;
37 37
 		}
38 38
 	}
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 	 *	@access public
45 45
 	 * @return \EE_Encryption
46 46
 	 */
47
-	public static function instance ( ) {
47
+	public static function instance( ) {
48 48
 		// check if class object is instantiated
49
-		if ( ! self::$_instance instanceof EE_Encryption ) {
49
+		if ( ! self::$_instance instanceof EE_Encryption) {
50 50
 			self::$_instance = new self();
51 51
 		}
52 52
 		return self::$_instance;
@@ -61,15 +61,15 @@  discard block
 block discarded – undo
61 61
 	 */
62 62
 	public  function get_encryption_key() {
63 63
 		// if encryption key has not been set
64
-		if ( empty( $this->_encryption_key )) {
64
+		if (empty($this->_encryption_key)) {
65 65
 			// retrieve encryption_key from db
66
-			$this->_encryption_key = get_option( 'ee_encryption_key', '' );
66
+			$this->_encryption_key = get_option('ee_encryption_key', '');
67 67
 			// WHAT?? No encryption_key in the db ??
68
-			if ( $this->_encryption_key === '' ) {
68
+			if ($this->_encryption_key === '') {
69 69
 				// let's make one. And md5 it to make it just the right size for a key
70
-				$new_key =  md5($this->generate_random_string());
70
+				$new_key = md5($this->generate_random_string());
71 71
 				// now save it to the db for later
72
-				add_option( 'ee_encryption_key', $new_key );
72
+				add_option('ee_encryption_key', $new_key);
73 73
 				// here's the key - FINALLY !
74 74
 				$this->_encryption_key = $new_key;
75 75
 			}
@@ -85,15 +85,15 @@  discard block
 block discarded – undo
85 85
 	 * @param string $text_string  - the text to be encrypted
86 86
 	 * @return string
87 87
 	 */
88
-	public function encrypt ( $text_string = '' ) {
88
+	public function encrypt($text_string = '') {
89 89
 		// you give me nothing??? GET OUT !
90
-		if  ( empty( $text_string ))  {
90
+		if (empty($text_string)) {
91 91
 			return $text_string;
92 92
 		}
93
-		if ( $this->_use_mcrypt ) {
94
-			$encrypted_text = $this->m_encrypt( $text_string );
93
+		if ($this->_use_mcrypt) {
94
+			$encrypted_text = $this->m_encrypt($text_string);
95 95
 		} else {
96
-			$encrypted_text = $this->acme_encrypt( $text_string );
96
+			$encrypted_text = $this->acme_encrypt($text_string);
97 97
 		}
98 98
 		return $encrypted_text;
99 99
 	}
@@ -106,16 +106,16 @@  discard block
 block discarded – undo
106 106
 	 * @param string $encrypted_text - the text to be decrypted
107 107
 	 * @return string
108 108
 	 */
109
-	public function decrypt  ( $encrypted_text = '' )  {
109
+	public function decrypt($encrypted_text = '') {
110 110
 		// you give me nothing??? GET OUT !
111
-		if  ( empty( $encrypted_text ))  {
111
+		if (empty($encrypted_text)) {
112 112
 			return $encrypted_text;
113 113
 		}
114 114
 		// if PHP's mcrypt functions are installed then we'll use them
115
-		if ( $this->_use_mcrypt ) {
116
-			$decrypted_text = $this->m_decrypt( $encrypted_text );
115
+		if ($this->_use_mcrypt) {
116
+			$decrypted_text = $this->m_decrypt($encrypted_text);
117 117
 		} else {
118
-			$decrypted_text = $this->acme_decrypt( $encrypted_text );
118
+			$decrypted_text = $this->acme_decrypt($encrypted_text);
119 119
 		}
120 120
 		return $decrypted_text;
121 121
  	}
@@ -130,13 +130,13 @@  discard block
 block discarded – undo
130 130
 	 * @internal param $string - the text to be encoded
131 131
 	 * @return string
132 132
 	 */
133
-	public function base64_string_encode ( $text_string = '' ) {
133
+	public function base64_string_encode($text_string = '') {
134 134
 		// you give me nothing??? GET OUT !
135
-		if  (empty($text_string) || ! function_exists('base64_encode'))  {
135
+		if (empty($text_string) || ! function_exists('base64_encode')) {
136 136
 			return $text_string;
137 137
 		}
138 138
 		// encode
139
-        return base64_encode ( $text_string );
139
+        return base64_encode($text_string);
140 140
 	}
141 141
 
142 142
 
@@ -149,13 +149,13 @@  discard block
 block discarded – undo
149 149
 	 * @internal param $string - the text to be decoded
150 150
 	 * @return string
151 151
 	 */
152
-	public function base64_string_decode ( $encoded_string = '' ) {
152
+	public function base64_string_decode($encoded_string = '') {
153 153
 		// you give me nothing??? GET OUT !
154
-		if  (empty($encoded_string) || ! $this->valid_base_64($encoded_string))  {
154
+		if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
155 155
 			return $encoded_string;
156 156
 		}
157 157
 		// decode
158
-        return base64_decode ( $encoded_string );
158
+        return base64_decode($encoded_string);
159 159
 	}
160 160
 
161 161
 
@@ -168,15 +168,15 @@  discard block
 block discarded – undo
168 168
 	 * @internal param $string - the text to be encoded
169 169
 	 * @return string
170 170
 	 */
171
-	public function base64_url_encode ( $text_string = '' ) {
171
+	public function base64_url_encode($text_string = '') {
172 172
 		// you give me nothing??? GET OUT !
173
-		if  (empty($text_string) || ! function_exists('base64_encode'))  {
173
+		if (empty($text_string) || ! function_exists('base64_encode')) {
174 174
 			return $text_string;
175 175
 		}
176 176
 		// encode
177
-		$encoded_string = base64_encode ( $text_string );
177
+		$encoded_string = base64_encode($text_string);
178 178
 		// remove chars to make encoding more URL friendly
179
-        return strtr ( $encoded_string, '+/=', '-_,' );
179
+        return strtr($encoded_string, '+/=', '-_,');
180 180
 	}
181 181
 
182 182
 
@@ -189,15 +189,15 @@  discard block
 block discarded – undo
189 189
 	 * @internal param $string - the text to be decoded
190 190
 	 * @return string
191 191
 	 */
192
-	public function base64_url_decode ( $encoded_string = '' ) {
192
+	public function base64_url_decode($encoded_string = '') {
193 193
 		// you give me nothing??? GET OUT !
194
-		if  (empty($encoded_string) || ! $this->valid_base_64($encoded_string))  {
194
+		if (empty($encoded_string) || ! $this->valid_base_64($encoded_string)) {
195 195
 			return $encoded_string;
196 196
 		}
197 197
 		// replace previously removed characters
198
-		$encoded_string = strtr ( $encoded_string, '-_,', '+/=' );
198
+		$encoded_string = strtr($encoded_string, '-_,', '+/=');
199 199
 		// decode
200
-        return base64_decode ( $encoded_string );
200
+        return base64_decode($encoded_string);
201 201
 	}
202 202
 
203 203
 
@@ -209,17 +209,17 @@  discard block
 block discarded – undo
209 209
 	 * @internal param $string - the text to be encrypted
210 210
 	 * @return string
211 211
 	 */
212
-	private function m_encrypt  ( $text_string = '' ) {
212
+	private function m_encrypt($text_string = '') {
213 213
 		// you give me nothing??? GET OUT !
214 214
         if (empty($text_string)) {
215 215
             return $text_string;
216 216
 		}
217 217
 		// get the initialization vector size
218
-		$iv_size = mcrypt_get_iv_size ( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB );
218
+		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
219 219
 		// initialization vector
220
-		$iv = mcrypt_create_iv ( $iv_size, MCRYPT_RAND );
220
+		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
221 221
 		// encrypt it
222
-		$encrypted_text = mcrypt_encrypt ( MCRYPT_RIJNDAEL_256, $this->get_encryption_key(), $text_string, MCRYPT_MODE_ECB, $iv );
222
+		$encrypted_text = mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $this->get_encryption_key(), $text_string, MCRYPT_MODE_ECB, $iv);
223 223
         // trim and maybe encode
224 224
 		return function_exists('base64_encode') ? trim(base64_encode($encrypted_text)) : trim($encrypted_text);
225 225
 	}
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
 	 * @internal param $string - the text to be decrypted
234 234
 	 * @return string
235 235
 	 */
236
-	private function m_decrypt  ( $encrypted_text = '' )  {
236
+	private function m_decrypt($encrypted_text = '') {
237 237
 		// you give me nothing??? GET OUT !
238 238
         if (empty($encrypted_text)) {
239 239
             return $encrypted_text;
@@ -241,11 +241,11 @@  discard block
 block discarded – undo
241 241
 		// decode
242 242
         $encrypted_text = $this->valid_base_64($encrypted_text) ? base64_decode($encrypted_text) : $encrypted_text;
243 243
         // get the initialization vector size
244
-		$iv_size = mcrypt_get_iv_size ( MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB );
245
-		$iv = mcrypt_create_iv ( $iv_size, MCRYPT_RAND );
244
+		$iv_size = mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB);
245
+		$iv = mcrypt_create_iv($iv_size, MCRYPT_RAND);
246 246
 		// decrypt it
247
-		$decrypted_text = mcrypt_decrypt ( MCRYPT_RIJNDAEL_256, $this->get_encryption_key(), $encrypted_text, MCRYPT_MODE_ECB, $iv );
248
-		$decrypted_text = trim ( $decrypted_text );
247
+		$decrypted_text = mcrypt_decrypt(MCRYPT_RIJNDAEL_256, $this->get_encryption_key(), $encrypted_text, MCRYPT_MODE_ECB, $iv);
248
+		$decrypted_text = trim($decrypted_text);
249 249
 		return $decrypted_text;
250 250
 	}
251 251
 
@@ -259,18 +259,18 @@  discard block
 block discarded – undo
259 259
 	 * @internal param $string - the text to be decrypted
260 260
 	 * @return string
261 261
 	 */
262
-	private function acme_encrypt ( $text_string = '' ) {
262
+	private function acme_encrypt($text_string = '') {
263 263
 		// you give me nothing??? GET OUT !
264 264
         if (empty($text_string)) {
265 265
             return $text_string;
266 266
 		}
267
-		$key_bits = str_split ( str_pad ( '', strlen( $text_string ), $this->get_encryption_key(), STR_PAD_RIGHT ));
268
-		$string_bits = str_split( $text_string );
269
-		foreach ( $string_bits as $k =>$v ) {
270
-			$temp = ord( $v ) + ord ( $key_bits[$k] );
271
-			$string_bits[$k] = chr ( $temp > 255 ? ( $temp - 256 ) : $temp );
267
+		$key_bits = str_split(str_pad('', strlen($text_string), $this->get_encryption_key(), STR_PAD_RIGHT));
268
+		$string_bits = str_split($text_string);
269
+		foreach ($string_bits as $k =>$v) {
270
+			$temp = ord($v) + ord($key_bits[$k]);
271
+			$string_bits[$k] = chr($temp > 255 ? ($temp - 256) : $temp);
272 272
 		}
273
-        return function_exists('base64_encode') ? base64_encode( implode( '', $string_bits ) ) : implode('', $string_bits);
273
+        return function_exists('base64_encode') ? base64_encode(implode('', $string_bits)) : implode('', $string_bits);
274 274
 	}
275 275
 
276 276
 
@@ -282,20 +282,20 @@  discard block
 block discarded – undo
282 282
 	 * @param string $encrypted_text the text to be decrypted
283 283
 	 * @return string
284 284
 	 */
285
-	private function acme_decrypt ( $encrypted_text = '' ) {
285
+	private function acme_decrypt($encrypted_text = '') {
286 286
 		// you give me nothing??? GET OUT !
287
-		if  ( empty($encrypted_text))  {
287
+		if (empty($encrypted_text)) {
288 288
 			return $encrypted_text;
289 289
 		}
290 290
         // decode the data ?
291 291
         $encrypted_text = $this->valid_base_64($encrypted_text) ? base64_decode($encrypted_text) : $encrypted_text;
292
-		$key_bits = str_split ( str_pad ( '', strlen ( $encrypted_text ), $this->get_encryption_key(), STR_PAD_RIGHT ));
293
-		$string_bits = str_split ( $encrypted_text );
294
-		foreach ( $string_bits as $k => $v ) {
295
-			$temp = ord ( $v ) - ord ( $key_bits[$k] );
296
-			$string_bits[$k] = chr ( $temp < 0 ? ( $temp + 256 ) : $temp );
292
+		$key_bits = str_split(str_pad('', strlen($encrypted_text), $this->get_encryption_key(), STR_PAD_RIGHT));
293
+		$string_bits = str_split($encrypted_text);
294
+		foreach ($string_bits as $k => $v) {
295
+			$temp = ord($v) - ord($key_bits[$k]);
296
+			$string_bits[$k] = chr($temp < 0 ? ($temp + 256) : $temp);
297 297
 		}
298
-        return implode( '', $string_bits );
298
+        return implode('', $string_bits);
299 299
 	}
300 300
 
301 301
 
@@ -334,13 +334,13 @@  discard block
 block discarded – undo
334 334
 	 * @internal param $string - number of characters for random string
335 335
 	 * @return string
336 336
 	 */
337
-	public function generate_random_string ( $length = 40 ) {
338
-		$iterations = ceil ( $length / 40 );
337
+	public function generate_random_string($length = 40) {
338
+		$iterations = ceil($length / 40);
339 339
 		$random_string = '';
340
-		for ($i = 0; $i < $iterations; $i ++) {
341
-			$random_string .= sha1( microtime(TRUE) . mt_rand( 10000, 90000 ));
340
+		for ($i = 0; $i < $iterations; $i++) {
341
+			$random_string .= sha1(microtime(TRUE).mt_rand(10000, 90000));
342 342
 		}
343
-		$random_string =  substr( $random_string, 0, $length );
343
+		$random_string = substr($random_string, 0, $length);
344 344
 		return $random_string;
345 345
 	}
346 346
 
Please login to merge, or discard this patch.
espresso.php 1 patch
Spacing   +91 added lines, -91 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('ABSPATH')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
  * @link             {@link http://www.eventespresso.com}
40 40
  * @since            4.0
41 41
  */
42
-if ( function_exists( 'espresso_version' ) ) {
42
+if (function_exists('espresso_version')) {
43 43
 
44 44
 	/**
45 45
 	 *    espresso_duplicate_plugin_error
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
 			</p>
57 57
 		</div>
58 58
 		<?php
59
-		espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
59
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
60 60
 	}
61
-	add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 );
61
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
62 62
 
63 63
 } else {
64 64
 
65
-	define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' );
65
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.0');
66 66
 
67
-	if ( ! version_compare( PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=' ) ) {
67
+	if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) {
68 68
 
69 69
 		/**
70 70
 		 * espresso_minimum_php_version_error
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 				</p>
91 91
 			</div>
92 92
 			<?php
93
-			espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
93
+			espresso_deactivate_plugin(plugin_basename(__FILE__));
94 94
 		}
95
-		add_action( 'admin_notices', 'espresso_minimum_php_version_error', 1 );
95
+		add_action('admin_notices', 'espresso_minimum_php_version_error', 1);
96 96
 
97 97
 	} else {
98 98
 
@@ -103,99 +103,99 @@  discard block
 block discarded – undo
103 103
 		 * @return string
104 104
 		 */
105 105
 		function espresso_version() {
106
-			return apply_filters( 'FHEE__espresso__espresso_version', '4.9.21.rc.002' );
106
+			return apply_filters('FHEE__espresso__espresso_version', '4.9.21.rc.002');
107 107
 		}
108 108
 
109 109
 		// define versions
110
-		define( 'EVENT_ESPRESSO_VERSION', espresso_version() );
111
-		define( 'EE_MIN_WP_VER_REQUIRED', '4.1' );
112
-		define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' );
113
-		define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' );
114
-		define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ );
110
+		define('EVENT_ESPRESSO_VERSION', espresso_version());
111
+		define('EE_MIN_WP_VER_REQUIRED', '4.1');
112
+		define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
113
+		define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
114
+		define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
115 115
 
116 116
 		//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
117
-		if ( ! defined( 'DS' ) ) {
118
-			define( 'DS', '/' );
117
+		if ( ! defined('DS')) {
118
+			define('DS', '/');
119 119
 		}
120
-		if ( ! defined( 'PS' ) ) {
121
-			define( 'PS', PATH_SEPARATOR );
120
+		if ( ! defined('PS')) {
121
+			define('PS', PATH_SEPARATOR);
122 122
 		}
123
-		if ( ! defined( 'SP' ) ) {
124
-			define( 'SP', ' ' );
123
+		if ( ! defined('SP')) {
124
+			define('SP', ' ');
125 125
 		}
126
-		if ( ! defined( 'EENL' ) ) {
127
-			define( 'EENL', "\n" );
126
+		if ( ! defined('EENL')) {
127
+			define('EENL', "\n");
128 128
 		}
129
-		define( 'EE_SUPPORT_EMAIL', '[email protected]' );
129
+		define('EE_SUPPORT_EMAIL', '[email protected]');
130 130
 		// define the plugin directory and URL
131
-		define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) );
132
-		define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) );
133
-		define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) );
131
+		define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
132
+		define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
133
+		define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
134 134
 		// main root folder paths
135
-		define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS );
136
-		define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS );
137
-		define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS );
138
-		define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS );
139
-		define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS );
140
-		define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS );
141
-		define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS );
142
-		define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS );
135
+		define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
136
+		define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
137
+		define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
138
+		define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
139
+		define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
140
+		define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
141
+		define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
142
+		define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
143 143
 		// core system paths
144
-		define( 'EE_ADMIN', EE_CORE . 'admin' . DS );
145
-		define( 'EE_CPTS', EE_CORE . 'CPTs' . DS );
146
-		define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS );
147
-		define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS );
148
-		define( 'EE_BUSINESS', EE_CORE . 'business' . DS );
149
-		define( 'EE_MODELS', EE_CORE . 'db_models' . DS );
150
-		define( 'EE_HELPERS', EE_CORE . 'helpers' . DS );
151
-		define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS );
152
-		define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS );
153
-		define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS );
154
-		define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS );
155
-		define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS );
144
+		define('EE_ADMIN', EE_CORE.'admin'.DS);
145
+		define('EE_CPTS', EE_CORE.'CPTs'.DS);
146
+		define('EE_CLASSES', EE_CORE.'db_classes'.DS);
147
+		define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
148
+		define('EE_BUSINESS', EE_CORE.'business'.DS);
149
+		define('EE_MODELS', EE_CORE.'db_models'.DS);
150
+		define('EE_HELPERS', EE_CORE.'helpers'.DS);
151
+		define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
152
+		define('EE_TEMPLATES', EE_CORE.'templates'.DS);
153
+		define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
154
+		define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
155
+		define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
156 156
 		// gateways
157
-		define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS );
158
-		define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS );
157
+		define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
158
+		define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
159 159
 		// asset URL paths
160
-		define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS );
161
-		define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS );
162
-		define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS );
163
-		define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS );
164
-		define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' );
165
-		define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' );
160
+		define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
161
+		define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
162
+		define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
163
+		define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
164
+		define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
165
+		define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
166 166
 		// define upload paths
167 167
 		$uploads = wp_upload_dir();
168 168
 		// define the uploads directory and URL
169
-		define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS );
170
-		define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS );
169
+		define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
170
+		define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
171 171
 		// define the templates directory and URL
172
-		define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS );
173
-		define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS );
172
+		define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
173
+		define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
174 174
 		// define the gateway directory and URL
175
-		define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS );
176
-		define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS );
175
+		define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
176
+		define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
177 177
 		// languages folder/path
178
-		define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS );
179
-		define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS );
178
+		define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
179
+		define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
180 180
 		//check for dompdf fonts in uploads
181
-		if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) {
182
-			define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS );
181
+		if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
182
+			define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
183 183
 		}
184 184
 		//ajax constants
185 185
 		define(
186 186
 			'EE_FRONT_AJAX',
187
-			isset( $_REQUEST['ee_front_ajax'] ) || isset( $_REQUEST['data']['ee_front_ajax'] ) ? true : false
187
+			isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false
188 188
 		);
189 189
 		define(
190 190
 			'EE_ADMIN_AJAX',
191
-			isset( $_REQUEST['ee_admin_ajax'] ) || isset( $_REQUEST['data']['ee_admin_ajax'] ) ? true : false
191
+			isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false
192 192
 		);
193 193
 		//just a handy constant occasionally needed for finding values representing infinity in the DB
194 194
 		//you're better to use this than its straight value (currently -1) in case you ever
195 195
 		//want to change its default value! or find when -1 means infinity
196
-		define( 'EE_INF_IN_DB', -1 );
197
-		define( 'EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX );
198
-		define( 'EE_DEBUG', false );
196
+		define('EE_INF_IN_DB', -1);
197
+		define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
198
+		define('EE_DEBUG', false);
199 199
 
200 200
 
201 201
 		/**
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 		 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
204 204
 		 */
205 205
 		function espresso_plugin_activation() {
206
-			update_option( 'ee_espresso_activation', true );
206
+			update_option('ee_espresso_activation', true);
207 207
 		}
208
-		register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' );
208
+		register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
209 209
 
210 210
 
211 211
 
@@ -215,15 +215,15 @@  discard block
 block discarded – undo
215 215
 		 */
216 216
 		function espresso_load_error_handling() {
217 217
 			// load debugging tools
218
-			if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) {
219
-				require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' );
218
+			if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
219
+				require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php');
220 220
 				EEH_Debug_Tools::instance();
221 221
 			}
222 222
 			// load error handling
223
-			if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) {
224
-				require_once( EE_CORE . 'EE_Error.core.php' );
223
+			if (is_readable(EE_CORE.'EE_Error.core.php')) {
224
+				require_once(EE_CORE.'EE_Error.core.php');
225 225
 			} else {
226
-				wp_die( esc_html__( 'The EE_Error core class could not be loaded.', 'event_espresso' ) );
226
+				wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso'));
227 227
 			}
228 228
 		}
229 229
 
@@ -237,16 +237,16 @@  discard block
 block discarded – undo
237 237
 		 * @param    string $full_path_to_file
238 238
 		 * @throws    EE_Error
239 239
 		 */
240
-		function espresso_load_required( $classname, $full_path_to_file ) {
240
+		function espresso_load_required($classname, $full_path_to_file) {
241 241
 			static $error_handling_loaded = false;
242
-			if ( ! $error_handling_loaded ) {
242
+			if ( ! $error_handling_loaded) {
243 243
 				espresso_load_error_handling();
244 244
 				$error_handling_loaded = true;
245 245
 			}
246
-			if ( is_readable( $full_path_to_file ) ) {
247
-				require_once( $full_path_to_file );
246
+			if (is_readable($full_path_to_file)) {
247
+				require_once($full_path_to_file);
248 248
 			} else {
249
-				throw new EE_Error (
249
+				throw new EE_Error(
250 250
 					sprintf(
251 251
 						esc_html__(
252 252
 							'The %s class file could not be located or is not readable due to file permissions.',
@@ -258,15 +258,15 @@  discard block
 block discarded – undo
258 258
 			}
259 259
 		}
260 260
 
261
-		espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' );
262
-		espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' );
263
-		espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' );
261
+		espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php');
262
+		espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php');
263
+		espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
264 264
 		new EE_Bootstrap();
265 265
 
266 266
 	}
267 267
 }
268 268
 
269
-if ( ! function_exists( 'espresso_deactivate_plugin' ) ) {
269
+if ( ! function_exists('espresso_deactivate_plugin')) {
270 270
 
271 271
 	/**
272 272
 	 *    deactivate_plugin
@@ -276,12 +276,12 @@  discard block
 block discarded – undo
276 276
 	 * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
277 277
 	 * @return    void
278 278
 	 */
279
-	function espresso_deactivate_plugin( $plugin_basename = '' ) {
280
-		if ( ! function_exists( 'deactivate_plugins' ) ) {
281
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
279
+	function espresso_deactivate_plugin($plugin_basename = '') {
280
+		if ( ! function_exists('deactivate_plugins')) {
281
+			require_once(ABSPATH.'wp-admin/includes/plugin.php');
282 282
 		}
283
-		unset( $_GET['activate'], $_REQUEST['activate'] );
284
-		deactivate_plugins( $plugin_basename );
283
+		unset($_GET['activate'], $_REQUEST['activate']);
284
+		deactivate_plugins($plugin_basename);
285 285
 	}
286 286
 
287 287
 }
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page.core.php 2 patches
Indentation   +542 added lines, -542 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -28,562 +28,562 @@  discard block
 block discarded – undo
28 28
 {
29 29
 
30 30
 
31
-    public function __construct($routing = true)
32
-    {
33
-        parent::__construct($routing);
34
-    }
35
-
36
-
37
-
38
-    protected function _init_page_props()
39
-    {
40
-        $this->page_slug = EE_MAINTENANCE_PG_SLUG;
41
-        $this->page_label = EE_MAINTENANCE_LABEL;
42
-        $this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL;
43
-        $this->_admin_base_path = EE_MAINTENANCE_ADMIN;
44
-    }
45
-
46
-
47
-
48
-    protected function _ajax_hooks()
49
-    {
50
-        add_action('wp_ajax_migration_step', array($this, 'migration_step'));
51
-        add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran'));
52
-    }
53
-
54
-
55
-
56
-    protected function _define_page_props()
57
-    {
58
-        $this->_admin_page_title = EE_MAINTENANCE_LABEL;
59
-        $this->_labels = array(
60
-            'buttons' => array(
61
-                'reset_capabilities' => __('Reset Event Espresso Capabilities', 'event_espresso'),
62
-            ),
63
-        );
64
-    }
65
-
66
-
67
-
68
-    protected function _set_page_routes()
69
-    {
70
-        $this->_page_routes = array(
71
-            'default'                             => array(
72
-                'func'       => '_maintenance',
73
-                'capability' => 'manage_options',
74
-            ),
75
-            'change_maintenance_level'            => array(
76
-                'func'       => '_change_maintenance_level',
77
-                'capability' => 'manage_options',
78
-                'noheader'   => true,
79
-            ),
80
-            'system_status'                       => array(
81
-                'func'       => '_system_status',
82
-                'capability' => 'manage_options',
83
-            ),
84
-            'send_migration_crash_report'         => array(
85
-                'func'       => '_send_migration_crash_report',
86
-                'capability' => 'manage_options',
87
-                'noheader'   => true,
88
-            ),
89
-            'confirm_migration_crash_report_sent' => array(
90
-                'func'       => '_confirm_migration_crash_report_sent',
91
-                'capability' => 'manage_options',
92
-            ),
93
-            'data_reset'                          => array(
94
-                'func'       => '_data_reset_and_delete',
95
-                'capability' => 'manage_options',
96
-            ),
97
-            'reset_db'                            => array(
98
-                'func'       => '_reset_db',
99
-                'capability' => 'manage_options',
100
-                'noheader'   => true,
101
-                'args'       => array('nuke_old_ee4_data' => true),
102
-            ),
103
-            'start_with_fresh_ee4_db'             => array(
104
-                'func'       => '_reset_db',
105
-                'capability' => 'manage_options',
106
-                'noheader'   => true,
107
-                'args'       => array('nuke_old_ee4_data' => false),
108
-            ),
109
-            'delete_db'                           => array(
110
-                'func'       => '_delete_db',
111
-                'capability' => 'manage_options',
112
-                'noheader'   => true,
113
-            ),
114
-            'rerun_migration_from_ee3'            => array(
115
-                'func'       => '_rerun_migration_from_ee3',
116
-                'capability' => 'manage_options',
117
-                'noheader'   => true,
118
-            ),
119
-            'reset_capabilities'                  => array(
120
-                'func'       => '_reset_capabilities',
121
-                'capability' => 'manage_options',
122
-                'noheader'   => true,
123
-            ),
124
-            'reattempt_migration'                 => array(
125
-                'func'       => '_reattempt_migration',
126
-                'capability' => 'manage_options',
127
-                'noheader'   => true,
128
-            ),
129
-        );
130
-    }
131
-
132
-
133
-
134
-    protected function _set_page_config()
135
-    {
136
-        $this->_page_config = array(
137
-            'default'       => array(
138
-                'nav'           => array(
139
-                    'label' => __('Maintenance', 'event_espresso'),
140
-                    'order' => 10,
141
-                ),
142
-                'require_nonce' => false,
143
-            ),
144
-            'data_reset'    => array(
145
-                'nav'           => array(
146
-                    'label' => __('Reset/Delete Data', 'event_espresso'),
147
-                    'order' => 20,
148
-                ),
149
-                'require_nonce' => false,
150
-            ),
151
-            'system_status' => array(
152
-                'nav'           => array(
153
-                    'label' => __("System Information", "event_espresso"),
154
-                    'order' => 30,
155
-                ),
156
-                'require_nonce' => false,
157
-            ),
158
-        );
159
-    }
160
-
161
-
162
-
163
-    /**
164
-     * default maintenance page. If we're in maintenance mode level 2, then we need to show
165
-     * the migration scripts and all that UI.
166
-     */
167
-    public function _maintenance()
168
-    {
169
-        //it all depends if we're in maintenance model level 1 (frontend-only) or
170
-        //level 2 (everything except maintenance page)
171
-        try {
172
-            //get the current maintenance level and check if
173
-            //we are removed
174
-            $mm = EE_Maintenance_Mode::instance()->level();
175
-            $placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
176
-            if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
177
-                //we just took the site out of maintenance mode, so notify the user.
178
-                //unfortunately this message appears to be echoed on the NEXT page load...
179
-                //oh well, we should really be checking for this on addon deactivation anyways
180
-                EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required',
181
-                    'event_espresso'));
182
-                $this->_process_notices(array('page' => 'espresso_maintenance_settings'), false);
183
-            }
184
-            //in case an exception is thrown while trying to handle migrations
185
-            switch (EE_Maintenance_Mode::instance()->level()) {
186
-                case EE_Maintenance_Mode::level_0_not_in_maintenance:
187
-                case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
188
-                    $show_maintenance_switch = true;
189
-                    $show_backup_db_text = false;
190
-                    $show_migration_progress = false;
191
-                    $script_names = array();
192
-                    $addons_should_be_upgraded_first = false;
193
-                    break;
194
-                case EE_Maintenance_Mode::level_2_complete_maintenance:
195
-                    $show_maintenance_switch = false;
196
-                    $show_migration_progress = true;
197
-                    if (isset($this->_req_data['continue_migration'])) {
198
-                        $show_backup_db_text = false;
199
-                    } else {
200
-                        $show_backup_db_text = true;
201
-                    }
202
-                    $scripts_needing_to_run = EE_Data_Migration_Manager::instance()
203
-                                                                       ->check_for_applicable_data_migration_scripts();
204
-                    $addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();
205
-                    $script_names = array();
206
-                    $current_script = null;
207
-                    foreach ($scripts_needing_to_run as $script) {
208
-                        if ($script instanceof EE_Data_Migration_Script_Base) {
209
-                            if ( ! $current_script) {
210
-                                $current_script = $script;
211
-                                $current_script->migration_page_hooks();
212
-                            }
213
-                            $script_names[] = $script->pretty_name();
214
-                        }
215
-                    }
216
-                    break;
217
-            }
218
-            $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
219
-            $exception_thrown = false;
220
-        } catch (EE_Error $e) {
221
-            EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
222
-            //now, just so we can display the page correctly, make a error migration script stage object
223
-            //and also put the error on it. It only persists for the duration of this request
224
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
225
-            $most_recent_migration->add_error($e->getMessage());
226
-            $exception_thrown = true;
227
-        }
228
-        $current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();
229
-        $current_db_state = str_replace('.decaf', '', $current_db_state);
230
-        if ($exception_thrown
231
-            || ($most_recent_migration
232
-                && $most_recent_migration instanceof EE_Data_Migration_Script_Base
233
-                && $most_recent_migration->is_broken()
234
-            )
235
-        ) {
236
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
237
-            $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
238
-            $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
239
-                                                                                        'success' => '0',
240
-            ), EE_MAINTENANCE_ADMIN_URL);
241
-        } elseif ($addons_should_be_upgraded_first) {
242
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
243
-        } else {
244
-            if ($most_recent_migration
245
-                && $most_recent_migration instanceof EE_Data_Migration_Script_Base
246
-                && $most_recent_migration->can_continue()
247
-            ) {
248
-                $show_backup_db_text = false;
249
-                $show_continue_current_migration_script = true;
250
-                $show_most_recent_migration = true;
251
-            } elseif (isset($this->_req_data['continue_migration'])) {
252
-                $show_most_recent_migration = true;
253
-                $show_continue_current_migration_script = false;
254
-            } else {
255
-                $show_most_recent_migration = false;
256
-                $show_continue_current_migration_script = false;
257
-            }
258
-            if (isset($current_script)) {
259
-                $migrates_to = $current_script->migrates_to_version();
260
-                $plugin_slug = $migrates_to['slug'];
261
-                $new_version = $migrates_to['version'];
262
-                $this->_template_args = array_merge($this->_template_args, array(
263
-                    'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"),
264
-                        isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug),
265
-                    'next_db_state'    => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'),
266
-                        $new_version, $plugin_slug) : null,
267
-                ));
268
-            }
269
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
270
-            $this->_template_args = array_merge(
271
-                $this->_template_args,
272
-                array(
273
-                    'show_most_recent_migration'             => $show_most_recent_migration,
274
-                    //flag for showing the most recent migration's status and/or errors
275
-                    'show_migration_progress'                => $show_migration_progress,
276
-                    //flag for showing the option to run migrations and see their progress
277
-                    'show_backup_db_text'                    => $show_backup_db_text,
278
-                    //flag for showing text telling the user to backup their DB
279
-                    'show_maintenance_switch'                => $show_maintenance_switch,
280
-                    //flag for showing the option to change maintenance mode between levels 0 and 1
281
-                    'script_names'                           => $script_names,
282
-                    //array of names of scripts that have run
283
-                    'show_continue_current_migration_script' => $show_continue_current_migration_script,
284
-                    //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
285
-                    'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
286
-                        EE_MAINTENANCE_ADMIN_URL),
287
-                    'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'),
288
-                        EE_MAINTENANCE_ADMIN_URL),
289
-                    'ultimate_db_state'                      => sprintf(__("EE%s", 'event_espresso'),
290
-                        espresso_version()),
291
-                )
292
-            );
293
-            //make sure we have the form fields helper available. It usually is, but sometimes it isn't
294
-            //localize script stuff
295
-            wp_localize_script('ee-maintenance', 'ee_maintenance', array(
296
-                'migrating'                        => __("Migrating...", "event_espresso"),
297
-                'next'                             => __("Next", "event_espresso"),
298
-                'fatal_error'                      => __("A Fatal Error Has Occurred", "event_espresso"),
299
-                'click_next_when_ready'            => __("The current Migration has ended. Click 'next' when ready to proceed",
300
-                    "event_espresso"),
301
-                'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
302
-                'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
303
-                'status_completed'                 => EE_Data_Migration_Manager::status_completed,
304
-            ));
305
-        }
306
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
307
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
308
-            $this->_template_args, true);
309
-        $this->display_admin_page_with_sidebar();
310
-    }
311
-
312
-
313
-
314
-    /**
315
-     * returns JSON and executes another step of the currently-executing data migration (called via ajax)
316
-     */
317
-    public function migration_step()
318
-    {
319
-        $this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();
320
-        $this->_return_json();
321
-    }
322
-
323
-
324
-
325
-    /**
326
-     * Can be used by js when it notices a response with HTML in it in order
327
-     * to log the malformed response
328
-     */
329
-    public function add_error_to_migrations_ran()
330
-    {
331
-        EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);
332
-        $this->_template_args['data'] = array('ok' => true);
333
-        $this->_return_json();
334
-    }
335
-
336
-
337
-
338
-    /**
339
-     * changes the maintenance level, provided there are still no migration scripts that shoudl run
340
-     */
341
-    public function _change_maintenance_level()
342
-    {
343
-        $new_level = intval($this->_req_data['maintenance_mode_level']);
344
-        if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
345
-            EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);
346
-            $success = true;
347
-        } else {
348
-            EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
349
-            $success = false;
350
-        }
351
-        $this->_redirect_after_action($success, 'Maintenance Mode', __("Updated", "event_espresso"));
352
-    }
353
-
354
-
355
-
356
-    /**
357
-     * a tab with options for resetting and/or deleting EE data
358
-     *
359
-     * @throws \EE_Error
360
-     */
361
-    public function _data_reset_and_delete()
362
-    {
363
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
364
-        $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
365
-            'reset_capabilities',
366
-            'reset_capabilities',
367
-            array(),
368
-            'button button-primary',
369
-            '',
370
-            false
371
-        );
372
-        $this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
373
-            array('action' => 'delete_db'),
374
-            EE_MAINTENANCE_ADMIN_URL
375
-        );
376
-        $this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
377
-            array('action' => 'reset_db'),
378
-            EE_MAINTENANCE_ADMIN_URL
379
-        );
380
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
381
-            $this->_template_path,
382
-            $this->_template_args,
383
-            true
384
-        );
385
-        $this->display_admin_page_with_sidebar();
386
-    }
387
-
388
-
389
-
390
-    protected function _reset_capabilities()
391
-    {
392
-        EE_Registry::instance()->CAP->init_caps(true);
393
-        EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.',
394
-            'event_espresso'));
395
-        $this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true);
396
-    }
397
-
398
-
399
-
400
-    /**
401
-     * resets the DMSs so we can attempt to continue migrating after a fatal error
402
-     * (only a good idea when someone has somehow tried ot fix whatever caused
403
-     * the fatal error in teh first place)
404
-     */
405
-    protected function _reattempt_migration()
406
-    {
407
-        EE_Data_Migration_Manager::instance()->reattempt();
408
-        $this->_redirect_after_action(false, '', '', array('action' => 'default'), true);
409
-    }
410
-
411
-
412
-
413
-    /**
414
-     * shows the big ol' System Information page
415
-     */
416
-    public function _system_status()
417
-    {
418
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
419
-        $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
420
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
421
-            $this->_template_args, true);
422
-        $this->display_admin_page_with_sidebar();
423
-    }
424
-
425
-
426
-
427
-    public function _send_migration_crash_report()
428
-    {
429
-        $from = $this->_req_data['from'];
430
-        $from_name = $this->_req_data['from_name'];
431
-        $body = $this->_req_data['body'];
432
-        try {
433
-            $success = wp_mail(EE_SUPPORT_EMAIL,
434
-                'Migration Crash Report',
435
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
436
-                array(
437
-                    "from:$from_name<$from>",
438
-                    //					'content-type:text/html charset=UTF-8'
439
-                ));
440
-        } catch (Exception $e) {
441
-            $success = false;
442
-        }
443
-        $this->_redirect_after_action($success, __("Migration Crash Report", "event_espresso"),
444
-            __("sent", "event_espresso"),
445
-            array('success' => $success, 'action' => 'confirm_migration_crash_report_sent'));
446
-    }
447
-
448
-
449
-
450
-    public function _confirm_migration_crash_report_sent()
451
-    {
452
-        try {
453
-            $most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
454
-        } catch (EE_Error $e) {
455
-            EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
456
-            //now, just so we can display the page correctly, make a error migration script stage object
457
-            //and also put the error on it. It only persists for the duration of this request
458
-            $most_recent_migration = new EE_DMS_Unknown_1_0_0();
459
-            $most_recent_migration->add_error($e->getMessage());
460
-        }
461
-        $success = $this->_req_data['success'] == '1' ? true : false;
462
-        $this->_template_args['success'] = $success;
463
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;
464
-        $this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
465
-            EE_MAINTENANCE_ADMIN_URL);
466
-        $this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
467
-            EE_MAINTENANCE_ADMIN_URL);
468
-        $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
469
-            EE_MAINTENANCE_ADMIN_URL);
470
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
471
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
472
-            $this->_template_args, true);
473
-        $this->display_admin_page_with_sidebar();
474
-    }
475
-
476
-
477
-
478
-    /**
479
-     * Resets the entire EE4 database.
480
-     * Currently basically only sets up ee4 database for a fresh install- doesn't
481
-     * actually clean out the old wp options, or cpts (although does erase old ee table data)
482
-     *
483
-     * @param boolean $nuke_old_ee4_data controls whether or not we
484
-     *                                   destroy the old ee4 data, or just try initializing ee4 default data
485
-     */
486
-    public function _reset_db($nuke_old_ee4_data = true)
487
-    {
488
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
489
-        if ($nuke_old_ee4_data) {
490
-            EEH_Activation::delete_all_espresso_cpt_data();
491
-            EEH_Activation::delete_all_espresso_tables_and_data(false);
492
-            EEH_Activation::remove_cron_tasks();
493
-        }
494
-        //make sure when we reset the registry's config that it
495
-        //switches to using the new singleton
496
-        EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
497
-        EE_System::instance()->initialize_db_if_no_migrations_required(true);
498
-        EE_System::instance()->redirect_to_about_ee();
499
-    }
500
-
501
-
502
-
503
-    /**
504
-     * Deletes ALL EE tables, Records, and Options from the database.
505
-     */
506
-    public function _delete_db()
507
-    {
508
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
509
-        EEH_Activation::delete_all_espresso_cpt_data();
510
-        EEH_Activation::delete_all_espresso_tables_and_data();
511
-        EEH_Activation::remove_cron_tasks();
512
-        EEH_Activation::deactivate_event_espresso();
513
-        wp_safe_redirect(admin_url('plugins.php'));
514
-        exit;
515
-    }
516
-
517
-
518
-
519
-    /**
520
-     * sets up EE4 to rerun the migrations from ee3 to ee4
521
-     */
522
-    public function _rerun_migration_from_ee3()
523
-    {
524
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
525
-        EEH_Activation::delete_all_espresso_cpt_data();
526
-        EEH_Activation::delete_all_espresso_tables_and_data(false);
527
-        //set the db state to something that will require migrations
528
-        update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
529
-        EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);
530
-        $this->_redirect_after_action(true, __("Database", 'event_espresso'), __("reset", 'event_espresso'));
531
-    }
532
-
533
-
534
-
535
-    //none of the below group are currently used for Gateway Settings
536
-    protected function _add_screen_options()
537
-    {
538
-    }
539
-
540
-
541
-
542
-    protected function _add_feature_pointers()
543
-    {
544
-    }
545
-
31
+	public function __construct($routing = true)
32
+	{
33
+		parent::__construct($routing);
34
+	}
35
+
36
+
37
+
38
+	protected function _init_page_props()
39
+	{
40
+		$this->page_slug = EE_MAINTENANCE_PG_SLUG;
41
+		$this->page_label = EE_MAINTENANCE_LABEL;
42
+		$this->_admin_base_url = EE_MAINTENANCE_ADMIN_URL;
43
+		$this->_admin_base_path = EE_MAINTENANCE_ADMIN;
44
+	}
45
+
46
+
47
+
48
+	protected function _ajax_hooks()
49
+	{
50
+		add_action('wp_ajax_migration_step', array($this, 'migration_step'));
51
+		add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran'));
52
+	}
53
+
54
+
55
+
56
+	protected function _define_page_props()
57
+	{
58
+		$this->_admin_page_title = EE_MAINTENANCE_LABEL;
59
+		$this->_labels = array(
60
+			'buttons' => array(
61
+				'reset_capabilities' => __('Reset Event Espresso Capabilities', 'event_espresso'),
62
+			),
63
+		);
64
+	}
65
+
66
+
67
+
68
+	protected function _set_page_routes()
69
+	{
70
+		$this->_page_routes = array(
71
+			'default'                             => array(
72
+				'func'       => '_maintenance',
73
+				'capability' => 'manage_options',
74
+			),
75
+			'change_maintenance_level'            => array(
76
+				'func'       => '_change_maintenance_level',
77
+				'capability' => 'manage_options',
78
+				'noheader'   => true,
79
+			),
80
+			'system_status'                       => array(
81
+				'func'       => '_system_status',
82
+				'capability' => 'manage_options',
83
+			),
84
+			'send_migration_crash_report'         => array(
85
+				'func'       => '_send_migration_crash_report',
86
+				'capability' => 'manage_options',
87
+				'noheader'   => true,
88
+			),
89
+			'confirm_migration_crash_report_sent' => array(
90
+				'func'       => '_confirm_migration_crash_report_sent',
91
+				'capability' => 'manage_options',
92
+			),
93
+			'data_reset'                          => array(
94
+				'func'       => '_data_reset_and_delete',
95
+				'capability' => 'manage_options',
96
+			),
97
+			'reset_db'                            => array(
98
+				'func'       => '_reset_db',
99
+				'capability' => 'manage_options',
100
+				'noheader'   => true,
101
+				'args'       => array('nuke_old_ee4_data' => true),
102
+			),
103
+			'start_with_fresh_ee4_db'             => array(
104
+				'func'       => '_reset_db',
105
+				'capability' => 'manage_options',
106
+				'noheader'   => true,
107
+				'args'       => array('nuke_old_ee4_data' => false),
108
+			),
109
+			'delete_db'                           => array(
110
+				'func'       => '_delete_db',
111
+				'capability' => 'manage_options',
112
+				'noheader'   => true,
113
+			),
114
+			'rerun_migration_from_ee3'            => array(
115
+				'func'       => '_rerun_migration_from_ee3',
116
+				'capability' => 'manage_options',
117
+				'noheader'   => true,
118
+			),
119
+			'reset_capabilities'                  => array(
120
+				'func'       => '_reset_capabilities',
121
+				'capability' => 'manage_options',
122
+				'noheader'   => true,
123
+			),
124
+			'reattempt_migration'                 => array(
125
+				'func'       => '_reattempt_migration',
126
+				'capability' => 'manage_options',
127
+				'noheader'   => true,
128
+			),
129
+		);
130
+	}
131
+
132
+
133
+
134
+	protected function _set_page_config()
135
+	{
136
+		$this->_page_config = array(
137
+			'default'       => array(
138
+				'nav'           => array(
139
+					'label' => __('Maintenance', 'event_espresso'),
140
+					'order' => 10,
141
+				),
142
+				'require_nonce' => false,
143
+			),
144
+			'data_reset'    => array(
145
+				'nav'           => array(
146
+					'label' => __('Reset/Delete Data', 'event_espresso'),
147
+					'order' => 20,
148
+				),
149
+				'require_nonce' => false,
150
+			),
151
+			'system_status' => array(
152
+				'nav'           => array(
153
+					'label' => __("System Information", "event_espresso"),
154
+					'order' => 30,
155
+				),
156
+				'require_nonce' => false,
157
+			),
158
+		);
159
+	}
160
+
161
+
162
+
163
+	/**
164
+	 * default maintenance page. If we're in maintenance mode level 2, then we need to show
165
+	 * the migration scripts and all that UI.
166
+	 */
167
+	public function _maintenance()
168
+	{
169
+		//it all depends if we're in maintenance model level 1 (frontend-only) or
170
+		//level 2 (everything except maintenance page)
171
+		try {
172
+			//get the current maintenance level and check if
173
+			//we are removed
174
+			$mm = EE_Maintenance_Mode::instance()->level();
175
+			$placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
176
+			if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
177
+				//we just took the site out of maintenance mode, so notify the user.
178
+				//unfortunately this message appears to be echoed on the NEXT page load...
179
+				//oh well, we should really be checking for this on addon deactivation anyways
180
+				EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required',
181
+					'event_espresso'));
182
+				$this->_process_notices(array('page' => 'espresso_maintenance_settings'), false);
183
+			}
184
+			//in case an exception is thrown while trying to handle migrations
185
+			switch (EE_Maintenance_Mode::instance()->level()) {
186
+				case EE_Maintenance_Mode::level_0_not_in_maintenance:
187
+				case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
188
+					$show_maintenance_switch = true;
189
+					$show_backup_db_text = false;
190
+					$show_migration_progress = false;
191
+					$script_names = array();
192
+					$addons_should_be_upgraded_first = false;
193
+					break;
194
+				case EE_Maintenance_Mode::level_2_complete_maintenance:
195
+					$show_maintenance_switch = false;
196
+					$show_migration_progress = true;
197
+					if (isset($this->_req_data['continue_migration'])) {
198
+						$show_backup_db_text = false;
199
+					} else {
200
+						$show_backup_db_text = true;
201
+					}
202
+					$scripts_needing_to_run = EE_Data_Migration_Manager::instance()
203
+																	   ->check_for_applicable_data_migration_scripts();
204
+					$addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();
205
+					$script_names = array();
206
+					$current_script = null;
207
+					foreach ($scripts_needing_to_run as $script) {
208
+						if ($script instanceof EE_Data_Migration_Script_Base) {
209
+							if ( ! $current_script) {
210
+								$current_script = $script;
211
+								$current_script->migration_page_hooks();
212
+							}
213
+							$script_names[] = $script->pretty_name();
214
+						}
215
+					}
216
+					break;
217
+			}
218
+			$most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
219
+			$exception_thrown = false;
220
+		} catch (EE_Error $e) {
221
+			EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
222
+			//now, just so we can display the page correctly, make a error migration script stage object
223
+			//and also put the error on it. It only persists for the duration of this request
224
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
225
+			$most_recent_migration->add_error($e->getMessage());
226
+			$exception_thrown = true;
227
+		}
228
+		$current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();
229
+		$current_db_state = str_replace('.decaf', '', $current_db_state);
230
+		if ($exception_thrown
231
+			|| ($most_recent_migration
232
+				&& $most_recent_migration instanceof EE_Data_Migration_Script_Base
233
+				&& $most_recent_migration->is_broken()
234
+			)
235
+		) {
236
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
237
+			$this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
238
+			$this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
239
+																						'success' => '0',
240
+			), EE_MAINTENANCE_ADMIN_URL);
241
+		} elseif ($addons_should_be_upgraded_first) {
242
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
243
+		} else {
244
+			if ($most_recent_migration
245
+				&& $most_recent_migration instanceof EE_Data_Migration_Script_Base
246
+				&& $most_recent_migration->can_continue()
247
+			) {
248
+				$show_backup_db_text = false;
249
+				$show_continue_current_migration_script = true;
250
+				$show_most_recent_migration = true;
251
+			} elseif (isset($this->_req_data['continue_migration'])) {
252
+				$show_most_recent_migration = true;
253
+				$show_continue_current_migration_script = false;
254
+			} else {
255
+				$show_most_recent_migration = false;
256
+				$show_continue_current_migration_script = false;
257
+			}
258
+			if (isset($current_script)) {
259
+				$migrates_to = $current_script->migrates_to_version();
260
+				$plugin_slug = $migrates_to['slug'];
261
+				$new_version = $migrates_to['version'];
262
+				$this->_template_args = array_merge($this->_template_args, array(
263
+					'current_db_state' => sprintf(__("EE%s (%s)", "event_espresso"),
264
+						isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug),
265
+					'next_db_state'    => isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'),
266
+						$new_version, $plugin_slug) : null,
267
+				));
268
+			}
269
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
270
+			$this->_template_args = array_merge(
271
+				$this->_template_args,
272
+				array(
273
+					'show_most_recent_migration'             => $show_most_recent_migration,
274
+					//flag for showing the most recent migration's status and/or errors
275
+					'show_migration_progress'                => $show_migration_progress,
276
+					//flag for showing the option to run migrations and see their progress
277
+					'show_backup_db_text'                    => $show_backup_db_text,
278
+					//flag for showing text telling the user to backup their DB
279
+					'show_maintenance_switch'                => $show_maintenance_switch,
280
+					//flag for showing the option to change maintenance mode between levels 0 and 1
281
+					'script_names'                           => $script_names,
282
+					//array of names of scripts that have run
283
+					'show_continue_current_migration_script' => $show_continue_current_migration_script,
284
+					//flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
285
+					'reset_db_page_link'                     => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
286
+						EE_MAINTENANCE_ADMIN_URL),
287
+					'update_migration_script_page_link'      => EE_Admin_Page::add_query_args_and_nonce(array('action' => 'change_maintenance_level'),
288
+						EE_MAINTENANCE_ADMIN_URL),
289
+					'ultimate_db_state'                      => sprintf(__("EE%s", 'event_espresso'),
290
+						espresso_version()),
291
+				)
292
+			);
293
+			//make sure we have the form fields helper available. It usually is, but sometimes it isn't
294
+			//localize script stuff
295
+			wp_localize_script('ee-maintenance', 'ee_maintenance', array(
296
+				'migrating'                        => __("Migrating...", "event_espresso"),
297
+				'next'                             => __("Next", "event_espresso"),
298
+				'fatal_error'                      => __("A Fatal Error Has Occurred", "event_espresso"),
299
+				'click_next_when_ready'            => __("The current Migration has ended. Click 'next' when ready to proceed",
300
+					"event_espresso"),
301
+				'status_no_more_migration_scripts' => EE_Data_Migration_Manager::status_no_more_migration_scripts,
302
+				'status_fatal_error'               => EE_Data_Migration_Manager::status_fatal_error,
303
+				'status_completed'                 => EE_Data_Migration_Manager::status_completed,
304
+			));
305
+		}
306
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
307
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
308
+			$this->_template_args, true);
309
+		$this->display_admin_page_with_sidebar();
310
+	}
311
+
312
+
313
+
314
+	/**
315
+	 * returns JSON and executes another step of the currently-executing data migration (called via ajax)
316
+	 */
317
+	public function migration_step()
318
+	{
319
+		$this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();
320
+		$this->_return_json();
321
+	}
322
+
323
+
324
+
325
+	/**
326
+	 * Can be used by js when it notices a response with HTML in it in order
327
+	 * to log the malformed response
328
+	 */
329
+	public function add_error_to_migrations_ran()
330
+	{
331
+		EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);
332
+		$this->_template_args['data'] = array('ok' => true);
333
+		$this->_return_json();
334
+	}
335
+
336
+
337
+
338
+	/**
339
+	 * changes the maintenance level, provided there are still no migration scripts that shoudl run
340
+	 */
341
+	public function _change_maintenance_level()
342
+	{
343
+		$new_level = intval($this->_req_data['maintenance_mode_level']);
344
+		if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
345
+			EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);
346
+			$success = true;
347
+		} else {
348
+			EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
349
+			$success = false;
350
+		}
351
+		$this->_redirect_after_action($success, 'Maintenance Mode', __("Updated", "event_espresso"));
352
+	}
353
+
354
+
355
+
356
+	/**
357
+	 * a tab with options for resetting and/or deleting EE data
358
+	 *
359
+	 * @throws \EE_Error
360
+	 */
361
+	public function _data_reset_and_delete()
362
+	{
363
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
364
+		$this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
365
+			'reset_capabilities',
366
+			'reset_capabilities',
367
+			array(),
368
+			'button button-primary',
369
+			'',
370
+			false
371
+		);
372
+		$this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
373
+			array('action' => 'delete_db'),
374
+			EE_MAINTENANCE_ADMIN_URL
375
+		);
376
+		$this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(
377
+			array('action' => 'reset_db'),
378
+			EE_MAINTENANCE_ADMIN_URL
379
+		);
380
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
381
+			$this->_template_path,
382
+			$this->_template_args,
383
+			true
384
+		);
385
+		$this->display_admin_page_with_sidebar();
386
+	}
387
+
388
+
389
+
390
+	protected function _reset_capabilities()
391
+	{
392
+		EE_Registry::instance()->CAP->init_caps(true);
393
+		EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.',
394
+			'event_espresso'));
395
+		$this->_redirect_after_action(false, '', '', array('action' => 'data_reset'), true);
396
+	}
397
+
398
+
399
+
400
+	/**
401
+	 * resets the DMSs so we can attempt to continue migrating after a fatal error
402
+	 * (only a good idea when someone has somehow tried ot fix whatever caused
403
+	 * the fatal error in teh first place)
404
+	 */
405
+	protected function _reattempt_migration()
406
+	{
407
+		EE_Data_Migration_Manager::instance()->reattempt();
408
+		$this->_redirect_after_action(false, '', '', array('action' => 'default'), true);
409
+	}
410
+
411
+
412
+
413
+	/**
414
+	 * shows the big ol' System Information page
415
+	 */
416
+	public function _system_status()
417
+	{
418
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
419
+		$this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
420
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
421
+			$this->_template_args, true);
422
+		$this->display_admin_page_with_sidebar();
423
+	}
424
+
425
+
426
+
427
+	public function _send_migration_crash_report()
428
+	{
429
+		$from = $this->_req_data['from'];
430
+		$from_name = $this->_req_data['from_name'];
431
+		$body = $this->_req_data['body'];
432
+		try {
433
+			$success = wp_mail(EE_SUPPORT_EMAIL,
434
+				'Migration Crash Report',
435
+				$body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
436
+				array(
437
+					"from:$from_name<$from>",
438
+					//					'content-type:text/html charset=UTF-8'
439
+				));
440
+		} catch (Exception $e) {
441
+			$success = false;
442
+		}
443
+		$this->_redirect_after_action($success, __("Migration Crash Report", "event_espresso"),
444
+			__("sent", "event_espresso"),
445
+			array('success' => $success, 'action' => 'confirm_migration_crash_report_sent'));
446
+	}
447
+
448
+
449
+
450
+	public function _confirm_migration_crash_report_sent()
451
+	{
452
+		try {
453
+			$most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
454
+		} catch (EE_Error $e) {
455
+			EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
456
+			//now, just so we can display the page correctly, make a error migration script stage object
457
+			//and also put the error on it. It only persists for the duration of this request
458
+			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
459
+			$most_recent_migration->add_error($e->getMessage());
460
+		}
461
+		$success = $this->_req_data['success'] == '1' ? true : false;
462
+		$this->_template_args['success'] = $success;
463
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;
464
+		$this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reset_db'),
465
+			EE_MAINTENANCE_ADMIN_URL);
466
+		$this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'data_reset'),
467
+			EE_MAINTENANCE_ADMIN_URL);
468
+		$this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
469
+			EE_MAINTENANCE_ADMIN_URL);
470
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
471
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
472
+			$this->_template_args, true);
473
+		$this->display_admin_page_with_sidebar();
474
+	}
475
+
476
+
477
+
478
+	/**
479
+	 * Resets the entire EE4 database.
480
+	 * Currently basically only sets up ee4 database for a fresh install- doesn't
481
+	 * actually clean out the old wp options, or cpts (although does erase old ee table data)
482
+	 *
483
+	 * @param boolean $nuke_old_ee4_data controls whether or not we
484
+	 *                                   destroy the old ee4 data, or just try initializing ee4 default data
485
+	 */
486
+	public function _reset_db($nuke_old_ee4_data = true)
487
+	{
488
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
489
+		if ($nuke_old_ee4_data) {
490
+			EEH_Activation::delete_all_espresso_cpt_data();
491
+			EEH_Activation::delete_all_espresso_tables_and_data(false);
492
+			EEH_Activation::remove_cron_tasks();
493
+		}
494
+		//make sure when we reset the registry's config that it
495
+		//switches to using the new singleton
496
+		EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(true);
497
+		EE_System::instance()->initialize_db_if_no_migrations_required(true);
498
+		EE_System::instance()->redirect_to_about_ee();
499
+	}
500
+
501
+
502
+
503
+	/**
504
+	 * Deletes ALL EE tables, Records, and Options from the database.
505
+	 */
506
+	public function _delete_db()
507
+	{
508
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
509
+		EEH_Activation::delete_all_espresso_cpt_data();
510
+		EEH_Activation::delete_all_espresso_tables_and_data();
511
+		EEH_Activation::remove_cron_tasks();
512
+		EEH_Activation::deactivate_event_espresso();
513
+		wp_safe_redirect(admin_url('plugins.php'));
514
+		exit;
515
+	}
516
+
517
+
518
+
519
+	/**
520
+	 * sets up EE4 to rerun the migrations from ee3 to ee4
521
+	 */
522
+	public function _rerun_migration_from_ee3()
523
+	{
524
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
525
+		EEH_Activation::delete_all_espresso_cpt_data();
526
+		EEH_Activation::delete_all_espresso_tables_and_data(false);
527
+		//set the db state to something that will require migrations
528
+		update_option(EE_Data_Migration_Manager::current_database_state, '3.1.36.0');
529
+		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_2_complete_maintenance);
530
+		$this->_redirect_after_action(true, __("Database", 'event_espresso'), __("reset", 'event_espresso'));
531
+	}
532
+
533
+
534
+
535
+	//none of the below group are currently used for Gateway Settings
536
+	protected function _add_screen_options()
537
+	{
538
+	}
539
+
540
+
541
+
542
+	protected function _add_feature_pointers()
543
+	{
544
+	}
545
+
546 546
 
547 547
 
548
-    public function admin_init()
549
-    {
550
-    }
551
-
552
-
553
-
554
-    public function admin_notices()
555
-    {
556
-    }
557
-
548
+	public function admin_init()
549
+	{
550
+	}
551
+
552
+
553
+
554
+	public function admin_notices()
555
+	{
556
+	}
557
+
558 558
 
559 559
 
560
-    public function admin_footer_scripts()
561
-    {
562
-    }
560
+	public function admin_footer_scripts()
561
+	{
562
+	}
563 563
 
564 564
 
565 565
 
566
-    public function load_scripts_styles()
567
-    {
568
-        wp_enqueue_script('ee_admin_js');
566
+	public function load_scripts_styles()
567
+	{
568
+		wp_enqueue_script('ee_admin_js');
569 569
 //		wp_enqueue_media();
570 570
 //		wp_enqueue_script('media-upload');
571
-        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
572
-            EVENT_ESPRESSO_VERSION, true);
573
-        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
574
-            EVENT_ESPRESSO_VERSION);
575
-        wp_enqueue_style('espresso_maintenance');
576
-    }
571
+		wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
572
+			EVENT_ESPRESSO_VERSION, true);
573
+		wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
574
+			EVENT_ESPRESSO_VERSION);
575
+		wp_enqueue_style('espresso_maintenance');
576
+	}
577 577
 
578 578
 
579 579
 
580
-    public function load_scripts_styles_default()
581
-    {
582
-        //styles
580
+	public function load_scripts_styles_default()
581
+	{
582
+		//styles
583 583
 //		wp_enqueue_style('ee-text-links');
584 584
 //		//scripts
585 585
 //		wp_enqueue_script('ee-text-links');
586
-    }
586
+	}
587 587
 
588 588
 
589 589
 
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -233,13 +233,13 @@  discard block
 block discarded – undo
233 233
                 && $most_recent_migration->is_broken()
234 234
             )
235 235
         ) {
236
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
236
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php';
237 237
             $this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
238 238
             $this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action'  => 'confirm_migration_crash_report_sent',
239 239
                                                                                         'success' => '0',
240 240
             ), EE_MAINTENANCE_ADMIN_URL);
241 241
         } elseif ($addons_should_be_upgraded_first) {
242
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
242
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php';
243 243
         } else {
244 244
             if ($most_recent_migration
245 245
                 && $most_recent_migration instanceof EE_Data_Migration_Script_Base
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
                         $new_version, $plugin_slug) : null,
267 267
                 ));
268 268
             }
269
-            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
269
+            $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php';
270 270
             $this->_template_args = array_merge(
271 271
                 $this->_template_args,
272 272
                 array(
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
                 'status_completed'                 => EE_Data_Migration_Manager::status_completed,
304 304
             ));
305 305
         }
306
-        $this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
306
+        $this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration
307 307
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
308 308
             $this->_template_args, true);
309 309
         $this->display_admin_page_with_sidebar();
@@ -360,7 +360,7 @@  discard block
 block discarded – undo
360 360
      */
361 361
     public function _data_reset_and_delete()
362 362
     {
363
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
363
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php';
364 364
         $this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button(
365 365
             'reset_capabilities',
366 366
             'reset_capabilities',
@@ -415,7 +415,7 @@  discard block
 block discarded – undo
415 415
      */
416 416
     public function _system_status()
417 417
     {
418
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
418
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php';
419 419
         $this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
420 420
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
421 421
             $this->_template_args, true);
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
         try {
433 433
             $success = wp_mail(EE_SUPPORT_EMAIL,
434 434
                 'Migration Crash Report',
435
-                $body . "/r/n<br>" . print_r(EEM_System_Status::instance()->get_system_stati(), true),
435
+                $body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true),
436 436
                 array(
437 437
                     "from:$from_name<$from>",
438 438
                     //					'content-type:text/html charset=UTF-8'
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
             EE_MAINTENANCE_ADMIN_URL);
468 468
         $this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'),
469 469
             EE_MAINTENANCE_ADMIN_URL);
470
-        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
470
+        $this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php';
471 471
         $this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,
472 472
             $this->_template_args, true);
473 473
         $this->display_admin_page_with_sidebar();
@@ -568,9 +568,9 @@  discard block
 block discarded – undo
568 568
         wp_enqueue_script('ee_admin_js');
569 569
 //		wp_enqueue_media();
570 570
 //		wp_enqueue_script('media-upload');
571
-        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL . '/ee-maintenance.js', array('jquery'),
571
+        wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'),
572 572
             EVENT_ESPRESSO_VERSION, true);
573
-        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(),
573
+        wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(),
574 574
             EVENT_ESPRESSO_VERSION);
575 575
         wp_enqueue_style('espresso_maintenance');
576 576
     }
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page_Init.core.php 2 patches
Indentation   +84 added lines, -84 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -29,91 +29,91 @@  discard block
 block discarded – undo
29 29
 {
30 30
 
31 31
 
32
-    public function __construct()
33
-    {
34
-        //define some page related constants
35
-        define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36
-        define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
-        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
-        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
-        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
-        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
41
-        //check that if we're in maintenance mode that we tell the admin that
42
-        add_action('admin_notices', array($this, 'check_maintenance_mode'));
43
-        parent::__construct();
44
-    }
45
-
46
-
47
-
48
-    protected function _set_init_properties()
49
-    {
50
-        $this->label = EE_MAINTENANCE_LABEL;
51
-    }
52
-
53
-
54
-
55
-    protected function _set_menu_map()
56
-    {
57
-        $menu_map = $this->_menu_map();
58
-        $this->_menu_map = EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
59
-            ? new EE_Admin_Page_Main_Menu($menu_map) : new EE_Admin_Page_Sub_Menu($menu_map);
60
-    }
61
-
62
-
63
-
64
-    protected function _menu_map()
65
-    {
66
-        $map = array(
67
-            'menu_group'              => 'extras',
68
-            'menu_order'              => 30,
69
-            'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
70
-            'parent_slug'             => 'espresso_events',
71
-            'menu_slug'               => EE_MAINTENANCE_PG_SLUG,
72
-            'menu_label'              => EE_MAINTENANCE_LABEL,
73
-            'capability'              => 'manage_options',
74
-            'maintenance_mode_parent' => EE_MAINTENANCE_PG_SLUG,
75
-            'admin_init_page'         => $this,
76
-        );
77
-        if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
78
-            $map['menu_group'] = 'main';
79
-            $map['subtitle'] = EE_MAINTENANCE_LABEL;
80
-            $map['menu_label'] = __('Event Espresso', 'event_espresso');
81
-        }
82
-        return $map;
83
-    }
84
-
85
-
86
-
87
-    /**
88
-     * Checks if we're in maintenance mode, and if so we notify the admin adn tell them how to take the site OUT of
89
-     * maintenance mode
90
-     */
91
-    public function check_maintenance_mode()
92
-    {
93
-        $notice = '';
94
-        $maintenance_page_url = '';
95
-        if (EE_Maintenance_Mode::instance()->level()) {
96
-            $maintenance_page_url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_MAINTENANCE_ADMIN_URL);
97
-            switch (EE_Maintenance_Mode::instance()->level()) {
98
-                case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
99
-                    $notice = '<div class="update-nag">
32
+	public function __construct()
33
+	{
34
+		//define some page related constants
35
+		define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36
+		define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
+		define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
+		define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
+		define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
+		define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
41
+		//check that if we're in maintenance mode that we tell the admin that
42
+		add_action('admin_notices', array($this, 'check_maintenance_mode'));
43
+		parent::__construct();
44
+	}
45
+
46
+
47
+
48
+	protected function _set_init_properties()
49
+	{
50
+		$this->label = EE_MAINTENANCE_LABEL;
51
+	}
52
+
53
+
54
+
55
+	protected function _set_menu_map()
56
+	{
57
+		$menu_map = $this->_menu_map();
58
+		$this->_menu_map = EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance
59
+			? new EE_Admin_Page_Main_Menu($menu_map) : new EE_Admin_Page_Sub_Menu($menu_map);
60
+	}
61
+
62
+
63
+
64
+	protected function _menu_map()
65
+	{
66
+		$map = array(
67
+			'menu_group'              => 'extras',
68
+			'menu_order'              => 30,
69
+			'show_on_menu'            => EE_Admin_Page_Menu_Map::BLOG_ADMIN_ONLY,
70
+			'parent_slug'             => 'espresso_events',
71
+			'menu_slug'               => EE_MAINTENANCE_PG_SLUG,
72
+			'menu_label'              => EE_MAINTENANCE_LABEL,
73
+			'capability'              => 'manage_options',
74
+			'maintenance_mode_parent' => EE_MAINTENANCE_PG_SLUG,
75
+			'admin_init_page'         => $this,
76
+		);
77
+		if (EE_Maintenance_Mode::instance()->level() == EE_Maintenance_Mode::level_2_complete_maintenance) {
78
+			$map['menu_group'] = 'main';
79
+			$map['subtitle'] = EE_MAINTENANCE_LABEL;
80
+			$map['menu_label'] = __('Event Espresso', 'event_espresso');
81
+		}
82
+		return $map;
83
+	}
84
+
85
+
86
+
87
+	/**
88
+	 * Checks if we're in maintenance mode, and if so we notify the admin adn tell them how to take the site OUT of
89
+	 * maintenance mode
90
+	 */
91
+	public function check_maintenance_mode()
92
+	{
93
+		$notice = '';
94
+		$maintenance_page_url = '';
95
+		if (EE_Maintenance_Mode::instance()->level()) {
96
+			$maintenance_page_url = EE_Admin_Page::add_query_args_and_nonce(array(), EE_MAINTENANCE_ADMIN_URL);
97
+			switch (EE_Maintenance_Mode::instance()->level()) {
98
+				case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
99
+					$notice = '<div class="update-nag">
100 100
 						'
101
-                              . sprintf(__("Event Espresso is in Frontend-Only MAINTENANCE MODE. This means the front-end (ie, non-wp-admin pages) is disabled for ALL users except site admins. Visit the %s Maintenance Page %s to disable maintenance mode.",
102
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>")
103
-                              .
104
-                              '</div>';
105
-                    break;
106
-                case EE_Maintenance_Mode::level_2_complete_maintenance:
107
-                    $notice = '<div class="error">
101
+							  . sprintf(__("Event Espresso is in Frontend-Only MAINTENANCE MODE. This means the front-end (ie, non-wp-admin pages) is disabled for ALL users except site admins. Visit the %s Maintenance Page %s to disable maintenance mode.",
102
+							"event_espresso"), "<a href='$maintenance_page_url'>", "</a>")
103
+							  .
104
+							  '</div>';
105
+					break;
106
+				case EE_Maintenance_Mode::level_2_complete_maintenance:
107
+					$notice = '<div class="error">
108 108
 						<p>' . sprintf(__("As part of the process for updating Event Espresso, your database also
109 109
 needs to be updated. Event Espresso is in COMPLETE MAINTENANCE MODE (both WordPress admin pages and front-end event registration pages are disabled) until you run the database update script. %s Visit the Maintenance Page to get started,%s it only takes a moment.",
110
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
111
-                              '</div>';
112
-                    break;
113
-            }
114
-        }
115
-        echo apply_filters('FHEE__Maintenance_Admin_Page_Init__check_maintenance_mode__notice', $notice,
116
-            $maintenance_page_url);
117
-    }
110
+							"event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
111
+							  '</div>';
112
+					break;
113
+			}
114
+		}
115
+		echo apply_filters('FHEE__Maintenance_Admin_Page_Init__check_maintenance_mode__notice', $notice,
116
+			$maintenance_page_url);
117
+	}
118 118
 
119 119
 } //end class Payments_Admin_Page_Init
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -34,10 +34,10 @@  discard block
 block discarded – undo
34 34
         //define some page related constants
35 35
         define('EE_MAINTENANCE_LABEL', __('Maintenance', 'event_espresso'));
36 36
         define('EE_MAINTENANCE_PG_SLUG', 'espresso_maintenance_settings');
37
-        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page=' . EE_MAINTENANCE_PG_SLUG));
38
-        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES . 'maintenance' . DS);
39
-        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN . 'templates' . DS);
40
-        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL . 'maintenance/assets/');
37
+        define('EE_MAINTENANCE_ADMIN_URL', admin_url('admin.php?page='.EE_MAINTENANCE_PG_SLUG));
38
+        define('EE_MAINTENANCE_ADMIN', EE_ADMIN_PAGES.'maintenance'.DS);
39
+        define('EE_MAINTENANCE_TEMPLATE_PATH', EE_MAINTENANCE_ADMIN.'templates'.DS);
40
+        define('EE_MAINTENANCE_ASSETS_URL', EE_ADMIN_PAGES_URL.'maintenance/assets/');
41 41
         //check that if we're in maintenance mode that we tell the admin that
42 42
         add_action('admin_notices', array($this, 'check_maintenance_mode'));
43 43
         parent::__construct();
@@ -107,7 +107,7 @@  discard block
 block discarded – undo
107 107
                     $notice = '<div class="error">
108 108
 						<p>' . sprintf(__("As part of the process for updating Event Espresso, your database also
109 109
 needs to be updated. Event Espresso is in COMPLETE MAINTENANCE MODE (both WordPress admin pages and front-end event registration pages are disabled) until you run the database update script. %s Visit the Maintenance Page to get started,%s it only takes a moment.",
110
-                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>") .
110
+                            "event_espresso"), "<a href='$maintenance_page_url'>", "</a>").
111 111
                               '</div>';
112 112
                     break;
113 113
             }
Please login to merge, or discard this patch.
admin_pages/maintenance/templates/ee_migration_page.template.php 1 patch
Indentation   +104 added lines, -104 removed lines patch added patch discarded remove patch
@@ -27,35 +27,35 @@  discard block
 block discarded – undo
27 27
             <h3 class="espresso-header">
28 28
                 <span class="dashicons dashicons-flag ee-icon-size-22"></span>
29 29
                 <?php
30
-                echo apply_filters(
31
-                        'FHEE__ee_migration_page__header',
32
-                        sprintf(
33
-                                __("Event Espresso has detected event data from version %s that can be migrated (updated) to work with version %s.",
34
-                                        "event_espresso"),
35
-                                $current_db_state,
36
-                                $next_db_state
37
-                        ),
38
-                        $current_db_state,
39
-                        $next_db_state
40
-                );
41
-                ?>
30
+				echo apply_filters(
31
+						'FHEE__ee_migration_page__header',
32
+						sprintf(
33
+								__("Event Espresso has detected event data from version %s that can be migrated (updated) to work with version %s.",
34
+										"event_espresso"),
35
+								$current_db_state,
36
+								$next_db_state
37
+						),
38
+						$current_db_state,
39
+						$next_db_state
40
+				);
41
+				?>
42 42
             </h3>
43 43
             <p>
44 44
                 <?php echo apply_filters('FHEE__ee_migration_page__p_after_header',
45
-                        sprintf(__("Since you have already been using Event Espresso and have previous event and registration data in your database, you have the option to migrate, or copy over, this existing data into a format that is compatible with %s.",
46
-                                "event_espresso"), $next_db_state), $next_db_state); ?>
45
+						sprintf(__("Since you have already been using Event Espresso and have previous event and registration data in your database, you have the option to migrate, or copy over, this existing data into a format that is compatible with %s.",
46
+								"event_espresso"), $next_db_state), $next_db_state); ?>
47 47
             </p>
48 48
         <?php } elseif ($show_most_recent_migration) { ?>
49 49
             <h3 class="espresso-header">
50 50
                 <span class="dashicons dashicons-awards ee-icon-size-22"></span>
51 51
                 <?php echo apply_filters('FHEE__ee_migration_page__done_migration_header',
52
-                        sprintf(__('Congratulations! Your database is "up-to-date" and you are ready to begin using %s',
53
-                                "event_espresso"), $ultimate_db_state)); ?>
52
+						sprintf(__('Congratulations! Your database is "up-to-date" and you are ready to begin using %s',
53
+								"event_espresso"), $ultimate_db_state)); ?>
54 54
             </h3>
55 55
             <p>
56 56
                 <?php echo apply_filters('FHEE__ee_migration_page__p_after_done_migration_header',
57
-                        sprintf(__("Time to find out about all the great new features %s has to offer.",
58
-                                "event_espresso"), $ultimate_db_state)); ?> &nbsp;
57
+						sprintf(__("Time to find out about all the great new features %s has to offer.",
58
+								"event_espresso"), $ultimate_db_state)); ?> &nbsp;
59 59
                 <b><a id="get-started-after-migrate" class="button-primary"
60 60
                       href="<?php echo add_query_arg(array('page' => 'espresso_about'), admin_url('admin.php')); ?>">
61 61
                         <?php _e("Let's Get Started", "event_espresso"); ?>&nbsp;<span
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
                     <span class="dashicons dashicons-admin-tools"></span>
72 72
                     <?php _e("Migration Options", "event_espresso"); ?>
73 73
                     <span class="tiny-text lt-grey-text"> &nbsp; <?php _e(' to migrate or not to migrate?',
74
-                                "event_espresso"); ?></span>
74
+								"event_espresso"); ?></span>
75 75
                 </h2>
76 76
                 <div class="ee-table-wrap">
77 77
                     <table>
@@ -80,24 +80,24 @@  discard block
 block discarded – undo
80 80
                             <td><h3><?php _e('1', 'event_espresso'); ?></h3></td>
81 81
                             <td>
82 82
                                 <?php
83
-                                echo apply_filters(
84
-                                        'FHEE__ee_migration_page__option_1_main',
85
-                                        sprintf(
86
-                                                __('%1$sYes. I have backed up my database%2$s, %3$sunderstand the risks involved%4$s, and am ready to migrate my existing %5$s data to %6$s.',
87
-                                                        "event_espresso"),
88
-                                                '<strong>',
89
-                                                '</strong>',
90
-                                                '<a id="migration-risks" class="" title="'
91
-                                                . esc_attr__('click for more details', "event_espresso")
92
-                                                . '">',
93
-                                                '</a>',
94
-                                                $current_db_state,
95
-                                                $next_db_state
96
-                                        ),
97
-                                        $current_db_state,
98
-                                        $next_db_state
99
-                                );
100
-                                ?>
83
+								echo apply_filters(
84
+										'FHEE__ee_migration_page__option_1_main',
85
+										sprintf(
86
+												__('%1$sYes. I have backed up my database%2$s, %3$sunderstand the risks involved%4$s, and am ready to migrate my existing %5$s data to %6$s.',
87
+														"event_espresso"),
88
+												'<strong>',
89
+												'</strong>',
90
+												'<a id="migration-risks" class="" title="'
91
+												. esc_attr__('click for more details', "event_espresso")
92
+												. '">',
93
+												'</a>',
94
+												$current_db_state,
95
+												$next_db_state
96
+										),
97
+										$current_db_state,
98
+										$next_db_state
99
+								);
100
+								?>
101 101
                                 <a id="display-migration-details"
102 102
                                    class="display-the-hidden lt-grey-text smaller-text hide-if-no-js"
103 103
                                    rel="migration-details"><?php _e('click for more details', "event_espresso"); ?>
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
                                    class="hide-the-displayed lt-grey-text smaller-text hide-if-no-js"
107 107
                                    rel="migration-details"
108 108
                                    style="display:none;"><?php echo sprintf(__('hide%1$sdetails%1$s-',
109
-                                            'event_espresso'), '&nbsp;'); ?></a>
109
+											'event_espresso'), '&nbsp;'); ?></a>
110 110
                             </td>
111 111
                             <td>
112 112
                                 <a id="db-backed-up"
113 113
                                    class="toggle-migration-monitor button-primary"><?php echo apply_filters('FHEE__ee_migration_page__option_1_button_text',
114
-                                            sprintf(__("Migrate My %s Data to %s", "event_espresso"), $current_db_state,
115
-                                                    $next_db_state), $current_db_state, $next_db_state); ?></a>
114
+											sprintf(__("Migrate My %s Data to %s", "event_espresso"), $current_db_state,
115
+													$next_db_state), $current_db_state, $next_db_state); ?></a>
116 116
                             </td>
117 117
                         </tr>
118 118
                         <tr>
@@ -120,24 +120,24 @@  discard block
 block discarded – undo
120 120
                                 <div id="migration-details-dv" style="display: none; padding: 1em;">
121 121
 
122 122
                                     <span class="reminder-spn"><?php printf(__("%s Important: %s Before migrating, please back up your database and files.",
123
-                                                "event_espresso"), "<b>", "</b>"); ?></span>
123
+												"event_espresso"), "<b>", "</b>"); ?></span>
124 124
                                     <p>
125 125
                                         <?php
126
-                                        printf(
127
-                                                __('%1$sNot sure how to backup your existing data?%2$s Here is %3$sWordPress\'s explanation%7$s, and here\'s %6$sour explanation%7$s.%8$sYou can also search the WordPress plugin database for %4$s database backup plugins %7$s,%8$sor have one of our dedicated support technicians help you by purchasing a %5$sPriority Support Token%7$s.',
128
-                                                        "event_espresso"),
129
-                                                '<b>',
130
-                                                '</b>',
131
-                                                "<a href='http://codex.wordpress.org/Backing_Up_Your_Database'>",
132
-                                                "<a href='"
133
-                                                . admin_url('plugin-install.php?tab=search&type=term&s=database+backup&plugin-search-input=Search+Plugins')
134
-                                                . "'>",
135
-                                                "<a href='http://eventespresso.com/product/priority-support-tokens/'>",
136
-                                                '<a href="http://eventespresso.com/wiki/how-to-back-up-your-site/">',
137
-                                                "</a>",
138
-                                                '<br/>'
139
-                                        );
140
-                                        ?>
126
+										printf(
127
+												__('%1$sNot sure how to backup your existing data?%2$s Here is %3$sWordPress\'s explanation%7$s, and here\'s %6$sour explanation%7$s.%8$sYou can also search the WordPress plugin database for %4$s database backup plugins %7$s,%8$sor have one of our dedicated support technicians help you by purchasing a %5$sPriority Support Token%7$s.',
128
+														"event_espresso"),
129
+												'<b>',
130
+												'</b>',
131
+												"<a href='http://codex.wordpress.org/Backing_Up_Your_Database'>",
132
+												"<a href='"
133
+												. admin_url('plugin-install.php?tab=search&type=term&s=database+backup&plugin-search-input=Search+Plugins')
134
+												. "'>",
135
+												"<a href='http://eventespresso.com/product/priority-support-tokens/'>",
136
+												'<a href="http://eventespresso.com/wiki/how-to-back-up-your-site/">',
137
+												"</a>",
138
+												'<br/>'
139
+										);
140
+										?>
141 141
                                     </p>
142 142
                                     <?php do_action('AHEE__ee_migration_page__option_1_extra_details'); ?>
143 143
                                 </div>
@@ -147,12 +147,12 @@  discard block
 block discarded – undo
147 147
                             <td><h3><?php _e('2', 'event_espresso'); ?></h3></td>
148 148
                             <td>
149 149
                                 <?php echo apply_filters('FHEE__ee_migration_page__option_2_main',
150
-                                        sprintf(__('I do NOT want to migrate my %1$s data to %2$s at this time and just want to use %3$s without migrating data.',
151
-                                                "event_espresso"), $current_db_state, $next_db_state,
152
-                                                $ultimate_db_state), $current_db_state, $next_db_state,
153
-                                        $ultimate_db_state); ?><br/>
150
+										sprintf(__('I do NOT want to migrate my %1$s data to %2$s at this time and just want to use %3$s without migrating data.',
151
+												"event_espresso"), $current_db_state, $next_db_state,
152
+												$ultimate_db_state), $current_db_state, $next_db_state,
153
+										$ultimate_db_state); ?><br/>
154 154
                                 <span class="reminder-spn"><?php _e('Please Note: In order to avoid errors, any existing Event Espresso data (events, ticket, registrations, etc) in your db will be erased! Regular WP data will NOT be affected.',
155
-                                            'event_espresso'); ?></span>
155
+											'event_espresso'); ?></span>
156 156
                                 <a id="display-no-migration-details"
157 157
                                    class="display-the-hidden lt-grey-text smaller-text hide-if-no-js"
158 158
                                    rel="no-migration-details"><?php _e('click for more details', "event_espresso"); ?>
@@ -161,13 +161,13 @@  discard block
 block discarded – undo
161 161
                                    class="hide-the-displayed lt-grey-text smaller-text hide-if-no-js"
162 162
                                    rel="no-migration-details"
163 163
                                    style="display:none;"><?php echo sprintf(__('hide%1$sdetails%1$s-',
164
-                                            'event_espresso'), '&nbsp;'); ?></a>
164
+											'event_espresso'), '&nbsp;'); ?></a>
165 165
                             </td>
166 166
                             <td>
167 167
                                 <a id="do-not-migrate" class="do-not-migrate button-primary"
168 168
                                    href="<?php echo $reset_db_page_link; ?>"><?php echo apply_filters('FHEE__ee_migration_page__option_2_button_text',
169
-                                            sprintf(__("Just Start %s and Delete Existing Data", "event_espresso"),
170
-                                                    $ultimate_db_state), $ultimate_db_state); ?></a>
169
+											sprintf(__("Just Start %s and Delete Existing Data", "event_espresso"),
170
+													$ultimate_db_state), $ultimate_db_state); ?></a>
171 171
                             </td>
172 172
                         </tr>
173 173
                         <tr>
@@ -175,8 +175,8 @@  discard block
 block discarded – undo
175 175
                                 <div id="no-migration-details-dv" style="display: none; padding: 1em;">
176 176
                                     <p>
177 177
                                         <?php echo apply_filters('FHEE__ee_migration_page__option_2_details',
178
-                                                sprintf(__("If your existing Event and Registration Data is no longer relevant nor required, you can just start up %s without performing a data migration.",
179
-                                                        "event_espresso"), $ultimate_db_state), $ultimate_db_state); ?>
178
+												sprintf(__("If your existing Event and Registration Data is no longer relevant nor required, you can just start up %s without performing a data migration.",
179
+														"event_espresso"), $ultimate_db_state), $ultimate_db_state); ?>
180 180
                                     </p>
181 181
                                 </div>
182 182
                             </td>
@@ -189,29 +189,29 @@  discard block
 block discarded – undo
189 189
         <?php } ?>
190 190
 
191 191
         <?php
192
-        if ($show_most_recent_migration) {
193
-            if ($most_recent_migration && $most_recent_migration instanceof EE_Data_Migration_Script_Base) {
194
-                if ($most_recent_migration->can_continue()) {
195
-                    //tell the user they should continue their migration because it appears to be unfinished... well, assuming there were no errors ?>
192
+		if ($show_most_recent_migration) {
193
+			if ($most_recent_migration && $most_recent_migration instanceof EE_Data_Migration_Script_Base) {
194
+				if ($most_recent_migration->can_continue()) {
195
+					//tell the user they should continue their migration because it appears to be unfinished... well, assuming there were no errors ?>
196 196
                     <h3 class="espresso-header">
197 197
                         <span class="dashicons dashicons-star-half ee-icon-size-22"></span>
198 198
                         <?php printf(__("It appears that your previous Data Migration Task (%s) is incomplete, and should be resumed",
199
-                                "event_espresso"), $most_recent_migration->pretty_name()); ?>
199
+								"event_espresso"), $most_recent_migration->pretty_name()); ?>
200 200
                     </h3>
201 201
                 <?php } elseif ($most_recent_migration->is_broken()) {
202
-                    //tell the user the migration failed and they should notify EE?>
202
+					//tell the user the migration failed and they should notify EE?>
203 203
                     <h3 class="espresso-header">
204 204
                         <span class="dashicons dashicons-no ee-icon-size-22"></span>
205 205
                         <?php echo $most_recent_migration->get_feedback_message() ?>
206 206
                     </h3>
207 207
                 <?php }
208
-                //display errors or not of the most recent migration ran
209
-                if ($most_recent_migration->get_errors()) { ?>
208
+				//display errors or not of the most recent migration ran
209
+				if ($most_recent_migration->get_errors()) { ?>
210 210
                     <div class="ee-attention">
211 211
                         <strong><?php printf(__("Warnings occurred during your last migration (%s):", 'event_espresso'),
212
-                                    $most_recent_migration->pretty_name()) ?></strong>
212
+									$most_recent_migration->pretty_name()) ?></strong>
213 213
                         <a id="show-hide-migration-warnings" class="display-the-hidden"><?php _e("Show Warnings",
214
-                                    'event_espresso'); ?></a>
214
+									'event_espresso'); ?></a>
215 215
                         <ul class="migration-warnings" style="display:none">
216 216
                             <?php foreach ($most_recent_migration->get_errors() as $error) { ?>
217 217
                                 <li><?php echo htmlentities($error) ?></li>
@@ -219,15 +219,15 @@  discard block
 block discarded – undo
219 219
                         </ul>
220 220
                     </div>
221 221
                 <?php } else {
222
-                    //there were no errors during the last migration, just say so?>
222
+					//there were no errors during the last migration, just say so?>
223 223
                     <h2><?php printf(__("The last data migration task (%s) ran successfully without errors.",
224
-                                "event_espresso"), $most_recent_migration->pretty_name()) ?></h2>
224
+								"event_espresso"), $most_recent_migration->pretty_name()) ?></h2>
225 225
                 <?php }
226
-            } else {
227
-            }
228
-        }
229
-        // end of: if ( $show_most_recent_migration )
230
-        ?>
226
+			} else {
227
+			}
228
+		}
229
+		// end of: if ( $show_most_recent_migration )
230
+		?>
231 231
 
232 232
     </div>
233 233
     <!--end of #migration-prep-->
@@ -247,12 +247,12 @@  discard block
 block discarded – undo
247 247
             <div id='progress-area'>
248 248
                 <h3 class="espresso-header">
249 249
                     <?php
250
-                    echo sprintf(_n(
251
-                            "In order to import all of your existing Event Espresso data, the following upgrade task needs to be performed:",
252
-                            "In order to import all of your existing Event Espresso data, the following %s upgrade tasks need to be performed:",
253
-                            count($script_names),
254
-                            "event_espresso"
255
-                    ), count($script_names)); ?>
250
+					echo sprintf(_n(
251
+							"In order to import all of your existing Event Espresso data, the following upgrade task needs to be performed:",
252
+							"In order to import all of your existing Event Espresso data, the following %s upgrade tasks need to be performed:",
253
+							count($script_names),
254
+							"event_espresso"
255
+					), count($script_names)); ?>
256 256
                 </h3>
257 257
                 <ul style="list-style: inside;">
258 258
                     <?php foreach ($script_names as $script_name) { ?>
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
                 <br/>
263 263
                 <?php if (count($script_names) > 1) { ?>
264 264
                     <p><?php _e("Please note: after each task is completed you will need to continue the data migration, or report an error to Event Espresso.",
265
-                                "event_espresso"); ?></p>
265
+								"event_espresso"); ?></p>
266 266
                 <?php } ?>
267 267
 
268 268
                 <div class="ee-attention">
@@ -272,11 +272,11 @@  discard block
 block discarded – undo
272 272
 					</span>
273 273
                         <br/>
274 274
                         <?php _e("Depending on the number of events and the complexity of the information in your database, this could take a few minutes.",
275
-                                "event_espresso"); ?>
275
+								"event_espresso"); ?>
276 276
                     </p>
277 277
                     <p>
278 278
                         <?php printf(__("%sPlease be patient and do NOT navigate away from this page once the migration has begun%s. If any issues arise due to existing malformed data, an itemized report will be made available to you after the migration has completed.",
279
-                                "event_espresso"), '<strong>', '</strong>'); ?>
279
+								"event_espresso"), '<strong>', '</strong>'); ?>
280 280
                     </p>
281 281
                     <p>
282 282
                         <?php _e("Click the button below to begin the migration process.", "event_espresso") ?>
@@ -292,7 +292,7 @@  discard block
 block discarded – undo
292 292
 
293 293
                 <button id='start-migration' class='button-primary'>
294 294
                     <?php echo $show_continue_current_migration_script ? __("Continue Migration", "event_espresso")
295
-                            : __("Begin Migration", "event_espresso"); ?>
295
+							: __("Begin Migration", "event_espresso"); ?>
296 296
                 </button>
297 297
                 <br class="clear"/>
298 298
 
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
         </div>
309 309
 
310 310
     <?php }
311
-    if ($show_maintenance_switch) {
312
-        ?>
311
+	if ($show_maintenance_switch) {
312
+		?>
313 313
         <h2><span class="dashicons dashicons-admin-tools"></span><?php _e('Set Event Espresso Maintenance Mode',
314
-                    'event_espresso'); ?></h2>
314
+					'event_espresso'); ?></h2>
315 315
         <form method='post' action='<?php echo $update_migration_script_page_link ?>'>
316 316
             <div class="ee-table-wrap">
317 317
                 <table>
@@ -319,15 +319,15 @@  discard block
 block discarded – undo
319 319
                         <td width="40px" align="center">
320 320
                             <input type="radio" id="maintenance_mode_level_off" name="maintenance_mode_level"
321 321
                                    value="0" <?php echo EE_Maintenance_Mode::instance()->level()
322
-                                                        == EE_Maintenance_Mode::level_0_not_in_maintenance
323
-                                    ? 'checked="checked"' : '' ?>>
322
+														== EE_Maintenance_Mode::level_0_not_in_maintenance
323
+									? 'checked="checked"' : '' ?>>
324 324
                         </td>
325 325
                         <th align="left">
326 326
                             <label for="maintenance_mode_level_off"><?php _e('Maintenance Mode OFF',
327
-                                        'event_espresso'); ?></label>
327
+										'event_espresso'); ?></label>
328 328
                             <p class='description' style="font-weight: normal;">
329 329
                                 <?php _e("This is the normal operating mode for Event Espresso and allows all functionality to be viewed by all site visitors.",
330
-                                        "event_espresso"); ?>
330
+										"event_espresso"); ?>
331 331
                             </p>
332 332
                         </th>
333 333
                     </tr>
@@ -335,8 +335,8 @@  discard block
 block discarded – undo
335 335
                         <td width="40px" align="center">
336 336
                             <input type="radio" id="maintenance_mode_level_on" name="maintenance_mode_level"
337 337
                                    value="1" <?php echo EE_Maintenance_Mode::instance()->level()
338
-                                                        == EE_Maintenance_Mode::level_1_frontend_only_maintenance
339
-                                    ? 'checked="checked"' : '' ?>>
338
+														== EE_Maintenance_Mode::level_1_frontend_only_maintenance
339
+									? 'checked="checked"' : '' ?>>
340 340
                         </td>
341 341
                         <th align="left">
342 342
                             <label for="maintenance_mode_level_on">
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
                             </label>
345 345
                             <p class='description' style="font-weight: normal;">
346 346
                                 <?php _e("This disables Event Espresso frontend functionality for all site visitors that are not administrators, and allows you to configure and/or test things on the frontend of your website before others can see.",
347
-                                        "event_espresso"); ?>
347
+										"event_espresso"); ?>
348 348
                             </p>
349 349
                         </th>
350 350
                     </tr>
@@ -356,6 +356,6 @@  discard block
 block discarded – undo
356 356
             </p>
357 357
         </form>
358 358
         <?php
359
-    } ?>
359
+	} ?>
360 360
 
361 361
 </div>
Please login to merge, or discard this patch.