Completed
Branch BUG-9492-refactor-activation-l... (cb6da3)
by
unknown
23:45 queued 12:49
created
core/libraries/messages/EE_Messages_Queue.lib.php 1 patch
Spacing   +92 added lines, -92 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @param \EE_Message_Repository       $message_repository
73 73
 	 */
74
-	public function __construct( EE_Message_Repository $message_repository ) {
75
-		$this->_batch_count        = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 );
74
+	public function __construct(EE_Message_Repository $message_repository) {
75
+		$this->_batch_count        = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50);
76 76
 		$this->_rate_limit         = $this->get_rate_limit();
77 77
 		$this->_message_repository = $message_repository;
78 78
 	}
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	 *                                 use the messenger send method but typically is based on preview data.
92 92
 	 * @return bool          Whether the message was successfully added to the repository or not.
93 93
 	 */
94
-	public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) {
94
+	public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) {
95 95
 		$data['preview'] = $preview;
96 96
 		$data['test_send'] = $test_send;
97
-		return $this->_message_repository->add( $message, $data );
97
+		return $this->_message_repository->add($message, $data);
98 98
 	}
99 99
 
100 100
 
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	 * @param bool          $persist    This flag indicates whether to attempt to delete the object from the db as well.
107 107
 	 * @return bool
108 108
 	 */
109
-	public function remove( EE_Message $message, $persist = false ) {
110
-		if ( $persist && $this->_message_repository->current() !== $message ) {
109
+	public function remove(EE_Message $message, $persist = false) {
110
+		if ($persist && $this->_message_repository->current() !== $message) {
111 111
 			//get pointer on right message
112
-			if ( $this->_message_repository->has( $message ) ) {
112
+			if ($this->_message_repository->has($message)) {
113 113
 				$this->_message_repository->rewind();
114
-				while( $this->_message_repository->valid() ) {
115
-					if ( $this->_message_repository->current() === $message ) {
114
+				while ($this->_message_repository->valid()) {
115
+					if ($this->_message_repository->current() === $message) {
116 116
 						break;
117 117
 					}
118 118
 					$this->_message_repository->next();
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 				return false;
122 122
 			}
123 123
 		}
124
-		return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message );
124
+		return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message);
125 125
 	}
126 126
 
127 127
 
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
 	 * @return bool  true if successfully retrieved batch, false no batch ready.
162 162
 	 */
163 163
 	public function get_batch_to_generate() {
164
-		if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) {
164
+		if ($this->is_locked(EE_Messages_Queue::action_generating)) {
165 165
 			return false;
166 166
 		}
167 167
 
168 168
 		//lock batch generation to prevent race conditions.
169
-		$this->lock_queue( EE_Messages_Queue::action_generating );
169
+		$this->lock_queue(EE_Messages_Queue::action_generating);
170 170
 
171 171
 		$query_args = array(
172 172
 			// key 0 = where conditions
173
-			0 => array( 'STS_ID' => EEM_Message::status_incomplete ),
173
+			0 => array('STS_ID' => EEM_Message::status_incomplete),
174 174
 			'order_by' => $this->_get_priority_orderby(),
175 175
 			'limit' => $this->_batch_count
176 176
 		);
177
-		$messages = EEM_Message::instance()->get_all( $query_args );
177
+		$messages = EEM_Message::instance()->get_all($query_args);
178 178
 
179
-		if ( ! $messages ) {
179
+		if ( ! $messages) {
180 180
 			return false; //nothing to generate
181 181
 		}
182 182
 
183
-		foreach ( $messages as $message ) {
184
-			if ( $message instanceof EE_Message ) {
183
+		foreach ($messages as $message) {
184
+			if ($message instanceof EE_Message) {
185 185
 				$data = $message->all_extra_meta_array();
186
-				$this->add( $message, $data );
186
+				$this->add($message, $data);
187 187
 			}
188 188
 		}
189 189
 		return true;
@@ -206,34 +206,34 @@  discard block
 block discarded – undo
206 206
 	 *               to assist with notifying user.
207 207
 	 */
208 208
 	public function get_to_send_batch_and_send() {
209
-		if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) {
209
+		if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) {
210 210
 			return false;
211 211
 		}
212 212
 
213
-		$this->lock_queue( EE_Messages_Queue::action_sending );
213
+		$this->lock_queue(EE_Messages_Queue::action_sending);
214 214
 
215 215
 		$batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit;
216 216
 
217 217
 		$query_args = array(
218 218
 			// key 0 = where conditions
219
-			0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ),
219
+			0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())),
220 220
 			'order_by' => $this->_get_priority_orderby(),
221 221
 			'limit' => $batch
222 222
 		);
223 223
 
224
-		$messages_to_send = EEM_Message::instance()->get_all( $query_args );
224
+		$messages_to_send = EEM_Message::instance()->get_all($query_args);
225 225
 
226 226
 
227 227
 		//any to send?
228
-		if ( ! $messages_to_send ) {
229
-			$this->unlock_queue( EE_Messages_Queue::action_sending );
228
+		if ( ! $messages_to_send) {
229
+			$this->unlock_queue(EE_Messages_Queue::action_sending);
230 230
 			return false;
231 231
 		}
232 232
 
233 233
 		//add to queue.
234
-		foreach ( $messages_to_send as $message ) {
235
-			if ( $message instanceof EE_Message ) {
236
-				$this->add( $message );
234
+		foreach ($messages_to_send as $message) {
235
+			if ($message instanceof EE_Message) {
236
+				$this->add($message);
237 237
 			}
238 238
 		}
239 239
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		$this->execute();
242 242
 
243 243
 		//release lock
244
-		$this->unlock_queue( EE_Messages_Queue::action_sending );
244
+		$this->unlock_queue(EE_Messages_Queue::action_sending);
245 245
 		return true;
246 246
 	}
247 247
 
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @param   string  $type   The type of queue being locked.
255 255
 	 */
256
-	public function lock_queue( $type = EE_Messages_Queue::action_generating ) {
257
-		set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) );
256
+	public function lock_queue($type = EE_Messages_Queue::action_generating) {
257
+		set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type));
258 258
 	}
259 259
 
260 260
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @param   string  $type   The type of queue being unlocked.
267 267
 	 */
268
-	public function unlock_queue( $type = EE_Messages_Queue::action_generating ) {
269
-		delete_transient( $this->_get_lock_key( $type ) );
268
+	public function unlock_queue($type = EE_Messages_Queue::action_generating) {
269
+		delete_transient($this->_get_lock_key($type));
270 270
 	}
271 271
 
272 272
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param string $type  The type of lock.
278 278
 	 * @return string
279 279
 	 */
280
-	protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) {
281
-		return '_ee_lock_' . $type;
280
+	protected function _get_lock_key($type = EE_Messages_Queue::action_generating) {
281
+		return '_ee_lock_'.$type;
282 282
 	}
283 283
 
284 284
 
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 * @param string $type  The type of lock
290 290
 	 * @return int   time to expiry in seconds.
291 291
 	 */
292
-	protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) {
293
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type );
292
+	protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) {
293
+		return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type);
294 294
 	}
295 295
 
296 296
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return int
309 309
 	 */
310 310
 	protected function _get_rate_limit_expiry() {
311
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS );
311
+		return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS);
312 312
 	}
313 313
 
314 314
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return int
320 320
 	 */
321 321
 	protected function _default_rate_limit() {
322
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 );
322
+		return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200);
323 323
 	}
324 324
 
325 325
 
@@ -345,11 +345,11 @@  discard block
 block discarded – undo
345 345
 	 * @param  string $type The type of lock being checked for.
346 346
 	 * @return bool
347 347
 	 */
348
-	public function is_locked( $type = EE_Messages_Queue::action_generating ) {
348
+	public function is_locked($type = EE_Messages_Queue::action_generating) {
349 349
 		return filter_var(
350 350
 			apply_filters(
351 351
 				'FHEE__EE_Messages_Queue__is_locked',
352
-				get_transient( $this->_get_lock_key( $type ) ),
352
+				get_transient($this->_get_lock_key($type)),
353 353
 				$this
354 354
 			),
355 355
 			FILTER_VALIDATE_BOOLEAN
@@ -368,9 +368,9 @@  discard block
 block discarded – undo
368 368
 	 * @return int
369 369
 	 */
370 370
 	public function get_rate_limit() {
371
-		if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) {
371
+		if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) {
372 372
 			$rate_limit = $this->_default_rate_limit();
373
-			set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() );
373
+			set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key());
374 374
 		}
375 375
 		return $rate_limit;
376 376
 	}
@@ -382,12 +382,12 @@  discard block
 block discarded – undo
382 382
 	 * This updates existing rate limit with the new limit which is the old minus the batch.
383 383
 	 * @param int $batch_completed  This sets the new rate limit based on the given batch that was completed.
384 384
 	 */
385
-	public function set_rate_limit( $batch_completed ) {
385
+	public function set_rate_limit($batch_completed) {
386 386
 		//first get the most up to date rate limit (in case its expired and reset)
387 387
 		$rate_limit = $this->get_rate_limit();
388 388
 		$new_limit = $rate_limit - $batch_completed;
389 389
 		//updating the transient option directly to avoid resetting the expiry.
390
-		update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit );
390
+		update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit);
391 391
 	}
392 392
 
393 393
 
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 	 * @param string $task This indicates what type of request is going to be initiated.
401 401
 	 * @param int    $priority  This indicates the priority that triggers initiating the request.
402 402
 	 */
403
-	public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) {
403
+	public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) {
404 404
 		//determine what status is matched with the priority as part of the trigger conditions.
405 405
 		$status = $task == 'generate'
406 406
 			? EEM_Message::status_incomplete
@@ -408,8 +408,8 @@  discard block
 block discarded – undo
408 408
 		// always make sure we save because either this will get executed immediately on a separate request
409 409
 		// or remains in the queue for the regularly scheduled queue batch.
410 410
 		$this->save();
411
-		if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) {
412
-			EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task );
411
+		if ($this->_message_repository->count_by_priority_and_status($priority, $status)) {
412
+			EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task);
413 413
 		}
414 414
 	}
415 415
 
@@ -434,53 +434,53 @@  discard block
 block discarded – undo
434 434
 	 *                    Also, if the messenger is an request type messenger (or a preview),
435 435
 	 * 					  its entirely possible that the messenger will exit before
436 436
 	 */
