Completed
Branch FET-3467-waitlists (4406f2)
by
unknown
46:31 queued 34:26
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   +293 added lines, -293 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
 
@@ -332,9 +332,9 @@  discard block
 block discarded – undo
332 332
 	  * @return \EE_Cart
333 333
 	  */
334 334
 	 public function cart() {
335
-        return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart
336
-            ? $this->_session_data['cart']
337
-            : null;
335
+		return isset($this->_session_data['cart']) && $this->_session_data['cart'] instanceof EE_Cart
336
+			? $this->_session_data['cart']
337
+			: null;
338 338
 	 }
339 339
 
340 340
 
@@ -354,7 +354,7 @@  discard block
 block discarded – undo
354 354
 	  * reset_checkout
355 355
 	  */
356 356
 	 public function reset_checkout() {
357
-        do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
357
+		do_action('AHEE__EE_Session__reset_checkout__before_reset', $this);
358 358
 		 $this->_session_data['checkout'] = NULL;
359 359
 	 }
360 360
 
@@ -364,9 +364,9 @@  discard block
 block discarded – undo
364 364
 	  * @return \EE_Checkout
365 365
 	  */
366 366
 	 public function checkout() {
367
-        return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
368
-            ? $this->_session_data['checkout']
369
-            : null;
367
+		return isset($this->_session_data['checkout']) && $this->_session_data['checkout'] instanceof EE_Checkout
368
+			? $this->_session_data['checkout']
369
+			: null;
370 370
 	 }
371 371
 
372 372
 
@@ -389,7 +389,7 @@  discard block
 block discarded – undo
389 389
 	  * reset_transaction
390 390
 	  */
391 391
 	 public function reset_transaction() {
392
-        do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
392
+		do_action('AHEE__EE_Session__reset_transaction__before_reset', $this);
393 393
 		 $this->_session_data['transaction'] = NULL;
394 394
 	 }
395 395
 
@@ -399,10 +399,10 @@  discard block
 block discarded – undo
399 399
 	  * @return \EE_Transaction
400 400
 	  */
401 401
 	 public function transaction() {
402
-        return isset($this->_session_data['transaction'])
403
-               && $this->_session_data['transaction'] instanceof EE_Transaction
404
-           ? $this->_session_data['transaction']
405
-           : null;
402
+		return isset($this->_session_data['transaction'])
403
+			   && $this->_session_data['transaction'] instanceof EE_Transaction
404
+		   ? $this->_session_data['transaction']
405
+		   : null;
406 406
 	 }
407 407
 
408 408
 
@@ -479,16 +479,16 @@  discard block
 block discarded – undo
479 479
 		// set the "user agent"
480 480
 		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
481 481
 		// now let's retrieve what's in the db
482
-        $session_data = $this->_retrieve_session_data();
483
-        if (! empty($session_data)) {
484
-            // get the current time in UTC
482
+		$session_data = $this->_retrieve_session_data();
483
+		if (! empty($session_data)) {
484
+			// get the current time in UTC
485 485
 			$this->_time = isset( $this->_time ) ? $this->_time : time();
486 486
 			// and reset the session expiration
487 487
 			$this->_expiration = isset( $session_data['expiration'] )
488 488
 				? $session_data['expiration']
489 489
 				: $this->_time + $this->_lifespan;
490 490
 		} else {
491
-            // set initial site access time and the session expiration
491
+			// set initial site access time and the session expiration
492 492
 			$this->_set_init_access_and_expiration();
493 493
 			// set referer
494 494
 			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] )
@@ -497,14 +497,14 @@  discard block
 block discarded – undo
497 497
 			// no previous session = go back and create one (on top of the data above)
498 498
 			return FALSE;
499 499
 		}
500
-        // now the user agent
500
+		// now the user agent
501 501
 		if ( $session_data['user_agent'] !== $this->_user_agent ) {
502 502
 			return FALSE;
503 503
 		}
504 504
 		// wait a minute... how old are you?
505 505
 		if ( $this->_time > $this->_expiration ) {
506 506
 			// yer too old fer me!
507
-            $this->_expired = true;
507
+			$this->_expired = true;
508 508
 			// wipe out everything that isn't a default session datum
509 509
 			$this->clear_session( __CLASS__, __FUNCTION__ );
510 510
 		}
@@ -516,101 +516,101 @@  discard block
 block discarded – undo
516 516
 
517 517
 
518 518
 
