Completed
Branch BUG-10057-catch-phpmailer-exce... (0561c4)
by
unknown
36:56 queued 18:00
created
core/exceptions/SendMessageException.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\exceptions;
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
 
@@ -15,5 +15,5 @@  discard block
 block discarded – undo
15 15
  * @author        Darren Ethier
16 16
  * @since         4.9.11.rc.001
17 17
  */
18
-class SendMessageException extends \RuntimeException  {}
18
+class SendMessageException extends \RuntimeException {}
19 19
 // End of file SendMessageException.php
20 20
\ No newline at end of file
Please login to merge, or discard this patch.
core/business/EE_Registration_Processor.class.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -3,8 +3,8 @@  discard block
 block discarded – undo
3 3
 use EventEspresso\core\domain\entities\RegUrlLink;
4 4
 use EventEspresso\core\domain\services\registration\CreateRegistrationService;
5 5
 
6
-if ( ! defined( 'EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
7
-EE_Registry::instance()->load_class( 'Processor_Base' );
6
+if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
7
+EE_Registry::instance()->load_class('Processor_Base');
8 8
 
9 9
 /**
10 10
  * Class EE_Registration_Processor
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 */
67 67
 	public static function instance() {
68 68
 		// check if class object is instantiated
69
-		if ( ! self::$_instance instanceof EE_Registration_Processor ) {
69
+		if ( ! self::$_instance instanceof EE_Registration_Processor) {
70 70
 			self::$_instance = new self();
71 71
 		}
72 72
 		return self::$_instance;
@@ -86,8 +86,8 @@  discard block
 block discarded – undo
86 86
 	 * @param int $REG_ID
87 87
 	 * @return string
88 88
 	 */
89
-	public function old_reg_status( $REG_ID ) {
90
-		return isset( $this->_old_reg_status[ $REG_ID ] ) ? $this->_old_reg_status[ $REG_ID ] : null;
89
+	public function old_reg_status($REG_ID) {
90
+		return isset($this->_old_reg_status[$REG_ID]) ? $this->_old_reg_status[$REG_ID] : null;
91 91
 	}
92 92
 
93 93
 
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 * @param int $REG_ID
97 97
 	 * @param string $old_reg_status
98 98
 	 */
99
-	public function set_old_reg_status( $REG_ID, $old_reg_status ) {
99
+	public function set_old_reg_status($REG_ID, $old_reg_status) {
100 100
 		// only set the first time
101
-		if ( ! isset( $this->_old_reg_status[ $REG_ID ] ) ) {
102
-			$this->_old_reg_status[ $REG_ID ] = $old_reg_status;
101
+		if ( ! isset($this->_old_reg_status[$REG_ID])) {
102
+			$this->_old_reg_status[$REG_ID] = $old_reg_status;
103 103
 		}
104 104
 	}
105 105
 
@@ -109,8 +109,8 @@  discard block
 block discarded – undo
109 109
 	 * @param int $REG_ID
110 110
 	 * @return string
111 111
 	 */
112
-	public function new_reg_status( $REG_ID ) {
113
-		return isset( $this->_new_reg_status[ $REG_ID ] ) ? $this->_new_reg_status[ $REG_ID ] : null;
112
+	public function new_reg_status($REG_ID) {
113
+		return isset($this->_new_reg_status[$REG_ID]) ? $this->_new_reg_status[$REG_ID] : null;
114 114
 	}
115 115
 
116 116
 
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 	 * @param int $REG_ID
120 120
 	 * @param string $new_reg_status
121 121
 	 */
122
-	public function set_new_reg_status( $REG_ID, $new_reg_status ) {
123
-		$this->_new_reg_status[ $REG_ID ] = $new_reg_status;
122
+	public function set_new_reg_status($REG_ID, $new_reg_status) {
123
+		$this->_new_reg_status[$REG_ID] = $new_reg_status;
124 124
 	}
125 125
 
126 126
 
@@ -131,8 +131,8 @@  discard block
 block discarded – undo
131 131
 	 * @param int $REG_ID
132 132
 	 * @return bool
133 133
 	 */
134
-	public function reg_status_updated( $REG_ID ) {
135
-		return $this->new_reg_status( $REG_ID ) !== $this->old_reg_status( $REG_ID ) ? true : false;
134
+	public function reg_status_updated($REG_ID) {
135
+		return $this->new_reg_status($REG_ID) !== $this->old_reg_status($REG_ID) ? true : false;
136 136
 	}
137 137
 
138 138
 
@@ -141,13 +141,13 @@  discard block
 block discarded – undo
141 141
 	 * @param \EE_Registration $registration
142 142
 	 * @throws \EE_Error
143 143
 	 */
144
-	public function update_registration_status_and_trigger_notifications( \EE_Registration $registration ) {
145
-		$this->toggle_incomplete_registration_status_to_default( $registration, false );
146
-		$this->toggle_registration_status_for_default_approved_events( $registration, false );
147
-		$this->toggle_registration_status_if_no_monies_owing( $registration, false );
144
+	public function update_registration_status_and_trigger_notifications(\EE_Registration $registration) {
145
+		$this->toggle_incomplete_registration_status_to_default($registration, false);
146
+		$this->toggle_registration_status_for_default_approved_events($registration, false);
147
+		$this->toggle_registration_status_if_no_monies_owing($registration, false);
148 148
 		$registration->save();
149 149
 		// trigger notifications
150
-		$this->trigger_registration_update_notifications( $registration );
150
+		$this->trigger_registration_update_notifications($registration);
151 151
 	}
152 152
 
153 153
 
@@ -162,18 +162,18 @@  discard block
 block discarded – undo
162 162
 	 * @return boolean
163 163
 	 * @throws \EE_Error
164 164
 	 */
165
-	public function manually_update_registration_status( EE_Registration $registration, $new_reg_status = '', $save = true ) {
165
+	public function manually_update_registration_status(EE_Registration $registration, $new_reg_status = '', $save = true) {
166 166
 		// set initial REG_Status
167
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
167
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
168 168
 		// set incoming REG_Status
169
-		$this->set_new_reg_status( $registration->ID(), $new_reg_status );
169
+		$this->set_new_reg_status($registration->ID(), $new_reg_status);
170 170
 		// toggle reg status but only if it has changed and the user can do so
171 171
 		if (
172
-			$this->reg_status_updated( $registration->ID() ) &&
173
-			EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registration', 'toggle_registration_status', $registration->ID() )
172
+			$this->reg_status_updated($registration->ID()) &&
173
+			EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'toggle_registration_status', $registration->ID())
174 174
 		) {
175 175
 			// change status to new value
176
-			if ( $registration->set_status( $this->new_reg_status( $registration->ID() ) ) && $save ) {
176
+			if ($registration->set_status($this->new_reg_status($registration->ID())) && $save) {
177 177
 				$registration->save();
178 178
 			}
179 179
 			return TRUE;
@@ -193,30 +193,30 @@  discard block
 block discarded – undo
193 193
 	 * @return void
194 194
 	 * @throws \EE_Error
195 195
 	 */
196
-	public function toggle_incomplete_registration_status_to_default( EE_Registration $registration, $save = TRUE ) {
196
+	public function toggle_incomplete_registration_status_to_default(EE_Registration $registration, $save = TRUE) {
197 197
 		$existing_reg_status = $registration->status_ID();
198 198
 		// set initial REG_Status
199
-		$this->set_old_reg_status( $registration->ID(), $existing_reg_status );
199
+		$this->set_old_reg_status($registration->ID(), $existing_reg_status);
200 200
 		// is the registration currently incomplete ?
201
-		if ( $registration->status_ID() === EEM_Registration::status_id_incomplete ) {
201
+		if ($registration->status_ID() === EEM_Registration::status_id_incomplete) {
202 202
 			// grab default reg status for the event, if set
203 203
 			$event_default_registration_status = $registration->event()->default_registration_status();
204 204
 			// if no default reg status is set for the event, then use the global value
205
-			$STS_ID = ! empty( $event_default_registration_status )
205
+			$STS_ID = ! empty($event_default_registration_status)
206 206
 				? $event_default_registration_status
207 207
 				: EE_Registry::instance()->CFG->registration->default_STS_ID;
208 208
 			// if the event default reg status is approved, then downgrade temporarily to payment pending to ensure that payments are triggered
209 209
 			$STS_ID = $STS_ID === EEM_Registration::status_id_approved ? EEM_Registration::status_id_pending_payment : $STS_ID;
210 210
 			// set incoming REG_Status
211
-			$this->set_new_reg_status( $registration->ID(), $STS_ID );
212
-			$registration->set_status( $STS_ID );
213
-			if ( $save ) {
211
+			$this->set_new_reg_status($registration->ID(), $STS_ID);
212
+			$registration->set_status($STS_ID);
213
+			if ($save) {
214 214
 				$registration->save();
215 215
 			}
216 216
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
217
-			if ( ! EE_Processor_Base::$IPN ) {
217
+			if ( ! EE_Processor_Base::$IPN) {
218 218
 				// otherwise, send out notifications
219
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
219
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
220 220
 			}
221 221
 			// DEBUG LOG
222 222
 			//$this->log(
@@ -241,10 +241,10 @@  discard block
 block discarded – undo
241 241
 	 * @return boolean
242 242
 	 * @throws \EE_Error
243 243
 	 */
244
-	public function toggle_registration_status_for_default_approved_events( EE_Registration $registration, $save = TRUE ) {
244
+	public function toggle_registration_status_for_default_approved_events(EE_Registration $registration, $save = TRUE) {
245 245
 		$reg_status = $registration->status_ID();
246 246
 		// set initial REG_Status
247
-		$this->set_old_reg_status( $registration->ID(), $reg_status );
247
+		$this->set_old_reg_status($registration->ID(), $reg_status);
248 248
 		// if not already, toggle reg status to approved IF the event default reg status is approved
249 249
 		// ( as long as the registration wasn't cancelled or declined at some point )
250 250
 		if (
@@ -254,16 +254,16 @@  discard block
 block discarded – undo
254 254
 			$registration->event()->default_registration_status() === EEM_Registration::status_id_approved
255 255
 		) {
256 256
 			// set incoming REG_Status
257
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
257
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
258 258
 			// toggle status to approved
259
-			$registration->set_status( EEM_Registration::status_id_approved );
260
-			if ( $save ) {
259
+			$registration->set_status(EEM_Registration::status_id_approved);
260
+			if ($save) {
261 261
 				$registration->save();
262 262
 			}
263 263
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
264
-			if ( ! EE_Processor_Base::$IPN ) {
264
+			if ( ! EE_Processor_Base::$IPN) {
265 265
 				// otherwise, send out notifications
266
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
266
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
267 267
 			}
268 268
 			// DEBUG LOG
269 269
 			//$this->log(
@@ -291,19 +291,19 @@  discard block
 block discarded – undo
291 291
 	 * @return bool
292 292
 	 * @throws \EE_Error
293 293
 	 */
294
-	public function toggle_registration_status_if_no_monies_owing( EE_Registration $registration, $save = TRUE, $additional_details = array() ) {
294
+	public function toggle_registration_status_if_no_monies_owing(EE_Registration $registration, $save = TRUE, $additional_details = array()) {
295 295
 		// set initial REG_Status
296
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
296
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
297 297
 		//EEH_Debug_Tools::printr( $additional_details, '$additional_details', __FILE__, __LINE__ );
298 298
 		// was a payment just made ?
299 299
 		if (
300
-			isset( $additional_details[ 'payment_updates' ], $additional_details[ 'last_payment' ] ) &&
301
-			$additional_details[ 'payment_updates' ] &&
302
-			$additional_details[ 'last_payment' ] instanceof EE_Payment
300
+			isset($additional_details['payment_updates'], $additional_details['last_payment']) &&
301
+			$additional_details['payment_updates'] &&
302
+			$additional_details['last_payment'] instanceof EE_Payment
303 303
 		) {
304
-			$payment = $additional_details[ 'last_payment' ];
304
+			$payment = $additional_details['last_payment'];
305 305
 			$total_paid = 0;
306
-			foreach ( self::$_amount_paid as $reg => $amount_paid ) {
306
+			foreach (self::$_amount_paid as $reg => $amount_paid) {
307 307
 				$total_paid += $amount_paid;
308 308
 			}
309 309
 		} else {
@@ -327,30 +327,30 @@  discard block
 block discarded – undo
327 327
 					$registration->transaction()->is_completed() ||
328 328
 					$registration->transaction()->is_overpaid() ||
329 329
 					$registration->transaction()->is_free() ||
330
-					apply_filters( 'FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration )
330
+					apply_filters('FHEE__EE_Registration_Processor__toggle_registration_status_if_no_monies_owing', false, $registration)
331 331
 				) || (
332 332
 					$payment instanceof EE_Payment &&
333 333
 					$payment->is_approved() &&
334 334
 					// this specific registration has not yet been paid for
335
-					! isset( self::$_amount_paid[ $registration->ID() ] ) &&
335
+					! isset(self::$_amount_paid[$registration->ID()]) &&
336 336
 					// payment amount, less what we have already attributed to other registrations, is greater than this reg's final price
337 337
 					$payment->amount() - $total_paid >= $registration->final_price()
338 338
 				)
339 339
 			)
340 340
 		) {
341 341
 			// mark as paid
342
-			self::$_amount_paid[ $registration->ID() ] = $registration->final_price();
342
+			self::$_amount_paid[$registration->ID()] = $registration->final_price();
343 343
 			// track new REG_Status
344
-			$this->set_new_reg_status( $registration->ID(), EEM_Registration::status_id_approved );
344
+			$this->set_new_reg_status($registration->ID(), EEM_Registration::status_id_approved);
345 345
 			// toggle status to approved
346
-			$registration->set_status( EEM_Registration::status_id_approved );
347
-			if ( $save ) {
346
+			$registration->set_status(EEM_Registration::status_id_approved);
347
+			if ($save) {
348 348
 				$registration->save();
349 349
 			}
350 350
 			// don't trigger notifications during IPNs because they will get triggered by EE_Payment_Processor
351
-			if ( ! EE_Processor_Base::$IPN ) {
351
+			if ( ! EE_Processor_Base::$IPN) {
352 352
 				// otherwise, send out notifications
353
-				add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10 );
353
+				add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_true', 10);
354 354
 			}
355 355
 			// DEBUG LOG
356 356
 			//$this->log(
@@ -376,27 +376,27 @@  discard block
 block discarded – undo
376 376
 	 * @param array 	$additional_details
377 377
 	 * @return void
378 378
 	 */
379
-	public function trigger_registration_update_notifications( $registration, $additional_details = array() ) {
379
+	public function trigger_registration_update_notifications($registration, $additional_details = array()) {
380 380
 		try {
381
-			if ( ! $registration instanceof EE_Registration ) {
382
-				throw new EE_Error( __( 'An invalid registration was received.', 'event_espresso' ) );
381
+			if ( ! $registration instanceof EE_Registration) {
382
+				throw new EE_Error(__('An invalid registration was received.', 'event_espresso'));
383 383
 			}
384
-			EE_Registry::instance()->load_helper( 'Debug_Tools' );
384
+			EE_Registry::instance()->load_helper('Debug_Tools');
385 385
 			EEH_Debug_Tools::log(
386 386
 				__CLASS__,
387 387
 				__FUNCTION__,
388 388
 				__LINE__,
389
-				array( $registration->transaction(), $additional_details ),
389
+				array($registration->transaction(), $additional_details),
390 390
 				false,
391
-				'EE_Transaction: ' . $registration->transaction()->ID()
391
+				'EE_Transaction: '.$registration->transaction()->ID()
392 392
 			);
393 393
 			do_action(
394 394
 				'AHEE__EE_Registration_Processor__trigger_registration_update_notifications',
395 395
 				$registration,
396 396
 				$additional_details
397 397
 			);
398
-		} catch( Exception $e ) {
399
-			EE_Error::add_error( $e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine() );
398
+		} catch (Exception $e) {
399
+			EE_Error::add_error($e->getMessage(), $e->getFile(), 'unknown_function_from_exception', $e->getLine());
400 400
 		}
401 401
 	}
402 402
 
@@ -410,22 +410,22 @@  discard block
 block discarded – undo
410 410
 	 * @return bool
411 411
 	 * @throws \EE_Error
412 412
 	 */
413
-	public function update_registration_after_checkout_or_payment(  EE_Registration $registration, $additional_details = array() ) {
413
+	public function update_registration_after_checkout_or_payment(EE_Registration $registration, $additional_details = array()) {
414 414
 		// set initial REG_Status
415
-		$this->set_old_reg_status( $registration->ID(), $registration->status_ID() );
415
+		$this->set_old_reg_status($registration->ID(), $registration->status_ID());
416 416
 
417 417
 		// if the registration status gets updated, then save the registration
418 418
 		if (
419
-			$this->toggle_registration_status_for_default_approved_events( $registration, false )
420
-			|| $this->toggle_registration_status_if_no_monies_owing( $registration, false, $additional_details )
419
+			$this->toggle_registration_status_for_default_approved_events($registration, false)
420
+			|| $this->toggle_registration_status_if_no_monies_owing($registration, false, $additional_details)
421 421
 		) {
422 422
 			$registration->save();
423 423
 		}
424 424
 
425 425
 		// set new  REG_Status
426
-		$this->set_new_reg_status( $registration->ID(), $registration->status_ID() );
427
-		return $this->reg_status_updated( $registration->ID() )
428
-		       && $this->new_reg_status( $registration->ID() ) === EEM_Registration::status_id_approved
426
+		$this->set_new_reg_status($registration->ID(), $registration->status_ID());
427
+		return $this->reg_status_updated($registration->ID())
428
+		       && $this->new_reg_status($registration->ID()) === EEM_Registration::status_id_approved
429 429
 			? true
430 430
 			: false;
431 431
 	}
@@ -441,20 +441,20 @@  discard block
 block discarded – undo
441 441
 	 * @return void
442 442
 	 * @throws \EE_Error
443 443
 	 */
444
-	public function update_registration_final_prices( $transaction, $save_regs = true ) {
445
-		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item( $transaction->total_line_item() );
446
-		foreach( $transaction->registrations() as $registration ) {
444
+	public function update_registration_final_prices($transaction, $save_regs = true) {
445
+		$reg_final_price_per_ticket_line_item = EEH_Line_Item::calculate_reg_final_prices_per_line_item($transaction->total_line_item());
446
+		foreach ($transaction->registrations() as $registration) {
447 447
 			/** @var EE_Line_Item $line_item */
448
-			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration( $registration );
449
-			if( isset( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] ) ) {
450
-				$registration->set_final_price( $reg_final_price_per_ticket_line_item[ $line_item->ID() ] );
451
-				if( $save_regs ) {
448
+			$line_item = EEM_Line_Item::instance()->get_line_item_for_registration($registration);
449
+			if (isset($reg_final_price_per_ticket_line_item[$line_item->ID()])) {
450
+				$registration->set_final_price($reg_final_price_per_ticket_line_item[$line_item->ID()]);
451
+				if ($save_regs) {
452 452
 					$registration->save();
453 453
 				}
454 454
 			}
455 455
 		}
456 456
 		//and make sure there's no rounding problem
457
-		$this->fix_reg_final_price_rounding_issue( $transaction );
457
+		$this->fix_reg_final_price_rounding_issue($transaction);
458 458
 	}
459 459
 
460 460
 
@@ -474,7 +474,7 @@  discard block
 block discarded – undo
474 474
 	 * @return boolean success verifying that there is NO difference after this method is done
475 475
 	 * @throws \EE_Error
476 476
 	 */
477
-	public function fix_reg_final_price_rounding_issue( $transaction ) {
477
+	public function fix_reg_final_price_rounding_issue($transaction) {
478 478
 		$reg_final_price_sum = EEM_Registration::instance()->sum(
479 479
 			array(
480 480
 				array(
@@ -483,9 +483,9 @@  discard block
 block discarded – undo
483 483
 			),
484 484
 			'REG_final_price'
485 485
 		);
486
-		$diff =  $transaction->total() - (float) $reg_final_price_sum;
486
+		$diff = $transaction->total() - (float) $reg_final_price_sum;
487 487
 		//ok then, just grab one of the registrations
488
-		if( $diff !== 0 ) {
488
+		if ($diff !== 0) {
489 489
 			$a_reg = EEM_Registration::instance()->get_one(
490 490
 					array(
491 491
 						array(
@@ -494,7 +494,7 @@  discard block
 block discarded – undo
494 494
 					));
495 495
 			$success = $a_reg instanceof EE_Registration
496 496
 				? $a_reg->save(
497
-					array( 'REG_final_price' => $a_reg->final_price() + $diff )
497
+					array('REG_final_price' => $a_reg->final_price() + $diff)
498 498
 				)
499 499
 				: false;
500 500
 			return $success ? true : false;
@@ -519,13 +519,13 @@  discard block
 block discarded – undo
519 519
 		$update_reg = true
520 520
 	) {
521 521
 		// these reg statuses should not be considered in any calculations involving monies owing
522
-		$closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses
522
+		$closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses
523 523
 			: EEM_Registration::closed_reg_statuses();
524
-		if ( ! in_array( $registration->status_ID(), $closed_reg_statuses ) ) {
524
+		if ( ! in_array($registration->status_ID(), $closed_reg_statuses)) {
525 525
 			return false;
526 526
 		}
527 527
 		$registration->set_final_price(0);
528
-		if ( $update_reg ) {
528
+		if ($update_reg) {
529 529
 			$registration->save();
530 530
 		}
531 531
 		return true;
@@ -548,23 +548,23 @@  discard block
 block discarded – undo
548 548
 		$update_reg = true
549 549
 	) {
550 550
 		// these reg statuses should not be considered in any calculations involving monies owing
551
-		$closed_reg_statuses = ! empty( $closed_reg_statuses ) ? $closed_reg_statuses
551
+		$closed_reg_statuses = ! empty($closed_reg_statuses) ? $closed_reg_statuses
552 552
 			: EEM_Registration::closed_reg_statuses();
553
-		if ( in_array( $registration->status_ID(), $closed_reg_statuses ) ) {
553
+		if (in_array($registration->status_ID(), $closed_reg_statuses)) {
554 554
 			return false;
555 555
 		}
556 556
 		$ticket = $registration->ticket();
557
-		if ( ! $ticket instanceof EE_Ticket ) {
557
+		if ( ! $ticket instanceof EE_Ticket) {
558 558
 			throw new EE_Error(
559 559
 				sprintf(
560
-					__( 'The Ticket for Registration %1$d was not found or is invalid.',
561
-						'event_espresso' ),
560
+					__('The Ticket for Registration %1$d was not found or is invalid.',
561
+						'event_espresso'),
562 562
 					$registration->ticket_ID()
563 563
 				)
564 564
 			);
565 565
 		}
566
-		$registration->set_final_price( $ticket->price() );
567
-		if ( $update_reg ) {
566
+		$registration->set_final_price($ticket->price());
567
+		if ($update_reg) {
568 568
 			$registration->save();
569 569
 		}
570 570
 		return true;
@@ -602,7 +602,7 @@  discard block
 block discarded – undo
602 602
 		$total_ticket_count = 1
603 603
 	) {
604 604
 		EE_Error::doing_it_wrong(
605
-			__CLASS__ . '::' . __FUNCTION__,
605
+			__CLASS__.'::'.__FUNCTION__,
606 606
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
607 607
 				'\EventEspresso\core\domain\services\registration\CreateRegistrationService::create()'),
608 608
 			'4.9.1',
@@ -645,7 +645,7 @@  discard block
 block discarded – undo
645 645
 	public function generate_reg_url_link($att_nmbr, $item)
646 646
 	{
647 647
 		EE_Error::doing_it_wrong(
648
-			__CLASS__ . '::' . __FUNCTION__,
648
+			__CLASS__.'::'.__FUNCTION__,
649 649
 			sprintf(__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
650 650
 				'EventEspresso\core\domain\entities\RegUrlLink'),
651 651
 			'4.9.1',
@@ -665,11 +665,11 @@  discard block
 block discarded – undo
665 665
 	 * @return string
666 666
 	 * @throws \EE_Error
667 667
 	 */
668
-	public function generate_reg_code( EE_Registration $registration ) {
668
+	public function generate_reg_code(EE_Registration $registration) {
669 669
 		EE_Error::doing_it_wrong(
670
-			__CLASS__ . '::' . __FUNCTION__,
670
+			__CLASS__.'::'.__FUNCTION__,
671 671
 			sprintf(
672
-				__( 'This method is deprecated. Please use "%s" instead', 'event_espresso' ),
672
+				__('This method is deprecated. Please use "%s" instead', 'event_espresso'),
673 673
 				'EventEspresso\core\domain\entities\RegCode'
674 674
 			),
675 675
 			'4.9.1',
@@ -678,7 +678,7 @@  discard block
 block discarded – undo
678 678
 		return apply_filters(
679 679
 			'FHEE__EE_Registration_Processor___generate_reg_code__new_reg_code',
680 680
 			new RegCode(
681
-				RegUrlLink::fromRegistration( $registration ),
681
+				RegUrlLink::fromRegistration($registration),
682 682
 				$registration->transaction(),
683 683
 				$registration->ticket()
684 684
 			),
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Queue.lib.php 1 patch
Spacing   +102 added lines, -102 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use \EventEspresso\core\exceptions\SendMessageException;
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
 /**
@@ -76,8 +76,8 @@  discard block
 block discarded – undo
76 76
 	 *
77 77
 	 * @param \EE_Message_Repository       $message_repository
78 78
 	 */
79
-	public function __construct( EE_Message_Repository $message_repository ) {
80
-		$this->_batch_count        = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 );
79
+	public function __construct(EE_Message_Repository $message_repository) {
80
+		$this->_batch_count        = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50);
81 81
 		$this->_rate_limit         = $this->get_rate_limit();
82 82
 		$this->_message_repository = $message_repository;
83 83
 	}
@@ -96,10 +96,10 @@  discard block
 block discarded – undo
96 96
 	 *                                 use the messenger send method but typically is based on preview data.
97 97
 	 * @return bool          Whether the message was successfully added to the repository or not.
98 98
 	 */
99
-	public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) {
99
+	public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) {
100 100
 		$data['preview'] = $preview;
101 101
 		$data['test_send'] = $test_send;
102
-		return $this->_message_repository->add( $message, $data );
102
+		return $this->_message_repository->add($message, $data);
103 103
 	}
104 104
 
105 105
 
@@ -111,13 +111,13 @@  discard block
 block discarded – undo
111 111
 	 * @param bool          $persist    This flag indicates whether to attempt to delete the object from the db as well.
112 112
 	 * @return bool
113 113
 	 */
114
-	public function remove( EE_Message $message, $persist = false ) {
115
-		if ( $persist && $this->_message_repository->current() !== $message ) {
114
+	public function remove(EE_Message $message, $persist = false) {
115
+		if ($persist && $this->_message_repository->current() !== $message) {
116 116
 			//get pointer on right message
117
-			if ( $this->_message_repository->has( $message ) ) {
117
+			if ($this->_message_repository->has($message)) {
118 118
 				$this->_message_repository->rewind();
119
-				while( $this->_message_repository->valid() ) {
120
-					if ( $this->_message_repository->current() === $message ) {
119
+				while ($this->_message_repository->valid()) {
120
+					if ($this->_message_repository->current() === $message) {
121 121
 						break;
122 122
 					}
123 123
 					$this->_message_repository->next();
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 				return false;
127 127
 			}
128 128
 		}
129
-		return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message );
129
+		return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message);
130 130
 	}
131 131
 
132 132
 
@@ -166,29 +166,29 @@  discard block
 block discarded – undo
166 166
 	 * @return bool  true if successfully retrieved batch, false no batch ready.
167 167
 	 */
168 168
 	public function get_batch_to_generate() {
169
-		if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) {
169
+		if ($this->is_locked(EE_Messages_Queue::action_generating)) {
170 170
 			return false;
171 171
 		}
172 172
 
173 173
 		//lock batch generation to prevent race conditions.
174
-		$this->lock_queue( EE_Messages_Queue::action_generating );
174
+		$this->lock_queue(EE_Messages_Queue::action_generating);
175 175
 
176 176
 		$query_args = array(
177 177
 			// key 0 = where conditions
178
-			0 => array( 'STS_ID' => EEM_Message::status_incomplete ),
178
+			0 => array('STS_ID' => EEM_Message::status_incomplete),
179 179
 			'order_by' => $this->_get_priority_orderby(),
180 180
 			'limit' => $this->_batch_count
181 181
 		);
182
-		$messages = EEM_Message::instance()->get_all( $query_args );
182
+		$messages = EEM_Message::instance()->get_all($query_args);
183 183
 
184
-		if ( ! $messages ) {
184
+		if ( ! $messages) {
185 185
 			return false; //nothing to generate
186 186
 		}
187 187
 
188
-		foreach ( $messages as $message ) {
189
-			if ( $message instanceof EE_Message ) {
188
+		foreach ($messages as $message) {
189
+			if ($message instanceof EE_Message) {
190 190
 				$data = $message->all_extra_meta_array();
191
-				$this->add( $message, $data );
191
+				$this->add($message, $data);
192 192
 			}
193 193
 		}
194 194
 		return true;
@@ -211,34 +211,34 @@  discard block
 block discarded – undo
211 211
 	 *               to assist with notifying user.
212 212
 	 */
213 213
 	public function get_to_send_batch_and_send() {
214
-		if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) {
214
+		if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) {
215 215
 			return false;
216 216
 		}
217 217
 
218
-		$this->lock_queue( EE_Messages_Queue::action_sending );
218
+		$this->lock_queue(EE_Messages_Queue::action_sending);
219 219
 
220 220
 		$batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit;
221 221
 
222 222
 		$query_args = array(
223 223
 			// key 0 = where conditions
224
-			0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ),
224
+			0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())),
225 225
 			'order_by' => $this->_get_priority_orderby(),
226 226
 			'limit' => $batch
227 227
 		);
228 228
 
229
-		$messages_to_send = EEM_Message::instance()->get_all( $query_args );
229
+		$messages_to_send = EEM_Message::instance()->get_all($query_args);
230 230
 
231 231
 
232 232
 		//any to send?
233
-		if ( ! $messages_to_send ) {
234
-			$this->unlock_queue( EE_Messages_Queue::action_sending );
233
+		if ( ! $messages_to_send) {
234
+			$this->unlock_queue(EE_Messages_Queue::action_sending);
235 235
 			return false;
236 236
 		}
237 237
 
238 238
 		//add to queue.
239
-		foreach ( $messages_to_send as $message ) {
240
-			if ( $message instanceof EE_Message ) {
241
-				$this->add( $message );
239
+		foreach ($messages_to_send as $message) {
240
+			if ($message instanceof EE_Message) {
241
+				$this->add($message);
242 242
 			}
243 243
 		}
244 244
 
@@ -246,7 +246,7 @@  discard block
 block discarded – undo
246 246
 		$this->execute();
247 247
 
248 248
 		//release lock
249
-		$this->unlock_queue( EE_Messages_Queue::action_sending );
249
+		$this->unlock_queue(EE_Messages_Queue::action_sending);
250 250
 		return true;
251 251
 	}
252 252
 
@@ -258,8 +258,8 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @param   string  $type   The type of queue being locked.
260 260
 	 */
261
-	public function lock_queue( $type = EE_Messages_Queue::action_generating ) {
262
-		set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) );
261
+	public function lock_queue($type = EE_Messages_Queue::action_generating) {
262
+		set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type));
263 263
 	}
264 264
 
265 265
 
@@ -270,8 +270,8 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @param   string  $type   The type of queue being unlocked.
272 272
 	 */
273
-	public function unlock_queue( $type = EE_Messages_Queue::action_generating ) {
274
-		delete_transient( $this->_get_lock_key( $type ) );
273
+	public function unlock_queue($type = EE_Messages_Queue::action_generating) {
274
+		delete_transient($this->_get_lock_key($type));
275 275
 	}
276 276
 
277 277
 
@@ -282,8 +282,8 @@  discard block
 block discarded – undo
282 282
 	 * @param string $type  The type of lock.
283 283
 	 * @return string
284 284
 	 */
285
-	protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) {
286
-		return '_ee_lock_' . $type;
285
+	protected function _get_lock_key($type = EE_Messages_Queue::action_generating) {
286
+		return '_ee_lock_'.$type;
287 287
 	}
288 288
 
289 289
 
@@ -294,8 +294,8 @@  discard block
 block discarded – undo
294 294
 	 * @param string $type  The type of lock
295 295
 	 * @return int   time to expiry in seconds.
296 296
 	 */
297
-	protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) {
298
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type );
297
+	protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) {
298
+		return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type);
299 299
 	}
300 300
 
301 301
 
@@ -313,7 +313,7 @@  discard block
 block discarded – undo
313 313
 	 * @return int
314 314
 	 */
315 315
 	protected function _get_rate_limit_expiry() {
316
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS );
316
+		return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS);
317 317
 	}
318 318
 
319 319
 
@@ -324,7 +324,7 @@  discard block
 block discarded – undo
324 324
 	 * @return int
325 325
 	 */
326 326
 	protected function _default_rate_limit() {
327
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 );
327
+		return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200);
328 328
 	}
329 329
 
330 330
 
@@ -350,14 +350,14 @@  discard block
 block discarded – undo
350 350
 	 * @param  string $type The type of lock being checked for.
351 351
 	 * @return bool
352 352
 	 */
353
-	public function is_locked( $type = EE_Messages_Queue::action_generating ) {
353
+	public function is_locked($type = EE_Messages_Queue::action_generating) {
354 354
 		/**
355 355
 		 * This filters the default is_locked behaviour.
356 356
 		 */
357 357
 		$is_locked = filter_var(
358 358
 			apply_filters(
359 359
 				'FHEE__EE_Messages_Queue__is_locked',
360
-				get_transient( $this->_get_lock_key( $type ) ),
360
+				get_transient($this->_get_lock_key($type)),
361 361
 				$this
362 362
 			),
363 363
 			FILTER_VALIDATE_BOOLEAN
@@ -368,7 +368,7 @@  discard block
 block discarded – undo
368 368
 		 *            Also implemented here because messages processed on the same request should not have any locks applied.
369 369
 		 */
370 370
 		if (
371
-			apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false )
371
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
372 372
 			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
373 373
 		) {
374 374
 			$is_locked = false;
@@ -390,9 +390,9 @@  discard block
 block discarded – undo
390 390
 	 * @return int
391 391
 	 */
392 392
 	public function get_rate_limit() {
393
-		if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) {
393
+		if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) {
394 394
 			$rate_limit = $this->_default_rate_limit();
395
-			set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() );
395
+			set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key());
396 396
 		}
397 397
 		return $rate_limit;
398 398
 	}
@@ -404,12 +404,12 @@  discard block
 block discarded – undo
404 404
 	 * This updates existing rate limit with the new limit which is the old minus the batch.
405 405
 	 * @param int $batch_completed  This sets the new rate limit based on the given batch that was completed.
406 406
 	 */
407
-	public function set_rate_limit( $batch_completed ) {
407
+	public function set_rate_limit($batch_completed) {
408 408
 		//first get the most up to date rate limit (in case its expired and reset)
409 409
 		$rate_limit = $this->get_rate_limit();
410 410
 		$new_limit = $rate_limit - $batch_completed;
411 411
 		//updating the transient option directly to avoid resetting the expiry.
412
-		update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit );
412
+		update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit);
413 413
 	}
414 414
 
415 415
 
@@ -422,7 +422,7 @@  discard block
 block discarded – undo
422 422
 	 * @param string $task This indicates what type of request is going to be initiated.
423 423
 	 * @param int    $priority  This indicates the priority that triggers initiating the request.
424 424
 	 */
425
-	public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) {
425
+	public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) {
426 426
 		//determine what status is matched with the priority as part of the trigger conditions.
427 427
 		$status = $task == 'generate'
428 428
 			? EEM_Message::status_incomplete
@@ -442,19 +442,19 @@  discard block
 block discarded – undo
442 442
 		 *   the same request.
443 443
 		 */
444 444
 		if (
445
-			apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false )
445
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
446 446
 			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
447 447
 		) {
448
-			$messages_processor = EE_Registry::instance()->load_lib( 'Messages_Processor' );
449
-			if ( $messages_processor instanceof EE_Messages_Processor ) {
450
-				return $messages_processor->process_immediately_from_queue( $this );
448
+			$messages_processor = EE_Registry::instance()->load_lib('Messages_Processor');
449
+			if ($messages_processor instanceof EE_Messages_Processor) {
450
+				return $messages_processor->process_immediately_from_queue($this);
451 451
 			}
452 452
 			//if we get here then that means the messages processor couldn't be loaded so messages will just remain
453 453
 			//queued for manual triggering by end user.
454 454
 		}
455 455
 
456
-		if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) {
457
-			EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task );
456
+		if ($this->_message_repository->count_by_priority_and_status($priority, $status)) {
457
+			EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task);
458 458
 		}
459 459
 	}
460 460
 
@@ -479,53 +479,53 @@  discard block
 block discarded – undo
479 479
 	 *                    Also, if the messenger is an request type messenger (or a preview),
480 480
 	 * 					  its entirely possible that the messenger will exit before
481 481
 	 */
482
-	public function execute( $save = true, $sending_messenger = null, $by_priority = false ) {
482
+	public function execute($save = true, $sending_messenger = null, $by_priority = false) {
483 483
 		$messages_sent = 0;
484 484
 		$this->_did_hook = array();
485 485
 		$this->_message_repository->rewind();
486 486
 
487
-		while ( $this->_message_repository->valid() ) {
487
+		while ($this->_message_repository->valid()) {
488 488
 			$error_messages = array();
489 489
 			/** @type EE_Message $message */
490 490
 			$message = $this->_message_repository->current();
491 491
 			//only process things that are queued for sending
492
-			if ( ! in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) {
492
+			if ( ! in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) {
493 493
 				$this->_message_repository->next();
494 494
 				continue;
495 495
 			}
496 496
 			//if $by_priority is set and does not match then continue;
497
-			if ( $by_priority && $by_priority != $message->priority() ) {
497
+			if ($by_priority && $by_priority != $message->priority()) {
498 498
 				$this->_message_repository->next();
499 499
 				continue;
500 500
 			}
501 501
 			//error checking
502
-			if ( ! $message->valid_messenger() ) {
502
+			if ( ! $message->valid_messenger()) {
503 503
 				$error_messages[] = sprintf(
504
-					__( 'The %s messenger is not active at time of sending.', 'event_espresso' ),
504
+					__('The %s messenger is not active at time of sending.', 'event_espresso'),
505 505
 					$message->messenger()
506 506
 				);
507 507
 			}
508
-			if ( ! $message->valid_message_type() ) {
508
+			if ( ! $message->valid_message_type()) {
509 509
 				$error_messages[] = sprintf(
510
-					__( 'The %s message type is not active at the time of sending.', 'event_espresso' ),
510
+					__('The %s message type is not active at the time of sending.', 'event_espresso'),
511 511
 					$message->message_type()
512 512
 				);
513 513
 			}
514 514
 			// if there was supposed to be a sending messenger for this message, but it was invalid/inactive,
515 515
 			// then it will instead be an EE_Error object, so let's check for that
516
-			if ( $sending_messenger instanceof EE_Error ) {
516
+			if ($sending_messenger instanceof EE_Error) {
517 517
 				$error_messages[] = $sending_messenger->getMessage();
518 518
 			}
519 519
 			// if there are no errors, then let's process the message
520
-			if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) {
520
+			if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) {
521 521
 				$messages_sent++;
522 522
 			}
523
-			$this->_set_error_message( $message, $error_messages );
523
+			$this->_set_error_message($message, $error_messages);
524 524
 			//add modified time
525
-			$message->set_modified( time() );
525
+			$message->set_modified(time());
526 526
 			$this->_message_repository->next();
527 527
 		}
528
-		if ( $save ) {
528
+		if ($save) {
529 529
 			$this->save();
530 530
 		}
531 531
 		return $messages_sent;
@@ -540,7 +540,7 @@  discard block
 block discarded – undo
540 540
 	 * @param mixed 	 $sending_messenger (optional)
541 541
 	 * @return bool
542 542
 	 */
543
-	protected function _process_message( EE_Message $message, $sending_messenger = null ) {
543
+	protected function _process_message(EE_Message $message, $sending_messenger = null) {
544 544
 		// these *should* have been validated in the execute() method above
545 545
 		$messenger = $message->messenger_object();
546 546
 		$message_type = $message->message_type_object();
@@ -550,20 +550,20 @@  discard block
 block discarded – undo
550 550
 			&& $messenger instanceof EE_messenger
551 551
 			&& $sending_messenger->name != $messenger->name
552 552
 		) {
553
-			$messenger->do_secondary_messenger_hooks( $sending_messenger->name );
553
+			$messenger->do_secondary_messenger_hooks($sending_messenger->name);
554 554
 			$messenger = $sending_messenger;
555 555
 		}
556 556
 		// send using messenger, but double check objects
557
-		if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) {
557
+		if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) {
558 558
 			//set hook for message type (but only if not using another messenger to send).
559
-			if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) {
560
-				$message_type->do_messenger_hooks( $messenger );
561
-				$this->_did_hook[ $message_type->name ] = 1;
559
+			if ( ! isset($this->_did_hook[$message_type->name])) {
560
+				$message_type->do_messenger_hooks($messenger);
561
+				$this->_did_hook[$message_type->name] = 1;
562 562
 			}
563 563
 			//if preview then use preview method
564 564
 			return $this->_message_repository->is_preview()
565
-				? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() )
566
-				: $this->_do_send( $message, $messenger, $message_type );
565
+				? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send())
566
+				: $this->_do_send($message, $messenger, $message_type);
567 567
 		}
568 568
 		return false;
569 569
 	}
@@ -581,12 +581,12 @@  discard block
 block discarded – undo
581 581
 	 * @param array $status  Stati to check for in queue
582 582
 	 * @return int  Count of EE_Message's matching the given status.
583 583
 	 */
584
-	public function count_STS_in_queue( $status ) {
584
+	public function count_STS_in_queue($status) {
585 585
 		$count = 0;
586
-		$status = is_array( $status ) ? $status : array( $status );
586
+		$status = is_array($status) ? $status : array($status);
587 587
 		$this->_message_repository->rewind();
588
-		foreach( $this->_message_repository as $message ) {
589
-			if ( in_array( $message->STS_ID(), $status ) ) {
588
+		foreach ($this->_message_repository as $message) {
589
+			if (in_array($message->STS_ID(), $status)) {
590 590
 				$count++;
591 591
 			}
592 592
 		}
@@ -603,15 +603,15 @@  discard block
 block discarded – undo
603 603
 	 * @param $test_send
604 604
 	 * @return bool   true means all went well, false means, not so much.
605 605
 	 */
606
-	protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) {
607
-		if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) {
608
-			if ( ! $test_send ) {
609
-				$message->set_content( $preview );
606
+	protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) {
607
+		if ($preview = $messenger->get_preview($message, $message_type, $test_send)) {
608
+			if ( ! $test_send) {
609
+				$message->set_content($preview);
610 610
 			}
611
-			$message->set_STS_ID( EEM_Message::status_sent );
611
+			$message->set_STS_ID(EEM_Message::status_sent);
612 612
 			return true;
613 613
 		} else {
614
-			$message->set_STS_ID( EEM_Message::status_failed );
614
+			$message->set_STS_ID(EEM_Message::status_failed);
615 615
 			return false;
616 616
 		}
617 617
 	}
@@ -633,18 +633,18 @@  discard block
 block discarded – undo
633 633
 	 *
634 634
 	 * @return bool true means all went well, false means, not so much.
635 635
 	 */
636
-	protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) {
636
+	protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) {
637 637
 		try {
638
-			if ( $messenger->send_message( $message, $message_type ) ) {
639
-				$message->set_STS_ID( EEM_Message::status_sent );
638
+			if ($messenger->send_message($message, $message_type)) {
639
+				$message->set_STS_ID(EEM_Message::status_sent);
640 640
 				return true;
641 641
 			} else {
642
-				$message->set_STS_ID( EEM_Message::status_retry );
642
+				$message->set_STS_ID(EEM_Message::status_retry);
643 643
 				return false;
644 644
 			}
645
-		} catch( SendMessageException $e ) {
646
-			$message->set_STS_ID( EEM_Message::status_failed );
647
-			$message->set_error_message( $e->getMessage() );
645
+		} catch (SendMessageException $e) {
646
+			$message->set_STS_ID(EEM_Message::status_failed);
647
+			$message->set_error_message($e->getMessage());
648 648
 			return false;
649 649
 		}
650 650
 	}
@@ -658,21 +658,21 @@  discard block
 block discarded – undo
658 658
 	 * @param EE_Message $message
659 659
 	 * @param array      $error_messages the response from the messenger.
660 660
 	 */
661
-	protected function _set_error_message( EE_Message $message, $error_messages ) {
661
+	protected function _set_error_message(EE_Message $message, $error_messages) {
662 662
 		$error_messages = (array) $error_messages;
663
-		if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) {
663
+		if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) {
664 664
 			$notices = EE_Error::has_notices();
665
-			$error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' );
666
-			if ( $notices === 1 ) {
665
+			$error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso');
666
+			if ($notices === 1) {
667 667
 				$notices = EE_Error::get_vanilla_notices();
668
-				$notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array();
669
-				$error_messages[] = implode( "\n", $notices['errors'] );
668
+				$notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array();
669
+				$error_messages[] = implode("\n", $notices['errors']);
670 670
 			}
671 671
 		}
672
-		if ( count( $error_messages ) > 0 ) {
673
-			$msg = __( 'Message was not executed successfully.', 'event_espresso' );
674
-			$msg = $msg . "\n" . implode( "\n", $error_messages );
675
-			$message->set_error_message( $msg );
672
+		if (count($error_messages) > 0) {
673
+			$msg = __('Message was not executed successfully.', 'event_espresso');
674
+			$msg = $msg."\n".implode("\n", $error_messages);
675
+			$message->set_error_message($msg);
676 676
 		}
677 677
 	}
678 678
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_messenger.lib.php 1 patch
Spacing   +101 added lines, -101 removed lines patch added patch discarded remove patch
@@ -1,7 +1,7 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use \EventEspresso\core\exceptions\SendMessageException;
3 3
 
4
-if (!defined('EVENT_ESPRESSO_VERSION') )
4
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
5 5
 	exit('NO direct script access allowed');
6 6
 
7 7
 /**
@@ -279,7 +279,7 @@  discard block
 block discarded – undo
279 279
 	 * @return void
280 280
 	 */
281 281
 	public function enqueue_scripts_styles() {
282
-		do_action( 'AHEE__EE_messenger__enqueue_scripts_styles');
282
+		do_action('AHEE__EE_messenger__enqueue_scripts_styles');
283 283
 	}
284 284
 
285 285
 
@@ -349,7 +349,7 @@  discard block
 block discarded – undo
349 349
 
350 350
 		$this->_supports_labels->template_variation_description = __('These are different styles to choose from for the selected template structure.  Usually these affect things like font style, color, borders etc.  In some cases the styles will also make minor layout changes.');
351 351
 
352
-		$this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this );
352
+		$this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this);
353 353
 	}
354 354
 
355 355
 
@@ -364,10 +364,10 @@  discard block
 block discarded – undo
364 364
 	 * @return stdClass
365 365
 	 */
366 366
 	public function get_supports_labels() {
367
-		if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) {
367
+		if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) {
368 368
 			$this->_set_supports_labels_defaults();
369 369
 		}
370
-		return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this );
370
+		return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this);
371 371
 	}
372 372
 
373 373
 
@@ -387,10 +387,10 @@  discard block
 block discarded – undo
387 387
 	 *
388 388
 	 * @return string                    path or url for the requested variation.
389 389
 	 */
390
-	public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) {
390
+	public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) {
391 391
 		$this->_tmp_pack = $pack;
392
-		$variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters );
393
-		$variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path;
392
+		$variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters);
393
+		$variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path;
394 394
 		return $variation_path;
395 395
 
396 396
 	}
@@ -408,13 +408,13 @@  discard block
 block discarded – undo
408 408
 	 * @return array
409 409
 	 */
410 410
 	public function get_default_message_types() {
411
-		$class = get_class( $this );
411
+		$class = get_class($this);
412 412
 
413 413
 		//messenger specific filter
414
-		$default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this );
414
+		$default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this);
415 415
 
416 416
 		//all messengers filter
417
-		$default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this );
417
+		$default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
418 418
 		return $default_types;
419 419
 	}
420 420
 
@@ -429,14 +429,14 @@  discard block
 block discarded – undo
429 429
 	 * @return array
430 430
 	 */
431 431
 	public function get_valid_message_types() {
432
-		$class = get_class( $this );
432
+		$class = get_class($this);
433 433
 
434 434
 		//messenger specific filter
435 435
 		//messenger specific filter
436
-		$valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this );
436
+		$valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
437 437
 
438 438
 		//all messengers filter
439
-		$valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this );
439
+		$valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
440 440
 		return $valid_types;
441 441
 	}
442 442
 
@@ -450,7 +450,7 @@  discard block
 block discarded – undo
450 450
 	 * @access public
451 451
 	 * @param array $new_config Whatever is put in here will reset the _validator_config property
452 452
 	 */
453
-	public function set_validator_config( $new_config ) {
453
+	public function set_validator_config($new_config) {
454 454
 		$this->_validator_config = $new_config;
455 455
 	}
456 456
 
@@ -466,8 +466,8 @@  discard block
 block discarded – undo
466 466
 	public function get_validator_config() {
467 467
 		$class = get_class($this);
468 468
 
469
-		$config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this );
470
-		$config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this );
469
+		$config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this);
470
+		$config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
471 471
 		return $config;
472 472
 	}
473 473
 
@@ -484,8 +484,8 @@  discard block
 block discarded – undo
484 484
 	 * @access public
485 485
 	 * @return string content for page
486 486
 	 */
487
-	public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) {
488
-		return $this->_get_admin_page_content( $page, $action, $extra, $message_types );
487
+	public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) {
488
+		return $this->_get_admin_page_content($page, $action, $extra, $message_types);
489 489
 	}
490 490
 
491 491
 
@@ -495,20 +495,20 @@  discard block
 block discarded – undo
495 495
 	 * @param array $extra
496 496
 	 * @return mixed|string
497 497
 	 */
498
-	protected function _get_admin_content_events_edit( $message_types, $extra ) {
498
+	protected function _get_admin_content_events_edit($message_types, $extra) {
499 499
 		//defaults
500 500
 		$template_args = array();
501 501
 		$selector_rows = '';
502 502
 
503 503
 		//we don't need message types here so we're just going to ignore. we do, however, expect the event id here. The event id is needed to provide a link to setup a custom template for this event.
504
-		$event_id = isset( $extra['event'] ) ? $extra['event'] : NULL;
504
+		$event_id = isset($extra['event']) ? $extra['event'] : NULL;
505 505
 
506
-		$template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
507
-		$template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
506
+		$template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
507
+		$template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php';
508 508
 
509 509
 		//array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
510 510
 		$global_templates = EEM_Message_Template_Group::instance()->get_all(
511
-			array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
511
+			array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true))
512 512
 		);
513 513
 		$templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
514 514
 			$event_id,
@@ -517,55 +517,55 @@  discard block
 block discarded – undo
517 517
 				'MTP_is_active' => true
518 518
 			)
519 519
 		);
520
-		$templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array();
520
+		$templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array();
521 521
 
522 522
 		//so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
523
-		foreach ( $global_templates as $mtpgID => $mtpg ) {
524
-			if ( $mtpg instanceof EE_Message_Template_Group ) {
523
+		foreach ($global_templates as $mtpgID => $mtpg) {
524
+			if ($mtpg instanceof EE_Message_Template_Group) {
525 525
 				//verify this message type is supposed to show on this page
526 526
 				$mtp_obj = $mtpg->message_type_obj();
527
-				if ( ! $mtp_obj instanceof EE_message_type ) {
527
+				if ( ! $mtp_obj instanceof EE_message_type) {
528 528
 					continue;
529 529
 				}
530
-				$mtp_obj->admin_registered_pages = (array)$mtp_obj->admin_registered_pages;
531
-				if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) {
530
+				$mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
531
+				if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
532 532
 					continue;
533 533
 				}
534 534
 				$select_values = array();
535
-				$select_values[ $mtpgID ] = __( 'Global', 'event_espresso' );
536
-				$default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get( 'MTP_is_override' ) ? $mtpgID : null;
535
+				$select_values[$mtpgID] = __('Global', 'event_espresso');
536
+				$default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
537 537
 				//if the override has been set for the global template, then that means even if there are custom templates already created we ignore them because of the set override.
538
-				if ( ! $mtpg->get( 'MTP_is_override' ) ) {
538
+				if ( ! $mtpg->get('MTP_is_override')) {
539 539
 					//any custom templates for this message type?
540
-					$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() );
541
-					foreach ( $custom_templates as $cmtpgID => $cmtpg ) {
542
-						$select_values[ $cmtpgID ] = $cmtpg->name();
543
-						$default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value;
540
+					$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
541
+					foreach ($custom_templates as $cmtpgID => $cmtpg) {
542
+						$select_values[$cmtpgID] = $cmtpg->name();
543
+						$default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
544 544
 					}
545 545
 				}
546 546
 				//if there is no $default_value then we set it as the global
547
-				$default_value = empty( $default_value ) ? $mtpgID : $default_value;
548
-				$edit_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value ), admin_url( 'admin.php' ) );
549
-				$create_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value ), admin_url( 'admin.php' ) );
550
-				$st_args[ 'mt_name' ] = ucwords( $mtp_obj->label[ 'singular' ] );
551
-				$st_args[ 'mt_slug' ] = $mtpg->message_type();
552
-				$st_args[ 'messenger_slug' ] = $this->name;
553
-				$st_args[ 'selector' ] = EEH_Form_Fields::select_input( 'event_message_templates_relation[' . $mtpgID . ']', $select_values, $default_value, 'data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '"', 'message-template-selector' );
547
+				$default_value = empty($default_value) ? $mtpgID : $default_value;
548
+				$edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php'));
549
+				$create_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'add_new_message_template', 'GRP_ID' => $default_value), admin_url('admin.php'));
550
+				$st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
551
+				$st_args['mt_slug'] = $mtpg->message_type();
552
+				$st_args['messenger_slug'] = $this->name;
553
+				$st_args['selector'] = EEH_Form_Fields::select_input('event_message_templates_relation['.$mtpgID.']', $select_values, $default_value, 'data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'"', 'message-template-selector');
554 554
 				//note that  message template group that has override_all_custom set will remove the ability to set a custom message template based off of the global (and that also in turn overrides any other custom templates).
555
-				$st_args[ 'create_button' ] = $mtpg->get( 'MTP_is_override' ) ? '' : '<a data-messenger="' . $this->name . '" data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $create_url . '" class="button button-small create-mtpg-button">' . __( 'Create New Custom', 'event_espresso' ) . '</a>';
556
-				$st_args[ 'create_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ? $st_args[ 'create_button' ] : '';
557
-				$st_args[ 'edit_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID ) ? '<a data-messagetype="' . $mtpg->message_type() . '" data-grpid="' . $default_value . '" target="_blank" href="' . $edit_url . '" class="button button-small edit-mtpg-button">' . __( 'Edit', 'event_espresso' ) . '</a>' : '';
558
-				$selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, true );
555
+				$st_args['create_button'] = $mtpg->get('MTP_is_override') ? '' : '<a data-messenger="'.$this->name.'" data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$create_url.'" class="button button-small create-mtpg-button">'.__('Create New Custom', 'event_espresso').'</a>';
556
+				$st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : '';
557
+				$st_args['edit_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $mtpgID) ? '<a data-messagetype="'.$mtpg->message_type().'" data-grpid="'.$default_value.'" target="_blank" href="'.$edit_url.'" class="button button-small edit-mtpg-button">'.__('Edit', 'event_espresso').'</a>' : '';
558
+				$selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
559 559
 			}
560 560
 		}
561 561
 
562 562
 		//if no selectors present then get out.
563
-		if ( empty( $selector_rows ) ) {
563
+		if (empty($selector_rows)) {
564 564
 			return '';
565 565
 		}
566 566
 
567 567
 		$template_args['selector_rows'] = $selector_rows;
568
-		return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE );
568
+		return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE);
569 569
 	}
570 570
 
571 571
 
@@ -580,8 +580,8 @@  discard block
 block discarded – undo
580 580
 	 * @return array $this->_template_fields
581 581
 	 */
582 582
 	public function get_template_fields() {
583
-		$template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this );
584
-		$template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this );
583
+		$template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this);
584
+		$template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
585 585
 		return $template_fields;
586 586
 	}
587 587
 
@@ -595,9 +595,9 @@  discard block
 block discarded – undo
595 595
 	 * @param mixed $value
596 596
 	 */
597 597
 	protected function _set_template_value($item, $value) {
598
-		if ( array_key_exists($item, $this->_template_fields) ) {
599
-			$prop = '_' . $item;
600
-			$this->{$prop}= $value;
598
+		if (array_key_exists($item, $this->_template_fields)) {
599
+			$prop = '_'.$item;
600
+			$this->{$prop} = $value;
601 601
 		}
602 602
 	}
603 603
 
@@ -615,18 +615,18 @@  discard block
 block discarded – undo
615 615
 	 *
616 616
 	 * @throws SendMessageException
617 617
 	 */
618
-	final public function send_message( $message, EE_message_type $message_type ) {
618
+	final public function send_message($message, EE_message_type $message_type) {
619 619
 		try {
620
-			$this->_validate_and_setup( $message );
620
+			$this->_validate_and_setup($message);
621 621
 			$this->_incoming_message_type = $message_type;
622 622
 			$response = $this->_send_message();
623
-			if ( $response instanceof WP_Error ) {
624
-				EE_Error::add_error( $response->get_error_message(), __FILE__, __FUNCTION__, __LINE__ );
623
+			if ($response instanceof WP_Error) {
624
+				EE_Error::add_error($response->get_error_message(), __FILE__, __FUNCTION__, __LINE__);
625 625
 				$response = false;
626 626
 			}
627
-		} catch ( \Exception $e ) {
627
+		} catch (\Exception $e) {
628 628
 			//convert to an instance of SendMessageException
629
-			throw new SendMessageException( $e->getMessage() );
629
+			throw new SendMessageException($e->getMessage());
630 630
 		}
631 631
 		return $response;
632 632
 	}
@@ -640,28 +640,28 @@  discard block
 block discarded – undo
640 640
 	 * @param  bool   $send    true we will actually use the _send method (for test sends). FALSE we just return preview
641 641
 	 * @return string          return the message html content
642 642
 	 */
643
-	public function get_preview( EE_Message $message, EE_message_type $message_type, $send = false ) {
644
-		$this->_validate_and_setup( $message );
643
+	public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false) {
644
+		$this->_validate_and_setup($message);
645 645
 
646 646
 		$this->_incoming_message_type = $message_type;
647 647
 
648
-		if ( $send ) {
648
+		if ($send) {
649 649
 			//are we overriding any existing template fields?
650 650
 			$settings = $this->get_existing_test_settings();
651
-			if ( ! empty( $settings ) ) {
652
-				foreach ( $settings as $field => $value ) {
653
-					$this->_set_template_value( $field, $value );
651
+			if ( ! empty($settings)) {
652
+				foreach ($settings as $field => $value) {
653
+					$this->_set_template_value($field, $value);
654 654
 				}
655 655
 			}
656 656
 		}
657 657
 
658 658
 		//enqueue preview js so that any links/buttons on the page are disabled.
659
-		if ( ! $send ) {
659
+		if ( ! $send) {
660 660
 			// the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
661 661
 			// it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
662
-			add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 );
663
-			add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 );
664
-			add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 );
662
+			add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10);
663
+			add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10);
664
+			add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10);
665 665
 		}
666 666
 
667 667
 		return $send ? $this->_send_message() : $this->_preview();
@@ -679,10 +679,10 @@  discard block
 block discarded – undo
679 679
 	 */
680 680
 	public function add_preview_script() {
681 681
 		//error message
682
-		EE_Registry::$i18n_js_strings[ 'links_disabled' ] = __( 'All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso' );
683
-		wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true );
684
-		wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings );
685
-		wp_enqueue_script( 'ee-messages-preview-js' );
682
+		EE_Registry::$i18n_js_strings['links_disabled'] = __('All the links on this page have been disabled because this is a generated preview message for the purpose of ensuring layout, style, and content setup.  To test generated links, you must trigger an actual message notification.', 'event_espresso');
683
+		wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
684
+		wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
685
+		wp_enqueue_script('ee-messages-preview-js');
686 686
 	}
687 687
 
688 688
 
@@ -693,13 +693,13 @@  discard block
 block discarded – undo
693 693
 	 * @param  EE_Message $message
694 694
 	 * @throws EE_Error
695 695
 	 */
696
-	protected function _validate_and_setup( EE_Message $message ) {
696
+	protected function _validate_and_setup(EE_Message $message) {
697 697
 		$template_pack = $message->get_template_pack();
698 698
 		$variation = $message->get_template_pack_variation();
699 699
 
700 700
 		//verify we have the required template pack value on the $message object.
701
-		if ( ! $template_pack instanceof EE_Messages_Template_Pack ) {
702
-			throw new EE_Error( __('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso' ) );
701
+		if ( ! $template_pack instanceof EE_Messages_Template_Pack) {
702
+			throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
703 703
 		}
704 704
 
705 705
 		$this->_tmp_pack = $template_pack;
@@ -708,11 +708,11 @@  discard block
 block discarded – undo
708 708
 
709 709
 		$template_fields = $this->get_template_fields();
710 710
 
711
-		foreach ( $template_fields as $template => $value ) {
712
-			if ( $template !== 'extra' ) {
713
-				$column_value = $message->get_field_or_extra_meta( 'MSG_' . $template );
711
+		foreach ($template_fields as $template => $value) {
712
+			if ($template !== 'extra') {
713
+				$column_value = $message->get_field_or_extra_meta('MSG_'.$template);
714 714
 				$message_template_value = $column_value ? $column_value : null;
715
-				$this->_set_template_value( $template, $message_template_value );
715
+				$this->_set_template_value($template, $message_template_value);
716 716
 			}
717 717
 		}
718 718
 	}
@@ -727,19 +727,19 @@  discard block
 block discarded – undo
727 727
 	 * @return string
728 728
 	 * @throws \EE_Error
729 729
 	 */
730
-	protected function _get_main_template( $preview = FALSE ) {
730
+	protected function _get_main_template($preview = FALSE) {
731 731
 		$type = $preview ? 'preview' : 'main';
732 732
 
733
-		$wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type );
733
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
734 734
 
735 735
 		//check file exists and is readable
736
-		if ( !is_readable( $wrapper_template ) )
737
-			throw new EE_Error( sprintf( __('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso' ), ucwords($this->label['singular']) , $wrapper_template ) );
736
+		if ( ! is_readable($wrapper_template))
737
+			throw new EE_Error(sprintf(__('Unable to access the template file for the %s messenger main content wrapper.  The location being attempted is %s.', 'event_espresso'), ucwords($this->label['singular']), $wrapper_template));
738 738
 
739 739
 		//add message type to template args
740 740
 		$this->_template_args['message_type'] = $this->_incoming_message_type;
741 741
 
742
-		return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE );
742
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE);
743 743
 	}
744 744
 
745 745
 
@@ -775,9 +775,9 @@  discard block
 block discarded – undo
775 775
 	 */
776 776
 	public function get_existing_test_settings() {
777 777
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
778
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
778
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
779 779
 		$settings = $Message_Resource_Manager->get_active_messengers_option();
780
-		return isset( $settings[ $this->name ]['test_settings'] ) ? $settings[ $this->name ]['test_settings'] : array();
780
+		return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array();
781 781
 	}
782 782
 
783 783
 
@@ -789,12 +789,12 @@  discard block
 block discarded – undo
789 789
 	 * @param $settings
790 790
 	 * @return bool success/fail
791 791
 	 */
792
-	public function set_existing_test_settings( $settings ) {
792
+	public function set_existing_test_settings($settings) {
793 793
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
794
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
794
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
795 795
 		$existing = $Message_Resource_Manager->get_active_messengers_option();
796
-		$existing[ $this->name ]['test_settings'] = $settings;
797
-		return $Message_Resource_Manager->update_active_messengers_option( $existing );
796
+		$existing[$this->name]['test_settings'] = $settings;
797
+		return $Message_Resource_Manager->update_active_messengers_option($existing);
798 798
 	}
799 799
 
800 800
 
@@ -807,21 +807,21 @@  discard block
 block discarded – undo
807 807
 	 * @param string $field The field to retrieve the label for
808 808
 	 * @return string        	  The label
809 809
 	 */
810
-	public function get_field_label( $field ) {
810
+	public function get_field_label($field) {
811 811
 		//first let's see if the field requests is in the top level array.
812
-		if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) )
812
+		if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label']))
813 813
 			return $this->_template[$field]['label'];
814 814
 
815 815
 		//nope so let's look in the extra array to see if it's there HOWEVER if the field exists as a top level index in the extra array then we know the label is in the 'main' index.
816
-		if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] )  )
816
+		if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label']))
817 817
 			return $this->_template_fields['extra'][$field]['main']['label'];
818 818
 
819 819
 		//now it's possible this field may just be existing in any of the extra array items.
820
-		if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) {
821
-			foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) {
822
-				if ( !is_array( $subfields ) )
820
+		if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
821
+			foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
822
+				if ( ! is_array($subfields))
823 823
 					continue;
824
-				if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) )
824
+				if (isset($subfields[$field]) && ! empty($subfields[$field]['label']))
825 825
 					return $subfields[$field]['label'];
826 826
 			}
827 827
 		}
@@ -842,7 +842,7 @@  discard block
 block discarded – undo
842 842
 	 *
843 843
 	 * @return void
844 844
 	 */
845
-	public function do_secondary_messenger_hooks( $sending_messenger_name ) {
845
+	public function do_secondary_messenger_hooks($sending_messenger_name) {
846 846
 		return;
847 847
 	}
848 848
 
Please login to merge, or discard this patch.
espresso.php 1 patch
Spacing   +93 added lines, -93 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'ABSPATH' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('ABSPATH')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /*
5 5
   Plugin Name:		Event Espresso
@@ -42,7 +42,7 @@  discard block
 block discarded – undo
42 42
  *
43 43
  */
44 44
 
45
-if ( function_exists( 'espresso_version' ) ) {
45
+if (function_exists('espresso_version')) {
46 46
 
47 47
 	/**
48 48
 	 *    espresso_duplicate_plugin_error
@@ -51,12 +51,12 @@  discard block
 block discarded – undo
51 51
 	function espresso_duplicate_plugin_error() {
52 52
 		?>
53 53
 		<div class="error">
54
-			<p><?php _e( 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso' ); ?></p>
54
+			<p><?php _e('Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', 'event_espresso'); ?></p>
55 55
 		</div>
56 56
 		<?php
57
-		espresso_deactivate_plugin( plugin_basename( __FILE__ ) );
57
+		espresso_deactivate_plugin(plugin_basename(__FILE__));
58 58
 	}
59
-	add_action( 'admin_notices', 'espresso_duplicate_plugin_error', 1 );
59
+	add_action('admin_notices', 'espresso_duplicate_plugin_error', 1);
60 60
 
61 61
 } else {
62 62
 
@@ -67,103 +67,103 @@  discard block
 block discarded – undo
67 67
 	 * @return string
68 68
 	 */
69 69
 	function espresso_version() {
70
-		return apply_filters( 'FHEE__espresso__espresso_version', '4.9.11.rc.001' );
70
+		return apply_filters('FHEE__espresso__espresso_version', '4.9.11.rc.001');
71 71
 	}
72 72
 
73 73
 	// define versions
74
-	define( 'EVENT_ESPRESSO_VERSION', espresso_version() );
75
-	define( 'EE_MIN_WP_VER_REQUIRED', '4.1' );
76
-	define( 'EE_MIN_WP_VER_RECOMMENDED', '4.4.2' );
77
-	define( 'EE_MIN_PHP_VER_REQUIRED', '5.3.0' );
78
-	define( 'EE_MIN_PHP_VER_RECOMMENDED', '5.4.44' );
79
-	define( 'EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - ' . EVENT_ESPRESSO_VERSION );
80
-	define( 'EVENT_ESPRESSO_MAIN_FILE', __FILE__ );
74
+	define('EVENT_ESPRESSO_VERSION', espresso_version());
75
+	define('EE_MIN_WP_VER_REQUIRED', '4.1');
76
+	define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2');
77
+	define('EE_MIN_PHP_VER_REQUIRED', '5.3.0');
78
+	define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44');
79
+	define('EVENT_ESPRESSO_POWERED_BY', 'Event Espresso - '.EVENT_ESPRESSO_VERSION);
80
+	define('EVENT_ESPRESSO_MAIN_FILE', __FILE__);
81 81
 	//used to be DIRECTORY_SEPARATOR, but that caused issues on windows
82
-	if ( ! defined( 'DS' ) ) {
83
-		define( 'DS', '/' );
82
+	if ( ! defined('DS')) {
83
+		define('DS', '/');
84 84
 	}
85
-	if ( ! defined( 'PS' ) ) {
86
-		define( 'PS', PATH_SEPARATOR );
85
+	if ( ! defined('PS')) {
86
+		define('PS', PATH_SEPARATOR);
87 87
 	}
88
-	if ( ! defined( 'SP' ) ) {
89
-		define( 'SP', ' ' );
88
+	if ( ! defined('SP')) {
89
+		define('SP', ' ');
90 90
 	}
91
-	if ( ! defined( 'EENL' ) ) {
92
-		define( 'EENL', "\n" );
91
+	if ( ! defined('EENL')) {
92
+		define('EENL', "\n");
93 93
 	}
94
-	define( 'EE_SUPPORT_EMAIL', '[email protected]' );
94
+	define('EE_SUPPORT_EMAIL', '[email protected]');
95 95
 	// define the plugin directory and URL
96
-	define( 'EE_PLUGIN_BASENAME', plugin_basename( EVENT_ESPRESSO_MAIN_FILE ) );
97
-	define( 'EE_PLUGIN_DIR_PATH', plugin_dir_path( EVENT_ESPRESSO_MAIN_FILE ) );
98
-	define( 'EE_PLUGIN_DIR_URL', plugin_dir_url( EVENT_ESPRESSO_MAIN_FILE ) );
96
+	define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE));
97
+	define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE));
98
+	define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE));
99 99
 	// main root folder paths
100
-	define( 'EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS );
101
-	define( 'EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS );
102
-	define( 'EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS );
103
-	define( 'EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS );
104
-	define( 'EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS );
105
-	define( 'EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS );
106
-	define( 'EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS );
107
-	define( 'EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS );
100
+	define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH.'admin_pages'.DS);
101
+	define('EE_CORE', EE_PLUGIN_DIR_PATH.'core'.DS);
102
+	define('EE_MODULES', EE_PLUGIN_DIR_PATH.'modules'.DS);
103
+	define('EE_PUBLIC', EE_PLUGIN_DIR_PATH.'public'.DS);
104
+	define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH.'shortcodes'.DS);
105
+	define('EE_WIDGETS', EE_PLUGIN_DIR_PATH.'widgets'.DS);
106
+	define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH.'payment_methods'.DS);
107
+	define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH.'caffeinated'.DS);
108 108
 	// core system paths
109
-	define( 'EE_ADMIN', EE_CORE . 'admin' . DS );
110
-	define( 'EE_CPTS', EE_CORE . 'CPTs' . DS );
111
-	define( 'EE_CLASSES', EE_CORE . 'db_classes' . DS );
112
-	define( 'EE_INTERFACES', EE_CORE . 'interfaces' . DS );
113
-	define( 'EE_BUSINESS', EE_CORE . 'business' . DS );
114
-	define( 'EE_MODELS', EE_CORE . 'db_models' . DS );
115
-	define( 'EE_HELPERS', EE_CORE . 'helpers' . DS );
116
-	define( 'EE_LIBRARIES', EE_CORE . 'libraries' . DS );
117
-	define( 'EE_TEMPLATES', EE_CORE . 'templates' . DS );
118
-	define( 'EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS );
119
-	define( 'EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS );
120
-	define( 'EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS );
109
+	define('EE_ADMIN', EE_CORE.'admin'.DS);
110
+	define('EE_CPTS', EE_CORE.'CPTs'.DS);
111
+	define('EE_CLASSES', EE_CORE.'db_classes'.DS);
112
+	define('EE_INTERFACES', EE_CORE.'interfaces'.DS);
113
+	define('EE_BUSINESS', EE_CORE.'business'.DS);
114
+	define('EE_MODELS', EE_CORE.'db_models'.DS);
115
+	define('EE_HELPERS', EE_CORE.'helpers'.DS);
116
+	define('EE_LIBRARIES', EE_CORE.'libraries'.DS);
117
+	define('EE_TEMPLATES', EE_CORE.'templates'.DS);
118
+	define('EE_THIRD_PARTY', EE_CORE.'third_party_libs'.DS);
119
+	define('EE_GLOBAL_ASSETS', EE_TEMPLATES.'global_assets'.DS);
120
+	define('EE_FORM_SECTIONS', EE_LIBRARIES.'form_sections'.DS);
121 121
 	// gateways
122
-	define( 'EE_GATEWAYS', EE_MODULES . 'gateways' . DS );
123
-	define( 'EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS );
122
+	define('EE_GATEWAYS', EE_MODULES.'gateways'.DS);
123
+	define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL.'modules'.DS.'gateways'.DS);
124 124
 	// asset URL paths
125
-	define( 'EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS );
126
-	define( 'EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS );
127
-	define( 'EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS );
128
-	define( 'EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS );
129
-	define( 'EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/' );
130
-	define( 'EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/' );
125
+	define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL.'core'.DS.'templates'.DS);
126
+	define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL.'global_assets'.DS);
127
+	define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL.'images'.DS);
128
+	define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL.'core'.DS.'third_party_libs'.DS);
129
+	define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL.'core/helpers/assets/');
130
+	define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL.'core/libraries/');
131 131
 	// define upload paths
132 132
 	$uploads = wp_upload_dir();
133 133
 	// define the uploads directory and URL
134
-	define( 'EVENT_ESPRESSO_UPLOAD_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS );
135
-	define( 'EVENT_ESPRESSO_UPLOAD_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS );
134
+	define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'].DS.'espresso'.DS);
135
+	define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'].DS.'espresso'.DS);
136 136
 	// define the templates directory and URL
137
-	define( 'EVENT_ESPRESSO_TEMPLATE_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'templates' . DS );
138
-	define( 'EVENT_ESPRESSO_TEMPLATE_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'templates' . DS );
137
+	define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'].DS.'espresso'.DS.'templates'.DS);
138
+	define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'].DS.'espresso'.DS.'templates'.DS);
139 139
 	// define the gateway directory and URL
140
-	define( 'EVENT_ESPRESSO_GATEWAY_DIR', $uploads[ 'basedir' ] . DS . 'espresso' . DS . 'gateways' . DS );
141
-	define( 'EVENT_ESPRESSO_GATEWAY_URL', $uploads[ 'baseurl' ] . DS . 'espresso' . DS . 'gateways' . DS );
140
+	define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'].DS.'espresso'.DS.'gateways'.DS);
141
+	define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'].DS.'espresso'.DS.'gateways'.DS);
142 142
 	// languages folder/path
143
-	define( 'EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS );
144
-	define( 'EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS );
143
+	define('EE_LANGUAGES_SAFE_LOC', '..'.DS.'uploads'.DS.'espresso'.DS.'languages'.DS);
144
+	define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'languages'.DS);
145 145
 	//check for dompdf fonts in uploads
146
-	if ( file_exists( EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS ) ) {
147
-		define( 'DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS );
146
+	if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS)) {
147
+		define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR.'fonts'.DS);
148 148
 	}
149 149
 	//ajax constants
150
-	define( 'EE_FRONT_AJAX', isset( $_REQUEST[ 'ee_front_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_front_ajax' ] ) ? true : false );
151
-	define( 'EE_ADMIN_AJAX', isset( $_REQUEST[ 'ee_admin_ajax' ] ) || isset( $_REQUEST[ 'data' ][ 'ee_admin_ajax' ] ) ? true : false );
150
+	define('EE_FRONT_AJAX', isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false);
151
+	define('EE_ADMIN_AJAX', isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false);
152 152
 	//just a handy constant occasionally needed for finding values representing infinity in the DB
153 153
 	//you're better to use this than its straight value (currently -1) in case you ever
154 154
 	//want to change its default value! or find when -1 means infinity
155
-	define( 'EE_INF_IN_DB', -1 );
156
-	define( 'EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX );
157
-	define( 'EE_DEBUG', false );
155
+	define('EE_INF_IN_DB', -1);
156
+	define('EE_INF', INF > (float) PHP_INT_MAX ? INF : PHP_INT_MAX);
157
+	define('EE_DEBUG', false);
158 158
 
159 159
 	/**
160 160
 	 *    espresso_plugin_activation
161 161
 	 *    adds a wp-option to indicate that EE has been activated via the WP admin plugins page
162 162
 	 */
163 163
 	function espresso_plugin_activation() {
164
-		update_option( 'ee_espresso_activation', true );
164
+		update_option('ee_espresso_activation', true);
165 165
 	}
166
-	register_activation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation' );
166
+	register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation');
167 167
 
168 168
 
169 169
 
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		//	}
178 178
 		//
179 179
 	}
180
-	register_deactivation_hook( EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation' );
180
+	register_deactivation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_deactivation');
181 181
 
182 182
 
183 183
 
@@ -187,15 +187,15 @@  discard block
 block discarded – undo
187 187
 	 */
188 188
 	function espresso_load_error_handling() {
189 189
 		// load debugging tools
190
-		if ( WP_DEBUG === true && is_readable( EE_HELPERS . 'EEH_Debug_Tools.helper.php' ) ) {
191
-			require_once( EE_HELPERS . 'EEH_Debug_Tools.helper.php' );
190
+		if (WP_DEBUG === true && is_readable(EE_HELPERS.'EEH_Debug_Tools.helper.php')) {
191
+			require_once(EE_HELPERS.'EEH_Debug_Tools.helper.php');
192 192
 			EEH_Debug_Tools::instance();
193 193
 		}
194 194
 		// load error handling
195
-		if ( is_readable( EE_CORE . 'EE_Error.core.php' ) ) {
196
-			require_once( EE_CORE . 'EE_Error.core.php' );
195
+		if (is_readable(EE_CORE.'EE_Error.core.php')) {
196
+			require_once(EE_CORE.'EE_Error.core.php');
197 197
 		} else {
198
-			wp_die( __( 'The EE_Error core class could not be loaded.', 'event_espresso' ) );
198
+			wp_die(__('The EE_Error core class could not be loaded.', 'event_espresso'));
199 199
 		}
200 200
 	}
201 201
 
@@ -209,25 +209,25 @@  discard block
 block discarded – undo
209 209
 	 * @param    string $full_path_to_file
210 210
 	 * @throws    EE_Error
211 211
 	 */
212
-	function espresso_load_required( $classname, $full_path_to_file ) {
212
+	function espresso_load_required($classname, $full_path_to_file) {
213 213
 		static $error_handling_loaded = false;
214
-		if ( ! $error_handling_loaded ) {
214
+		if ( ! $error_handling_loaded) {
215 215
 			espresso_load_error_handling();
216 216
 			$error_handling_loaded = true;
217 217
 		}
218
-		if ( is_readable( $full_path_to_file ) ) {
219
-			require_once( $full_path_to_file );
218
+		if (is_readable($full_path_to_file)) {
219
+			require_once($full_path_to_file);
220 220
 		} else {
221
-			throw new EE_Error ( sprintf(
222
-				__( 'The %s class file could not be located or is not readable due to file permissions.', 'event_espresso' ),
221
+			throw new EE_Error(sprintf(
222
+				__('The %s class file could not be located or is not readable due to file permissions.', 'event_espresso'),
223 223
 				$classname
224
-			) );
224
+			));
225 225
 		}
226 226
 	}
227 227
 
228
-	espresso_load_required( 'EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php' );
229
-	espresso_load_required( 'EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php' );
230
-	espresso_load_required( 'EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php' );
228
+	espresso_load_required('EEH_Base', EE_CORE.'helpers'.DS.'EEH_Base.helper.php');
229
+	espresso_load_required('EEH_File', EE_CORE.'helpers'.DS.'EEH_File.helper.php');
230
+	espresso_load_required('EE_Bootstrap', EE_CORE.'EE_Bootstrap.core.php');
231 231
 	new EE_Bootstrap();
232 232
 
233 233
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 
237 237
 
238 238
 
239
-if ( ! function_exists( 'espresso_deactivate_plugin' ) ) {
239
+if ( ! function_exists('espresso_deactivate_plugin')) {
240 240
 	/**
241 241
 	*    deactivate_plugin
242 242
 	* usage:  espresso_deactivate_plugin( plugin_basename( __FILE__ ));
@@ -245,11 +245,11 @@  discard block
 block discarded – undo
245 245
 	* @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file
246 246
 	* @return    void
247 247
 	*/
248
-	function espresso_deactivate_plugin( $plugin_basename = '' ) {
249
-		if ( ! function_exists( 'deactivate_plugins' ) ) {
250
-			require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
248
+	function espresso_deactivate_plugin($plugin_basename = '') {
249
+		if ( ! function_exists('deactivate_plugins')) {
250
+			require_once(ABSPATH.'wp-admin/includes/plugin.php');
251 251
 		}
252
-		unset( $_GET[ 'activate' ], $_REQUEST[ 'activate' ] );
253
-		deactivate_plugins( $plugin_basename );
252
+		unset($_GET['activate'], $_REQUEST['activate']);
253
+		deactivate_plugins($plugin_basename);
254 254
 	}
255 255
 }
Please login to merge, or discard this patch.