Completed
Branch FET-8209-allow-multiple-carts (f5b2f0)
by
unknown
108:40 queued 97:50
created
core/libraries/messages/messenger/EE_Email_messenger.class.php 3 patches
Spacing   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 /**
30 30
  * This sets up the email messenger for the EE_messages (notifications) subsystem in EE.
31 31
  */
32
-class EE_Email_messenger extends EE_messenger  {
32
+class EE_Email_messenger extends EE_messenger {
33 33
 
34 34
 	/**
35 35
 	 * The following are the properties that email requires for the message going out.
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 	protected function _set_valid_shortcodes() {
78 78
 		//remember by leaving the other fields not set, those fields will inherit the valid shortcodes from the message type.
79 79
 		$this->_valid_shortcodes = array(
80
-			'to' => array('email','event_author', 'primary_registration_details', 'recipient_details'),
80
+			'to' => array('email', 'event_author', 'primary_registration_details', 'recipient_details'),
81 81
 			'from' => array('email', 'event_author', 'primary_registration_details', 'recipient_details')
82 82
 			);
83 83
 	}
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 				'shortcodes' => array('organization', 'primary_registration_details', 'event_author', 'primary_registration_details', 'recipient_details')
112 112
 				),
113 113
 			'content' => array(
114
-				'shortcodes' => array('event_list','attendee_list', 'ticket_list', 'organization', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list', 'transaction', 'messenger')
114
+				'shortcodes' => array('event_list', 'attendee_list', 'ticket_list', 'organization', 'primary_registration_details', 'primary_registration_list', 'event_author', 'recipient_details', 'recipient_list', 'transaction', 'messenger')
115 115
 				),
116 116
 			'attendee_list' => array(
117 117
 				'shortcodes' => array('attendee', 'event_list', 'ticket_list'),
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
 				'required' => array('[EVENT_LIST]')
123 123
 				),
124 124
 			'ticket_list' => array(
125
-				'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list','primary_registration_details', 'recipient_details'),
125
+				'shortcodes' => array('event_list', 'attendee_list', 'ticket', 'datetime_list', 'primary_registration_details', 'recipient_details'),
126 126
 				'required' => array('[TICKET_LIST]')
127 127
 				),
128 128
 			'datetime_list' => array(
@@ -141,21 +141,21 @@  discard block
 block discarded – undo
141 141
 	 *
142 142
 	 * @since 4.5.0
143 143
 	 */
144
-	public function do_secondary_messenger_hooks( $sending_messenger_name ) {
145
-		if ( $sending_messenger_name = 'html' ) {
146
-			add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10, 8 );
144
+	public function do_secondary_messenger_hooks($sending_messenger_name) {
145
+		if ($sending_messenger_name = 'html') {
146
+			add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
147 147
 		}
148 148
 	}
149 149
 
150 150
 
151 151
 
152 152
 
153
-	public function add_email_css( $variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack ) {
153
+	public function add_email_css($variation_path, $messenger, $message_type, $type, $variation, $file_extension, $url, EE_Messages_Template_Pack $template_pack) {
154 154
 		//prevent recursion on this callback.
155
-		remove_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10 );
156
-		$variation = $this->get_variation( $template_pack, $message_type, $url, 'main', $variation, FALSE  );
155
+		remove_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10);
156
+		$variation = $this->get_variation($template_pack, $message_type, $url, 'main', $variation, FALSE);
157 157
 
158
-		add_filter( 'FHEE__EE_Messages_Template_Pack__get_variation', array( $this, 'add_email_css' ), 10, 8 );
158
+		add_filter('FHEE__EE_Messages_Template_Pack__get_variation', array($this, 'add_email_css'), 10, 8);
159 159
 		return $variation;
160 160
 	}
161 161
 
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 				'required' => FALSE,
188 188
 				'validation' => FALSE,
189 189
 				'format' => '%s',
190
-				'value' => sprintf( __('Test email sent from %s', 'event_espresso'), get_bloginfo('name') ),
190
+				'value' => sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name')),
191 191
 				'default'=> '',
192 192
 				'css_class' => ''
193 193
 				)
@@ -349,16 +349,16 @@  discard block
 block discarded – undo
349 349
 	 * @return bool | WP_Error  true if message delivered, false if it didn't deliver OR bubble up any error object if present.
350 350
 	 */
351 351
 	protected function _send_message() {
352
-		$success =  wp_mail(
353
-			html_entity_decode( $this->_to, ENT_QUOTES, "UTF-8" ),
354
-			stripslashes( html_entity_decode( $this->_subject, ENT_QUOTES, "UTF-8" )),
352
+		$success = wp_mail(
353
+			html_entity_decode($this->_to, ENT_QUOTES, "UTF-8"),
354
+			stripslashes(html_entity_decode($this->_subject, ENT_QUOTES, "UTF-8")),
355 355
 			$this->_body(),
356 356
 			$this->_headers()
357 357
 		);
358
-		if ( ! $success ) {
358
+		if ( ! $success) {
359 359
 			EE_Error::add_error(
360 360
 				sprintf(
361
-					__( 'The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', 'event_espresso'),
361
+					__('The email did not send successfully.%3$sThe WordPress wp_mail function is used for sending mails but does not give any useful information when an email fails to send.%3$sIt is possible the "to" address (%1$s) or "from" address (%2$s) is invalid.%3$s', 'event_espresso'),
362 362
 					$this->_to,
363 363
 					$this->_from,
364 364
 					'<br />'
@@ -377,7 +377,7 @@  discard block
 block discarded – undo
377 377
 	 * @return string html body of the message content and the related css.
378 378
 	 */
379 379
 	protected function _preview() {
380
-		return $this->_body( true );
380
+		return $this->_body(true);
381 381
 	}
382 382
 
383 383
 
@@ -392,18 +392,18 @@  discard block
 block discarded – undo
392 392
 	 */
393 393
 	protected function _headers() {
394 394
 		$this->_ensure_has_from_email_address();
395
-		$from = stripslashes_deep( html_entity_decode($this->_from,  ENT_QUOTES,"UTF-8" ) );
395
+		$from = stripslashes_deep(html_entity_decode($this->_from, ENT_QUOTES, "UTF-8"));
396 396
 		$headers = array(
397 397
 			'MIME-Version: 1.0',
398
-			'From:' . $from,
399
-			'Reply-To:' . $from,
398
+			'From:'.$from,
399
+			'Reply-To:'.$from,
400 400
 			'Content-Type:text/html; charset=utf-8'
401 401
 			);
402 402
 
403 403
 		//but wait!  Header's for the from is NOT reliable because some plugins don't respect From: as set in the header.
404
-		add_filter( 'wp_mail_from',  array( $this, 'set_from_address' ), 100 );
405
-		add_filter( 'wp_mail_from_name', array( $this, 'set_from_name' ), 100 );
406
-		return apply_filters( 'FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this );
404
+		add_filter('wp_mail_from', array($this, 'set_from_address'), 100);
405
+		add_filter('wp_mail_from_name', array($this, 'set_from_name'), 100);
406
+		return apply_filters('FHEE__EE_Email_messenger___headers', $headers, $this->_incoming_message_type, $this);
407 407
 	}
408 408
 
409 409
 
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 	 * address for the from address to avoid problems with sending emails.
413 413
 	 */
414 414
 	protected function _ensure_has_from_email_address() {
415
-		if ( empty( $this->_from ) ) {
415
+		if (empty($this->_from)) {
416 416
 			$this->_from = get_bloginfo('admin_email');
417 417
 		}
418 418
 	}
@@ -429,21 +429,21 @@  discard block
 block discarded – undo
429 429
 	 * @return array
430 430
 	 */
431 431
 	private function _parse_from() {
432
-		if ( strpos( $this->_from, '<' ) !== false ) {
433
-			$from_name = substr( $this->_from, 0, strpos( $this->_from, '<' ) - 1 );
434
-			$from_name = str_replace( '"', '', $from_name );
435
-			$from_name = trim( $from_name );
436
-
437
-			$from_email = substr( $this->_from, strpos( $this->_from, '<' ) + 1 );
438
-			$from_email = str_replace( '>', '', $from_email );
439
-			$from_email = trim( $from_email );
440
-		} elseif ( trim( $this->_from ) !== '' ) {
432
+		if (strpos($this->_from, '<') !== false) {
433
+			$from_name = substr($this->_from, 0, strpos($this->_from, '<') - 1);
434
+			$from_name = str_replace('"', '', $from_name);
435
+			$from_name = trim($from_name);
436
+
437
+			$from_email = substr($this->_from, strpos($this->_from, '<') + 1);
438
+			$from_email = str_replace('>', '', $from_email);
439
+			$from_email = trim($from_email);
440
+		} elseif (trim($this->_from) !== '') {
441 441
 			$from_name = '';
442
-			$from_email = trim( $this->_from );
442
+			$from_email = trim($this->_from);
443 443
 		} else {
444 444
 			$from_name = $from_email = '';
445 445
 		}
446
-		return array( $from_name, $from_email );
446
+		return array($from_name, $from_email);
447 447
 	}
448 448
 
449 449
 
@@ -456,10 +456,10 @@  discard block
 block discarded – undo
456 456
 	 *
457 457
 	 * @param string $from_email What the original from_email is.
458 458
 	 */
459
-	public function set_from_address( $from_email ) {
459
+	public function set_from_address($from_email) {
460 460
 		$parsed_from = $this->_parse_from();
461 461
 		//includes fallback if the parsing failed.
462
-		$from_email = is_array( $parsed_from ) && ! empty( $parsed_from[1] ) ? $parsed_from[1] : get_bloginfo( 'admin_email' );
462
+		$from_email = is_array($parsed_from) && ! empty($parsed_from[1]) ? $parsed_from[1] : get_bloginfo('admin_email');
463 463
 		return $from_email;
464 464
 	}
465 465
 
@@ -473,16 +473,16 @@  discard block
 block discarded – undo
473 473
 	 *
474 474
 	 * @param string $from_name The original from_name.
475 475
 	 */
476
-	public function set_from_name( $from_name ) {
476
+	public function set_from_name($from_name) {
477 477
 		$parsed_from = $this->_parse_from();
478
-		if ( is_array( $parsed_from) && ! empty( $parsed_from[0] ) ) {
479
-			$from_name =  $parsed_from[0];
478
+		if (is_array($parsed_from) && ! empty($parsed_from[0])) {
479
+			$from_name = $parsed_from[0];
480 480
 		}
481 481
 
482 482
 		//if from name is "WordPress" let's sub in the site name instead (more friendly!)
483 483
 		$from_name = $from_name == 'WordPress' ? get_bloginfo() : $from_name;
484 484
 
485
-		return stripslashes_deep( html_entity_decode($from_name,  ENT_QUOTES,"UTF-8" ) );
485
+		return stripslashes_deep(html_entity_decode($from_name, ENT_QUOTES, "UTF-8"));
486 486
 	}
487 487
 
488 488
 
@@ -493,14 +493,14 @@  discard block
 block discarded – undo
493 493
 	 * @param bool $preview will determine whether this is preview template or not.
494 494
 	 * @return string formatted body for email.
495 495
 	 */
496
-	protected function _body( $preview = false ) {
496
+	protected function _body($preview = false) {
497 497
 		//setup template args!
498 498
 		$this->_template_args = array(
499 499
 			'subject' => $this->_subject,
500 500
 			'from' => $this->_from,
501
-			'main_body' => wpautop(stripslashes_deep( html_entity_decode($this->_content,  ENT_QUOTES,"UTF-8" ) ))
501
+			'main_body' => wpautop(stripslashes_deep(html_entity_decode($this->_content, ENT_QUOTES, "UTF-8")))
502 502
 			);
503
-		$body =  $this->_get_main_template( $preview );
503
+		$body = $this->_get_main_template($preview);
504 504
 
505 505
 		/**
506 506
 		 * This filter allows one to bypass the CSSToInlineStyles tool and leave the body untouched.
@@ -508,17 +508,17 @@  discard block
 block discarded – undo
508 508
 		 * @type    bool    $preview    Indicates whether a preview is being generated or not.
509 509
 		 * @return  bool    true  indicates to use the inliner, false bypasses it.
510 510
 		 */
511
-		if ( apply_filters( 'FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview ) ) {
511
+		if (apply_filters('FHEE__EE_Email_messenger__apply_CSSInliner ', true, $preview)) {
512 512
 
513 513
 			//require CssToInlineStyles library and its dependencies via composer autoloader
514
-			require_once EE_THIRD_PARTY . 'cssinliner/vendor/autoload.php';
514
+			require_once EE_THIRD_PARTY.'cssinliner/vendor/autoload.php';
515 515
 
516 516
 			//now if this isn't a preview, let's setup the body so it has inline styles
517
-			if ( ! $preview || ( $preview && defined( 'DOING_AJAX' ) ) ) {
518
-				$style = file_get_contents( $this->get_variation( $this->_tmp_pack, $this->_incoming_message_type->name, FALSE, 'main', $this->_variation ), TRUE );
519
-				$CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles( $body, $style );
520
-				$body = ltrim( $CSS->convert( true ), ">\n" ); //for some reason the library has a bracket and new line at the beginning.  This takes care of that.
521
-				$body = ltrim( $body, "<?" ); //see https://events.codebasehq.com/projects/event-espresso/tickets/8609
517
+			if ( ! $preview || ($preview && defined('DOING_AJAX'))) {
518
+				$style = file_get_contents($this->get_variation($this->_tmp_pack, $this->_incoming_message_type->name, FALSE, 'main', $this->_variation), TRUE);
519
+				$CSS = new TijsVerkoyen\CssToInlineStyles\CssToInlineStyles($body, $style);
520
+				$body = ltrim($CSS->convert(true), ">\n"); //for some reason the library has a bracket and new line at the beginning.  This takes care of that.
521
+				$body = ltrim($body, "<?"); //see https://events.codebasehq.com/projects/event-espresso/tickets/8609
522 522
 			}
523 523
 
524 524
 		}
@@ -537,8 +537,8 @@  discard block
 block discarded – undo
537 537
 	public function get_existing_test_settings() {
538 538
 		$settings = parent::get_existing_test_settings();
539 539
 		//override subject if present because we always want it to be fresh.
540
-		if ( is_array( $settings ) && ! empty( $settings['subject'] ) ) {
541
-			$settings['subject'] = sprintf( __('Test email sent from %s', 'event_espresso'), get_bloginfo('name') );
540
+		if (is_array($settings) && ! empty($settings['subject'])) {
541
+			$settings['subject'] = sprintf(__('Test email sent from %s', 'event_espresso'), get_bloginfo('name'));
542 542
 		}
543 543
 		return $settings;
544 544
 	}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -426,7 +426,7 @@
 block discarded – undo
426 426
 	 *
427 427
 	 * @since 4.3.1
428 428
 	 *
429
-	 * @return array
429
+	 * @return string[]
430 430
 	 */
431 431
 	private function _parse_from() {
432 432
 		if ( strpos( $this->_from, '<' ) !== false ) {
Please login to merge, or discard this patch.
Braces   +2 added lines, -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if (!defined('EVENT_ESPRESSO_VERSION') ) {
3 3
 	exit('NO direct script access allowed');
4
+}
4 5
 
5 6
 /**
6 7
  * Event Espresso
Please login to merge, or discard this patch.
core/libraries/messages/messenger/EE_Html_messenger.class.php 1 patch
Spacing   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
3
-	exit( 'NO direct script access allowed' );
2
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 
6 6
 
@@ -43,16 +43,16 @@  discard block
 block discarded – undo
43 43
 	public function __construct() {
44 44
 		//set properties
45 45
 		$this->name = 'html';
46
-		$this->description = __( 'This messenger outputs a message to a browser for display.', 'event_espresso' );
46
+		$this->description = __('This messenger outputs a message to a browser for display.', 'event_espresso');
47 47
 		$this->label = array(
48
-			'singular' => __( 'html', 'event_espresso' ),
49
-			'plural'   => __( 'html', 'event_espresso' ),
48
+			'singular' => __('html', 'event_espresso'),
49
+			'plural'   => __('html', 'event_espresso'),
50 50
 		);
51 51
 		$this->activate_on_install = true;
52 52
 		// add the "powered by EE" credit link to the HTML receipt and invoice
53 53
 		add_filter(
54 54
 			'FHEE__EE_Html_messenger___send_message__main_body',
55
-			array( $this, 'add_powered_by_credit_link_to_receipt_and_invoice' ),
55
+			array($this, 'add_powered_by_credit_link_to_receipt_and_invoice'),
56 56
 			10,
57 57
 			3
58 58
 		);
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 	 * @see abstract declaration in EE_messenger for details.
92 92
 	 */
93 93
 	protected function _set_admin_pages() {
94
-		$this->admin_registered_pages = array( 'events_edit' => true );
94
+		$this->admin_registered_pages = array('events_edit' => true);
95 95
 	}
96 96
 
97 97
 
@@ -111,7 +111,7 @@  discard block
 block discarded – undo
111 111
 	protected function _set_validator_config() {
112 112
 		$this->_validator_config = array(
113 113
 			'subject'                       => array(
114
-				'shortcodes' => array( 'organization', 'primary_registration_details', 'email', 'transaction' ),
114
+				'shortcodes' => array('organization', 'primary_registration_details', 'email', 'transaction'),
115 115
 			),
116 116
 			'content'                       => array(
117 117
 				'shortcodes' => array(
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
 					'primary_registration_list',
138 138
 					'event_author',
139 139
 				),
140
-				'required'   => array( '[EVENT_LIST]' ),
140
+				'required'   => array('[EVENT_LIST]'),
141 141
 			),
142 142
 			'ticket_list'                   => array(
143 143
 				'shortcodes' => array(
@@ -148,39 +148,39 @@  discard block
 block discarded – undo
148 148
 					'line_item_list',
149 149
 					'venue',
150 150
 				),
151
-				'required'   => array( '[TICKET_LIST]' ),
151
+				'required'   => array('[TICKET_LIST]'),
152 152
 			),
153 153
 			'ticket_line_item_no_pms'       => array(
154
-				'shortcodes' => array( 'line_item', 'ticket' ),
155
-				'required'   => array( '[TICKET_LINE_ITEM_LIST]' ),
154
+				'shortcodes' => array('line_item', 'ticket'),
155
+				'required'   => array('[TICKET_LINE_ITEM_LIST]'),
156 156
 			),
157 157
 			'ticket_line_item_pms'          => array(
158
-				'shortcodes' => array( 'line_item', 'ticket', 'line_item_list' ),
159
-				'required'   => array( '[TICKET_LINE_ITEM_LIST]' ),
158
+				'shortcodes' => array('line_item', 'ticket', 'line_item_list'),
159
+				'required'   => array('[TICKET_LINE_ITEM_LIST]'),
160 160
 			),
161 161
 			'price_modifier_line_item_list' => array(
162
-				'shortcodes' => array( 'line_item' ),
163
-				'required'   => array( '[PRICE_MODIFIER_LINE_ITEM_LIST]' ),
162
+				'shortcodes' => array('line_item'),
163
+				'required'   => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'),
164 164
 			),
165 165
 			'datetime_list'                 => array(
166
-				'shortcodes' => array( 'datetime' ),
167
-				'required'   => array( '[DATETIME_LIST]' ),
166
+				'shortcodes' => array('datetime'),
167
+				'required'   => array('[DATETIME_LIST]'),
168 168
 			),
169 169
 			'attendee_list'                 => array(
170
-				'shortcodes' => array( 'attendee' ),
171
-				'required'   => array( '[ATTENDEE_LIST]' ),
170
+				'shortcodes' => array('attendee'),
171
+				'required'   => array('[ATTENDEE_LIST]'),
172 172
 			),
173 173
 			'tax_line_item_list'            => array(
174
-				'shortcodes' => array( 'line_item' ),
175
-				'required'   => array( '[TAX_LINE_ITEM_LIST]' ),
174
+				'shortcodes' => array('line_item'),
175
+				'required'   => array('[TAX_LINE_ITEM_LIST]'),
176 176
 			),
177 177
 			'additional_line_item_list'     => array(
178
-				'shortcodes' => array( 'line_item' ),
179
-				'required'   => array( '[ADDITIONAL_LINE_ITEM_LIST]' ),
178
+				'shortcodes' => array('line_item'),
179
+				'required'   => array('[ADDITIONAL_LINE_ITEM_LIST]'),
180 180
 			),
181 181
 			'payment_list'                  => array(
182
-				'shortcodes' => array( 'payment' ),
183
-				'required'   => array( '[PAYMENT_LIST_*]' ),
182
+				'shortcodes' => array('payment'),
183
+				'required'   => array('[PAYMENT_LIST_*]'),
184 184
 			),
185 185
 		);
186 186
 	}
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 	 * @param string $sending_messenger_name the name of the sending messenger so we only set the hooks needed.
197 197
 	 * @return void
198 198
 	 */
199
-	public function do_secondary_messenger_hooks( $sending_messenger_name ) {
200
-		if ( $sending_messenger_name = 'pdf' ) {
201
-			add_filter( 'EE_messenger__get_variation__variation', array( $this, 'add_html_css' ), 10, 8 );
199
+	public function do_secondary_messenger_hooks($sending_messenger_name) {
200
+		if ($sending_messenger_name = 'pdf') {
201
+			add_filter('EE_messenger__get_variation__variation', array($this, 'add_html_css'), 10, 8);
202 202
 		}
203 203
 	}
204 204
 
@@ -247,7 +247,7 @@  discard block
 block discarded – undo
247 247
 	 */
248 248
 	public function enqueue_scripts_styles() {
249 249
 		parent::enqueue_scripts_styles();
250
-		do_action( 'AHEE__EE_Html_messenger__enqueue_scripts_styles' );
250
+		do_action('AHEE__EE_Html_messenger__enqueue_scripts_styles');
251 251
 	}
252 252
 
253 253
 
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 		$this->_template_fields = array(
276 276
 			'subject' => array(
277 277
 				'input'      => 'text',
278
-				'label'      => __( 'Page Title', 'event_espresso' ),
278
+				'label'      => __('Page Title', 'event_espresso'),
279 279
 				'type'       => 'string',
280 280
 				'required'   => true,
281 281
 				'validation' => true,
@@ -288,7 +288,7 @@  discard block
 block discarded – undo
288 288
 				'content' => array(
289 289
 					'main'                          => array(
290 290
 						'input'      => 'wp_editor',
291
-						'label'      => __( 'Main Content', 'event_espresso' ),
291
+						'label'      => __('Main Content', 'event_espresso'),
292 292
 						'type'       => 'string',
293 293
 						'required'   => true,
294 294
 						'validation' => true,
@@ -303,7 +303,7 @@  discard block
 block discarded – undo
303 303
 						'validation'          => true,
304 304
 						'format'              => '%s',
305 305
 						'rows'                => '15',
306
-						'shortcodes_required' => array( '[EVENT_LIST]' ),
306
+						'shortcodes_required' => array('[EVENT_LIST]'),
307 307
 					),
308 308
 					'ticket_list'                   => array(
309 309
 						'input'               => 'textarea',
@@ -314,11 +314,11 @@  discard block
 block discarded – undo
314 314
 						'format'              => '%s',
315 315
 						'css_class'           => 'large-text',
316 316
 						'rows'                => '10',
317
-						'shortcodes_required' => array( '[TICKET_LIST]' ),
317
+						'shortcodes_required' => array('[TICKET_LIST]'),
318 318
 					),
319 319
 					'ticket_line_item_no_pms'       => array(
320 320
 						'input'               => 'textarea',
321
-						'label'               => '[TICKET_LINE_ITEM_LIST] <br>' . __(
321
+						'label'               => '[TICKET_LINE_ITEM_LIST] <br>'.__(
322 322
 								'Ticket Line Item List with no Price Modifiers',
323 323
 								'event_espresso'
324 324
 							),
@@ -328,11 +328,11 @@  discard block
 block discarded – undo
328 328
 						'format'              => '%s',
329 329
 						'css_class'           => 'large-text',
330 330
 						'rows'                => '5',
331
-						'shortcodes_required' => array( '[TICKET_LINE_ITEM_LIST]' ),
331
+						'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'),
332 332
 					),
333 333
 					'ticket_line_item_pms'          => array(
334 334
 						'input'               => 'textarea',
335
-						'label'               => '[TICKET_LINE_ITEM_LIST] <br>' . __(
335
+						'label'               => '[TICKET_LINE_ITEM_LIST] <br>'.__(
336 336
 								'Ticket Line Item List with Price Modifiers',
337 337
 								'event_espresso'
338 338
 							),
@@ -342,7 +342,7 @@  discard block
 block discarded – undo
342 342
 						'format'              => '%s',
343 343
 						'css_class'           => 'large-text',
344 344
 						'rows'                => '5',
345
-						'shortcodes_required' => array( '[TICKET_LINE_ITEM_LIST]' ),
345
+						'shortcodes_required' => array('[TICKET_LINE_ITEM_LIST]'),
346 346
 					),
347 347
 					'price_modifier_line_item_list' => array(
348 348
 						'input'               => 'textarea',
@@ -353,7 +353,7 @@  discard block
 block discarded – undo
353 353
 						'format'              => '%s',
354 354
 						'css_class'           => 'large-text',
355 355
 						'rows'                => '5',
356
-						'shortcodes_required' => array( '[PRICE_MODIFIER_LINE_ITEM_LIST]' ),
356
+						'shortcodes_required' => array('[PRICE_MODIFIER_LINE_ITEM_LIST]'),
357 357
 					),
358 358
 					'datetime_list'                 => array(
359 359
 						'input'               => 'textarea',
@@ -364,7 +364,7 @@  discard block
 block discarded – undo
364 364
 						'format'              => '%s',
365 365
 						'css_class'           => 'large-text',
366 366
 						'rows'                => '5',
367
-						'shortcodes_required' => array( '[DATETIME_LIST]' ),
367
+						'shortcodes_required' => array('[DATETIME_LIST]'),
368 368
 					),
369 369
 					'attendee_list'                 => array(
370 370
 						'input'               => 'textarea',
@@ -375,7 +375,7 @@  discard block
 block discarded – undo
375 375
 						'format'              => '%s',
376 376
 						'css_class'           => 'large-text',
377 377
 						'rows'                => '5',
378
-						'shortcodes_required' => array( '[ATTENDEE_LIST]' ),
378
+						'shortcodes_required' => array('[ATTENDEE_LIST]'),
379 379
 					),
380 380
 					'tax_line_item_list'            => array(
381 381
 						'input'               => 'textarea',
@@ -386,7 +386,7 @@  discard block
 block discarded – undo
386 386
 						'format'              => '%s',
387 387
 						'css_class'           => 'large-text',
388 388
 						'rows'                => '5',
389
-						'shortcodes_required' => array( '[TAX_LINE_ITEM_LIST]' ),
389
+						'shortcodes_required' => array('[TAX_LINE_ITEM_LIST]'),
390 390
 					),
391 391
 					'additional_line_item_list'     => array(
392 392
 						'input'               => 'textarea',
@@ -397,7 +397,7 @@  discard block
 block discarded – undo
397 397
 						'format'              => '%s',
398 398
 						'css_class'           => 'large-text',
399 399
 						'rows'                => '5',
400
-						'shortcodes_required' => array( '[ADDITIONAL_LINE_ITEM_LIST]' ),
400
+						'shortcodes_required' => array('[ADDITIONAL_LINE_ITEM_LIST]'),
401 401
 					),
402 402
 					'payment_list'                  => array(
403 403
 						'input'               => 'textarea',
@@ -408,7 +408,7 @@  discard block
 block discarded – undo
408 408
 						'format'              => '%s',
409 409
 						'css_class'           => 'large-text',
410 410
 						'rows'                => '5',
411
-						'shortcodes_required' => array( '[PAYMENT_LIST_*]' ),
411
+						'shortcodes_required' => array('[PAYMENT_LIST_*]'),
412 412
 					),
413 413
 				),
414 414
 			),
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @since 4.5.0
423 423
 	 */
424 424
 	protected function _set_default_message_types() {
425
-		$this->_default_message_types = array( 'receipt', 'invoice' );
425
+		$this->_default_message_types = array('receipt', 'invoice');
426 426
 	}
427 427
 
428 428
 
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	 * @since 4.5.0
433 433
 	 */
434 434
 	protected function _set_valid_message_types() {
435
-		$this->_valid_message_types = array( 'receipt', 'invoice' );
435
+		$this->_valid_message_types = array('receipt', 'invoice');
436 436
 	}
437 437
 
438 438
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 */
446 446
 	protected function _send_message() {
447 447
 		$this->_template_args = array(
448
-			'page_title' => html_entity_decode( stripslashes( $this->_subject ), ENT_QUOTES, "UTF-8" ),
448
+			'page_title' => html_entity_decode(stripslashes($this->_subject), ENT_QUOTES, "UTF-8"),
449 449
 			'base_css'   => $this->get_variation(
450 450
 				$this->_tmp_pack,
451 451
 				$this->_incoming_message_type->name,
@@ -483,7 +483,7 @@  discard block
 block discarded – undo
483 483
 			),
484 484
 		);
485 485
 		$this->_deregister_wp_hooks();
486
-		add_action( 'wp_enqueue_scripts', array( $this, 'enqueue_scripts_styles' ) );
486
+		add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts_styles'));
487 487
 		echo $this->_get_main_template();
488 488
 		exit();
489 489
 	}
@@ -499,16 +499,16 @@  discard block
 block discarded – undo
499 499
 	 * @return void
500 500
 	 */
501 501
 	protected function _deregister_wp_hooks() {
502
-		remove_all_actions( 'wp_head' );
503
-		remove_all_actions( 'wp_footer' );
504
-		remove_all_actions( 'wp_print_footer_scripts' );
505
-		remove_all_actions( 'wp_enqueue_scripts' );
502
+		remove_all_actions('wp_head');
503
+		remove_all_actions('wp_footer');
504
+		remove_all_actions('wp_print_footer_scripts');
505
+		remove_all_actions('wp_enqueue_scripts');
506 506
 		global $wp_scripts, $wp_styles;
507 507
 		$wp_scripts = $wp_styles = array();
508 508
 		//just add back in wp_enqueue_scripts and wp_print_footer_scripts cause that's all we want to load.
509
-		add_action( 'wp_footer', 'wp_print_footer_scripts' );
510
-		add_action( 'wp_print_footer_scripts', '_wp_footer_scripts' );
511
-		add_action( 'wp_head', 'wp_enqueue_scripts' );
509
+		add_action('wp_footer', 'wp_print_footer_scripts');
510
+		add_action('wp_print_footer_scripts', '_wp_footer_scripts');
511
+		add_action('wp_head', 'wp_enqueue_scripts');
512 512
 	}
513 513
 
514 514
 
@@ -520,11 +520,11 @@  discard block
 block discarded – undo
520 520
 	 * @param bool $preview
521 521
 	 * @return string
522 522
 	 */
523
-	protected function _get_main_template( $preview = false ) {
524
-		$wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, 'main' );
523
+	protected function _get_main_template($preview = false) {
524
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name, 'main');
525 525
 		//include message type as a template arg
526 526
 		$this->_template_args['message_type'] = $this->_incoming_message_type;
527
-		return EEH_Template::display_template( $wrapper_template, $this->_template_args, true );
527
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, true);
528 528
 	}
529 529
 
530 530
 
@@ -557,15 +557,15 @@  discard block
 block discarded – undo
557 557
 		EE_message_type $incoming_message_type
558 558
 	) {
559 559
 		if (
560
-			( $incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt' )
561
-			&& apply_filters( 'FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true )
560
+			($incoming_message_type->name === 'invoice' || $incoming_message_type->name === 'receipt')
561
+			&& apply_filters('FHEE_EE_Html_messenger__add_powered_by_credit_link_to_receipt_and_invoice', true)
562 562
 		) {
563 563
 			$content .= \EEH_Template::powered_by_event_espresso(
564 564
 				'aln-cntr',
565 565
 				'',
566
-				array( 'utm_content' => 'messages_system' )
566
+				array('utm_content' => 'messages_system')
567 567
 			)
568
-			. EEH_HTML::div( EEH_HTML::p('&nbsp;') );
568
+			. EEH_HTML::div(EEH_HTML::p('&nbsp;'));
569 569
 		}
570 570
 		return $content;
571 571
 	}
Please login to merge, or discard this patch.
modules/ticket_selector/TicketSelectorIframeEmbedButton.php 2 patches
Indentation   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -17,27 +17,27 @@
 block discarded – undo
17 17
 class TicketSelectorIframeEmbedButton extends IframeEmbedButton
18 18
 {
19 19
 
20
-    /**
21
-     * TicketSelectorIframeEmbedButton constructor.
22
-     */
23
-    public function __construct()
24
-    {
25
-        parent::__construct(
26
-            esc_html__( 'Ticket Selector', 'event_espresso' ),
27
-            'ticket_selector'
28
-        );
29
-    }
30
-
31
-
32
-
33
-    /**
34
-     * Adds an iframe embed code button to the Event editor.
35
-     */
36
-    public function addEventEditorIframeEmbedButton()
37
-    {
38
-        // add button for iframe code to event editor.
39
-        $this->addEventEditorIframeEmbedButtonFilter();
40
-    }
20
+	/**
21
+	 * TicketSelectorIframeEmbedButton constructor.
22
+	 */
23
+	public function __construct()
24
+	{
25
+		parent::__construct(
26
+			esc_html__( 'Ticket Selector', 'event_espresso' ),
27
+			'ticket_selector'
28
+		);
29
+	}
30
+
31
+
32
+
33
+	/**
34
+	 * Adds an iframe embed code button to the Event editor.
35
+	 */
36
+	public function addEventEditorIframeEmbedButton()
37
+	{
38
+		// add button for iframe code to event editor.
39
+		$this->addEventEditorIframeEmbedButtonFilter();
40
+	}
41 41
 
42 42
 
43 43
 
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -3,7 +3,7 @@  discard block
 block discarded – undo
3 3
 
4 4
 use EventEspresso\core\libraries\iframe_display\IframeEmbedButton;
5 5
 
6
-defined( 'ABSPATH' ) || exit;
6
+defined('ABSPATH') || exit;
7 7
 
8 8
 
9 9
 
@@ -23,7 +23,7 @@  discard block
 block discarded – undo
23 23
     public function __construct()
24 24
     {
25 25
         parent::__construct(
26
-            esc_html__( 'Ticket Selector', 'event_espresso' ),
26
+            esc_html__('Ticket Selector', 'event_espresso'),
27 27
             'ticket_selector'
28 28
         );
29 29
     }
Please login to merge, or discard this patch.
core/Factory.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 
4 4
 use EventEspresso\core\libraries\iframe_display\Iframe;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
7
-	exit( 'No direct script access allowed' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
7
+	exit('No direct script access allowed');
8 8
 }
9 9
 
10 10
 
@@ -26,10 +26,10 @@  discard block
 block discarded – undo
26 26
 	 * @return mixed|null
27 27
 	 * @throws \EE_Error
28 28
 	 */
29
-	public static function create( $class_name, $arguments = array() ) {
30
-		if ( empty( $class_name ) ) {
29
+	public static function create($class_name, $arguments = array()) {
30
+		if (empty($class_name)) {
31 31
 			throw new \EE_Error(
32
-				__( 'You must provide a class name in order to instantiate it.', 'event_espresso' )
32
+				__('You must provide a class name in order to instantiate it.', 'event_espresso')
33 33
 			);
34 34
 		}
35 35
 		// if ( ! class_exists( $class_name ) ) {
@@ -41,20 +41,20 @@  discard block
 block discarded – undo
41 41
 		// 	);
42 42
 		// }
43 43
 		$object = null;
44
-		switch ( $class_name ) {
44
+		switch ($class_name) {
45 45
 
46 46
 			case 'EE_Request' :
47
-				$object = new \EE_Request( $_GET, $_POST, $_COOKIE );
47
+				$object = new \EE_Request($_GET, $_POST, $_COOKIE);
48 48
 				break;
49 49
 
50 50
 			case 'Iframe' :
51
-				$title = isset( $arguments['title'] ) ? $arguments['title'] : null;
52
-				$content = isset( $arguments['content'] ) ? $arguments['content'] : null;
53
-				$object = new Iframe( $title, $content );
51
+				$title = isset($arguments['title']) ? $arguments['title'] : null;
52
+				$content = isset($arguments['content']) ? $arguments['content'] : null;
53
+				$object = new Iframe($title, $content);
54 54
 				break;
55 55
 
56 56
 			default :
57
-				$object = new $class_name( $arguments );
57
+				$object = new $class_name($arguments);
58 58
 
59 59
 		}
60 60
 
Please login to merge, or discard this patch.
messages/message_type/newsletter/EE_Newsletter_message_type.class.php 2 patches
Spacing   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -22,10 +22,10 @@  discard block
 block discarded – undo
22 22
 
23 23
 	public function __construct() {
24 24
 		$this->name = 'newsletter';
25
-		$this->description = __( 'Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso' );
25
+		$this->description = __('Batch message type messages are triggered manually by the admin for sending notifications to a selected group of recipients. This should only be used for more general notification type messages that contain information specific for the recipients. For "newsletter" type messages we recommend using an email list service like MailChimp, because sending non-related mail-outs to contacts increases the risk of your site domain getting added to spam lists, which will prevent messages getting to users.', 'event_espresso');
26 26
 		$this->label = array(
27
-			'singular' => __( 'batch', 'event_espresso' ),
28
-			'plural' => __( 'batches', 'event_espresso' )
27
+			'singular' => __('batch', 'event_espresso'),
28
+			'plural' => __('batches', 'event_espresso')
29 29
 			);
30 30
 		$this->_master_templates = array(
31 31
 			'email' => 'registration',
@@ -49,9 +49,9 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 
52
-	protected function _get_data_for_context( $context, EE_Registration $registration, $id ) {
52
+	protected function _get_data_for_context($context, EE_Registration $registration, $id) {
53 53
 		//newsletter message type data handler is 'Registrations' and it expects an array of EE_Registration objects.
54
-		return array( $registration );
54
+		return array($registration);
55 55
 	}
56 56
 
57 57
 
@@ -64,15 +64,15 @@  discard block
 block discarded – undo
64 64
 
65 65
 	protected function _set_contexts() {
66 66
 		$this->_context_label = array(
67
-			'label' => __( 'recipient', 'event_espresso' ),
68
-			'plural' => __( 'recipients', 'event_espresso' ),
69
-			'description' => __( 'Recipient\'s are who will receive the message.', 'event_espresso' )
67
+			'label' => __('recipient', 'event_espresso'),
68
+			'plural' => __('recipients', 'event_espresso'),
69
+			'description' => __('Recipient\'s are who will receive the message.', 'event_espresso')
70 70
 			);
71 71
 
72 72
 		$this->_contexts = array(
73 73
 			'attendee' => array(
74
-				'label' => __( 'Registrant', 'event_espresso' ),
75
-				'description' => __( 'This template goes to selected registrants.', 'event_espresso' )
74
+				'label' => __('Registrant', 'event_espresso'),
75
+				'description' => __('This template goes to selected registrants.', 'event_espresso')
76 76
 				)
77 77
 			);
78 78
 	}
@@ -98,13 +98,13 @@  discard block
 block discarded – undo
98 98
 			'newsletter',
99 99
 			);
100 100
 
101
-		foreach ( $this->_valid_shortcodes as $context => $shortcodes ) {
102
-			foreach ( $shortcodes as $key => $shortcode ) {
103
-				if ( ! in_array( $shortcode, $included_shortcodes ) ) {
104
-					unset( $this->_valid_shortcodes[ $context ][ $key ] );
101
+		foreach ($this->_valid_shortcodes as $context => $shortcodes) {
102
+			foreach ($shortcodes as $key => $shortcode) {
103
+				if ( ! in_array($shortcode, $included_shortcodes)) {
104
+					unset($this->_valid_shortcodes[$context][$key]);
105 105
 				}
106 106
 			}
107
-			$this->_valid_shortcodes[ $context ][] = 'newsletter';
107
+			$this->_valid_shortcodes[$context][] = 'newsletter';
108 108
 		}
109 109
 
110 110
 	}
@@ -118,44 +118,44 @@  discard block
 block discarded – undo
118 118
 		$addressee = array();
119 119
 
120 120
 		//looping through registrations
121
-		foreach ( $this->_data->registrations as $reg_id => $details ) {
121
+		foreach ($this->_data->registrations as $reg_id => $details) {
122 122
 			//set $attendee array to blank on each loop
123 123
 			$aee = array();
124 124
 
125 125
 			//need to get the attendee from this registration.
126
-			$attendee = isset( $details['att_obj'] ) && $details['att_obj'] instanceof EE_Attendee
126
+			$attendee = isset($details['att_obj']) && $details['att_obj'] instanceof EE_Attendee
127 127
 				? $details['att_obj']
128 128
 				: null;
129 129
 
130
-			if ( ! $attendee instanceof EE_Attendee ) {
130
+			if ( ! $attendee instanceof EE_Attendee) {
131 131
 				continue;
132 132
 			}
133 133
 
134 134
 			//set $aee from attendee object
135 135
 			$aee['att_obj'] = $attendee;
136
-			$aee['reg_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['reg_objs'] )
137
-				? $this->_data->attendees[ $attendee->ID() ]['reg_objs']
136
+			$aee['reg_objs'] = isset($this->_data->attendees[$attendee->ID()]['reg_objs'])
137
+				? $this->_data->attendees[$attendee->ID()]['reg_objs']
138 138
 				: array();
139 139
 			$aee['attendee_email'] = $attendee->email();
140
-			$aee['tkt_objs'] = isset( $this->_data->attendees[ $attendee->ID() ]['tkt_objs'] )
141
-				? $this->_data->attendees[ $attendee->ID() ]['tkt_objs']
140
+			$aee['tkt_objs'] = isset($this->_data->attendees[$attendee->ID()]['tkt_objs'])
141
+				? $this->_data->attendees[$attendee->ID()]['tkt_objs']
142 142
 				: array();
143 143
 
144
-			if ( isset( $this->_data->attendees[ $attendee->ID() ]['evt_objs'] ) ) {
145
-				$aee['evt_objs'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs'];
146
-				$aee['events'] = $this->_data->attendees[ $attendee->ID() ]['evt_objs'];
144
+			if (isset($this->_data->attendees[$attendee->ID()]['evt_objs'])) {
145
+				$aee['evt_objs'] = $this->_data->attendees[$attendee->ID()]['evt_objs'];
146
+				$aee['events'] = $this->_data->attendees[$attendee->ID()]['evt_objs'];
147 147
 			} else {
148 148
 				$aee['evt_objs'] = $aee['events'] = array();
149 149
 			}
150 150
 
151
-			$aee['reg_obj'] = isset( $details['reg_obj'] )
151
+			$aee['reg_obj'] = isset($details['reg_obj'])
152 152
 				? $details['reg_obj']
153 153
 				: null;
154 154
 			$aee['attendees'] = $this->_data->attendees;
155 155
 
156 156
 			//merge in the primary attendee data
157
-			$aee = array_merge( $this->_default_addressee_data, $aee );
158
-			$addressee[] = new EE_Messages_Addressee( $aee );
157
+			$aee = array_merge($this->_default_addressee_data, $aee);
158
+			$addressee[] = new EE_Messages_Addressee($aee);
159 159
 		}
160 160
 		return $addressee;
161 161
 	}
Please login to merge, or discard this patch.
Braces   +3 added lines, -1 removed lines patch added patch discarded remove patch
@@ -5,7 +5,9 @@
 block discarded – undo
5 5
  * @subpackage helpers
6 6
  * @since           4.3.0
7 7
  */
8
-if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed');
8
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
9
+	exit('No direct script access allowed');
10
+}
9 11
 
10 12
 /**
11 13
  * The message type for newsletter type of messages.
Please login to merge, or discard this patch.
payment_methods/Paypal_Standard/EEG_Paypal_Standard.gateway.php 2 patches
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -274,26 +274,26 @@  discard block
 block discarded – undo
274 274
 		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
275 275
 			return $payment;
276 276
 		}
277
-        // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
278
-        // registrations, ticket counts, etc)
279
-        if (
280
-            (
281
-                $update_info[ 'payment_status' ] === 'Refunded'
282
-                || $update_info[ 'payment_status' ] === 'Partially_Refunded'
283
-            )
284
-            && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true )
285
-        ) {
286
-            throw new EventEspresso\core\exceptions\IpnException(
287
-                sprintf(
288
-                    esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
289
-                    $update_info['payment_status']
290
-                ),
291
-                EventEspresso\core\exceptions\IpnException::UNSUPPORTED,
292
-                null,
293
-                $payment,
294
-                $update_info
295
-            );
296
-        }
277
+		// kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
278
+		// registrations, ticket counts, etc)
279
+		if (
280
+			(
281
+				$update_info[ 'payment_status' ] === 'Refunded'
282
+				|| $update_info[ 'payment_status' ] === 'Partially_Refunded'
283
+			)
284
+			&& apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true )
285
+		) {
286
+			throw new EventEspresso\core\exceptions\IpnException(
287
+				sprintf(
288
+					esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
289
+					$update_info['payment_status']
290
+				),
291
+				EventEspresso\core\exceptions\IpnException::UNSUPPORTED,
292
+				null,
293
+				$payment,
294
+				$update_info
295
+			);
296
+		}
297 297
 		//ok, well let's process this payment then!
298 298
 		switch ( $update_info[ 'payment_status' ] ) {
299 299
 
@@ -541,17 +541,17 @@  discard block
 block discarded – undo
541 541
 
542 542
 		//might paypal have changed the taxes?
543 543
 		if( $this->_paypal_taxes && $payment_was_itemized ) {
544
-            // note that we're doing this BEFORE adding shipping;
544
+			// note that we're doing this BEFORE adding shipping;
545 545
 			// we actually want PayPal's shipping to remain non-taxable
546
-            $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
547
-            $this->_line_item->set_total_tax_to(
548
-	            $transaction_total_line_item,
549
-                (float)$update_info['tax'],
550
-                esc_html__( 'Taxes', 'event_espresso' ),
551
-                esc_html__( 'Calculated by Paypal', 'event_espresso' ),
552
-                'paypal_tax'
553
-            );
554
-            $grand_total_needs_resaving = TRUE;
546
+			$this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
547
+			$this->_line_item->set_total_tax_to(
548
+				$transaction_total_line_item,
549
+				(float)$update_info['tax'],
550
+				esc_html__( 'Taxes', 'event_espresso' ),
551
+				esc_html__( 'Calculated by Paypal', 'event_espresso' ),
552
+				'paypal_tax'
553
+			);
554
+			$grand_total_needs_resaving = TRUE;
555 555
 		}
556 556
 
557 557
 		$shipping_amount = (float)$update_info[ 'mc_shipping' ];
Please login to merge, or discard this patch.
Spacing   +122 added lines, -122 removed lines patch added patch discarded remove patch
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 	 * @return EEG_Paypal_Standard
71 71
 	 */
72 72
 	public function __construct() {
73
-		$this->set_uses_separate_IPN_request( true ) ;
73
+		$this->set_uses_separate_IPN_request(true);
74 74
 		parent::__construct();
75 75
 	}
76 76
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * Also sets the gateway url class variable based on whether debug mode is enabled or not
81 81
 	 * @param array $settings_array
82 82
 	 */
83
-	public function set_settings($settings_array){
83
+	public function set_settings($settings_array) {
84 84
 		parent::set_settings($settings_array);
85 85
 		$this->_gateway_url = $this->_debug_mode
86 86
 			? 'https://www.sandbox.paypal.com/cgi-bin/webscr'
@@ -114,42 +114,42 @@  discard block
 block discarded – undo
114 114
 
115 115
 		$total_discounts_to_cart_total = $transaction->paid();
116 116
 		//only itemize the order if we're paying for the rest of the order's amount
117
-		if( EEH_Money::compare_floats( $payment->amount(), $transaction->total(), '==' ) ) {
118
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true );
117
+		if (EEH_Money::compare_floats($payment->amount(), $transaction->total(), '==')) {
118
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true);
119 119
 			//this payment is for the remaining transaction amount,
120 120
 			//keep track of exactly how much the itemized order amount equals
121 121
 			$itemized_sum = 0;
122 122
 			$shipping_previously_added = 0;
123 123
 			//so let's show all the line items
124
-			foreach($total_line_item->get_items() as $line_item){
125
-				if ( $line_item instanceof EE_Line_Item ) {
124
+			foreach ($total_line_item->get_items() as $line_item) {
125
+				if ($line_item instanceof EE_Line_Item) {
126 126
 					//it's some kind of discount
127
-					if( $line_item->total() < 0 ) {
128
-						$total_discounts_to_cart_total += abs( $line_item->total() );
127
+					if ($line_item->total() < 0) {
128
+						$total_discounts_to_cart_total += abs($line_item->total());
129 129
 						$itemized_sum += $line_item->total();
130 130
 						continue;
131 131
 					}
132 132
 					//dont include shipping again.
133
-					if( strpos( $line_item->code(), 'paypal_shipping_') === 0 ) {
133
+					if (strpos($line_item->code(), 'paypal_shipping_') === 0) {
134 134
 						$shipping_previously_added = $line_item->total();
135 135
 						continue;
136 136
 					}
137
-					$redirect_args[ 'item_name_' . $item_num ] = substr(
138
-						$this->_format_line_item_name( $line_item, $payment ),
137
+					$redirect_args['item_name_'.$item_num] = substr(
138
+						$this->_format_line_item_name($line_item, $payment),
139 139
 						0, 127
140 140
 					);
141
-					$redirect_args[ 'amount_' . $item_num ] = $line_item->unit_price();
142
-					$redirect_args[ 'quantity_' . $item_num ] = $line_item->quantity();
141
+					$redirect_args['amount_'.$item_num] = $line_item->unit_price();
142
+					$redirect_args['quantity_'.$item_num] = $line_item->quantity();
143 143
 					//if we're not letting PayPal calculate shipping, tell them its 0
144
-					if ( ! $this->_paypal_shipping ) {
145
-						$redirect_args[ 'shipping_' . $item_num ] = '0';
146
-						$redirect_args[ 'shipping2_' . $item_num ] = '0';
144
+					if ( ! $this->_paypal_shipping) {
145
+						$redirect_args['shipping_'.$item_num] = '0';
146
+						$redirect_args['shipping2_'.$item_num] = '0';
147 147
 					}
148 148
 					$item_num++;
149 149
 					$itemized_sum += $line_item->total();
150 150
 				}
151 151
 			}
152
-			$taxes_li = $this->_line_item->get_taxes_subtotal( $total_line_item );
152
+			$taxes_li = $this->_line_item->get_taxes_subtotal($total_line_item);
153 153
 			//ideally itemized sum equals the transaction total. but if not (which is weird)
154 154
 			//and the itemized sum is LESS than the transaction total
155 155
 			//add another line item
@@ -159,47 +159,47 @@  discard block
 block discarded – undo
159 159
 				$transaction->total() - $itemized_sum - $taxes_li->total() - $shipping_previously_added,
160 160
 				2
161 161
 			);
162
-			if( $itemized_sum_diff_from_txn_total < 0 ) {
162
+			if ($itemized_sum_diff_from_txn_total < 0) {
163 163
 				//itemized sum is too big
164
-				$total_discounts_to_cart_total += abs( $itemized_sum_diff_from_txn_total );
165
-			} elseif( $itemized_sum_diff_from_txn_total > 0 ) {
166
-				$redirect_args[ 'item_name_' . $item_num ] = substr(
167
-						__( 'Other charges', 'event_espresso' ), 0, 127 );
168
-				$redirect_args[ 'amount_' . $item_num ] = $this->format_currency( $itemized_sum_diff_from_txn_total );
169
-				$redirect_args[ 'quantity_' . $item_num ] = 1;
164
+				$total_discounts_to_cart_total += abs($itemized_sum_diff_from_txn_total);
165
+			} elseif ($itemized_sum_diff_from_txn_total > 0) {
166
+				$redirect_args['item_name_'.$item_num] = substr(
167
+						__('Other charges', 'event_espresso'), 0, 127 );
168
+				$redirect_args['amount_'.$item_num] = $this->format_currency($itemized_sum_diff_from_txn_total);
169
+				$redirect_args['quantity_'.$item_num] = 1;
170 170
 				$item_num++;
171 171
 			}
172
-			if( $total_discounts_to_cart_total > 0 ) {
173
-				$redirect_args[ 'discount_amount_cart' ] = $this->format_currency( $total_discounts_to_cart_total );
172
+			if ($total_discounts_to_cart_total > 0) {
173
+				$redirect_args['discount_amount_cart'] = $this->format_currency($total_discounts_to_cart_total);
174 174
 			}
175 175
 			//add our taxes to the order if we're NOT using PayPal's
176
-			if( ! $this->_paypal_taxes ){
176
+			if ( ! $this->_paypal_taxes) {
177 177
 				$redirect_args['tax_cart'] = $total_line_item->get_total_tax();
178 178
 			}
179 179
 		} else {
180
-			$payment->update_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, false );
180
+			$payment->update_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, false);
181 181
 			//partial payment that's not for the remaining amount, so we can't send an itemized list
182
-			$redirect_args['item_name_' . $item_num] = substr(
183
-				$this->_format_partial_payment_line_item_name( $payment ),
182
+			$redirect_args['item_name_'.$item_num] = substr(
183
+				$this->_format_partial_payment_line_item_name($payment),
184 184
 				0, 127
185 185
 			);
186
-			$redirect_args['amount_' . $item_num] = $payment->amount();
187
-			$redirect_args['shipping_' . $item_num ] = '0';
188
-			$redirect_args['shipping2_' . $item_num ] = '0';
186
+			$redirect_args['amount_'.$item_num] = $payment->amount();
187
+			$redirect_args['shipping_'.$item_num] = '0';
188
+			$redirect_args['shipping2_'.$item_num] = '0';
189 189
 			$redirect_args['tax_cart'] = '0';
190 190
 			$item_num++;
191 191
 		}
192 192
 
193
-		if($this->_debug_mode){
194
-			$redirect_args['item_name_' . $item_num] = 'DEBUG INFO (this item only added in sandbox mode';
195
-			$redirect_args['amount_' . $item_num] = 0;
193
+		if ($this->_debug_mode) {
194
+			$redirect_args['item_name_'.$item_num] = 'DEBUG INFO (this item only added in sandbox mode';
195
+			$redirect_args['amount_'.$item_num] = 0;
196 196
 			$redirect_args['on0_'.$item_num] = 'NOTIFY URL';
197
-			$redirect_args['os0_' . $item_num] = $notify_url;
197
+			$redirect_args['os0_'.$item_num] = $notify_url;
198 198
 			$redirect_args['on1_'.$item_num] = 'RETURN URL';
199
-			$redirect_args['os1_' . $item_num] = $return_url;
199
+			$redirect_args['os1_'.$item_num] = $return_url;
200 200
 //			$redirect_args['option_index_' . $item_num] = 1; // <-- dunno if this is needed ?
201
-			$redirect_args['shipping_' . $item_num ] = '0';
202
-			$redirect_args['shipping2_' . $item_num ] = '0';
201
+			$redirect_args['shipping_'.$item_num] = '0';
202
+			$redirect_args['shipping2_'.$item_num] = '0';
203 203
 		}
204 204
 
205 205
 		$redirect_args['business'] = $this->_paypal_id;
@@ -209,14 +209,14 @@  discard block
 block discarded – undo
209 209
 		$redirect_args['cmd'] = '_cart';
210 210
 		$redirect_args['upload'] = 1;
211 211
 		$redirect_args['currency_code'] = $payment->currency_code();
212
-		$redirect_args['rm'] = 2;//makes the user return with method=POST
213
-		if($this->_image_url){
212
+		$redirect_args['rm'] = 2; //makes the user return with method=POST
213
+		if ($this->_image_url) {
214 214
 			$redirect_args['image_url'] = $this->_image_url;
215 215
 		}
216 216
 		$redirect_args['no_shipping'] = $this->_shipping_details;
217
-		$redirect_args['bn'] = 'EventEspresso_SP';//EE will blow up if you change this
217
+		$redirect_args['bn'] = 'EventEspresso_SP'; //EE will blow up if you change this
218 218
 
219
-		$redirect_args = apply_filters( "FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this );
219
+		$redirect_args = apply_filters("FHEE__EEG_Paypal_Standard__set_redirection_info__arguments", $redirect_args, $this);
220 220
 
221 221
 		$payment->set_redirect_url($this->_gateway_url);
222 222
 		$payment->set_redirect_args($redirect_args);
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
 		$this->log(
225 225
 			array(
226 226
 				'message'     => sprintf(
227
-					__( 'PayPal payment request initiated.', 'event_espresso' )
227
+					__('PayPal payment request initiated.', 'event_espresso')
228 228
 				),
229 229
 				'transaction' => $transaction->model_field_array(),
230 230
 			),
@@ -244,14 +244,14 @@  discard block
 block discarded – undo
244 244
 	 * @return \EEI_Payment updated
245 245
 	 * @throws \EE_Error, IpnException
246 246
 	 */
247
-	public function handle_payment_update( $update_info, $transaction ){
247
+	public function handle_payment_update($update_info, $transaction) {
248 248
 		// verify there's payment data that's been sent
249
-		if ( empty( $update_info[ 'payment_status' ] ) || empty( $update_info[ 'txn_id' ] ) ) {
249
+		if (empty($update_info['payment_status']) || empty($update_info['txn_id'])) {
250 250
 			// log the results
251 251
 			$this->log(
252 252
 				array(
253 253
 					'message' => sprintf(
254
-						__( 'PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso' )
254
+						__('PayPal IPN response is missing critical payment data. This may indicate a PDT request and require your PayPal account settings to be corrected.', 'event_espresso')
255 255
 					),
256 256
 					'update_info' => $update_info,
257 257
 				),
@@ -259,33 +259,33 @@  discard block
 block discarded – undo
259 259
 			);
260 260
 			// waaaait... is this a PDT request? (see https://developer.paypal.com/docs/classic/products/payment-data-transfer/)
261 261
 			// indicated by the "tx" argument? If so, we don't need it. We'll just use the IPN data when it comes
262
-			if ( isset( $update_info[ 'tx' ] ) ) {
262
+			if (isset($update_info['tx'])) {
263 263
 				return $transaction->last_payment();
264 264
 			} else {
265 265
 				return null;
266 266
 			}
267 267
 		}
268
-		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
269
-		if ( ! $payment instanceof EEI_Payment ) {
268
+		$payment = $this->_pay_model->get_payment_by_txn_id_chq_nmbr($update_info['txn_id']);
269
+		if ( ! $payment instanceof EEI_Payment) {
270 270
 			$payment = $transaction->last_payment();
271 271
 		}
272 272
 		// ok, then validate the IPN. Even if we've already processed this payment,
273 273
 		// let PayPal know we don't want to hear from them anymore!
274
-		if ( ! $this->validate_ipn( $update_info, $payment ) ) {
274
+		if ( ! $this->validate_ipn($update_info, $payment)) {
275 275
 			return $payment;
276 276
 		}
277 277
         // kill request here if this is a refund, we don't support them yet (we'd need to adjust the transaction,
278 278
         // registrations, ticket counts, etc)
279 279
         if (
280 280
             (
281
-                $update_info[ 'payment_status' ] === 'Refunded'
282
-                || $update_info[ 'payment_status' ] === 'Partially_Refunded'
281
+                $update_info['payment_status'] === 'Refunded'
282
+                || $update_info['payment_status'] === 'Partially_Refunded'
283 283
             )
284
-            && apply_filters( 'FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true )
284
+            && apply_filters('FHEE__EEG_Paypal_Standard__handle_payment_update__kill_refund_request', true)
285 285
         ) {
286 286
             throw new EventEspresso\core\exceptions\IpnException(
287 287
                 sprintf(
288
-                    esc_html__( 'Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
288
+                    esc_html__('Event Espresso does not yet support %1$s IPNs from PayPal', 'event_espresso'),
289 289
                     $update_info['payment_status']
290 290
                 ),
291 291
                 EventEspresso\core\exceptions\IpnException::UNSUPPORTED,
@@ -295,34 +295,34 @@  discard block
 block discarded – undo
295 295
             );
296 296
         }
297 297
 		//ok, well let's process this payment then!
298
-		switch ( $update_info[ 'payment_status' ] ) {
298
+		switch ($update_info['payment_status']) {
299 299
 
300 300
 			case 'Completed' :
301 301
 				$status = $this->_pay_model->approved_status();
302
-				$gateway_response = esc_html__( 'The payment is approved.', 'event_espresso' );
302
+				$gateway_response = esc_html__('The payment is approved.', 'event_espresso');
303 303
 				break;
304 304
 
305 305
 			case 'Pending' :
306 306
 				$status = $this->_pay_model->pending_status();
307
-				$gateway_response = esc_html__( 'The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso' );
307
+				$gateway_response = esc_html__('The payment is in progress. Another message will be sent when payment is approved.', 'event_espresso');
308 308
 				break;
309 309
 
310 310
 			case 'Denied' :
311 311
 				$status = $this->_pay_model->declined_status();
312
-				$gateway_response = esc_html__( 'The payment has been declined.', 'event_espresso' );
312
+				$gateway_response = esc_html__('The payment has been declined.', 'event_espresso');
313 313
 				break;
314 314
 
315 315
 			case 'Expired' :
316 316
 			case 'Failed' :
317 317
 				$status = $this->_pay_model->failed_status();
318
-				$gateway_response = esc_html__( 'The payment failed for technical reasons or expired.', 'event_espresso' );
318
+				$gateway_response = esc_html__('The payment failed for technical reasons or expired.', 'event_espresso');
319 319
 				break;
320 320
 
321 321
 			case 'Refunded' :
322 322
 			case 'Partially_Refunded' :
323 323
 				// even though it's a refund, we consider the payment as approved, it just has a negative value
324 324
 				$status = $this->_pay_model->approved_status();
325
-				$gateway_response = esc_html__( 'The payment has been refunded. Please update registrations accordingly.', 'event_espresso' );
325
+				$gateway_response = esc_html__('The payment has been refunded. Please update registrations accordingly.', 'event_espresso');
326 326
 				break;
327 327
 
328 328
 			case 'Voided' :
@@ -330,19 +330,19 @@  discard block
 block discarded – undo
330 330
 			case 'Canceled_Reversal' :
331 331
 			default :
332 332
 				$status = $this->_pay_model->cancelled_status();
333
-				$gateway_response = esc_html__( 'The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso' );
333
+				$gateway_response = esc_html__('The payment was cancelled, reversed, or voided. Please update registrations accordingly.', 'event_espresso');
334 334
 				break;
335 335
 
336 336
 		}
337 337
 
338 338
 		//check if we've already processed this payment
339
-		if ( $payment instanceof EEI_Payment ) {
339
+		if ($payment instanceof EEI_Payment) {
340 340
 			//payment exists. if this has the exact same status and amount, don't bother updating. just return
341
-			if ( $payment->status() === $status && (float)$payment->amount() === (float)$update_info[ 'mc_gross' ] ) {
341
+			if ($payment->status() === $status && (float) $payment->amount() === (float) $update_info['mc_gross']) {
342 342
 				// DUPLICATED IPN! don't bother updating transaction
343 343
 				throw new IpnException(
344 344
 					sprintf(
345
-						esc_html__( 'It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso' ),
345
+						esc_html__('It appears we have received a duplicate IPN from PayPal for payment %d', 'event_espresso'),
346 346
 						$payment->ID()
347 347
 					),
348 348
 					IpnException::DUPLICATE,
@@ -352,14 +352,14 @@  discard block
 block discarded – undo
352 352
 				);
353 353
 			} else {
354 354
 				// new payment yippee !!!
355
-				$payment->set_status( $status );
356
-				$payment->set_amount( (float)$update_info[ 'mc_gross' ] );
357
-				$payment->set_gateway_response( $gateway_response );
358
-				$payment->set_details( $update_info );
359
-				$payment->set_txn_id_chq_nmbr( $update_info[ 'txn_id' ] );
355
+				$payment->set_status($status);
356
+				$payment->set_amount((float) $update_info['mc_gross']);
357
+				$payment->set_gateway_response($gateway_response);
358
+				$payment->set_details($update_info);
359
+				$payment->set_txn_id_chq_nmbr($update_info['txn_id']);
360 360
 				$this->log(
361 361
 					array(
362
-						'message'  => esc_html__( 'Updated payment either from IPN or as part of POST from PayPal', 'event_espresso' ),
362
+						'message'  => esc_html__('Updated payment either from IPN or as part of POST from PayPal', 'event_espresso'),
363 363
 						'url'      => $this->_process_response_url(),
364 364
 						'payment'  => $payment->model_field_array(),
365 365
 						'IPN_data' => $update_info
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 			}
370 370
 
371 371
 		}
372
-		do_action( 'FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this );
372
+		do_action('FHEE__EEG_Paypal_Standard__handle_payment_update__payment_processed', $payment, $this);
373 373
 		return $payment;
374 374
 	}
375 375
 
@@ -384,9 +384,9 @@  discard block
 block discarded – undo
384 384
 	 * @return boolean
385 385
 	 * @throws \EE_Error
386 386
 	 */
387
-	public function validate_ipn( $update_info, $payment ) {
387
+	public function validate_ipn($update_info, $payment) {
388 388
 		//allow us to skip validating IPNs with PayPal (useful for testing)
389
-		if ( apply_filters( 'FHEE__EEG_Paypal_Standard__validate_ipn__skip', false ) ) {
389
+		if (apply_filters('FHEE__EEG_Paypal_Standard__validate_ipn__skip', false)) {
390 390
 			return true;
391 391
 		}
392 392
 		//...otherwise, we actually don't care what the $update_info is, we need to look
@@ -394,22 +394,22 @@  discard block
 block discarded – undo
394 394
 		// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
395 395
 		// Instead, read raw POST data from the input stream.
396 396
 		// @see https://gist.github.com/xcommerce-gists/3440401
397
-		$raw_post_data = file_get_contents( 'php://input' );
398
-		$raw_post_array = explode( '&', $raw_post_data );
397
+		$raw_post_data = file_get_contents('php://input');
398
+		$raw_post_array = explode('&', $raw_post_data);
399 399
 		$update_info = array();
400
-		foreach ( $raw_post_array as $keyval ) {
401
-			$keyval = explode( '=', $keyval );
402
-			if ( count( $keyval ) === 2 ) {
403
-				$update_info[ $keyval[ 0 ] ] = urldecode( $keyval[ 1 ] );
400
+		foreach ($raw_post_array as $keyval) {
401
+			$keyval = explode('=', $keyval);
402
+			if (count($keyval) === 2) {
403
+				$update_info[$keyval[0]] = urldecode($keyval[1]);
404 404
 			}
405 405
 		}
406 406
 		// read the IPN message sent from PayPal and prepend 'cmd=_notify-validate'
407 407
 		$req = 'cmd=_notify-validate';
408
-		$uses_get_magic_quotes = function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc() === 1
408
+		$uses_get_magic_quotes = function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() === 1
409 409
 			? true
410 410
 			: false;
411
-		foreach ( $update_info as $key => $value ) {
412
-			$value = $uses_get_magic_quotes ? urlencode( stripslashes( $value ) ) : urlencode( $value );
411
+		foreach ($update_info as $key => $value) {
412
+			$value = $uses_get_magic_quotes ? urlencode(stripslashes($value)) : urlencode($value);
413 413
 			$req .= "&$key=$value";
414 414
 		}
415 415
 		// HTTP POST the complete, unaltered IPN back to PayPal
@@ -418,38 +418,38 @@  discard block
 block discarded – undo
418 418
 			array(
419 419
 				'body' 				=> $req,
420 420
 				'sslverify' 		=> false,
421
-				'timeout' 		=> 60 ,
421
+				'timeout' 		=> 60,
422 422
 				// make sure to set a site specific unique "user-agent" string since the WordPres default gets declined by PayPal
423 423
 				// plz see: https://github.com/websharks/s2member/issues/610
424
-				'user-agent' 	=> 'Event Espresso v' . EVENT_ESPRESSO_VERSION . '; ' . home_url(),
424
+				'user-agent' 	=> 'Event Espresso v'.EVENT_ESPRESSO_VERSION.'; '.home_url(),
425 425
 				'httpversion' => '1.1'
426 426
 			)
427 427
 		);
428 428
 		// then check the response
429 429
 		if (
430
-			array_key_exists( 'body', $response )
431
-			&& ! is_wp_error( $response )
432
-			&& strcmp( $response[ 'body' ], "VERIFIED" ) === 0
430
+			array_key_exists('body', $response)
431
+			&& ! is_wp_error($response)
432
+			&& strcmp($response['body'], "VERIFIED") === 0
433 433
 		) {
434 434
 			return true;
435 435
 		}
436 436
 		// huh, something's wack... the IPN didn't validate. We must have replied to the IPN incorrectly,
437 437
 		// or their API must have changed: http://www.paypalobjects.com/en_US/ebook/PP_OrderManagement_IntegrationGuide/ipn.html
438
-		if( $response instanceof WP_Error ) {
438
+		if ($response instanceof WP_Error) {
439 439
 			$error_msg = sprintf(
440
-				esc_html__( 'WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso' ),
440
+				esc_html__('WP Error. Code: "%1$s", Message: "%2$s", Data: "%3$s"', 'event_espresso'),
441 441
 				$response->get_error_code(),
442 442
 				$response->get_error_message(),
443
-				print_r( $response->get_error_data(), true )
443
+				print_r($response->get_error_data(), true)
444 444
 			);
445
-		} elseif( is_array( $response ) && isset( $response[ 'body' ] ) ) {
446
-			$error_msg = $response[ 'body' ];
445
+		} elseif (is_array($response) && isset($response['body'])) {
446
+			$error_msg = $response['body'];
447 447
 		} else {
448
-			$error_msg = print_r( $response, true );
448
+			$error_msg = print_r($response, true);
449 449
 		}
450
-		$payment->set_gateway_response( sprintf( esc_html__( "IPN Validation failed! Paypal responded with '%s'", "event_espresso" ), $error_msg ) );
451
-		$payment->set_details( array( 'REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response ) );
452
-		$payment->set_status( EEM_Payment::status_id_failed );
450
+		$payment->set_gateway_response(sprintf(esc_html__("IPN Validation failed! Paypal responded with '%s'", "event_espresso"), $error_msg));
451
+		$payment->set_details(array('REQUEST' => $update_info, 'VALIDATION_RESPONSE' => $response));
452
+		$payment->set_status(EEM_Payment::status_id_failed);
453 453
 		// log the results
454 454
 		$this->log(
455 455
 			array(
@@ -469,9 +469,9 @@  discard block
 block discarded – undo
469 469
 	 * @return string
470 470
 	 */
471 471
 	protected function _process_response_url() {
472
-		if ( isset( $_SERVER[ 'HTTP_HOST' ], $_SERVER[ 'REQUEST_URI' ] ) ) {
472
+		if (isset($_SERVER['HTTP_HOST'], $_SERVER['REQUEST_URI'])) {
473 473
 			$url = is_ssl() ? 'https://' : 'http://';
474
-			$url .= EEH_URL::filter_input_server_url( 'HTTP_HOST' );
474
+			$url .= EEH_URL::filter_input_server_url('HTTP_HOST');
475 475
 			$url .= EEH_URL::filter_input_server_url();
476 476
 		} else {
477 477
 			$url = 'unknown';
@@ -488,12 +488,12 @@  discard block
 block discarded – undo
488 488
 	 * @param EEI_Payment $payment
489 489
 	 * @throws \EE_Error
490 490
 	 */
491
-	public function update_txn_based_on_payment( $payment ) {
491
+	public function update_txn_based_on_payment($payment) {
492 492
 		$update_info = $payment->details();
493 493
 		/** @var EE_Transaction $transaction */
494 494
 		$transaction = $payment->transaction();
495
-		$payment_was_itemized = $payment->get_extra_meta( EEG_Paypal_Standard::itemized_payment_option_name, true, false );
496
-		if( ! $transaction ){
495
+		$payment_was_itemized = $payment->get_extra_meta(EEG_Paypal_Standard::itemized_payment_option_name, true, false);
496
+		if ( ! $transaction) {
497 497
 			$this->log(
498 498
 				esc_html__(
499 499
 					'Payment with ID %d has no related transaction, and so update_txn_based_on_payment couldn\'t be executed properly',
@@ -503,10 +503,10 @@  discard block
 block discarded – undo
503 503
 			);
504 504
 			return;
505 505
 		}
506
-		if(
507
-			! is_array( $update_info )
508
-			|| ! isset( $update_info[ 'mc_shipping' ] )
509
-			|| ! isset( $update_info[ 'tax' ] )
506
+		if (
507
+			! is_array($update_info)
508
+			|| ! isset($update_info['mc_shipping'])
509
+			|| ! isset($update_info['tax'])
510 510
 		) {
511 511
 			$this->log(
512 512
 				array(
@@ -521,7 +521,7 @@  discard block
 block discarded – undo
521 521
 			);
522 522
 			return;
523 523
 		}
524
-		if( $payment->status() !== $this->_pay_model->approved_status() ) {
524
+		if ($payment->status() !== $this->_pay_model->approved_status()) {
525 525
 			$this->log(
526 526
 				array(
527 527
 					'message' => esc_html__(
@@ -540,44 +540,44 @@  discard block
 block discarded – undo
540 540
 		$transaction_total_line_item = $transaction->total_line_item();
541 541
 
542 542
 		//might paypal have changed the taxes?
543
-		if( $this->_paypal_taxes && $payment_was_itemized ) {
543
+		if ($this->_paypal_taxes && $payment_was_itemized) {
544 544
             // note that we're doing this BEFORE adding shipping;
545 545
 			// we actually want PayPal's shipping to remain non-taxable
546
-            $this->_line_item->set_line_items_taxable( $transaction_total_line_item, true, 'paypal_shipping' );
546
+            $this->_line_item->set_line_items_taxable($transaction_total_line_item, true, 'paypal_shipping');
547 547
             $this->_line_item->set_total_tax_to(
548 548
 	            $transaction_total_line_item,
549
-                (float)$update_info['tax'],
550
-                esc_html__( 'Taxes', 'event_espresso' ),
551
-                esc_html__( 'Calculated by Paypal', 'event_espresso' ),
549
+                (float) $update_info['tax'],
550
+                esc_html__('Taxes', 'event_espresso'),
551
+                esc_html__('Calculated by Paypal', 'event_espresso'),
552 552
                 'paypal_tax'
553 553
             );
554 554
             $grand_total_needs_resaving = TRUE;
555 555
 		}
556 556
 
557
-		$shipping_amount = (float)$update_info[ 'mc_shipping' ];
557
+		$shipping_amount = (float) $update_info['mc_shipping'];
558 558
 		//might paypal have added shipping?
559
-		if( $this->_paypal_shipping && $shipping_amount && $payment_was_itemized ){
559
+		if ($this->_paypal_shipping && $shipping_amount && $payment_was_itemized) {
560 560
 			$this->_line_item->add_unrelated_item(
561 561
 				$transaction_total_line_item,
562
-				sprintf( esc_html__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID() ),
562
+				sprintf(esc_html__('Shipping for transaction %1$s', 'event_espresso'), $transaction->ID()),
563 563
 				$shipping_amount,
564 564
 				esc_html__('Shipping charges calculated by Paypal', 'event_espresso'),
565 565
 				1,
566 566
 				false,
567
-				'paypal_shipping_' . $transaction->ID()
567
+				'paypal_shipping_'.$transaction->ID()
568 568
 			);
569 569
 			$grand_total_needs_resaving = true;
570 570
 		}
571 571
 
572
-		if( $grand_total_needs_resaving ){
573
-			$transaction_total_line_item->save_this_and_descendants_to_txn( $transaction->ID() );
572
+		if ($grand_total_needs_resaving) {
573
+			$transaction_total_line_item->save_this_and_descendants_to_txn($transaction->ID());
574 574
 			/** @var EE_Registration_Processor $registration_processor */
575
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
576
-			$registration_processor->update_registration_final_prices( $transaction );
575
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
576
+			$registration_processor->update_registration_final_prices($transaction);
577 577
 		}
578 578
 		$this->log(
579 579
 			array(
580
-				'message'                     => esc_html__( 'Updated transaction related to payment', 'event_espresso' ),
580
+				'message'                     => esc_html__('Updated transaction related to payment', 'event_espresso'),
581 581
 				'url'                         => $this->_process_response_url(),
582 582
 				'transaction (updated)'       => $transaction->model_field_array(),
583 583
 				'payment (updated)'           => $payment->model_field_array(),
Please login to merge, or discard this patch.
core/exceptions/IpnException.php 1 patch
Indentation   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 namespace EventEspresso\core\exceptions;
3 3
 
4 4
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
-    exit('No direct script access allowed');
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -21,71 +21,71 @@  discard block
 block discarded – undo
21 21
 class IpnException extends \LogicException
22 22
 {
23 23
 
24
-    const DUPLICATE          = 1;
24
+	const DUPLICATE          = 1;
25 25
 
26
-    const UNABLE_TO_VALIDATE = 2;
26
+	const UNABLE_TO_VALIDATE = 2;
27 27
 
28
-    const UNSUPPORTED        = 3;
28
+	const UNSUPPORTED        = 3;
29 29
 
30
-    /**
31
-     * @var \EE_Payment
32
-     */
33
-    protected $payment;
30
+	/**
31
+	 * @var \EE_Payment
32
+	 */
33
+	protected $payment;
34 34
 
35
-    /**
36
-     * @var mixed IPN data, usually an array or object
37
-     */
38
-    protected $ipn_data;
35
+	/**
36
+	 * @var mixed IPN data, usually an array or object
37
+	 */
38
+	protected $ipn_data;
39 39
 
40 40
 
41 41
 
42
-    public function __construct(
43
-        $message,
44
-        $code = 0,
45
-        \Exception $previous = null,
46
-        \EE_Payment $payment = null,
47
-        $ipn_data = array()
48
-    ) {
49
-        parent::__construct($message, $code, $previous);
50
-        $this->payment = $payment;
51
-        $this->ipn_data = $ipn_data;
52
-    }
42
+	public function __construct(
43
+		$message,
44
+		$code = 0,
45
+		\Exception $previous = null,
46
+		\EE_Payment $payment = null,
47
+		$ipn_data = array()
48
+	) {
49
+		parent::__construct($message, $code, $previous);
50
+		$this->payment = $payment;
51
+		$this->ipn_data = $ipn_data;
52
+	}
53 53
 
54 54
 
55 55
 
56
-    /**
57
-     * Gets the payment associated with this IPN, if known
58
-     *
59
-     * @return \EE_Payment
60
-     */
61
-    public function getPayment()
62
-    {
63
-        return $this->payment;
64
-    }
56
+	/**
57
+	 * Gets the payment associated with this IPN, if known
58
+	 *
59
+	 * @return \EE_Payment
60
+	 */
61
+	public function getPayment()
62
+	{
63
+		return $this->payment;
64
+	}
65 65
 
66 66
 
67 67
 
68
-    /**
69
-     * Returns the payment's properties as an array (even if there is no payment, in which case it's an empty array)
70
-     *
71
-     * @return array
72
-     * @throws \EE_Error
73
-     */
74
-    public function getPaymentProperties()
75
-    {
76
-        return $this->getPayment() instanceof \EE_Payment ? $this->getPayment()->model_field_array() : array();
77
-    }
68
+	/**
69
+	 * Returns the payment's properties as an array (even if there is no payment, in which case it's an empty array)
70
+	 *
71
+	 * @return array
72
+	 * @throws \EE_Error
73
+	 */
74
+	public function getPaymentProperties()
75
+	{
76
+		return $this->getPayment() instanceof \EE_Payment ? $this->getPayment()->model_field_array() : array();
77
+	}
78 78
 
79 79
 
80 80
 
81
-    /**
82
-     * Returns an array, object, or string, however, the IPN data was received
83
-     *
84
-     * @return mixed
85
-     */
86
-    public function getIpnData()
87
-    {
88
-        return $this->ipn_data;
89
-    }
81
+	/**
82
+	 * Returns an array, object, or string, however, the IPN data was received
83
+	 *
84
+	 * @return mixed
85
+	 */
86
+	public function getIpnData()
87
+	{
88
+		return $this->ipn_data;
89
+	}
90 90
 
91 91
 }
92 92
\ No newline at end of file
Please login to merge, or discard this patch.
modules/invalid_checkout_access/EED_Invalid_Checkout_Access.module.php 1 patch
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\modules\invalid_checkout_access\InvalidCheckoutAccess;
3 3
 
4
-if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 
@@ -36,12 +36,12 @@  discard block
 block discarded – undo
36 36
 	public static function set_hooks_admin() {
37 37
 		add_action(
38 38
 			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
39
-			array( 'EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form' ),
39
+			array('EED_Invalid_Checkout_Access', 'display_invalid_checkout_access_form'),
40 40
 			15
41 41
 		);
42 42
 		add_filter(
43 43
 			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
44
-			array( 'EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form' )
44
+			array('EED_Invalid_Checkout_Access', 'process_invalid_checkout_access_form')
45 45
 		);
46 46
 	}
47 47
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
 	 *
54 54
 	 * @var WP $WP
55 55
 	 */
56
-	public function run( $WP ) {
56
+	public function run($WP) {
57 57
 		// TODO: Implement run() method.
58 58
 	}
59 59
 
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
 	 * @return InvalidCheckoutAccess
64 64
 	 */
65 65
 	public static function getInvalidCheckoutAccess() {
66
-		if ( ! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess ) {
66
+		if ( ! self::$invalid_checkout_access_form instanceof InvalidCheckoutAccess) {
67 67
 			self::$invalid_checkout_access_form = new InvalidCheckoutAccess();
68 68
 		}
69 69
 		return self::$invalid_checkout_access_form;
@@ -90,9 +90,9 @@  discard block
 block discarded – undo
90 90
 	 * @param \EE_Registration_Config $EE_Registration_Config
91 91
 	 * @return \EE_Registration_Config
92 92
 	 */
93
-	public static function process_invalid_checkout_access_form( \EE_Registration_Config $EE_Registration_Config ) {
93
+	public static function process_invalid_checkout_access_form(\EE_Registration_Config $EE_Registration_Config) {
94 94
 		$invalid_checkout_access_form = \EED_Invalid_Checkout_Access::getInvalidCheckoutAccess();
95
-		return $invalid_checkout_access_form->processForm( $EE_Registration_Config );
95
+		return $invalid_checkout_access_form->processForm($EE_Registration_Config);
96 96
 	}
97 97
 
98 98
 
Please login to merge, or discard this patch.
core/EE_Session.core.php 4 patches
Braces   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -341,7 +341,7 @@
 block discarded – undo
341 341
 		}
342 342
 		 if ( ! empty( $key ))  {
343 343
 			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
344
-		}  else  {
344
+		} else  {
345 345
 			return $this->_session_data;
346 346
 		}
347 347
 	}
Please login to merge, or discard this patch.
Doc Comments   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -433,7 +433,7 @@  discard block
 block discarded – undo
433 433
 	  * set session data
434 434
 	  * @access 	public
435 435
 	  * @param 	array $data
436
-	  * @return 	TRUE on success, FALSE on fail
436
+	  * @return 	boolean on success, FALSE on fail
437 437
 	  */
438 438
 	public function set_session_data( $data ) {
439 439
 
@@ -461,7 +461,7 @@  discard block
 block discarded – undo
461 461
 	 /**
462 462
 	  * @initiate session
463 463
 	  * @access   private
464
-	  * @return TRUE on success, FALSE on fail
464
+	  * @return boolean on success, FALSE on fail
465 465
 	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
466 466
 	  * @throws \EE_Error
467 467
 	  */
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
       * @update session data  prior to saving to the db
682 682
       * @access public
683 683
       * @param bool $new_session
684
-      * @return TRUE on success, FALSE on fail
684
+      * @return boolean on success, FALSE on fail
685 685
       * @throws \EE_Error
686 686
       */
687 687
 	public function update( $new_session = FALSE ) {
@@ -787,7 +787,7 @@  discard block
 block discarded – undo
787 787
 	  * _save_session_to_db
788 788
 	  *
789 789
 	  * @access public
790
-	  * @return string
790
+	  * @return boolean
791 791
 	  * @throws \EE_Error
792 792
 	  */
793 793
 	private function _save_session_to_db() {
@@ -959,7 +959,7 @@  discard block
 block discarded – undo
959 959
 	  * @access public
960 960
 	  * @param array $data_to_reset
961 961
 	  * @param bool  $show_all_notices
962
-	  * @return TRUE on success, FALSE on fail
962
+	  * @return boolean on success, FALSE on fail
963 963
 	  */
964 964
 	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
965 965
 		// if $data_to_reset is not in an array, then put it in one
Please login to merge, or discard this patch.
Indentation   +290 added lines, -290 removed lines patch added patch discarded remove patch
@@ -22,19 +22,19 @@  discard block
 block discarded – undo
22 22
 	  */
23 23
 	 private static $_instance;
24 24
 
25
-     /**
26
-      * @var CacheStorageInterface $cache_storage
27
-      */
28
-     protected $cache_storage;
29
-
30
-     /**
31
-      * EE_Encryption object
32
-      *
33
-      * @var EE_Encryption
34
-      */
35
-     protected $encryption;
36
-
37
-     /**
25
+	 /**
26
+	  * @var CacheStorageInterface $cache_storage
27
+	  */
28
+	 protected $cache_storage;
29
+
30
+	 /**
31
+	  * EE_Encryption object
32
+	  *
33
+	  * @var EE_Encryption
34
+	  */
35
+	 protected $encryption;
36
+
37
+	 /**
38 38
 	  * the session id
39 39
 	  * @var string
40 40
 	  */
@@ -65,12 +65,12 @@  discard block
 block discarded – undo
65 65
 	  */
66 66
 	 private $_expiration;
67 67
 
68
-    /**
69
-     * whether or not session has expired at some point
70
-     *
71
-     * @var boolean
72
-     */
73
-    private $_expired = false;
68
+	/**
69
+	 * whether or not session has expired at some point
70
+	 *
71
+	 * @var boolean
72
+	 */
73
+	private $_expired = false;
74 74
 
75 75
 	 /**
76 76
 	  * current time as Unix timestamp in GMT
@@ -107,30 +107,30 @@  discard block
 block discarded – undo
107 107
 	  * @var array
108 108
 	  */
109 109
 	 private $_default_session_vars = array (
110
-        'id'            => null,
111
-        'user_id'       => null,
112
-        'ip_address'    => null,
113
-        'user_agent'    => null,
114
-        'init_access'   => null,
115
-        'last_access'   => null,
116
-        'expiration'    => null,
117
-        'pages_visited' => array(),
110
+		'id'            => null,
111
+		'user_id'       => null,
112
+		'ip_address'    => null,
113
+		'user_agent'    => null,
114
+		'init_access'   => null,
115
+		'last_access'   => null,
116
+		'expiration'    => null,
117
+		'pages_visited' => array(),
118 118
 	);
119 119
 
120 120
 
121 121
 
122 122
 	 /**
123 123
 	  * @singleton method used to instantiate class object
124
-      * @param CacheStorageInterface $cache_storage
125
-      * @param \EE_Encryption        $encryption
124
+	  * @param CacheStorageInterface $cache_storage
125
+	  * @param \EE_Encryption        $encryption
126 126
 	  * @return EE_Session
127 127
 	  * @throws InvalidSessionDataException
128 128
 	  * @throws \EE_Error
129 129
 	  */
130 130
 	public static function instance(
131
-        CacheStorageInterface $cache_storage = null,
132
-        EE_Encryption $encryption = null
133
-    ) {
131
+		CacheStorageInterface $cache_storage = null,
132
+		EE_Encryption $encryption = null
133
+	) {
134 134
 		// check if class object is instantiated
135 135
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
136 136
 		// add_filter( 'FHEE_load_EE_Session', '__return_false' );
@@ -143,10 +143,10 @@  discard block
 block discarded – undo
143 143
 
144 144
 
145 145
 	 /**
146
-      * protected constructor to prevent direct creation
147
-      *
148
-      * @param CacheStorageInterface $cache_storage
149
-      * @param \EE_Encryption $encryption
146
+	  * protected constructor to prevent direct creation
147
+	  *
148
+	  * @param CacheStorageInterface $cache_storage
149
+	  * @param \EE_Encryption $encryption
150 150
 	  * @throws \EE_Error
151 151
 	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
152 152
 	  */
@@ -181,59 +181,59 @@  discard block
 block discarded – undo
181 181
 				$this->{$var_name} = $session_setting;
182 182
 			}
183 183
 		}
184
-         $this->cache_storage = $cache_storage;
185
-         // are we using encryption?
186
-         $this->_use_encryption = $encryption instanceof EE_Encryption && EE_Registry::instance()->CFG->admin->encode_session_data();
187
-         // \EEH_Debug_Tools::printr($this->_use_encryption, '$this->_use_encryption', __FILE__, __LINE__);
188
-        // encrypt data via: $this->encryption->encrypt();
189
-        $this->encryption = $encryption;
184
+		 $this->cache_storage = $cache_storage;
185
+		 // are we using encryption?
186
+		 $this->_use_encryption = $encryption instanceof EE_Encryption && EE_Registry::instance()->CFG->admin->encode_session_data();
187
+		 // \EEH_Debug_Tools::printr($this->_use_encryption, '$this->_use_encryption', __FILE__, __LINE__);
188
+		// encrypt data via: $this->encryption->encrypt();
189
+		$this->encryption = $encryption;
190 190
 		// filter hook allows outside functions/classes/plugins to change default empty cart
191 191
 		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
192 192
 		array_merge( $this->_default_session_vars, $extra_default_session_vars );
193 193
 		// apply default session vars
194 194
 		$this->_set_defaults();
195
-         add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
196
-         // check request for 'clear_session' param
195
+		 add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
196
+		 // check request for 'clear_session' param
197 197
 		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
198 198
 		// once everything is all said and done,
199 199
 		add_action( 'shutdown', array( $this, 'update' ), 100 );
200
-         $this->configure_garbage_collection_filters();
200
+		 $this->configure_garbage_collection_filters();
201 201
 	}
202 202
 
203 203
 
204 204
 
205
-     /**
206
-      * @return void
207
-      * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
208
-      * @throws \EE_Error
209
-      */
205
+	 /**
206
+	  * @return void
207
+	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
208
+	  * @throws \EE_Error
209
+	  */
210 210
 	 public function open_session() {
211
-         // check for existing session and retrieve it from db
212
-         if ( ! $this->_espresso_session()) {
213
-             // or just start a new one
214
-             $this->_create_espresso_session();
215
-         }
216
-     }
211
+		 // check for existing session and retrieve it from db
212
+		 if ( ! $this->_espresso_session()) {
213
+			 // or just start a new one
214
+			 $this->_create_espresso_session();
215
+		 }
216
+	 }
217 217
 
218 218
 
219 219
 
220
-    /**
221
-     * @return bool
222
-     */
223
-    public function expired()
224
-    {
225
-        return $this->_expired;
226
-    }
220
+	/**
221
+	 * @return bool
222
+	 */
223
+	public function expired()
224
+	{
225
+		return $this->_expired;
226
+	}
227 227
 
228 228
 
229 229
 
230
-    /**
231
-     * @return void
232
-     */
233
-    public function reset_expired()
234
-    {
235
-        $this->_expired = false;
236
-    }
230
+	/**
231
+	 * @return void
232
+	 */
233
+	public function reset_expired()
234
+	{
235
+		$this->_expired = false;
236
+	}
237 237
 
238 238
 
239 239
 	 /**
@@ -245,24 +245,24 @@  discard block
 block discarded – undo
245 245
 
246 246
 
247 247
 
248
-    /**
249
-     * @return int
250
-     */
251
-    public function extension()
252
-    {
253
-        return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', (10 * MINUTE_IN_SECONDS));
254
-    }
248
+	/**
249
+	 * @return int
250
+	 */
251
+	public function extension()
252
+	{
253
+		return apply_filters('FHEE__EE_Session__extend_expiration__seconds_added', (10 * MINUTE_IN_SECONDS));
254
+	}
255 255
 
256 256
 
257 257
 
258
-    /**
259
-     * @param int $time number of seconds to add to session expiration
260
-     */
261
-    public function extend_expiration($time = 0)
262
-    {
263
-        $time = $time ? $time : $this->extension();
264
-        $this->_expiration += absint($time);
265
-    }
258
+	/**
259
+	 * @param int $time number of seconds to add to session expiration
260
+	 */
261
+	public function extend_expiration($time = 0)
262
+	{
263
+		$time = $time ? $time : $this->extension();
264
+		$this->_expiration += absint($time);
265
+	}
266 266
 
267 267
 
268 268
 
@@ -306,15 +306,15 @@  discard block
 block discarded – undo
306 306
 
307 307
 
308 308
 
309
-    /**
310
-     * @param \EE_Cart $cart
311
-     * @return bool
312
-     */
313
-    public function set_cart(EE_Cart $cart)
314
-    {
315
-        $this->_session_data['cart'] = $cart;
316
-        return true;
317
-    }
309
+	/**
310
+	 * @param \EE_Cart $cart
311
+	 * @return bool
312
+	 */
313
+	public function set_cart(EE_Cart $cart)
314
+	{
315
+		$this->_session_data['cart'] = $cart;
316
+		return true;
317
+	}
318 318
 
319 319
 
320 320
 
@@ -322,7 +322,7 @@  discard block
 block discarded – undo
322 322
 	  * reset_cart
323 323
 	  */
324 324
 	 public function reset_cart() {
325
-        do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
325
+		do_action('AHEE__EE_Session__reset_cart__before_reset', $this);
326 326
 		 $this->_session_data['cart'] = NULL;
327 327
 	 }
328 328
 
@@ -355,7 +355,7 @@  discard block
 block discarded – undo
355 355
 	  * reset_checkout
356 356
 	  */
357 357
 	 public function reset_checkout() {
358
-        do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
358
+		do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
359 359
 		 $this->_session_data['checkout'] = NULL;
360 360
 	 }
361 361
 
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 	  * @return \EE_Checkout
366 366
 	  */
367 367
 	 public function checkout() {
368
-        return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
369
-            ? $this->_session_data['checkout']
370
-            : null;
368
+		return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
369
+			? $this->_session_data['checkout']
370
+			: null;
371 371
 	 }
372 372
 
373 373
 
@@ -390,7 +390,7 @@  discard block
 block discarded – undo
390 390
 	  * reset_transaction
391 391
 	  */
392 392
 	 public function reset_transaction() {
393
-        do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
393
+		do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
394 394
 		 $this->_session_data['transaction'] = NULL;
395 395
 	 }
396 396
 
@@ -400,10 +400,10 @@  discard block
 block discarded – undo
400 400
 	  * @return \EE_Transaction
401 401
 	  */
402 402
 	 public function transaction() {
403
-        return isset($this->_session_data['transaction'])
404
-               && $this->_session_data['transaction'] instanceof EE_Transaction
405
-           ? $this->_session_data['transaction']
406
-           : null;
403
+		return isset($this->_session_data['transaction'])
404
+			   && $this->_session_data['transaction'] instanceof EE_Transaction
405
+		   ? $this->_session_data['transaction']
406
+		   : null;
407 407
 	 }
408 408
 
409 409
 
@@ -480,16 +480,16 @@  discard block
 block discarded – undo
480 480
 		// set the "user agent"
481 481
 		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
482 482
 		// now let's retrieve what's in the db
483
-        $session_data = $this->_retrieve_session_data();
484
-        if (! empty($session_data)) {
485
-            // get the current time in UTC
483
+		$session_data = $this->_retrieve_session_data();
484
+		if (! empty($session_data)) {
485
+			// get the current time in UTC
486 486
 			$this->_time = isset( $this->_time ) ? $this->_time : time();
487 487
 			// and reset the session expiration
488 488
 			$this->_expiration = isset( $session_data['expiration'] )
489 489
 				? $session_data['expiration']
490 490
 				: $this->_time + $this->_lifespan;
491 491
 		} else {
492
-            // set initial site access time and the session expiration
492
+			// set initial site access time and the session expiration
493 493
 			$this->_set_init_access_and_expiration();
494 494
 			// set referer
495 495
 			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] )
@@ -498,14 +498,14 @@  discard block
 block discarded – undo
498 498
 			// no previous session = go back and create one (on top of the data above)
499 499
 			return FALSE;
500 500
 		}
501
-        // now the user agent
501
+		// now the user agent
502 502
 		if ( $session_data['user_agent'] !== $this->_user_agent ) {
503 503
 			return FALSE;
504 504
 		}
505 505
 		// wait a minute... how old are you?
506 506
 		if ( $this->_time > $this->_expiration ) {
507 507
 			// yer too old fer me!
508
-            $this->_expired = true;
508
+			$this->_expired = true;
509 509
 			// wipe out everything that isn't a default session datum
510 510
 			$this->clear_session( __CLASS__, __FUNCTION__ );
511 511
 		}
@@ -517,101 +517,101 @@  discard block
 block discarded – undo
517 517
 
518 518
 
519 519
 
520
-     /**
521
-      * _get_session_data
522
-      * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases
523
-      *
524
-      * @return array
525
-      * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
526
-      */
527
-     protected function _retrieve_session_data()
528
-     {
529
-         $ssn_key = EE_Session::session_id_prefix . $this->_sid;
530
-         try {
531
-             // we're using WP's Transient API to store session data using the PHP session ID as the option name
532
-             $session_data = $this->cache_storage->get($ssn_key, false);
533
-	         if (empty($session_data)) {
534
-		         return array();
535
-             }
536
-             if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
537
-                 $hash_check = $this->cache_storage->get(
538
-                     EE_Session::hash_check_prefix . $this->_sid,
539
-                     false
540
-                 );
541
-                 if ($hash_check && $hash_check !== md5($session_data)) {
542
-	                 EE_Error::add_error(
543
-                         sprintf(
544
-                             __(
545
-                                 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
546
-                                 'event_espresso'
547
-                             ),
548
-                             EE_Session::session_id_prefix . $this->_sid
549
-                         ),
550
-                         __FILE__, __FUNCTION__, __LINE__
551
-                     );
552
-                 }
553
-             }
554
-         } catch (Exception $e) {
555
-             // let's just eat that error for now and attempt to correct any corrupted data
556
-             global $wpdb;
557
-             $row = $wpdb->get_row(
558
-                 $wpdb->prepare(
559
-                     "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
560
-                     '_transient_' . $ssn_key
561
-                 )
562
-             );
563
-             $session_data = is_object($row) ? $row->option_value : null;
564
-             if ($session_data) {
565
-                 $session_data = preg_replace_callback(
566
-                     '!s:(d+):"(.*?)";!',
567
-                     function ($match) {
568
-                         return $match[1] === strlen($match[2])
569
-                             ? $match[0]
570
-                             : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
571
-                     },
572
-                     $session_data
573
-                 );
574
-             }
575
-	         $session_data = maybe_unserialize($session_data);
576
-         }
577
-	     // in case the data is encoded... try to decode it
578
-         $session_data = $this->encryption instanceof EE_Encryption
579
-             ? $this->encryption->base64_string_decode($session_data)
580
-             : $session_data;
581
-
582
-         if ( ! is_array($session_data)) {
583
-             try {
584
-	             $session_data = maybe_unserialize($session_data);
585
-             } catch (Exception $e) {
586
-                 $msg = esc_html__(
587
-                     'An error occurred while attempting to unserialize the session data.',
588
-                     'event_espresso'
589
-                 );
590
-                 $msg .= WP_DEBUG
591
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
592
-                     : '';
593
-                 throw new InvalidSessionDataException($msg, 0, $e);
594
-             }
595
-         }
596
-         // just a check to make sure the session array is indeed an array
597
-         if ( ! is_array($session_data)) {
598
-             // no?!?! then something is wrong
599
-             $msg = esc_html__(
600
-                 'The session data is missing, invalid, or corrupted.',
601
-                 'event_espresso'
602
-             );
603
-             $msg .= WP_DEBUG
604
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
605
-                 : '';
606
-	         throw new InvalidSessionDataException($msg);
607
-         }
608
-	     if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) {
609
-             $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
610
-                 $session_data['transaction']
611
-	         );
612
-	     }
613
-         return $session_data;
614
-     }
520
+	 /**
521
+	  * _get_session_data
522
+	  * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases
523
+	  *
524
+	  * @return array
525
+	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
526
+	  */
527
+	 protected function _retrieve_session_data()
528
+	 {
529
+		 $ssn_key = EE_Session::session_id_prefix . $this->_sid;
530
+		 try {
531
+			 // we're using WP's Transient API to store session data using the PHP session ID as the option name
532
+			 $session_data = $this->cache_storage->get($ssn_key, false);
533
+			 if (empty($session_data)) {
534
+				 return array();
535
+			 }
536
+			 if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
537
+				 $hash_check = $this->cache_storage->get(
538
+					 EE_Session::hash_check_prefix . $this->_sid,
539
+					 false
540
+				 );
541
+				 if ($hash_check && $hash_check !== md5($session_data)) {
542
+					 EE_Error::add_error(
543
+						 sprintf(
544
+							 __(
545
+								 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
546
+								 'event_espresso'
547
+							 ),
548
+							 EE_Session::session_id_prefix . $this->_sid
549
+						 ),
550
+						 __FILE__, __FUNCTION__, __LINE__
551
+					 );
552
+				 }
553
+			 }
554
+		 } catch (Exception $e) {
555
+			 // let's just eat that error for now and attempt to correct any corrupted data
556
+			 global $wpdb;
557
+			 $row = $wpdb->get_row(
558
+				 $wpdb->prepare(
559
+					 "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
560
+					 '_transient_' . $ssn_key
561
+				 )
562
+			 );
563
+			 $session_data = is_object($row) ? $row->option_value : null;
564
+			 if ($session_data) {
565
+				 $session_data = preg_replace_callback(
566
+					 '!s:(d+):"(.*?)";!',
567
+					 function ($match) {
568
+						 return $match[1] === strlen($match[2])
569
+							 ? $match[0]
570
+							 : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
571
+					 },
572
+					 $session_data
573
+				 );
574
+			 }
575
+			 $session_data = maybe_unserialize($session_data);
576
+		 }
577
+		 // in case the data is encoded... try to decode it
578
+		 $session_data = $this->encryption instanceof EE_Encryption
579
+			 ? $this->encryption->base64_string_decode($session_data)
580
+			 : $session_data;
581
+
582
+		 if ( ! is_array($session_data)) {
583
+			 try {
584
+				 $session_data = maybe_unserialize($session_data);
585
+			 } catch (Exception $e) {
586
+				 $msg = esc_html__(
587
+					 'An error occurred while attempting to unserialize the session data.',
588
+					 'event_espresso'
589
+				 );
590
+				 $msg .= WP_DEBUG
591
+					 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
592
+					 : '';
593
+				 throw new InvalidSessionDataException($msg, 0, $e);
594
+			 }
595
+		 }
596
+		 // just a check to make sure the session array is indeed an array
597
+		 if ( ! is_array($session_data)) {
598
+			 // no?!?! then something is wrong
599
+			 $msg = esc_html__(
600
+				 'The session data is missing, invalid, or corrupted.',
601
+				 'event_espresso'
602
+			 );
603
+			 $msg .= WP_DEBUG
604
+				 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
605
+				 : '';
606
+			 throw new InvalidSessionDataException($msg);
607
+		 }
608
+		 if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) {
609
+			 $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
610
+				 $session_data['transaction']
611
+			 );
612
+		 }
613
+		 return $session_data;
614
+	 }
615 615
 
616 616
 
617 617
 
@@ -678,13 +678,13 @@  discard block
 block discarded – undo
678 678
 
679 679
 
680 680
 
681
-     /**
682
-      * @update session data  prior to saving to the db
683
-      * @access public
684
-      * @param bool $new_session
685
-      * @return TRUE on success, FALSE on fail
686
-      * @throws \EE_Error
687
-      */
681
+	 /**
682
+	  * @update session data  prior to saving to the db
683
+	  * @access public
684
+	  * @param bool $new_session
685
+	  * @return TRUE on success, FALSE on fail
686
+	  * @throws \EE_Error
687
+	  */
688 688
 	public function update( $new_session = FALSE ) {
689 689
 		$this->_session_data = isset( $this->_session_data )
690 690
 			&& is_array( $this->_session_data )
@@ -770,12 +770,12 @@  discard block
 block discarded – undo
770 770
 
771 771
 
772 772
 
773
-     /**
774
-      * @create session data array
775
-      * @access public
776
-      * @return bool
777
-      * @throws \EE_Error
778
-      */
773
+	 /**
774
+	  * @create session data array
775
+	  * @access public
776
+	  * @return bool
777
+	  * @throws \EE_Error
778
+	  */
779 779
 	private function _create_espresso_session( ) {
780 780
 		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
781 781
 		// use the update function for now with $new_session arg set to TRUE
@@ -795,19 +795,19 @@  discard block
 block discarded – undo
795 795
 		if (
796 796
 			// if the current request is NOT one of the following
797 797
 			! (
798
-                // an an AJAX request from the frontend
799
-                EE_Registry::instance()->REQ->front_ajax
800
-                || (
801
-                    // OR an admin request that is NOT AJAX
798
+				// an an AJAX request from the frontend
799
+				EE_Registry::instance()->REQ->front_ajax
800
+				|| (
801
+					// OR an admin request that is NOT AJAX
802 802
 					! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
803
-                    && is_admin()
803
+					&& is_admin()
804 804
 				)
805
-                || (
806
-                    // OR an espresso page
807
-                    EE_Registry::instance()->REQ instanceof EE_Request_Handler
808
-                    && EE_Registry::instance()->REQ->is_espresso_page()
809
-                )
810
-            )
805
+				|| (
806
+					// OR an espresso page
807
+					EE_Registry::instance()->REQ instanceof EE_Request_Handler
808
+					&& EE_Registry::instance()->REQ->is_espresso_page()
809
+				)
810
+			)
811 811
 		) {
812 812
 			return false;
813 813
 		}
@@ -818,27 +818,27 @@  discard block
 block discarded – undo
818 818
 			}
819 819
 			$this->_session_data['transaction'] = $transaction->ID();
820 820
 		}
821
-        // then serialize all of our session data
821
+		// then serialize all of our session data
822 822
 		$session_data = serialize($this->_session_data);
823 823
 		// do we need to also encode it to avoid corrupted data when saved to the db?
824 824
 		$session_data = $this->_use_encryption
825
-            ? $this->encryption->base64_string_encode( $session_data )
826
-            : $session_data;
825
+			? $this->encryption->base64_string_encode( $session_data )
826
+			: $session_data;
827 827
 		// maybe save hash check
828 828
 		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
829
-            $this->cache_storage->add(
830
-                EE_Session::hash_check_prefix . $this->_sid,
831
-                md5($session_data),
832
-                $this->_lifespan
833
-            );
834
-        }
835
-        // we're using the Transient API for storing session data,
836
-        return $this->cache_storage->add(
837
-            EE_Session::session_id_prefix . $this->_sid,
838
-            $session_data,
839
-            $this->_lifespan
840
-        );
841
-    }
829
+			$this->cache_storage->add(
830
+				EE_Session::hash_check_prefix . $this->_sid,
831
+				md5($session_data),
832
+				$this->_lifespan
833
+			);
834
+		}
835
+		// we're using the Transient API for storing session data,
836
+		return $this->cache_storage->add(
837
+			EE_Session::session_id_prefix . $this->_sid,
838
+			$session_data,
839
+			$this->_lifespan
840
+		);
841
+	}
842 842
 
843 843
 
844 844
 
@@ -931,18 +931,18 @@  discard block
 block discarded – undo
931 931
 
932 932
 
933 933
 
934
-     /**
935
-      * Clear EE_Session data
936
-      *
937
-      * @access public
938
-      * @param string $class
939
-      * @param string $function
940
-      * @return void
941
-      * @throws \EE_Error
942
-      */
934
+	 /**
935
+	  * Clear EE_Session data
936
+	  *
937
+	  * @access public
938
+	  * @param string $class
939
+	  * @param string $function
940
+	  * @return void
941
+	  * @throws \EE_Error
942
+	  */
943 943
 	public function clear_session( $class = '', $function = '' ) {
944 944
 		//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>';
945
-        do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
945
+		do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
946 946
 		$this->reset_cart();
947 947
 		$this->reset_checkout();
948 948
 		$this->reset_transaction();
@@ -1009,12 +1009,12 @@  discard block
 block discarded – undo
1009 1009
 
1010 1010
 
1011 1011
 
1012
-     /**
1013
-      *   wp_loaded
1014
-      *
1015
-      * @access public
1016
-      * @throws \EE_Error
1017
-      */
1012
+	 /**
1013
+	  *   wp_loaded
1014
+	  *
1015
+	  * @access public
1016
+	  * @throws \EE_Error
1017
+	  */
1018 1018
 	public function wp_loaded() {
1019 1019
 		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
1020 1020
 			$this->clear_session( __CLASS__, __FUNCTION__ );
@@ -1023,12 +1023,12 @@  discard block
 block discarded – undo
1023 1023
 
1024 1024
 
1025 1025
 
1026
-     /**
1027
-      * Used to reset the entire object (for tests).
1028
-      *
1029
-      * @since 4.3.0
1030
-      * @throws \EE_Error
1031
-      */
1026
+	 /**
1027
+	  * Used to reset the entire object (for tests).
1028
+	  *
1029
+	  * @since 4.3.0
1030
+	  * @throws \EE_Error
1031
+	  */
1032 1032
 	public function reset_instance() {
1033 1033
 		$this->clear_session();
1034 1034
 		self::$_instance = NULL;
@@ -1036,29 +1036,29 @@  discard block
 block discarded – undo
1036 1036
 
1037 1037
 
1038 1038
 
1039
-     public function configure_garbage_collection_filters()
1040
-     {
1041
-         // run old filter we had for controlling session cleanup
1042
-         $expired_session_transient_delete_query_limit = absint(
1043
-             apply_filters(
1044
-                 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1045
-                 50
1046
-             )
1047
-         );
1048
-         // is there a value? or one that is different than the default 50 records?
1049
-         if ($expired_session_transient_delete_query_limit === 0) {
1050
-             // hook into TransientCacheStorage in case Session cleanup was turned off
1051
-             add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero');
1052
-         } else if ($expired_session_transient_delete_query_limit !== 50) {
1053
-             // or use that for the new transient cleanup query limit
1054
-             add_filter(
1055
-                 'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1056
-                 function () use ($expired_session_transient_delete_query_limit) {
1057
-                     return $expired_session_transient_delete_query_limit;
1058
-                 }
1059
-             );
1060
-         }
1061
-     }
1039
+	 public function configure_garbage_collection_filters()
1040
+	 {
1041
+		 // run old filter we had for controlling session cleanup
1042
+		 $expired_session_transient_delete_query_limit = absint(
1043
+			 apply_filters(
1044
+				 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1045
+				 50
1046
+			 )
1047
+		 );
1048
+		 // is there a value? or one that is different than the default 50 records?
1049
+		 if ($expired_session_transient_delete_query_limit === 0) {
1050
+			 // hook into TransientCacheStorage in case Session cleanup was turned off
1051
+			 add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero');
1052
+		 } else if ($expired_session_transient_delete_query_limit !== 50) {
1053
+			 // or use that for the new transient cleanup query limit
1054
+			 add_filter(
1055
+				 'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1056
+				 function () use ($expired_session_transient_delete_query_limit) {
1057
+					 return $expired_session_transient_delete_query_limit;
1058
+				 }
1059
+			 );
1060
+		 }
1061
+	 }
1062 1062
 
1063 1063
 
1064 1064
 
Please login to merge, or discard this patch.
Spacing   +151 added lines, -151 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php use EventEspresso\core\exceptions\InvalidSessionDataException;
2 2
 use EventEspresso\core\services\cache\CacheStorageInterface;
3 3
 
4
-if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
5 5
 /**
6 6
  *
7 7
  * EE_Session class
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	  * array for defining default session vars
107 107
 	  * @var array
108 108
 	  */
109
-	 private $_default_session_vars = array (
109
+	 private $_default_session_vars = array(
110 110
         'id'            => null,
111 111
         'user_id'       => null,
112 112
         'ip_address'    => null,
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 		// check if class object is instantiated
135 135
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
136 136
 		// add_filter( 'FHEE_load_EE_Session', '__return_false' );
137
-		if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) {
138
-			self::$_instance = new self($cache_storage, $encryption );
137
+		if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) {
138
+			self::$_instance = new self($cache_storage, $encryption);
139 139
 		}
140 140
 		return self::$_instance;
141 141
 	}
@@ -150,15 +150,15 @@  discard block
 block discarded – undo
150 150
 	  * @throws \EE_Error
151 151
 	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
152 152
 	  */
153
-	 protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null ) {
153
+	 protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null) {
154 154
 
155 155
 		// 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' );
156
-		if ( ! apply_filters( 'FHEE_load_EE_Session', true ) ) {
156
+		if ( ! apply_filters('FHEE_load_EE_Session', true)) {
157 157
 			return;
158 158
 		}
159
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
160
-		if ( ! defined( 'ESPRESSO_SESSION' ) ) {
161
-			define( 'ESPRESSO_SESSION', true );
159
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
160
+		if ( ! defined('ESPRESSO_SESSION')) {
161
+			define('ESPRESSO_SESSION', true);
162 162
 		}
163 163
 		// default session lifespan in seconds
164 164
 		$this->_lifespan = apply_filters(
@@ -172,12 +172,12 @@  discard block
 block discarded – undo
172 172
 		 * 		}
173 173
 		 */
174 174
 		// retrieve session options from db
175
-		$session_settings = (array) get_option( 'ee_session_settings', array() );
176
-		if ( ! empty( $session_settings )) {
175
+		$session_settings = (array) get_option('ee_session_settings', array());
176
+		if ( ! empty($session_settings)) {
177 177
 			// cycle though existing session options
178
-			foreach ( $session_settings as $var_name => $session_setting ) {
178
+			foreach ($session_settings as $var_name => $session_setting) {
179 179
 				// set values for class properties
180
-				$var_name = '_' . $var_name;
180
+				$var_name = '_'.$var_name;
181 181
 				$this->{$var_name} = $session_setting;
182 182
 			}
183 183
 		}
@@ -188,15 +188,15 @@  discard block
 block discarded – undo
188 188
         // encrypt data via: $this->encryption->encrypt();
189 189
         $this->encryption = $encryption;
190 190
 		// filter hook allows outside functions/classes/plugins to change default empty cart
191
-		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
192
-		array_merge( $this->_default_session_vars, $extra_default_session_vars );
191
+		$extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
192
+		array_merge($this->_default_session_vars, $extra_default_session_vars);
193 193
 		// apply default session vars
194 194
 		$this->_set_defaults();
195 195
          add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
196 196
          // check request for 'clear_session' param
197
-		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
197
+		add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
198 198
 		// once everything is all said and done,
199
-		add_action( 'shutdown', array( $this, 'update' ), 100 );
199
+		add_action('shutdown', array($this, 'update'), 100);
200 200
          $this->configure_garbage_collection_filters();
201 201
 	}
202 202
 
@@ -284,11 +284,11 @@  discard block
 block discarded – undo
284 284
 	 */
285 285
 	private function _set_defaults() {
286 286
 		// set some defaults
287
-		foreach ( $this->_default_session_vars as $key => $default_var ) {
288
-			if ( is_array( $default_var )) {
289
-				$this->_session_data[ $key ] = array();
287
+		foreach ($this->_default_session_vars as $key => $default_var) {
288
+			if (is_array($default_var)) {
289
+				$this->_session_data[$key] = array();
290 290
 			} else {
291
-				$this->_session_data[ $key ] = '';
291
+				$this->_session_data[$key] = '';
292 292
 			}
293 293
 		}
294 294
 	}
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 	  * @param $ID
333 333
 	  * @return \EE_Cart
334 334
 	  */
335
-	 public function cart( $ID ) {
336
-		 return isset( $this->_session_data['cart'], $this->_session_data['cart'][ $ID ] )
337
-			 ? $this->_session_data['cart'][ $ID ]
335
+	 public function cart($ID) {
336
+		 return isset($this->_session_data['cart'], $this->_session_data['cart'][$ID])
337
+			 ? $this->_session_data['cart'][$ID]
338 338
 			 : NULL;
339 339
 	 }
340 340
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	  * @param \EE_Checkout $checkout
345 345
 	  * @return bool
346 346
 	  */
347
-	 public function set_checkout( EE_Checkout $checkout ) {
347
+	 public function set_checkout(EE_Checkout $checkout) {
348 348
 		 $this->_session_data['checkout'] = $checkout;
349 349
 		 return TRUE;
350 350
 	 }
@@ -377,9 +377,9 @@  discard block
 block discarded – undo
377 377
 	  * @return bool
378 378
 	  * @throws \EE_Error
379 379
 	  */
380
-	 public function set_transaction( EE_Transaction $transaction ) {
380
+	 public function set_transaction(EE_Transaction $transaction) {
381 381
 		 // first remove the session from the transaction before we save the transaction in the session
382
-		 $transaction->set_txn_session_data( NULL );
382
+		 $transaction->set_txn_session_data(NULL);
383 383
 		 $this->_session_data['transaction'] = $transaction;
384 384
 		 return TRUE;
385 385
 	 }
@@ -415,15 +415,15 @@  discard block
 block discarded – undo
415 415
 	  * @param bool $reset_cache
416 416
 	  * @return    array
417 417
 	  */
418
-	public function get_session_data( $key = NULL, $reset_cache = FALSE ) {
419
-		if ( $reset_cache ) {
418
+	public function get_session_data($key = NULL, $reset_cache = FALSE) {
419
+		if ($reset_cache) {
420 420
 			$this->reset_cart();
421 421
 			$this->reset_checkout();
422 422
 			$this->reset_transaction();
423 423
 		}
424
-		 if ( ! empty( $key ))  {
425
-			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
426
-		}  else  {
424
+		 if ( ! empty($key)) {
425
+			return  isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL;
426
+		} else {
427 427
 			return $this->_session_data;
428 428
 		}
429 429
 	}
@@ -436,20 +436,20 @@  discard block
 block discarded – undo
436 436
 	  * @param 	array $data
437 437
 	  * @return 	TRUE on success, FALSE on fail
438 438
 	  */
439
-	public function set_session_data( $data ) {
439
+	public function set_session_data($data) {
440 440
 
441 441
 		// nothing ??? bad data ??? go home!
442
-		if ( empty( $data ) || ! is_array( $data )) {
443
-			EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
442
+		if (empty($data) || ! is_array($data)) {
443
+			EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
444 444
 			return FALSE;
445 445
 		}
446 446
 
447
-		foreach ( $data as $key =>$value ) {
448
-			if ( isset( $this->_default_session_vars[ $key ] )) {
449
-				EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ );
447
+		foreach ($data as $key =>$value) {
448
+			if (isset($this->_default_session_vars[$key])) {
449
+				EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__);
450 450
 				return FALSE;
451 451
 			} else {
452
-				$this->_session_data[ $key ] = $value;
452
+				$this->_session_data[$key] = $value;
453 453
 			}
454 454
 		}
455 455
 
@@ -467,9 +467,9 @@  discard block
 block discarded – undo
467 467
 	  * @throws \EE_Error
468 468
 	  */
469 469
 	private function _espresso_session() {
470
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
470
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
471 471
 		// check that session has started
472
-		if ( session_id() === '' ) {
472
+		if (session_id() === '') {
473 473
 			//starts a new session if one doesn't already exist, or re-initiates an existing one
474 474
 			session_start();
475 475
 		}
@@ -478,39 +478,39 @@  discard block
 block discarded – undo
478 478
 		// and the visitors IP
479 479
 		$this->_ip_address = $this->_visitor_ip();
480 480
 		// set the "user agent"
481
-		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
481
+		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE;
482 482
 		// now let's retrieve what's in the db
483 483
         $session_data = $this->_retrieve_session_data();
484
-        if (! empty($session_data)) {
484
+        if ( ! empty($session_data)) {
485 485
             // get the current time in UTC
486
-			$this->_time = isset( $this->_time ) ? $this->_time : time();
486
+			$this->_time = isset($this->_time) ? $this->_time : time();
487 487
 			// and reset the session expiration
488
-			$this->_expiration = isset( $session_data['expiration'] )
488
+			$this->_expiration = isset($session_data['expiration'])
489 489
 				? $session_data['expiration']
490 490
 				: $this->_time + $this->_lifespan;
491 491
 		} else {
492 492
             // set initial site access time and the session expiration
493 493
 			$this->_set_init_access_and_expiration();
494 494
 			// set referer
495
-			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] )
496
-				? esc_attr( $_SERVER['HTTP_REFERER'] )
495
+			$this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER'])
496
+				? esc_attr($_SERVER['HTTP_REFERER'])
497 497
 				: '';
498 498
 			// no previous session = go back and create one (on top of the data above)
499 499
 			return FALSE;
500 500
 		}
501 501
         // now the user agent
502
-		if ( $session_data['user_agent'] !== $this->_user_agent ) {
502
+		if ($session_data['user_agent'] !== $this->_user_agent) {
503 503
 			return FALSE;
504 504
 		}
505 505
 		// wait a minute... how old are you?
506
-		if ( $this->_time > $this->_expiration ) {
506
+		if ($this->_time > $this->_expiration) {
507 507
 			// yer too old fer me!
508 508
             $this->_expired = true;
509 509
 			// wipe out everything that isn't a default session datum
510
-			$this->clear_session( __CLASS__, __FUNCTION__ );
510
+			$this->clear_session(__CLASS__, __FUNCTION__);
511 511
 		}
512 512
 		// make event espresso session data available to plugin
513
-		$this->_session_data = array_merge( $this->_session_data, $session_data );
513
+		$this->_session_data = array_merge($this->_session_data, $session_data);
514 514
 		return TRUE;
515 515
 
516 516
 	}
@@ -526,7 +526,7 @@  discard block
 block discarded – undo
526 526
       */
527 527
      protected function _retrieve_session_data()
528 528
      {
529
-         $ssn_key = EE_Session::session_id_prefix . $this->_sid;
529
+         $ssn_key = EE_Session::session_id_prefix.$this->_sid;
530 530
          try {
531 531
              // we're using WP's Transient API to store session data using the PHP session ID as the option name
532 532
              $session_data = $this->cache_storage->get($ssn_key, false);
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
              }
536 536
              if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
537 537
                  $hash_check = $this->cache_storage->get(
538
-                     EE_Session::hash_check_prefix . $this->_sid,
538
+                     EE_Session::hash_check_prefix.$this->_sid,
539 539
                      false
540 540
                  );
541 541
                  if ($hash_check && $hash_check !== md5($session_data)) {
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
                                  'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
546 546
                                  'event_espresso'
547 547
                              ),
548
-                             EE_Session::session_id_prefix . $this->_sid
548
+                             EE_Session::session_id_prefix.$this->_sid
549 549
                          ),
550 550
                          __FILE__, __FUNCTION__, __LINE__
551 551
                      );
@@ -557,17 +557,17 @@  discard block
 block discarded – undo
557 557
              $row = $wpdb->get_row(
558 558
                  $wpdb->prepare(
559 559
                      "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
560
-                     '_transient_' . $ssn_key
560
+                     '_transient_'.$ssn_key
561 561
                  )
562 562
              );
563 563
              $session_data = is_object($row) ? $row->option_value : null;
564 564
              if ($session_data) {
565 565
                  $session_data = preg_replace_callback(
566 566
                      '!s:(d+):"(.*?)";!',
567
-                     function ($match) {
567
+                     function($match) {
568 568
                          return $match[1] === strlen($match[2])
569 569
                              ? $match[0]
570
-                             : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
570
+                             : 's:'.strlen($match[2]).':"'.$match[2].'";';
571 571
                      },
572 572
                      $session_data
573 573
                  );
@@ -588,7 +588,7 @@  discard block
 block discarded – undo
588 588
                      'event_espresso'
589 589
                  );
590 590
                  $msg .= WP_DEBUG
591
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
591
+                     ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
592 592
                      : '';
593 593
                  throw new InvalidSessionDataException($msg, 0, $e);
594 594
              }
@@ -601,11 +601,11 @@  discard block
 block discarded – undo
601 601
                  'event_espresso'
602 602
              );
603 603
              $msg .= WP_DEBUG
604
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
604
+                 ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
605 605
                  : '';
606 606
 	         throw new InvalidSessionDataException($msg);
607 607
          }
608
-	     if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) {
608
+	     if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) {
609 609
              $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
610 610
                  $session_data['transaction']
611 611
 	         );
@@ -626,12 +626,12 @@  discard block
 block discarded – undo
626 626
 	  */
627 627
 	protected function _generate_session_id() {
628 628
 		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
629
-		if ( isset( $_REQUEST[ 'EESID' ] ) ) {
630
-			$session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] );
629
+		if (isset($_REQUEST['EESID'])) {
630
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
631 631
 		} else {
632
-			$session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() );
632
+			$session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
633 633
 		}
634
-		return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id );
634
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
635 635
 	}
636 636
 
637 637
 
@@ -643,20 +643,20 @@  discard block
 block discarded – undo
643 643
 	  */
644 644
 	protected function _get_sid_salt() {
645 645
 		// was session id salt already saved to db ?
646
-		if ( empty( $this->_sid_salt ) ) {
646
+		if (empty($this->_sid_salt)) {
647 647
 			// no?  then maybe use WP defined constant
648
-			if ( defined( 'AUTH_SALT' ) ) {
648
+			if (defined('AUTH_SALT')) {
649 649
 				$this->_sid_salt = AUTH_SALT;
650 650
 			}
651 651
 			// if salt doesn't exist or is too short
652
-			if ( strlen( $this->_sid_salt ) < 32 ) {
652
+			if (strlen($this->_sid_salt) < 32) {
653 653
 				// create a new one
654
-				$this->_sid_salt = wp_generate_password( 64 );
654
+				$this->_sid_salt = wp_generate_password(64);
655 655
 			}
656 656
 			// and save it as a permanent session setting
657
-			$session_settings = get_option( 'ee_session_settings' );
658
-			$session_settings[ 'sid_salt' ] = $this->_sid_salt;
659
-			update_option( 'ee_session_settings', $session_settings );
657
+			$session_settings = get_option('ee_session_settings');
658
+			$session_settings['sid_salt'] = $this->_sid_salt;
659
+			update_option('ee_session_settings', $session_settings);
660 660
 		}
661 661
 		return $this->_sid_salt;
662 662
 	}
@@ -685,19 +685,19 @@  discard block
 block discarded – undo
685 685
       * @return TRUE on success, FALSE on fail
686 686
       * @throws \EE_Error
687 687
       */
688
-	public function update( $new_session = FALSE ) {
689
-		$this->_session_data = isset( $this->_session_data )
690
-			&& is_array( $this->_session_data )
691
-			&& isset( $this->_session_data['id'])
688
+	public function update($new_session = FALSE) {
689
+		$this->_session_data = isset($this->_session_data)
690
+			&& is_array($this->_session_data)
691
+			&& isset($this->_session_data['id'])
692 692
 			? $this->_session_data
693 693
 			: array();
694
-		if ( empty( $this->_session_data )) {
694
+		if (empty($this->_session_data)) {
695 695
 			$this->_set_defaults();
696 696
 		}
697 697
 		$session_data = array();
698
-		foreach ( $this->_session_data as $key => $value ) {
698
+		foreach ($this->_session_data as $key => $value) {
699 699
 
700
-			switch( $key ) {
700
+			switch ($key) {
701 701
 
702 702
 				case 'id' :
703 703
 					// session ID
@@ -715,7 +715,7 @@  discard block
 block discarded – undo
715 715
 				break;
716 716
 
717 717
 				case 'init_access' :
718
-					$session_data['init_access'] = absint( $value );
718
+					$session_data['init_access'] = absint($value);
719 719
 				break;
720 720
 
721 721
 				case 'last_access' :
@@ -725,7 +725,7 @@  discard block
 block discarded – undo
725 725
 
726 726
 				case 'expiration' :
727 727
 					// when the session expires
728
-					$session_data['expiration'] = ! empty( $this->_expiration )
728
+					$session_data['expiration'] = ! empty($this->_expiration)
729 729
 						? $this->_expiration
730 730
 						: $session_data['init_access'] + $this->_lifespan;
731 731
 				break;
@@ -737,11 +737,11 @@  discard block
 block discarded – undo
737 737
 
738 738
 				case 'pages_visited' :
739 739
 					$page_visit = $this->_get_page_visit();
740
-					if ( $page_visit ) {
740
+					if ($page_visit) {
741 741
 						// set pages visited where the first will be the http referrer
742
-						$this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit;
742
+						$this->_session_data['pages_visited'][$this->_time] = $page_visit;
743 743
 						// we'll only save the last 10 page visits.
744
-						$session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 );
744
+						$session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
745 745
 					}
746 746
 				break;
747 747
 
@@ -755,9 +755,9 @@  discard block
 block discarded – undo
755 755
 
756 756
 		$this->_session_data = $session_data;
757 757
 		// creating a new session does not require saving to the db just yet
758
-		if ( ! $new_session ) {
758
+		if ( ! $new_session) {
759 759
 			// ready? let's save
760
-			if ( $this->_save_session_to_db() ) {
760
+			if ($this->_save_session_to_db()) {
761 761
 				return TRUE;
762 762
 			} else {
763 763
 				return FALSE;
@@ -777,9 +777,9 @@  discard block
 block discarded – undo
777 777
       * @throws \EE_Error
778 778
       */
779 779
 	private function _create_espresso_session( ) {
780
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
780
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
781 781
 		// use the update function for now with $new_session arg set to TRUE
782
-		return  $this->update( TRUE ) ? TRUE : FALSE;
782
+		return  $this->update(TRUE) ? TRUE : FALSE;
783 783
 	}
784 784
 
785 785
 
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
                 EE_Registry::instance()->REQ->front_ajax
800 800
                 || (
801 801
                     // OR an admin request that is NOT AJAX
802
-					! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
802
+					! (defined('DOING_AJAX') && DOING_AJAX)
803 803
                     && is_admin()
804 804
 				)
805 805
                 || (
@@ -812,8 +812,8 @@  discard block
 block discarded – undo
812 812
 			return false;
813 813
 		}
814 814
 		$transaction = $this->transaction();
815
-		if ( $transaction instanceof EE_Transaction ) {
816
-			if ( ! $transaction->ID() ) {
815
+		if ($transaction instanceof EE_Transaction) {
816
+			if ( ! $transaction->ID()) {
817 817
 				$transaction->save();
818 818
 			}
819 819
 			$this->_session_data['transaction'] = $transaction->ID();
@@ -822,19 +822,19 @@  discard block
 block discarded – undo
822 822
 		$session_data = serialize($this->_session_data);
823 823
 		// do we need to also encode it to avoid corrupted data when saved to the db?
824 824
 		$session_data = $this->_use_encryption
825
-            ? $this->encryption->base64_string_encode( $session_data )
825
+            ? $this->encryption->base64_string_encode($session_data)
826 826
             : $session_data;
827 827
 		// maybe save hash check
828
-		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
828
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
829 829
             $this->cache_storage->add(
830
-                EE_Session::hash_check_prefix . $this->_sid,
830
+                EE_Session::hash_check_prefix.$this->_sid,
831 831
                 md5($session_data),
832 832
                 $this->_lifespan
833 833
             );
834 834
         }
835 835
         // we're using the Transient API for storing session data,
836 836
         return $this->cache_storage->add(
837
-            EE_Session::session_id_prefix . $this->_sid,
837
+            EE_Session::session_id_prefix.$this->_sid,
838 838
             $session_data,
839 839
             $this->_lifespan
840 840
         );
@@ -863,10 +863,10 @@  discard block
 block discarded – undo
863 863
 			'HTTP_FORWARDED',
864 864
 			'REMOTE_ADDR'
865 865
 		);
866
-		foreach ( $server_keys as $key ){
867
-			if ( isset( $_SERVER[ $key ] )) {
868
-				foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) {
869
-					if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) {
866
+		foreach ($server_keys as $key) {
867
+			if (isset($_SERVER[$key])) {
868
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
869
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) {
870 870
 						$visitor_ip = $ip;
871 871
 					}
872 872
 				}
@@ -885,32 +885,32 @@  discard block
 block discarded – undo
885 885
 	 *			@return string
886 886
 	 */
887 887
 	public function _get_page_visit() {
888
-		$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
888
+		$page_visit = home_url('/').'wp-admin/admin-ajax.php';
889 889
 		// check for request url
890
-		if ( isset( $_SERVER['REQUEST_URI'] )) {
890
+		if (isset($_SERVER['REQUEST_URI'])) {
891 891
 			$http_host = '';
892 892
 			$page_id = '?';
893 893
 			$e_reg = '';
894
-			$request_uri = esc_url( $_SERVER['REQUEST_URI'] );
895
-			$ru_bits = explode( '?', $request_uri );
894
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
895
+			$ru_bits = explode('?', $request_uri);
896 896
 			$request_uri = $ru_bits[0];
897 897
 			// check for and grab host as well
898
-			if ( isset( $_SERVER['HTTP_HOST'] )) {
899
-				$http_host = esc_url( $_SERVER['HTTP_HOST'] );
898
+			if (isset($_SERVER['HTTP_HOST'])) {
899
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
900 900
 			}
901 901
 			// check for page_id in SERVER REQUEST
902
-			if ( isset( $_REQUEST['page_id'] )) {
902
+			if (isset($_REQUEST['page_id'])) {
903 903
 				// rebuild $e_reg without any of the extra parameters
904
-				$page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&amp;';
904
+				$page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
905 905
 			}
906 906
 			// check for $e_reg in SERVER REQUEST
907
-			if ( isset( $_REQUEST['ee'] )) {
907
+			if (isset($_REQUEST['ee'])) {
908 908
 				// rebuild $e_reg without any of the extra parameters
909
-				$e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] );
909
+				$e_reg = 'ee='.esc_attr($_REQUEST['ee']);
910 910
 			}
911
-			$page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' );
911
+			$page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
912 912
 		}
913
-		return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : '';
913
+		return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
914 914
 
915 915
 	}
916 916
 
@@ -940,14 +940,14 @@  discard block
 block discarded – undo
940 940
       * @return void
941 941
       * @throws \EE_Error
942 942
       */
943
-	public function clear_session( $class = '', $function = '' ) {
943
+	public function clear_session($class = '', $function = '') {
944 944
 		//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>';
945
-        do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
945
+        do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
946 946
 		$this->reset_cart();
947 947
 		$this->reset_checkout();
948 948
 		$this->reset_transaction();
949 949
 		// wipe out everything that isn't a default session datum
950
-		$this->reset_data( array_keys( $this->_session_data ));
950
+		$this->reset_data(array_keys($this->_session_data));
951 951
 		// reset initial site access time and the session expiration
952 952
 		$this->_set_init_access_and_expiration();
953 953
 		$this->_save_session_to_db();
@@ -962,42 +962,42 @@  discard block
 block discarded – undo
962 962
 	  * @param bool  $show_all_notices
963 963
 	  * @return TRUE on success, FALSE on fail
964 964
 	  */
965
-	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
965
+	public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) {
966 966
 		// if $data_to_reset is not in an array, then put it in one
967
-		if ( ! is_array( $data_to_reset ) ) {
968
-			$data_to_reset = array ( $data_to_reset );
967
+		if ( ! is_array($data_to_reset)) {
968
+			$data_to_reset = array($data_to_reset);
969 969
 		}
970 970
 		// nothing ??? go home!
971
-		if ( empty( $data_to_reset )) {
972
-			EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
971
+		if (empty($data_to_reset)) {
972
+			EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
973 973
 			return FALSE;
974 974
 		}
975 975
 		$return_value = TRUE;
976 976
 		// since $data_to_reset is an array, cycle through the values
977
-		foreach ( $data_to_reset as $reset ) {
977
+		foreach ($data_to_reset as $reset) {
978 978
 
979 979
 			// first check to make sure it is a valid session var
980
-			if ( isset( $this->_session_data[ $reset ] )) {
980
+			if (isset($this->_session_data[$reset])) {
981 981
 				// then check to make sure it is not a default var
982
-				if ( ! array_key_exists( $reset, $this->_default_session_vars )) {
982
+				if ( ! array_key_exists($reset, $this->_default_session_vars)) {
983 983
 					// remove session var
984
-					unset( $this->_session_data[ $reset ] );
985
-					if ( $show_all_notices ) {
986
-						EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
984
+					unset($this->_session_data[$reset]);
985
+					if ($show_all_notices) {
986
+						EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
987 987
 					}
988
-					$return_value = !isset($return_value) ? TRUE : $return_value;
988
+					$return_value = ! isset($return_value) ? TRUE : $return_value;
989 989
 
990 990
 				} else {
991 991
 					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
992
-					if ( $show_all_notices ) {
993
-						EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
992
+					if ($show_all_notices) {
993
+						EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
994 994
 					}
995 995
 					$return_value = FALSE;
996 996
 				}
997 997
 
998
-			} else if ( $show_all_notices ) {
998
+			} else if ($show_all_notices) {
999 999
 				// oops! that session var does not exist!
1000
-				EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
1000
+				EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
1001 1001
 				$return_value = FALSE;
1002 1002
 			}
1003 1003
 
@@ -1016,8 +1016,8 @@  discard block
 block discarded – undo
1016 1016
       * @throws \EE_Error
1017 1017
       */
1018 1018
 	public function wp_loaded() {
1019
-		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
1020
-			$this->clear_session( __CLASS__, __FUNCTION__ );
1019
+		if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) {
1020
+			$this->clear_session(__CLASS__, __FUNCTION__);
1021 1021
 		}
1022 1022
 	}
1023 1023
 
@@ -1053,7 +1053,7 @@  discard block
 block discarded – undo
1053 1053
              // or use that for the new transient cleanup query limit
1054 1054
              add_filter(
1055 1055
                  'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1056
-                 function () use ($expired_session_transient_delete_query_limit) {
1056
+                 function() use ($expired_session_transient_delete_query_limit) {
1057 1057
                      return $expired_session_transient_delete_query_limit;
1058 1058
                  }
1059 1059
              );
@@ -1067,34 +1067,34 @@  discard block
 block discarded – undo
1067 1067
 	  * @param $data1
1068 1068
 	  * @return string
1069 1069
 	  */
1070
-	 private function find_serialize_error( $data1 ) {
1070
+	 private function find_serialize_error($data1) {
1071 1071
 		$error = '<pre>';
1072 1072
 		 $data2 = preg_replace_callback(
1073 1073
 			 '!s:(\d+):"(.*?)";!',
1074
-			 function ( $match ) {
1075
-				 return ( $match[1] === strlen( $match[2] ) )
1074
+			 function($match) {
1075
+				 return ($match[1] === strlen($match[2]))
1076 1076
 					 ? $match[0]
1077 1077
 					 : 's:'
1078
-					   . strlen( $match[2] )
1078
+					   . strlen($match[2])
1079 1079
 					   . ':"'
1080 1080
 					   . $match[2]
1081 1081
 					   . '";';
1082 1082
 			 },
1083 1083
 			 $data1
1084 1084
 		 );
1085
-		$max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 );
1086
-		$error .= $data1 . PHP_EOL;
1087
-		$error .= $data2 . PHP_EOL;
1088
-		for ( $i = 0; $i < $max; $i++ ) {
1089
-			if ( @$data1[ $i ] !== @$data2[ $i ] ) {
1090
-				$error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL;
1091
-				$error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . ' != ' . ord( @$data2[ $i ] ) . PHP_EOL;
1092
-				$error .= "\t-> Line Number = $i" . PHP_EOL;
1093
-				$start = ( $i - 20 );
1094
-				$start = ( $start < 0 ) ? 0 : $start;
1085
+		$max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1086
+		$error .= $data1.PHP_EOL;
1087
+		$error .= $data2.PHP_EOL;
1088
+		for ($i = 0; $i < $max; $i++) {
1089
+			if (@$data1[$i] !== @$data2[$i]) {
1090
+				$error .= 'Difference '.@$data1[$i].' != '.@$data2[$i].PHP_EOL;
1091
+				$error .= "\t-> ORD number ".ord(@$data1[$i]).' != '.ord(@$data2[$i]).PHP_EOL;
1092
+				$error .= "\t-> Line Number = $i".PHP_EOL;
1093
+				$start = ($i - 20);
1094
+				$start = ($start < 0) ? 0 : $start;
1095 1095
 				$length = 40;
1096 1096
 				$point = $max - $i;
1097
-				if ( $point < 20 ) {
1097
+				if ($point < 20) {
1098 1098
 					$rlength = 1;
1099 1099
 					$rpoint = -$point;
1100 1100
 				} else {
@@ -1103,16 +1103,16 @@  discard block
 block discarded – undo
1103 1103
 				}
1104 1104
 				$error .= "\t-> Section Data1  = ";
1105 1105
 				$error .= substr_replace(
1106
-					substr( $data1, $start, $length ),
1107
-					"<b style=\"color:green\">{$data1[ $i ]}</b>",
1106
+					substr($data1, $start, $length),
1107
+					"<b style=\"color:green\">{$data1[$i]}</b>",
1108 1108
 					$rpoint,
1109 1109
 					$rlength
1110 1110
 				);
1111 1111
 				$error .= PHP_EOL;
1112 1112
 				$error .= "\t-> Section Data2  = ";
1113 1113
 				$error .= substr_replace(
1114
-					substr( $data2, $start, $length ),
1115
-					"<b style=\"color:red\">{$data2[ $i ]}</b>",
1114
+					substr($data2, $start, $length),
1115
+					"<b style=\"color:red\">{$data2[$i]}</b>",
1116 1116
 					$rpoint,
1117 1117
 					$rlength
1118 1118
 				);
Please login to merge, or discard this patch.