437
-	public function execute( $save = true, $sending_messenger = null, $by_priority = false ) {
437
+	public function execute($save = true, $sending_messenger = null, $by_priority = false) {
438 438
 		$messages_sent = 0;
439 439
 		$this->_did_hook = array();
440 440
 		$this->_message_repository->rewind();
441 441
 
442
-		while ( $this->_message_repository->valid() ) {
442
+		while ($this->_message_repository->valid()) {
443 443
 			$error_messages = array();
444 444
 			/** @type EE_Message $message */
445 445
 			$message = $this->_message_repository->current();
446 446
 			//if the message in the queue has a sent status, then skip
447
-			if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_sent() ) ) {
447
+			if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_sent())) {
448 448
 				$this->_message_repository->next();
449 449
 				continue;
450 450
 			}
451 451
 			//if $by_priority is set and does not match then continue;
452
-			if ( $by_priority && $by_priority != $message->priority() ) {
452
+			if ($by_priority && $by_priority != $message->priority()) {
453 453
 				$this->_message_repository->next();
454 454
 				continue;
455 455
 			}
456 456
 			//error checking
457
-			if ( ! $message->valid_messenger() ) {
457
+			if ( ! $message->valid_messenger()) {
458 458
 				$error_messages[] = sprintf(
459
-					__( 'The %s messenger is not active at time of sending.', 'event_espresso' ),
459
+					__('The %s messenger is not active at time of sending.', 'event_espresso'),
460 460
 					$message->messenger()
461 461
 				);
462 462
 			}
463
-			if ( ! $message->valid_message_type() ) {
463
+			if ( ! $message->valid_message_type()) {
464 464
 				$error_messages[] = sprintf(
465
-					__( 'The %s message type is not active at the time of sending.', 'event_espresso' ),
465
+					__('The %s message type is not active at the time of sending.', 'event_espresso'),
466 466
 					$message->message_type()
467 467
 				);
468 468
 			}
469 469
 			// if there was supposed to be a sending messenger for this message, but it was invalid/inactive,
470 470
 			// then it will instead be an EE_Error object, so let's check for that
471
-			if ( $sending_messenger instanceof EE_Error ) {
471
+			if ($sending_messenger instanceof EE_Error) {
472 472
 				$error_messages[] = $sending_messenger->getMessage();
473 473
 			}
474 474
 			// if there are no errors, then let's process the message
475
-			if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) {
475
+			if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) {
476 476
 				$messages_sent++;
477 477
 			}
478
-			$this->_set_error_message( $message, $error_messages );
478
+			$this->_set_error_message($message, $error_messages);
479 479
 			//add modified time
480
-			$message->set_modified( time() );
480
+			$message->set_modified(time());
481 481
 			$this->_message_repository->next();
482 482
 		}
483
-		if ( $save ) {
483
+		if ($save) {
484 484
 			$this->save();
485 485
 		}
486 486
 		return $messages_sent;
@@ -495,7 +495,7 @@  discard block
 block discarded – undo
495 495
 	 * @param mixed 	 $sending_messenger (optional)
496 496
 	 * @return bool
497 497
 	 */
498
-	protected function _process_message( EE_Message $message, $sending_messenger = null ) {
498
+	protected function _process_message(EE_Message $message, $sending_messenger = null) {
499 499
 		// these *should* have been validated in the execute() method above
500 500
 		$messenger = $message->messenger_object();
501 501
 		$message_type = $message->message_type_object();
@@ -505,20 +505,20 @@  discard block
 block discarded – undo
505 505
 			&& $messenger instanceof EE_messenger
506 506
 			&& $sending_messenger->name != $messenger->name
507 507
 		) {
508
-			$messenger->do_secondary_messenger_hooks( $sending_messenger->name );
508
+			$messenger->do_secondary_messenger_hooks($sending_messenger->name);
509 509
 			$messenger = $sending_messenger;
510 510
 		}
511 511
 		// send using messenger, but double check objects
512
-		if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) {
512
+		if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) {
513 513
 			//set hook for message type (but only if not using another messenger to send).
514
-			if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) {
515
-				$message_type->do_messenger_hooks( $messenger );
516
-				$this->_did_hook[ $message_type->name ] = 1;
514
+			if ( ! isset($this->_did_hook[$message_type->name])) {
515
+				$message_type->do_messenger_hooks($messenger);
516
+				$this->_did_hook[$message_type->name] = 1;
517 517
 			}
518 518
 			//if preview then use preview method
519 519
 			return $this->_message_repository->is_preview()
520
-				? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() )
521
-				: $this->_do_send( $message, $messenger, $message_type );
520
+				? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send())
521
+				: $this->_do_send($message, $messenger, $message_type);
522 522
 		}
523 523
 		return false;
524 524
 	}
@@ -536,12 +536,12 @@  discard block
 block discarded – undo
536 536
 	 * @param array $status  Stati to check for in queue
537 537
 	 * @return int  Count of EE_Message's matching the given status.
538 538
 	 */
539
-	public function count_STS_in_queue( $status ) {
539
+	public function count_STS_in_queue($status) {
540 540
 		$count = 0;
541
-		$status = is_array( $status ) ? $status : array( $status );
541
+		$status = is_array($status) ? $status : array($status);
542 542
 		$this->_message_repository->rewind();
543
-		foreach( $this->_message_repository as $message ) {
544
-			if ( in_array( $message->STS_ID(), $status ) ) {
543
+		foreach ($this->_message_repository as $message) {
544
+			if (in_array($message->STS_ID(), $status)) {
545 545
 				$count++;
546 546
 			}
547 547
 		}
@@ -558,15 +558,15 @@  discard block
 block discarded – undo
558 558
 	 * @param $test_send
559 559
 	 * @return bool   true means all went well, false means, not so much.
560 560
 	 */
561
-	protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) {
562
-		if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) {
563
-			if ( ! $test_send ) {
564
-				$message->set_content( $preview );
561
+	protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) {
562
+		if ($preview = $messenger->get_preview($message, $message_type, $test_send)) {
563
+			if ( ! $test_send) {
564
+				$message->set_content($preview);
565 565
 			}
566
-			$message->set_STS_ID( EEM_Message::status_sent );
566
+			$message->set_STS_ID(EEM_Message::status_sent);
567 567
 			return true;
568 568
 		} else {
569
-			$message->set_STS_ID( EEM_Message::status_failed );
569
+			$message->set_STS_ID(EEM_Message::status_failed);
570 570
 			return false;
571 571
 		}
572 572
 	}
@@ -582,12 +582,12 @@  discard block
 block discarded – undo
582 582
 	 * @param EE_message_type $message_type
583 583
 	 * @return bool true means all went well, false means, not so much.
584 584
 	 */
585
-	protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) {
586
-		if ( $messenger->send_message( $message, $message_type ) ) {
587
-			$message->set_STS_ID( EEM_Message::status_sent );
585
+	protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) {
586
+		if ($messenger->send_message($message, $message_type)) {
587
+			$message->set_STS_ID(EEM_Message::status_sent);
588 588
 			return true;
589 589
 		} else {
590
-			$message->set_STS_ID( EEM_Message::status_retry );
590
+			$message->set_STS_ID(EEM_Message::status_retry);
591 591
 			return false;
592 592
 		}
593 593
 	}
@@ -601,21 +601,21 @@  discard block
 block discarded – undo
601 601
 	 * @param EE_Message $message
602 602
 	 * @param array      $error_messages the response from the messenger.
603 603
 	 */
604
-	protected function _set_error_message( EE_Message $message, $error_messages ) {
604
+	protected function _set_error_message(EE_Message $message, $error_messages) {
605 605
 		$error_messages = (array) $error_messages;
606
-		if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) {
606
+		if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) {
607 607
 			$notices = EE_Error::has_notices();
608
-			$error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' );
609
-			if ( $notices === 1 ) {
608
+			$error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso');
609
+			if ($notices === 1) {
610 610
 				$notices = EE_Error::get_vanilla_notices();
611
-				$notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array();
612
-				$error_messages[] = implode( "\n", $notices['errors'] );
611
+				$notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array();
612
+				$error_messages[] = implode("\n", $notices['errors']);
613 613
 			}
614 614
 		}
615
-		if ( count( $error_messages ) > 0 ) {
616
-			$msg = __( 'Message was not executed successfully.', 'event_espresso' );
617
-			$msg = $msg . "\n" . implode( "\n", $error_messages );
618
-			$message->set_error_message( $msg );
615
+		if (count($error_messages) > 0) {
616
+			$msg = __('Message was not executed successfully.', 'event_espresso');
617
+			$msg = $msg."\n".implode("\n", $error_messages);
618
+			$message->set_error_message($msg);
619 619
 		}
620 620
 	}
621 621
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_messenger.lib.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -289,7 +289,7 @@  discard block
 block discarded – undo
289 289
 	 * @return void
290 290
 	 */
291 291
 	public function enqueue_scripts_styles() {
292
-		do_action( 'AHEE__EE_messenger__enqueue_scripts_styles');
292
+		do_action('AHEE__EE_messenger__enqueue_scripts_styles');
293 293
 	}
294 294
 
295 295
 
@@ -359,7 +359,7 @@  discard block
 block discarded – undo
359 359
 
360 360
 		$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.');
361 361
 
362
-		$this->_supports_labels = apply_filters( 'FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this );
362
+		$this->_supports_labels = apply_filters('FHEE__EE_messenger___set_supports_labels_defaults___supports_labels', $this->_supports_labels, $this);
363 363
 	}
364 364
 
365 365
 
@@ -374,10 +374,10 @@  discard block
 block discarded – undo
374 374
 	 * @return stdClass
375 375
 	 */
376 376
 	public function get_supports_labels() {
377
-		if ( empty( $this->_supports_labels->template_pack ) || empty( $this->_supports_labels->template_variation) ) {
377
+		if (empty($this->_supports_labels->template_pack) || empty($this->_supports_labels->template_variation)) {
378 378
 			$this->_set_supports_labels_defaults();
379 379
 		}
380
-		return apply_filters( 'FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this );
380
+		return apply_filters('FHEE__EE_messenger__get_supports_labels', $this->_supports_labels, $this);
381 381
 	}
382 382
 
383 383
 
@@ -397,10 +397,10 @@  discard block
 block discarded – undo
397 397
 	 *
398 398
 	 * @return string                    path or url for the requested variation.
399 399
 	 */
400
-	public function get_variation( EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE ) {
400
+	public function get_variation(EE_Messages_Template_Pack $pack, $message_type_name, $url = FALSE, $type = 'main', $variation = 'default', $skip_filters = FALSE) {
401 401
 		$this->_tmp_pack = $pack;
402
-		$variation_path = apply_filters( 'EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters );
403
-		$variation_path = empty( $variation_path ) ? $this->_tmp_pack->get_variation( $this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters ) : $variation_path;
402
+		$variation_path = apply_filters('EE_messenger__get_variation__variation', false, $pack, $this->name, $message_type_name, $url, $type, $variation, $skip_filters);
403
+		$variation_path = empty($variation_path) ? $this->_tmp_pack->get_variation($this->name, $message_type_name, $type, $variation, $url, '.css', $skip_filters) : $variation_path;
404 404
 		return $variation_path;
405 405
 
406 406
 	}
@@ -418,13 +418,13 @@  discard block
 block discarded – undo
418 418
 	 * @return array
419 419
 	 */
420 420
 	public function get_default_message_types() {
421
-		$class = get_class( $this );
421
+		$class = get_class($this);
422 422
 
423 423
 		//messenger specific filter
424
-		$default_types = apply_filters( 'FHEE__' . $class . '__get_default_message_types__default_types', $this->_default_message_types, $this );
424
+		$default_types = apply_filters('FHEE__'.$class.'__get_default_message_types__default_types', $this->_default_message_types, $this);
425 425
 
426 426
 		//all messengers filter
427
-		$default_types = apply_filters( 'FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this );
427
+		$default_types = apply_filters('FHEE__EE_messenger__get_default_message_types__default_types', $default_types, $this);
428 428
 		return $default_types;
429 429
 	}
430 430
 
@@ -439,14 +439,14 @@  discard block
 block discarded – undo
439 439
 	 * @return array
440 440
 	 */
441 441
 	public function get_valid_message_types() {
442
-		$class = get_class( $this );
442
+		$class = get_class($this);
443 443
 
444 444
 		//messenger specific filter
445 445
 		//messenger specific filter
446
-		$valid_types = apply_filters( 'FHEE__' . $class . '__get_valid_message_types__valid_types', $this->_valid_message_types, $this );
446
+		$valid_types = apply_filters('FHEE__'.$class.'__get_valid_message_types__valid_types', $this->_valid_message_types, $this);
447 447
 
448 448
 		//all messengers filter
449
-		$valid_types = apply_filters( 'FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this );
449
+		$valid_types = apply_filters('FHEE__EE_messenger__get_valid_message_types__valid_types', $valid_types, $this);
450 450
 		return $valid_types;
451 451
 	}
452 452
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 	 * @access public
461 461
 	 * @param array $new_config Whatever is put in here will reset the _validator_config property
462 462
 	 */
463
-	public function set_validator_config( $new_config ) {
463
+	public function set_validator_config($new_config) {
464 464
 		$this->_validator_config = $new_config;
465 465
 	}
466 466
 
@@ -476,8 +476,8 @@  discard block
 block discarded – undo
476 476
 	public function get_validator_config() {
477 477
 		$class = get_class($this);
478 478
 
479
-		$config = apply_filters( 'FHEE__' . $class . '__get_validator_config', $this->_validator_config, $this );
480
-		$config = apply_filters( 'FHEE__EE_messenger__get_validator_config', $config, $this );
479
+		$config = apply_filters('FHEE__'.$class.'__get_validator_config', $this->_validator_config, $this);
480
+		$config = apply_filters('FHEE__EE_messenger__get_validator_config', $config, $this);
481 481
 		return $config;
482 482
 	}
483 483
 
@@ -494,8 +494,8 @@  discard block
 block discarded – undo
494 494
 	 * @access public
495 495
 	 * @return string content for page
496 496
 	 */
497
-	public function get_messenger_admin_page_content( $page, $action = null, $extra = array(), $message_types = array() ) {
498
-		return $this->_get_admin_page_content( $page, $action, $extra, $message_types );
497
+	public function get_messenger_admin_page_content($page, $action = null, $extra = array(), $message_types = array()) {
498
+		return $this->_get_admin_page_content($page, $action, $extra, $message_types);
499 499
 	}
500 500
 
501 501
 
@@ -505,20 +505,20 @@  discard block
 block discarded – undo
505 505
 	 * @param array $extra
506 506
 	 * @return mixed|string
507 507
 	 */
508
-	protected function _get_admin_content_events_edit( $message_types, $extra ) {
508
+	protected function _get_admin_content_events_edit($message_types, $extra) {
509 509
 		//defaults
510 510
 		$template_args = array();
511 511
 		$selector_rows = '';
512 512
 
513 513
 		//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.
514
-		$event_id = isset( $extra['event'] ) ? $extra['event'] : NULL;
514
+		$event_id = isset($extra['event']) ? $extra['event'] : NULL;
515 515
 
516
-		$template_wrapper_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
517
-		$template_row_path = EE_LIBRARIES . 'messages/messenger/admin_templates/event_switcher_row.template.php';
516
+		$template_wrapper_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_wrapper.template.php';
517
+		$template_row_path = EE_LIBRARIES.'messages/messenger/admin_templates/event_switcher_row.template.php';
518 518
 
519 519
 		//array of template objects for global and custom (non-trashed) (but remember just for this messenger!)
520 520
 		$global_templates = EEM_Message_Template_Group::instance()->get_all(
521
-			array( array( 'MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true ) )
521
+			array(array('MTP_messenger' => $this->name, 'MTP_is_global' => true, 'MTP_is_active' => true))
522 522
 		);
523 523
 		$templates_for_event = EEM_Message_Template_Group::instance()->get_all_custom_templates_by_event(
524 524
 			$event_id,
@@ -527,55 +527,55 @@  discard block
 block discarded – undo
527 527
 				'MTP_is_active' => true
528 528
 			)
529 529
 		);
530
-		$templates_for_event = !empty( $templates_for_event ) ? $templates_for_event : array();
530
+		$templates_for_event = ! empty($templates_for_event) ? $templates_for_event : array();
531 531
 
532 532
 		//so we need to setup the rows for the selectors and we use the global mtpgs (cause those will the active message template groups)
533
-		foreach ( $global_templates as $mtpgID => $mtpg ) {
534
-			if ( $mtpg instanceof EE_Message_Template_Group ) {
533
+		foreach ($global_templates as $mtpgID => $mtpg) {
534
+			if ($mtpg instanceof EE_Message_Template_Group) {
535 535
 				//verify this message type is supposed to show on this page
536 536
 				$mtp_obj = $mtpg->message_type_obj();
537
-				if ( ! $mtp_obj instanceof EE_message_type ) {
537
+				if ( ! $mtp_obj instanceof EE_message_type) {
538 538
 					continue;
539 539
 				}
540
-				$mtp_obj->admin_registered_pages = (array)$mtp_obj->admin_registered_pages;
541
-				if ( ! in_array( 'events_edit', $mtp_obj->admin_registered_pages ) ) {
540
+				$mtp_obj->admin_registered_pages = (array) $mtp_obj->admin_registered_pages;
541
+				if ( ! in_array('events_edit', $mtp_obj->admin_registered_pages)) {
542 542
 					continue;
543 543
 				}
544 544
 				$select_values = array();
545
-				$select_values[ $mtpgID ] = __( 'Global', 'event_espresso' );
546
-				$default_value = array_key_exists( $mtpgID, $templates_for_event ) && ! $mtpg->get( 'MTP_is_override' ) ? $mtpgID : null;
545
+				$select_values[$mtpgID] = __('Global', 'event_espresso');
546
+				$default_value = array_key_exists($mtpgID, $templates_for_event) && ! $mtpg->get('MTP_is_override') ? $mtpgID : null;
547 547
 				//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.
548
-				if ( ! $mtpg->get( 'MTP_is_override' ) ) {
548
+				if ( ! $mtpg->get('MTP_is_override')) {
549 549
 					//any custom templates for this message type?
550
-					$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt( $this->name, $mtpg->message_type() );
551
-					foreach ( $custom_templates as $cmtpgID => $cmtpg ) {
552
-						$select_values[ $cmtpgID ] = $cmtpg->name();
553
-						$default_value = array_key_exists( $cmtpgID, $templates_for_event ) ? $cmtpgID : $default_value;
550
+					$custom_templates = EEM_Message_Template_Group::instance()->get_custom_message_template_by_m_and_mt($this->name, $mtpg->message_type());
551
+					foreach ($custom_templates as $cmtpgID => $cmtpg) {
552
+						$select_values[$cmtpgID] = $cmtpg->name();
553
+						$default_value = array_key_exists($cmtpgID, $templates_for_event) ? $cmtpgID : $default_value;
554 554
 					}
555 555
 				}
556 556
 				//if there is no $default_value then we set it as the global
557
-				$default_value = empty( $default_value ) ? $mtpgID : $default_value;
558
-				$edit_url = EEH_URL::add_query_args_and_nonce( array( 'page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value ), admin_url( 'admin.php' ) );
559
-				$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' ) );
560
-				$st_args[ 'mt_name' ] = ucwords( $mtp_obj->label[ 'singular' ] );
561
-				$st_args[ 'mt_slug' ] = $mtpg->message_type();
562
-				$st_args[ 'messenger_slug' ] = $this->name;
563
-				$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' );
557
+				$default_value = empty($default_value) ? $mtpgID : $default_value;
558
+				$edit_url = EEH_URL::add_query_args_and_nonce(array('page' => 'espresso_messages', 'action' => 'edit_message_template', 'id' => $default_value), admin_url('admin.php'));
559
+				$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'));
560
+				$st_args['mt_name'] = ucwords($mtp_obj->label['singular']);
561
+				$st_args['mt_slug'] = $mtpg->message_type();
562
+				$st_args['messenger_slug'] = $this->name;
563
+				$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');
564 564
 				//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).
565
-				$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>';
566
-				$st_args[ 'create_button' ] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ? $st_args[ 'create_button' ] : '';
567
-				$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>' : '';
568
-				$selector_rows .= EEH_Template::display_template( $template_row_path, $st_args, true );
565
+				$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>';
566
+				$st_args['create_button'] = EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template') ? $st_args['create_button'] : '';
567
+				$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>' : '';
568
+				$selector_rows .= EEH_Template::display_template($template_row_path, $st_args, true);
569 569
 			}
570 570
 		}
571 571
 
572 572
 		//if no selectors present then get out.
573
-		if ( empty( $selector_rows ) ) {
573
+		if (empty($selector_rows)) {
574 574
 			return '';
575 575
 		}
576 576
 
577 577
 		$template_args['selector_rows'] = $selector_rows;
578
-		return EEH_Template::display_template( $template_wrapper_path, $template_args, TRUE );
578
+		return EEH_Template::display_template($template_wrapper_path, $template_args, TRUE);
579 579
 	}
580 580
 
581 581
 
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 	 * @return array $this->_template_fields
591 591
 	 */
592 592
 	public function get_template_fields() {
593
-		$template_fields = apply_filters( 'FHEE__' . get_class($this) . '__get_template_fields', $this->_template_fields, $this );
594
-		$template_fields = apply_filters( 'FHEE__EE_messenger__get_template_fields', $template_fields, $this );
593
+		$template_fields = apply_filters('FHEE__'.get_class($this).'__get_template_fields', $this->_template_fields, $this);
594
+		$template_fields = apply_filters('FHEE__EE_messenger__get_template_fields', $template_fields, $this);
595 595
 		return $template_fields;
596 596
 	}
597 597
 
@@ -605,9 +605,9 @@  discard block
 block discarded – undo
605 605
 	 * @param mixed $value
606 606
 	 */
607 607
 	protected function _set_template_value($item, $value) {
608
-		if ( array_key_exists($item, $this->_template_fields) ) {
609
-			$prop = '_' . $item;
610
-			$this->{$prop}= $value;
608
+		if (array_key_exists($item, $this->_template_fields)) {
609
+			$prop = '_'.$item;
610
+			$this->{$prop} = $value;
611 611
 		}
612 612
 	}
613 613
 
@@ -618,8 +618,8 @@  discard block
 block discarded – undo
618 618
 	 * @return bool Very important that all messengers return bool for successful send or not.  Error messages can be
619 619
 	 *              added to EE_Error.
620 620
 	 */
621
-	public function send_message( $message, EE_message_type $message_type ) {
622
-		$this->_validate_and_setup( $message );
621
+	public function send_message($message, EE_message_type $message_type) {
622
+		$this->_validate_and_setup($message);
623 623
 		$this->_incoming_message_type = $message_type;
624 624
 		return $this->_send_message();
625 625
 	}
@@ -633,28 +633,28 @@  discard block
 block discarded – undo
633 633
 	 * @param  bool   $send    true we will actually use the _send method (for test sends). FALSE we just return preview
634 634
 	 * @return string          return the message html content
635 635
 	 */
636
-	public function get_preview( EE_Message $message, EE_message_type $message_type, $send = false ) {
637
-		$this->_validate_and_setup( $message );
636
+	public function get_preview(EE_Message $message, EE_message_type $message_type, $send = false) {
637
+		$this->_validate_and_setup($message);
638 638
 
639 639
 		$this->_incoming_message_type = $message_type;
640 640
 
641
-		if ( $send ) {
641
+		if ($send) {
642 642
 			//are we overriding any existing template fields?
643 643
 			$settings = $this->get_existing_test_settings();
644
-			if ( ! empty( $settings ) ) {
645
-				foreach ( $settings as $field => $value ) {
646
-					$this->_set_template_value( $field, $value );
644
+			if ( ! empty($settings)) {
645
+				foreach ($settings as $field => $value) {
646
+					$this->_set_template_value($field, $value);
647 647
 				}
648 648
 			}
649 649
 		}
650 650
 
651 651
 		//enqueue preview js so that any links/buttons on the page are disabled.
652
-		if ( ! $send ) {
652
+		if ( ! $send) {
653 653
 			// the below may seem like duplication.  However, typically if a messenger enqueues scripts/styles,
654 654
 			// it deregisters all existing wp scripts and styles first.  So the second hook ensures our previewer still gets setup.
655
-			add_action( 'admin_enqueue_scripts', array( $this, 'add_preview_script' ), 10 );
656
-			add_action( 'wp_enqueue_scripts', array( $this, 'add_preview_script' ), 10 );
657
-			add_action( 'AHEE__EE_messenger__enqueue_scripts_styles', array( $this, 'add_preview_script' ), 10 );
655
+			add_action('admin_enqueue_scripts', array($this, 'add_preview_script'), 10);
656
+			add_action('wp_enqueue_scripts', array($this, 'add_preview_script'), 10);
657
+			add_action('AHEE__EE_messenger__enqueue_scripts_styles', array($this, 'add_preview_script'), 10);
658 658
 		}
659 659
 
660 660
 		return $send ? $this->_send_message() : $this->_preview();
@@ -672,10 +672,10 @@  discard block
 block discarded – undo
672 672
 	 */
673 673
 	public function add_preview_script() {
674 674
 		//error message
675
-		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' );
676
-		wp_register_script( 'ee-messages-preview-js', EE_LIBRARIES_URL . 'messages/messenger/assets/js/ee-messages-preview.js', array( 'jquery' ), EVENT_ESPRESSO_VERSION, true );
677
-		wp_localize_script( 'ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings );
678
-		wp_enqueue_script( 'ee-messages-preview-js' );
675
+		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');
676
+		wp_register_script('ee-messages-preview-js', EE_LIBRARIES_URL.'messages/messenger/assets/js/ee-messages-preview.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
677
+		wp_localize_script('ee-messages-preview-js', 'eei18n', EE_Registry::$i18n_js_strings);
678
+		wp_enqueue_script('ee-messages-preview-js');
679 679
 	}
680 680
 
681 681
 
@@ -686,13 +686,13 @@  discard block
 block discarded – undo
686 686
 	 * @param  EE_Message $message
687 687
 	 * @throws EE_Error
688 688
 	 */
689
-	protected function _validate_and_setup( EE_Message $message ) {
689
+	protected function _validate_and_setup(EE_Message $message) {
690 690
 		$template_pack = $message->get_template_pack();
691 691
 		$variation = $message->get_template_pack_variation();
692 692
 
693 693
 		//verify we have the required template pack value on the $message object.
694
-		if ( ! $template_pack instanceof EE_Messages_Template_Pack ) {
695
-			throw new EE_Error( __('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso' ) );
694
+		if ( ! $template_pack instanceof EE_Messages_Template_Pack) {
695
+			throw new EE_Error(__('Incoming $message object must have an EE_Messages_Template_Pack object available.', 'event_espresso'));
696 696
 		}
697 697
 
698 698
 		$this->_tmp_pack = $template_pack;
@@ -701,11 +701,11 @@  discard block
 block discarded – undo
701 701
 
702 702
 		$template_fields = $this->get_template_fields();
703 703
 
704
-		foreach ( $template_fields as $template => $value ) {
705
-			if ( $template !== 'extra' ) {
706
-				$column_value = $message->get_field_or_extra_meta( 'MSG_' . $template );
704
+		foreach ($template_fields as $template => $value) {
705
+			if ($template !== 'extra') {
706
+				$column_value = $message->get_field_or_extra_meta('MSG_'.$template);
707 707
 				$message_template_value = $column_value ? $column_value : null;
708
-				$this->_set_template_value( $template, $message_template_value );
708
+				$this->_set_template_value($template, $message_template_value);
709 709
 			}
710 710
 		}
711 711
 	}
@@ -720,19 +720,19 @@  discard block
 block discarded – undo
720 720
 	 * @return string
721 721
 	 * @throws \EE_Error
722 722
 	 */
723
-	protected function _get_main_template( $preview = FALSE ) {
723
+	protected function _get_main_template($preview = FALSE) {
724 724
 		$type = $preview ? 'preview' : 'main';
725 725
 
726
-		$wrapper_template = $this->_tmp_pack->get_wrapper( $this->name, $type );
726
+		$wrapper_template = $this->_tmp_pack->get_wrapper($this->name, $type);
727 727
 
728 728
 		//check file exists and is readable
729
-		if ( !is_readable( $wrapper_template ) )
730
-			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 ) );
729
+		if ( ! is_readable($wrapper_template))
730
+			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));
731 731
 
732 732
 		//add message type to template args
733 733
 		$this->_template_args['message_type'] = $this->_incoming_message_type;
734 734
 
735
-		return EEH_Template::display_template( $wrapper_template, $this->_template_args, TRUE );
735
+		return EEH_Template::display_template($wrapper_template, $this->_template_args, TRUE);
736 736
 	}
737 737
 
738 738
 
@@ -768,9 +768,9 @@  discard block
 block discarded – undo
768 768
 	 */
769 769
 	public function get_existing_test_settings() {
770 770
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
771
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
771
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
772 772
 		$settings = $Message_Resource_Manager->get_active_messengers_option();
773
-		return isset( $settings[ $this->name ]['test_settings'] ) ? $settings[ $this->name ]['test_settings'] : array();
773
+		return isset($settings[$this->name]['test_settings']) ? $settings[$this->name]['test_settings'] : array();
774 774
 	}
775 775
 
776 776
 
@@ -782,12 +782,12 @@  discard block
 block discarded – undo
782 782
 	 * @param $settings
783 783
 	 * @return bool success/fail
784 784
 	 */
785
-	public function set_existing_test_settings( $settings ) {
785
+	public function set_existing_test_settings($settings) {
786 786
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
787
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
787
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
788 788
 		$existing = $Message_Resource_Manager->get_active_messengers_option();
789
-		$existing[ $this->name ]['test_settings'] = $settings;
790
-		return $Message_Resource_Manager->update_active_messengers_option( $existing );
789
+		$existing[$this->name]['test_settings'] = $settings;
790
+		return $Message_Resource_Manager->update_active_messengers_option($existing);
791 791
 	}
792 792
 
793 793
 
@@ -800,21 +800,21 @@  discard block
 block discarded – undo
800 800
 	 * @param string $field The field to retrieve the label for
801 801
 	 * @return string        	  The label
802 802
 	 */
803
-	public function get_field_label( $field ) {
803
+	public function get_field_label($field) {
804 804
 		//first let's see if the field requests is in the top level array.
805
-		if ( isset( $this->_template_fields[$field] ) && !empty( $this->_template_fields[$field]['label'] ) )
805
+		if (isset($this->_template_fields[$field]) && ! empty($this->_template_fields[$field]['label']))
806 806
 			return $this->_template[$field]['label'];
807 807
 
808 808
 		//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.
809
-		if ( isset( $this->_template_fields['extra'] ) && !empty( $this->_template_fields['extra'][$field] ) && !empty( $this->_template_fields['extra'][$field]['main']['label'] )  )
809
+		if (isset($this->_template_fields['extra']) && ! empty($this->_template_fields['extra'][$field]) && ! empty($this->_template_fields['extra'][$field]['main']['label']))
810 810
 			return $this->_template_fields['extra'][$field]['main']['label'];
811 811
 
812 812
 		//now it's possible this field may just be existing in any of the extra array items.
813
-		if ( !empty( $this->_template_fields['extra'] ) && is_array( $this->_template_fields['extra'] ) ) {
814
-			foreach ( $this->_template_fields['extra'] as $main_field => $subfields ) {
815
-				if ( !is_array( $subfields ) )
813
+		if ( ! empty($this->_template_fields['extra']) && is_array($this->_template_fields['extra'])) {
814
+			foreach ($this->_template_fields['extra'] as $main_field => $subfields) {
815
+				if ( ! is_array($subfields))
816 816
 					continue;
817
-				if ( isset( $subfields[$field] ) && !empty( $subfields[$field]['label'] ) )
817
+				if (isset($subfields[$field]) && ! empty($subfields[$field]['label']))
818 818
 					return $subfields[$field]['label'];
819 819
 			}
820 820
 		}
@@ -835,7 +835,7 @@  discard block
 block discarded – undo
835 835
 	 *
836 836
 	 * @return void
837 837
 	 */
838
-	public function do_secondary_messenger_hooks( $sending_messenger_name ) {
838
+	public function do_secondary_messenger_hooks($sending_messenger_name) {
839 839
 		return;
840 840
 	}
841 841
 
Please login to merge, or discard this patch.
core/libraries/messages/validators/EE_Messages_Validator.core.php 1 patch
Spacing   +100 added lines, -100 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -119,9 +119,9 @@  discard block
 block discarded – undo
119 119
 	 * @param       $context
120 120
 	 * @throws \EE_Error
121 121
 	 */
122
-	public function __construct( $fields, $context ) {
122
+	public function __construct($fields, $context) {
123 123
 		//check that _m_name and _mt_name have been set by child class otherwise we get out.
124
-		if ( empty($this->_m_name ) || empty( $this->_mt_name) )
124
+		if (empty($this->_m_name) || empty($this->_mt_name))
125 125
 			throw new EE_Error(
126 126
 				__(
127 127
 					'EE_Messages_Validator child classes MUST set the $_m_name and $_mt_name property.  Check that the child class is doing this',
@@ -167,14 +167,14 @@  discard block
 block discarded – undo
167 167
 	 */
168 168
 	private function _load_objects() {
169 169
 		//load messenger
170
-		$messenger = ucwords( str_replace( '_', ' ', $this->_m_name ) );
171
-		$messenger = str_replace( ' ', '_', $messenger );
172
-		$messenger = 'EE_' . $messenger . '_messenger';
170
+		$messenger = ucwords(str_replace('_', ' ', $this->_m_name));
171
+		$messenger = str_replace(' ', '_', $messenger);
172
+		$messenger = 'EE_'.$messenger.'_messenger';
173 173
 
174
-		if ( ! class_exists( $messenger ) ) {
174
+		if ( ! class_exists($messenger)) {
175 175
 			throw new EE_Error(
176 176
 				sprintf(
177
-					__( 'There is no messenger class for the given string (%s)', 'event_espresso' ),
177
+					__('There is no messenger class for the given string (%s)', 'event_espresso'),
178 178
 					$this->_m_name
179 179
 				)
180 180
 			);
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 		$this->_messenger = new $messenger();
184 184
 
185 185
 		//load message type
186
-		$message_type = ucwords( str_replace( '_', ' ', $this->_mt_name ) );
187
-		$message_type = str_replace( ' ', '_', $message_type );
188
-		$message_type = 'EE_' . $message_type . '_message_type';
186
+		$message_type = ucwords(str_replace('_', ' ', $this->_mt_name));
187
+		$message_type = str_replace(' ', '_', $message_type);
188
+		$message_type = 'EE_'.$message_type.'_message_type';
189 189
 
190
-		if ( !class_exists( $message_type ) ) {
190
+		if ( ! class_exists($message_type)) {
191 191
 			throw new EE_Error(
192 192
 				sprintf(
193
-					__( 'There is no message type class for the given string (%s)', 'event_espresso' ),
193
+					__('There is no message type class for the given string (%s)', 'event_espresso'),
194 194
 					$this->_mt_name
195 195
 				)
196 196
 			);
@@ -227,25 +227,25 @@  discard block
 block discarded – undo
227 227
 		$shortcode_groups = $mt_codes;
228 228
 		$groups_per_field = array();
229 229
 
230
-		foreach ( $msgr_validator as $field => $config ) {
231
-			if ( empty($config) || !isset($config['shortcodes']) )
232
-				continue;  //Nothing to see here.
233
-			$groups_per_field[$field] = array_intersect( $config['shortcodes'], $mt_codes );
234
-			$shortcode_groups = array_merge( $config[ 'shortcodes'], $shortcode_groups );
230
+		foreach ($msgr_validator as $field => $config) {
231
+			if (empty($config) || ! isset($config['shortcodes']))
232
+				continue; //Nothing to see here.
233
+			$groups_per_field[$field] = array_intersect($config['shortcodes'], $mt_codes);
234
+			$shortcode_groups = array_merge($config['shortcodes'], $shortcode_groups);
235 235
 		}
236 236
 
237
-		$shortcode_groups = array_unique( $shortcode_groups);
237
+		$shortcode_groups = array_unique($shortcode_groups);
238 238
 
239 239
 		// okay now we've got our groups.
240 240
 		// Let's get the codes from the objects into an array indexed by group for easy retrieval later.
241 241
 		$codes_from_objs = array();
242 242
 
243
-		foreach ( $shortcode_groups as $group ) {
244
-			$ref = ucwords( str_replace('_', ' ', $group ) );
245
-			$ref = str_replace( ' ', '_', $ref );
246
-			$classname = 'EE_' . $ref . '_Shortcodes';
247
-			if ( class_exists( $classname ) ) {
248
-				$a = new ReflectionClass( $classname );
243
+		foreach ($shortcode_groups as $group) {
244
+			$ref = ucwords(str_replace('_', ' ', $group));
245
+			$ref = str_replace(' ', '_', $ref);
246
+			$classname = 'EE_'.$ref.'_Shortcodes';
247
+			if (class_exists($classname)) {
248
+				$a = new ReflectionClass($classname);
249 249
 				$obj = $a->newInstance();
250 250
 				$codes_from_objs[$group] = $obj->get_shortcodes();
251 251
 			}
@@ -254,8 +254,8 @@  discard block
 block discarded – undo
254 254
 
255 255
 		//let's just replace the $mt shortcode group indexes with the actual shortcodes (unique)
256 256
 		$final_mt_codes = array();
257
-		foreach ( $mt_codes as $group ) {
258
-			$final_mt_codes = array_merge( $final_mt_codes, $codes_from_objs[$group] );
257
+		foreach ($mt_codes as $group) {
258
+			$final_mt_codes = array_merge($final_mt_codes, $codes_from_objs[$group]);
259 259
 		}
260 260
 
261 261
 		$mt_codes = $final_mt_codes;
@@ -263,60 +263,60 @@  discard block
 block discarded – undo
263 263
 
264 264
 		// k now in this next loop we're going to loop through $msgr_validator again
265 265
 		// and setup the _validators property from the data we've setup so far.
266
-		foreach ( $msgr_validator as $field => $config ) {
266
+		foreach ($msgr_validator as $field => $config) {
267 267
 			//if required shortcode is not in our list of codes for the given field, then we skip this field.
268 268
 			$required = isset($config['required'])
269 269
 				? array_intersect($config['required'], array_keys($mt_codes))
270 270
 				: true;
271
-			if ( empty($required) )
271
+			if (empty($required))
272 272
 				continue;
273 273
 
274 274
 			//If we have an override then we use it to indicate the codes we want.
275
-			if ( isset( $this->_valid_shortcodes_modifier[$context][$field] ) ) {
276
-				$this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group(
277
-					$this->_valid_shortcodes_modifier[ $context ][ $field ],
275
+			if (isset($this->_valid_shortcodes_modifier[$context][$field])) {
276
+				$this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
277
+					$this->_valid_shortcodes_modifier[$context][$field],
278 278
 					$codes_from_objs
279 279
 				);
280 280
 			}
281 281
 
282 282
 			//if we have specific shortcodes for a field then we need to use them
283
-			else if ( isset( $groups_per_field[$field] ) ) {
284
-				$this->_validators[ $field ][ 'shortcodes' ] = $this->_reassemble_valid_shortcodes_from_group(
285
-					$groups_per_field[ $field ],
283
+			else if (isset($groups_per_field[$field])) {
284
+				$this->_validators[$field]['shortcodes'] = $this->_reassemble_valid_shortcodes_from_group(
285
+					$groups_per_field[$field],
286 286
 					$codes_from_objs
287 287
 				);
288 288
 			}
289 289
 
290 290
 			//if empty config then we're assuming we're just going to use the shortcodes from the message type context
291
-			else if ( empty( $config ) ) {
291
+			else if (empty($config)) {
292 292
 				$this->_validators[$field]['shortcodes'] = $mt_codes;
293 293
 			}
294 294
 
295 295
 			//if we have specific shortcodes then we need to use them
296
-			else if ( isset($config['specific_shortcodes'] ) ) {
296
+			else if (isset($config['specific_shortcodes'])) {
297 297
 				$this->_validators[$field]['shortcodes'] = $config['specific_shortcodes'];
298 298
 			}
299 299
 
300 300
 			//otherwise the shortcodes are what is set by the messenger for that field
301 301
 			else {
302
-				foreach ( $config['shortcodes'] as $group ) {
302
+				foreach ($config['shortcodes'] as $group) {
303 303
 					$this->_validators[$field]['shortcodes'] = isset($this->_validators[$field]['shortcodes'])
304
-						? array_merge( $this->_validators[$field]['shortcodes'], $codes_from_objs[$group] )
304
+						? array_merge($this->_validators[$field]['shortcodes'], $codes_from_objs[$group])
305 305
 						: $codes_from_objs[$group];
306 306
 				}
307 307
 			}
308 308
 
309 309
 			//now let's just make sure that any excluded specific shortcodes are removed.
310 310
 			$specific_excludes = $this->get_specific_shortcode_excludes();
311
-			if ( isset( $specific_excludes[$field] ) ) {
312
-				foreach( $specific_excludes[$field] as $sex ) {
313
-					if ( isset( $this->_validators[$field]['shortcodes'][$sex] ) )
314
-						unset( $this->_validators[$field]['shortcodes'][$sex] );
311
+			if (isset($specific_excludes[$field])) {
312
+				foreach ($specific_excludes[$field] as $sex) {
313
+					if (isset($this->_validators[$field]['shortcodes'][$sex]))
314
+						unset($this->_validators[$field]['shortcodes'][$sex]);
315 315
 				}
316 316
 			}
317 317
 
318 318
 			//hey! don't forget to include the type if present!
319
-			$this->_validators[$field]['type'] = isset( $config['type'] ) ? $config['type'] : NULL;
319
+			$this->_validators[$field]['type'] = isset($config['type']) ? $config['type'] : NULL;
320 320
 		}
321 321
 	}
322 322
 
@@ -344,7 +344,7 @@  discard block
 block discarded – undo
344 344
 	public function get_specific_shortcode_excludes() {
345 345
 		//specific validator filter
346 346
 		$shortcode_excludes = apply_filters(
347
-			'FHEE__' . get_class( $this ) . '__get_specific_shortcode_excludes;',
347
+			'FHEE__'.get_class($this).'__get_specific_shortcode_excludes;',
348 348
 			$this->_specific_shortcode_excludes,
349 349
 			$this->_context
350 350
 		);
@@ -372,20 +372,20 @@  discard block
 block discarded – undo
372 372
 		//some defaults
373 373
 		$template_fields = $this->_messenger->get_template_fields();
374 374
 		//loop through the fields and check!
375
-		foreach ( $this->_fields as $field => $value ) {
375
+		foreach ($this->_fields as $field => $value) {
376 376
 			$this->_errors[$field] = array();
377 377
 			$err_msg = '';
378 378
 			$field_label = '';
379 379
 			//if field is not present in the _validators array then we continue
380
-			if ( !isset( $this->_validators[$field] ) ) {
381
-				unset( $this->_errors[$field] );
380
+			if ( ! isset($this->_validators[$field])) {
381
+				unset($this->_errors[$field]);
382 382
 				continue;
383 383
 			}
384 384
 
385 385
 			//get the translated field label!
386 386
 			//first check if it's in the main fields list
387
-			if ( isset( $template_fields[$field] ) ) {
388
-				if ( empty( $template_fields[$field] ) )
387
+			if (isset($template_fields[$field])) {
388
+				if (empty($template_fields[$field]))
389 389
 					$field_label = $field; //most likely the field is found in the 'extra' array.
390 390
 				else
391 391
 					$field_label = $template_fields[$field]['label'];
@@ -393,16 +393,16 @@  discard block
 block discarded – undo
393 393
 
394 394
 			// if field label is empty OR is equal to the current field
395 395
 			// then we need to loop through the 'extra' fields in the template_fields config (if present)
396
-			if ( isset( $template_fields['extra'] ) && ( empty($field_label) ) || $field_label == $field ) {
397
-				foreach( $template_fields['extra'] as $main_field => $secondary_field ) {
398
-					foreach ( $secondary_field as $name => $values ) {
399
-						if ( $name == $field ) {
396
+			if (isset($template_fields['extra']) && (empty($field_label)) || $field_label == $field) {
397
+				foreach ($template_fields['extra'] as $main_field => $secondary_field) {
398
+					foreach ($secondary_field as $name => $values) {
399
+						if ($name == $field) {
400 400
 							$field_label = $values['label'];
401 401
 						}
402 402
 
403 403
 						// if we've got a 'main' secondary field, let's see if that matches what field we're on
404 404
 						// which means it contains the label for this field.
405
-						if ( $name == 'main' && $main_field == $field_label )
405
+						if ($name == 'main' && $main_field == $field_label)
406 406
 							$field_label = $values['label'];
407 407
 					}
408 408
 				}
@@ -410,27 +410,27 @@  discard block
 block discarded – undo
410 410
 
411 411
 			//field is present. Let's validate shortcodes first (but only if shortcodes present).
412 412
 			if (
413
-				isset( $this->_validators[ $field ][ 'shortcodes' ] )
414
-				&& ! empty( $this->_validators[ $field ][ 'shortcodes' ] )
413
+				isset($this->_validators[$field]['shortcodes'])
414
+				&& ! empty($this->_validators[$field]['shortcodes'])
415 415
 			) {
416
-				$invalid_shortcodes = $this->_invalid_shortcodes( $value, $this->_validators[$field]['shortcodes'] );
416
+				$invalid_shortcodes = $this->_invalid_shortcodes($value, $this->_validators[$field]['shortcodes']);
417 417
 				// if true then that means there is a returned error message
418 418
 				// that we'll need to add to the _errors array for this field.
419
-				if ( $invalid_shortcodes ) {
419
+				if ($invalid_shortcodes) {
420 420
 					$v_s = array_keys($this->_validators[$field]['shortcodes']);
421 421
 					$err_msg = sprintf(
422 422
 						__(
423 423
 							'%3$sThe following shortcodes were found in the "%1$s" field that ARE not valid: %2$s%4$s',
424 424
 							'event_espresso'
425 425
 						),
426
-						'<strong>' . $field_label . '</strong>',
426
+						'<strong>'.$field_label.'</strong>',
427 427
 						$invalid_shortcodes,
428 428
 						'<p>',
429 429
 						'</p >'
430 430
 					);
431 431
 					$err_msg .= sprintf(
432
-						__( '%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso' ),
433
-						implode( ', ', $v_s ),
432
+						__('%2$sValid shortcodes for this field are: %1$s%3$s', 'event_espresso'),
433
+						implode(', ', $v_s),
434 434
 						'<strong>',
435 435
 						'</strong>'
436 436
 					);
@@ -438,10 +438,10 @@  discard block
 block discarded – undo
438 438
 			}
439 439
 
440 440
 			//if there's a "type" to be validated then let's do that too.
441
-			if ( isset( $this->_validators[$field]['type'] ) && !empty( $this->_validators[$field]['type'] ) ) {
442
-				switch ( $this->_validators[$field]['type'] ) {
441
+			if (isset($this->_validators[$field]['type']) && ! empty($this->_validators[$field]['type'])) {
442
+				switch ($this->_validators[$field]['type']) {
443 443
 					case 'number' :
444
-						if ( !is_numeric($value) )
444
+						if ( ! is_numeric($value))
445 445
 							$err_msg .= sprintf(
446 446
 								__(
447 447
 									'%3$sThe %1$s field is supposed to be a number. The value given (%2$s)  is not.  Please double-check and make sure the field contains a number%4$s',
@@ -455,7 +455,7 @@  discard block
 block discarded – undo
455 455
 						break;
456 456
 					case 'email' :
457 457
 						$valid_email = $this->_validate_email($value);
458
-						if ( !$valid_email )
458
+						if ( ! $valid_email)
459 459
 							$err_msg .= htmlentities(
460 460
 								sprintf(
461 461
 									__(
@@ -472,23 +472,23 @@  discard block
 block discarded – undo
472 472
 			}
473 473
 
474 474
 			//if $err_msg isn't empty let's setup the _errors array for this field.
475
-			if ( !empty($err_msg ) ) {
475
+			if ( ! empty($err_msg)) {
476 476
 				$this->_errors[$field]['msg'] = $err_msg;
477 477
 			} else {
478
-				unset( $this->_errors[$field] );
478
+				unset($this->_errors[$field]);
479 479
 			}
480 480
 		}
481 481
 
482 482
 		// if we have ANY errors, then we want to make sure we return the values
483 483
 		// for ALL the fields so the user doesn't have to retype them all.
484
-		if ( !empty( $this->_errors ) ) {
485
-			foreach ( $this->_fields as $field => $value ) {
484
+		if ( ! empty($this->_errors)) {
485
+			foreach ($this->_fields as $field => $value) {
486 486
 				$this->_errors[$field]['value'] = stripslashes($value);
487 487
 			}
488 488
 		}
489 489
 
490 490
 		//return any errors or just TRUE if everything validates
491
-		return empty( $this->_errors ) ? TRUE : $this->_errors;
491
+		return empty($this->_errors) ? TRUE : $this->_errors;
492 492
 	}
493 493
 
494 494
 
@@ -501,10 +501,10 @@  discard block
 block discarded – undo
501 501
 	 * @param  array $codes_from_objs All the codes available.
502 502
 	 * @return array                   an array of actual shortcodes (that will be used for validation).
503 503
 	 */
504
-	private function _reassemble_valid_shortcodes_from_group( $groups, $codes_from_objs ) {
504
+	private function _reassemble_valid_shortcodes_from_group($groups, $codes_from_objs) {
505 505
 		$shortcodes = array();
506
-		foreach ( $groups as $group ) {
507
-			$shortcodes = array_merge( $shortcodes, $codes_from_objs[$group] );
506
+		foreach ($groups as $group) {
507
+			$shortcodes = array_merge($shortcodes, $codes_from_objs[$group]);
508 508
 		}
509 509
 		return $shortcodes;
510 510
 	}
@@ -523,29 +523,29 @@  discard block
 block discarded – undo
523 523
 	 */
524 524
 	protected function _invalid_shortcodes($value, $valid_shortcodes) {
525 525
 		//first we need to go through the string and get the shortcodes in the string
526
-		preg_match_all( '/(\[.+?\])/', $value, $matches );
526
+		preg_match_all('/(\[.+?\])/', $value, $matches);
527 527
 		$incoming_shortcodes = (array) $matches[0];
528 528
 
529 529
 		//get a diff of the shortcodes in the string vs the valid shortcodes
530
-		$diff = array_diff( $incoming_shortcodes, array_keys($valid_shortcodes) );
530
+		$diff = array_diff($incoming_shortcodes, array_keys($valid_shortcodes));
531 531
 
532 532
 		//we need to account for custom codes so let's loop through the diff and remove any of those type of codes
533
-		foreach ( $diff as $ind => $code ) {
534
-			if ( preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code ) ) {
533
+		foreach ($diff as $ind => $code) {
534
+			if (preg_match('/(\[[A-Za-z0-9\_]+_\*)/', $code)) {
535 535
 				//strip the shortcode so we just have the BASE string (i.e. [ANSWER_*] )
536 536
 				$dynamic_sc = preg_replace('/(_\*+.+)/', '_*]', $code);
537 537
 				//does this exist in the $valid_shortcodes?  If so then unset.
538
-				if ( isset( $valid_shortcodes[$dynamic_sc] ) ) {
539
-					unset( $diff[$ind] );
538
+				if (isset($valid_shortcodes[$dynamic_sc])) {
539
+					unset($diff[$ind]);
540 540
 				}
541 541
 			}
542 542
 		}
543 543
 
544
-		if ( empty( $diff ) ) return FALSE; //there is no diff, we have no invalid shortcodes, so return
544
+		if (empty($diff)) return FALSE; //there is no diff, we have no invalid shortcodes, so return
545 545
 
546 546
 		//made it here? then let's assemble the error message
547
-		$invalid_shortcodes = implode( '</strong>,<strong>', $diff );
548
-		$invalid_shortcodes = '<strong>' . $invalid_shortcodes . '</strong>';
547
+		$invalid_shortcodes = implode('</strong>,<strong>', $diff);
548
+		$invalid_shortcodes = '<strong>'.$invalid_shortcodes.'</strong>';
549 549
 		return $invalid_shortcodes;
550 550
 	}
551 551
 
@@ -557,13 +557,13 @@  discard block
 block discarded – undo
557 557
 	 * @param  string $value incoming value to validate
558 558
 	 * @return bool        true if the string validates, false if it doesn't
559 559
 	 */
560
-	protected function _validate_email( $value ) {
560
+	protected function _validate_email($value) {
561 561
 		$validate = TRUE;
562 562
 		$or_val = $value;
563 563
 
564 564
 		// empty strings will validate because this is how a message template
565 565
 		// for a particular context can be "turned off" (if there is no email then no message)
566
-		if ( empty( $value ) )
566
+		if (empty($value))
567 567
 			return $validate;
568 568
 
569 569
 		// first determine if there ARE any shortcodes.
@@ -581,19 +581,19 @@  discard block
 block discarded – undo
581 581
 		// its possible that this message is being "turned off" for a particular context
582 582
 
583 583
 
584
-		if ( !empty($or_val) && empty($value) )
584
+		if ( ! empty($or_val) && empty($value))
585 585
 			return $validate;
586 586
 
587 587
 		//trim any commas from beginning and end of string ( after whitespace trimmed );
588
-		$value = trim( trim($value), ',' );
588
+		$value = trim(trim($value), ',');
589 589
 
590 590
 
591 591
 		//next we need to split up the string if its comma delimited.
592 592
 		$emails = explode(',', $value);
593 593
 		$empty = FALSE; //used to indicate that there is an empty comma.
594 594
 		//now let's loop through the emails and do our checks
595
-		foreach ( $emails as $email ) {
596
-			if ( empty($email) ) {
595
+		foreach ($emails as $email) {
596
+			if (empty($email)) {
597 597
 				$empty = TRUE;
598 598
 				continue;
599 599
 			}
@@ -601,20 +601,20 @@  discard block
 block discarded – undo
601 601
 			//trim whitespace
602 602
 			$email = trim($email);
603 603
 			//either its of type "[email protected]", or its of type "fname lname <[email protected]>"
604
-			if(is_email($email)){
604
+			if (is_email($email)) {
605 605
 				continue;
606
-			}else{
606
+			} else {
607 607
 				$matches = array();
608
-				$validate = preg_match( '/(.*)<(.+)>/', $email, $matches ) ? TRUE : FALSE;
609
-				if( $validate && is_email($matches[2])){
608
+				$validate = preg_match('/(.*)<(.+)>/', $email, $matches) ? TRUE : FALSE;
609
+				if ($validate && is_email($matches[2])) {
610 610
 					continue;
611
-				}else{
611
+				} else {
612 612
 					return false;
613 613
 				}
614 614
 			}
615 615
 		}
616 616
 
617
-		$validate = $empty && !$has_shortcodes ? FALSE : $validate;
617
+		$validate = $empty && ! $has_shortcodes ? FALSE : $validate;
618 618
 
619 619
 		return $validate;
620 620
 
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 	 * @throws Exception
631 631
 	 * @return mixed
632 632
 	 */
633
-	public function __get( $property ) {
633
+	public function __get($property) {
634 634
 		$expected_properties_map = array(
635 635
 			/**
636 636
 			 * @deprecated 4.9.0
@@ -642,15 +642,15 @@  discard block
 block discarded – undo
642 642
 			'_MSGTYP' => '_message_type'
643 643
 		);
644 644
 
645
-		if ( isset( $expected_properties_map[ $property ] ) ) {
646
-			return $this->{$expected_properties_map[ $property ]};
645
+		if (isset($expected_properties_map[$property])) {
646
+			return $this->{$expected_properties_map[$property]};
647 647
 		}
648 648
 
649 649
 		throw new Exception(
650 650
 			sprintf(
651
-				__( 'The property %1$s being requested on %2$s does not exist', 'event_espresso' ),
651
+				__('The property %1$s being requested on %2$s does not exist', 'event_espresso'),
652 652
 				$property,
653
-				get_class( $this )
653
+				get_class($this)
654 654
 			)
655 655
 		);
656 656
 	}
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Generator.lib.php 2 patches
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -458,8 +458,8 @@  discard block
 block discarded – undo
458 458
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this
459 459
 		//context is turned off) EXCEPT if we're previewing
460 460
 		if ( empty( $templates['to'][ $context ] )
461
-		     && ! $this->_generation_queue->get_message_repository()->is_preview()
462
-		     && ! $this->_current_messenger->allow_empty_to_field() ) {
461
+			 && ! $this->_generation_queue->get_message_repository()->is_preview()
462
+			 && ! $this->_current_messenger->allow_empty_to_field() ) {
463 463
 			//we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field.
464 464
 			return false;
465 465
 		}
@@ -575,9 +575,9 @@  discard block
 block discarded – undo
575 575
 		 * Check if there is any generation data, but only if this is not for a preview.
576 576
 		 */
577 577
 		if ( ! $this->_generation_queue->get_message_repository()->get_generation_data()
578
-		     && (
579
-			     ! $this->_generation_queue->get_message_repository()->is_preview()
580
-			     && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' )
578
+			 && (
579
+				 ! $this->_generation_queue->get_message_repository()->is_preview()
580
+				 && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' )
581 581
 		) {
582 582
 			$this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' );
583 583
 		}
Please login to merge, or discard this patch.
Spacing   +113 added lines, -113 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' )) { exit( 'No direct script access allowed' ); }
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
 
3 3
 /**
4 4
  * This class is used for generating EE_Message objects with given info.
@@ -116,17 +116,17 @@  discard block
 block discarded – undo
116 116
 	 *
117 117
 	 * @return EE_Messages_Queue  The new queue for holding generated EE_Message objects.
118 118
 	 */
119
-	public function generate( $save = true ) {
119
+	public function generate($save = true) {
120 120
 		//iterate through the messages in the queue, generate, and add to new queue.
121 121
 		$this->_generation_queue->get_message_repository()->rewind();
122
-		while ( $this->_generation_queue->get_message_repository()->valid() ) {
122
+		while ($this->_generation_queue->get_message_repository()->valid()) {
123 123
 			//reset "current" properties
124 124
 			$this->_reset_current_properties();
125 125
 
126 126
 			/** @type EE_Message $msg */
127 127
 			$msg = $this->_generation_queue->get_message_repository()->current();
128 128
 
129
-			if ( $this->_verify() ) {
129
+			if ($this->_verify()) {
130 130
 				//let's get generating!
131 131
 				$this->_generate();
132 132
 			}
@@ -138,26 +138,26 @@  discard block
 block discarded – undo
138 138
 			$this->_generation_queue->get_message_repository()->next();
139 139
 			$next_msg = $this->_generation_queue->get_message_repository()->current();
140 140
 			//restore pointer to current item
141
-			$this->_generation_queue->get_message_repository()->set_current( $msg );
141
+			$this->_generation_queue->get_message_repository()->set_current($msg);
142 142
 
143 143
 			//if there are error messages then let's set the status and the error message.
144
-			if ( $this->_error_msg ) {
144
+			if ($this->_error_msg) {
145 145
 				//if the status is already debug only, then let's leave it at that.
146
-				if ( $msg->STS_ID() !== EEM_Message::status_debug_only ) {
147
-					$msg->set_STS_ID( EEM_Message::status_failed );
146
+				if ($msg->STS_ID() !== EEM_Message::status_debug_only) {
147
+					$msg->set_STS_ID(EEM_Message::status_failed);
148 148
 				}
149 149
 				$msg->set_error_message(
150
-					__( 'Message failed to generate for the following reasons: ' )
150
+					__('Message failed to generate for the following reasons: ')
151 151
 					. "\n"
152
-					. implode( "\n", $this->_error_msg )
152
+					. implode("\n", $this->_error_msg)
153 153
 				);
154
-				$msg->set_modified( time() );
154
+				$msg->set_modified(time());
155 155
 			} else {
156 156
 				//remove from db
157 157
 				$this->_generation_queue->get_message_repository()->delete();
158 158
 			}
159 159
 			//next item
160
-			$this->_generation_queue->get_message_repository()->set_current( $next_msg );
160
+			$this->_generation_queue->get_message_repository()->set_current($next_msg);
161 161
 		}
162 162
 
163 163
 		//generation queue is ALWAYS saved to record any errors in the generation process.
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 		 * so a EE_Extra_Meta entry could be created and attached to the EE_Message.  In those cases the save flag is
171 171
 		 * irrelevant.
172 172
 		 */
173
-		if ( $save ) {
173
+		if ($save) {
174 174
 			$this->_ready_queue->save();
175 175
 		}
176 176
 
@@ -188,7 +188,7 @@  discard block
 block discarded – undo
188 188
 	protected function _reset_current_properties() {
189 189
 		$this->_verified = false;
190 190
 		//make sure any _data value in the current message type is reset
191
-		if ( $this->_current_message_type instanceof EE_message_type ) {
191
+		if ($this->_current_message_type instanceof EE_message_type) {
192 192
 			$this->_current_message_type->reset_data();
193 193
 		}
194 194
 		$this->_current_messenger = $this->_current_message_type = $this->_current_data_handler = null;
@@ -207,7 +207,7 @@  discard block
 block discarded – undo
207 207
 	 */
208 208
 	protected function _generate() {
209 209
 		//double check verification has run and that everything is ready to work with (saves us having to validate everything again).
210
-		if ( ! $this->_verified ) {
210
+		if ( ! $this->_verified) {
211 211
 			return false; //get out because we don't have a valid setup to work with.
212 212
 		}
213 213
 
@@ -217,34 +217,34 @@  discard block
 block discarded – undo
217 217
 				$this->_current_data_handler,
218 218
 				$this->_generation_queue->get_message_repository()->current()->context()
219 219
 			);
220
-		} catch ( EE_Error $e ) {
220
+		} catch (EE_Error $e) {
221 221
 			$this->_error_msg[] = $e->getMessage();
222 222
 			return false;
223 223
 		}
224 224
 
225 225
 
226 226
 		//if no addressees then get out because there is nothing to generation (possible bad data).
227
-		if ( ! $this->_valid_addressees( $addressees ) ) {
228
-			$this->_generation_queue->get_message_repository()->current()->set_STS_ID( EEM_Message::status_debug_only );
229
-			$this->_error_msg[] = __( 'This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects.  There were no attendees prepared by the data handler.
230
-			  Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso' );
227
+		if ( ! $this->_valid_addressees($addressees)) {
228
+			$this->_generation_queue->get_message_repository()->current()->set_STS_ID(EEM_Message::status_debug_only);
229
+			$this->_error_msg[] = __('This is not a critical error but an informational notice. Unable to generate messages EE_Messages_Addressee objects.  There were no attendees prepared by the data handler.
230
+			  Sometimes this is because messages only get generated for certain registration statuses. For example, the ticket notice message type only goes to approved registrations.', 'event_espresso');
231 231
 			return false;
232 232
 		}
233 233
 
234 234
 		$message_template_group = $this->_get_message_template_group();
235 235
 
236 236
 		//in the unlikely event there is no EE_Message_Template_Group available, get out!
237
-		if ( ! $message_template_group instanceof EE_Message_Template_Group ) {
238
-			$this->_error_msg[] = __( 'Unable to get the Message Templates for the Message being generated.  No message template group accessible.', 'event_espresso' );
237
+		if ( ! $message_template_group instanceof EE_Message_Template_Group) {
238
+			$this->_error_msg[] = __('Unable to get the Message Templates for the Message being generated.  No message template group accessible.', 'event_espresso');
239 239
 			return false;
240 240
 		}
241 241
 
242 242
 		//get formatted templates for using to parse and setup EE_Message objects.
243
-		$templates = $this->_get_templates( $message_template_group );
243
+		$templates = $this->_get_templates($message_template_group);
244 244
 
245 245
 
246 246
 		//setup new EE_Message objects (and add to _ready_queue)
247
-		return $this->_assemble_messages( $addressees, $templates, $message_template_group );
247
+		return $this->_assemble_messages($addressees, $templates, $message_template_group);
248 248
 	}
249 249
 
250 250
 
@@ -262,17 +262,17 @@  discard block
 block discarded – undo
262 262
 		//so let's use that.
263 263
 		$GRP_ID = $this->_generation_queue->get_message_repository()->current()->GRP_ID();
264 264
 
265
-		if ( $GRP_ID ) {
265
+		if ($GRP_ID) {
266 266
 			//attempt to retrieve from repo first
267
-			$GRP = $this->_template_collection->get_by_ID( $GRP_ID );
268
-			if ( $GRP instanceof EE_Message_Template_Group ) {
269
-				return $GRP;  //got it!
267
+			$GRP = $this->_template_collection->get_by_ID($GRP_ID);
268
+			if ($GRP instanceof EE_Message_Template_Group) {
269
+				return $GRP; //got it!
270 270
 			}
271 271
 
272 272
 			//nope don't have it yet.  Get from DB then add to repo
273
-			$GRP = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
274
-			if ( $GRP instanceof EE_Message_Template_Group ) {
275
-				$this->_template_collection->add( $GRP );
273
+			$GRP = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
274
+			if ($GRP instanceof EE_Message_Template_Group) {
275
+				$this->_template_collection->add($GRP);
276 276
 			}
277 277
 			return $GRP;
278 278
 		}
@@ -291,41 +291,41 @@  discard block
 block discarded – undo
291 291
 		//in vanilla EE we're assuming there's only one event.
292 292
 		//However, if there are multiple events then we'll just use the default templates instead of different
293 293
 		// templates per event (which could create problems).
294
-		if ( count( $this->_current_data_handler->events ) === 1 ) {
295
-			foreach ( $this->_current_data_handler->events as $event ) {
294
+		if (count($this->_current_data_handler->events) === 1) {
295
+			foreach ($this->_current_data_handler->events as $event) {
296 296
 				$EVT_ID = $event['ID'];
297 297
 			}
298 298
 		}
299 299
 
300 300
 		//before going any further, let's see if its in the queue
301
-		$GRP = $this->_template_collection->get_by_key( $this->_template_collection->get_key( $this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID ) );
301
+		$GRP = $this->_template_collection->get_by_key($this->_template_collection->get_key($this->_current_messenger->name, $this->_current_message_type->name, $EVT_ID));
302 302
 
303
-		if ( $GRP instanceof EE_Message_Template_Group ) {
303
+		if ($GRP instanceof EE_Message_Template_Group) {
304 304
 			return $GRP;
305 305
 		}
306 306
 
307 307
 		//nope still no GRP?
308 308
 		//first we get the global template in case it has an override set.
309
-		$global_template_qa = array_merge( array( 'MTP_is_global' => true ), $template_qa );
310
-		$global_GRP = EEM_Message_Template_Group::instance()->get_one( array( $global_template_qa ) );
309
+		$global_template_qa = array_merge(array('MTP_is_global' => true), $template_qa);
310
+		$global_GRP = EEM_Message_Template_Group::instance()->get_one(array($global_template_qa));
311 311
 
312 312
 		//if this is an override, then we just return it.
313
-		if ( $global_GRP instanceof EE_Message_Template_Group && $global_GRP->get( 'MTP_is_override' ) ) {
314
-			$this->_template_collection->add( $global_GRP, $EVT_ID );
313
+		if ($global_GRP instanceof EE_Message_Template_Group && $global_GRP->get('MTP_is_override')) {
314
+			$this->_template_collection->add($global_GRP, $EVT_ID);
315 315
 			return $global_GRP;
316 316
 		}
317 317
 
318 318
 		//STILL here? Okay that means we want to see if there is event specific group and if there is we return it,
319 319
 		//otherwise we return the global group we retrieved.
320
-		if ( $EVT_ID ) {
320
+		if ($EVT_ID) {
321 321
 			$template_qa['Event.EVT_ID'] = $EVT_ID;
322 322
 		}
323 323
 
324
-		$GRP = EEM_Message_Template_Group::instance()->get_one( array( $template_qa ) );
324
+		$GRP = EEM_Message_Template_Group::instance()->get_one(array($template_qa));
325 325
 		$GRP = $GRP instanceof EE_Message_Template_Group ? $GRP : $global_GRP;
326 326
 
327
-		if ( $GRP instanceof EE_Message_Template_Group ) {
328
-			$this->_template_collection->add( $GRP, $EVT_ID );
327
+		if ($GRP instanceof EE_Message_Template_Group) {
328
+			$this->_template_collection->add($GRP, $EVT_ID);
329 329
 			return $GRP;
330 330
 		}
331 331
 
@@ -349,15 +349,15 @@  discard block
 block discarded – undo
349 349
 	 *                      )
350 350
 	 *                  )
351 351
 	 */
352
-	protected function _get_templates( EE_Message_Template_Group $message_template_group ) {
352
+	protected function _get_templates(EE_Message_Template_Group $message_template_group) {
353 353
 		$templates = array();
354 354
 		$context_templates = $message_template_group->context_templates();
355
-		foreach ( $context_templates as $context => $template_fields ) {
356
-			foreach ( $template_fields as $template_field => $template_obj ) {
357
-				if ( ! $template_obj instanceof EE_Message_Template ) {
355
+		foreach ($context_templates as $context => $template_fields) {
356
+			foreach ($template_fields as $template_field => $template_obj) {
357
+				if ( ! $template_obj instanceof EE_Message_Template) {
358 358
 					continue;
359 359
 				}
360
-				$templates[ $template_field ][ $context ] = $template_obj->get( 'MTP_content' );
360
+				$templates[$template_field][$context] = $template_obj->get('MTP_content');
361 361
 			}
362 362
 		}
363 363
 		return $templates;
@@ -379,20 +379,20 @@  discard block
 block discarded – undo
379 379
 	 *                get added to the queue with EEM_Message::status_idle, unsuccessfully generated messages will get added
380 380
 	 *                to the queue as EEM_Message::status_failed.  Very rarely should "false" be returned from this method.
381 381
 	 */
382
-	protected function _assemble_messages( $addressees, $templates, EE_Message_Template_Group $message_template_group ) {
382
+	protected function _assemble_messages($addressees, $templates, EE_Message_Template_Group $message_template_group) {
383 383
 
384 384
 		//if templates are empty then get out because we can't generate anything.
385
-		if ( ! $templates ) {
385
+		if ( ! $templates) {
386 386
 			return false;
387 387
 		}
388 388
 
389 389
 		//We use this as the counter for generated messages because don't forget we may be executing this inside of a
390 390
 		//generation_queue.  So _ready_queue may have generated EE_Message objects already.
391 391
 		$generated_count = 0;
392
-		foreach ( $addressees as $context => $recipients ) {
393
-			foreach ( $recipients as $recipient ) {
394
-				$message = $this->_setup_message_object( $context, $recipient, $templates, $message_template_group );
395
-				if ( $message instanceof EE_Message ) {
392
+		foreach ($addressees as $context => $recipients) {
393
+			foreach ($recipients as $recipient) {
394
+				$message = $this->_setup_message_object($context, $recipient, $templates, $message_template_group);
395
+				if ($message instanceof EE_Message) {
396 396
 					$this->_ready_queue->add(
397 397
 						$message,
398 398
 						array(),
@@ -403,7 +403,7 @@  discard block
 block discarded – undo
403 403
 				}
404 404
 
405 405
 				//if the current MSG being generated is for a test send then we'll only use ONE message in the generation.
406
-				if ( $this->_generation_queue->get_message_repository()->is_test_send() ) {
406
+				if ($this->_generation_queue->get_message_repository()->is_test_send()) {
407 407
 					break 2;
408 408
 				}
409 409
 			}
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	) {
433 433
 		//stuff we already know
434 434
 		$transaction_id = $recipient->txn instanceof EE_Transaction ? $recipient->txn->ID() : 0;
435
-		$transaction_id = empty( $transaction_id ) && $this->_current_data_handler->txn instanceof EE_Transaction
435
+		$transaction_id = empty($transaction_id) && $this->_current_data_handler->txn instanceof EE_Transaction
436 436
 			? $this->_current_data_handler->txn->ID()
437 437
 			: $transaction_id;
438 438
 		$message_fields = array(
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 
446 446
 		//recipient id and type should be on the EE_Messages_Addressee object but if this is empty, let's try to grab the
447 447
 		//info from the att_obj found in the EE_Messages_Addressee object.
448
-		if ( empty( $recipient->recipient_id ) || empty( $recipient->recipient_type ) ) {
448
+		if (empty($recipient->recipient_id) || empty($recipient->recipient_type)) {
449 449
 			$message_fields['MSG_recipient_ID'] = $recipient->att_obj instanceof EE_Attendee
450 450
 				? $recipient->att_obj->ID()
451 451
 				: 0;
@@ -454,7 +454,7 @@  discard block
 block discarded – undo
454 454
 			$message_fields['MSG_recipient_ID'] = $recipient->recipient_id;
455 455
 			$message_fields['MSG_recipient_type'] = $recipient->recipient_type;
456 456
 		}
457
-		$message = EE_Message_Factory::create( $message_fields );
457
+		$message = EE_Message_Factory::create($message_fields);
458 458
 
459 459
 		//grab valid shortcodes for shortcode parser
460 460
 		$mt_shortcodes = $this->_current_message_type->get_valid_shortcodes();
@@ -462,43 +462,43 @@  discard block
 block discarded – undo
462 462
 
463 463
 		//if the 'to' field is empty (messages will ALWAYS have a "to" field, then we get out because that means this
464 464
 		//context is turned off) EXCEPT if we're previewing
465
-		if ( empty( $templates['to'][ $context ] )
465
+		if (empty($templates['to'][$context])
466 466
 		     && ! $this->_generation_queue->get_message_repository()->is_preview()
467
-		     && ! $this->_current_messenger->allow_empty_to_field() ) {
467
+		     && ! $this->_current_messenger->allow_empty_to_field()) {
468 468
 			//we silently exit here and do NOT record a fail because the message is "turned off" by having no "to" field.
469 469
 			return false;
470 470
 		}
471 471
 		$error_msg = array();
472
-		foreach ( $templates as $field => $field_context ) {
472
+		foreach ($templates as $field => $field_context) {
473 473
 			$error_msg = array();
474 474
 			//let's setup the valid shortcodes for the incoming context.
475
-			$valid_shortcodes = $mt_shortcodes[ $context ];
475
+			$valid_shortcodes = $mt_shortcodes[$context];
476 476
 			//merge in valid shortcodes for the field.
477
-			$shortcodes = isset($m_shortcodes[ $field ]) ? $m_shortcodes[ $field ] : $valid_shortcodes;
478
-			if ( isset( $templates[ $field ][ $context ] ) ) {
477
+			$shortcodes = isset($m_shortcodes[$field]) ? $m_shortcodes[$field] : $valid_shortcodes;
478
+			if (isset($templates[$field][$context])) {
479 479
 				//prefix field.
480
-				$column_name = 'MSG_' . $field;
480
+				$column_name = 'MSG_'.$field;
481 481
 				try {
482 482
 					$content = $this->_shortcode_parser->parse_message_template(
483
-						$templates[ $field ][ $context ],
483
+						$templates[$field][$context],
484 484
 						$recipient,
485 485
 						$shortcodes,
486 486
 						$this->_current_message_type,
487 487
 						$this->_current_messenger,
488 488
 						$message );
489
-					$message->set_field_or_extra_meta( $column_name, $content );
490
-				} catch ( EE_Error $e ) {
491
-					$error_msg[] = sprintf( __( 'There was a problem generating the content for the field %s: %s', 'event_espresso' ), $field, $e->getMessage() );
492
-					$message->set_STS_ID( EEM_Message::status_failed );
489
+					$message->set_field_or_extra_meta($column_name, $content);
490
+				} catch (EE_Error $e) {
491
+					$error_msg[] = sprintf(__('There was a problem generating the content for the field %s: %s', 'event_espresso'), $field, $e->getMessage());
492
+					$message->set_STS_ID(EEM_Message::status_failed);
493 493
 				}
494 494
 			}
495 495
 		}
496 496
 
497
-		if ( $message->STS_ID() === EEM_Message::status_failed ) {
498
-			$error_msg = __( 'There were problems generating this message:', 'event_espresso' ) . "\n" . implode( "\n", $error_msg );
499
-			$message->set_error_message( $error_msg );
497
+		if ($message->STS_ID() === EEM_Message::status_failed) {
498
+			$error_msg = __('There were problems generating this message:', 'event_espresso')."\n".implode("\n", $error_msg);
499
+			$message->set_error_message($error_msg);
500 500
 		} else {
501
-			$message->set_STS_ID( EEM_Message::status_idle );
501
+			$message->set_STS_ID(EEM_Message::status_idle);
502 502
 		}
503 503
 		return $message;
504 504
 	}
@@ -532,14 +532,14 @@  discard block
 block discarded – undo
532 532
 	 * @param array $addressees  Keys correspond to contexts for the message type and values are EE_Messages_Addressee[]
533 533
 	 * @return bool
534 534
 	 */
535
-	protected function _valid_addressees( $addressees ) {
536
-		if ( ! $addressees || ! is_array( $addressees ) ) {
535
+	protected function _valid_addressees($addressees) {
536
+		if ( ! $addressees || ! is_array($addressees)) {
537 537
 			return false;
538 538
 		}
539 539
 
540
-		foreach( $addressees as $addressee_array ) {
541
-			foreach ( $addressee_array as $addressee ) {
542
-				if ( ! $addressee instanceof EE_Messages_Addressee ) {
540
+		foreach ($addressees as $addressee_array) {
541
+			foreach ($addressee_array as $addressee) {
542
+				if ( ! $addressee instanceof EE_Messages_Addressee) {
543 543
 					return false;
544 544
 				}
545 545
 			}
@@ -560,19 +560,19 @@  discard block
 block discarded – undo
560 560
 	protected function _validate_messenger_and_message_type() {
561 561
 
562 562
 		//first are there any existing error messages?  If so then return.
563
-		if ( $this->_error_msg ) {
563
+		if ($this->_error_msg) {
564 564
 			return false;
565 565
 		}
566 566
 		/** @type EE_Message $message */
567 567
 		$message = $this->_generation_queue->get_message_repository()->current();
568 568
 		try {
569
-			$this->_current_messenger = $message->valid_messenger( true ) ? $message->messenger_object() : null;
570
-		} catch ( Exception $e ) {
569
+			$this->_current_messenger = $message->valid_messenger(true) ? $message->messenger_object() : null;
570
+		} catch (Exception $e) {
571 571
 			$this->_error_msg[] = $e->getMessage();
572 572
 		}
573 573
 		try {
574
-			$this->_current_message_type = $message->valid_message_type( true ) ? $message->message_type_object() : null;
575
-		} catch ( Exception $e ) {
574
+			$this->_current_message_type = $message->valid_message_type(true) ? $message->message_type_object() : null;
575
+		} catch (Exception $e) {
576 576
 			$this->_error_msg[] = $e->getMessage();
577 577
 		}
578 578
 
@@ -584,10 +584,10 @@  discard block
 block discarded – undo
584 584
 			     ! $this->_generation_queue->get_message_repository()->is_preview()
585 585
 			     && $this->_generation_queue->get_message_repository()->get_data_handler() !== 'EE_Messages_Preview_incoming_data' )
586 586
 		) {
587
-			$this->_error_msg[] = __( 'There is no generation data for this message. Unable to generate.' );
587
+			$this->_error_msg[] = __('There is no generation data for this message. Unable to generate.');
588 588
 		}
589 589
 
590
-		return empty( $this->_error_msg );
590
+		return empty($this->_error_msg);
591 591
 	}
592 592
 
593 593
 
@@ -604,7 +604,7 @@  discard block
 block discarded – undo
604 604
 
605 605
 		//First, are there any existing error messages?  If so, return because if there were errors elsewhere this can't
606 606
 		//be used anyways.
607
-		if ( $this->_error_msg ) {
607
+		if ($this->_error_msg) {
608 608
 			return false;
609 609
 		}
610 610
 
@@ -613,29 +613,29 @@  discard block
 block discarded – undo
613 613
 		/** @type EE_Messages_incoming_data $data_handler_class_name - well not really... just the class name actually */
614 614
 		$data_handler_class_name = $this->_generation_queue->get_message_repository()->get_data_handler()
615 615
 			? $this->_generation_queue->get_message_repository()->get_data_handler()
616
-			: 'EE_Messages_' .  $this->_current_message_type->get_data_handler( $generation_data ) . '_incoming_data';
616
+			: 'EE_Messages_'.$this->_current_message_type->get_data_handler($generation_data).'_incoming_data';
617 617
 
618 618
 		//If this EE_Message is for a preview, then let's switch out to the preview data handler.
619
-		if ( $this->_generation_queue->get_message_repository()->is_preview() ) {
620
-			$data_handler_class_name  = 'EE_Messages_Preview_incoming_data';
619
+		if ($this->_generation_queue->get_message_repository()->is_preview()) {
620
+			$data_handler_class_name = 'EE_Messages_Preview_incoming_data';
621 621
 		}
622 622
 
623 623
 		//First get the class name for the data handler (and also verifies it exists.
624
-		if ( ! class_exists( $data_handler_class_name ) ) {
624
+		if ( ! class_exists($data_handler_class_name)) {
625 625
 			$this->_error_msg[] = sprintf(
626
-				__( 'The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes.  Looking for %s.', 'event_espresso' ),
626
+				__('The included data handler class name does not match any valid, accessible, "EE_Messages_incoming_data" classes.  Looking for %s.', 'event_espresso'),
627 627
 				$data_handler_class_name
628 628
 			);
629 629
 			return false;
630 630
 		}
631 631
 
632 632
 		//convert generation_data for data_handler_instantiation.
633
-		$generation_data = $data_handler_class_name::convert_data_from_persistent_storage( $generation_data );
633
+		$generation_data = $data_handler_class_name::convert_data_from_persistent_storage($generation_data);
634 634
 
635 635
 		//note, this may set error messages as well.
636
-		$this->_set_data_handler( $generation_data, $data_handler_class_name );
636
+		$this->_set_data_handler($generation_data, $data_handler_class_name);
637 637
 
638
-		return empty( $this->_error_msg );
638
+		return empty($this->_error_msg);
639 639
 	}
640 640
 
641 641
 
@@ -652,16 +652,16 @@  discard block
 block discarded – undo
652 652
 	 *
653 653
 	 * @return void.
654 654
 	 */
655
-	protected function _set_data_handler( $generating_data, $data_handler_class_name ) {
655
+	protected function _set_data_handler($generating_data, $data_handler_class_name) {
656 656
 		//valid classname for the data handler.  Now let's setup the key for the data handler repository to see if there
657 657
 		//is already a ready data handler in the repository.
658
-		$this->_current_data_handler = $this->_data_handler_collection->get_by_key( $this->_data_handler_collection->get_key( $data_handler_class_name, $generating_data ) );
659
-		if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data ) {
658
+		$this->_current_data_handler = $this->_data_handler_collection->get_by_key($this->_data_handler_collection->get_key($data_handler_class_name, $generating_data));
659
+		if ( ! $this->_current_data_handler instanceof EE_messages_incoming_data) {
660 660
 			//no saved data_handler in the repo so let's set one up and add it to the repo.
661 661
 			try {
662
-				$this->_current_data_handler = new $data_handler_class_name( $generating_data );
663
-				$this->_data_handler_collection->add( $this->_current_data_handler, $generating_data );
664
-			} catch( EE_Error $e ) {
662
+				$this->_current_data_handler = new $data_handler_class_name($generating_data);
663
+				$this->_data_handler_collection->add($this->_current_data_handler, $generating_data);
664
+			} catch (EE_Error $e) {
665 665
 				$this->_error_msg[] = $e->get_error();
666 666
 			}
667 667
 		}
@@ -681,13 +681,13 @@  discard block
 block discarded – undo
681 681
 	 * @param bool                   $preview Indicate whether this is being used for a preview or not.
682 682
 	 * @return mixed Prepped data for persisting to the queue.  false is returned if unable to prep data.
683 683
 	 */
684
-	protected function _prepare_data_for_queue( EE_Message_To_Generate $message_to_generate, $preview ) {
684
+	protected function _prepare_data_for_queue(EE_Message_To_Generate $message_to_generate, $preview) {
685 685
 		/** @type EE_Messages_incoming_data $data_handler - well not really... just the class name actually */
686
-		$data_handler = $message_to_generate->get_data_handler_class_name( $preview );
687
-		if ( ! $message_to_generate->valid() ) {
686
+		$data_handler = $message_to_generate->get_data_handler_class_name($preview);
687
+		if ( ! $message_to_generate->valid()) {
688 688
 			return false; //unable to get the data because the info in the EE_Message_To_Generate class is invalid.
689 689
 		}
690
-		return $data_handler::convert_data_for_persistent_storage( $message_to_generate->data() );
690
+		return $data_handler::convert_data_for_persistent_storage($message_to_generate->data());
691 691
 	}
692 692
 
693 693
 
@@ -700,26 +700,26 @@  discard block
 block discarded – undo
700 700
 	 * @param EE_Message_To_Generate $message_to_generate
701 701
 	 * @param bool                   $test_send Whether this is just a test send or not.  Typically used for previews.
702 702
 	 */
703
-	public function create_and_add_message_to_queue( EE_Message_To_Generate $message_to_generate, $test_send = false ) {
703
+	public function create_and_add_message_to_queue(EE_Message_To_Generate $message_to_generate, $test_send = false) {
704 704
 		//prep data
705
-		$data = $this->_prepare_data_for_queue( $message_to_generate, $message_to_generate->preview() );
705
+		$data = $this->_prepare_data_for_queue($message_to_generate, $message_to_generate->preview());
706 706
 
707 707
 		$message = $message_to_generate->get_EE_Message();
708 708
 
709 709
 		//is there a GRP_ID in the request?
710
-		if ( $GRP_ID = EE_Registry::instance()->REQ->get( 'GRP_ID' ) ) {
711
-			$message->set_GRP_ID( $GRP_ID );
710
+		if ($GRP_ID = EE_Registry::instance()->REQ->get('GRP_ID')) {
711
+			$message->set_GRP_ID($GRP_ID);
712 712
 		}
713 713
 
714
-		if ( $data === false ) {
715
-			$message->set_STS_ID( EEM_Message::status_failed );
716
-			$message->set_error_message( __( 'Unable to prepare data for persistence to the database.', 'event_espresso' ) );
714
+		if ($data === false) {
715
+			$message->set_STS_ID(EEM_Message::status_failed);
716
+			$message->set_error_message(__('Unable to prepare data for persistence to the database.', 'event_espresso'));
717 717
 		} else {
718 718
 			//make sure that the data handler is cached on the message as well
719 719
 			$data['data_handler_class_name'] = $message_to_generate->get_data_handler_class_name();
720 720
 		}
721 721
 
722
-		$this->_generation_queue->add( $message, $data, $message_to_generate->preview(), $test_send );
722
+		$this->_generation_queue->add($message, $data, $message_to_generate->preview(), $test_send);
723 723
 	}
724 724
 
725 725
 
Please login to merge, or discard this patch.
core/db_classes/EE_Message_Template_Group.class.php 1 patch
Spacing   +51 added lines, -51 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * EE_Message_Template_Group class
@@ -18,9 +18,9 @@  discard block
 block discarded – undo
18 18
 	 * @param string $timezone
19 19
 	 * @return EE_Message_Template_Group|mixed
20 20
 	 */
21
-	public static function new_instance( $props_n_values = array(), $timezone = '' ) {
22
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone );
23
-		return $has_object ? $has_object : new self( $props_n_values, FALSE, $timezone );
21
+	public static function new_instance($props_n_values = array(), $timezone = '') {
22
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
23
+		return $has_object ? $has_object : new self($props_n_values, FALSE, $timezone);
24 24
 	}
25 25
 
26 26
 
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 	 * @param string $timezone
31 31
 	 * @return EE_Message_Template_Group
32 32
 	 */
33
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = '' ) {
34
-		return new self( $props_n_values, TRUE, $timezone );
33
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '') {
34
+		return new self($props_n_values, TRUE, $timezone);
35 35
 	}
36 36
 
37 37
 
@@ -40,11 +40,11 @@  discard block
 block discarded – undo
40 40
 	 * @param bool $message_type
41 41
 	 * @throws EE_Error
42 42
 	 */
43
-	public function set_message_type( $message_type = FALSE ) {
44
-		if ( ! $message_type ) {
45
-			throw new EE_Error( __( 'Missing required value for the message_type parameter', 'event_espresso' ) );
43
+	public function set_message_type($message_type = FALSE) {
44
+		if ( ! $message_type) {
45
+			throw new EE_Error(__('Missing required value for the message_type parameter', 'event_espresso'));
46 46
 		}
47
-		$this->set( 'MTP_message_type', $message_type );
47
+		$this->set('MTP_message_type', $message_type);
48 48
 	}
49 49
 
50 50
 
@@ -53,11 +53,11 @@  discard block
 block discarded – undo
53 53
 	 * @param bool $messenger
54 54
 	 * @throws EE_Error
55 55
 	 */
56
-	public function set_messenger( $messenger = FALSE ) {
57
-		if ( ! $messenger ) {
58
-			throw new EE_Error( __( 'Missing required value for the messenger parameter', 'event_espresso' ) );
56
+	public function set_messenger($messenger = FALSE) {
57
+		if ( ! $messenger) {
58
+			throw new EE_Error(__('Missing required value for the messenger parameter', 'event_espresso'));
59 59
 		}
60
-		$this->set( 'MTP_messenger', $messenger );
60
+		$this->set('MTP_messenger', $messenger);
61 61
 	}
62 62
 
63 63
 
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 	 * @param bool $GRP_ID
67 67
 	 * @throws EE_Error
68 68
 	 */
69
-	public function set_group_template_id( $GRP_ID = FALSE ) {
70
-		if ( ! $GRP_ID ) {
71
-			throw new EE_Error( __( 'Missing required value for the message template group id', 'event_espresso' ) );
69
+	public function set_group_template_id($GRP_ID = FALSE) {
70
+		if ( ! $GRP_ID) {
71
+			throw new EE_Error(__('Missing required value for the message template group id', 'event_espresso'));
72 72
 		}
73
-		$this->set( 'GRP_ID', $GRP_ID );
73
+		$this->set('GRP_ID', $GRP_ID);
74 74
 	}
75 75
 
76 76
 
@@ -81,7 +81,7 @@  discard block
 block discarded – undo
81 81
 	 * @return int
82 82
 	 */
83 83
 	public function GRP_ID() {
84
-		return $this->get( 'GRP_ID' );
84
+		return $this->get('GRP_ID');
85 85
 	}
86 86
 
87 87
 
@@ -92,8 +92,8 @@  discard block
 block discarded – undo
92 92
 	 * @return int
93 93
 	 */
94 94
 	public function user() {
95
-		$user_id = $this->get( 'MTP_user_id' );
96
-		return empty( $user_id ) ? get_current_user_id() : $user_id;
95
+		$user_id = $this->get('MTP_user_id');
96
+		return empty($user_id) ? get_current_user_id() : $user_id;
97 97
 	}
98 98
 
99 99
 
@@ -116,7 +116,7 @@  discard block
 block discarded – undo
116 116
 	 * @return int
117 117
 	 */
118 118
 	public function count_events() {
119
-		return $this->count_related( 'Event' );
119
+		return $this->count_related('Event');
120 120
 	}
121 121
 
122 122
 
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
 	 * @return string
127 127
 	 */
128 128
 	public function name() {
129
-		return $this->get( 'MTP_name' );
129
+		return $this->get('MTP_name');
130 130
 	}
131 131
 
132 132
 
@@ -136,7 +136,7 @@  discard block
 block discarded – undo
136 136
 	 * @return string
137 137
 	 */
138 138
 	public function description() {
139
-		return $this->get( 'MTP_description' );
139
+		return $this->get('MTP_description');
140 140
 	}
141 141
 
142 142
 
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
 	 * @param  array $query_params like EEM_Base::get_all()
147 147
 	 * @return EE_Message_Template[]
148 148
 	 */
149
-	public function message_templates( $query_params = array() ) {
150
-		return $this->get_many_related( 'Message_Template', $query_params );
149
+	public function message_templates($query_params = array()) {
150
+		return $this->get_many_related('Message_Template', $query_params);
151 151
 	}
152 152
 
153 153
 
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 * @return string
159 159
 	 */
160 160
 	public function messenger() {
161
-		return $this->get( 'MTP_messenger' );
161
+		return $this->get('MTP_messenger');
162 162
 	}
163 163
 
164 164
 
@@ -175,10 +175,10 @@  discard block
 block discarded – undo
175 175
 	public function messenger_obj() {
176 176
 		$messenger = $this->messenger();
177 177
 		try {
178
-			$messenger = EEH_MSG_Template::messenger_obj( $messenger );
179
-		} catch( EE_Error $e ) {
178
+			$messenger = EEH_MSG_Template::messenger_obj($messenger);
179
+		} catch (EE_Error $e) {
180 180
 			//if an exception was thrown then let's deactivate this message template group because it means there is no class for this messenger in this group.
181
-			$this->set( 'MTP_is_active', false );
181
+			$this->set('MTP_is_active', false);
182 182
 			$this->save();
183 183
 			return null;
184 184
 		}
@@ -194,7 +194,7 @@  discard block
 block discarded – undo
194 194
 	 * @return string
195 195
 	 */
196 196
 	public function message_type() {
197
-		return $this->get( 'MTP_message_type' );
197
+		return $this->get('MTP_message_type');
198 198
 	}
199 199
 
200 200
 
@@ -212,10 +212,10 @@  discard block
 block discarded – undo
212 212
 	public function message_type_obj() {
213 213
 		$message_type = $this->message_type();
214 214
 		try {
215
-			$message_type = EEH_MSG_Template::message_type_obj( $message_type );
216
-		} catch(EE_Error $e) {
215
+			$message_type = EEH_MSG_Template::message_type_obj($message_type);
216
+		} catch (EE_Error $e) {
217 217
 			//if an exception was thrown then let's deactivate this message template group because it means there is no class for the message type in this group.
218
-			$this->set( 'MTP_is_active', false );
218
+			$this->set('MTP_is_active', false);
219 219
 			$this->save();
220 220
 			return null;
221 221
 		}
@@ -252,13 +252,13 @@  discard block
 block discarded – undo
252 252
 	 */
253 253
 	public function context_templates() {
254 254
 		$mtps_arr = array();
255
-		$mtps = $this->get_many_related( 'Message_Template' );
256
-		if ( empty( $mtps ) ) {
255
+		$mtps = $this->get_many_related('Message_Template');
256
+		if (empty($mtps)) {
257 257
 			return array();
258 258
 		}
259 259
 		//note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
260
-		foreach ( $mtps as $mtp ) {
261
-			$mtps_arr[ $mtp->get( 'MTP_context' ) ][ $mtp->get( 'MTP_template_field' ) ] = $mtp;
260
+		foreach ($mtps as $mtp) {
261
+			$mtps_arr[$mtp->get('MTP_context')][$mtp->get('MTP_template_field')] = $mtp;
262 262
 		}
263 263
 		return $mtps_arr;
264 264
 	}
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 * @return boolean true if it is, false if it isn't
271 271
 	 */
272 272
 	public function is_global() {
273
-		return $this->get( 'MTP_is_global' );
273
+		return $this->get('MTP_is_global');
274 274
 	}
275 275
 
276 276
 
@@ -280,7 +280,7 @@  discard block
 block discarded – undo
280 280
 	 * @return boolean true if it is, false if it isn't
281 281
 	 */
282 282
 	public function is_active() {
283
-		return $this->get( 'MTP_is_active' );
283
+		return $this->get('MTP_is_active');
284 284
 	}
285 285
 
286 286
 
@@ -296,10 +296,10 @@  discard block
 block discarded – undo
296 296
 	 * @param bool   $merged  If TRUE then we don't return shortcodes indexed by field but instead an array of the unique shortcodes for all the given (or all) fields.
297 297
 	 * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no shortcodes found.
298 298
 	 */
299
-	public function get_shortcodes( $context, $fields = array(), $merged = FALSE ) {
299
+	public function get_shortcodes($context, $fields = array(), $merged = FALSE) {
300 300
 		$messenger = $this->messenger();
301 301
 		$message_type = $this->message_type();
302
-		return EEH_MSG_Template::get_shortcodes( $message_type, $messenger, $fields, $context, $merged );
302
+		return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged);
303 303
 	}
304 304
 
305 305
 
@@ -340,7 +340,7 @@  discard block
 block discarded – undo
340 340
 	 * @return string
341 341
 	 */
342 342
 	public function get_template_pack_name() {
343
-		return $this->get_extra_meta( 'MTP_template_pack', true, 'default' );
343
+		return $this->get_extra_meta('MTP_template_pack', true, 'default');
344 344
 	}
345 345
 
346 346
 
@@ -355,8 +355,8 @@  discard block
 block discarded – undo
355 355
 	 */
356 356
 	public function get_template_pack() {
357 357
 		$pack_name = $this->get_template_pack_name();
358
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
359
-		return EEH_MSG_Template::get_template_pack( $pack_name );
358
+		EE_Registry::instance()->load_helper('MSG_Template');
359
+		return EEH_MSG_Template::get_template_pack($pack_name);
360 360
 	}
361 361
 
362 362
 
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
 	 * @return string
370 370
 	 */
371 371
 	public function get_template_pack_variation() {
372
-		return $this->get_extra_meta( 'MTP_variation', TRUE, 'default' );
372
+		return $this->get_extra_meta('MTP_variation', TRUE, 'default');
373 373
 	}
374 374
 
375 375
 
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	 * @param string $template_pack_name What message template pack is assigned.
382 382
 	 * @return int
383 383
 	 */
384
-	public function set_template_pack_name( $template_pack_name ) {
385
-		return $this->update_extra_meta( 'MTP_template_pack', $template_pack_name );
384
+	public function set_template_pack_name($template_pack_name) {
385
+		return $this->update_extra_meta('MTP_template_pack', $template_pack_name);
386 386
 	}
387 387
 
388 388
 
@@ -394,8 +394,8 @@  discard block
 block discarded – undo
394 394
 	 * @param string $variation What variation is being set on the message template group.
395 395
 	 * @return int
396 396
 	 */
397
-	public function set_template_pack_variation( $variation ) {
398
-		return $this->update_extra_meta( 'MTP_variation', $variation );
397
+	public function set_template_pack_variation($variation) {
398
+		return $this->update_extra_meta('MTP_variation', $variation);
399 399
 	}
400 400
 }
401 401
 //end EE_Message_Template_Group class
Please login to merge, or discard this patch.
modules/messages/EED_Messages.module.php 1 patch
Spacing   +182 added lines, -182 removed lines patch added patch discarded remove patch
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 	 * @return EED_Module
70 70
 	 */
71 71
 	public static function instance() {
72
-		return parent::get_instance( __CLASS__ );
72
+		return parent::get_instance(__CLASS__);
73 73
 	}
74 74
 
75 75
 
@@ -84,11 +84,11 @@  discard block
 block discarded – undo
84 84
 	 */
85 85
 	public static function set_hooks() {
86 86
 		//actions
87
-		add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 );
88
-		add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 2 );
87
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
88
+		add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 2);
89 89
 		//filters
90
-		add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 );
91
-		add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 );
90
+		add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
91
+		add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
92 92
 		//register routes
93 93
 		self::_register_routes();
94 94
 	}
@@ -101,16 +101,16 @@  discard block
 block discarded – undo
101 101
 	 */
102 102
 	public static function set_hooks_admin() {
103 103
 		//actions
104
-		add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 );
105
-		add_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array( 'EED_Messages', 'payment_reminder' ), 10 );
106
-		add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 3 );
107
-		add_action( 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', array( 'EED_Messages', 'send_newsletter_message' ), 10, 2 );
108
-		add_action( 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array( 'EED_Messages', 'cancelled_registration' ), 10 );
109
-		add_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', array( 'EED_Messages', 'process_admin_payment' ), 10, 1 );
104
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
105
+		add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array('EED_Messages', 'payment_reminder'), 10);
106
+		add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 3);
107
+		add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send__with_registrations', array('EED_Messages', 'send_newsletter_message'), 10, 2);
108
+		add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array('EED_Messages', 'cancelled_registration'), 10);
109
+		add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', array('EED_Messages', 'process_admin_payment'), 10, 1);
110 110
 		//filters
111
-		add_filter( 'FHEE__EE_Admin_Page___process_resend_registration__success', array( 'EED_Messages', 'process_resend' ), 10, 2 );
112
-		add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 );
113
-		add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 );
111
+		add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', array('EED_Messages', 'process_resend'), 10, 2);
112
+		add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
113
+		add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
114 114
 	}
115 115
 
116 116
 
@@ -124,11 +124,11 @@  discard block
 block discarded – undo
124 124
 	 * @return void
125 125
 	 */
126 126
 	protected static function _register_routes() {
127
-		EE_Config::register_route( 'msg_url_trigger', 'Messages', 'run' );
128
-		EE_Config::register_route( 'msg_cron_trigger', 'Messages', 'execute_batch_request' );
129
-		EE_Config::register_route( 'msg_browser_trigger', 'Messages', 'browser_trigger' );
130
-		EE_Config::register_route( 'msg_browser_error_trigger', 'Messages', 'browser_error_trigger' );
131
-		do_action( 'AHEE__EED_Messages___register_routes' );
127
+		EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
128
+		EE_Config::register_route('msg_cron_trigger', 'Messages', 'execute_batch_request');
129
+		EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
130
+		EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
131
+		do_action('AHEE__EED_Messages___register_routes');
132 132
 	}
133 133
 
134 134
 
@@ -139,18 +139,18 @@  discard block
 block discarded – undo
139 139
 	 * @since 4.9.0
140 140
 	 * @param WP $WP
141 141
 	 */
142
-	public function browser_trigger( $WP ) {
142
+	public function browser_trigger($WP) {
143 143
 		//ensure controller is loaded
144 144
 		self::_load_controller();
145
-		$token = EE_Registry::instance()->REQ->get( 'token' );
145
+		$token = EE_Registry::instance()->REQ->get('token');
146 146
 		try {
147
-			$mtg = new EE_Message_Generated_From_Token( $token, 'html', self::$_message_resource_manager );
148
-			self::$_MSG_PROCESSOR->generate_and_send_now( $mtg );
149
-		} catch( EE_Error $e ) {
150
-			$error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' );
147
+			$mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_message_resource_manager);
148
+			self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
149
+		} catch (EE_Error $e) {
150
+			$error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso');
151 151
 			// add specific message for developers if WP_DEBUG in on
152
-			$error_msg .= '||' . $e->getMessage();
153
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
152
+			$error_msg .= '||'.$e->getMessage();
153
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
154 154
 		}
155 155
 	}
156 156
 
@@ -166,20 +166,20 @@  discard block
 block discarded – undo
166 166
 	 * @since 4.9.0
167 167
 	 * @param $WP
168 168
 	 */
169
-	public function browser_error_trigger( $WP ) {
170
-		$token = EE_Registry::instance()->REQ->get( 'token' );
171
-		if ( $token ) {
172
-			$message = EEM_Message::instance()->get_one_by_token( $token );
173
-			if ( $message instanceof EE_Message ) {
174
-				header( 'HTTP/1.1 200 OK' );
175
-				$error_msg = nl2br( $message->error_message() );
169
+	public function browser_error_trigger($WP) {
170
+		$token = EE_Registry::instance()->REQ->get('token');
171
+		if ($token) {
172
+			$message = EEM_Message::instance()->get_one_by_token($token);
173
+			if ($message instanceof EE_Message) {
174
+				header('HTTP/1.1 200 OK');
175
+				$error_msg = nl2br($message->error_message());
176 176
 				?>
177 177
 				<!DOCTYPE html>
178 178
 				<html>
179 179
 					<head></head>
180 180
 					<body>
181
-						<?php echo empty( $error_msg )
182
-						? esc_html__( 'Unfortunately, we were unable to capture the error message for this message.', 'event_espresso' )
181
+						<?php echo empty($error_msg)
182
+						? esc_html__('Unfortunately, we were unable to capture the error message for this message.', 'event_espresso')
183 183
 						: wp_kses(
184 184
 							$error_msg,
185 185
 							array(
@@ -214,19 +214,19 @@  discard block
 block discarded – undo
214 214
 	 * @throws EE_Error
215 215
 	 * @return    void
216 216
 	 */
217
-	public function run( $WP ) {
217
+	public function run($WP) {
218 218
 		//ensure controller is loaded
219 219
 		self::_load_controller();
220 220
 		// attempt to process message
221 221
 		try {
222 222
 			/** @type EE_Message_To_Generate_From_Request $message_to_generate */
223
-			$message_to_generate = EE_Registry::instance()->load_lib( 'Message_To_Generate_From_Request' );
224
-			self::$_MSG_PROCESSOR->generate_and_send_now( $message_to_generate );
225
-		} catch ( EE_Error $e ) {
226
-			$error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' );
223
+			$message_to_generate = EE_Registry::instance()->load_lib('Message_To_Generate_From_Request');
224
+			self::$_MSG_PROCESSOR->generate_and_send_now($message_to_generate);
225
+		} catch (EE_Error $e) {
226
+			$error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso');
227 227
 			// add specific message for developers if WP_DEBUG in on
228
-			$error_msg .= '||' . $e->getMessage();
229
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
228
+			$error_msg .= '||'.$e->getMessage();
229
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
230 230
 		}
231 231
 	}
232 232
 
@@ -235,9 +235,9 @@  discard block
 block discarded – undo
235 235
 	 * This is triggered by the 'msg_cron_trigger' route.
236 236
 	 * @param WP $WP
237 237
 	 */
238
-	public function execute_batch_request( $WP ) {
238
+	public function execute_batch_request($WP) {
239 239
 		$this->run_cron();
240
-		header( 'HTTP/1.1 200 OK' );
240
+		header('HTTP/1.1 200 OK');
241 241
 		exit();
242 242
 	}
243 243
 
@@ -251,35 +251,35 @@  discard block
 block discarded – undo
251 251
 	public function run_cron() {
252 252
 		self::_load_controller();
253 253
 		//get required vars
254
-		$cron_type = EE_Registry::instance()->REQ->get( 'type' );
255
-		$transient_key = EE_Registry::instance()->REQ->get( 'key' );
254
+		$cron_type = EE_Registry::instance()->REQ->get('type');
255
+		$transient_key = EE_Registry::instance()->REQ->get('key');
256 256
 
257 257
 		//now let's verify transient, if not valid exit immediately
258
-		if ( ! get_transient( $transient_key ) ) {
258
+		if ( ! get_transient($transient_key)) {
259 259
 			/**
260 260
 			 * trigger error so this gets in the error logs.  This is important because it happens on a non-user request.
261 261
 			 */
262
-			trigger_error( esc_attr__( 'Invalid Request (Transient does not exist)', 'event_espresso' ) );
262
+			trigger_error(esc_attr__('Invalid Request (Transient does not exist)', 'event_espresso'));
263 263
 		}
264 264
 
265 265
 		//if made it here, lets' delete the transient to keep the db clean
266
-		delete_transient( $transient_key );
266
+		delete_transient($transient_key);
267 267
 
268
-		if ( apply_filters( 'FHEE__EED_Messages__run_cron__use_wp_cron', true ) ) {
268
+		if (apply_filters('FHEE__EED_Messages__run_cron__use_wp_cron', true)) {
269 269
 
270
-			$method = 'batch_' . $cron_type . '_from_queue';
271
-			if ( method_exists( self::$_MSG_PROCESSOR, $method ) ) {
270
+			$method = 'batch_'.$cron_type.'_from_queue';
271
+			if (method_exists(self::$_MSG_PROCESSOR, $method)) {
272 272
 				self::$_MSG_PROCESSOR->$method();
273 273
 			} else {
274 274
 				//no matching task
275 275
 				/**
276 276
 				 * trigger error so this gets in the error logs.  This is important because it happens on a non user request.
277 277
 				 */
278
-				trigger_error( esc_attr( sprintf( __( 'There is no task corresponding to this route %s', 'event_espresso' ), $cron_type ) ) );
278
+				trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), $cron_type)));
279 279
 			}
280 280
 		}
281 281
 
282
-		do_action( 'FHEE__EED_Messages__run_cron__end' );
282
+		do_action('FHEE__EED_Messages__run_cron__end');
283 283
 	}
284 284
 
285 285
 
@@ -295,9 +295,9 @@  discard block
 block discarded – undo
295 295
 	 *
296 296
 	 * @return EE_Messages_Template_Pack
297 297
 	 */
298
-	public static function get_template_pack( $template_pack_name ) {
299
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
300
-		return EEH_MSG_Template::get_template_pack( $template_pack_name );
298
+	public static function get_template_pack($template_pack_name) {
299
+		EE_Registry::instance()->load_helper('MSG_Template');
300
+		return EEH_MSG_Template::get_template_pack($template_pack_name);
301 301
 	}
302 302
 
303 303
 
@@ -311,14 +311,14 @@  discard block
 block discarded – undo
311 311
 	 * @return EE_Messages_Template_Pack[]
312 312
 	 */
313 313
 	public static function get_template_packs() {
314
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
314
+		EE_Registry::instance()->load_helper('MSG_Template');
315 315
 
316 316
 		//for backward compat, let's make sure this returns in the same format as originally.
317 317
 		$template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
318 318
 		$template_pack_collection->rewind();
319 319
 		$template_packs = array();
320
-		while ( $template_pack_collection->valid() ) {
321
-			$template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current();
320
+		while ($template_pack_collection->valid()) {
321
+			$template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current();
322 322
 			$template_pack_collection->next();
323 323
 		}
324 324
 		return $template_packs;
@@ -334,14 +334,14 @@  discard block
 block discarded – undo
334 334
 	 * @return void
335 335
 	 */
336 336
 	public static function set_autoloaders() {
337
-		if ( empty( self::$_MSG_PATHS ) ) {
337
+		if (empty(self::$_MSG_PATHS)) {
338 338
 			self::_set_messages_paths();
339
-			foreach ( self::$_MSG_PATHS as $path ) {
340
-				EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $path );
339
+			foreach (self::$_MSG_PATHS as $path) {
340
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
341 341
 			}
342 342
 			// add aliases
343
-			EEH_Autoloader::add_alias( 'EE_messages', 'EE_messages' );
344
-			EEH_Autoloader::add_alias( 'EE_messenger', 'EE_messenger' );
343
+			EEH_Autoloader::add_alias('EE_messages', 'EE_messages');
344
+			EEH_Autoloader::add_alias('EE_messenger', 'EE_messenger');
345 345
 		}
346 346
 	}
347 347
 
@@ -369,10 +369,10 @@  discard block
 block discarded – undo
369 369
 			'shortcodes',
370 370
 			);
371 371
 		$paths = array();
372
-		foreach ( $dir_ref as $index => $dir ) {
373
-			$paths[ $index ] = EE_LIBRARIES . $dir;
372
+		foreach ($dir_ref as $index => $dir) {
373
+			$paths[$index] = EE_LIBRARIES.$dir;
374 374
 		}
375
-		self::$_MSG_PATHS = apply_filters( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths );
375
+		self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
376 376
 	}
377 377
 
378 378
 
@@ -383,12 +383,12 @@  discard block
 block discarded – undo
383 383
 	 * @return void
384 384
 	 */
385 385
 	protected static function _load_controller() {
386
-		if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor ) {
387
-			EE_Registry::instance()->load_core( 'Request_Handler' );
386
+		if ( ! self::$_MSG_PROCESSOR instanceof EE_Messages_Processor) {
387
+			EE_Registry::instance()->load_core('Request_Handler');
388 388
 			self::set_autoloaders();
389
-			self::$_EEMSG = EE_Registry::instance()->load_lib( 'messages' );
390
-			self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib( 'Messages_Processor' );
391
-			self::$_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
389
+			self::$_EEMSG = EE_Registry::instance()->load_lib('messages');
390
+			self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor');
391
+			self::$_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
392 392
 		}
393 393
 	}
394 394
 
@@ -397,10 +397,10 @@  discard block
 block discarded – undo
397 397
 	/**
398 398
 	 * @param EE_Transaction $transaction
399 399
 	 */
400
-	public static function payment_reminder( EE_Transaction $transaction ) {
400
+	public static function payment_reminder(EE_Transaction $transaction) {
401 401
 		self::_load_controller();
402
-		$data = array( $transaction, null );
403
-		self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'payment_reminder', $data );
402
+		$data = array($transaction, null);
403
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
404 404
 	}
405 405
 
406 406
 
@@ -411,14 +411,14 @@  discard block
 block discarded – undo
411 411
 	 * @param  EE_Payment object
412 412
 	 * @return void
413 413
 	 */
414
-	public static function payment( EE_Transaction $transaction, EE_Payment $payment ) {
414
+	public static function payment(EE_Transaction $transaction, EE_Payment $payment) {
415 415
 		self::_load_controller();
416
-		$data = array( $transaction, $payment );
417
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
418
-		$message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() );
416
+		$data = array($transaction, $payment);
417
+		EE_Registry::instance()->load_helper('MSG_Template');
418
+		$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
419 419
 		//if payment amount is less than 0 then switch to payment_refund message type.
420 420
 		$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
421
-		self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data );
421
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
422 422
 	}
423 423
 
424 424
 
@@ -426,10 +426,10 @@  discard block
 block discarded – undo
426 426
 	/**
427 427
 	 * @param EE_Transaction $transaction
428 428
 	 */
429
-	public static function cancelled_registration( EE_Transaction $transaction ) {
429
+	public static function cancelled_registration(EE_Transaction $transaction) {
430 430
 		self::_load_controller();
431
-		$data = array( $transaction, null );
432
-		self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'cancelled_registration', $data );
431
+		$data = array($transaction, null);
432
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
433 433
 	}
434 434
 
435 435
 
@@ -442,9 +442,9 @@  discard block
 block discarded – undo
442 442
 	 * @param array $extra_details
443 443
 	 * @return void
444 444
 	 */
445
-	public static function maybe_registration( EE_Registration $registration, $extra_details = array() ) {
445
+	public static function maybe_registration(EE_Registration $registration, $extra_details = array()) {
446 446
 
447
-		if ( ! self::_verify_registration_notification_send( $registration, $extra_details ) ) {
447
+		if ( ! self::_verify_registration_notification_send($registration, $extra_details)) {
448 448
 			//no messages please
449 449
 			return;
450 450
 		}
@@ -459,22 +459,22 @@  discard block
 block discarded – undo
459 459
 		$mtgs = array();
460 460
 
461 461
 		//loop through registrations and trigger messages once per status.
462
-		foreach ( $all_registrations as $reg ) {
462
+		foreach ($all_registrations as $reg) {
463 463
 
464 464
 			//already triggered?
465
-			if ( in_array( $reg->status_ID(), $statuses_sent ) ) {
465
+			if (in_array($reg->status_ID(), $statuses_sent)) {
466 466
 				continue;
467 467
 			}
468 468
 
469
-			$message_type = EEH_MSG_Template::convert_reg_status_to_message_type( $reg->status_ID() );
470
-			$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( $message_type, array( $registration->transaction(), null, $reg->status_ID() ) );
469
+			$message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
470
+			$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type, array($registration->transaction(), null, $reg->status_ID()));
471 471
 			$statuses_sent[] = $reg->status_ID();
472 472
 		}
473 473
 
474
-		$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( 'registration_summary', array( $registration->transaction(), null ) );
474
+		$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary', array($registration->transaction(), null));
475 475
 
476 476
 		//batch queue and initiate request
477
-		self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $mtgs );
477
+		self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
478 478
 		self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
479 479
 	}
480 480
 
@@ -489,39 +489,39 @@  discard block
 block discarded – undo
489 489
 	 *
490 490
 	 * @return bool          true = send away, false = nope halt the presses.
491 491
 	 */
492
-	protected static function _verify_registration_notification_send( EE_Registration $registration, $extra_details = array() ) {
492
+	protected static function _verify_registration_notification_send(EE_Registration $registration, $extra_details = array()) {
493 493
 		 //self::log(
494 494
 		 //	__CLASS__, __FUNCTION__, __LINE__,
495 495
 		 //	$registration->transaction(),
496 496
 		 //	array( '$extra_details' => $extra_details )
497 497
 		 //);
498 498
 		// currently only using this to send messages for the primary registrant
499
-		if ( ! $registration->is_primary_registrant() ) {
499
+		if ( ! $registration->is_primary_registrant()) {
500 500
 			return false;
501 501
 		}
502 502
 		// first we check if we're in admin and not doing front ajax
503
-		if ( is_admin() && ! EE_FRONT_AJAX ) {
503
+		if (is_admin() && ! EE_FRONT_AJAX) {
504 504
 			//make sure appropriate admin params are set for sending messages
505
-			if ( empty( $_REQUEST['txn_reg_status_change']['send_notifications'] ) || ! absint( $_REQUEST['txn_reg_status_change']['send_notifications'] ) ) {
505
+			if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) {
506 506
 				//no messages sent please.
507 507
 				return false;
508 508
 			}
509 509
 		} else {
510 510
 			// frontend request (either regular or via AJAX)
511 511
 			// TXN is NOT finalized ?
512
-			if ( ! isset( $extra_details['finalized'] ) || $extra_details['finalized'] === false ) {
512
+			if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
513 513
 				return false;
514 514
 			}
515 515
 			// return visit but nothing changed ???
516 516
 			if (
517
-				isset( $extra_details['revisit'], $extra_details['status_updates'] ) &&
517
+				isset($extra_details['revisit'], $extra_details['status_updates']) &&
518 518
 				$extra_details['revisit'] && ! $extra_details['status_updates']
519 519
 			) {
520 520
 				return false;
521 521
 			}
522 522
 			// NOT sending messages && reg status is something other than "Not-Approved"
523 523
 			if (
524
-				! apply_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', false ) &&
524
+				! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
525 525
 				$registration->status_ID() !== EEM_Registration::status_id_not_approved
526 526
 			) {
527 527
 				return false;
@@ -543,10 +543,10 @@  discard block
 block discarded – undo
543 543
 	 *
544 544
 	 * @return array
545 545
 	 */
546
-	protected static function _get_reg_status_array( $reg_status = '' ) {
547
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
548
-		return EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status )
549
-			? EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status )
546
+	protected static function _get_reg_status_array($reg_status = '') {
547
+		EE_Registry::instance()->load_helper('MSG_Template');
548
+		return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
549
+			? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
550 550
 			: EEH_MSG_Template::reg_status_to_message_type_array();
551 551
 	}
552 552
 
@@ -562,10 +562,10 @@  discard block
 block discarded – undo
562 562
 	 *
563 563
 	 * @return string|bool The payment message type slug matching the status or false if no match.
564 564
 	 */
565
-	protected static function _get_payment_message_type( $payment_status ) {
566
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
567
-		return EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status )
568
-			? EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status )
565
+	protected static function _get_payment_message_type($payment_status) {
566
+		EE_Registry::instance()->load_helper('MSG_Template');
567
+		return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
568
+			? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
569 569
 			: false;
570 570
 	}
571 571
 
@@ -579,33 +579,33 @@  discard block
 block discarded – undo
579 579
 	 * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
580 580
 	 * @return bool          success/fail
581 581
 	 */
582
-	public static function process_resend( $req_data ) {
582
+	public static function process_resend($req_data) {
583 583
 		self::_load_controller();
584 584
 
585 585
 		//if $msgID in this request then skip to the new resend_message
586
-		if ( EE_Registry::instance()->REQ->get( 'MSG_ID' ) ) {
586
+		if (EE_Registry::instance()->REQ->get('MSG_ID')) {
587 587
 			return self::resend_message();
588 588
 		}
589 589
 
590 590
 		//make sure any incoming request data is set on the REQ so that it gets picked up later.
591 591
 		$req_data = (array) $req_data;
592
-		foreach( $req_data as $request_key => $request_value ) {
593
-			EE_Registry::instance()->REQ->set( $request_key, $request_value );
592
+		foreach ($req_data as $request_key => $request_value) {
593
+			EE_Registry::instance()->REQ->set($request_key, $request_value);
594 594
 		}
595 595
 
596
-		if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() ) {
596
+		if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) {
597 597
 			return false;
598 598
 		}
599 599
 
600 600
 		try {
601
-			self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $messages_to_send );
601
+			self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
602 602
 			self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
603
-		} catch( EE_Error $e ) {
604
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
603
+		} catch (EE_Error $e) {
604
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
605 605
 			return false;
606 606
 		}
607 607
 		EE_Error::add_success(
608
-			__( 'Messages have been successfully queued for generation and sending.', 'event_espresso' )
608
+			__('Messages have been successfully queued for generation and sending.', 'event_espresso')
609 609
 		);
610 610
 		return true; //everything got queued.
611 611
 	}
@@ -618,17 +618,17 @@  discard block
 block discarded – undo
618 618
 	public static function resend_message() {
619 619
 		self::_load_controller();
620 620
 
621
-		$msgID = EE_Registry::instance()->REQ->get( 'MSG_ID' );
622
-		if ( ! $msgID ) {
623
-			EE_Error::add_error( __( 'Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
621
+		$msgID = EE_Registry::instance()->REQ->get('MSG_ID');
622
+		if ( ! $msgID) {
623
+			EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
624 624
 			return false;
625 625
 		}
626 626
 
627
-		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( (array) $msgID );
627
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID);
628 628
 
629 629
 		//setup success message.
630
-		$count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend );
631
-		EE_Error::add_success( sprintf(
630
+		$count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
631
+		EE_Error::add_success(sprintf(
632 632
 			_n(
633 633
 				'There was %d message queued for resending.',
634 634
 				'There were %d messages queued for resending.',
@@ -636,7 +636,7 @@  discard block
 block discarded – undo
636 636
 				'event_espresso'
637 637
 			),
638 638
 			$count_ready_for_resend
639
-		) );
639
+		));
640 640
 		return true;
641 641
 	}
642 642
 
@@ -649,13 +649,13 @@  discard block
 block discarded – undo
649 649
 	 * @param  EE_Payment $payment EE_payment object
650 650
 	 * @return bool              success/fail
651 651
 	 */
652
-	public static function process_admin_payment( EE_Payment $payment ) {
653
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
652
+	public static function process_admin_payment(EE_Payment $payment) {
653
+		EE_Registry::instance()->load_helper('MSG_Template');
654 654
 		//we need to get the transaction object
655 655
 		$transaction = $payment->transaction();
656
-		if ( $transaction instanceof EE_Transaction ) {
657
-			$data = array( $transaction, $payment );
658
-			$message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() );
656
+		if ($transaction instanceof EE_Transaction) {
657
+			$data = array($transaction, $payment);
658
+			$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
659 659
 
660 660
 			//if payment amount is less than 0 then switch to payment_refund message type.
661 661
 			$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
@@ -665,22 +665,22 @@  discard block
 block discarded – undo
665 665
 
666 666
 			self::_load_controller();
667 667
 
668
-			self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data );
668
+			self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
669 669
 
670 670
 			//get count of queued for generation
671
-			$count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( array( EEM_Message::status_incomplete, EEM_Message::status_idle ) );
671
+			$count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(array(EEM_Message::status_incomplete, EEM_Message::status_idle));
672 672
 
673
-			if ( $count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0 ) {
674
-				add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' );
673
+			if ($count_to_generate > 0 && self::$_MSG_PROCESSOR->get_queue()->get_message_repository()->count() !== 0) {
674
+				add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
675 675
 				return true;
676 676
 			} else {
677
-				$count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::instance()->stati_indicating_failed_sending() );
677
+				$count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending());
678 678
 				/**
679 679
 				 * Verify that there are actually errors.  If not then we return a success message because the queue might have been emptied due to successful
680 680
 				 * IMMEDIATE generation.
681 681
 				 */
682
-				if ( $count_failed > 0 ) {
683
-					EE_Error::add_error( sprintf(
682
+				if ($count_failed > 0) {
683
+					EE_Error::add_error(sprintf(
684 684
 						_n(
685 685
 							'The payment notification generation failed.',
686 686
 							'%d payment notifications failed being sent.',
@@ -688,11 +688,11 @@  discard block
 block discarded – undo
688 688
 							'event_espresso'
689 689
 						),
690 690
 						$count_failed
691
-					), __FILE__, __FUNCTION__, __LINE__ );
691
+					), __FILE__, __FUNCTION__, __LINE__);
692 692
 
693 693
 					return false;
694 694
 				} else {
695
-					add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' );
695
+					add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
696 696
 					return true;
697 697
 				}
698 698
 			}
@@ -716,11 +716,11 @@  discard block
 block discarded – undo
716 716
 	 * @param  int      	      $grp_id     a specific message template group id.
717 717
 	 * @return void
718 718
 	 */
719
-	public static function send_newsletter_message( $registrations, $grp_id ) {
719
+	public static function send_newsletter_message($registrations, $grp_id) {
720 720
 		//make sure mtp is id and set it in the EE_Request Handler later messages setup.
721
-		EE_Registry::instance()->REQ->set( 'GRP_ID', (int) $grp_id );
721
+		EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id);
722 722
 		self::_load_controller();
723
-		self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'newsletter', $registrations );
723
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $registrations);
724 724
 	}
725 725
 
726 726
 
@@ -735,9 +735,9 @@  discard block
 block discarded – undo
735 735
 	 * @param string 	$message_type
736 736
 	 * @return 	string
737 737
 	 */
738
-	public static function registration_message_trigger_url( $registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice' ) {
738
+	public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice') {
739 739
 		// whitelist $messenger
740
-		switch ( $messenger ) {
740
+		switch ($messenger) {
741 741
 			case 'pdf' :
742 742
 				$sending_messenger = 'pdf';
743 743
 				$generating_messenger = 'html';
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
 				break;
750 750
 		}
751 751
 		// whitelist $message_type
752
-		switch ( $message_type ) {
752
+		switch ($message_type) {
753 753
 			case 'receipt' :
754 754
 				$message_type = 'receipt';
755 755
 				break;
@@ -759,7 +759,7 @@  discard block
 block discarded – undo
759 759
 				break;
760 760
 		}
761 761
 		// verify that both the messenger AND the message type are active
762
-		if ( EEH_MSG_Template::is_messenger_active( $sending_messenger ) && EEH_MSG_Template::is_mt_active( $message_type ) ) {
762
+		if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) {
763 763
 			//need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
764 764
 			$template_query_params = array(
765 765
 				'MTP_is_active' => true,
@@ -768,16 +768,16 @@  discard block
 block discarded – undo
768 768
 				'Event.EVT_ID' => $registration->event_ID()
769 769
 			);
770 770
 			//get the message template group.
771
-			$msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) );
771
+			$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
772 772
 			//if we don't have an EE_Message_Template_Group then return
773
-			if ( ! $msg_template_group instanceof EE_Message_Template_Group ) {
773
+			if ( ! $msg_template_group instanceof EE_Message_Template_Group) {
774 774
 				// remove EVT_ID from query params so that global templates get picked up
775
-				unset( $template_query_params['Event.EVT_ID'] );
775
+				unset($template_query_params['Event.EVT_ID']);
776 776
 				//get global template as the fallback
777
-				$msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) );
777
+				$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
778 778
 			}
779 779
 			//if we don't have an EE_Message_Template_Group then return
780
-			if ( ! $msg_template_group instanceof EE_Message_Template_Group ) {
780
+			if ( ! $msg_template_group instanceof EE_Message_Template_Group) {
781 781
 				return '';
782 782
 			}
783 783
 			// generate the URL
@@ -806,7 +806,7 @@  discard block
 block discarded – undo
806 806
 	 * @param bool 	  $send true we will do a test send using the messenger delivery, false we just do a regular preview
807 807
 	 * @return string|bool          The body of the message or if send is requested, sends.
808 808
 	 */
809
-	public static function preview_message( $type, $context, $messenger, $send = false ) {
809
+	public static function preview_message($type, $context, $messenger, $send = false) {
810 810
 		self::_load_controller();
811 811
 		$mtg = new EE_Message_To_Generate(
812 812
 			$messenger,
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
 			$context,
816 816
 			true
817 817
 		);
818
-		$generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview( $mtg, $send );
819
-		if ( $generated_preview_queue instanceof EE_Messages_Queue ) {
818
+		$generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg, $send);
819
+		if ($generated_preview_queue instanceof EE_Messages_Queue) {
820 820
 			return $generated_preview_queue->get_message_repository()->current()->content();
821 821
 		} else {
822 822
 			return $generated_preview_queue;
@@ -843,7 +843,7 @@  discard block
 block discarded – undo
843 843
 	 *
844 844
 	 * @return bool          success or fail.
845 845
 	 */
846
-	public static function send_message_with_messenger_only( $messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '' ) {
846
+	public static function send_message_with_messenger_only($messenger, $message_type, EE_Messages_Queue $queue, $custom_subject = '') {
847 847
 		self::_load_controller();
848 848
 		/** @type EE_Message_To_Generate_From_Queue $message_to_generate */
849 849
 		$message_to_generate = EE_Registry::instance()->load_lib(
@@ -855,7 +855,7 @@  discard block
 block discarded – undo
855 855
 				$custom_subject,
856 856
 			)
857 857
 		);
858
-		return self::$_MSG_PROCESSOR->queue_for_sending( $message_to_generate );
858
+		return self::$_MSG_PROCESSOR->queue_for_sending($message_to_generate);
859 859
 	}
860 860
 
861 861
 
@@ -868,22 +868,22 @@  discard block
 block discarded – undo
868 868
 	 * @param array     $message_ids An array of message ids
869 869
 	 * @return bool | EE_Messages_Queue     false if nothing was generated, EE_Messages_Queue containing generated messages.
870 870
 	 */
871
-	public static function generate_now( $message_ids ) {
871
+	public static function generate_now($message_ids) {
872 872
 		self::_load_controller();
873 873
 		$messages = EEM_Message::instance()->get_all(
874 874
 			array(
875 875
 				0 => array(
876
-					'MSG_ID' => array( 'IN', $message_ids ),
876
+					'MSG_ID' => array('IN', $message_ids),
877 877
 					'STS_ID' => EEM_Message::status_incomplete,
878 878
 				)
879 879
 			)
880 880
 		);
881 881
 
882
-		$generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages );
882
+		$generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
883 883
 
884
-		if ( ! $generated_queue instanceof EE_Messages_Queue ) {
884
+		if ( ! $generated_queue instanceof EE_Messages_Queue) {
885 885
 			EE_Error::add_error(
886
-				__( 'The messages were not generated.  This is usually because there is already a batch being generated on a separate request.  You can wait a minute or two and try again.', 'event_espresso' ),
886
+				__('The messages were not generated.  This is usually because there is already a batch being generated on a separate request.  You can wait a minute or two and try again.', 'event_espresso'),
887 887
 				__FILE__, __FUNCTION__, __LINE__
888 888
 			);
889 889
 		}
@@ -902,28 +902,28 @@  discard block
 block discarded – undo
902 902
 	 *
903 903
 	 * @return bool | EE_Messages_Queue  false if no messages sent.
904 904
 	 */
905
-	public static function send_now( $message_ids ) {
905
+	public static function send_now($message_ids) {
906 906
 		self::_load_controller();
907 907
 		$messages = EEM_Message::instance()->get_all(
908 908
 			array(
909 909
 				0 => array(
910
-					'MSG_ID' => array( 'IN', $message_ids ),
911
-					'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) )
910
+					'MSG_ID' => array('IN', $message_ids),
911
+					'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry))
912 912
 				)
913 913
 			)
914 914
 		);
915 915
 
916
-		$sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages );
916
+		$sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
917 917
 
918
-		if ( ! $sent_queue instanceof EE_Messages_Queue ) {
918
+		if ( ! $sent_queue instanceof EE_Messages_Queue) {
919 919
 			EE_Error::add_error(
920
-				__( 'The messages were not sent.  This is usually because there is already a batch being sent on a separate request.  You can wait a minute or two and try again.', 'event_espresso' ),
920
+				__('The messages were not sent.  This is usually because there is already a batch being sent on a separate request.  You can wait a minute or two and try again.', 'event_espresso'),
921 921
 				__FILE__, __FUNCTION__, __LINE__
922 922
 			);
923 923
 		} else {
924 924
 			//can count how many sent by using the messages in the queue
925
-			$sent_count = $sent_queue->count_STS_in_queue( EEM_Message::instance()->stati_indicating_sent() );
926
-			if ( $sent_count > 0 ) {
925
+			$sent_count = $sent_queue->count_STS_in_queue(EEM_Message::instance()->stati_indicating_sent());
926
+			if ($sent_count > 0) {
927 927
 				EE_Error::add_success(
928 928
 					sprintf(
929 929
 						_n(
@@ -938,8 +938,8 @@  discard block
 block discarded – undo
938 938
 			} else {
939 939
 				EE_Error::overwrite_errors();
940 940
 				EE_Error::add_error(
941
-					__( 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
942
-					If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ),
941
+					__('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, they were ALREADY sent on a different scheduled task, or there was an error.
942
+					If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'),
943 943
 					__FILE__, __FUNCTION__, __LINE__
944 944
 				);
945 945
 			}
@@ -960,13 +960,13 @@  discard block
 block discarded – undo
960 960
 	 *
961 961
 	 * @return bool  true means messages were successfully queued for resending, false means none were queued for resending.
962 962
 	 */
963
-	public static function queue_for_resending( $message_ids ) {
963
+	public static function queue_for_resending($message_ids) {
964 964
 		self::_load_controller();
965
-		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids );
965
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
966 966
 
967 967
 		//get queue and count
968
-		$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend );
969
-		if ( $queue_count > 0 ) {
968
+		$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
969
+		if ($queue_count > 0) {
970 970
 			EE_Error::add_success(
971 971
 				sprintf(
972 972
 					_n(
@@ -980,7 +980,7 @@  discard block
 block discarded – undo
980 980
 			);
981 981
 		} else {
982 982
 			EE_Error::add_error(
983
-				__( 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso' ),
983
+				__('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso'),
984 984
 				__FILE__, __FUNCTION__, __LINE__
985 985
 			);
986 986
 		}
@@ -1002,16 +1002,16 @@  discard block
 block discarded – undo
1002 1002
 	 * @param array $info
1003 1003
 	 * @param bool $display_request
1004 1004
 	 */
1005
-	protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) {
1006
-		if ( WP_DEBUG && false ) {
1007
-			if ( $transaction instanceof EE_Transaction ) {
1005
+	protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) {
1006
+		if (WP_DEBUG && false) {
1007
+			if ($transaction instanceof EE_Transaction) {
1008 1008
 				// don't serialize objects
1009
-				$info = EEH_Debug_Tools::strip_objects( $info );
1009
+				$info = EEH_Debug_Tools::strip_objects($info);
1010 1010
 				$info['TXN_status'] = $transaction->status_ID();
1011 1011
 				$info['TXN_reg_steps'] = $transaction->reg_steps();
1012
-				if ( $transaction->ID() ) {
1013
-					$index = 'EE_Transaction: ' . $transaction->ID();
1014
-					EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index );
1012
+				if ($transaction->ID()) {
1013
+					$index = 'EE_Transaction: '.$transaction->ID();
1014
+					EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
1015 1015
 				}
1016 1016
 			}
1017 1017
 		}
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Checkbox_Display_Strategy.strategy.php 1 patch
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -18,42 +18,42 @@
 block discarded – undo
18 18
 	 * @throws EE_Error
19 19
 	 * @return string of html to display the field
20 20
 	 */
21
-	public function display(){
21
+	public function display() {
22 22
 		$input = $this->get_input();
23 23
 		//d( $input );
24
-		$multi = count( $input->options() ) > 1 ? TRUE : FALSE;
24
+		$multi = count($input->options()) > 1 ? TRUE : FALSE;
25 25
 		$input->set_label_sizes();
26 26
 		$label_size_class = $input->get_label_size_class();
27 27
 		$html = '';
28
-		if ( ! is_array( $input->raw_value() ) && $input->raw_value() !== NULL ) {
28
+		if ( ! is_array($input->raw_value()) && $input->raw_value() !== NULL) {
29 29
 			EE_Error::doing_it_wrong(
30 30
 				'EE_Checkbox_Display_Strategy::display()',
31 31
 				sprintf(
32
-					__( 'Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'),
32
+					__('Input values for checkboxes should be an array of values, but the value for input "%1$s" is "%2$s". Please verify that the input name is exactly "%3$s"', 'event_espresso'),
33 33
 					$input->html_id(),
34
-					var_export( $input->raw_value(), true),
35
-					$input->html_name() . '[]'
34
+					var_export($input->raw_value(), true),
35
+					$input->html_name().'[]'
36 36
 				),
37 37
 				'4.8.1'
38 38
 			);
39 39
 		}
40
-		$input_raw_value = (array)$input->raw_value();
41
-		foreach( $input->options() as $value => $display_text ){
42
-			$value = $input->get_normalization_strategy()->unnormalize_one( $value );
43
-			$html_id = $multi ? $this->get_sub_input_id( $value ) : $input->html_id();
44
-			$html .= EEH_HTML::nl( 0, 'checkbox' );
45
-			$html .= '<label for="' . $html_id . '" id="' . $html_id . '-lbl" class="ee-checkbox-label-after' . $label_size_class . '">';
46
-			$html .= EEH_HTML::nl( 1, 'checkbox' );
40
+		$input_raw_value = (array) $input->raw_value();
41
+		foreach ($input->options() as $value => $display_text) {
42
+			$value = $input->get_normalization_strategy()->unnormalize_one($value);
43
+			$html_id = $multi ? $this->get_sub_input_id($value) : $input->html_id();
44
+			$html .= EEH_HTML::nl(0, 'checkbox');
45
+			$html .= '<label for="'.$html_id.'" id="'.$html_id.'-lbl" class="ee-checkbox-label-after'.$label_size_class.'">';
46
+			$html .= EEH_HTML::nl(1, 'checkbox');
47 47
 			$html .= '<input type="checkbox"';
48
-			$html .= ' name="' . $input->html_name() . '[]"';
49
-			$html .= ' id="' . $html_id . '"';
50
-			$html .= ' class="' . $input->html_class() . '"';
51
-			$html .= ' style="' . $input->html_style() . '"';
52
-			$html .= ' value="' . esc_attr( $value ) . '"';
53
-			$html .= ! empty( $input_raw_value ) && in_array( $value, $input_raw_value ) ? ' checked="checked"' : '';
48
+			$html .= ' name="'.$input->html_name().'[]"';
49
+			$html .= ' id="'.$html_id.'"';
50
+			$html .= ' class="'.$input->html_class().'"';
51
+			$html .= ' style="'.$input->html_style().'"';
52
+			$html .= ' value="'.esc_attr($value).'"';
53
+			$html .= ! empty($input_raw_value) && in_array($value, $input_raw_value) ? ' checked="checked"' : '';
54 54
 			$html .= '>&nbsp;';
55 55
 			$html .= $display_text;
56
-			$html .= EEH_HTML::nl( -1, 'checkbox' ) . '</label>';
56
+			$html .= EEH_HTML::nl( -1, 'checkbox' ).'</label>';
57 57
 		}
58 58
 		return $html;
59 59
 	}
Please login to merge, or discard this patch.
form_sections/strategies/display/EE_Select2_Display_Strategy.strategy.php 1 patch
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,7 +12,7 @@  discard block
 block discarded – undo
12 12
  * @since 				$VID:$
13 13
  *
14 14
  */
15
-class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy{
15
+class EE_Select2_Display_Strategy extends EE_Select_Display_Strategy {
16 16
 	
17 17
 	/**
18 18
 	 * Arguments that will be passed into the select2 javascript constructor
@@ -25,7 +25,7 @@  discard block
 block discarded – undo
25 25
 	 * @param array $select2_js_args pass in the EXACT array of JS arguments you want
26 26
 	 * to pass into the select2 js/html input. See https://select2.github.io
27 27
 	 */
28
-	public function __construct( $select2_js_args = array() ) {
28
+	public function __construct($select2_js_args = array()) {
29 29
 		$this->_select2_js_args = $select2_js_args;
30 30
 		parent::__construct();
31 31
 	}
@@ -35,8 +35,8 @@  discard block
 block discarded – undo
35 35
 	 * the select2 css
36 36
 	 */
37 37
 	public function enqueue_js() {
38
-		wp_enqueue_script( 'form_section_select2_init', EE_GLOBAL_ASSETS_URL . 'scripts/form_section_select2_init.js', array( 'select2' ), '1.0.0', true );
39
-		wp_enqueue_style( 'select2', EE_GLOBAL_ASSETS_URL . 'css/select2.min.css', array(), '4.0.2', 'all' );
38
+		wp_enqueue_script('form_section_select2_init', EE_GLOBAL_ASSETS_URL.'scripts/form_section_select2_init.js', array('select2'), '1.0.0', true);
39
+		wp_enqueue_style('select2', EE_GLOBAL_ASSETS_URL.'css/select2.min.css', array(), '4.0.2', 'all');
40 40
 	}
41 41
 	
42 42
 	/**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
 	 * Sets the exact js args which will be passed into the select2 js/html input
52 52
 	 * @param array $js_args
53 53
 	 */
54
-	public function set_js_args( $js_args ) {
54
+	public function set_js_args($js_args) {
55 55
 		$this->_select2_js_args = $js_args;
56 56
 	}
57 57
 	
@@ -60,12 +60,12 @@  discard block
 block discarded – undo
60 60
 	 * @param array $other_js_data
61 61
 	 * @return array
62 62
 	 */
63
-	public function get_other_js_data( $other_js_data = array() ) {
64
-		$other_js_data = parent::get_other_js_data( $other_js_data );
65
-		if( ! isset( $other_js_data[ 'select2s' ] ) ) {
63
+	public function get_other_js_data($other_js_data = array()) {
64
+		$other_js_data = parent::get_other_js_data($other_js_data);
65
+		if ( ! isset($other_js_data['select2s'])) {
66 66
 			$other_js_data['select2s'] = array();
67 67
 		}
68
-		$other_js_data[ 'select2s' ][ $this->_input->html_id() ] = $this->get_js_args();
68
+		$other_js_data['select2s'][$this->_input->html_id()] = $this->get_js_args();
69 69
 		return $other_js_data;
70 70
 	}
71 71
 }
72 72
\ No newline at end of file
Please login to merge, or discard this patch.
core/libraries/form_sections/base/EE_Form_Section_Proper.form.php 2 patches
Spacing   +181 added lines, -181 removed lines patch added patch discarded remove patch
@@ -7,7 +7,7 @@  discard block
 block discarded – undo
7 7
  * before the hook wp_enqueue_scripts is called (so that the form section can enqueue its needed scripts).
8 8
  * However, you may output the form (usually by calling get_html) anywhere you like.
9 9
  */
10
-class EE_Form_Section_Proper extends EE_Form_Section_Validatable{
10
+class EE_Form_Section_Proper extends EE_Form_Section_Validatable {
11 11
 
12 12
 	/**
13 13
 	 * Subsections
@@ -69,49 +69,49 @@  discard block
 block discarded – undo
69 69
 	 *                               } @see EE_Form_Section_Validatable::__construct()
70 70
 	 * @throws \EE_Error
71 71
 	 */
72
-	public function __construct( $options_array = array() ){
73
-		$options_array = (array) apply_filters( 'FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this );
72
+	public function __construct($options_array = array()) {
73
+		$options_array = (array) apply_filters('FHEE__EE_Form_Section_Proper___construct__options_array', $options_array, $this);
74 74
 		//call parent first, as it may be setting the name
75 75
 		parent::__construct($options_array);
76 76
 		//if they've included subsections in the constructor, add them now
77
-		if( isset( $options_array['include'] )){
77
+		if (isset($options_array['include'])) {
78 78
 			//we are going to make sure we ONLY have those subsections to include
79 79
 			//AND we are going to make sure they're in that specified order
80 80
 			$reordered_subsections = array();
81
-			foreach($options_array['include'] as $input_name){
82
-				if(isset($this->_subsections[$input_name])){
81
+			foreach ($options_array['include'] as $input_name) {
82
+				if (isset($this->_subsections[$input_name])) {
83 83
 					$reordered_subsections[$input_name] = $this->_subsections[$input_name];
84 84
 				}
85 85
 			}
86 86
 			$this->_subsections = $reordered_subsections;
87 87
 		}
88
-		if(isset($options_array['exclude'])){
88
+		if (isset($options_array['exclude'])) {
89 89
 			$exclude = $options_array['exclude'];
90 90
 			$this->_subsections = array_diff_key($this->_subsections, array_flip($exclude));
91 91
 		}
92
-		if(isset($options_array['layout_strategy'])){
92
+		if (isset($options_array['layout_strategy'])) {
93 93
 			$this->_layout_strategy = $options_array['layout_strategy'];
94 94
 		}
95
-		if( ! $this->_layout_strategy){
95
+		if ( ! $this->_layout_strategy) {
96 96
 			$this->_layout_strategy = new EE_Two_Column_Layout();
97 97
 		}
98 98
 		$this->_layout_strategy->_construct_finalize($this);
99 99
 
100 100
 		//ok so we are definitely going to want the forms JS,
101 101
 		//so enqueue it or remember to enqueue it during wp_enqueue_scripts
102
-		if( did_action( 'wp_enqueue_scripts' )
103
-			|| did_action( 'admin_enqueue_scripts' ) ) {
102
+		if (did_action('wp_enqueue_scripts')
103
+			|| did_action('admin_enqueue_scripts')) {
104 104
 			//ok so they've constructed this object after when they should have.
105 105
 			//just enqueue the generic form scripts and initialize the form immediately in the JS
106
-			\EE_Form_Section_Proper::wp_enqueue_scripts( true );
106
+			\EE_Form_Section_Proper::wp_enqueue_scripts(true);
107 107
 		} else {
108
-			add_action( 'wp_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
109
-			add_action( 'admin_enqueue_scripts', array( 'EE_Form_Section_Proper', 'wp_enqueue_scripts' ));
108
+			add_action('wp_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
109
+			add_action('admin_enqueue_scripts', array('EE_Form_Section_Proper', 'wp_enqueue_scripts'));
110 110
 		}
111
-		add_action( 'wp_footer', array( $this, 'ensure_scripts_localized' ), 1 );
111
+		add_action('wp_footer', array($this, 'ensure_scripts_localized'), 1);
112 112
 
113
-		if( isset( $options_array[ 'name' ] ) ) {
114
-			$this->_construct_finalize( null, $options_array[ 'name' ] );
113
+		if (isset($options_array['name'])) {
114
+			$this->_construct_finalize(null, $options_array['name']);
115 115
 		}
116 116
 	}
117 117
 
@@ -124,25 +124,25 @@  discard block
 block discarded – undo
124 124
 	 * @param string                 $name
125 125
 	 * @throws \EE_Error
126 126
 	 */
127
-	public function _construct_finalize( $parent_form_section, $name ) {
127
+	public function _construct_finalize($parent_form_section, $name) {
128 128
 		parent::_construct_finalize($parent_form_section, $name);
129 129
 		$this->_set_default_name_if_empty();
130 130
 		$this->_set_default_html_id_if_empty();
131
-		foreach( $this->_subsections as $subsection_name => $subsection ){
132
-			if ( $subsection instanceof EE_Form_Section_Base ) {
133
-				$subsection->_construct_finalize( $this, $subsection_name );
131
+		foreach ($this->_subsections as $subsection_name => $subsection) {
132
+			if ($subsection instanceof EE_Form_Section_Base) {
133
+				$subsection->_construct_finalize($this, $subsection_name);
134 134
 			} else {
135 135
 				throw new EE_Error(
136 136
 					sprintf(
137
-						__( 'Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso' ),
137
+						__('Subsection "%s" is not an instanceof EE_Form_Section_Base on form "%s". It is a "%s"', 'event_espresso'),
138 138
 						$subsection_name,
139 139
 						get_class($this),
140
-						$subsection ? get_class($subsection) : __( 'NULL', 'event_espresso' )
140
+						$subsection ? get_class($subsection) : __('NULL', 'event_espresso')
141 141
 					)
142 142
 				);
143 143
 			}
144 144
 		}
145
-		do_action( 'AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name );
145
+		do_action('AHEE__EE_Form_Section_Proper___construct_finalize__end', $this, $parent_form_section, $name);
146 146
 	}
147 147
 
148 148
 
@@ -151,7 +151,7 @@  discard block
 block discarded – undo
151 151
 	 * Gets the layout strategy for this form section
152 152
 	 * @return EE_Form_Section_Layout_Base
153 153
 	 */
154
-	public function get_layout_strategy(){
154
+	public function get_layout_strategy() {
155 155
 		return $this->_layout_strategy;
156 156
 	}
157 157
 
@@ -163,7 +163,7 @@  discard block
 block discarded – undo
163 163
 	 * @param EE_Form_Input_Base $input
164 164
 	 * @return string
165 165
 	 */
166
-	public function get_html_for_input($input){
166
+	public function get_html_for_input($input) {
167 167
 		return $this->_layout_strategy->layout_input($input);
168 168
 	}
169 169
 
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 * @param null $form_data
177 177
 	 * @return boolean
178 178
 	 */
179
-	public function was_submitted($form_data = NULL){
179
+	public function was_submitted($form_data = NULL) {
180 180
 		return $this->form_data_present_in($form_data);
181 181
 	}
182 182
 
@@ -201,17 +201,17 @@  discard block
 block discarded – undo
201 201
 	 *                          (eg you validated the data then stored it in the DB) you may want to skip this step.
202 202
 	 * @return void
203 203
 	 */
204
-	public function receive_form_submission($req_data = NULL, $validate = TRUE){
205
-		$req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate );
206
-		if( $req_data === NULL){
207
-			$req_data = array_merge( $_GET, $_POST );
204
+	public function receive_form_submission($req_data = NULL, $validate = TRUE) {
205
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__req_data', $req_data, $this, $validate);
206
+		if ($req_data === NULL) {
207
+			$req_data = array_merge($_GET, $_POST);
208 208
 		}
209
-		$req_data = apply_filters( 'FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this );
209
+		$req_data = apply_filters('FHEE__EE_Form_Section_Proper__receive_form_submission__request_data', $req_data, $this);
210 210
 		$this->_normalize($req_data);
211
-		if( $validate ){
211
+		if ($validate) {
212 212
 			$this->_validate();
213 213
 		}
214
-		do_action( 'AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate );
214
+		do_action('AHEE__EE_Form_Section_Proper__receive_form_submission__end', $req_data, $this, $validate);
215 215
 	}
216 216
 
217 217
 
@@ -224,12 +224,12 @@  discard block
 block discarded – undo
224 224
 	 * the value being an array formatted in teh same way
225 225
 	 * @param array $default_data
226 226
 	 */
227
-	public function populate_defaults($default_data){
228
-		foreach($this->subsections() as $subsection_name => $subsection){
229
-			if(isset($default_data[$subsection_name])){
230
-				if($subsection instanceof EE_Form_Input_Base){
227
+	public function populate_defaults($default_data) {
228
+		foreach ($this->subsections() as $subsection_name => $subsection) {
229
+			if (isset($default_data[$subsection_name])) {
230
+				if ($subsection instanceof EE_Form_Input_Base) {
231 231
 					$subsection->set_default($default_data[$subsection_name]);
232
-				}elseif($subsection instanceof EE_Form_Section_Proper){
232
+				}elseif ($subsection instanceof EE_Form_Section_Proper) {
233 233
 					$subsection->populate_defaults($default_data[$subsection_name]);
234 234
 				}
235 235
 			}
@@ -251,8 +251,8 @@  discard block
 block discarded – undo
251 251
 	 * @return EE_Form_Section_Base
252 252
 	 * @throws \EE_Error
253 253
 	 */
254
-	public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){
255
-		if( $require_construction_to_be_finalized ){
254
+	public function get_subsection($name, $require_construction_to_be_finalized = TRUE) {
255
+		if ($require_construction_to_be_finalized) {
256 256
 			$this->ensure_construct_finalized_called();
257 257
 		}
258 258
 		return isset($this->_subsections[$name]) ? $this->_subsections[$name] : NULL;
@@ -264,10 +264,10 @@  discard block
 block discarded – undo
264 264
 	 * Gets all the validatable subsections of this form section
265 265
 	 * @return EE_Form_Section_Validatable[]
266 266
 	 */
267
-	public function get_validatable_subsections(){
267
+	public function get_validatable_subsections() {
268 268
 		$validatable_subsections = array();
269
-		foreach($this->subsections() as $name=>$obj){
270
-			if($obj instanceof EE_Form_Section_Validatable){
269
+		foreach ($this->subsections() as $name=>$obj) {
270
+			if ($obj instanceof EE_Form_Section_Validatable) {
271 271
 				$validatable_subsections[$name] = $obj;
272 272
 			}
273 273
 		}
@@ -287,10 +287,10 @@  discard block
 block discarded – undo
287 287
 	 * @return EE_Form_Input_Base
288 288
 	 * @throws EE_Error
289 289
 	 */
290
-	public function get_input($name, $require_construction_to_be_finalized = TRUE ){
290
+	public function get_input($name, $require_construction_to_be_finalized = TRUE) {
291 291
 		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
292
-		if( ! $subsection instanceof EE_Form_Input_Base){
293
-			throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'),$name, get_class($this),$subsection ? get_class($subsection) : __("NULL", 'event_espresso')));
292
+		if ( ! $subsection instanceof EE_Form_Input_Base) {
293
+			throw new EE_Error(sprintf(__("Subsection '%s' is not an instanceof EE_Form_Input_Base on form '%s'. It is a '%s'", 'event_espresso'), $name, get_class($this), $subsection ? get_class($subsection) : __("NULL", 'event_espresso')));
294 294
 		}
295 295
 		return $subsection;
296 296
 	}
@@ -308,10 +308,10 @@  discard block
 block discarded – undo
308 308
 	 * @return EE_Form_Section_Proper
309 309
 	 * @throws EE_Error
310 310
 	 */
311
-	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE ){
312
-		$subsection = $this->get_subsection( $name, $require_construction_to_be_finalized );
313
-		if( ! $subsection instanceof EE_Form_Section_Proper){
314
-			throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'),$name, get_class($this)));
311
+	public function get_proper_subsection($name, $require_construction_to_be_finalized = TRUE) {
312
+		$subsection = $this->get_subsection($name, $require_construction_to_be_finalized);
313
+		if ( ! $subsection instanceof EE_Form_Section_Proper) {
314
+			throw new EE_Error(sprintf(__("Subsection '%'s is not an instanceof EE_Form_Section_Proper on form '%s'", 'event_espresso'), $name, get_class($this)));
315 315
 		}
316 316
 		return $subsection;
317 317
 	}
@@ -326,7 +326,7 @@  discard block
 block discarded – undo
326 326
 	 * @return mixed depending on the input's type and its normalization strategy
327 327
 	 * @throws \EE_Error
328 328
 	 */
329
-	public function get_input_value($name){
329
+	public function get_input_value($name) {
330 330
 		$input = $this->get_input($name);
331 331
 		return $input->normalized_value();
332 332
 	}
@@ -339,16 +339,16 @@  discard block
 block discarded – undo
339 339
 	 * @return boolean
340 340
 	 */
341 341
 	public function is_valid() {
342
-		if( ! $this->has_received_submission()){
342
+		if ( ! $this->has_received_submission()) {
343 343
 			throw new EE_Error(sprintf(__("You cannot check if a form is valid before receiving the form submission using receive_form_submission", "event_espresso")));
344 344
 		}
345
-		if( ! parent::is_valid()){
345
+		if ( ! parent::is_valid()) {
346 346
 			return false;
347 347
 		}
348 348
 		//ok so no errors general to this entire form section. so let's check the subsections
349
-		foreach( $this->get_validatable_subsections() as $subsection ){
350
-			if( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '' ){
351
-				$this->set_submission_error_message( $subsection->get_validation_error_string() );
349
+		foreach ($this->get_validatable_subsections() as $subsection) {
350
+			if ( ! $subsection->is_valid() || $subsection->get_validation_error_string() !== '') {
351
+				$this->set_submission_error_message($subsection->get_validation_error_string());
352 352
 				return false;
353 353
 			}
354 354
 		}
@@ -361,11 +361,11 @@  discard block
 block discarded – undo
361 361
 	 * gets teh default name of this form section if none is specified
362 362
 	 * @return string
363 363
 	 */
364
-	protected function _set_default_name_if_empty(){
365
-		if( ! $this->_name ){
364
+	protected function _set_default_name_if_empty() {
365
+		if ( ! $this->_name) {
366 366
 			$classname = get_class($this);
367 367
 			$default_name = str_replace("EE_", "", $classname);
368
-			$this->_name =  $default_name;
368
+			$this->_name = $default_name;
369 369
 		}
370 370
 	}
371 371
 
@@ -380,7 +380,7 @@  discard block
 block discarded – undo
380 380
 	 *             and get_html when you are about to display the form.
381 381
 	 * @throws \EE_Error
382 382
 	 */
383
-	public function get_html_and_js(){
383
+	public function get_html_and_js() {
384 384
 		//no doing_it_wrong yet because we ourselves are still doing it wrong...
385 385
 		//and theoretically this CAN be used properly, provided its used during "wp_enqueue_scripts"
386 386
 		$this->enqueue_js();
@@ -395,7 +395,7 @@  discard block
 block discarded – undo
395 395
 	 * @return string
396 396
 	 * @throws \EE_Error
397 397
 	 */
398
-	public function get_html(){
398
+	public function get_html() {
399 399
 		$this->ensure_construct_finalized_called();
400 400
 		return $this->_layout_strategy->layout_form();
401 401
 	}
@@ -408,9 +408,9 @@  discard block
 block discarded – undo
408 408
 	 * @return string
409 409
 	 * @throws \EE_Error
410 410
 	 */
411
-	public function enqueue_js(){
411
+	public function enqueue_js() {
412 412
 		$this->_enqueue_and_localize_form_js();
413
-		foreach( $this->subsections() as $subsection ) {
413
+		foreach ($this->subsections() as $subsection) {
414 414
 			$subsection->enqueue_js();
415 415
 		}
416 416
 	}
@@ -427,10 +427,10 @@  discard block
 block discarded – undo
427 427
 	 * @param boolean $init_form_validation_automatically whether or not we want the form validation to be triggered automatically or not
428 428
 	 * @return void
429 429
 	 */
430
-	public static function wp_enqueue_scripts( $init_form_validation_automatically = true ){
431
-		add_filter( 'FHEE_load_jquery_validate', '__return_true' );
432
-		wp_register_script( 'ee_form_section_validation', EE_GLOBAL_ASSETS_URL . 'scripts' . DS . 'form_section_validation.js', array( 'jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods' ), EVENT_ESPRESSO_VERSION, TRUE );
433
-		wp_localize_script( 'ee_form_section_validation', 'ee_form_section_validation_init', array( 'init' => $init_form_validation_automatically ? true : false ) );
430
+	public static function wp_enqueue_scripts($init_form_validation_automatically = true) {
431
+		add_filter('FHEE_load_jquery_validate', '__return_true');
432
+		wp_register_script('ee_form_section_validation', EE_GLOBAL_ASSETS_URL.'scripts'.DS.'form_section_validation.js', array('jquery-validate', 'jquery-ui-datepicker', 'jquery-validate-extra-methods'), EVENT_ESPRESSO_VERSION, TRUE);
433
+		wp_localize_script('ee_form_section_validation', 'ee_form_section_validation_init', array('init' => $init_form_validation_automatically ? true : false));
434 434
 	}
435 435
 
436 436
 
@@ -442,14 +442,14 @@  discard block
 block discarded – undo
442 442
 	 *
443 443
 	 * @throws \EE_Error
444 444
 	 */
445
-	public function _enqueue_and_localize_form_js(){
445
+	public function _enqueue_and_localize_form_js() {
446 446
 		$this->ensure_construct_finalized_called();
447 447
 		//actually, we don't want to localize just yet. There may be other forms on the page.
448 448
 		//so we need to add our form section data to a static variable accessible by all form sections
449 449
 		//and localize it just before the footer
450 450
 		$this->localize_validation_rules();
451
-		add_action( 'wp_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ), 2 );
452
-		add_action( 'admin_footer', array( 'EE_Form_Section_Proper', 'localize_script_for_all_forms' ) );
451
+		add_action('wp_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'), 2);
452
+		add_action('admin_footer', array('EE_Form_Section_Proper', 'localize_script_for_all_forms'));
453 453
 	}
454 454
 
455 455
 
@@ -461,11 +461,11 @@  discard block
 block discarded – undo
461 461
 	 * @return void
462 462
 	 * @throws \EE_Error
463 463
 	 */
464
-	public function localize_validation_rules( $return_for_subsection = FALSE ){
464
+	public function localize_validation_rules($return_for_subsection = FALSE) {
465 465
 		// we only want to localize vars ONCE for the entire form, so if the form section doesn't have a parent, then it must be the top dog
466
-		if ( $return_for_subsection || ! $this->parent_section() ) {
467
-			EE_Form_Section_Proper::$_js_localization['form_data'][ $this->html_id() ] = array(
468
-				'form_section_id'=> $this->html_id( TRUE ),
466
+		if ($return_for_subsection || ! $this->parent_section()) {
467
+			EE_Form_Section_Proper::$_js_localization['form_data'][$this->html_id()] = array(
468
+				'form_section_id'=> $this->html_id(TRUE),
469 469
 				'validation_rules'=> $this->get_jquery_validation_rules(),
470 470
 				'other_data' => $this->get_other_js_data(),
471 471
 				'errors'=> $this->subsection_validation_errors_by_html_name()
@@ -481,9 +481,9 @@  discard block
 block discarded – undo
481 481
 	 * @param array $form_other_js_data
482 482
 	 * @return array
483 483
 	 */
484
-	public function get_other_js_data( $form_other_js_data = array() ) {
485
-		foreach( $this->subsections() as $subsection ) {
486
-			$form_other_js_data = $subsection->get_other_js_data( $form_other_js_data );
484
+	public function get_other_js_data($form_other_js_data = array()) {
485
+		foreach ($this->subsections() as $subsection) {
486
+			$form_other_js_data = $subsection->get_other_js_data($form_other_js_data);
487 487
 		}
488 488
 		return $form_other_js_data;
489 489
 	}
@@ -494,12 +494,12 @@  discard block
 block discarded – undo
494 494
 	 * Keys are their form names, and values are the inputs themselves
495 495
 	 * @return EE_Form_Input_Base
496 496
 	 */
497
-	public function inputs_in_subsections(){
497
+	public function inputs_in_subsections() {
498 498
 		$inputs = array();
499
-		foreach($this->subsections() as $subsection){
500
-			if( $subsection instanceof EE_Form_Input_Base ){
501
-				$inputs[ $subsection->html_name() ] = $subsection;
502
-			}elseif($subsection instanceof EE_Form_Section_Proper ){
499
+		foreach ($this->subsections() as $subsection) {
500
+			if ($subsection instanceof EE_Form_Input_Base) {
501
+				$inputs[$subsection->html_name()] = $subsection;
502
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
503 503
 				$inputs += $subsection->inputs_in_subsections();
504 504
 			}
505 505
 		}
@@ -512,12 +512,12 @@  discard block
 block discarded – undo
512 512
 	 * and values are a string of all their validation errors
513 513
 	 * @return string[]
514 514
 	 */
515
-	public function subsection_validation_errors_by_html_name(){
515
+	public function subsection_validation_errors_by_html_name() {
516 516
 		$inputs = $this->inputs();
517 517
 		$errors = array();
518
-		foreach( $inputs as $form_input ){
519
-			if ( $form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors() ){
520
-				$errors[ $form_input->html_name() ] = $form_input->get_validation_error_string();
518
+		foreach ($inputs as $form_input) {
519
+			if ($form_input instanceof EE_Form_Input_Base && $form_input->get_validation_errors()) {
520
+				$errors[$form_input->html_name()] = $form_input->get_validation_error_string();
521 521
 			}
522 522
 		}
523 523
 		return $errors;
@@ -529,16 +529,16 @@  discard block
 block discarded – undo
529 529
 	 * passes all the form data required by the JS to the JS, and enqueues the few required JS files.
530 530
 	 * Should be setup by each form during the _enqueues_and_localize_form_js
531 531
 	 */
532
-	public static function localize_script_for_all_forms(){
532
+	public static function localize_script_for_all_forms() {
533 533
 		//allow inputs and stuff to hook in their JS and stuff here
534 534
 		do_action('AHEE__EE_Form_Section_Proper__localize_script_for_all_forms__begin');
535 535
 		EE_Form_Section_Proper::$_js_localization['localized_error_messages'] = EE_Form_Section_Proper::_get_localized_error_messages();
536
-		$email_validation_level = isset( EE_Registry::instance()->CFG->registration->email_validation_level )
536
+		$email_validation_level = isset(EE_Registry::instance()->CFG->registration->email_validation_level)
537 537
 			? EE_Registry::instance()->CFG->registration->email_validation_level
538 538
 			: 'wp_default';
539 539
 		EE_Form_Section_Proper::$_js_localization['email_validation_level'] = $email_validation_level;
540
-		wp_enqueue_script( 'ee_form_section_validation' );
541
-		wp_localize_script( 'ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization );
540
+		wp_enqueue_script('ee_form_section_validation');
541
+		wp_localize_script('ee_form_section_validation', 'ee_form_section_vars', EE_Form_Section_Proper::$_js_localization);
542 542
 	}
543 543
 
544 544
 
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	/**
547 547
 	 * ensure_scripts_localized
548 548
 	 */
549
-	public function ensure_scripts_localized(){
550
-		if ( ! EE_Form_Section_Proper::$_scripts_localized ) {
549
+	public function ensure_scripts_localized() {
550
+		if ( ! EE_Form_Section_Proper::$_scripts_localized) {
551 551
 			$this->_enqueue_and_localize_form_js();
552 552
 		}
553 553
 	}
@@ -559,10 +559,10 @@  discard block
 block discarded – undo
559 559
 	 * is that the key here should be the same as the custom validation rule put in the JS file
560 560
 	 * @return array keys are custom validation rules, and values are internationalized strings
561 561
 	 */
562
-	private static function _get_localized_error_messages(){
562
+	private static function _get_localized_error_messages() {
563 563
 		return array(
564 564
 			'validUrl'=>  __("This is not a valid absolute URL. Eg, http://domain.com/monkey.jpg", "event_espresso"),
565
-			'regex' => __( 'Please check your input', 'event_espresso' ),
565
+			'regex' => __('Please check your input', 'event_espresso'),
566 566
 		);
567 567
 	}
568 568
 
@@ -590,10 +590,10 @@  discard block
 block discarded – undo
590 590
 	 * Gets the JS to put inside the jquery validation rules for subsection of this form section. See parent function for more...
591 591
 	 * @return array
592 592
 	 */
593
-	public function get_jquery_validation_rules(){
593
+	public function get_jquery_validation_rules() {
594 594
 		$jquery_validation_rules = array();
595
-		foreach($this->get_validatable_subsections() as $subsection){
596
-			$jquery_validation_rules = array_merge( $jquery_validation_rules,  $subsection->get_jquery_validation_rules() );
595
+		foreach ($this->get_validatable_subsections() as $subsection) {
596
+			$jquery_validation_rules = array_merge($jquery_validation_rules, $subsection->get_jquery_validation_rules());
597 597
 		}
598 598
 		return $jquery_validation_rules;
599 599
 	}
@@ -608,11 +608,11 @@  discard block
 block discarded – undo
608 608
 	protected function _normalize($req_data) {
609 609
 		$this->_received_submission = TRUE;
610 610
 		$this->_validation_errors = array();
611
-		foreach($this->get_validatable_subsections() as $subsection){
612
-			try{
611
+		foreach ($this->get_validatable_subsections() as $subsection) {
612
+			try {
613 613
 				$subsection->_normalize($req_data);
614
-			}catch( EE_Validation_Error $e ){
615
-				$subsection->add_validation_error( $e );
614
+			} catch (EE_Validation_Error $e) {
615
+				$subsection->add_validation_error($e);
616 616
 			}
617 617
 		}
618 618
 	}
@@ -626,9 +626,9 @@  discard block
 block discarded – undo
626 626
 	 * calling parent::_validate() first.
627 627
 	 */
628 628
 	protected function _validate() {
629
-		foreach($this->get_validatable_subsections() as $subsection_name => $subsection){
630
-			if(method_exists($this,'_validate_'.$subsection_name)){
631
-				call_user_func_array(array($this,'_validate_'.$subsection_name), array($subsection));
629
+		foreach ($this->get_validatable_subsections() as $subsection_name => $subsection) {
630
+			if (method_exists($this, '_validate_'.$subsection_name)) {
631
+				call_user_func_array(array($this, '_validate_'.$subsection_name), array($subsection));
632 632
 			}
633 633
 			$subsection->_validate();
634 634
 		}
@@ -640,13 +640,13 @@  discard block
 block discarded – undo
640 640
 	 * Gets all the validated inputs for the form section
641 641
 	 * @return array
642 642
 	 */
643
-	public function valid_data(){
643
+	public function valid_data() {
644 644
 		$inputs = array();
645
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
646
-			if ( $subsection instanceof EE_Form_Section_Proper ) {
647
-				$inputs[ $subsection_name ] = $subsection->valid_data();
648
-			} else if ( $subsection instanceof EE_Form_Input_Base ){
649
-				$inputs[ $subsection_name ] = $subsection->normalized_value();
645
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
646
+			if ($subsection instanceof EE_Form_Section_Proper) {
647
+				$inputs[$subsection_name] = $subsection->valid_data();
648
+			} else if ($subsection instanceof EE_Form_Input_Base) {
649
+				$inputs[$subsection_name] = $subsection->normalized_value();
650 650
 			}
651 651
 		}
652 652
 		return $inputs;
@@ -658,11 +658,11 @@  discard block
 block discarded – undo
658 658
 	 * Gets all the inputs on this form section
659 659
 	 * @return EE_Form_Input_Base[]
660 660
 	 */
661
-	public function inputs(){
661
+	public function inputs() {
662 662
 		$inputs = array();
663
-		foreach( $this->subsections() as $subsection_name =>$subsection ){
664
-			if ( $subsection instanceof EE_Form_Input_Base ){
665
-				$inputs[ $subsection_name ] = $subsection;
663
+		foreach ($this->subsections() as $subsection_name =>$subsection) {
664
+			if ($subsection instanceof EE_Form_Input_Base) {
665
+				$inputs[$subsection_name] = $subsection;
666 666
 			}
667 667
 		}
668 668
 		return $inputs;
@@ -674,10 +674,10 @@  discard block
 block discarded – undo
674 674
 	 * Gets all the subsections which are a proper form
675 675
 	 * @return EE_Form_Section_Proper[]
676 676
 	 */
677
-	public function subforms(){
677
+	public function subforms() {
678 678
 		$form_sections = array();
679
-		foreach($this->subsections() as $name=>$obj){
680
-			if($obj instanceof EE_Form_Section_Proper){
679
+		foreach ($this->subsections() as $name=>$obj) {
680
+			if ($obj instanceof EE_Form_Section_Proper) {
681 681
 				$form_sections[$name] = $obj;
682 682
 			}
683 683
 		}
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
 	 * if you only want form inputs or proper form sections.
693 693
 	 * @return EE_Form_Section_Proper[]
694 694
 	 */
695
-	public function subsections(){
695
+	public function subsections() {
696 696
 		$this->ensure_construct_finalized_called();
697 697
 		return $this->_subsections;
698 698
 	}
@@ -710,8 +710,8 @@  discard block
 block discarded – undo
710 710
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
711 711
 	 * input's normalized value, or an array like the top-level array
712 712
 	 */
713
-	public function input_values( $include_subform_inputs = false, $flatten = false ){
714
-		return $this->_input_values( false, $include_subform_inputs, $flatten );
713
+	public function input_values($include_subform_inputs = false, $flatten = false) {
714
+		return $this->_input_values(false, $include_subform_inputs, $flatten);
715 715
 	}
716 716
 
717 717
 	/**
@@ -727,8 +727,8 @@  discard block
 block discarded – undo
727 727
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
728 728
 	 * input's normalized value, or an array like the top-level array
729 729
 	 */
730
-	public function input_pretty_values(  $include_subform_inputs = false, $flatten = false ){
731
-		return $this->_input_values( true, $include_subform_inputs, $flatten );
730
+	public function input_pretty_values($include_subform_inputs = false, $flatten = false) {
731
+		return $this->_input_values(true, $include_subform_inputs, $flatten);
732 732
 	}
733 733
 
734 734
 	/**
@@ -741,17 +741,17 @@  discard block
 block discarded – undo
741 741
 	 * it can be a multidimensional array where keys are always subsection names and values are either the
742 742
 	 * input's normalized value, or an array like the top-level array
743 743
 	 */
744
-	public function _input_values( $pretty = false, $include_subform_inputs = false, $flatten = false ) {
744
+	public function _input_values($pretty = false, $include_subform_inputs = false, $flatten = false) {
745 745
 		$input_values = array();
746
-		foreach( $this->subsections() as $subsection_name => $subsection ) {
747
-			if( $subsection instanceof EE_Form_Input_Base ) {
748
-				$input_values[ $subsection_name ] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value();
749
-			} else if( $subsection instanceof EE_Form_Section_Proper && $include_subform_inputs ) {
750
-				$subform_input_values = $subsection->_input_values( $pretty, $include_subform_inputs, $flatten );
751
-				if( $flatten ) {
752
-					$input_values = array_merge( $input_values, $subform_input_values );
746
+		foreach ($this->subsections() as $subsection_name => $subsection) {
747
+			if ($subsection instanceof EE_Form_Input_Base) {
748
+				$input_values[$subsection_name] = $pretty ? $subsection->pretty_value() : $subsection->normalized_value();
749
+			} else if ($subsection instanceof EE_Form_Section_Proper && $include_subform_inputs) {
750
+				$subform_input_values = $subsection->_input_values($pretty, $include_subform_inputs, $flatten);
751
+				if ($flatten) {
752
+					$input_values = array_merge($input_values, $subform_input_values);
753 753
 				} else {
754
-					$input_values[ $subsection_name ] = $subform_input_values;
754
+					$input_values[$subsection_name] = $subform_input_values;
755 755
 				}
756 756
 			}
757 757
 		}
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
 	 * @return boolean
768 768
 	 * @throws \EE_Error
769 769
 	 */
770
-	public function has_received_submission(){
770
+	public function has_received_submission() {
771 771
 		$this->ensure_construct_finalized_called();
772 772
 		return $this->_received_submission;
773 773
 	}
@@ -780,8 +780,8 @@  discard block
 block discarded – undo
780 780
 	 * @param array $inputs_to_exclude values are the input names
781 781
 	 * @return void
782 782
 	 */
783
-	public function exclude($inputs_to_exclude = array()){
784
-		foreach($inputs_to_exclude as $input_to_exclude_name){
783
+	public function exclude($inputs_to_exclude = array()) {
784
+		foreach ($inputs_to_exclude as $input_to_exclude_name) {
785 785
 			unset($this->_subsections[$input_to_exclude_name]);
786 786
 		}
787 787
 	}
@@ -792,8 +792,8 @@  discard block
 block discarded – undo
792 792
 	 * @param array $inputs_to_hide
793 793
 	 * @throws \EE_Error
794 794
 	 */
795
-	public function hide($inputs_to_hide= array()){
796
-		foreach($inputs_to_hide as $input_to_hide){
795
+	public function hide($inputs_to_hide = array()) {
796
+		foreach ($inputs_to_hide as $input_to_hide) {
797 797
 			$input = $this->get_input($input_to_hide);
798 798
 
799 799
 			$input->set_display_strategy(new EE_Hidden_Display_Strategy());
@@ -818,13 +818,13 @@  discard block
 block discarded – undo
818 818
 	 * @return void
819 819
 	 * @throws \EE_Error
820 820
 	 */
821
-	public function add_subsections( $new_subsections, $subsection_name_to_target = NULL, $add_before = true ){
822
-		foreach($new_subsections as $subsection_name => $subsection){
823
-			if( ! $subsection instanceof EE_Form_Section_Base){
821
+	public function add_subsections($new_subsections, $subsection_name_to_target = NULL, $add_before = true) {
822
+		foreach ($new_subsections as $subsection_name => $subsection) {
823
+			if ( ! $subsection instanceof EE_Form_Section_Base) {
824 824
 				EE_Error::add_error(
825 825
 					sprintf(
826 826
 						__("Trying to add a %s as a subsection (it was named '%s') to the form section '%s'. It was removed.", "event_espresso"),
827
-						get_class( $subsection ),
827
+						get_class($subsection),
828 828
 						$subsection_name,
829 829
 						$this->name()
830 830
 					)
@@ -833,7 +833,7 @@  discard block
 block discarded – undo
833 833
 			}
834 834
 		}
835 835
 
836
-		$this->_subsections = EEH_Array::insert_into_array( $this->_subsections, $new_subsections, $subsection_name_to_target, $add_before );
836
+		$this->_subsections = EEH_Array::insert_into_array($this->_subsections, $new_subsections, $subsection_name_to_target, $add_before);
837 837
 
838 838
 		/*$subsections_before = array();
839 839
 		if( $subsection_name_to_target ){
@@ -864,8 +864,8 @@  discard block
 block discarded – undo
864 864
 				$this->_subsections = $new_subsections;
865 865
 			}
866 866
 		}*/
867
-		if( $this->_construction_finalized ){
868
-			foreach($this->_subsections as $name => $subsection){
867
+		if ($this->_construction_finalized) {
868
+			foreach ($this->_subsections as $name => $subsection) {
869 869
 				$subsection->_construct_finalize($this, $name);
870 870
 			}
871 871
 		}
@@ -876,8 +876,8 @@  discard block
 block discarded – undo
876 876
 	/**
877 877
 	 * Just gets all validatable subsections to clean their sensitive data
878 878
 	 */
879
-	public function clean_sensitive_data(){
880
-		foreach($this->get_validatable_subsections() as $subsection){
879
+	public function clean_sensitive_data() {
880
+		foreach ($this->get_validatable_subsections() as $subsection) {
881 881
 			$subsection->clean_sensitive_data();
882 882
 		}
883 883
 	}
@@ -887,8 +887,8 @@  discard block
 block discarded – undo
887 887
 	/**
888 888
 	 * @param string $form_submission_error_message
889 889
 	 */
890
-	public function set_submission_error_message( $form_submission_error_message = '' ) {
891
-		$this->_form_submission_error_message .= ! empty( $form_submission_error_message ) ? $form_submission_error_message : __( 'Form submission failed due to errors', 'event_espresso' );
890
+	public function set_submission_error_message($form_submission_error_message = '') {
891
+		$this->_form_submission_error_message .= ! empty($form_submission_error_message) ? $form_submission_error_message : __('Form submission failed due to errors', 'event_espresso');
892 892
 	}
893 893
 
894 894
 
@@ -905,8 +905,8 @@  discard block
 block discarded – undo
905 905
 	/**
906 906
 	 * @param string $form_submission_success_message
907 907
 	 */
908
-	public function set_submission_success_message( $form_submission_success_message ) {
909
-		$this->_form_submission_success_message .= ! empty( $form_submission_success_message ) ? $form_submission_success_message : __( 'Form submitted successfully', 'event_espresso' );
908
+	public function set_submission_success_message($form_submission_success_message) {
909
+		$this->_form_submission_success_message .= ! empty($form_submission_success_message) ? $form_submission_success_message : __('Form submitted successfully', 'event_espresso');
910 910
 	}
911 911
 
912 912
 
@@ -929,10 +929,10 @@  discard block
 block discarded – undo
929 929
 	 * @return string
930 930
 	 * @throws \EE_Error
931 931
 	 */
932
-	public function html_name_prefix(){
933
-		if( $this->parent_section() instanceof EE_Form_Section_Proper ){
934
-			return $this->parent_section()->html_name_prefix() . '[' . $this->name() . ']';
935
-		}else{
932
+	public function html_name_prefix() {
933
+		if ($this->parent_section() instanceof EE_Form_Section_Proper) {
934
+			return $this->parent_section()->html_name_prefix().'['.$this->name().']';
935
+		} else {
936 936
 			return $this->name();
937 937
 		}
938 938
 	}
@@ -947,7 +947,7 @@  discard block
 block discarded – undo
947 947
 	 * @return string
948 948
 	 * @throws \EE_Error
949 949
 	 */
950
-	public function name(){
950
+	public function name() {
951 951
 		$this->ensure_construct_finalized_called();
952 952
 		return parent::name();
953 953
 	}
@@ -958,7 +958,7 @@  discard block
 block discarded – undo
958 958
 	 * @return EE_Form_Section_Proper
959 959
 	 * @throws \EE_Error
960 960
 	 */
961
-	public function parent_section(){
961
+	public function parent_section() {
962 962
 		$this->ensure_construct_finalized_called();
963 963
 		return parent::parent_section();
964 964
 	}
@@ -971,9 +971,9 @@  discard block
 block discarded – undo
971 971
 	 * @return void
972 972
 	 * @throws \EE_Error
973 973
 	 */
974
-	public function ensure_construct_finalized_called(){
975
-		if( ! $this->_construction_finalized ){
976
-			$this->_construct_finalize($this->_parent_section, $this->_name );
974
+	public function ensure_construct_finalized_called() {
975
+		if ( ! $this->_construction_finalized) {
976
+			$this->_construct_finalize($this->_parent_section, $this->_name);
977 977
 		}
978 978
 	}
979 979
 
@@ -985,17 +985,17 @@  discard block
 block discarded – undo
985 985
 	 * @param array $req_data
986 986
 	 * @return boolean
987 987
 	 */
988
-	public function form_data_present_in( $req_data = NULL ) {
989
-		if( $req_data === NULL){
988
+	public function form_data_present_in($req_data = NULL) {
989
+		if ($req_data === NULL) {
990 990
 			$req_data = $_POST;
991 991
 		}
992
-		foreach( $this->subsections() as $subsection ) {
993
-			if($subsection instanceof EE_Form_Input_Base ) {
994
-				if( $subsection->form_data_present_in( $req_data ) ) {
992
+		foreach ($this->subsections() as $subsection) {
993
+			if ($subsection instanceof EE_Form_Input_Base) {
994
+				if ($subsection->form_data_present_in($req_data)) {
995 995
 					return TRUE;
996 996
 				}
997
-			}elseif( $subsection instanceof EE_Form_Section_Proper ) {
998
-				if( $subsection->form_data_present_in( $req_data ) ) {
997
+			}elseif ($subsection instanceof EE_Form_Section_Proper) {
998
+				if ($subsection->form_data_present_in($req_data)) {
999 999
 					return TRUE;
1000 1000
 				}
1001 1001
 			}
@@ -1012,14 +1012,14 @@  discard block
 block discarded – undo
1012 1012
 	 */
1013 1013
 	public function get_validation_errors_accumulated() {
1014 1014
 		$validation_errors = $this->get_validation_errors();
1015
-		foreach($this->get_validatable_subsections() as $subsection ) {
1016
-			if( $subsection instanceof EE_Form_Section_Proper ) {
1015
+		foreach ($this->get_validatable_subsections() as $subsection) {
1016
+			if ($subsection instanceof EE_Form_Section_Proper) {
1017 1017
 				$validation_errors_on_this_subsection = $subsection->get_validation_errors_accumulated();
1018 1018
 			} else {
1019
-				$validation_errors_on_this_subsection =  $subsection->get_validation_errors();
1019
+				$validation_errors_on_this_subsection = $subsection->get_validation_errors();
1020 1020
 			}
1021
-			if( $validation_errors_on_this_subsection ){
1022
-				$validation_errors = array_merge( $validation_errors, $validation_errors_on_this_subsection );
1021
+			if ($validation_errors_on_this_subsection) {
1022
+				$validation_errors = array_merge($validation_errors, $validation_errors_on_this_subsection);
1023 1023
 			}
1024 1024
 		}
1025 1025
 		return $validation_errors;
@@ -1041,24 +1041,24 @@  discard block
 block discarded – undo
1041 1041
 	 * @param string|false $form_section_path we accept false also because substr( '../', '../' ) = false
1042 1042
 	 * @return EE_Form_Section_Base
1043 1043
 	 */
1044
-	public function find_section_from_path( $form_section_path ) {
1044
+	public function find_section_from_path($form_section_path) {
1045 1045
 		//check if we can find the input from purely going straight up the tree
1046
-		$input = parent::find_section_from_path( $form_section_path );
1047
-		if( $input instanceof EE_Form_Section_Base ) {
1046
+		$input = parent::find_section_from_path($form_section_path);
1047
+		if ($input instanceof EE_Form_Section_Base) {
1048 1048
 			return $input;
1049 1049
 		}
1050 1050
 
1051
-		$next_slash_pos = strpos( $form_section_path, '/' );
1052
-		if( $next_slash_pos !== false ) {
1053
-			$child_section_name = substr( $form_section_path, 0, $next_slash_pos );
1054
-			$subpath = substr( $form_section_path, $next_slash_pos + 1 );
1051
+		$next_slash_pos = strpos($form_section_path, '/');
1052
+		if ($next_slash_pos !== false) {
1053
+			$child_section_name = substr($form_section_path, 0, $next_slash_pos);
1054
+			$subpath = substr($form_section_path, $next_slash_pos + 1);
1055 1055
 		} else {
1056 1056
 			$child_section_name = $form_section_path;
1057 1057
 			$subpath = '';
1058 1058
 		}
1059
-		$child_section =  $this->get_subsection( $child_section_name );
1060
-		if ( $child_section instanceof EE_Form_Section_Base ) {
1061
-			return $child_section->find_section_from_path( $subpath );
1059
+		$child_section = $this->get_subsection($child_section_name);
1060
+		if ($child_section instanceof EE_Form_Section_Base) {
1061
+			return $child_section->find_section_from_path($subpath);
1062 1062
 		} else {
1063 1063
 			return null;
1064 1064
 		}
Please login to merge, or discard this patch.
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -248,7 +248,7 @@
 block discarded – undo
248 248
 	 *                                                      with construction finalize being called later
249 249
 	 *                                                      (realizing that the subsections' html names
250 250
 	 *                                                      might not be set yet, etc.)
251
-	 * @return EE_Form_Section_Base
251
+	 * @return EE_Form_Section_Validatable|null
252 252
 	 * @throws \EE_Error
253 253
 	 */
254 254
 	public function get_subsection($name, $require_construction_to_be_finalized = TRUE ){
Please login to merge, or discard this patch.