519
-     /**
520
-      * _get_session_data
521
-      * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases
522
-      *
523
-      * @return array
524
-      * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
525
-      */
526
-     protected function _retrieve_session_data()
527
-     {
528
-         $ssn_key = EE_Session::session_id_prefix . $this->_sid;
529
-         try {
530
-             // we're using WP's Transient API to store session data using the PHP session ID as the option name
531
-             $session_data = $this->cache_storage->get($ssn_key, false);
532
-	         if (empty($session_data)) {
533
-		         return array();
534
-             }
535
-             if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
536
-                 $hash_check = $this->cache_storage->get(
537
-                     EE_Session::hash_check_prefix . $this->_sid,
538
-                     false
539
-                 );
540
-                 if ($hash_check && $hash_check !== md5($session_data)) {
541
-	                 EE_Error::add_error(
542
-                         sprintf(
543
-                             __(
544
-                                 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
545
-                                 'event_espresso'
546
-                             ),
547
-                             EE_Session::session_id_prefix . $this->_sid
548
-                         ),
549
-                         __FILE__, __FUNCTION__, __LINE__
550
-                     );
551
-                 }
552
-             }
553
-         } catch (Exception $e) {
554
-             // let's just eat that error for now and attempt to correct any corrupted data
555
-             global $wpdb;
556
-             $row = $wpdb->get_row(
557
-                 $wpdb->prepare(
558
-                     "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
559
-                     '_transient_' . $ssn_key
560
-                 )
561
-             );
562
-             $session_data = is_object($row) ? $row->option_value : null;
563
-             if ($session_data) {
564
-                 $session_data = preg_replace_callback(
565
-                     '!s:(d+):"(.*?)";!',
566
-                     function ($match) {
567
-                         return $match[1] === strlen($match[2])
568
-                             ? $match[0]
569
-                             : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
570
-                     },
571
-                     $session_data
572
-                 );
573
-             }
574
-	         $session_data = maybe_unserialize($session_data);
575
-         }
576
-	     // in case the data is encoded... try to decode it
577
-         $session_data = $this->encryption instanceof EE_Encryption
578
-             ? $this->encryption->base64_string_decode($session_data)
579
-             : $session_data;
580
-
581
-         if ( ! is_array($session_data)) {
582
-             try {
583
-	             $session_data = maybe_unserialize($session_data);
584
-             } catch (Exception $e) {
585
-                 $msg = esc_html__(
586
-                     'An error occurred while attempting to unserialize the session data.',
587
-                     'event_espresso'
588
-                 );
589
-                 $msg .= WP_DEBUG
590
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
591
-                     : '';
592
-                 throw new InvalidSessionDataException($msg, 0, $e);
593
-             }
594
-         }
595
-         // just a check to make sure the session array is indeed an array
596
-         if ( ! is_array($session_data)) {
597
-             // no?!?! then something is wrong
598
-             $msg = esc_html__(
599
-                 'The session data is missing, invalid, or corrupted.',
600
-                 'event_espresso'
601
-             );
602
-             $msg .= WP_DEBUG
603
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
604
-                 : '';
605
-	         throw new InvalidSessionDataException($msg);
606
-         }
607
-	     if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) {
608
-             $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
609
-                 $session_data['transaction']
610
-	         );
611
-	     }
612
-         return $session_data;
613
-     }
519
+	 /**
520
+	  * _get_session_data
521
+	  * Retrieves the session data, and attempts to correct any encoding issues that can occur due to improperly setup databases
522
+	  *
523
+	  * @return array
524
+	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
525
+	  */
526
+	 protected function _retrieve_session_data()
527
+	 {
528
+		 $ssn_key = EE_Session::session_id_prefix . $this->_sid;
529
+		 try {
530
+			 // we're using WP's Transient API to store session data using the PHP session ID as the option name
531
+			 $session_data = $this->cache_storage->get($ssn_key, false);
532
+			 if (empty($session_data)) {
533
+				 return array();
534
+			 }
535
+			 if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
536
+				 $hash_check = $this->cache_storage->get(
537
+					 EE_Session::hash_check_prefix . $this->_sid,
538
+					 false
539
+				 );
540
+				 if ($hash_check && $hash_check !== md5($session_data)) {
541
+					 EE_Error::add_error(
542
+						 sprintf(
543
+							 __(
544
+								 'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
545
+								 'event_espresso'
546
+							 ),
547
+							 EE_Session::session_id_prefix . $this->_sid
548
+						 ),
549
+						 __FILE__, __FUNCTION__, __LINE__
550
+					 );
551
+				 }
552
+			 }
553
+		 } catch (Exception $e) {
554
+			 // let's just eat that error for now and attempt to correct any corrupted data
555
+			 global $wpdb;
556
+			 $row = $wpdb->get_row(
557
+				 $wpdb->prepare(
558
+					 "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
559
+					 '_transient_' . $ssn_key
560
+				 )
561
+			 );
562
+			 $session_data = is_object($row) ? $row->option_value : null;
563
+			 if ($session_data) {
564
+				 $session_data = preg_replace_callback(
565
+					 '!s:(d+):"(.*?)";!',
566
+					 function ($match) {
567
+						 return $match[1] === strlen($match[2])
568
+							 ? $match[0]
569
+							 : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
570
+					 },
571
+					 $session_data
572
+				 );
573
+			 }
574
+			 $session_data = maybe_unserialize($session_data);
575
+		 }
576
+		 // in case the data is encoded... try to decode it
577
+		 $session_data = $this->encryption instanceof EE_Encryption
578
+			 ? $this->encryption->base64_string_decode($session_data)
579
+			 : $session_data;
580
+
581
+		 if ( ! is_array($session_data)) {
582
+			 try {
583
+				 $session_data = maybe_unserialize($session_data);
584
+			 } catch (Exception $e) {
585
+				 $msg = esc_html__(
586
+					 'An error occurred while attempting to unserialize the session data.',
587
+					 'event_espresso'
588
+				 );
589
+				 $msg .= WP_DEBUG
590
+					 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
591
+					 : '';
592
+				 throw new InvalidSessionDataException($msg, 0, $e);
593
+			 }
594
+		 }
595
+		 // just a check to make sure the session array is indeed an array
596
+		 if ( ! is_array($session_data)) {
597
+			 // no?!?! then something is wrong
598
+			 $msg = esc_html__(
599
+				 'The session data is missing, invalid, or corrupted.',
600
+				 'event_espresso'
601
+			 );
602
+			 $msg .= WP_DEBUG
603
+				 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
604
+				 : '';
605
+			 throw new InvalidSessionDataException($msg);
606
+		 }
607
+		 if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) {
608
+			 $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
609
+				 $session_data['transaction']
610
+			 );
611
+		 }
612
+		 return $session_data;
613
+	 }
614 614
 
615 615
 
616 616
 
@@ -677,13 +677,13 @@  discard block
 block discarded – undo
677 677
 
678 678
 
679 679
 
680
-     /**
681
-      * @update session data  prior to saving to the db
682
-      * @access public
683
-      * @param bool $new_session
684
-      * @return TRUE on success, FALSE on fail
685
-      * @throws \EE_Error
686
-      */
680
+	 /**
681
+	  * @update session data  prior to saving to the db
682
+	  * @access public
683
+	  * @param bool $new_session
684
+	  * @return TRUE on success, FALSE on fail
685
+	  * @throws \EE_Error
686
+	  */
687 687
 	public function update( $new_session = FALSE ) {
688 688
 		$this->_session_data = isset( $this->_session_data )
689 689
 			&& is_array( $this->_session_data )
@@ -769,12 +769,12 @@  discard block
 block discarded – undo
769 769
 
770 770
 
771 771
 
772
-     /**
773
-      * @create session data array
774
-      * @access public
775
-      * @return bool
776
-      * @throws \EE_Error
777
-      */
772
+	 /**
773
+	  * @create session data array
774
+	  * @access public
775
+	  * @return bool
776
+	  * @throws \EE_Error
777
+	  */
778 778
 	private function _create_espresso_session( ) {
779 779
 		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
780 780
 		// use the update function for now with $new_session arg set to TRUE
@@ -794,19 +794,19 @@  discard block
 block discarded – undo
794 794
 		if (
795 795
 			// if the current request is NOT one of the following
796 796
 			! (
797
-                // an an AJAX request from the frontend
798
-                EE_Registry::instance()->REQ->front_ajax
799
-                || (
800
-                    // OR an admin request that is NOT AJAX
797
+				// an an AJAX request from the frontend
798
+				EE_Registry::instance()->REQ->front_ajax
799
+				|| (
800
+					// OR an admin request that is NOT AJAX
801 801
 					! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
802
-                    && is_admin()
802
+					&& is_admin()
803 803
 				)
804
-                || (
805
-                    // OR an espresso page
806
-                    EE_Registry::instance()->REQ instanceof EE_Request_Handler
807
-                    && EE_Registry::instance()->REQ->is_espresso_page()
808
-                )
809
-            )
804
+				|| (
805
+					// OR an espresso page
806
+					EE_Registry::instance()->REQ instanceof EE_Request_Handler
807
+					&& EE_Registry::instance()->REQ->is_espresso_page()
808
+				)
809
+			)
810 810
 		) {
811 811
 			return false;
812 812
 		}
@@ -817,27 +817,27 @@  discard block
 block discarded – undo
817 817
 			}
818 818
 			$this->_session_data['transaction'] = $transaction->ID();
819 819
 		}
820
-        // then serialize all of our session data
820
+		// then serialize all of our session data
821 821
 		$session_data = serialize($this->_session_data);
822 822
 		// do we need to also encode it to avoid corrupted data when saved to the db?
823 823
 		$session_data = $this->_use_encryption
824
-            ? $this->encryption->base64_string_encode( $session_data )
825
-            : $session_data;
824
+			? $this->encryption->base64_string_encode( $session_data )
825
+			: $session_data;
826 826
 		// maybe save hash check
827 827
 		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
828
-            $this->cache_storage->add(
829
-                EE_Session::hash_check_prefix . $this->_sid,
830
-                md5($session_data),
831
-                $this->_lifespan
832
-            );
833
-        }
834
-        // we're using the Transient API for storing session data,
835
-        return $this->cache_storage->add(
836
-            EE_Session::session_id_prefix . $this->_sid,
837
-            $session_data,
838
-            $this->_lifespan
839
-        );
840
-    }
828
+			$this->cache_storage->add(
829
+				EE_Session::hash_check_prefix . $this->_sid,
830
+				md5($session_data),
831
+				$this->_lifespan
832
+			);
833
+		}
834
+		// we're using the Transient API for storing session data,
835
+		return $this->cache_storage->add(
836
+			EE_Session::session_id_prefix . $this->_sid,
837
+			$session_data,
838
+			$this->_lifespan
839
+		);
840
+	}
841 841
 
842 842
 
843 843
 
@@ -930,18 +930,18 @@  discard block
 block discarded – undo
930 930
 
931 931
 
932 932
 
933
-     /**
934
-      * Clear EE_Session data
935
-      *
936
-      * @access public
937
-      * @param string $class
938
-      * @param string $function
939
-      * @return void
940
-      * @throws \EE_Error
941
-      */
933
+	 /**
934
+	  * Clear EE_Session data
935
+	  *
936
+	  * @access public
937
+	  * @param string $class
938
+	  * @param string $function
939
+	  * @return void
940
+	  * @throws \EE_Error
941
+	  */
942 942
 	public function clear_session( $class = '', $function = '' ) {
943 943
 		//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>';
944
-        do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
944
+		do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
945 945
 		$this->reset_cart();
946 946
 		$this->reset_checkout();
947 947
 		$this->reset_transaction();
@@ -1008,12 +1008,12 @@  discard block
 block discarded – undo
1008 1008
 
1009 1009
 
1010 1010
 
1011
-     /**
1012
-      *   wp_loaded
1013
-      *
1014
-      * @access public
1015
-      * @throws \EE_Error
1016
-      */
1011
+	 /**
1012
+	  *   wp_loaded
1013
+	  *
1014
+	  * @access public
1015
+	  * @throws \EE_Error
1016
+	  */
1017 1017
 	public function wp_loaded() {
1018 1018
 		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
1019 1019
 			$this->clear_session( __CLASS__, __FUNCTION__ );
@@ -1022,12 +1022,12 @@  discard block
 block discarded – undo
1022 1022
 
1023 1023
 
1024 1024
 
1025
-     /**
1026
-      * Used to reset the entire object (for tests).
1027
-      *
1028
-      * @since 4.3.0
1029
-      * @throws \EE_Error
1030
-      */
1025
+	 /**
1026
+	  * Used to reset the entire object (for tests).
1027
+	  *
1028
+	  * @since 4.3.0
1029
+	  * @throws \EE_Error
1030
+	  */
1031 1031
 	public function reset_instance() {
1032 1032
 		$this->clear_session();
1033 1033
 		self::$_instance = NULL;
@@ -1035,29 +1035,29 @@  discard block
 block discarded – undo
1035 1035
 
1036 1036
 
1037 1037
 
1038
-     public function configure_garbage_collection_filters()
1039
-     {
1040
-         // run old filter we had for controlling session cleanup
1041
-         $expired_session_transient_delete_query_limit = absint(
1042
-             apply_filters(
1043
-                 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1044
-                 50
1045
-             )
1046
-         );
1047
-         // is there a value? or one that is different than the default 50 records?
1048
-         if ($expired_session_transient_delete_query_limit === 0) {
1049
-             // hook into TransientCacheStorage in case Session cleanup was turned off
1050
-             add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero');
1051
-         } else if ($expired_session_transient_delete_query_limit !== 50) {
1052
-             // or use that for the new transient cleanup query limit
1053
-             add_filter(
1054
-                 'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1055
-                 function () use ($expired_session_transient_delete_query_limit) {
1056
-                     return $expired_session_transient_delete_query_limit;
1057
-                 }
1058
-             );
1059
-         }
1060
-     }
1038
+	 public function configure_garbage_collection_filters()
1039
+	 {
1040
+		 // run old filter we had for controlling session cleanup
1041
+		 $expired_session_transient_delete_query_limit = absint(
1042
+			 apply_filters(
1043
+				 'FHEE__EE_Session__garbage_collection___expired_session_transient_delete_query_limit',
1044
+				 50
1045
+			 )
1046
+		 );
1047
+		 // is there a value? or one that is different than the default 50 records?
1048
+		 if ($expired_session_transient_delete_query_limit === 0) {
1049
+			 // hook into TransientCacheStorage in case Session cleanup was turned off
1050
+			 add_filter('FHEE__TransientCacheStorage__transient_cleanup_schedule', '__return_zero');
1051
+		 } else if ($expired_session_transient_delete_query_limit !== 50) {
1052
+			 // or use that for the new transient cleanup query limit
1053
+			 add_filter(
1054
+				 'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1055
+				 function () use ($expired_session_transient_delete_query_limit) {
1056
+					 return $expired_session_transient_delete_query_limit;
1057
+				 }
1058
+			 );
1059
+		 }
1060
+	 }
1061 1061
 
1062 1062
 
1063 1063
 
Please login to merge, or discard this patch.
Spacing   +148 added lines, -148 removed lines patch added patch discarded remove patch
@@ -2,7 +2,7 @@  discard block
 block discarded – undo
2 2
 use EventEspresso\core\exceptions\InvalidSessionDataException;
3 3
 use EventEspresso\core\services\cache\CacheStorageInterface;
4 4
 
5
-if (!defined( 'EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
5
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
6 6
 /**
7 7
  *
8 8
  * EE_Session class
@@ -108,7 +108,7 @@  discard block
 block discarded – undo
108 108
 	  * array for defining default session vars
109 109
 	  * @var array
110 110
 	  */
111
-	 private $_default_session_vars = array (
111
+	 private $_default_session_vars = array(
112 112
         'id'            => null,
113 113
         'user_id'       => null,
114 114
         'ip_address'    => null,
@@ -136,8 +136,8 @@  discard block
 block discarded – undo
136 136
 		// check if class object is instantiated
137 137
 		// session loading is turned ON by default, but prior to the init hook, can be turned back OFF via:
138 138
 		// add_filter( 'FHEE_load_EE_Session', '__return_false' );
139
-		if ( ! self::$_instance instanceof EE_Session && apply_filters( 'FHEE_load_EE_Session', true ) ) {
140
-			self::$_instance = new self($cache_storage, $encryption );
139
+		if ( ! self::$_instance instanceof EE_Session && apply_filters('FHEE_load_EE_Session', true)) {
140
+			self::$_instance = new self($cache_storage, $encryption);
141 141
 		}
142 142
 		return self::$_instance;
143 143
 	}
@@ -152,15 +152,15 @@  discard block
 block discarded – undo
152 152
 	  * @throws \EE_Error
153 153
 	  * @throws \EventEspresso\core\exceptions\InvalidSessionDataException
154 154
 	  */
155
-	 protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null ) {
155
+	 protected function __construct(CacheStorageInterface $cache_storage, EE_Encryption $encryption = null) {
156 156
 
157 157
 		// 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' );
158
-		if ( ! apply_filters( 'FHEE_load_EE_Session', true ) ) {
158
+		if ( ! apply_filters('FHEE_load_EE_Session', true)) {
159 159
 			return;
160 160
 		}
161
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
162
-		if ( ! defined( 'ESPRESSO_SESSION' ) ) {
163
-			define( 'ESPRESSO_SESSION', true );
161
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
162
+		if ( ! defined('ESPRESSO_SESSION')) {
163
+			define('ESPRESSO_SESSION', true);
164 164
 		}
165 165
 		// default session lifespan in seconds
166 166
 		$this->_lifespan = apply_filters(
@@ -174,12 +174,12 @@  discard block
 block discarded – undo
174 174
 		 * 		}
175 175
 		 */
176 176
 		// retrieve session options from db
177
-		$session_settings = (array) get_option( 'ee_session_settings', array() );
178
-		if ( ! empty( $session_settings )) {
177
+		$session_settings = (array) get_option('ee_session_settings', array());
178
+		if ( ! empty($session_settings)) {
179 179
 			// cycle though existing session options
180
-			foreach ( $session_settings as $var_name => $session_setting ) {
180
+			foreach ($session_settings as $var_name => $session_setting) {
181 181
 				// set values for class properties
182
-				$var_name = '_' . $var_name;
182
+				$var_name = '_'.$var_name;
183 183
 				$this->{$var_name} = $session_setting;
184 184
 			}
185 185
 		}
@@ -190,15 +190,15 @@  discard block
 block discarded – undo
190 190
         // encrypt data via: $this->encryption->encrypt();
191 191
         $this->encryption = $encryption;
192 192
 		// filter hook allows outside functions/classes/plugins to change default empty cart
193
-		$extra_default_session_vars = apply_filters( 'FHEE__EE_Session__construct__extra_default_session_vars', array() );
194
-		array_merge( $this->_default_session_vars, $extra_default_session_vars );
193
+		$extra_default_session_vars = apply_filters('FHEE__EE_Session__construct__extra_default_session_vars', array());
194
+		array_merge($this->_default_session_vars, $extra_default_session_vars);
195 195
 		// apply default session vars
196 196
 		$this->_set_defaults();
197 197
          add_action('AHEE__EE_System__initialize', array($this, 'open_session'));
198 198
          // check request for 'clear_session' param
199
-		add_action( 'AHEE__EE_Request_Handler__construct__complete', array( $this, 'wp_loaded' ));
199
+		add_action('AHEE__EE_Request_Handler__construct__complete', array($this, 'wp_loaded'));
200 200
 		// once everything is all said and done,
201
-		add_action( 'shutdown', array( $this, 'update' ), 100 );
201
+		add_action('shutdown', array($this, 'update'), 100);
202 202
          $this->configure_garbage_collection_filters();
203 203
 	}
204 204
 
@@ -286,11 +286,11 @@  discard block
 block discarded – undo
286 286
 	 */
287 287
 	private function _set_defaults() {
288 288
 		// set some defaults
289
-		foreach ( $this->_default_session_vars as $key => $default_var ) {
290
-			if ( is_array( $default_var )) {
291
-				$this->_session_data[ $key ] = array();
289
+		foreach ($this->_default_session_vars as $key => $default_var) {
290
+			if (is_array($default_var)) {
291
+				$this->_session_data[$key] = array();
292 292
 			} else {
293
-				$this->_session_data[ $key ] = '';
293
+				$this->_session_data[$key] = '';
294 294
 			}
295 295
 		}
296 296
 	}
@@ -345,7 +345,7 @@  discard block
 block discarded – undo
345 345
 	  * @param \EE_Checkout $checkout
346 346
 	  * @return bool
347 347
 	  */
348
-	 public function set_checkout( EE_Checkout $checkout ) {
348
+	 public function set_checkout(EE_Checkout $checkout) {
349 349
 		 $this->_session_data['checkout'] = $checkout;
350 350
 		 return TRUE;
351 351
 	 }
@@ -378,9 +378,9 @@  discard block
 block discarded – undo
378 378
 	  * @return bool
379 379
 	  * @throws \EE_Error
380 380
 	  */
381
-	 public function set_transaction( EE_Transaction $transaction ) {
381
+	 public function set_transaction(EE_Transaction $transaction) {
382 382
 		 // first remove the session from the transaction before we save the transaction in the session
383
-		 $transaction->set_txn_session_data( NULL );
383
+		 $transaction->set_txn_session_data(NULL);
384 384
 		 $this->_session_data['transaction'] = $transaction;
385 385
 		 return TRUE;
386 386
 	 }
@@ -416,15 +416,15 @@  discard block
 block discarded – undo
416 416
 	  * @param bool $reset_cache
417 417
 	  * @return    array
418 418
 	  */
419
-	public function get_session_data( $key = NULL, $reset_cache = FALSE ) {
420
-		if ( $reset_cache ) {
419
+	public function get_session_data($key = NULL, $reset_cache = FALSE) {
420
+		if ($reset_cache) {
421 421
 			$this->reset_cart();
422 422
 			$this->reset_checkout();
423 423
 			$this->reset_transaction();
424 424
 		}
425
-		 if ( ! empty( $key ))  {
426
-			return  isset( $this->_session_data[ $key ] ) ? $this->_session_data[ $key ] : NULL;
427
-		}  else  {
425
+		 if ( ! empty($key)) {
426
+			return  isset($this->_session_data[$key]) ? $this->_session_data[$key] : NULL;
427
+		} else {
428 428
 			return $this->_session_data;
429 429
 		}
430 430
 	}
@@ -437,20 +437,20 @@  discard block
 block discarded – undo
437 437
 	  * @param 	array $data
438 438
 	  * @return 	TRUE on success, FALSE on fail
439 439
 	  */
440
-	public function set_session_data( $data ) {
440
+	public function set_session_data($data) {
441 441
 
442 442
 		// nothing ??? bad data ??? go home!
443
-		if ( empty( $data ) || ! is_array( $data )) {
444
-			EE_Error::add_error( __( 'No session data or invalid session data was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
443
+		if (empty($data) || ! is_array($data)) {
444
+			EE_Error::add_error(__('No session data or invalid session data was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
445 445
 			return FALSE;
446 446
 		}
447 447
 
448
-		foreach ( $data as $key =>$value ) {
449
-			if ( isset( $this->_default_session_vars[ $key ] )) {
450
-				EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $key ), __FILE__, __FUNCTION__, __LINE__ );
448
+		foreach ($data as $key =>$value) {
449
+			if (isset($this->_default_session_vars[$key])) {
450
+				EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $key), __FILE__, __FUNCTION__, __LINE__);
451 451
 				return FALSE;
452 452
 			} else {
453
-				$this->_session_data[ $key ] = $value;
453
+				$this->_session_data[$key] = $value;
454 454
 			}
455 455
 		}
456 456
 
@@ -468,9 +468,9 @@  discard block
 block discarded – undo
468 468
 	  * @throws \EE_Error
469 469
 	  */
470 470
 	private function _espresso_session() {
471
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
471
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
472 472
 		// check that session has started
473
-		if ( session_id() === '' ) {
473
+		if (session_id() === '') {
474 474
 			//starts a new session if one doesn't already exist, or re-initiates an existing one
475 475
 			session_start();
476 476
 		}
@@ -479,39 +479,39 @@  discard block
 block discarded – undo
479 479
 		// and the visitors IP
480 480
 		$this->_ip_address = $this->_visitor_ip();
481 481
 		// set the "user agent"
482
-		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr( $_SERVER['HTTP_USER_AGENT'] ) : FALSE;
482
+		$this->_user_agent = isset($_SERVER['HTTP_USER_AGENT']) ? esc_attr($_SERVER['HTTP_USER_AGENT']) : FALSE;
483 483
 		// now let's retrieve what's in the db
484 484
         $session_data = $this->_retrieve_session_data();
485
-        if (! empty($session_data)) {
485
+        if ( ! empty($session_data)) {
486 486
             // get the current time in UTC
487
-			$this->_time = isset( $this->_time ) ? $this->_time : time();
487
+			$this->_time = isset($this->_time) ? $this->_time : time();
488 488
 			// and reset the session expiration
489
-			$this->_expiration = isset( $session_data['expiration'] )
489
+			$this->_expiration = isset($session_data['expiration'])
490 490
 				? $session_data['expiration']
491 491
 				: $this->_time + $this->_lifespan;
492 492
 		} else {
493 493
             // set initial site access time and the session expiration
494 494
 			$this->_set_init_access_and_expiration();
495 495
 			// set referer
496
-			$this->_session_data[ 'pages_visited' ][ $this->_session_data['init_access'] ] = isset( $_SERVER['HTTP_REFERER'] )
497
-				? esc_attr( $_SERVER['HTTP_REFERER'] )
496
+			$this->_session_data['pages_visited'][$this->_session_data['init_access']] = isset($_SERVER['HTTP_REFERER'])
497
+				? esc_attr($_SERVER['HTTP_REFERER'])
498 498
 				: '';
499 499
 			// no previous session = go back and create one (on top of the data above)
500 500
 			return FALSE;
501 501
 		}
502 502
         // now the user agent
503
-		if ( $session_data['user_agent'] !== $this->_user_agent ) {
503
+		if ($session_data['user_agent'] !== $this->_user_agent) {
504 504
 			return FALSE;
505 505
 		}
506 506
 		// wait a minute... how old are you?
507
-		if ( $this->_time > $this->_expiration ) {
507
+		if ($this->_time > $this->_expiration) {
508 508
 			// yer too old fer me!
509 509
             $this->_expired = true;
510 510
 			// wipe out everything that isn't a default session datum
511
-			$this->clear_session( __CLASS__, __FUNCTION__ );
511
+			$this->clear_session(__CLASS__, __FUNCTION__);
512 512
 		}
513 513
 		// make event espresso session data available to plugin
514
-		$this->_session_data = array_merge( $this->_session_data, $session_data );
514
+		$this->_session_data = array_merge($this->_session_data, $session_data);
515 515
 		return TRUE;
516 516
 
517 517
 	}
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
       */
528 528
      protected function _retrieve_session_data()
529 529
      {
530
-         $ssn_key = EE_Session::session_id_prefix . $this->_sid;
530
+         $ssn_key = EE_Session::session_id_prefix.$this->_sid;
531 531
          try {
532 532
              // we're using WP's Transient API to store session data using the PHP session ID as the option name
533 533
              $session_data = $this->cache_storage->get($ssn_key, false);
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
              }
537 537
              if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
538 538
                  $hash_check = $this->cache_storage->get(
539
-                     EE_Session::hash_check_prefix . $this->_sid,
539
+                     EE_Session::hash_check_prefix.$this->_sid,
540 540
                      false
541 541
                  );
542 542
                  if ($hash_check && $hash_check !== md5($session_data)) {
@@ -546,7 +546,7 @@  discard block
 block discarded – undo
546 546
                                  'The stored data for session %1$s failed to pass a hash check and therefore appears to be invalid.',
547 547
                                  'event_espresso'
548 548
                              ),
549
-                             EE_Session::session_id_prefix . $this->_sid
549
+                             EE_Session::session_id_prefix.$this->_sid
550 550
                          ),
551 551
                          __FILE__, __FUNCTION__, __LINE__
552 552
                      );
@@ -558,17 +558,17 @@  discard block
 block discarded – undo
558 558
              $row = $wpdb->get_row(
559 559
                  $wpdb->prepare(
560 560
                      "SELECT option_value FROM {$wpdb->options} WHERE option_name = %s LIMIT 1",
561
-                     '_transient_' . $ssn_key
561
+                     '_transient_'.$ssn_key
562 562
                  )
563 563
              );
564 564
              $session_data = is_object($row) ? $row->option_value : null;
565 565
              if ($session_data) {
566 566
                  $session_data = preg_replace_callback(
567 567
                      '!s:(d+):"(.*?)";!',
568
-                     function ($match) {
568
+                     function($match) {
569 569
                          return $match[1] === strlen($match[2])
570 570
                              ? $match[0]
571
-                             : 's:' . strlen($match[2]) . ':"' . $match[2] . '";';
571
+                             : 's:'.strlen($match[2]).':"'.$match[2].'";';
572 572
                      },
573 573
                      $session_data
574 574
                  );
@@ -589,7 +589,7 @@  discard block
 block discarded – undo
589 589
                      'event_espresso'
590 590
                  );
591 591
                  $msg .= WP_DEBUG
592
-                     ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
592
+                     ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
593 593
                      : '';
594 594
                  throw new InvalidSessionDataException($msg, 0, $e);
595 595
              }
@@ -602,11 +602,11 @@  discard block
 block discarded – undo
602 602
                  'event_espresso'
603 603
              );
604 604
              $msg .= WP_DEBUG
605
-                 ? '<br><pre>' . print_r($session_data, true) . '</pre><br>' . $this->find_serialize_error($session_data)
605
+                 ? '<br><pre>'.print_r($session_data, true).'</pre><br>'.$this->find_serialize_error($session_data)
606 606
                  : '';
607 607
 	         throw new InvalidSessionDataException($msg);
608 608
          }
609
-	     if ( isset($session_data['transaction'] ) && absint($session_data['transaction'] ) !== 0 ) {
609
+	     if (isset($session_data['transaction']) && absint($session_data['transaction']) !== 0) {
610 610
              $session_data['transaction'] = EEM_Transaction::instance()->get_one_by_ID(
611 611
                  $session_data['transaction']
612 612
 	         );
@@ -627,12 +627,12 @@  discard block
 block discarded – undo
627 627
 	  */
628 628
 	protected function _generate_session_id() {
629 629
 		// check if the SID was passed explicitly, otherwise get from session, then add salt and hash it to reduce length
630
-		if ( isset( $_REQUEST[ 'EESID' ] ) ) {
631
-			$session_id = sanitize_text_field( $_REQUEST[ 'EESID' ] );
630
+		if (isset($_REQUEST['EESID'])) {
631
+			$session_id = sanitize_text_field($_REQUEST['EESID']);
632 632
 		} else {
633
-			$session_id = md5( session_id() . get_current_blog_id() . $this->_get_sid_salt() );
633
+			$session_id = md5(session_id().get_current_blog_id().$this->_get_sid_salt());
634 634
 		}
635
-		return apply_filters( 'FHEE__EE_Session___generate_session_id__session_id', $session_id );
635
+		return apply_filters('FHEE__EE_Session___generate_session_id__session_id', $session_id);
636 636
 	}
637 637
 
638 638
 
@@ -644,20 +644,20 @@  discard block
 block discarded – undo
644 644
 	  */
645 645
 	protected function _get_sid_salt() {
646 646
 		// was session id salt already saved to db ?
647
-		if ( empty( $this->_sid_salt ) ) {
647
+		if (empty($this->_sid_salt)) {
648 648
 			// no?  then maybe use WP defined constant
649
-			if ( defined( 'AUTH_SALT' ) ) {
649
+			if (defined('AUTH_SALT')) {
650 650
 				$this->_sid_salt = AUTH_SALT;
651 651
 			}
652 652
 			// if salt doesn't exist or is too short
653
-			if ( strlen( $this->_sid_salt ) < 32 ) {
653
+			if (strlen($this->_sid_salt) < 32) {
654 654
 				// create a new one
655
-				$this->_sid_salt = wp_generate_password( 64 );
655
+				$this->_sid_salt = wp_generate_password(64);
656 656
 			}
657 657
 			// and save it as a permanent session setting
658
-			$session_settings = get_option( 'ee_session_settings' );
659
-			$session_settings[ 'sid_salt' ] = $this->_sid_salt;
660
-			update_option( 'ee_session_settings', $session_settings );
658
+			$session_settings = get_option('ee_session_settings');
659
+			$session_settings['sid_salt'] = $this->_sid_salt;
660
+			update_option('ee_session_settings', $session_settings);
661 661
 		}
662 662
 		return $this->_sid_salt;
663 663
 	}
@@ -686,19 +686,19 @@  discard block
 block discarded – undo
686 686
       * @return TRUE on success, FALSE on fail
687 687
       * @throws \EE_Error
688 688
       */
689
-	public function update( $new_session = FALSE ) {
690
-		$this->_session_data = isset( $this->_session_data )
691
-			&& is_array( $this->_session_data )
692
-			&& isset( $this->_session_data['id'])
689
+	public function update($new_session = FALSE) {
690
+		$this->_session_data = isset($this->_session_data)
691
+			&& is_array($this->_session_data)
692
+			&& isset($this->_session_data['id'])
693 693
 			? $this->_session_data
694 694
 			: array();
695
-		if ( empty( $this->_session_data )) {
695
+		if (empty($this->_session_data)) {
696 696
 			$this->_set_defaults();
697 697
 		}
698 698
 		$session_data = array();
699
-		foreach ( $this->_session_data as $key => $value ) {
699
+		foreach ($this->_session_data as $key => $value) {
700 700
 
701
-			switch( $key ) {
701
+			switch ($key) {
702 702
 
703 703
 				case 'id' :
704 704
 					// session ID
@@ -716,7 +716,7 @@  discard block
 block discarded – undo
716 716
 				break;
717 717
 
718 718
 				case 'init_access' :
719
-					$session_data['init_access'] = absint( $value );
719
+					$session_data['init_access'] = absint($value);
720 720
 				break;
721 721
 
722 722
 				case 'last_access' :
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 
727 727
 				case 'expiration' :
728 728
 					// when the session expires
729
-					$session_data['expiration'] = ! empty( $this->_expiration )
729
+					$session_data['expiration'] = ! empty($this->_expiration)
730 730
 						? $this->_expiration
731 731
 						: $session_data['init_access'] + $this->_lifespan;
732 732
 				break;
@@ -738,11 +738,11 @@  discard block
 block discarded – undo
738 738
 
739 739
 				case 'pages_visited' :
740 740
 					$page_visit = $this->_get_page_visit();
741
-					if ( $page_visit ) {
741
+					if ($page_visit) {
742 742
 						// set pages visited where the first will be the http referrer
743
-						$this->_session_data[ 'pages_visited' ][ $this->_time ] = $page_visit;
743
+						$this->_session_data['pages_visited'][$this->_time] = $page_visit;
744 744
 						// we'll only save the last 10 page visits.
745
-						$session_data[ 'pages_visited' ] = array_slice( $this->_session_data['pages_visited'], -10 );
745
+						$session_data['pages_visited'] = array_slice($this->_session_data['pages_visited'], -10);
746 746
 					}
747 747
 				break;
748 748
 
@@ -756,9 +756,9 @@  discard block
 block discarded – undo
756 756
 
757 757
 		$this->_session_data = $session_data;
758 758
 		// creating a new session does not require saving to the db just yet
759
-		if ( ! $new_session ) {
759
+		if ( ! $new_session) {
760 760
 			// ready? let's save
761
-			if ( $this->_save_session_to_db() ) {
761
+			if ($this->_save_session_to_db()) {
762 762
 				return TRUE;
763 763
 			} else {
764 764
 				return FALSE;
@@ -778,9 +778,9 @@  discard block
 block discarded – undo
778 778
       * @throws \EE_Error
779 779
       */
780 780
 	private function _create_espresso_session( ) {
781
-		do_action( 'AHEE_log', __CLASS__, __FUNCTION__, '' );
781
+		do_action('AHEE_log', __CLASS__, __FUNCTION__, '');
782 782
 		// use the update function for now with $new_session arg set to TRUE
783
-		return  $this->update( TRUE ) ? TRUE : FALSE;
783
+		return  $this->update(TRUE) ? TRUE : FALSE;
784 784
 	}
785 785
 
786 786
 
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
                 EE_Registry::instance()->REQ->front_ajax
801 801
                 || (
802 802
                     // OR an admin request that is NOT AJAX
803
-					! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
803
+					! (defined('DOING_AJAX') && DOING_AJAX)
804 804
                     && is_admin()
805 805
 				)
806 806
                 || (
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
 			return false;
814 814
 		}
815 815
 		$transaction = $this->transaction();
816
-		if ( $transaction instanceof EE_Transaction ) {
817
-			if ( ! $transaction->ID() ) {
816
+		if ($transaction instanceof EE_Transaction) {
817
+			if ( ! $transaction->ID()) {
818 818
 				$transaction->save();
819 819
 			}
820 820
 			$this->_session_data['transaction'] = $transaction->ID();
@@ -823,19 +823,19 @@  discard block
 block discarded – undo
823 823
 		$session_data = serialize($this->_session_data);
824 824
 		// do we need to also encode it to avoid corrupted data when saved to the db?
825 825
 		$session_data = $this->_use_encryption
826
-            ? $this->encryption->base64_string_encode( $session_data )
826
+            ? $this->encryption->base64_string_encode($session_data)
827 827
             : $session_data;
828 828
 		// maybe save hash check
829
-		if ( apply_filters( 'FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG ) ) {
829
+		if (apply_filters('FHEE__EE_Session___perform_session_id_hash_check', WP_DEBUG)) {
830 830
             $this->cache_storage->add(
831
-                EE_Session::hash_check_prefix . $this->_sid,
831
+                EE_Session::hash_check_prefix.$this->_sid,
832 832
                 md5($session_data),
833 833
                 $this->_lifespan
834 834
             );
835 835
         }
836 836
         // we're using the Transient API for storing session data,
837 837
         return $this->cache_storage->add(
838
-            EE_Session::session_id_prefix . $this->_sid,
838
+            EE_Session::session_id_prefix.$this->_sid,
839 839
             $session_data,
840 840
             $this->_lifespan
841 841
         );
@@ -864,10 +864,10 @@  discard block
 block discarded – undo
864 864
 			'HTTP_FORWARDED',
865 865
 			'REMOTE_ADDR'
866 866
 		);
867
-		foreach ( $server_keys as $key ){
868
-			if ( isset( $_SERVER[ $key ] )) {
869
-				foreach ( array_map( 'trim', explode( ',', $_SERVER[ $key ] )) as $ip ) {
870
-					if ( $ip === '127.0.0.1' || filter_var( $ip, FILTER_VALIDATE_IP ) !== FALSE ) {
867
+		foreach ($server_keys as $key) {
868
+			if (isset($_SERVER[$key])) {
869
+				foreach (array_map('trim', explode(',', $_SERVER[$key])) as $ip) {
870
+					if ($ip === '127.0.0.1' || filter_var($ip, FILTER_VALIDATE_IP) !== FALSE) {
871 871
 						$visitor_ip = $ip;
872 872
 					}
873 873
 				}
@@ -886,32 +886,32 @@  discard block
 block discarded – undo
886 886
 	 *			@return string
887 887
 	 */
888 888
 	public function _get_page_visit() {
889
-		$page_visit = home_url('/') . 'wp-admin/admin-ajax.php';
889
+		$page_visit = home_url('/').'wp-admin/admin-ajax.php';
890 890
 		// check for request url
891
-		if ( isset( $_SERVER['REQUEST_URI'] )) {
891
+		if (isset($_SERVER['REQUEST_URI'])) {
892 892
 			$http_host = '';
893 893
 			$page_id = '?';
894 894
 			$e_reg = '';
895
-			$request_uri = esc_url( $_SERVER['REQUEST_URI'] );
896
-			$ru_bits = explode( '?', $request_uri );
895
+			$request_uri = esc_url($_SERVER['REQUEST_URI']);
896
+			$ru_bits = explode('?', $request_uri);
897 897
 			$request_uri = $ru_bits[0];
898 898
 			// check for and grab host as well
899
-			if ( isset( $_SERVER['HTTP_HOST'] )) {
900
-				$http_host = esc_url( $_SERVER['HTTP_HOST'] );
899
+			if (isset($_SERVER['HTTP_HOST'])) {
900
+				$http_host = esc_url($_SERVER['HTTP_HOST']);
901 901
 			}
902 902
 			// check for page_id in SERVER REQUEST
903
-			if ( isset( $_REQUEST['page_id'] )) {
903
+			if (isset($_REQUEST['page_id'])) {
904 904
 				// rebuild $e_reg without any of the extra parameters
905
-				$page_id = '?page_id=' . esc_attr( $_REQUEST['page_id'] ) . '&amp;';
905
+				$page_id = '?page_id='.esc_attr($_REQUEST['page_id']).'&amp;';
906 906
 			}
907 907
 			// check for $e_reg in SERVER REQUEST
908
-			if ( isset( $_REQUEST['ee'] )) {
908
+			if (isset($_REQUEST['ee'])) {
909 909
 				// rebuild $e_reg without any of the extra parameters
910
-				$e_reg = 'ee=' . esc_attr( $_REQUEST['ee'] );
910
+				$e_reg = 'ee='.esc_attr($_REQUEST['ee']);
911 911
 			}
912
-			$page_visit = rtrim( $http_host . $request_uri . $page_id . $e_reg, '?' );
912
+			$page_visit = rtrim($http_host.$request_uri.$page_id.$e_reg, '?');
913 913
 		}
914
-		return $page_visit !== home_url( '/wp-admin/admin-ajax.php' ) ? $page_visit : '';
914
+		return $page_visit !== home_url('/wp-admin/admin-ajax.php') ? $page_visit : '';
915 915
 
916 916
 	}
917 917
 
@@ -941,14 +941,14 @@  discard block
 block discarded – undo
941 941
       * @return void
942 942
       * @throws \EE_Error
943 943
       */
944
-	public function clear_session( $class = '', $function = '' ) {
944
+	public function clear_session($class = '', $function = '') {
945 945
 		//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>';
946
-        do_action( 'AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : ' . $class . '::' .  $function . '()' );
946
+        do_action('AHEE_log', __FILE__, __FUNCTION__, 'session cleared by : '.$class.'::'.$function.'()');
947 947
 		$this->reset_cart();
948 948
 		$this->reset_checkout();
949 949
 		$this->reset_transaction();
950 950
 		// wipe out everything that isn't a default session datum
951
-		$this->reset_data( array_keys( $this->_session_data ));
951
+		$this->reset_data(array_keys($this->_session_data));
952 952
 		// reset initial site access time and the session expiration
953 953
 		$this->_set_init_access_and_expiration();
954 954
 		$this->_save_session_to_db();
@@ -963,42 +963,42 @@  discard block
 block discarded – undo
963 963
 	  * @param bool  $show_all_notices
964 964
 	  * @return TRUE on success, FALSE on fail
965 965
 	  */
966
-	public function reset_data( $data_to_reset = array(), $show_all_notices = FALSE ) {
966
+	public function reset_data($data_to_reset = array(), $show_all_notices = FALSE) {
967 967
 		// if $data_to_reset is not in an array, then put it in one
968
-		if ( ! is_array( $data_to_reset ) ) {
969
-			$data_to_reset = array ( $data_to_reset );
968
+		if ( ! is_array($data_to_reset)) {
969
+			$data_to_reset = array($data_to_reset);
970 970
 		}
971 971
 		// nothing ??? go home!
972
-		if ( empty( $data_to_reset )) {
973
-			EE_Error::add_error( __( 'No session data could be reset, because no session var name was provided.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
972
+		if (empty($data_to_reset)) {
973
+			EE_Error::add_error(__('No session data could be reset, because no session var name was provided.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
974 974
 			return FALSE;
975 975
 		}
976 976
 		$return_value = TRUE;
977 977
 		// since $data_to_reset is an array, cycle through the values
978
-		foreach ( $data_to_reset as $reset ) {
978
+		foreach ($data_to_reset as $reset) {
979 979
 
980 980
 			// first check to make sure it is a valid session var
981
-			if ( isset( $this->_session_data[ $reset ] )) {
981
+			if (isset($this->_session_data[$reset])) {
982 982
 				// then check to make sure it is not a default var
983
-				if ( ! array_key_exists( $reset, $this->_default_session_vars )) {
983
+				if ( ! array_key_exists($reset, $this->_default_session_vars)) {
984 984
 					// remove session var
985
-					unset( $this->_session_data[ $reset ] );
986
-					if ( $show_all_notices ) {
987
-						EE_Error::add_success( sprintf( __( 'The session variable %s was removed.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
985
+					unset($this->_session_data[$reset]);
986
+					if ($show_all_notices) {
987
+						EE_Error::add_success(sprintf(__('The session variable %s was removed.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
988 988
 					}
989
-					$return_value = !isset($return_value) ? TRUE : $return_value;
989
+					$return_value = ! isset($return_value) ? TRUE : $return_value;
990 990
 
991 991
 				} else {
992 992
 					// yeeeeeeeeerrrrrrrrrrr OUT !!!!
993
-					if ( $show_all_notices ) {
994
-						EE_Error::add_error( sprintf( __( 'Sorry! %s is a default session datum and can not be reset.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
993
+					if ($show_all_notices) {
994
+						EE_Error::add_error(sprintf(__('Sorry! %s is a default session datum and can not be reset.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
995 995
 					}
996 996
 					$return_value = FALSE;
997 997
 				}
998 998
 
999
-			} else if ( $show_all_notices ) {
999
+			} else if ($show_all_notices) {
1000 1000
 				// oops! that session var does not exist!
1001
-				EE_Error::add_error( sprintf( __( 'The session item provided, %s, is invalid or does not exist.', 'event_espresso' ), $reset ), __FILE__, __FUNCTION__, __LINE__ );
1001
+				EE_Error::add_error(sprintf(__('The session item provided, %s, is invalid or does not exist.', 'event_espresso'), $reset), __FILE__, __FUNCTION__, __LINE__);
1002 1002
 				$return_value = FALSE;
1003 1003
 			}
1004 1004
 
@@ -1017,8 +1017,8 @@  discard block
 block discarded – undo
1017 1017
       * @throws \EE_Error
1018 1018
       */
1019 1019
 	public function wp_loaded() {
1020
-		if ( isset(  EE_Registry::instance()->REQ ) && EE_Registry::instance()->REQ->is_set( 'clear_session' )) {
1021
-			$this->clear_session( __CLASS__, __FUNCTION__ );
1020
+		if (isset(EE_Registry::instance()->REQ) && EE_Registry::instance()->REQ->is_set('clear_session')) {
1021
+			$this->clear_session(__CLASS__, __FUNCTION__);
1022 1022
 		}
1023 1023
 	}
1024 1024
 
@@ -1054,7 +1054,7 @@  discard block
 block discarded – undo
1054 1054
              // or use that for the new transient cleanup query limit
1055 1055
              add_filter(
1056 1056
                  'FHEE__TransientCacheStorage__clearExpiredTransients__limit',
1057
-                 function () use ($expired_session_transient_delete_query_limit) {
1057
+                 function() use ($expired_session_transient_delete_query_limit) {
1058 1058
                      return $expired_session_transient_delete_query_limit;
1059 1059
                  }
1060 1060
              );
@@ -1068,34 +1068,34 @@  discard block
 block discarded – undo
1068 1068
 	  * @param $data1
1069 1069
 	  * @return string
1070 1070
 	  */
1071
-	 private function find_serialize_error( $data1 ) {
1071
+	 private function find_serialize_error($data1) {
1072 1072
 		$error = '<pre>';
1073 1073
 		 $data2 = preg_replace_callback(
1074 1074
 			 '!s:(\d+):"(.*?)";!',
1075
-			 function ( $match ) {
1076
-				 return ( $match[1] === strlen( $match[2] ) )
1075
+			 function($match) {
1076
+				 return ($match[1] === strlen($match[2]))
1077 1077
 					 ? $match[0]
1078 1078
 					 : 's:'
1079
-					   . strlen( $match[2] )
1079
+					   . strlen($match[2])
1080 1080
 					   . ':"'
1081 1081
 					   . $match[2]
1082 1082
 					   . '";';
1083 1083
 			 },
1084 1084
 			 $data1
1085 1085
 		 );
1086
-		$max = ( strlen( $data1 ) > strlen( $data2 ) ) ? strlen( $data1 ) : strlen( $data2 );
1087
-		$error .= $data1 . PHP_EOL;
1088
-		$error .= $data2 . PHP_EOL;
1089
-		for ( $i = 0; $i < $max; $i++ ) {
1090
-			if ( @$data1[ $i ] !== @$data2[ $i ] ) {
1091
-				$error .= 'Difference ' . @$data1[ $i ] . ' != ' . @$data2[ $i ] . PHP_EOL;
1092
-				$error .= "\t-> ORD number " . ord( @$data1[ $i ] ) . ' != ' . ord( @$data2[ $i ] ) . PHP_EOL;
1093
-				$error .= "\t-> Line Number = $i" . PHP_EOL;
1094
-				$start = ( $i - 20 );
1095
-				$start = ( $start < 0 ) ? 0 : $start;
1086
+		$max = (strlen($data1) > strlen($data2)) ? strlen($data1) : strlen($data2);
1087
+		$error .= $data1.PHP_EOL;
1088
+		$error .= $data2.PHP_EOL;
1089
+		for ($i = 0; $i < $max; $i++) {
1090
+			if (@$data1[$i] !== @$data2[$i]) {
1091
+				$error .= 'Difference '.@$data1[$i].' != '.@$data2[$i].PHP_EOL;
1092
+				$error .= "\t-> ORD number ".ord(@$data1[$i]).' != '.ord(@$data2[$i]).PHP_EOL;
1093
+				$error .= "\t-> Line Number = $i".PHP_EOL;
1094
+				$start = ($i - 20);
1095
+				$start = ($start < 0) ? 0 : $start;
1096 1096
 				$length = 40;
1097 1097
 				$point = $max - $i;
1098
-				if ( $point < 20 ) {
1098
+				if ($point < 20) {
1099 1099
 					$rlength = 1;
1100 1100
 					$rpoint = -$point;
1101 1101
 				} else {
@@ -1104,16 +1104,16 @@  discard block
 block discarded – undo
1104 1104
 				}
1105 1105
 				$error .= "\t-> Section Data1  = ";
1106 1106
 				$error .= substr_replace(
1107
-					substr( $data1, $start, $length ),
1108
-					"<b style=\"color:green\">{$data1[ $i ]}</b>",
1107
+					substr($data1, $start, $length),
1108
+					"<b style=\"color:green\">{$data1[$i]}</b>",
1109 1109
 					$rpoint,
1110 1110
 					$rlength
1111 1111
 				);
1112 1112
 				$error .= PHP_EOL;
1113 1113
 				$error .= "\t-> Section Data2  = ";
1114 1114
 				$error .= substr_replace(
1115
-					substr( $data2, $start, $length ),
1116
-					"<b style=\"color:red\">{$data2[ $i ]}</b>",
1115
+					substr($data2, $start, $length),
1116
+					"<b style=\"color:red\">{$data2[$i]}</b>",
1117 1117
 					$rpoint,
1118 1118
 					$rlength
1119 1119
 				);
Please login to merge, or discard this patch.