Completed
Branch BUG-9647-cpt-queries (303307)
by
unknown
560:33 queued 542:03
created
core/libraries/messages/EE_message_type.lib.php 4 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -767,7 +767,7 @@
 block discarded – undo
767 767
 	 * Takes care of setting up the addressee object(s) for the primary attendee.
768 768
 	 *
769 769
 	 * @access protected
770
-	 * @return array of EE_Addressee objects
770
+	 * @return EE_Messages_Addressee[] of EE_Addressee objects
771 771
 	 */
772 772
 	protected function _primary_attendee_addressees() {
773 773
 		$aee = $this->_default_addressee_data;
Please login to merge, or discard this patch.
Indentation   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -326,11 +326,11 @@
 block discarded – undo
326 326
 	/**
327 327
 	 * This sets up any action/filter hooks this message type puts in place for a specific messenger.  Note that by
328 328
 	 * default this does nothing.  Child classes will need to override if they want to add specific hooks for a messenger.
329
-	*
330
-	* @since 1.0.0
331
-	*
332
-	* @return void
333
-	*/
329
+	 *
330
+	 * @since 1.0.0
331
+	 *
332
+	 * @return void
333
+	 */
334 334
 	protected function _do_messenger_hooks() {
335 335
 		return;
336 336
 	}
Please login to merge, or discard this patch.
Braces   +8 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,6 +1,7 @@  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 6
 /**
6 7
  * Event Espresso
@@ -655,8 +656,9 @@  discard block
 block discarded – undo
655 656
 		//process addressees for each context.  Child classes will have to have methods for each context defined to handle the processing of the data object within them
656 657
 		foreach ( $this->_contexts as $context => $details ) {
657 658
 			$xpctd_method = '_' . $context . '_addressees';
658
-			if ( !method_exists( $this, $xpctd_method ) )
659
-				throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) );
659
+			if ( !method_exists( $this, $xpctd_method ) ) {
660
+							throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) );
661
+			}
660 662
 			 $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) );
661 663
 		}
662 664
 		return true; //data was processed successfully.
@@ -823,7 +825,9 @@  discard block
 block discarded – undo
823 825
 			//set the attendee array to blank on each loop;
824 826
 			$aee = array();
825 827
 
826
-			if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue;
828
+			if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) {
829
+				continue;
830
+			}
827 831
 
828 832
 			//is $this->_regs_for_sending present?  If so, let's make sure we ONLY generate addressee for registrations in that array.
829 833
 			if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) {
Please login to merge, or discard this patch.
Spacing   +72 added lines, -72 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
 /**
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	 * @param int      $id 		Optional. Integer corresponding to the value for the primary key of a EE_Base_Class_Object
286 286
 	 * @return mixed ( EE_Base_Class||EE_Base_Class[] )
287 287
 	 */
288
-	abstract protected function _get_data_for_context( $context, EE_Registration $registration, $id );
288
+	abstract protected function _get_data_for_context($context, EE_Registration $registration, $id);
289 289
 
290 290
 
291 291
 
@@ -315,7 +315,7 @@  discard block
 block discarded – undo
315 315
 	 * @deprecated 4.9.0
316 316
 	 * @return int
317 317
 	 */
318
-	protected function _get_id_for_msg_url( $context, EE_Registration $registration ) {
318
+	protected function _get_id_for_msg_url($context, EE_Registration $registration) {
319 319
 		return 0;
320 320
 	}
321 321
 
@@ -346,7 +346,7 @@  discard block
 block discarded – undo
346 346
 	 *                          what messenger is being used to send the message at the time of sending.
347 347
 	 * @since 4.9.0
348 348
 	 */
349
-	public function do_messenger_hooks( $messenger = null ) {
349
+	public function do_messenger_hooks($messenger = null) {
350 350
 		$this->_active_messenger = $messenger;
351 351
 		$this->_do_messenger_hooks();
352 352
 	}
@@ -405,10 +405,10 @@  discard block
 block discarded – undo
405 405
 	 * @param mixed $data This sets the data property for the message type with the incoming data used for generating.
406 406
 	 * @return string (the reference for the data handler) (will be an empty string if could not be determined).
407 407
 	 */
408
-	public function get_data_handler( $data ) {
408
+	public function get_data_handler($data) {
409 409
 		$this->_data = $data;
410 410
 		$this->_set_data_handler();
411
-		return apply_filters( 'FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this );
411
+		return apply_filters('FHEE__EE_message_type__get_data_handler', $this->_data_handler, $this);
412 412
 	}
413 413
 
414 414
 
@@ -447,28 +447,28 @@  discard block
 block discarded – undo
447 447
 	 * @deprecated  4.9.0  Likely 4.9.10 or 4.10.0 will remove this method completely
448 448
 	 * @return string          generated url
449 449
 	 */
450
-	public function get_url_trigger( $context, $sending_messenger, EE_Registration $registration ) {
450
+	public function get_url_trigger($context, $sending_messenger, EE_Registration $registration) {
451 451
 
452 452
 		//validate context
453 453
 		//valid context?
454
-		if ( !isset( $this->_contexts[$context] ) ) {
455
-			throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) );
454
+		if ( ! isset($this->_contexts[$context])) {
455
+			throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this)));
456 456
 		}
457 457
 
458 458
 		//valid sending_messenger?
459 459
 		$not_valid_msgr = FALSE;
460
-		foreach ( $this->_with_messengers as $generating => $sendings ) {
461
-			if ( empty( $sendings ) || array_search( $sending_messenger, $sendings ) === FALSE ) {
460
+		foreach ($this->_with_messengers as $generating => $sendings) {
461
+			if (empty($sendings) || array_search($sending_messenger, $sendings) === FALSE) {
462 462
 				$not_valid_msgr = TRUE;
463 463
 			}
464 464
 		}
465 465
 
466
-		if ( $not_valid_msgr ) {
467
-			throw new EE_Error( sprintf( __('The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class( $this ) ) );
466
+		if ($not_valid_msgr) {
467
+			throw new EE_Error(sprintf(__('The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class($this)));
468 468
 		}
469 469
 
470 470
 		EE_Registry::instance()->load_helper('MSG_Template');
471
-		return EEH_MSG_Template::generate_url_trigger( $sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url( $context, $registration ) );
471
+		return EEH_MSG_Template::generate_url_trigger($sending_messenger, $this->_active_messenger->name, $context, $this->name, $registration, $this->_GRP_ID, $this->_get_id_for_msg_url($context, $registration));
472 472
 	}
473 473
 
474 474
 
@@ -489,19 +489,19 @@  discard block
 block discarded – undo
489 489
 	 *
490 490
 	 * @return mixed (EE_Base_Class||EE_Base_Class[])
491 491
 	 */
492
-	public function get_data_for_context( $context, EE_Registration $registration, $id = 0 ) {
492
+	public function get_data_for_context($context, EE_Registration $registration, $id = 0) {
493 493
 		//valid context?
494
-		if ( !isset( $this->_contexts[$context] ) ) {
495
-			throw new EE_Error( sprintf( __('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class( $this ) ) );
494
+		if ( ! isset($this->_contexts[$context])) {
495
+			throw new EE_Error(sprintf(__('The context %s is not a valid context for %s.', 'event_espresso'), $context, get_class($this)));
496 496
 		}
497 497
 
498 498
 		//get data and apply global and class specific filters on it.
499
-		$data = apply_filters( 'FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context( $context, $registration, $id ), $this );
500
-		$data = apply_filters( 'FHEE__' . get_class( $this ) . '__get_data_for_context__data', $data, $this );
499
+		$data = apply_filters('FHEE__EE_message_type__get_data_for_context__data', $this->_get_data_for_context($context, $registration, $id), $this);
500
+		$data = apply_filters('FHEE__'.get_class($this).'__get_data_for_context__data', $data, $this);
501 501
 
502 502
 		//if empty then something went wrong!
503
-		if ( empty( $data ) ) {
504
-			throw new EE_Error( sprintf(  __('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name ) );
503
+		if (empty($data)) {
504
+			throw new EE_Error(sprintf(__('There is no data retrieved, it is possible that the id given (%d) does not match any value in the database for the corresponding EE_Base_Class used by the data handler for the %s message type.', 'event_espresso'), $id, $this->name));
505 505
 		}
506 506
 
507 507
 		return $data;
@@ -552,7 +552,7 @@  discard block
 block discarded – undo
552 552
 	 */
553 553
 	public function with_messengers() {
554 554
 
555
-		return apply_filters( 'FHEE__EE_message_type__get_with_messengers__with_messengers__' . get_class( $this ), $this->_with_messengers);
555
+		return apply_filters('FHEE__EE_message_type__get_with_messengers__with_messengers__'.get_class($this), $this->_with_messengers);
556 556
 	}
557 557
 
558 558
 
@@ -570,9 +570,9 @@  discard block
 block discarded – undo
570 570
 	 * @access public
571 571
 	 * @return string
572 572
 	 */
573
-	public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array() ) {
573
+	public function get_message_type_admin_page_content($page, $action = NULL, $extra = array(), $messengers = array()) {
574 574
 		//we can also further refine the context by action (if present).
575
-		return $this->_get_admin_page_content( $page, $action, $extra, $messengers );
575
+		return $this->_get_admin_page_content($page, $action, $extra, $messengers);
576 576
 	}
577 577
 
578 578
 
@@ -602,8 +602,8 @@  discard block
 block discarded – undo
602 602
 	 */
603 603
 	public function get_master_templates() {
604 604
 		//first class specific filter then filter that by the global filter.
605
-		$master_templates = apply_filters( 'FHEE__' . get_class( $this ) . '__get_master_templates', $this->_master_templates );
606
-		return apply_filters( 'FHEE__EE_message_type__get_master_templates', $master_templates, $this );
605
+		$master_templates = apply_filters('FHEE__'.get_class($this).'__get_master_templates', $this->_master_templates);
606
+		return apply_filters('FHEE__EE_message_type__get_master_templates', $master_templates, $this);
607 607
 	}
608 608
 
609 609
 
@@ -617,23 +617,23 @@  discard block
 block discarded – undo
617 617
 	 * @return array   An array indexed by context where each context is an array of EE_Messages_Addressee objects for
618 618
 	 *                 that context
619 619
 	 */
620
-	public function get_addressees( EE_Messages_incoming_data $data, $context = '' ) {
620
+	public function get_addressees(EE_Messages_incoming_data $data, $context = '') {
621 621
 		//override _data
622 622
 		$this->_data = $data;
623 623
 		$addressees = array();
624 624
 
625 625
 		//if incoming context then limit to that context
626
-		if ( ! empty( $context ) ) {
627
-			$cntxt = ! empty( $this->_contexts[$context] ) ? $this->_contexts[$context] : '';
628
-			if ( ! empty( $cntxt )  ) {
626
+		if ( ! empty($context)) {
627
+			$cntxt = ! empty($this->_contexts[$context]) ? $this->_contexts[$context] : '';
628
+			if ( ! empty($cntxt)) {
629 629
 				$this->_contexts = array();
630 630
 				$this->_contexts[$context] = $cntxt;
631 631
 			}
632 632
 		}
633 633
 
634 634
 		$this->_set_default_addressee_data();
635
-		if ( $this->_process_data() ) {
636
-			$addressees =  $this->_addressees;
635
+		if ($this->_process_data()) {
636
+			$addressees = $this->_addressees;
637 637
 		}
638 638
 		return $addressees;
639 639
 	}
@@ -648,16 +648,16 @@  discard block
 block discarded – undo
648 648
 	protected function _process_data() {
649 649
 		//at a minimum, we NEED EE_Attendee objects.
650 650
 
651
-		if ( empty( $this->_data->attendees ) ) {
652
-			return false;  //there's no data to process!
651
+		if (empty($this->_data->attendees)) {
652
+			return false; //there's no data to process!
653 653
 		}
654 654
 
655 655
 		//process addressees for each context.  Child classes will have to have methods for each context defined to handle the processing of the data object within them
656
-		foreach ( $this->_contexts as $context => $details ) {
657
-			$xpctd_method = '_' . $context . '_addressees';
658
-			if ( !method_exists( $this, $xpctd_method ) )
659
-				throw new EE_Error( sprintf( __('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method) );
660
-			 $this->_addressees[$context] = call_user_func( array( $this, $xpctd_method ) );
656
+		foreach ($this->_contexts as $context => $details) {
657
+			$xpctd_method = '_'.$context.'_addressees';
658
+			if ( ! method_exists($this, $xpctd_method))
659
+				throw new EE_Error(sprintf(__('The data for %1$s message type cannot be prepared because there is no set method for doing so.  The expected method name is "%2$s" please doublecheck the %1$s message type class and make sure that method is present', 'event_espresso'), $this->label['singular'], $xpctd_method));
660
+			 $this->_addressees[$context] = call_user_func(array($this, $xpctd_method));
661 661
 		}
662 662
 		return true; //data was processed successfully.
663 663
 	}
@@ -692,8 +692,8 @@  discard block
 block discarded – undo
692 692
 			'total_ticket_count' => $this->_data->total_ticket_count
693 693
 			);
694 694
 
695
-		if ( is_array( $this->_data->primary_attendee_data ) ) {
696
-			$this->_default_addressee_data = array_merge( $this->_default_addressee_data, $this->_data->primary_attendee_data );
695
+		if (is_array($this->_data->primary_attendee_data)) {
696
+			$this->_default_addressee_data = array_merge($this->_default_addressee_data, $this->_data->primary_attendee_data);
697 697
 			$this->_default_addressee_data['primary_att_obj'] = $this->_data->primary_attendee_data['att_obj'];
698 698
 			$this->_default_addressee_data['primary_reg_obj'] = $this->_data->primary_attendee_data['reg_obj'];
699 699
 		}
@@ -711,26 +711,26 @@  discard block
 block discarded – undo
711 711
 	 * see abstract declaration in parent class for details, children message types can override these valid shortcodes if desired (we include all for all contexts by default).
712 712
 	 */
713 713
 	protected function _set_valid_shortcodes() {
714
-		$all_shortcodes = array( 'attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger' );
714
+		$all_shortcodes = array('attendee_list', 'attendee', 'datetime_list', 'datetime', 'event_list', 'event_meta', 'event', 'organization', 'recipient_details', 'recipient_list', 'ticket_list', 'ticket', 'transaction', 'venue', 'primary_registration_details', 'primary_registration_list', 'event_author', 'email', 'messenger');
715 715
 		$contexts = $this->get_contexts();
716
-		foreach ( $contexts as $context => $details ) {
716
+		foreach ($contexts as $context => $details) {
717 717
 			$this->_valid_shortcodes[$context] = $all_shortcodes;
718 718
 
719 719
 			//make sure non admin context does not include the event_author shortcodes
720
-			if ( $context != 'admin' ) {
721
-				if( ($key = array_search('event_author', $this->_valid_shortcodes[$context] ) ) !== false) {
720
+			if ($context != 'admin') {
721
+				if (($key = array_search('event_author', $this->_valid_shortcodes[$context])) !== false) {
722 722
 					unset($this->_valid_shortcodes[$context][$key]);
723 723
 				}
724 724
 			}
725 725
 		}
726 726
 
727 727
 		//make sure admin context does not include the recipient_details shortcodes IF we have admin context hooked in message types might not have that context.
728
-		if ( !empty( $this->_valid_shortcodes['admin'] ) ) {
729
-			if( ($key = array_search('recipient_details', $this->_valid_shortcodes['admin'] ) ) !== false) {
728
+		if ( ! empty($this->_valid_shortcodes['admin'])) {
729
+			if (($key = array_search('recipient_details', $this->_valid_shortcodes['admin'])) !== false) {
730 730
 					unset($this->_valid_shortcodes['admin'][$key]);
731 731
 				}
732 732
 			//make sure admin context does not include the recipient_details shortcodes
733
-			if( ($key = array_search('recipient_list', $this->_valid_shortcodes['admin'] ) ) !== false) {
733
+			if (($key = array_search('recipient_list', $this->_valid_shortcodes['admin'])) !== false) {
734 734
 					unset($this->_valid_shortcodes['admin'][$key]);
735 735
 				}
736 736
 		}
@@ -743,8 +743,8 @@  discard block
 block discarded – undo
743 743
 	 * @param  array  $new_config array of valid shortcodes (by context)
744 744
 	 * @return void               sets valid_shortcodes property
745 745
 	 */
746
-	public function reset_valid_shortcodes_config( $new_config ) {
747
-		foreach ( $new_config as $context => $shortcodes ) {
746
+	public function reset_valid_shortcodes_config($new_config) {
747
+		foreach ($new_config as $context => $shortcodes) {
748 748
 			$this->_valid_shortcodes[$context] = $shortcodes;
749 749
 		}
750 750
 	}
@@ -763,13 +763,13 @@  discard block
 block discarded – undo
763 763
 		$addressees = array();
764 764
 
765 765
 		//first we need to get the event admin user id for all the events and setup an addressee object for each unique admin user.
766
-		foreach ( $this->_data->events as $line_ref => $event ) {
767
-			$admin_id = $this->_get_event_admin_id( $event['ID'] );
766
+		foreach ($this->_data->events as $line_ref => $event) {
767
+			$admin_id = $this->_get_event_admin_id($event['ID']);
768 768
 			//make sure we are just including the events that belong to this admin!
769
-			$admin_events[ $admin_id ][$line_ref] = $event;
769
+			$admin_events[$admin_id][$line_ref] = $event;
770 770
 		}
771 771
 		//k now we can loop through the event_admins and setup the addressee data.
772
-		foreach ( $admin_events as $admin_id => $event_details ) {
772
+		foreach ($admin_events as $admin_id => $event_details) {
773 773
 			$aee = array(
774 774
 				'user_id' => $admin_id,
775 775
 				'events' => $event_details,
@@ -777,8 +777,8 @@  discard block
 block discarded – undo
777 777
 				'recipient_id' => $admin_id,
778 778
 				'recipient_type' => 'WP_User'
779 779
 			);
780
-			$aee = array_merge( $this->_default_addressee_data, $aee );
781
-			$addressees[] = new EE_Messages_Addressee( $aee );
780
+			$aee = array_merge($this->_default_addressee_data, $aee);
781
+			$addressees[] = new EE_Messages_Addressee($aee);
782 782
 		}
783 783
 
784 784
 		return $addressees;
@@ -800,7 +800,7 @@  discard block
 block discarded – undo
800 800
 		$aee['recipient_type'] = 'Attendee';
801 801
 
802 802
 		//great now we can instantiate the $addressee object and return (as an array);
803
-		$add[] = new EE_Messages_Addressee( $aee );
803
+		$add[] = new EE_Messages_Addressee($aee);
804 804
 		return $add;
805 805
 	}
806 806
 
@@ -819,38 +819,38 @@  discard block
 block discarded – undo
819 819
 		//use to verify unique attendee emails... we don't want to sent multiple copies to the same attendee do we?
820 820
 		$already_processed = array();
821 821
 
822
-		foreach ( $this->_data->attendees as $att_id => $details ) {
822
+		foreach ($this->_data->attendees as $att_id => $details) {
823 823
 			//set the attendee array to blank on each loop;
824 824
 			$aee = array();
825 825
 
826
-			if ( isset( $this->_data->reg_obj ) && ( $this->_data->reg_obj->attendee_ID() != $att_id ) && $this->_single_message ) continue;
826
+			if (isset($this->_data->reg_obj) && ($this->_data->reg_obj->attendee_ID() != $att_id) && $this->_single_message) continue;
827 827
 
828 828
 			//is $this->_regs_for_sending present?  If so, let's make sure we ONLY generate addressee for registrations in that array.
829
-			if ( ! empty( $this->_regs_for_sending ) && is_array( $this->_regs_for_sending ) ) {
830
-				$regs_allowed = array_intersect_key( array_flip( $this->_regs_for_sending ), $details['reg_objs'] );
831
-				if ( empty( $regs_allowed ) ) {
829
+			if ( ! empty($this->_regs_for_sending) && is_array($this->_regs_for_sending)) {
830
+				$regs_allowed = array_intersect_key(array_flip($this->_regs_for_sending), $details['reg_objs']);
831
+				if (empty($regs_allowed)) {
832 832
 					continue;
833 833
 				}
834 834
 			}
835 835
 
836 836
 			if (
837
-				in_array( $details['attendee_email'], $already_processed )
838
-				&& apply_filters( 'FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', true, $this->_data, $this )
837
+				in_array($details['attendee_email'], $already_processed)
838
+				&& apply_filters('FHEE__EE_message_type___attendee_addressees__prevent_duplicate_email_sends', true, $this->_data, $this)
839 839
 			) {
840 840
 				continue;
841 841
 			}
842 842
 
843 843
 			$already_processed[] = $details['attendee_email'];
844 844
 
845
-			foreach ( $details as $item => $value ) {
845
+			foreach ($details as $item => $value) {
846 846
 				$aee[$item] = $value;
847
-				if ( $item == 'line_ref' ) {
848
-					foreach ( $value as $event_id ) {
847
+				if ($item == 'line_ref') {
848
+					foreach ($value as $event_id) {
849 849
 						$aee['events'][$event_id] = $this->_data->events[$event_id];
850 850
 					}
851 851
 				}
852 852
 
853
-				if ( $item == 'attendee_email' ) {
853
+				if ($item == 'attendee_email') {
854 854
 					$aee['attendee_email'] = $value;
855 855
 				}
856 856
 
@@ -868,8 +868,8 @@  discard block
 block discarded – undo
868 868
 			$aee['recipient_type'] = 'Attendee';
869 869
 
870 870
 			//merge in the primary attendee data
871
-			$aee = array_merge( $this->_default_addressee_data, $aee );
872
-			$add[] = new EE_Messages_Addressee( $aee );
871
+			$aee = array_merge($this->_default_addressee_data, $aee);
872
+			$add[] = new EE_Messages_Addressee($aee);
873 873
 		}
874 874
 
875 875
 		return $add;
@@ -881,8 +881,8 @@  discard block
 block discarded – undo
881 881
 	 * @param $event_id
882 882
 	 * @return int
883 883
 	 */
884
-	protected function _get_event_admin_id( $event_id ) {
885
-		$event = EEM_Event::instance()->get_one_by_ID( $event_id );
884
+	protected function _get_event_admin_id($event_id) {
885
+		$event = EEM_Event::instance()->get_one_by_ID($event_id);
886 886
 		return $event instanceof EE_Event ? $event->wp_user() : 0;
887 887
 	}
888 888
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Processor.lib.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -410,7 +410,7 @@
 block discarded – undo
410 410
 	/**
411 411
 	 * This simply loops through all active messengers and takes care of setting up the
412 412
 	 * EE_Message_To_Generate objects.
413
-	 * @param $message_type
413
+	 * @param string $message_type
414 414
 	 * @param $data
415 415
 	 *
416 416
 	 * @return EE_Message_To_Generate[]
Please login to merge, or discard this patch.
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param EE_Message_Resource_Manager $message_resource_manager
37 37
 	 */
38
-	public function __construct( EE_Message_Resource_Manager $message_resource_manager ) {
38
+	public function __construct(EE_Message_Resource_Manager $message_resource_manager) {
39 39
 		$this->_message_resource_manager = $message_resource_manager;
40 40
 		$this->_init_queue_and_generator();
41 41
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * - $_generator = holds the messages generator
51 51
 	 */
52 52
 	protected function _init_queue_and_generator() {
53
-		$this->_generator = EE_Registry::factory( 'EE_Messages_Generator' );
53
+		$this->_generator = EE_Registry::factory('EE_Messages_Generator');
54 54
 		$this->_queue = $this->_generator->generation_queue();
55 55
 	}
56 56
 
@@ -75,13 +75,13 @@  discard block
 block discarded – undo
75 75
 	 * @return bool|EE_Messages_Queue return false if nothing generated.  This returns a new EE_Message_Queue with
76 76
 	 *                                   generated messages.
77 77
 	 */
78
-	public function batch_generate_from_queue( $messages = array(), $clear_queue = false ) {
79
-		if ( $this->_build_queue_for_generation( $messages, $clear_queue ) ) {
78
+	public function batch_generate_from_queue($messages = array(), $clear_queue = false) {
79
+		if ($this->_build_queue_for_generation($messages, $clear_queue)) {
80 80
 			$new_queue = $this->_generator->generate();
81
-			if ( $new_queue instanceof EE_Messages_Queue ) {
81
+			if ($new_queue instanceof EE_Messages_Queue) {
82 82
 				//unlock queue
83 83
 				$this->_queue->unlock_queue();
84
-				$this->_queue->initiate_request_by_priority( 'send' );
84
+				$this->_queue->initiate_request_by_priority('send');
85 85
 				return $new_queue;
86 86
 			}
87 87
 		}
@@ -102,24 +102,24 @@  discard block
 block discarded – undo
102 102
 	 *
103 103
 	 * @return bool true means queue prepped, false means there was a lock so no generation please.
104 104
 	 */
105
-	protected function _build_queue_for_generation( $messages = array(), $clear_queue = false ) {
105
+	protected function _build_queue_for_generation($messages = array(), $clear_queue = false) {
106 106
 
107
-		if ( $clear_queue ) {
107
+		if ($clear_queue) {
108 108
 			$this->_init_queue_and_generator();
109 109
 		}
110 110
 
111
-		if ( $messages ) {
111
+		if ($messages) {
112 112
 			//if generation is locked then get out now because that means processing is already happening.
113
-			if ( $this->_queue->is_locked() ) {
113
+			if ($this->_queue->is_locked()) {
114 114
 				return false;
115 115
 			}
116 116
 
117 117
 			$this->_queue->lock_queue();
118
-			$messages = is_array( $messages ) ? $messages : array( $messages );
119
-			foreach ( $messages as $message ) {
120
-				if ( $message instanceof EE_Message ) {
118
+			$messages = is_array($messages) ? $messages : array($messages);
119
+			foreach ($messages as $message) {
120
+				if ($message instanceof EE_Message) {
121 121
 					$data = $message->all_extra_meta_array();
122
-					$this->_queue->add( $message, $data );
122
+					$this->_queue->add($message, $data);
123 123
 				}
124 124
 			}
125 125
 			return true;
@@ -137,22 +137,22 @@  discard block
 block discarded – undo
137 137
 	 *
138 138
 	 * @return bool true means queue prepped, false means there was a lock so no queue prepped.
139 139
 	 */
140
-	protected function _build_queue_for_sending( $messages, $clear_queue = false ) {
140
+	protected function _build_queue_for_sending($messages, $clear_queue = false) {
141 141
 		//if sending is locked then get out now because that means processing is already happening.
142
-		if ( $this->_queue->is_locked( EE_Messages_Queue::action_sending ) ) {
142
+		if ($this->_queue->is_locked(EE_Messages_Queue::action_sending)) {
143 143
 			return false;
144 144
 		}
145 145
 
146
-		$this->_queue->lock_queue( EE_Messages_Queue::action_sending );
146
+		$this->_queue->lock_queue(EE_Messages_Queue::action_sending);
147 147
 
148
-		if ( $clear_queue ) {
148
+		if ($clear_queue) {
149 149
 			$this->_init_queue_and_generator();
150 150
 		}
151 151
 
152
-		$messages = is_array( $messages ) ? $messages : array( $messages );
152
+		$messages = is_array($messages) ? $messages : array($messages);
153 153
 
154
-		foreach ( $messages as $message ) {
155
-			$this->_queue->add( $message );
154
+		foreach ($messages as $message) {
155
+			$this->_queue->add($message);
156 156
 		}
157 157
 		return true;
158 158
 	}
@@ -168,11 +168,11 @@  discard block
 block discarded – undo
168 168
 	 *
169 169
 	 * @return EE_Messages_Queue
170 170
 	 */
171
-	public function batch_send_from_queue( $messages = array(), $clear_queue = false ) {
171
+	public function batch_send_from_queue($messages = array(), $clear_queue = false) {
172 172
 
173
-		if ( $messages && $this->_build_queue_for_sending( $messages, $clear_queue ) ) {
173
+		if ($messages && $this->_build_queue_for_sending($messages, $clear_queue)) {
174 174
 			$this->_queue->execute();
175
-			$this->_queue->unlock_queue( EE_Messages_Queue::action_sending );
175
+			$this->_queue->unlock_queue(EE_Messages_Queue::action_sending);
176 176
 		} else {
177 177
 			//get messages to send and execute.
178 178
 			$this->_queue->get_to_send_batch_and_send();
@@ -195,10 +195,10 @@  discard block
 block discarded – undo
195 195
 	 * @param EE_Message_To_Generate[] $messages_to_generate
196 196
 	 * @return EE_Messages_Queue
197 197
 	 */
198
-	public function generate_and_return(  $messages_to_generate ) {
198
+	public function generate_and_return($messages_to_generate) {
199 199
 		$this->_init_queue_and_generator();
200
-		$this->_queue_for_generation_loop( $messages_to_generate );
201
-		return $this->_generator->generate( false );
200
+		$this->_queue_for_generation_loop($messages_to_generate);
201
+		return $this->_generator->generate(false);
202 202
 	}
203 203
 
204 204
 
@@ -209,8 +209,8 @@  discard block
 block discarded – undo
209 209
 	 * @param  bool     $persist    Indicate whether to instruct the generator to persist the generated queue (true) or not (false).
210 210
 	 * @return EE_Messages_Queue
211 211
 	 */
212
-	public function generate_queue( $persist = true ) {
213
-		return $this->_generator->generate( $persist );
212
+	public function generate_queue($persist = true) {
213
+		return $this->_generator->generate($persist);
214 214
 	}
215 215
 
216 216
 
@@ -222,9 +222,9 @@  discard block
 block discarded – undo
222 222
 	 * @param EE_Message_To_Generate $message_to_generate
223 223
 	 * @return  EE_Messages_Queue
224 224
 	 */
225
-	public function queue_for_generation( EE_Message_To_Generate $message_to_generate ) {
226
-		if ( $message_to_generate->valid() ) {
227
-			$this->_generator->create_and_add_message_to_queue( $message_to_generate );
225
+	public function queue_for_generation(EE_Message_To_Generate $message_to_generate) {
226
+		if ($message_to_generate->valid()) {
227
+			$this->_generator->create_and_add_message_to_queue($message_to_generate);
228 228
 		}
229 229
 	}
230 230
 
@@ -240,9 +240,9 @@  discard block
 block discarded – undo
240 240
 	 *
241 241
 	 * @param EE_Message_To_Generate[] $messages_to_generate
242 242
 	 */
243
-	public function batch_queue_for_generation_and_persist( $messages_to_generate ) {
243
+	public function batch_queue_for_generation_and_persist($messages_to_generate) {
244 244
 		$this->_init_queue_and_generator();
245
-		$this->_queue_for_generation_loop( $messages_to_generate );
245
+		$this->_queue_for_generation_loop($messages_to_generate);
246 246
 		$this->_queue->save();
247 247
 	}
248 248
 
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @param EE_Message_To_Generate[]  $messages_to_generate
260 260
 	 */
261
-	public function batch_queue_for_generation_no_persist( $messages_to_generate ) {
261
+	public function batch_queue_for_generation_no_persist($messages_to_generate) {
262 262
 		$this->_init_queue_and_generator();
263
-		$this->_queue_for_generation_loop( $messages_to_generate );
263
+		$this->_queue_for_generation_loop($messages_to_generate);
264 264
 	}
265 265
 
266 266
 
@@ -272,15 +272,15 @@  discard block
 block discarded – undo
272 272
 	 *
273 273
 	 * @param EE_Message_To_Generate[] $messages_to_generate
274 274
 	 */
275
-	protected function _queue_for_generation_loop( $messages_to_generate ) {
275
+	protected function _queue_for_generation_loop($messages_to_generate) {
276 276
 		//make sure is in an array.
277
-		if ( ! is_array( $messages_to_generate ) ) {
278
-			$messages_to_generate = array( $messages_to_generate );
277
+		if ( ! is_array($messages_to_generate)) {
278
+			$messages_to_generate = array($messages_to_generate);
279 279
 		}
280 280
 
281
-		foreach ( $messages_to_generate as $message_to_generate ) {
282
-			if ( $message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid() ) {
283
-				$this->queue_for_generation( $message_to_generate );
281
+		foreach ($messages_to_generate as $message_to_generate) {
282
+			if ($message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid()) {
283
+				$this->queue_for_generation($message_to_generate);
284 284
 			}
285 285
 		}
286 286
 	}
@@ -295,10 +295,10 @@  discard block
 block discarded – undo
295 295
 	 * @param  EE_Message_To_Generate[]
296 296
 	 * @return EE_Messages_Queue
297 297
 	 */
298
-	public function generate_and_queue_for_sending( $messages_to_generate ) {
298
+	public function generate_and_queue_for_sending($messages_to_generate) {
299 299
 		$this->_init_queue_and_generator();
300
-		$this->_queue_for_generation_loop( $messages_to_generate );
301
-		return $this->_generator->generate( true );
300
+		$this->_queue_for_generation_loop($messages_to_generate);
301
+		return $this->_generator->generate(true);
302 302
 	}
303 303
 
304 304
 
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
 *@param   EE_Message_To_Generate $message_to_generate
312 312
 	 * @return  EE_Messages_Queue | bool   false if unable to generate otherwise the generated queue.
313 313
 	 */
314
-	public function generate_for_preview( EE_Message_To_Generate $message_to_generate ) {
315
-		if ( ! $message_to_generate->valid() ) {
314
+	public function generate_for_preview(EE_Message_To_Generate $message_to_generate) {
315
+		if ( ! $message_to_generate->valid()) {
316 316
 			EE_Error::add_error(
317
-				__( 'Unable to generate preview because of invalid data', 'event_espresso' ),
317
+				__('Unable to generate preview because of invalid data', 'event_espresso'),
318 318
 				__FILE__,
319 319
 				__FUNCTION__,
320 320
 				__LINE__
@@ -322,12 +322,12 @@  discard block
 block discarded – undo
322 322
 			return false;
323 323
 		}
324 324
 		//just make sure preview is set on the $message_to_generate (in case client forgot)
325
-		$message_to_generate->set_preview( true );
326
-		$generated_queue = $this->generate_and_return( array( $message_to_generate ) );
327
-		if ( $generated_queue->execute( false ) ) {
325
+		$message_to_generate->set_preview(true);
326
+		$generated_queue = $this->generate_and_return(array($message_to_generate));
327
+		if ($generated_queue->execute(false)) {
328 328
 			//the first queue item should be the preview
329 329
 			$generated_queue->get_queue()->rewind();
330
-			if ( ! $generated_queue->get_queue()->valid() ) {
330
+			if ( ! $generated_queue->get_queue()->valid()) {
331 331
 				return $generated_queue;
332 332
 			}
333 333
 			return $generated_queue->get_queue()->is_test_send() ? true : $generated_queue;
@@ -344,15 +344,15 @@  discard block
 block discarded – undo
344 344
 	 * @param EE_Message_To_Generate $message_to_generate
345 345
 	 * @return bool true or false for success.
346 346
 	 */
347
-	public function queue_for_sending( EE_Message_To_Generate $message_to_generate ) {
348
-		if ( ! $message_to_generate->valid() ) {
347
+	public function queue_for_sending(EE_Message_To_Generate $message_to_generate) {
348
+		if ( ! $message_to_generate->valid()) {
349 349
 			return false;
350 350
 		}
351 351
 		$this->_init_queue_and_generator();
352 352
 		$message = $message_to_generate->get_EE_Message();
353
-		$this->_queue->add( $message );
354
-		if ( $message->send_now() ) {
355
-			$this->_queue->execute( false );
353
+		$this->_queue->add($message);
354
+		if ($message->send_now()) {
355
+			$this->_queue->execute(false);
356 356
 		} else {
357 357
 			$this->_queue->save();
358 358
 		}
@@ -365,12 +365,12 @@  discard block
 block discarded – undo
365 365
 	 * @param EE_Message_To_Generate $message_to_generate
366 366
 	 * @return EE_Messages_Queue | null
367 367
 	 */
368
-	public function generate_and_send_now( EE_Message_To_Generate $message_to_generate ) {
369
-		if ( ! $message_to_generate->valid() ) {
368
+	public function generate_and_send_now(EE_Message_To_Generate $message_to_generate) {
369
+		if ( ! $message_to_generate->valid()) {
370 370
 			return null;
371 371
 		}
372 372
 		// is there supposed to be a sending messenger for this message?
373
-		if ( $message_to_generate instanceof EEI_Has_Sending_Messenger ) {
373
+		if ($message_to_generate instanceof EEI_Has_Sending_Messenger) {
374 374
 			// make sure it's valid, but if it's not,
375 375
 			// then set the value of $sending_messenger to an EE_Error object
376 376
 			// so that downstream code can easily see that things went wrong.
@@ -386,14 +386,14 @@  discard block
 block discarded – undo
386 386
 			$sending_messenger = null;
387 387
 		}
388 388
 
389
-		if ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle ) {
389
+		if ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle) {
390 390
 			$this->_init_queue_and_generator();
391
-			$this->_queue->add( $message_to_generate->get_EE_Message() );
392
-			$this->_queue->execute( false, $sending_messenger );
391
+			$this->_queue->add($message_to_generate->get_EE_Message());
392
+			$this->_queue->execute(false, $sending_messenger);
393 393
 			return $this->_queue;
394
-		} elseif ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete ) {
395
-			$generated_queue = $this->generate_and_return( array( $message_to_generate ) );
396
-			$generated_queue->execute( false, $sending_messenger );
394
+		} elseif ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete) {
395
+			$generated_queue = $this->generate_and_return(array($message_to_generate));
396
+			$generated_queue->execute(false, $sending_messenger);
397 397
 			return $generated_queue;
398 398
 		}
399 399
 		return null;
@@ -410,13 +410,13 @@  discard block
 block discarded – undo
410 410
 	 * @param mixed  $data   The data being used for generation.
411 411
 	 * @param bool   $persist   Whether to persist the queued messages to the db or not.
412 412
 	 */
413
-	public function generate_for_all_active_messengers( $message_type, $data, $persist = true ) {
414
-		$messages_to_generate = $this->setup_mtgs_for_all_active_messengers( $message_type, $data );
415
-		if ( $persist ) {
416
-			$this->batch_queue_for_generation_and_persist( $messages_to_generate );
413
+	public function generate_for_all_active_messengers($message_type, $data, $persist = true) {
414
+		$messages_to_generate = $this->setup_mtgs_for_all_active_messengers($message_type, $data);
415
+		if ($persist) {
416
+			$this->batch_queue_for_generation_and_persist($messages_to_generate);
417 417
 			$this->_queue->initiate_request_by_priority();
418 418
 		} else {
419
-			$this->batch_queue_for_generation_no_persist( $messages_to_generate );
419
+			$this->batch_queue_for_generation_no_persist($messages_to_generate);
420 420
 		}
421 421
 	}
422 422
 
@@ -431,11 +431,11 @@  discard block
 block discarded – undo
431 431
 	 *
432 432
 	 * @return EE_Message_To_Generate[]
433 433
 	 */
434
-	public function setup_mtgs_for_all_active_messengers( $message_type, $data ) {
434
+	public function setup_mtgs_for_all_active_messengers($message_type, $data) {
435 435
 		$messages_to_generate = array();
436
-		foreach ( $this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object  ) {
437
-			$message_to_generate = new EE_Message_To_Generate( $messenger_slug, $message_type, $data );
438
-			if ( $message_to_generate->valid() ) {
436
+		foreach ($this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object) {
437
+			$message_to_generate = new EE_Message_To_Generate($messenger_slug, $message_type, $data);
438
+			if ($message_to_generate->valid()) {
439 439
 				$messages_to_generate[] = $message_to_generate;
440 440
 			}
441 441
 		}
@@ -450,23 +450,23 @@  discard block
 block discarded – undo
450 450
 	 * and send.
451 451
 	 * @param array $message_ids
452 452
 	 */
453
-	public function setup_messages_from_ids_and_send( $message_ids ) {
453
+	public function setup_messages_from_ids_and_send($message_ids) {
454 454
 		$this->_init_queue_and_generator();
455
-		$messages = EEM_Message::instance()->get_all( array(
455
+		$messages = EEM_Message::instance()->get_all(array(
456 456
 			array(
457
-				'MSG_ID' => array( 'IN', $message_ids ),
458
-				'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_sent() )
457
+				'MSG_ID' => array('IN', $message_ids),
458
+				'STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_sent())
459 459
 			)
460 460
 		));
461 461
 		//set the Messages to resend.
462
-		foreach ( $messages as $message ) {
463
-			if ( $message instanceof EE_Message ) {
464
-				$message->set_STS_ID( EEM_Message::status_resend );
465
-				$this->_queue->add( $message );
462
+		foreach ($messages as $message) {
463
+			if ($message instanceof EE_Message) {
464
+				$message->set_STS_ID(EEM_Message::status_resend);
465
+				$this->_queue->add($message);
466 466
 			}
467 467
 		}
468 468
 
469
-		$this->_queue->initiate_request_by_priority( 'send' );
469
+		$this->_queue->initiate_request_by_priority('send');
470 470
 	}
471 471
 
472 472
 
@@ -480,23 +480,23 @@  discard block
 block discarded – undo
480 480
 	 *
481 481
 	 * @return EE_Message_To_Generate[]
482 482
 	 */
483
-	public function setup_messages_to_generate_from_registration_ids_in_request( $registration_ids_key = '_REG_ID' ) {
484
-		EE_Registry::instance()->load_core( 'Request_Handler' );
485
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
483
+	public function setup_messages_to_generate_from_registration_ids_in_request($registration_ids_key = '_REG_ID') {
484
+		EE_Registry::instance()->load_core('Request_Handler');
485
+		EE_Registry::instance()->load_helper('MSG_Template');
486 486
 		$regs_to_send = array();
487
-		$regIDs = EE_Registry::instance()->REQ->get( $registration_ids_key );
488
-		if ( empty( $regIDs ) ) {
489
-			EE_Error::add_error( __('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
487
+		$regIDs = EE_Registry::instance()->REQ->get($registration_ids_key);
488
+		if (empty($regIDs)) {
489
+			EE_Error::add_error(__('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
490 490
 			return false;
491 491
 		}
492 492
 
493 493
 		//make sure is an array
494
-		$regIDs = is_array( $regIDs ) ? $regIDs : array( $regIDs );
494
+		$regIDs = is_array($regIDs) ? $regIDs : array($regIDs);
495 495
 
496
-		foreach( $regIDs as $regID ) {
497
-			$reg = EEM_Registration::instance()->get_one_by_ID( $regID );
498
-			if ( ! $reg instanceof EE_Registration ) {
499
-				EE_Error::add_error( sprintf( __('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID ) );
496
+		foreach ($regIDs as $regID) {
497
+			$reg = EEM_Registration::instance()->get_one_by_ID($regID);
498
+			if ( ! $reg instanceof EE_Registration) {
499
+				EE_Error::add_error(sprintf(__('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID));
500 500
 				return false;
501 501
 			}
502 502
 			$regs_to_send[$reg->transaction_ID()][$reg->status_ID()][] = $reg;
@@ -504,11 +504,11 @@  discard block
 block discarded – undo
504 504
 
505 505
 		$messages_to_generate = array();
506 506
 
507
-		foreach ( $regs_to_send as $status_group ) {
508
-			foreach ( $status_group as $status_id => $registrations ) {
507
+		foreach ($regs_to_send as $status_group) {
508
+			foreach ($status_group as $status_id => $registrations) {
509 509
 				$messages_to_generate = $messages_to_generate + $this->setup_mtgs_for_all_active_messengers(
510
-						EEH_MSG_Template::convert_reg_status_to_message_type( $status_id ),
511
-						array( $registrations, $status_id )
510
+						EEH_MSG_Template::convert_reg_status_to_message_type($status_id),
511
+						array($registrations, $status_id)
512 512
 					);
513 513
 			}
514 514
 		}
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page.core.php 4 patches
Braces   +2 added lines, -5 removed lines patch added patch discarded remove patch
@@ -1849,8 +1849,7 @@  discard block
 block discarded – undo
1849 1849
 		$MTP = EEM_Message_Template_Group::instance();
1850 1850
 
1851 1851
 		if ( empty($GRP_ID) )
1852
-			{$this->_message_template_group = $MTP->create_default_object();}
1853
-		else
1852
+			{$this->_message_template_group = $MTP->create_default_object();} else
1854 1853
 			{$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );}
1855 1854
 
1856 1855
 		$this->_template_pack = $this->_message_template_group->get_template_pack();
@@ -2977,9 +2976,7 @@  discard block
 block discarded – undo
2977 2976
 				}
2978 2977
 			}
2979 2978
 			$this->_active_messengers[$messenger]['settings'] = $settings;
2980
-		}
2981
-
2982
-		else if ( $this->_req_data['type'] == 'message_type' ) {
2979
+		} else if ( $this->_req_data['type'] == 'message_type' ) {
2983 2980
 			$settings = $this->_req_data['message_type_settings'];
2984 2981
 			$messenger = $settings['messenger'];
2985 2982
 			$message_type = $settings['message_type'];
Please login to merge, or discard this patch.
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -2430,7 +2430,7 @@  discard block
 block discarded – undo
2430 2430
 	 * @param  int    $GRP_ID The group being deleted
2431 2431
 	 * @param  bool $include_group whether to delete the Message Template Group as well.
2432 2432
 	 *
2433
-	 * @return bool        boolean to indicate the success of the deletes or not.
2433
+	 * @return integer        boolean to indicate the success of the deletes or not.
2434 2434
 	 */
2435 2435
 	private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) {
2436 2436
 		$success = 1;
@@ -2565,7 +2565,7 @@  discard block
 block discarded – undo
2565 2565
 	 * This just prepares the content for the message type settings
2566 2566
 	 *
2567 2567
 	 * @param  object  $message_type The message type object
2568
-	 * @param  object  $messenger    The messenger object
2568
+	 * @param  EE_messenger|null  $messenger    The messenger object
2569 2569
 	 * @param  boolean $active       Whether the message type is active or not
2570 2570
 	 *
2571 2571
 	 * @return string                html output for the content
Please login to merge, or discard this patch.
Indentation   +49 added lines, -49 removed lines patch added patch discarded remove patch
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 *
102 102
 	 *
103 103
 	 * @throws EE_Error
104
-	*/
104
+	 */
105 105
 	protected function _load_message_resource_manager() {
106 106
 		$this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
107 107
 	}
@@ -211,9 +211,9 @@  discard block
 block discarded – undo
211 211
 
212 212
 	/**
213 213
 	 * 		an array for storing key => value pairs of request actions and their corresponding methods
214
-	*		@access protected
215
-	*		@return void
216
-	*/
214
+	 *		@access protected
215
+	 *		@return void
216
+	 */
217 217
 	protected function _set_page_routes() {
218 218
 		$grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] )
219 219
 			? $this->_req_data['GRP_ID']
@@ -517,8 +517,8 @@  discard block
 block discarded – undo
517 517
 	protected function _add_screen_options_global_mtps() {
518 518
 		/**
519 519
 		 * Note: the reason for the value swap here on $this->_admin_page_title is because $this->_per_page_screen_options
520
-         * uses the $_admin_page_title property and we want different outputs in the different spots.
521
-         */
520
+		 * uses the $_admin_page_title property and we want different outputs in the different spots.
521
+		 */
522 522
 		$page_title = $this->_admin_page_title;
523 523
 		$this->_admin_page_title = __('Global Message Templates', 'event_espresso');
524 524
 		$this->_per_page_screen_option();
@@ -721,9 +721,9 @@  discard block
 block discarded – undo
721 721
 		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' )
722 722
 			? array(
723 723
 				'generate_now' => __( 'Generate Now', 'event_espresso' ),
724
-		        'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ),
725
-		        'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ),
726
-		        'send_now' => __( 'Send Now', 'event_espresso' )
724
+				'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ),
725
+				'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ),
726
+				'send_now' => __( 'Send Now', 'event_espresso' )
727 727
 				)
728 728
 			: array();
729 729
 
@@ -734,10 +734,10 @@  discard block
 block discarded – undo
734 734
 
735 735
 		$this->_views = array(
736 736
 			 'all' => array(
737
-			    'slug' => 'all',
738
-			    'label' => __( 'All', 'event_espresso' ),
739
-			    'count' => 0,
740
-			    'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action )
737
+				'slug' => 'all',
738
+				'label' => __( 'All', 'event_espresso' ),
739
+				'count' => 0,
740
+				'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action )
741 741
 			 )
742 742
 		);
743 743
 
@@ -1127,9 +1127,9 @@  discard block
 block discarded – undo
1127 1127
 																			&& in_array($extra_field, $v_fields)
1128 1128
 																			&&
1129 1129
 																			(
1130
-								                                                is_array($validators[$extra_field] )
1130
+																				is_array($validators[$extra_field] )
1131 1131
 																				&& isset( $validators[$extra_field]['msg'] )
1132
-							                                                )
1132
+																			)
1133 1133
 								? 'validate-error ' . $css_class
1134 1134
 								: $css_class;
1135 1135
 
@@ -1414,8 +1414,8 @@  discard block
 block discarded – undo
1414 1414
 			 $GRP_ID,
1415 1415
 			 false,
1416 1416
 			 add_query_arg(
1417
-			    array( 'action' => 'global_mtps' ),
1418
-			    $this->_admin_base_url
1417
+				array( 'action' => 'global_mtps' ),
1418
+				$this->_admin_base_url
1419 1419
 			 )
1420 1420
 		);
1421 1421
 
@@ -1890,14 +1890,14 @@  discard block
 block discarded – undo
1890 1890
 
1891 1891
 
1892 1892
 	/**
1893
-     * This returns the shortcode selector skeleton for a given context and field.
1894
-     *
1895
-     * @since 4.9.rc.000
1896
-     *
1893
+	 * This returns the shortcode selector skeleton for a given context and field.
1894
+	 *
1895
+	 * @since 4.9.rc.000
1896
+	 *
1897 1897
 	 * @param string $field  The name of the field retrieving shortcodes for.
1898
-     * @param string $linked_input_id The css id of the input that the shortcodes get added to.
1899
-     * @return string
1900
-    */
1898
+	 * @param string $linked_input_id The css id of the input that the shortcodes get added to.
1899
+	 * @return string
1900
+	 */
1901 1901
 	protected function _get_shortcode_selector( $field, $linked_input_id ) {
1902 1902
 		$template_args = array(
1903 1903
 			'shortcodes' => $this->_get_shortcodes( array( $field ), true ),
@@ -2495,9 +2495,9 @@  discard block
 block discarded – undo
2495 2495
 
2496 2496
 	/**
2497 2497
 	 * 	_learn_more_about_message_templates_link
2498
-	*	@access protected
2499
-	*	@return string
2500
-	*/
2498
+	 *	@access protected
2499
+	 *	@return string
2500
+	 */
2501 2501
 	protected function _learn_more_about_message_templates_link() {
2502 2502
 		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>';
2503 2503
 	}
@@ -3038,7 +3038,7 @@  discard block
 block discarded – undo
3038 3038
 			/** @var EE_message_type $message_type */
3039 3039
 			$message_type = $this->_message_resource_manager->get_message_type( $message_type_name );
3040 3040
 			if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name )
3041
-			     && $message_type instanceof EE_message_type
3041
+				 && $message_type instanceof EE_message_type
3042 3042
 			) {
3043 3043
 				$this->_template_args['data']['active_mts'][] = $message_type_name;
3044 3044
 				if ( $message_type->get_admin_settings_fields() ) {
@@ -3374,10 +3374,10 @@  discard block
 block discarded – undo
3374 3374
 
3375 3375
 	/**
3376 3376
 	 * This immediately generates any EE_Message ID's that are selected that are EEM_Message::status_incomplete
3377
-     * However, this does not send immediately, it just queues for sending.
3378
-     *
3379
-     * @since 4.9.0
3380
-     */
3377
+	 * However, this does not send immediately, it just queues for sending.
3378
+	 *
3379
+	 * @since 4.9.0
3380
+	 */
3381 3381
 	protected function _generate_now() {
3382 3382
 		$msg_ids = $this->_get_msg_ids_from_request();
3383 3383
 		EED_Messages::generate_now( $msg_ids );
@@ -3388,11 +3388,11 @@  discard block
 block discarded – undo
3388 3388
 
3389 3389
 	/**
3390 3390
 	 * This immediately generates AND sends any EE_Message's selected that are EEM_Message::status_incomplete or that are
3391
-     * EEM_Message::status_resend or EEM_Message::status_idle
3392
-     *
3393
-     * @since 4.9.0
3394
-     *
3395
-     */
3391
+	 * EEM_Message::status_resend or EEM_Message::status_idle
3392
+	 *
3393
+	 * @since 4.9.0
3394
+	 *
3395
+	 */
3396 3396
 	protected function _generate_and_send_now() {
3397 3397
 		$this->_generate_now();
3398 3398
 		$this->_send_now();
@@ -3405,9 +3405,9 @@  discard block
 block discarded – undo
3405 3405
 
3406 3406
 	/**
3407 3407
 	 * This queues any EEM_Message::status_sent EE_Message ids in the request for resending.
3408
-     *
3409
-     * @since 4.9.0
3410
-     */
3408
+	 *
3409
+	 * @since 4.9.0
3410
+	 */
3411 3411
 	protected function _queue_for_resending() {
3412 3412
 		$msg_ids = $this->_get_msg_ids_from_request();
3413 3413
 		EED_Messages::queue_for_resending( $msg_ids );
@@ -3419,9 +3419,9 @@  discard block
 block discarded – undo
3419 3419
 
3420 3420
 	/**
3421 3421
 	 *  This sends immediately any EEM_Message::status_idle or EEM_Message::status_resend messages in the queue
3422
-     *
3423
-     *  @since 4.9.0
3424
-     */
3422
+	 *
3423
+	 *  @since 4.9.0
3424
+	 */
3425 3425
 	protected function _send_now() {
3426 3426
 		$msg_ids = $this->_get_msg_ids_from_request();
3427 3427
 		EED_Messages::send_now( $msg_ids );
@@ -3433,9 +3433,9 @@  discard block
 block discarded – undo
3433 3433
 
3434 3434
 	/**
3435 3435
 	 * Deletes EE_messages for IDs in the request.
3436
-     *
3437
-     * @since 4.9.0
3438
-     */
3436
+	 *
3437
+	 * @since 4.9.0
3438
+	 */
3439 3439
 	protected function _delete_ee_messages() {
3440 3440
 		$msg_ids = $this->_get_msg_ids_from_request();
3441 3441
 		$deleted_count = 0;
@@ -3464,9 +3464,9 @@  discard block
 block discarded – undo
3464 3464
 
3465 3465
 	/**
3466 3466
 	 *  This looks for 'MSG_ID' key in the request and returns an array of MSG_ID's if present.
3467
-     *  @since 4.9.0
3468
-     *  @return array
3469
-     */
3467
+	 *  @since 4.9.0
3468
+	 *  @return array
3469
+	 */
3470 3470
 	protected function _get_msg_ids_from_request() {
3471 3471
 		if ( ! isset( $this->_req_data['MSG_ID'] ) ) {
3472 3472
 			return array();
Please login to merge, or discard this patch.
Spacing   +605 added lines, -605 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
  *
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 	/**
73 73
 	 * @param bool $routing
74 74
 	 */
75
-	public function __construct( $routing = true ) {
75
+	public function __construct($routing = true) {
76 76
 		//make sure messages autoloader is running
77 77
 		EED_Messages::set_autoloaders();
78
-		parent::__construct( $routing );
78
+		parent::__construct($routing);
79 79
 	}
80 80
 
81 81
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 		$this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array();
91 91
 
92
-		$this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null;
92
+		$this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null;
93 93
 		$this->_load_message_resource_manager();
94 94
 	}
95 95
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @throws EE_Error
104 104
 	*/
105 105
 	protected function _load_message_resource_manager() {
106
-		$this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
106
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
107 107
 	}
108 108
 
109 109
 
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function get_messengers_for_list_table() {
118 118
 		$m_values = array();
119
-		$active_messengers = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_messenger' ) );
119
+		$active_messengers = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
120 120
 		//setup messengers for selects
121 121
 		$i = 1;
122
-		foreach ( $active_messengers as $active_messenger ) {
123
-			if ( $active_messenger instanceof EE_Message ) {
124
-				$m_values[ $i ]['id'] = $active_messenger->messenger();
125
-				$m_values[ $i ]['text'] = ucwords( $active_messenger->messenger_label() );
122
+		foreach ($active_messengers as $active_messenger) {
123
+			if ($active_messenger instanceof EE_Message) {
124
+				$m_values[$i]['id'] = $active_messenger->messenger();
125
+				$m_values[$i]['text'] = ucwords($active_messenger->messenger_label());
126 126
 				$i++;
127 127
 			}
128 128
 		}
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public function get_message_types_for_list_table() {
141 141
 		$mt_values = array();
142
-		$active_messages = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_message_type' ) );
142
+		$active_messages = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type'));
143 143
 		$i = 1;
144
-		foreach ( $active_messages as $active_message ) {
145
-			if ( $active_message instanceof EE_Message ) {
146
-				$mt_values[ $i ]['id'] = $active_message->message_type();
147
-				$mt_values[ $i ]['text'] = ucwords( $active_message->message_type_label() );
144
+		foreach ($active_messages as $active_message) {
145
+			if ($active_message instanceof EE_Message) {
146
+				$mt_values[$i]['id'] = $active_message->message_type();
147
+				$mt_values[$i]['text'] = ucwords($active_message->message_type_label());
148 148
 				$i++;
149 149
 			}
150 150
 		}
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	public function get_contexts_for_message_types_for_list_table() {
163 163
 		$contexts = array();
164
-		$active_message_contexts = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_context' ) );
165
-		foreach ( $active_message_contexts as $active_message ) {
166
-			if ( $active_message instanceof EE_Message ) {
164
+		$active_message_contexts = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
165
+		foreach ($active_message_contexts as $active_message) {
166
+			if ($active_message instanceof EE_Message) {
167 167
 				$message_type = $active_message->message_type_object();
168
-				if ( $message_type instanceof EE_message_type ) {
168
+				if ($message_type instanceof EE_message_type) {
169 169
 					$message_type_contexts = $message_type->get_contexts();
170
-					foreach ( $message_type_contexts as $context => $context_details ) {
171
-						$contexts[ $context ] = $context_details['label'];
170
+					foreach ($message_type_contexts as $context => $context_details) {
171
+						$contexts[$context] = $context_details['label'];
172 172
 					}
173 173
 				}
174 174
 			}
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
 
181 181
 	protected function _ajax_hooks() {
182
-		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) );
183
-		add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') );
184
-		add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') );
185
-		add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) );
186
-		add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) );
182
+		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle'));
183
+		add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle'));
184
+		add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings'));
185
+		add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form'));
186
+		add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack'));
187 187
 	}
188 188
 
189 189
 
@@ -215,13 +215,13 @@  discard block
 block discarded – undo
215 215
 	*		@return void
216 216
 	*/
217 217
 	protected function _set_page_routes() {
218
-		$grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] )
218
+		$grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID'])
219 219
 			? $this->_req_data['GRP_ID']
220 220
 			: 0;
221
-		$grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] )
221
+		$grp_id = empty($grp_id) && ! empty($this->_req_data['id'])
222 222
 			? $this->_req_data['id']
223 223
 			: $grp_id;
224
-		$msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] )
224
+		$msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID'])
225 225
 			? $this->_req_data['MSG_ID']
226 226
 			: 0;
227 227
 
@@ -263,35 +263,35 @@  discard block
 block discarded – undo
263 263
 			'insert_message_template' => array(
264 264
 				'func' => '_insert_or_update_message_template',
265 265
 				'capability' => 'ee_edit_messages',
266
-				'args' => array( 'new_template' => true ),
266
+				'args' => array('new_template' => true),
267 267
 				'noheader' => true
268 268
 			 ),
269 269
 			'update_message_template' => array(
270 270
 				'func' => '_insert_or_update_message_template',
271 271
 				'capability' => 'ee_edit_message',
272 272
 				'obj_id' => $grp_id,
273
-				'args' => array( 'new_template' => false ),
273
+				'args' => array('new_template' => false),
274 274
 				'noheader' => true
275 275
 			),
276 276
 			'trash_message_template' => array(
277 277
 				'func' => '_trash_or_restore_message_template',
278 278
 				'capability' => 'ee_delete_message',
279 279
 				'obj_id' => $grp_id,
280
-				'args' => array( 'trash' => true, 'all' => true ),
280
+				'args' => array('trash' => true, 'all' => true),
281 281
 				'noheader' => true
282 282
 			),
283 283
 			'trash_message_template_context' => array(
284 284
 				'func' => '_trash_or_restore_message_template',
285 285
 				'capability' => 'ee_delete_message',
286 286
 				'obj_id' => $grp_id,
287
-				'args' => array( 'trash' => true ),
287
+				'args' => array('trash' => true),
288 288
 				'noheader' => true
289 289
 			),
290 290
 			'restore_message_template' => array(
291 291
 				'func' => '_trash_or_restore_message_template',
292 292
 				'capability' => 'ee_delete_message',
293 293
 				'obj_id' => $grp_id,
294
-				'args' => array( 'trash' => false, 'all' => true ),
294
+				'args' => array('trash' => false, 'all' => true),
295 295
 				'noheader' => true
296 296
 			),
297 297
 			'restore_message_template_context' => array(
@@ -405,7 +405,7 @@  discard block
 block discarded – undo
405 405
 						'filename' => 'messages_overview_other',
406 406
 					),
407 407
 				),
408
-				'help_tour' => array( 'Messages_Overview_Help_Tour' ),
408
+				'help_tour' => array('Messages_Overview_Help_Tour'),
409 409
 				'require_nonce' => false
410 410
 			),
411 411
 			'custom_mtps' => array(
@@ -440,7 +440,7 @@  discard block
 block discarded – undo
440 440
 				),
441 441
 				'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'),
442 442
 				'has_metaboxes' => true,
443
-				'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ),
443
+				'help_tour' => array('Message_Templates_Edit_Help_Tour'),
444 444
 				'help_tabs' => array(
445 445
 					'edit_message_template' => array(
446 446
 						'title' => __('Message Template Editor', 'event_espresso'),
@@ -496,7 +496,7 @@  discard block
 block discarded – undo
496 496
 						'filename' => 'messages_settings_messengers'
497 497
 					),
498 498
 				),
499
-				'help_tour' => array( 'Messages_Settings_Help_Tour' ),
499
+				'help_tour' => array('Messages_Settings_Help_Tour'),
500 500
 				'require_nonce' => false
501 501
 			)
502 502
 		);
@@ -529,7 +529,7 @@  discard block
 block discarded – undo
529 529
 
530 530
 
531 531
 	protected function _add_screen_options_default() {
532
-		$this->_admin_page_title = __( 'Message Activity', 'event_espresso' );
532
+		$this->_admin_page_title = __('Message Activity', 'event_espresso');
533 533
 		$this->_per_page_screen_option();
534 534
 	}
535 535
 
@@ -551,37 +551,37 @@  discard block
 block discarded – undo
551 551
 
552 552
 
553 553
 	public function messages_help_tab() {
554
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' );
554
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php');
555 555
 	}
556 556
 
557 557
 
558 558
 	public function messengers_help_tab() {
559
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' );
559
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php');
560 560
 	}
561 561
 
562 562
 
563 563
 	public function message_types_help_tab() {
564
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' );
564
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php');
565 565
 	}
566 566
 
567 567
 
568 568
 	public function messages_overview_help_tab() {
569
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' );
569
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php');
570 570
 	}
571 571
 
572 572
 
573 573
 	public function message_templates_help_tab() {
574
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' );
574
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php');
575 575
 	}
576 576
 
577 577
 
578 578
 	public function edit_message_template_help_tab() {
579
-		$args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />';
580
-		$args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />';
581
-		$args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />';
582
-		$args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />';
583
-		$args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />';
584
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args);
579
+		$args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />';
580
+		$args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />';
581
+		$args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />';
582
+		$args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />';
583
+		$args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />';
584
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args);
585 585
 	}
586 586
 
587 587
 
@@ -589,22 +589,22 @@  discard block
 block discarded – undo
589 589
 	public function message_template_shortcodes_help_tab() {
590 590
 		$this->_set_shortcodes();
591 591
 		$args['shortcodes'] = $this->_shortcodes;
592
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args );
592
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args);
593 593
 	}
594 594
 
595 595
 
596 596
 
597 597
 	public function preview_message_help_tab() {
598
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' );
598
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php');
599 599
 	}
600 600
 
601 601
 
602 602
 	public function settings_help_tab() {
603
-		$args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
604
-		$args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
603
+		$args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />';
604
+		$args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />';
605 605
 		$args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>';
606 606
 		$args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>';
607
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
607
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args);
608 608
 	}
609 609
 
610 610
 
@@ -612,31 +612,31 @@  discard block
 block discarded – undo
612 612
 
613 613
 
614 614
 	public function load_scripts_styles() {
615
-		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION );
615
+		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
616 616
 		wp_enqueue_style('espresso_ee_msg');
617 617
 
618
-		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true );
619
-		wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION );
618
+		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true);
619
+		wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION);
620 620
 	}
621 621
 
622 622
 
623 623
 
624 624
 	public function load_scripts_styles_default() {
625
-		wp_enqueue_script( 'ee-msg-list-table-js' );
625
+		wp_enqueue_script('ee-msg-list-table-js');
626 626
 	}
627 627
 
628 628
 
629 629
 
630 630
 
631 631
 
632
-	public function wp_editor_css( $mce_css ) {
632
+	public function wp_editor_css($mce_css) {
633 633
 		//if we're on the edit_message_template route
634
-		if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger  ) {
634
+		if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
635 635
 			$message_type_name = $this->_active_message_type_name;
636 636
 
637 637
 			//we're going to REPLACE the existing mce css
638 638
 			//we need to get the css file location from the active messenger
639
-			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation );
639
+			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation);
640 640
 		}
641 641
 
642 642
 		return $mce_css;
@@ -654,15 +654,15 @@  discard block
 block discarded – undo
654 654
 			$this->_message_template_group->messenger_obj()->label['singular'],
655 655
 			$this->_message_template_group->message_type_obj()->label['singular']
656 656
 		);
657
-		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso' );
657
+		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso');
658 658
 
659
-		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION );
659
+		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION);
660 660
 
661 661
 		wp_enqueue_script('ee_admin_js');
662 662
 		wp_enqueue_script('ee_msgs_edit_js');
663 663
 
664 664
 		//add in special css for tiny_mce
665
-		add_filter( 'mce_css', array( $this, 'wp_editor_css' ) );
665
+		add_filter('mce_css', array($this, 'wp_editor_css'));
666 666
 	}
667 667
 
668 668
 
@@ -671,22 +671,22 @@  discard block
 block discarded – undo
671 671
 
672 672
 		$this->_set_message_template_group();
673 673
 
674
-		if ( isset( $this->_req_data['messenger'] ) ) {
675
-			$this->_active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
674
+		if (isset($this->_req_data['messenger'])) {
675
+			$this->_active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
676 676
 		}
677 677
 
678
-		$message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : '';
678
+		$message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : '';
679 679
 
680 680
 
681
-		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) );
681
+		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation));
682 682
 	}
683 683
 
684 684
 
685 685
 
686 686
 	public function load_scripts_styles_settings() {
687
-		wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION );
688
-		wp_enqueue_style( 'ee-text-links' );
689
-		wp_enqueue_style( 'ee-message-settings' );
687
+		wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION);
688
+		wp_enqueue_style('ee-text-links');
689
+		wp_enqueue_style('ee-message-settings');
690 690
 
691 691
 		wp_enqueue_script('ee-messages-settings');
692 692
 	}
@@ -716,40 +716,40 @@  discard block
 block discarded – undo
716 716
 	 * set views array for message queue list table
717 717
 	 */
718 718
 	public function _set_list_table_views_default() {
719
-		EE_Registry::instance()->load_helper( 'Template' );
719
+		EE_Registry::instance()->load_helper('Template');
720 720
 
721
-		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' )
721
+		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions')
722 722
 			? array(
723
-				'generate_now' => __( 'Generate Now', 'event_espresso' ),
724
-		        'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ),
725
-		        'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ),
726
-		        'send_now' => __( 'Send Now', 'event_espresso' )
723
+				'generate_now' => __('Generate Now', 'event_espresso'),
724
+		        'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'),
725
+		        'queue_for_resending' => __('Queue for Resending', 'event_espresso'),
726
+		        'send_now' => __('Send Now', 'event_espresso')
727 727
 				)
728 728
 			: array();
729 729
 
730
-		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' )
731
-			? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) )
730
+		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions')
731
+			? array('delete_ee_messages' => __('Delete Messages', 'event_espresso'))
732 732
 			: array();
733 733
 
734 734
 
735 735
 		$this->_views = array(
736 736
 			 'all' => array(
737 737
 			    'slug' => 'all',
738
-			    'label' => __( 'All', 'event_espresso' ),
738
+			    'label' => __('All', 'event_espresso'),
739 739
 			    'count' => 0,
740
-			    'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action )
740
+			    'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action)
741 741
 			 )
742 742
 		);
743 743
 
744 744
 
745
-		foreach ( EEM_Message::instance()->all_statuses() as $status ) {
746
-			if ( $status === EEM_Message::status_debug_only && ( ! defined( 'WP_DEBUG' ) || ! WP_DEBUG ) ) {
745
+		foreach (EEM_Message::instance()->all_statuses() as $status) {
746
+			if ($status === EEM_Message::status_debug_only && ( ! defined('WP_DEBUG') || ! WP_DEBUG)) {
747 747
 				continue;
748 748
 			}
749 749
 			$status_bulk_actions = $common_bulk_actions;
750 750
 			//unset bulk actions not applying to status
751
-			if ( ! empty( $status_bulk_actions ) ) {
752
-				switch ( $status ) {
751
+			if ( ! empty($status_bulk_actions)) {
752
+				switch ($status) {
753 753
 					case EEM_Message::status_idle :
754 754
 					case EEM_Message::status_resend :
755 755
 						$status_bulk_actions['send_now'] = $common_bulk_actions['send_now'];
@@ -761,21 +761,21 @@  discard block
 block discarded – undo
761 761
 						break;
762 762
 
763 763
 					case EEM_Message::status_incomplete :
764
-						unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] );
764
+						unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']);
765 765
 						break;
766 766
 
767 767
 					case EEM_Message::status_retry :
768 768
 					case EEM_Message::status_sent :
769
-						unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] );
769
+						unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']);
770 770
 						break;
771 771
 				}
772 772
 			}
773 773
 
774
-			$this->_views[ strtolower( $status ) ] = array(
775
-				'slug' => strtolower( $status ),
776
-				'label' => EEH_Template::pretty_status( $status, false, 'sentence' ),
774
+			$this->_views[strtolower($status)] = array(
775
+				'slug' => strtolower($status),
776
+				'label' => EEH_Template::pretty_status($status, false, 'sentence'),
777 777
 				'count' => 0,
778
-				'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action )
778
+				'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action)
779 779
 			);
780 780
 		}
781 781
 	}
@@ -794,8 +794,8 @@  discard block
 block discarded – undo
794 794
 	protected function _message_queue_list_table() {
795 795
 		$this->_search_btn_label = __('Message Activity', 'event_espresso');
796 796
 		$this->_template_args['per_column'] = 6;
797
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() );
798
-		$this->_template_args['before_list_table'] = '<h3>' . EEM_Message::instance()->get_pretty_label_for_results() . '</h3>';
797
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items());
798
+		$this->_template_args['before_list_table'] = '<h3>'.EEM_Message::instance()->get_pretty_label_for_results().'</h3>';
799 799
 		$this->display_admin_list_table_page_with_no_sidebar();
800 800
 	}
801 801
 
@@ -808,8 +808,8 @@  discard block
 block discarded – undo
808 808
 		$action_css_classes = EEH_MSG_Template::get_message_action_icons();
809 809
 		$action_items = array();
810 810
 
811
-		foreach( $action_css_classes as $action_item => $action_details ) {
812
-			if ( $action_item === 'see_notifications_for' ) {
811
+		foreach ($action_css_classes as $action_item => $action_details) {
812
+			if ($action_item === 'see_notifications_for') {
813 813
 				continue;
814 814
 			}
815 815
 			$action_items[$action_item] = array(
@@ -821,37 +821,37 @@  discard block
 block discarded – undo
821 821
 		/** @type array $status_items status legend setup*/
822 822
 		$status_items = array(
823 823
 			'sent_status' => array(
824
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent,
825
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, false, 'sentence' )
824
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent,
825
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence')
826 826
 				),
827 827
 			'idle_status' => array(
828
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle,
829
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, false, 'sentence' )
828
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle,
829
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence')
830 830
 				),
831 831
 			'failed_status' => array(
832
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed,
833
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, false, 'sentence' )
832
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed,
833
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence')
834 834
 			),
835 835
 			'resend_status' => array(
836
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend,
837
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, false, 'sentence' )
836
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend,
837
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence')
838 838
 				),
839 839
 			'incomplete_status' => array(
840
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete,
841
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, false, 'sentence' )
840
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete,
841
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence')
842 842
 				),
843 843
 			'retry_status' => array(
844
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry,
845
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, false, 'sentence' )
844
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry,
845
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence')
846 846
 				)
847 847
 		);
848
-		if ( defined( 'WP_DEBUG' ) && WP_DEBUG ) {
848
+		if (defined('WP_DEBUG') && WP_DEBUG) {
849 849
 			$status_items['debug_only_status'] = array(
850
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only,
851
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_debug_only, false, 'sentence' )
850
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only,
851
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence')
852 852
 			);
853 853
 		}
854
-		return array_merge( $action_items, $status_items );
854
+		return array_merge($action_items, $status_items);
855 855
 	}
856 856
 
857 857
 
@@ -861,9 +861,9 @@  discard block
 block discarded – undo
861 861
 
862 862
 	protected function _custom_mtps_preview() {
863 863
 		$this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso');
864
-		$this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso' ) . '" />';
864
+		$this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />';
865 865
 		$this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the caffeinated version of Event Espresso.  With the Custom Message Templates feature, you are able to create custom templates and set them per event.', 'event_espresso').'</strong>';
866
-		$this->display_admin_caf_preview_page( 'custom_message_types', false );
866
+		$this->display_admin_caf_preview_page('custom_message_types', false);
867 867
 	}
868 868
 
869 869
 
@@ -887,31 +887,31 @@  discard block
 block discarded – undo
887 887
 	 *
888 888
 	 * @return array
889 889
 	 */
890
-	public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) {
890
+	public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) {
891 891
 
892 892
 		$MTP = EEM_Message_Template_Group::instance();
893 893
 
894 894
 		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby'];
895 895
 		$orderby = $this->_req_data['orderby'];
896 896
 
897
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC';
897
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
898 898
 
899
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
900
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage;
899
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
900
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage;
901 901
 
902
-		$offset = ($current_page-1)*$per_page;
903
-		$limit = $all ? null : array( $offset, $per_page );
902
+		$offset = ($current_page - 1) * $per_page;
903
+		$limit = $all ? null : array($offset, $per_page);
904 904
 
905 905
 
906 906
 		//options will match what is in the _views array property
907
-		switch( $type ) {
907
+		switch ($type) {
908 908
 
909 909
 			case 'in_use':
910
-				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true );
910
+				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true);
911 911
 				break;
912 912
 
913 913
 			default:
914
-				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global );
914
+				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global);
915 915
 
916 916
 		}
917 917
 
@@ -930,8 +930,8 @@  discard block
 block discarded – undo
930 930
 		$installed_message_types = $this->_message_resource_manager->installed_message_types();
931 931
 		$installed = array();
932 932
 
933
-		foreach ( $installed_message_types as $message_type ) {
934
-			$installed[ $message_type->name ] = $message_type;
933
+		foreach ($installed_message_types as $message_type) {
934
+			$installed[$message_type->name] = $message_type;
935 935
 		}
936 936
 
937 937
 		return $installed;
@@ -950,24 +950,24 @@  discard block
 block discarded – undo
950 950
 	 *
951 951
 	 * @throws EE_error
952 952
 	 */
953
-	protected function _add_message_template(  $message_type = '', $messenger='', $GRP_ID = '' ) {
953
+	protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') {
954 954
 		//set values override any request data
955
-		$message_type = !empty( $message_type ) ? $message_type : '';
956
-		$message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type;
955
+		$message_type = ! empty($message_type) ? $message_type : '';
956
+		$message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type;
957 957
 
958
-		$messenger = !empty( $messenger ) ? $messenger : '';
959
-		$messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger;
958
+		$messenger = ! empty($messenger) ? $messenger : '';
959
+		$messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger;
960 960
 
961
-		$GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : '';
962
-		$GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID;
961
+		$GRP_ID = ! empty($GRP_ID) ? $GRP_ID : '';
962
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID;
963 963
 
964 964
 		//we need messenger and message type.  They should be coming from the event editor. If not here then return error
965
-		if ( empty( $message_type ) || empty( $messenger )  )
966
-			{throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));}
965
+		if (empty($message_type) || empty($messenger))
966
+			{throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); }
967 967
 
968 968
 		//we need the GRP_ID for the template being used as the base for the new template
969
-		if ( empty( $GRP_ID ) )
970
-			{throw new EE_Error( __('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso' ) );}
969
+		if (empty($GRP_ID))
970
+			{throw new EE_Error(__('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso')); }
971 971
 
972 972
 		//let's just make sure the template gets generated!
973 973
 
@@ -988,8 +988,8 @@  discard block
 block discarded – undo
988 988
 	 * @param int      $GRP_ID         GRP_ID for the related message template group this new template will be based
989 989
 	 *                                 off of.
990 990
 	 */
991
-	public function add_message_template( $message_type, $messenger, $GRP_ID ) {
992
-		$this->_add_message_template( $message_type, $messenger, $GRP_ID );
991
+	public function add_message_template($message_type, $messenger, $GRP_ID) {
992
+		$this->_add_message_template($message_type, $messenger, $GRP_ID);
993 993
 	}
994 994
 
995 995
 
@@ -1000,14 +1000,14 @@  discard block
 block discarded – undo
1000 1000
 	 * @return void
1001 1001
 	 */
1002 1002
 	protected function _edit_message_template() {
1003
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '');
1003
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1004 1004
 		$template_fields = '';
1005 1005
 		$sidebar_fields = '';
1006 1006
 		//we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates.
1007
-		add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 );
1007
+		add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2);
1008 1008
 
1009
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] )
1010
-			? absint( $this->_req_data['id'] )
1009
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id'])
1010
+			? absint($this->_req_data['id'])
1011 1011
 			: false;
1012 1012
 
1013 1013
 		$this->_set_shortcodes(); //this also sets the _message_template property.
@@ -1015,20 +1015,20 @@  discard block
 block discarded – undo
1015 1015
 		$c_label = $message_template_group->context_label();
1016 1016
 		$c_config = $message_template_group->contexts_config();
1017 1017
 
1018
-		reset( $c_config );
1019
-		$context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] )
1018
+		reset($c_config);
1019
+		$context = isset($this->_req_data['context']) && ! empty($this->_req_data['context'])
1020 1020
 			? strtolower($this->_req_data['context'])
1021 1021
 			: key($c_config);
1022 1022
 
1023 1023
 
1024
-		if ( empty($GRP_ID) ) {
1024
+		if (empty($GRP_ID)) {
1025 1025
 			$action = 'insert_message_template';
1026 1026
 			//$button_both = false;
1027 1027
 			//$button_text = array( __( 'Save','event_espresso') );
1028 1028
 			//$button_actions = array('something_different');
1029 1029
 			//$referrer = false;
1030 1030
 			$edit_message_template_form_url = add_query_arg(
1031
-				array( 'action' => $action, 'noheader' => true ),
1031
+				array('action' => $action, 'noheader' => true),
1032 1032
 				EE_MSG_ADMIN_URL
1033 1033
 			);
1034 1034
 		} else {
@@ -1038,7 +1038,7 @@  discard block
 block discarded – undo
1038 1038
 			//$button_actions = array();
1039 1039
 			//$referrer = $this->_admin_base_url;
1040 1040
 			$edit_message_template_form_url = add_query_arg(
1041
-				array( 'action' => $action, 'noheader' => true ),
1041
+				array('action' => $action, 'noheader' => true),
1042 1042
 				EE_MSG_ADMIN_URL
1043 1043
 			);
1044 1044
 		}
@@ -1052,14 +1052,14 @@  discard block
 block discarded – undo
1052 1052
 
1053 1053
 		//Do we have any validation errors?
1054 1054
 		$validators = $this->_get_transient();
1055
-		$v_fields = !empty($validators) ? array_keys($validators) : array();
1055
+		$v_fields = ! empty($validators) ? array_keys($validators) : array();
1056 1056
 
1057 1057
 
1058 1058
 		//we need to assemble the title from Various details
1059 1059
 		$context_label = sprintf(
1060 1060
 			__('(%s %s)', 'event_espresso'),
1061 1061
 			$c_config[$context]['label'],
1062
-			ucwords($c_label['label'] )
1062
+			ucwords($c_label['label'])
1063 1063
 		);
1064 1064
 
1065 1065
 		$title = sprintf(
@@ -1080,7 +1080,7 @@  discard block
 block discarded – undo
1080 1080
 			$message_template_group->message_type()
1081 1081
 		);
1082 1082
 
1083
-		if ( !$template_field_structure ) {
1083
+		if ( ! $template_field_structure) {
1084 1084
 			$template_field_structure = false;
1085 1085
 			$template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso');
1086 1086
 		}
@@ -1090,51 +1090,51 @@  discard block
 block discarded – undo
1090 1090
 
1091 1091
 
1092 1092
 		//if we have the extra key.. then we need to remove the content index from the template_field_structure as it will get handled in the "extra" array.
1093
-		if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) {
1094
-			foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) {
1095
-				unset( $template_field_structure[$context][$reference_field] );
1093
+		if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) {
1094
+			foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) {
1095
+				unset($template_field_structure[$context][$reference_field]);
1096 1096
 			}
1097 1097
 		}
1098 1098
 
1099 1099
 		//let's loop through the template_field_structure and actually assemble the input fields!
1100
-		if ( !empty($template_field_structure) ) {
1101
-			foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) {
1100
+		if ( ! empty($template_field_structure)) {
1101
+			foreach ($template_field_structure[$context] as $template_field => $field_setup_array) {
1102 1102
 				//if this is an 'extra' template field then we need to remove any existing fields that are keyed up in the extra array and reset them.
1103
-				if ( $template_field == 'extra' ) {
1103
+				if ($template_field == 'extra') {
1104 1104
 					$this->_template_args['is_extra_fields'] = true;
1105
-					foreach ( $field_setup_array as $reference_field => $new_fields_array ) {
1106
-						$message_template = $message_templates[ $context ][ $reference_field ];
1105
+					foreach ($field_setup_array as $reference_field => $new_fields_array) {
1106
+						$message_template = $message_templates[$context][$reference_field];
1107 1107
 						$content = $message_template instanceof EE_Message_Template
1108
-							? $message_template->get( 'MTP_content' )
1108
+							? $message_template->get('MTP_content')
1109 1109
 							: '';
1110
-						foreach ( $new_fields_array as $extra_field =>  $extra_array ) {
1110
+						foreach ($new_fields_array as $extra_field =>  $extra_array) {
1111 1111
 							//let's verify if we need this extra field via the shortcodes parameter.
1112 1112
 							$continue = false;
1113
-							if ( isset( $extra_array['shortcodes_required'] ) ) {
1114
-								foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) {
1115
-									if ( !array_key_exists( $shortcode, $this->_shortcodes ) )
1116
-										{$continue = true;}
1113
+							if (isset($extra_array['shortcodes_required'])) {
1114
+								foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
1115
+									if ( ! array_key_exists($shortcode, $this->_shortcodes))
1116
+										{$continue = true; }
1117 1117
 								}
1118
-								if ( $continue ) {continue;}
1118
+								if ($continue) {continue; }
1119 1119
 							}
1120 1120
 
1121
-							$field_id = $reference_field . '-' . $extra_field . '-content';
1121
+							$field_id = $reference_field.'-'.$extra_field.'-content';
1122 1122
 							$template_form_fields[$field_id] = $extra_array;
1123
-							$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']';
1124
-							$css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : '';
1123
+							$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']';
1124
+							$css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : '';
1125 1125
 
1126
-							$template_form_fields[$field_id]['css_class'] = ! empty( $v_fields )
1126
+							$template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1127 1127
 																			&& in_array($extra_field, $v_fields)
1128 1128
 																			&&
1129 1129
 																			(
1130
-								                                                is_array($validators[$extra_field] )
1131
-																				&& isset( $validators[$extra_field]['msg'] )
1130
+								                                                is_array($validators[$extra_field])
1131
+																				&& isset($validators[$extra_field]['msg'])
1132 1132
 							                                                )
1133
-								? 'validate-error ' . $css_class
1133
+								? 'validate-error '.$css_class
1134 1134
 								: $css_class;
1135 1135
 
1136
-							$template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field])
1137
-								? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") )
1136
+							$template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field])
1137
+								? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8"))
1138 1138
 								: '';
1139 1139
 
1140 1140
 							//do we have a validation error?  if we do then let's use that value instead
@@ -1150,32 +1150,32 @@  discard block
 block discarded – undo
1150 1150
 								$field_id
1151 1151
 							);
1152 1152
 
1153
-							if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) {
1153
+							if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') {
1154 1154
 								//we want to decode the entities
1155 1155
 								$template_form_fields[$field_id]['value'] = stripslashes(
1156
-									html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")
1156
+									html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")
1157 1157
 								);
1158 1158
 
1159 1159
 							}/**/
1160 1160
 						}
1161
-						$templatefield_MTP_id = $reference_field . '-MTP_ID';
1162
-						$templatefield_templatename_id = $reference_field . '-name';
1161
+						$templatefield_MTP_id = $reference_field.'-MTP_ID';
1162
+						$templatefield_templatename_id = $reference_field.'-name';
1163 1163
 
1164 1164
 						$template_form_fields[$templatefield_MTP_id] = array(
1165
-							'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1165
+							'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]',
1166 1166
 							'label' => null,
1167 1167
 							'input' => 'hidden',
1168 1168
 							'type' => 'int',
1169 1169
 							'required' => false,
1170 1170
 							'validation' => false,
1171
-							'value' => !empty($message_templates) ? $message_template->ID() : '',
1171
+							'value' => ! empty($message_templates) ? $message_template->ID() : '',
1172 1172
 							'css_class' => '',
1173 1173
 							'format' => '%d',
1174 1174
 							'db-col' => 'MTP_ID'
1175 1175
 						);
1176 1176
 
1177 1177
 						$template_form_fields[$templatefield_templatename_id] = array(
1178
-							'name' => 'MTP_template_fields[' . $reference_field . '][name]',
1178
+							'name' => 'MTP_template_fields['.$reference_field.'][name]',
1179 1179
 							'label' => null,
1180 1180
 							'input' => 'hidden',
1181 1181
 							'type' => 'string',
@@ -1189,14 +1189,14 @@  discard block
 block discarded – undo
1189 1189
 					}
1190 1190
 					continue; //skip the next stuff, we got the necessary fields here for this dataset.
1191 1191
 				} else {
1192
-					$field_id = $template_field . '-content';
1192
+					$field_id = $template_field.'-content';
1193 1193
 					$template_form_fields[$field_id] = $field_setup_array;
1194
-					$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]';
1195
-					$message_template = isset( $message_templates[ $context ][ $template_field ] )
1196
-						? $message_templates[ $context ][ $template_field ]
1194
+					$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]';
1195
+					$message_template = isset($message_templates[$context][$template_field])
1196
+						? $message_templates[$context][$template_field]
1197 1197
 						: null;
1198
-					$template_form_fields[$field_id]['value'] = ! empty( $message_templates )
1199
-																&& is_array( $message_templates[$context] )
1198
+					$template_form_fields[$field_id]['value'] = ! empty($message_templates)
1199
+																&& is_array($message_templates[$context])
1200 1200
 																&& $message_template instanceof EE_Message_Template
1201 1201
 						? $message_template->get('MTP_content')
1202 1202
 						: '';
@@ -1209,10 +1209,10 @@  discard block
 block discarded – undo
1209 1209
 
1210 1210
 					$template_form_fields[$field_id]['db-col'] = 'MTP_content';
1211 1211
 					$css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : '';
1212
-					$template_form_fields[$field_id]['css_class'] =  ! empty( $v_fields )
1213
-																	 && in_array( $template_field, $v_fields )
1214
-																	 && isset( $validators[$template_field]['msg'] )
1215
-						? 'validate-error ' . $css_class
1212
+					$template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1213
+																	 && in_array($template_field, $v_fields)
1214
+																	 && isset($validators[$template_field]['msg'])
1215
+						? 'validate-error '.$css_class
1216 1216
 						: $css_class;
1217 1217
 
1218 1218
 					//shortcode selector
@@ -1223,12 +1223,12 @@  discard block
 block discarded – undo
1223 1223
 
1224 1224
 				//k took care of content field(s) now let's take care of others.
1225 1225
 
1226
-				$templatefield_MTP_id = $template_field . '-MTP_ID';
1227
-				$templatefield_field_templatename_id = $template_field . '-name';
1226
+				$templatefield_MTP_id = $template_field.'-MTP_ID';
1227
+				$templatefield_field_templatename_id = $template_field.'-name';
1228 1228
 
1229 1229
 				//foreach template field there are actually two form fields created
1230 1230
 				$template_form_fields[$templatefield_MTP_id] = array(
1231
-					'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1231
+					'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]',
1232 1232
 					'label' => null,
1233 1233
 					'input' => 'hidden',
1234 1234
 					'type' => 'int',
@@ -1241,7 +1241,7 @@  discard block
 block discarded – undo
1241 1241
 				);
1242 1242
 
1243 1243
 				$template_form_fields[$templatefield_field_templatename_id] = array(
1244
-					'name' => 'MTP_template_fields[' . $template_field . '][name]',
1244
+					'name' => 'MTP_template_fields['.$template_field.'][name]',
1245 1245
 					'label' => null,
1246 1246
 					'input' => 'hidden',
1247 1247
 					'type' => 'string',
@@ -1385,13 +1385,13 @@  discard block
 block discarded – undo
1385 1385
 				'value' => $GRP_ID
1386 1386
 				);
1387 1387
 			$sidebar_form_fields['ee-msg-evt-nonce'] = array(
1388
-				'name' => $action . '_nonce',
1388
+				'name' => $action.'_nonce',
1389 1389
 				'input' => 'hidden',
1390 1390
 				'type' => 'string',
1391
-				'value' => wp_create_nonce( $action . '_nonce')
1391
+				'value' => wp_create_nonce($action.'_nonce')
1392 1392
 				);
1393 1393
 
1394
-			if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) {
1394
+			if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
1395 1395
 				$sidebar_form_fields['ee-msg-template-switch'] = array(
1396 1396
 					'name' => 'template_switch',
1397 1397
 					'input' => 'hidden',
@@ -1401,8 +1401,8 @@  discard block
 block discarded – undo
1401 1401
 			}
1402 1402
 
1403 1403
 
1404
-			$template_fields = $this->_generate_admin_form_fields( $template_form_fields );
1405
-			$sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields );
1404
+			$template_fields = $this->_generate_admin_form_fields($template_form_fields);
1405
+			$sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields);
1406 1406
 
1407 1407
 
1408 1408
 		} //end if ( !empty($template_field_structure) )
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
 			 $GRP_ID,
1415 1415
 			 false,
1416 1416
 			 add_query_arg(
1417
-			    array( 'action' => 'global_mtps' ),
1417
+			    array('action' => 'global_mtps'),
1418 1418
 			    $this->_admin_base_url
1419 1419
 			 )
1420 1420
 		);
@@ -1430,7 +1430,7 @@  discard block
 block discarded – undo
1430 1430
 			),
1431 1431
 			$this->_admin_base_url
1432 1432
 		);
1433
-		$preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>';
1433
+		$preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>';
1434 1434
 
1435 1435
 
1436 1436
 		//setup context switcher
@@ -1458,17 +1458,17 @@  discard block
 block discarded – undo
1458 1458
 		$this->_template_args['after_admin_page_content'] = $this->_add_form_element_after();
1459 1459
 
1460 1460
 		$this->_template_path = $this->_template_args['GRP_ID']
1461
-			? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1462
-			: EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1461
+			? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php'
1462
+			: EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php';
1463 1463
 
1464 1464
 		//send along EE_Message_Template_Group object for further template use.
1465 1465
 		$this->_template_args['MTP'] = $message_template_group;
1466 1466
 
1467
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true );
1467
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true);
1468 1468
 
1469 1469
 
1470 1470
 		//finally, let's set the admin_page title
1471
-		$this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title );
1471
+		$this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title);
1472 1472
 
1473 1473
 
1474 1474
 		//we need to take care of setting the shortcodes property for use elsewhere.
@@ -1481,7 +1481,7 @@  discard block
 block discarded – undo
1481 1481
 	}
1482 1482
 
1483 1483
 
1484
-	public function filter_tinymce_init( $mceInit, $editor_id ) {
1484
+	public function filter_tinymce_init($mceInit, $editor_id) {
1485 1485
 		return $mceInit;
1486 1486
 	}
1487 1487
 
@@ -1492,7 +1492,7 @@  discard block
 block discarded – undo
1492 1492
 	}
1493 1493
 
1494 1494
 	public function _add_form_element_before() {
1495
-		return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">';
1495
+		return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">';
1496 1496
 	}
1497 1497
 
1498 1498
 	public function _add_form_element_after() {
@@ -1509,25 +1509,25 @@  discard block
 block discarded – undo
1509 1509
 	 *
1510 1510
 	 */
1511 1511
 	public function switch_template_pack() {
1512
-		$GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1513
-		$template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : '';
1512
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1513
+		$template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : '';
1514 1514
 
1515 1515
 		//verify we have needed values.
1516
-		if ( empty( $GRP_ID ) || empty( $template_pack ) ) {
1516
+		if (empty($GRP_ID) || empty($template_pack)) {
1517 1517
 			$this->_template_args['error'] = true;
1518
-			EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__  );
1518
+			EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1519 1519
 		} else {
1520 1520
 			//get template, set the new template_pack and then reset to default
1521 1521
 			/** @type EE_Message_Template_Group $message_template_group */
1522
-			$message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1522
+			$message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1523 1523
 
1524
-			$message_template_group->set_template_pack_name( $template_pack );
1524
+			$message_template_group->set_template_pack_name($template_pack);
1525 1525
 			$this->_req_data['msgr'] = $message_template_group->messenger();
1526 1526
 			$this->_req_data['mt'] = $message_template_group->message_type();
1527 1527
 
1528 1528
 			$query_args = $this->_reset_to_default_template();
1529 1529
 
1530
-			if ( empty( $query_args['id'] ) ) {
1530
+			if (empty($query_args['id'])) {
1531 1531
 				EE_Error::add_error(
1532 1532
 					__(
1533 1533
 						'Something went wrong with switching the template pack. Please try again or contact EE support',
@@ -1537,7 +1537,7 @@  discard block
 block discarded – undo
1537 1537
 				);
1538 1538
 				$this->_template_args['error'] = true;
1539 1539
 			} else {
1540
-				$template_label =$message_template_group->get_template_pack()->label;
1540
+				$template_label = $message_template_group->get_template_pack()->label;
1541 1541
 				$template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels();
1542 1542
 				EE_Error::add_success(
1543 1543
 					sprintf(
@@ -1550,7 +1550,7 @@  discard block
 block discarded – undo
1550 1550
 					)
1551 1551
 				);
1552 1552
 				//generate the redirect url for js.
1553
-				$url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1553
+				$url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1554 1554
 				$this->_template_args['data']['redirect_url'] = $url;
1555 1555
 				$this->_template_args['success'] = true;
1556 1556
 			}
@@ -1572,9 +1572,9 @@  discard block
 block discarded – undo
1572 1572
 	protected function _reset_to_default_template() {
1573 1573
 
1574 1574
 		$templates = array();
1575
-		$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1575
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1576 1576
 		//we need to make sure we've got the info we need.
1577
-		if ( ! isset( $this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'] ) ) {
1577
+		if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) {
1578 1578
 			EE_Error::add_error(
1579 1579
 				__(
1580 1580
 					'In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset.  At least one of these is missing.',
@@ -1586,9 +1586,9 @@  discard block
 block discarded – undo
1586 1586
 
1587 1587
 		// all templates will be reset to whatever the defaults are
1588 1588
 		// for the global template matching the messenger and message type.
1589
-		$success = !empty( $GRP_ID ) ? true : false;
1589
+		$success = ! empty($GRP_ID) ? true : false;
1590 1590
 
1591
-		if ( $success ) {
1591
+		if ($success) {
1592 1592
 
1593 1593
 			//let's first determine if the incoming template is a global template,
1594 1594
 			// if it isn't then we need to get the global template matching messenger and message type.
@@ -1596,9 +1596,9 @@  discard block
 block discarded – undo
1596 1596
 
1597 1597
 
1598 1598
 			//note this is ONLY deleting the template fields (Message Template rows) NOT the message template group.
1599
-			$success = $this->_delete_mtp_permanently( $GRP_ID, false );
1599
+			$success = $this->_delete_mtp_permanently($GRP_ID, false);
1600 1600
 
1601
-			if ( $success ) {
1601
+			if ($success) {
1602 1602
 				// if successfully deleted, lets generate the new ones.
1603 1603
 				// Note. We set GLOBAL to true, because resets on ANY template
1604 1604
 				// will use the related global template defaults for regeneration.
@@ -1616,32 +1616,32 @@  discard block
 block discarded – undo
1616 1616
 		}
1617 1617
 
1618 1618
 		//any error messages?
1619
-		if ( !$success ) {
1619
+		if ( ! $success) {
1620 1620
 			EE_Error::add_error(
1621
-				__( 'Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso' ),
1621
+				__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'),
1622 1622
 				__FILE__, __FUNCTION__, __LINE__
1623 1623
 			);
1624 1624
 		}
1625 1625
 
1626 1626
 		//all good, let's add a success message!
1627
-		if ( $success && ! empty( $templates ) ) {
1627
+		if ($success && ! empty($templates)) {
1628 1628
 			$templates = $templates[0]; //the info for the template we generated is the first element in the returned array.
1629 1629
 			EE_Error::overwrite_success();
1630
-			EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') );
1630
+			EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso'));
1631 1631
 		}
1632 1632
 
1633 1633
 
1634 1634
 		$query_args = array(
1635
-			'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null,
1636
-			'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null,
1637
-			'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps'
1635
+			'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null,
1636
+			'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null,
1637
+			'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps'
1638 1638
 			);
1639 1639
 
1640 1640
 		//if called via ajax then we return query args otherwise redirect
1641
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
1641
+		if (defined('DOING_AJAX') && DOING_AJAX) {
1642 1642
 			return $query_args;
1643 1643
 		} else {
1644
-			$this->_redirect_after_action( false, '', '', $query_args, true );
1644
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1645 1645
 			return null;
1646 1646
 		}
1647 1647
 	}
@@ -1654,7 +1654,7 @@  discard block
 block discarded – undo
1654 1654
 	 * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
1655 1655
 	 * @return string
1656 1656
 	 */
1657
-	public function _preview_message( $send = false ) {
1657
+	public function _preview_message($send = false) {
1658 1658
 		//first make sure we've got the necessary parameters
1659 1659
 		if (
1660 1660
 			! isset(
@@ -1670,13 +1670,13 @@  discard block
 block discarded – undo
1670 1670
 			);
1671 1671
 		}
1672 1672
 
1673
-		EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] );
1673
+		EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']);
1674 1674
 
1675 1675
 
1676 1676
 		//get the preview!
1677
-		$preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send );
1677
+		$preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send);
1678 1678
 
1679
-		if ( $send ) {
1679
+		if ($send) {
1680 1680
 			return $preview;
1681 1681
 		}
1682 1682
 
@@ -1686,22 +1686,22 @@  discard block
 block discarded – undo
1686 1686
 			'context' => $this->_req_data['context'],
1687 1687
 			'action' => 'edit_message_template'
1688 1688
 			);
1689
-		$go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1690
-		$preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>';
1689
+		$go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1690
+		$preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>';
1691 1691
 		$message_types = $this->get_installed_message_types();
1692
-		$active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
1692
+		$active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
1693 1693
 		$active_messenger_label = $active_messenger instanceof EE_messenger
1694
-			? ucwords( $active_messenger->label['singular'] )
1695
-			: esc_html__( 'Unknown Messenger', 'event_espresso' );
1694
+			? ucwords($active_messenger->label['singular'])
1695
+			: esc_html__('Unknown Messenger', 'event_espresso');
1696 1696
 		//let's provide a helpful title for context
1697 1697
 		$preview_title = sprintf(
1698
-			__( 'Viewing Preview for %s %s Message Template', 'event_espresso' ),
1698
+			__('Viewing Preview for %s %s Message Template', 'event_espresso'),
1699 1699
 			$active_messenger_label,
1700
-			ucwords( $message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] )
1700
+			ucwords($message_types[$this->_req_data['message_type']]->label['singular'])
1701 1701
 		);
1702 1702
 		//setup display of preview.
1703 1703
 		$this->_admin_page_title = $preview_title;
1704
-		$this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview);
1704
+		$this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview);
1705 1705
 		$this->_template_args['data']['force_json'] = true;
1706 1706
 		return '';
1707 1707
 	}
@@ -1731,9 +1731,9 @@  discard block
 block discarded – undo
1731 1731
 	 * @return void
1732 1732
 	 */
1733 1733
 	protected function _register_edit_meta_boxes() {
1734
-		add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' );
1735
-		add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1736
-		add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1734
+		add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default');
1735
+		add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high');
1736
+		add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high');
1737 1737
 	}
1738 1738
 
1739 1739
 
@@ -1752,14 +1752,14 @@  discard block
 block discarded – undo
1752 1752
 
1753 1753
 		$tp_select_values = array();
1754 1754
 
1755
-		foreach ( $tp_collection as $tp ) {
1755
+		foreach ($tp_collection as $tp) {
1756 1756
 			//only include template packs that support this messenger and message type!
1757 1757
 			$supports = $tp->get_supports();
1758 1758
 			if (
1759
-				! isset( $supports[ $this->_message_template_group->messenger() ] )
1759
+				! isset($supports[$this->_message_template_group->messenger()])
1760 1760
 				|| ! in_array(
1761 1761
 					$this->_message_template_group->message_type(),
1762
-					$supports[ $this->_message_template_group->messenger() ]
1762
+					$supports[$this->_message_template_group->messenger()]
1763 1763
 				)
1764 1764
 			) {
1765 1765
 				//not supported
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 		}
1774 1774
 
1775 1775
 		//if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by the default template pack.  This still allows for the odd template pack to override.
1776
-		if ( empty( $tp_select_values ) ) {
1776
+		if (empty($tp_select_values)) {
1777 1777
 			$tp_select_values[] = array(
1778 1778
 				'text' => __('Default', 'event_espresso'),
1779 1779
 				'id' => 'default'
@@ -1786,14 +1786,14 @@  discard block
 block discarded – undo
1786 1786
 			$this->_message_template_group->message_type()
1787 1787
 		);
1788 1788
 		$variations_select_values = array();
1789
-		foreach ( $variations as $variation => $label ) {
1789
+		foreach ($variations as $variation => $label) {
1790 1790
 			$variations_select_values[] = array(
1791 1791
 				'text' => $label,
1792 1792
 				'id' => $variation
1793 1793
 			);
1794 1794
 		}
1795 1795
 
1796
-		$template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels();
1796
+		$template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
1797 1797
 
1798 1798
 		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input(
1799 1799
 			'MTP_template_pack',
@@ -1810,9 +1810,9 @@  discard block
 block discarded – undo
1810 1810
 		$template_args['template_pack_description'] = $template_pack_labels->template_pack_description;
1811 1811
 		$template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
1812 1812
 
1813
-		$template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
1813
+		$template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php';
1814 1814
 
1815
-		EEH_Template::display_template( $template, $template_args );
1815
+		EEH_Template::display_template($template, $template_args);
1816 1816
 	}
1817 1817
 
1818 1818
 
@@ -1843,47 +1843,47 @@  discard block
 block discarded – undo
1843 1843
 		//first we need to see if there are any fields
1844 1844
 		$fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
1845 1845
 
1846
-		if ( !empty( $fields ) ) {
1846
+		if ( ! empty($fields)) {
1847 1847
 			//yup there be fields
1848
-			foreach ( $fields as $field => $config ) {
1849
-				$field_id = $this->_message_template_group->messenger() . '_' . $field;
1848
+			foreach ($fields as $field => $config) {
1849
+				$field_id = $this->_message_template_group->messenger().'_'.$field;
1850 1850
 				$existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
1851
-				$default = isset( $config['default'] ) ? $config['default'] : '';
1852
-				$default = isset( $config['value'] ) ? $config['value'] : $default;
1851
+				$default = isset($config['default']) ? $config['default'] : '';
1852
+				$default = isset($config['value']) ? $config['value'] : $default;
1853 1853
 
1854 1854
 				//if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults
1855 1855
 				$fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : '';
1856
-				$existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix;
1856
+				$existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix;
1857 1857
 
1858 1858
 				$template_form_fields[$field_id] = array(
1859
-					'name' => 'test_settings_fld[' . $field . ']',
1859
+					'name' => 'test_settings_fld['.$field.']',
1860 1860
 					'label' => $config['label'],
1861 1861
 					'input' => $config['input'],
1862 1862
 					'type' => $config['type'],
1863 1863
 					'required' => $config['required'],
1864 1864
 					'validation' => $config['validation'],
1865
-					'value' => isset( $existing[$field] ) ? $existing[$field] : $default,
1865
+					'value' => isset($existing[$field]) ? $existing[$field] : $default,
1866 1866
 					'css_class' => $config['css_class'],
1867
-					'options' => isset( $config['options'] ) ? $config['options'] : array(),
1867
+					'options' => isset($config['options']) ? $config['options'] : array(),
1868 1868
 					'default' => $default,
1869 1869
 					'format' => $config['format']
1870 1870
 					);
1871 1871
 			}
1872 1872
 		}
1873 1873
 
1874
-		$test_settings_fields = !empty( $template_form_fields)
1875
-			? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' )
1874
+		$test_settings_fields = ! empty($template_form_fields)
1875
+			? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds')
1876 1876
 			: '';
1877 1877
 
1878 1878
 		$test_settings_html = '';
1879 1879
 		//print out $test_settings_fields
1880
-		if ( !empty( $test_settings_fields ) ) {
1880
+		if ( ! empty($test_settings_fields)) {
1881 1881
 			echo $test_settings_fields;
1882
-			$test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="' . __('Test Send', 'event_espresso') . '" /><div style="clear:both"></div>';
1882
+			$test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="'.__('Test Send', 'event_espresso').'" /><div style="clear:both"></div>';
1883 1883
 		}
1884 1884
 
1885 1885
 		//and button
1886
-		echo $test_settings_html . '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>' . '<div class="publishing-action alignright resetbutton">' . $button . '</div><div style="clear:both"></div>';
1886
+		echo $test_settings_html.'<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>'.'<div class="publishing-action alignright resetbutton">'.$button.'</div><div style="clear:both"></div>';
1887 1887
 	}
1888 1888
 
1889 1889
 
@@ -1898,13 +1898,13 @@  discard block
 block discarded – undo
1898 1898
      * @param string $linked_input_id The css id of the input that the shortcodes get added to.
1899 1899
      * @return string
1900 1900
     */
1901
-	protected function _get_shortcode_selector( $field, $linked_input_id ) {
1901
+	protected function _get_shortcode_selector($field, $linked_input_id) {
1902 1902
 		$template_args = array(
1903
-			'shortcodes' => $this->_get_shortcodes( array( $field ), true ),
1903
+			'shortcodes' => $this->_get_shortcodes(array($field), true),
1904 1904
 			'fieldname' => $field,
1905 1905
 			'linked_input_id' => $linked_input_id
1906 1906
 		);
1907
-		return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true );
1907
+		return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true);
1908 1908
 	}
1909 1909
 
1910 1910
 
@@ -1919,13 +1919,13 @@  discard block
 block discarded – undo
1919 1919
 		$shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set
1920 1920
 		//$messenger = $this->_message_template_group->messenger_obj();
1921 1921
 		//now let's set the content depending on the status of the shortcodes array
1922
-		if ( empty( $shortcodes ) ) {
1923
-			$content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>';
1922
+		if (empty($shortcodes)) {
1923
+			$content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>';
1924 1924
 			echo $content;
1925 1925
 		} else {
1926 1926
 			//$alt = 0;
1927 1927
 			?>
1928
-			<div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf( __('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p>
1928
+			<div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf(__('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso'), '<span class="dashicons dashicons-menu"></span>'); ?></p>
1929 1929
 			<?php
1930 1930
 		}
1931 1931
 
@@ -1942,7 +1942,7 @@  discard block
 block discarded – undo
1942 1942
 	protected function _set_shortcodes() {
1943 1943
 
1944 1944
 		//no need to run this if the property is already set
1945
-		if ( !empty($this->_shortcodes ) ) {return;}
1945
+		if ( ! empty($this->_shortcodes)) {return; }
1946 1946
 
1947 1947
 		$this->_shortcodes = $this->_get_shortcodes();
1948 1948
 	}
@@ -1964,14 +1964,14 @@  discard block
 block discarded – undo
1964 1964
 	 * @return array          Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true
1965 1965
 	 *                       just an array of shortcode/label pairs.
1966 1966
 	 */
1967
-	protected function _get_shortcodes( $fields = array(), $merged = true ) {
1967
+	protected function _get_shortcodes($fields = array(), $merged = true) {
1968 1968
 		$this->_set_message_template_group();
1969 1969
 
1970 1970
 		//we need the messenger and message template to retrieve the valid shortcodes array.
1971
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false;
1972
-		$context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() );
1971
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false;
1972
+		$context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config());
1973 1973
 
1974
-		return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array();
1974
+		return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array();
1975 1975
 	}
1976 1976
 
1977 1977
 
@@ -1984,19 +1984,19 @@  discard block
 block discarded – undo
1984 1984
 	 */
1985 1985
 	protected function _set_message_template_group() {
1986 1986
 
1987
-		if ( !empty( $this->_message_template_group ) )
1988
-			{return;} //get out if this is already set.
1987
+		if ( ! empty($this->_message_template_group))
1988
+			{return; } //get out if this is already set.
1989 1989
 
1990
-		$GRP_ID =  ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false;
1991
-		$GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID;
1990
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false;
1991
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID;
1992 1992
 
1993 1993
 		//let's get the message templates
1994 1994
 		$MTP = EEM_Message_Template_Group::instance();
1995 1995
 
1996
-		if ( empty($GRP_ID) )
1997
-			{$this->_message_template_group = $MTP->create_default_object();}
1996
+		if (empty($GRP_ID))
1997
+			{$this->_message_template_group = $MTP->create_default_object(); }
1998 1998
 		else
1999
-			{$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );}
1999
+			{$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); }
2000 2000
 
2001 2001
 		$this->_template_pack = $this->_message_template_group->get_template_pack();
2002 2002
 		$this->_variation = $this->_message_template_group->get_template_pack_variation();
@@ -2015,7 +2015,7 @@  discard block
 block discarded – undo
2015 2015
 	 * @param array $args various things the context switcher needs.
2016 2016
 	 *
2017 2017
 	 */
2018
-	protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) {
2018
+	protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) {
2019 2019
 		$context_details = $template_group_object->contexts_config();
2020 2020
 		$context_label = $template_group_object->context_label();
2021 2021
 		ob_start();
@@ -2023,20 +2023,20 @@  discard block
 block discarded – undo
2023 2023
 		<div class="ee-msg-switcher-container">
2024 2024
 			<form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm">
2025 2025
 				<?php
2026
-					foreach ( $args as $name => $value ) {
2027
-						if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;}
2026
+					foreach ($args as $name => $value) {
2027
+						if ($name == 'context' || empty($value) || $name == 'extra') {continue; }
2028 2028
 						?>
2029 2029
 						<input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" />
2030 2030
 						<?php
2031 2031
 					}
2032 2032
 					//setup nonce_url
2033
-					wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
2033
+					wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false);
2034 2034
 				?>
2035 2035
 				<select name="context">
2036 2036
 					<?php
2037 2037
 					$context_templates = $template_group_object->context_templates();
2038
-					if ( is_array($context_templates) ) :
2039
-							foreach ( $context_templates as $context => $template_fields ) :
2038
+					if (is_array($context_templates)) :
2039
+							foreach ($context_templates as $context => $template_fields) :
2040 2040
 								$checked = ($context == $args['context']) ? 'selected="selected"' : '';
2041 2041
 					?>
2042 2042
 					<option value="<?php echo $context; ?>" <?php echo $checked; ?>>
@@ -2044,7 +2044,7 @@  discard block
 block discarded – undo
2044 2044
 					</option>
2045 2045
 					<?php endforeach; endif; ?>
2046 2046
 				</select>
2047
-				<?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?>
2047
+				<?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?>
2048 2048
 				<input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>">
2049 2049
 			</form>
2050 2050
 			<?php echo $args['extra']; ?>
@@ -2071,8 +2071,8 @@  discard block
 block discarded – undo
2071 2071
 	 * @return array
2072 2072
 	 */
2073 2073
 	protected function _set_message_template_column_values($index) {
2074
-		if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) {
2075
-			foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) {
2074
+		if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) {
2075
+			foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) {
2076 2076
 				$this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value;
2077 2077
 			}
2078 2078
 		} /*else {
@@ -2081,22 +2081,22 @@  discard block
 block discarded – undo
2081 2081
 
2082 2082
 
2083 2083
 		$set_column_values = array(
2084
-			'MTP_ID'             => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ),
2085
-			'GRP_ID'             => absint( $this->_req_data[ 'GRP_ID' ] ),
2086
-			'MTP_user_id'        => absint( $this->_req_data[ 'MTP_user_id' ] ),
2087
-			'MTP_messenger'      => strtolower( $this->_req_data[ 'MTP_messenger' ] ),
2088
-			'MTP_message_type'   => strtolower( $this->_req_data[ 'MTP_message_type' ] ),
2089
-			'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ),
2090
-			'MTP_context'        => strtolower( $this->_req_data[ 'MTP_context' ] ),
2091
-			'MTP_content'        => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ],
2092
-			'MTP_is_global'      => isset( $this->_req_data[ 'MTP_is_global' ] )
2093
-				? absint( $this->_req_data[ 'MTP_is_global' ] )
2084
+			'MTP_ID'             => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']),
2085
+			'GRP_ID'             => absint($this->_req_data['GRP_ID']),
2086
+			'MTP_user_id'        => absint($this->_req_data['MTP_user_id']),
2087
+			'MTP_messenger'      => strtolower($this->_req_data['MTP_messenger']),
2088
+			'MTP_message_type'   => strtolower($this->_req_data['MTP_message_type']),
2089
+			'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']),
2090
+			'MTP_context'        => strtolower($this->_req_data['MTP_context']),
2091
+			'MTP_content'        => $this->_req_data['MTP_template_fields'][$index]['content'],
2092
+			'MTP_is_global'      => isset($this->_req_data['MTP_is_global'])
2093
+				? absint($this->_req_data['MTP_is_global'])
2094 2094
 				: 0,
2095
-			'MTP_is_override'    => isset( $this->_req_data[ 'MTP_is_override' ] )
2096
-				? absint( $this->_req_data[ 'MTP_is_override' ] )
2095
+			'MTP_is_override'    => isset($this->_req_data['MTP_is_override'])
2096
+				? absint($this->_req_data['MTP_is_override'])
2097 2097
 				: 0,
2098
-			'MTP_deleted'        => absint( $this->_req_data[ 'MTP_deleted' ] ),
2099
-			'MTP_is_active'      => absint( $this->_req_data[ 'MTP_is_active' ] )
2098
+			'MTP_deleted'        => absint($this->_req_data['MTP_deleted']),
2099
+			'MTP_is_active'      => absint($this->_req_data['MTP_is_active'])
2100 2100
 		);
2101 2101
 
2102 2102
 
@@ -2108,36 +2108,36 @@  discard block
 block discarded – undo
2108 2108
 
2109 2109
 
2110 2110
 
2111
-	protected function _insert_or_update_message_template($new = false ) {
2111
+	protected function _insert_or_update_message_template($new = false) {
2112 2112
 
2113
-		do_action ( 'AHEE_log', __FILE__, __FUNCTION__, '');
2113
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2114 2114
 		$success = 0;
2115 2115
 		$override = false;
2116 2116
 
2117 2117
 		//setup notices description
2118
-		$messenger = ! empty( $this->_req_data['MTP_messenger'] )
2119
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_messenger'] ) )
2118
+		$messenger = ! empty($this->_req_data['MTP_messenger'])
2119
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger']))
2120 2120
 			: false;
2121 2121
 
2122
-		$message_type = ! empty( $this->_req_data['MTP_message_type'] )
2123
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_message_type'] ) )
2122
+		$message_type = ! empty($this->_req_data['MTP_message_type'])
2123
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type']))
2124 2124
 			: false;
2125 2125
 
2126
-		$context = ! empty( $this->_req_data['MTP_context'] )
2127
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_context'] ) )
2126
+		$context = ! empty($this->_req_data['MTP_context'])
2127
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context']))
2128 2128
 			: false;
2129 2129
 
2130
-		$item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : '';
2130
+		$item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : '';
2131 2131
 		$item_desc .= 'Message Template';
2132 2132
 		$query_args = array();
2133 2133
 		$edit_array = array();
2134 2134
 		$action_desc = '';
2135 2135
 
2136 2136
 		//if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit.
2137
-		if ( $new ) {
2138
-			$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
2139
-			if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) {
2140
-				if ( empty($edit_array) ) {
2137
+		if ($new) {
2138
+			$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
2139
+			if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) {
2140
+				if (empty($edit_array)) {
2141 2141
 					$success = 0;
2142 2142
 				} else {
2143 2143
 					$success = 1;
@@ -2156,7 +2156,7 @@  discard block
 block discarded – undo
2156 2156
 
2157 2157
 
2158 2158
 			//run update for each template field in displayed context
2159
-			if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) {
2159
+			if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) {
2160 2160
 				EE_Error::add_error(
2161 2161
 					__('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'),
2162 2162
 					__FILE__, __FUNCTION__, __LINE__
@@ -2165,25 +2165,25 @@  discard block
 block discarded – undo
2165 2165
 
2166 2166
 			} else {
2167 2167
 				//first validate all fields!
2168
-				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2168
+				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2169 2169
 
2170 2170
 				//if $validate returned error messages (i.e. is_array()) then we need to process them and setup an appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array.  WE need to make sure there is no actual error messages in validates.
2171
-				if ( is_array($validates) && !empty($validates) ) {
2171
+				if (is_array($validates) && ! empty($validates)) {
2172 2172
 					//add the transient so when the form loads we know which fields to highlight
2173
-					$this->_add_transient( 'edit_message_template', $validates );
2173
+					$this->_add_transient('edit_message_template', $validates);
2174 2174
 
2175 2175
 					$success = 0;
2176 2176
 
2177 2177
 					//setup notices
2178
-					foreach ( $validates as $field => $error ) {
2179
-						if ( isset($error['msg'] ) ) {
2180
-							EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );
2178
+					foreach ($validates as $field => $error) {
2179
+						if (isset($error['msg'])) {
2180
+							EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
2181 2181
 						}
2182 2182
 					}
2183 2183
 
2184 2184
 				} else {
2185 2185
 					$set_column_values = array();
2186
-					foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) {
2186
+					foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) {
2187 2187
 						$set_column_values = $this->_set_message_template_column_values($template_field);
2188 2188
 
2189 2189
 						$where_cols_n_values = array(
@@ -2196,11 +2196,11 @@  discard block
 block discarded – undo
2196 2196
 							'MTP_context' => $set_column_values['MTP_context'],
2197 2197
 							'MTP_content' => $set_column_values['MTP_content']
2198 2198
 						);
2199
-						if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) {
2200
-							if ( $updated === false ) {
2199
+						if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) {
2200
+							if ($updated === false) {
2201 2201
 								EE_Error::add_error(
2202 2202
 									sprintf(
2203
-										__( '%s field was NOT updated for some reason', 'event_espresso' ),
2203
+										__('%s field was NOT updated for some reason', 'event_espresso'),
2204 2204
 										$template_field
2205 2205
 									),
2206 2206
 									__FILE__, __FUNCTION__, __LINE__
@@ -2214,46 +2214,46 @@  discard block
 block discarded – undo
2214 2214
 
2215 2215
 					//we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs)
2216 2216
 					$mtpg_fields = array(
2217
-						'MTP_user_id'      => $set_column_values[ 'MTP_user_id' ],
2218
-						'MTP_messenger'    => $set_column_values[ 'MTP_messenger' ],
2219
-						'MTP_message_type' => $set_column_values[ 'MTP_message_type' ],
2220
-						'MTP_is_global'    => $set_column_values[ 'MTP_is_global' ],
2221
-						'MTP_is_override'  => $set_column_values[ 'MTP_is_override' ],
2222
-						'MTP_deleted'      => $set_column_values[ 'MTP_deleted' ],
2223
-						'MTP_is_active'    => $set_column_values[ 'MTP_is_active' ],
2224
-						'MTP_name'         => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] )
2225
-							? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ]
2217
+						'MTP_user_id'      => $set_column_values['MTP_user_id'],
2218
+						'MTP_messenger'    => $set_column_values['MTP_messenger'],
2219
+						'MTP_message_type' => $set_column_values['MTP_message_type'],
2220
+						'MTP_is_global'    => $set_column_values['MTP_is_global'],
2221
+						'MTP_is_override'  => $set_column_values['MTP_is_override'],
2222
+						'MTP_deleted'      => $set_column_values['MTP_deleted'],
2223
+						'MTP_is_active'    => $set_column_values['MTP_is_active'],
2224
+						'MTP_name'         => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name'])
2225
+							? $this->_req_data['ee_msg_non_global_fields']['MTP_name']
2226 2226
 							: '',
2227
-						'MTP_description'  => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] )
2228
-							? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ]
2227
+						'MTP_description'  => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description'])
2228
+							? $this->_req_data['ee_msg_non_global_fields']['MTP_description']
2229 2229
 							: ''
2230 2230
 					);
2231 2231
 
2232
-					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] );
2233
-					$updated = $MTPG->update( $mtpg_fields, array($mtpg_where) );
2232
+					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']);
2233
+					$updated = $MTPG->update($mtpg_fields, array($mtpg_where));
2234 2234
 
2235
-					if ( $updated === false ) {
2235
+					if ($updated === false) {
2236 2236
 						EE_Error::add_error(
2237 2237
 							sprintf(
2238
-								__( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ),
2239
-								$set_column_values[ 'GRP_ID' ]
2238
+								__('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'),
2239
+								$set_column_values['GRP_ID']
2240 2240
 							),
2241 2241
 							__FILE__, __FUNCTION__, __LINE__
2242 2242
 						);
2243 2243
 					} else {
2244 2244
 						//k now we need to ensure the template_pack and template_variation fields are set.
2245
-						$template_pack = ! empty( $this->_req_data['MTP_template_pack' ] )
2245
+						$template_pack = ! empty($this->_req_data['MTP_template_pack'])
2246 2246
 							? $this->_req_data['MTP_template_pack']
2247 2247
 							: 'default';
2248 2248
 
2249
-						$template_variation = ! empty( $this->_req_data['MTP_template_variation'] )
2249
+						$template_variation = ! empty($this->_req_data['MTP_template_variation'])
2250 2250
 							? $this->_req_data['MTP_template_variation']
2251 2251
 							: 'default';
2252 2252
 
2253
-						$mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] );
2254
-						if ( $mtpg_obj instanceof EE_Message_Template_Group ) {
2255
-							$mtpg_obj->set_template_pack_name( $template_pack );
2256
-							$mtpg_obj->set_template_pack_variation( $template_variation );
2253
+						$mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']);
2254
+						if ($mtpg_obj instanceof EE_Message_Template_Group) {
2255
+							$mtpg_obj->set_template_pack_name($template_pack);
2256
+							$mtpg_obj->set_template_pack_variation($template_variation);
2257 2257
 						}
2258 2258
 						$success = 1;
2259 2259
 					}
@@ -2263,7 +2263,7 @@  discard block
 block discarded – undo
2263 2263
 		}
2264 2264
 
2265 2265
 		//we return things differently if doing ajax
2266
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
2266
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2267 2267
 			$this->_template_args['success'] = $success;
2268 2268
 			$this->_template_args['error'] = ! $success ? true : false;
2269 2269
 			$this->_template_args['content'] = '';
@@ -2271,9 +2271,9 @@  discard block
 block discarded – undo
2271 2271
 				'grpID' => $edit_array['GRP_ID'],
2272 2272
 				'templateName' => $edit_array['template_name']
2273 2273
 				);
2274
-			if ( $success ) {
2274
+			if ($success) {
2275 2275
 				EE_Error::overwrite_success();
2276
-				EE_Error::add_success( __('The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.', 'event_espresso') );
2276
+				EE_Error::add_success(__('The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.', 'event_espresso'));
2277 2277
 			}
2278 2278
 
2279 2279
 			$this->_return_json();
@@ -2281,13 +2281,13 @@  discard block
 block discarded – undo
2281 2281
 
2282 2282
 
2283 2283
 		//was a test send triggered?
2284
-		if ( isset( $this->_req_data['test_button'] ) ) {
2284
+		if (isset($this->_req_data['test_button'])) {
2285 2285
 			EE_Error::overwrite_success();
2286
-			$this->_do_test_send( $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] );
2286
+			$this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2287 2287
 			$override = true;
2288 2288
 		}
2289 2289
 
2290
-		if ( empty( $query_args ) ) {
2290
+		if (empty($query_args)) {
2291 2291
 			$query_args = array(
2292 2292
 				'id' => $this->_req_data['GRP_ID'],
2293 2293
 				'context' => $this->_req_data['MTP_context'],
@@ -2295,7 +2295,7 @@  discard block
 block discarded – undo
2295 2295
 				);
2296 2296
 		}
2297 2297
 
2298
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override );
2298
+		$this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
2299 2299
 	}
2300 2300
 
2301 2301
 
@@ -2309,28 +2309,28 @@  discard block
 block discarded – undo
2309 2309
 	 * @param  string $message_type message type being tested
2310 2310
 	 *
2311 2311
 	 */
2312
-	protected function _do_test_send( $context, $messenger, $message_type ) {
2312
+	protected function _do_test_send($context, $messenger, $message_type) {
2313 2313
 		//set things up for preview
2314 2314
 		$this->_req_data['messenger'] = $messenger;
2315 2315
 		$this->_req_data['message_type'] = $message_type;
2316 2316
 		$this->_req_data['context'] = $context;
2317
-		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : '';
2318
-		$active_messenger = $this->_message_resource_manager->get_active_messenger( $messenger );
2317
+		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : '';
2318
+		$active_messenger = $this->_message_resource_manager->get_active_messenger($messenger);
2319 2319
 
2320 2320
 		//let's save any existing fields that might be required by the messenger
2321 2321
 		if (
2322
-			isset( $this->_req_data['test_settings_fld'] )
2322
+			isset($this->_req_data['test_settings_fld'])
2323 2323
 			&& $active_messenger instanceof EE_messenger
2324 2324
 		) {
2325
-			$active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] );
2325
+			$active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']);
2326 2326
 		}
2327 2327
 
2328 2328
 		$success = $this->_preview_message(true);
2329 2329
 
2330
-		if ( $success ) {
2331
-			EE_Error::add_success( __('Test message sent', 'event_espresso') );
2330
+		if ($success) {
2331
+			EE_Error::add_success(__('Test message sent', 'event_espresso'));
2332 2332
 		} else {
2333
-			EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
2333
+			EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2334 2334
 		}
2335 2335
 	}
2336 2336
 
@@ -2356,11 +2356,11 @@  discard block
 block discarded – undo
2356 2356
 	protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) {
2357 2357
 
2358 2358
 		//if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we just don't generate any templates.
2359
-		if ( empty( $message_types ) ) {
2359
+		if (empty($message_types)) {
2360 2360
 			return true;
2361 2361
 		}
2362 2362
 
2363
-		return EEH_MSG_Template::generate_new_templates( $messenger, $message_types, $GRP_ID, $global );
2363
+		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
2364 2364
 	}
2365 2365
 
2366 2366
 
@@ -2376,33 +2376,33 @@  discard block
 block discarded – undo
2376 2376
 	 *
2377 2377
 	 * @return void
2378 2378
 	 */
2379
-	protected function _trash_or_restore_message_template($trash = true, $all = false ) {
2380
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2379
+	protected function _trash_or_restore_message_template($trash = true, $all = false) {
2380
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2381 2381
 		$MTP = EEM_Message_Template_Group::instance();
2382 2382
 
2383 2383
 		$success = 1;
2384 2384
 
2385 2385
 		//incoming GRP_IDs
2386
-		if ( $all ) {
2386
+		if ($all) {
2387 2387
 			//Checkboxes
2388
-			if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) {
2388
+			if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2389 2389
 				//if array has more than one element then success message should be plural.
2390 2390
 				//todo: what about nonce?
2391
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2391
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2392 2392
 
2393 2393
 				//cycle through checkboxes
2394
-				while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) {
2395
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2396
-					if ( ! $trashed_or_restored ) {
2394
+				while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2395
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2396
+					if ( ! $trashed_or_restored) {
2397 2397
 						$success = 0;
2398 2398
 					}
2399 2399
 				}
2400 2400
 			} else {
2401 2401
 				//grab single GRP_ID and handle
2402
-				$GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0;
2403
-				if ( ! empty( $GRP_ID ) ) {
2404
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2405
-					if ( ! $trashed_or_restored ) {
2402
+				$GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
2403
+				if ( ! empty($GRP_ID)) {
2404
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2405
+					if ( ! $trashed_or_restored) {
2406 2406
 						$success = 0;
2407 2407
 					}
2408 2408
 				} else {
@@ -2414,13 +2414,13 @@  discard block
 block discarded – undo
2414 2414
 
2415 2415
 		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2416 2416
 
2417
-		$action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc;
2417
+		$action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc;
2418 2418
 
2419 2419
 		$item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
2420 2420
 
2421
-		$item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2421
+		$item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2422 2422
 
2423
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, array() );
2423
+		$this->_redirect_after_action($success, $item_desc, $action_desc, array());
2424 2424
 
2425 2425
 	}
2426 2426
 
@@ -2436,24 +2436,24 @@  discard block
 block discarded – undo
2436 2436
 	 * @return void
2437 2437
 	 */
2438 2438
 	protected function _delete_message_template() {
2439
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2439
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2440 2440
 
2441 2441
 		//checkboxes
2442
-		if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) {
2442
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2443 2443
 			//if array has more than one element then success message should be plural
2444
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2444
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2445 2445
 
2446 2446
 			//cycle through bulk action checkboxes
2447
-			while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) {
2448
-				$success = $this->_delete_mtp_permanently( $GRP_ID );
2447
+			while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2448
+				$success = $this->_delete_mtp_permanently($GRP_ID);
2449 2449
 			}
2450 2450
 		} else {
2451 2451
 			//grab single grp_id and delete
2452
-			$GRP_ID = absint($this->_req_data['id'] );
2453
-			$success = $this->_delete_mtp_permanently( $GRP_ID );
2452
+			$GRP_ID = absint($this->_req_data['id']);
2453
+			$success = $this->_delete_mtp_permanently($GRP_ID);
2454 2454
 		}
2455 2455
 
2456
-		$this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() );
2456
+		$this->_redirect_after_action($success, 'Message Templates', 'deleted', array());
2457 2457
 
2458 2458
 	}
2459 2459
 
@@ -2468,20 +2468,20 @@  discard block
 block discarded – undo
2468 2468
 	 *
2469 2469
 	 * @return bool        boolean to indicate the success of the deletes or not.
2470 2470
 	 */
2471
-	private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) {
2471
+	private function _delete_mtp_permanently($GRP_ID, $include_group = true) {
2472 2472
 		$success = 1;
2473 2473
 		$MTPG = EEM_Message_Template_Group::instance();
2474 2474
 		//first let's GET this group
2475
-		$MTG = $MTPG->get_one_by_ID( $GRP_ID );
2475
+		$MTG = $MTPG->get_one_by_ID($GRP_ID);
2476 2476
 		//then delete permanently all the related Message Templates
2477
-		$deleted = $MTG->delete_related_permanently( 'Message_Template' );
2477
+		$deleted = $MTG->delete_related_permanently('Message_Template');
2478 2478
 
2479
-		if ( $deleted === 0 )
2480
-			{$success = 0;}
2479
+		if ($deleted === 0)
2480
+			{$success = 0; }
2481 2481
 
2482 2482
 		//now delete permanently this particular group
2483 2483
 
2484
-		if ( $include_group && ! $MTG->delete_permanently() ) {
2484
+		if ($include_group && ! $MTG->delete_permanently()) {
2485 2485
 			$success = 0;
2486 2486
 		}
2487 2487
 		return $success;
@@ -2499,7 +2499,7 @@  discard block
 block discarded – undo
2499 2499
 	*	@return string
2500 2500
 	*/
2501 2501
 	protected function _learn_more_about_message_templates_link() {
2502
-		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>';
2502
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>';
2503 2503
 	}
2504 2504
 
2505 2505
 
@@ -2517,10 +2517,10 @@  discard block
 block discarded – undo
2517 2517
 
2518 2518
 		$this->_set_m_mt_settings();
2519 2519
 
2520
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2520
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2521 2521
 
2522 2522
 		//let's setup the messenger tabs
2523
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger );
2523
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger);
2524 2524
 		$this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
2525 2525
 		$this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->';
2526 2526
 
@@ -2539,7 +2539,7 @@  discard block
 block discarded – undo
2539 2539
 	 */
2540 2540
 	protected function _set_m_mt_settings() {
2541 2541
 		//first if this is already set then lets get out no need to regenerate data.
2542
-		if ( !empty($this->_m_mt_settings) ) {
2542
+		if ( ! empty($this->_m_mt_settings)) {
2543 2543
 			return;
2544 2544
 		}
2545 2545
 
@@ -2554,10 +2554,10 @@  discard block
 block discarded – undo
2554 2554
 
2555 2555
 		//assemble the array for the _tab_text_links helper
2556 2556
 
2557
-		foreach ( $messengers as $messenger ) {
2557
+		foreach ($messengers as $messenger) {
2558 2558
 			$this->_m_mt_settings['messenger_tabs'][$messenger->name] = array(
2559 2559
 				'label' => ucwords($messenger->label['singular']),
2560
-				'class' => $this->_message_resource_manager->is_messenger_active( $messenger->name ) ? 'messenger-active' : '',
2560
+				'class' => $this->_message_resource_manager->is_messenger_active($messenger->name) ? 'messenger-active' : '',
2561 2561
 				'href' => $messenger->name,
2562 2562
 				'title' => __('Modify this Messenger', 'event_espresso'),
2563 2563
 				'slug' => $messenger->name,
@@ -2567,26 +2567,26 @@  discard block
 block discarded – undo
2567 2567
 
2568 2568
 			$message_types_for_messenger = $messenger->get_valid_message_types();
2569 2569
 
2570
-			foreach ( $message_types as $message_type ) {
2570
+			foreach ($message_types as $message_type) {
2571 2571
 				//first we need to verify that this message type is valid with this messenger. Cause if it isn't then it shouldn't show in either the inactive OR active metabox.
2572
-				if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) {
2572
+				if ( ! in_array($message_type->name, $message_types_for_messenger)) {
2573 2573
 					continue;
2574 2574
 				}
2575 2575
 
2576
-				$a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) ? 'active' : 'inactive';
2576
+				$a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger($messenger->name, $message_type->name) ? 'active' : 'inactive';
2577 2577
 
2578 2578
 				$this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
2579
-					'label'    => ucwords( $message_type->label[ 'singular' ] ),
2580
-					'class'    => 'message-type-' . $a_or_i,
2581
-					'slug_id'  => $message_type->name . '-messagetype-' . $messenger->name,
2582
-					'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ),
2583
-					'href'     => 'espresso_' . $message_type->name . '_message_type_settings',
2579
+					'label'    => ucwords($message_type->label['singular']),
2580
+					'class'    => 'message-type-'.$a_or_i,
2581
+					'slug_id'  => $message_type->name.'-messagetype-'.$messenger->name,
2582
+					'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'),
2583
+					'href'     => 'espresso_'.$message_type->name.'_message_type_settings',
2584 2584
 					'title'    => $a_or_i == 'active'
2585
-						? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' )
2586
-						: __( 'Drag this message type to the messenger to activate', 'event_espresso' ),
2585
+						? __('Drag this message type to the Inactive window to deactivate', 'event_espresso')
2586
+						: __('Drag this message type to the messenger to activate', 'event_espresso'),
2587 2587
 					'content'  => $a_or_i == 'active'
2588
-						? $this->_message_type_settings_content( $message_type, $messenger, true )
2589
-						: $this->_message_type_settings_content( $message_type, $messenger ),
2588
+						? $this->_message_type_settings_content($message_type, $messenger, true)
2589
+						: $this->_message_type_settings_content($message_type, $messenger),
2590 2590
 					'slug'     => $message_type->name,
2591 2591
 					'active'   => $a_or_i == 'active' ? true : false,
2592 2592
 					'obj'      => $message_type
@@ -2605,34 +2605,34 @@  discard block
 block discarded – undo
2605 2605
 	 *
2606 2606
 	 * @return string                html output for the content
2607 2607
 	 */
2608
-	protected function _message_type_settings_content( $message_type, $messenger, $active = false ) {
2608
+	protected function _message_type_settings_content($message_type, $messenger, $active = false) {
2609 2609
 		//get message type fields
2610 2610
 		$fields = $message_type->get_admin_settings_fields();
2611
-		$settings_template_args['template_form_fields']= '';
2611
+		$settings_template_args['template_form_fields'] = '';
2612 2612
 
2613
-		if ( !empty( $fields ) && $active ) {
2613
+		if ( ! empty($fields) && $active) {
2614 2614
 
2615
-			$existing_settings = $message_type->get_existing_admin_settings( $messenger->name );
2615
+			$existing_settings = $message_type->get_existing_admin_settings($messenger->name);
2616 2616
 
2617
-			foreach( $fields as $fldname => $fldprops ) {
2618
-				$field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname;
2617
+			foreach ($fields as $fldname => $fldprops) {
2618
+				$field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname;
2619 2619
 				$template_form_field[$field_id] = array(
2620
-					'name' => 'message_type_settings[' . $fldname . ']',
2620
+					'name' => 'message_type_settings['.$fldname.']',
2621 2621
 					'label' => $fldprops['label'],
2622 2622
 					'input' => $fldprops['field_type'],
2623 2623
 					'type' => $fldprops['value_type'],
2624 2624
 					'required' => $fldprops['required'],
2625 2625
 					'validation' => $fldprops['validation'],
2626
-					'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2627
-					'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(),
2628
-					'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'],
2626
+					'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2627
+					'options' => isset($fldprops['options']) ? $fldprops['options'] : array(),
2628
+					'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2629 2629
 					'css_class' => 'no-drag',
2630 2630
 					'format' => $fldprops['format']
2631 2631
 				);
2632 2632
 			}
2633 2633
 
2634 2634
 
2635
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : '';
2635
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : '';
2636 2636
 		}
2637 2637
 
2638 2638
 		$settings_template_args['description'] = $message_type->description;
@@ -2652,13 +2652,13 @@  discard block
 block discarded – undo
2652 2652
 					)
2653 2653
 				);
2654 2654
 
2655
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2656
-		$settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : '';
2655
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2656
+		$settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : '';
2657 2657
 
2658 2658
 
2659 2659
 
2660
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
2661
-		$content = EEH_Template::display_template( $template, $settings_template_args, true );
2660
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php';
2661
+		$content = EEH_Template::display_template($template, $settings_template_args, true);
2662 2662
 		return $content;
2663 2663
 	}
2664 2664
 
@@ -2675,27 +2675,27 @@  discard block
 block discarded – undo
2675 2675
 		$m_boxes = $mt_boxes = array();
2676 2676
 		$m_template_args = $mt_template_args = array();
2677 2677
 
2678
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2678
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2679 2679
 
2680
-		if ( isset( $this->_m_mt_settings[ 'messenger_tabs' ] ) ) {
2681
-			foreach ( $this->_m_mt_settings[ 'messenger_tabs' ] as $messenger => $tab_array ) {
2682
-				$hide_on_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? '' : 'hidden';
2683
-				$hide_off_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? 'hidden' : '';
2680
+		if (isset($this->_m_mt_settings['messenger_tabs'])) {
2681
+			foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
2682
+				$hide_on_message = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden';
2683
+				$hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : '';
2684 2684
 				//messenger meta boxes
2685 2685
 				$active = $selected_messenger == $messenger ? true : false;
2686
-				$active_mt_tabs = isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] )
2687
-				? $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ]
2686
+				$active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active'])
2687
+				? $this->_m_mt_settings['message_type_tabs'][$messenger]['active']
2688 2688
 				: '';
2689
-				$m_boxes[ $messenger . '_a_box' ] = sprintf(
2690
-				__( '%s Settings', 'event_espresso' ),
2691
-				$tab_array[ 'label' ]
2689
+				$m_boxes[$messenger.'_a_box'] = sprintf(
2690
+				__('%s Settings', 'event_espresso'),
2691
+				$tab_array['label']
2692 2692
 				);
2693
-				$m_template_args[ $messenger . '_a_box' ] = array(
2694
-				'active_message_types'   => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2695
-				'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2696
-				? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2693
+				$m_template_args[$messenger.'_a_box'] = array(
2694
+				'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2695
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2696
+				? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2697 2697
 				: '',
2698
-				'content'                => $this->_get_messenger_box_content( $tab_array[ 'obj' ] ),
2698
+				'content'                => $this->_get_messenger_box_content($tab_array['obj']),
2699 2699
 				'hidden'                 => $active ? '' : ' hidden',
2700 2700
 				'hide_on_message'        => $hide_on_message,
2701 2701
 				'messenger'              => $messenger,
@@ -2704,11 +2704,11 @@  discard block
 block discarded – undo
2704 2704
 				// message type meta boxes
2705 2705
 				// (which is really just the inactive container for each messenger
2706 2706
 				// showing inactive message types for that messenger)
2707
-				$mt_boxes[ $messenger . '_i_box' ] = __( 'Inactive Message Types', 'event_espresso' );
2708
-				$mt_template_args[ $messenger . '_i_box' ] = array(
2709
-				'active_message_types'   => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2710
-				'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2711
-				? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2707
+				$mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso');
2708
+				$mt_template_args[$messenger.'_i_box'] = array(
2709
+				'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2710
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2711
+				? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2712 2712
 				: '',
2713 2713
 				'hidden'                 => $active ? '' : ' hidden',
2714 2714
 				'hide_on_message'        => $hide_on_message,
@@ -2721,12 +2721,12 @@  discard block
 block discarded – undo
2721 2721
 
2722 2722
 
2723 2723
 		//register messenger metaboxes
2724
-		$m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
2725
-		foreach ( $m_boxes as $box => $label ) {
2726
-			$callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] );
2727
-			$msgr = str_replace( '_a_box', '', $box );
2724
+		$m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php';
2725
+		foreach ($m_boxes as $box => $label) {
2726
+			$callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
2727
+			$msgr = str_replace('_a_box', '', $box);
2728 2728
 			add_meta_box(
2729
-				'espresso_' . $msgr . '_settings',
2729
+				'espresso_'.$msgr.'_settings',
2730 2730
 				$label,
2731 2731
 				create_function(
2732 2732
 					'$post, $metabox',
@@ -2740,14 +2740,14 @@  discard block
 block discarded – undo
2740 2740
 		}
2741 2741
 
2742 2742
 		//register message type metaboxes
2743
-		$mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
2744
-		foreach ( $mt_boxes as $box => $label ) {
2743
+		$mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php';
2744
+		foreach ($mt_boxes as $box => $label) {
2745 2745
 			$callback_args = array(
2746
-				'template_path' => $mt_template_path, 'template_args' => $mt_template_args[ $box ]
2746
+				'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]
2747 2747
 			);
2748
-			$mt = str_replace( '_i_box', '', $box );
2748
+			$mt = str_replace('_i_box', '', $box);
2749 2749
 			add_meta_box(
2750
-				'espresso_' . $mt . '_inactive_mts',
2750
+				'espresso_'.$mt.'_inactive_mts',
2751 2751
 				$label,
2752 2752
 				create_function(
2753 2753
 					'$post, $metabox',
@@ -2770,13 +2770,13 @@  discard block
 block discarded – undo
2770 2770
 	 *
2771 2771
 	 * @return string            html formatted tabs
2772 2772
 	 */
2773
-	protected function _get_mt_tabs( $tab_array ) {
2773
+	protected function _get_mt_tabs($tab_array) {
2774 2774
 		$tab_array = (array) $tab_array;
2775
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
2775
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php';
2776 2776
 		$tabs = '';
2777 2777
 
2778
-		foreach ( $tab_array as $tab ) {
2779
-			$tabs .=  EEH_Template::display_template( $template, $tab, true );
2778
+		foreach ($tab_array as $tab) {
2779
+			$tabs .= EEH_Template::display_template($template, $tab, true);
2780 2780
 		}
2781 2781
 
2782 2782
 		return $tabs;
@@ -2792,29 +2792,29 @@  discard block
 block discarded – undo
2792 2792
 	 *
2793 2793
 	 * @return string            html formatted content
2794 2794
 	 */
2795
-	protected function _get_messenger_box_content( EE_messenger $messenger ) {
2795
+	protected function _get_messenger_box_content(EE_messenger $messenger) {
2796 2796
 
2797 2797
 		$fields = $messenger->get_admin_settings_fields();
2798 2798
 		$settings_template_args['template_form_fields'] = '';
2799 2799
 
2800 2800
 		//is $messenger active?
2801
-		$settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active( $messenger->name );
2801
+		$settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name);
2802 2802
 
2803 2803
 
2804
-		if ( ! empty( $fields ) ) {
2804
+		if ( ! empty($fields)) {
2805 2805
 
2806 2806
 			$existing_settings = $messenger->get_existing_admin_settings();
2807 2807
 
2808
-			foreach( $fields as $fldname => $fldprops ) {
2809
-				$field_id = $messenger->name . '-' . $fldname;
2808
+			foreach ($fields as $fldname => $fldprops) {
2809
+				$field_id = $messenger->name.'-'.$fldname;
2810 2810
 				$template_form_field[$field_id] = array(
2811
-					'name' => 'messenger_settings[' . $field_id . ']',
2811
+					'name' => 'messenger_settings['.$field_id.']',
2812 2812
 					'label' => $fldprops['label'],
2813 2813
 					'input' => $fldprops['field_type'],
2814 2814
 					'type' => $fldprops['value_type'],
2815 2815
 					'required' => $fldprops['required'],
2816 2816
 					'validation' => $fldprops['validation'],
2817
-					'value' => isset( $existing_settings[$field_id])
2817
+					'value' => isset($existing_settings[$field_id])
2818 2818
 						? $existing_settings[$field_id]
2819 2819
 						: $fldprops['default'],
2820 2820
 					'css_class' => '',
@@ -2823,8 +2823,8 @@  discard block
 block discarded – undo
2823 2823
 			}
2824 2824
 
2825 2825
 
2826
-			$settings_template_args['template_form_fields'] = !empty($template_form_field)
2827
-				? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' )
2826
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field)
2827
+				? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form')
2828 2828
 				: '';
2829 2829
 		}
2830 2830
 
@@ -2841,39 +2841,39 @@  discard block
 block discarded – undo
2841 2841
 			);
2842 2842
 
2843 2843
 		//make sure any active message types that are existing are included in the hidden fields
2844
-		if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) {
2845
-			foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) {
2844
+		if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
2845
+			foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
2846 2846
 				$settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array(
2847 2847
 						'type' => 'hidden',
2848 2848
 						'value' => $mt
2849 2849
 					);
2850 2850
 			}
2851 2851
 		}
2852
-		$settings_template_args[ 'hidden_fields' ] = $this->_generate_admin_form_fields(
2853
-			$settings_template_args[ 'hidden_fields' ],
2852
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
2853
+			$settings_template_args['hidden_fields'],
2854 2854
 			'array'
2855 2855
 		);
2856
-		$active = $this->_message_resource_manager->is_messenger_active( $messenger->name );
2856
+		$active = $this->_message_resource_manager->is_messenger_active($messenger->name);
2857 2857
 
2858 2858
 		$settings_template_args['messenger'] = $messenger->name;
2859 2859
 		$settings_template_args['description'] = $messenger->description;
2860 2860
 		$settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
2861 2861
 
2862 2862
 
2863
-		$settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active( $messenger->name )
2863
+		$settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active($messenger->name)
2864 2864
 			? $settings_template_args['show_hide_edit_form']
2865 2865
 			: ' hidden';
2866 2866
 
2867
-		$settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] )
2867
+		$settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields'])
2868 2868
 			? ' hidden'
2869 2869
 			: $settings_template_args['show_hide_edit_form'];
2870 2870
 
2871 2871
 
2872 2872
 		$settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
2873
-		$settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
2873
+		$settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce');
2874 2874
 		$settings_template_args['on_off_status'] = $active ? true : false;
2875
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
2876
-		$content = EEH_Template::display_template( $template, $settings_template_args, true);
2875
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php';
2876
+		$content = EEH_Template::display_template($template, $settings_template_args, true);
2877 2877
 		return $content;
2878 2878
 	}
2879 2879
 
@@ -2887,9 +2887,9 @@  discard block
 block discarded – undo
2887 2887
 		$success = true;
2888 2888
 		$this->_prep_default_response_for_messenger_or_message_type_toggle();
2889 2889
 		//let's check that we have required data
2890
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
2890
+		if ( ! isset($this->_req_data['messenger'])) {
2891 2891
 			EE_Error::add_error(
2892
-				__( 'Messenger name needed to toggle activation. None given', 'event_espresso' ),
2892
+				__('Messenger name needed to toggle activation. None given', 'event_espresso'),
2893 2893
 				__FILE__,
2894 2894
 				__FUNCTION__,
2895 2895
 				__LINE__
@@ -2898,14 +2898,14 @@  discard block
 block discarded – undo
2898 2898
 		}
2899 2899
 
2900 2900
 		//do a nonce check here since we're not arriving via a normal route
2901
-		$nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : '';
2902
-		$nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
2901
+		$nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : '';
2902
+		$nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce';
2903 2903
 
2904
-		$this->_verify_nonce( $nonce, $nonce_ref );
2904
+		$this->_verify_nonce($nonce, $nonce_ref);
2905 2905
 
2906 2906
 
2907 2907
 
2908
-		if ( !isset( $this->_req_data[ 'status' ])) {
2908
+		if ( ! isset($this->_req_data['status'])) {
2909 2909
 			EE_Error::add_error(
2910 2910
 				__(
2911 2911
 					'Messenger status needed to know whether activation or deactivation is happening. No status is given',
@@ -2921,11 +2921,11 @@  discard block
 block discarded – undo
2921 2921
 		//do check to verify we have a valid status.
2922 2922
 		$status = $this->_req_data['status'];
2923 2923
 
2924
-		if ( $status != 'off' && $status != 'on' ) {
2924
+		if ($status != 'off' && $status != 'on') {
2925 2925
 			EE_Error::add_error(
2926 2926
 				sprintf(
2927
-					__( 'The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso' ),
2928
-					$this->_req_data[ 'status' ]
2927
+					__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
2928
+					$this->_req_data['status']
2929 2929
 				),
2930 2930
 				__FILE__,
2931 2931
 				__FUNCTION__,
@@ -2934,11 +2934,11 @@  discard block
 block discarded – undo
2934 2934
 			$success = false;
2935 2935
 		}
2936 2936
 
2937
-		if ( $success ) {
2937
+		if ($success) {
2938 2938
 			//made it here?  Stop dawdling then!!
2939 2939
 			$success = $status == 'off'
2940
-				? $this->_deactivate_messenger( $this->_req_data['messenger'] )
2941
-				: $this->_activate_messenger( $this->_req_data['messenger'] );
2940
+				? $this->_deactivate_messenger($this->_req_data['messenger'])
2941
+				: $this->_activate_messenger($this->_req_data['messenger']);
2942 2942
 		}
2943 2943
 
2944 2944
 		$this->_template_args['success'] = $success;
@@ -2961,7 +2961,7 @@  discard block
 block discarded – undo
2961 2961
 		$this->_prep_default_response_for_messenger_or_message_type_toggle();
2962 2962
 
2963 2963
 		//let's make sure we have the necessary data
2964
-		if ( ! isset( $this->_req_data[ 'message_type' ] ) ) {
2964
+		if ( ! isset($this->_req_data['message_type'])) {
2965 2965
 			EE_Error::add_error(
2966 2966
 				__('Message Type name needed to toggle activation. None given', 'event_espresso'),
2967 2967
 				__FILE__, __FUNCTION__, __LINE__
@@ -2969,7 +2969,7 @@  discard block
 block discarded – undo
2969 2969
 			$success = false;
2970 2970
 		}
2971 2971
 
2972
-		if ( ! isset( $this->_req_data[ 'messenger' ] ) ) {
2972
+		if ( ! isset($this->_req_data['messenger'])) {
2973 2973
 			EE_Error::add_error(
2974 2974
 				__('Messenger name needed to toggle activation. None given', 'event_espresso'),
2975 2975
 				__FILE__, __FUNCTION__, __LINE__
@@ -2977,7 +2977,7 @@  discard block
 block discarded – undo
2977 2977
 			$success = false;
2978 2978
 		}
2979 2979
 
2980
-		if ( ! isset( $this->_req_data[ 'status' ])) {
2980
+		if ( ! isset($this->_req_data['status'])) {
2981 2981
 			EE_Error::add_error(
2982 2982
 				__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'),
2983 2983
 				__FILE__, __FUNCTION__, __LINE__
@@ -2989,7 +2989,7 @@  discard block
 block discarded – undo
2989 2989
 		//do check to verify we have a valid status.
2990 2990
 		$status = $this->_req_data['status'];
2991 2991
 
2992
-		if ( $status != 'activate' && $status != 'deactivate' ) {
2992
+		if ($status != 'activate' && $status != 'deactivate') {
2993 2993
 			EE_Error::add_error(
2994 2994
 				sprintf(
2995 2995
 					__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'),
@@ -3002,16 +3002,16 @@  discard block
 block discarded – undo
3002 3002
 
3003 3003
 
3004 3004
 		//do a nonce check here since we're not arriving via a normal route
3005
-		$nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : '';
3006
-		$nonce_ref = $this->_req_data['message_type'] . '_nonce';
3005
+		$nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
3006
+		$nonce_ref = $this->_req_data['message_type'].'_nonce';
3007 3007
 
3008
-		$this->_verify_nonce( $nonce, $nonce_ref );
3008
+		$this->_verify_nonce($nonce, $nonce_ref);
3009 3009
 
3010
-		if ( $success ) {
3010
+		if ($success) {
3011 3011
 			//made it here? um, what are you waiting for then?
3012 3012
 			$success = $status == 'deactivate'
3013
-				? $this->_deactivate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] )
3014
-				: $this->_activate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] );
3013
+				? $this->_deactivate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type'])
3014
+				: $this->_activate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']);
3015 3015
 		}
3016 3016
 
3017 3017
 		$this->_template_args['success'] = $success;
@@ -3025,30 +3025,30 @@  discard block
 block discarded – undo
3025 3025
 	 * @param string $messenger_name The name of the messenger being activated
3026 3026
 	 * @return bool
3027 3027
 	 */
3028
-	protected function _activate_messenger( $messenger_name ) {
3028
+	protected function _activate_messenger($messenger_name) {
3029 3029
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3030
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3030
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3031 3031
 		$message_types_to_activate = $active_messenger instanceof EE_Messenger ? $active_messenger->get_default_message_types() : array();
3032 3032
 
3033 3033
 		//ensure is active
3034
-		$this->_message_resource_manager->activate_messenger( $messenger_name, $message_types_to_activate );
3034
+		$this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate);
3035 3035
 
3036 3036
 		//set response_data for reload
3037
-		foreach( $message_types_to_activate as $message_type_name ) {
3037
+		foreach ($message_types_to_activate as $message_type_name) {
3038 3038
 			/** @var EE_message_type $message_type */
3039
-			$message_type = $this->_message_resource_manager->get_message_type( $message_type_name );
3040
-			if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name )
3039
+			$message_type = $this->_message_resource_manager->get_message_type($message_type_name);
3040
+			if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)
3041 3041
 			     && $message_type instanceof EE_message_type
3042 3042
 			) {
3043 3043
 				$this->_template_args['data']['active_mts'][] = $message_type_name;
3044
-				if ( $message_type->get_admin_settings_fields() ) {
3044
+				if ($message_type->get_admin_settings_fields()) {
3045 3045
 					$this->_template_args['data']['mt_reload'][] = $message_type_name;
3046 3046
 				}
3047 3047
 			}
3048 3048
 		}
3049 3049
 
3050 3050
 		//add success message for activating messenger
3051
-		return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger );
3051
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger);
3052 3052
 
3053 3053
 	}
3054 3054
 
@@ -3059,11 +3059,11 @@  discard block
 block discarded – undo
3059 3059
 	 * @param string $messenger_name The name of the messenger being activated
3060 3060
 	 * @return bool
3061 3061
 	 */
3062
-	protected function _deactivate_messenger( $messenger_name ) {
3062
+	protected function _deactivate_messenger($messenger_name) {
3063 3063
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3064
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3065
-		$this->_message_resource_manager->deactivate_messenger( $messenger_name );
3066
-		return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger );
3064
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3065
+		$this->_message_resource_manager->deactivate_messenger($messenger_name);
3066
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger);
3067 3067
 	}
3068 3068
 
3069 3069
 
@@ -3074,23 +3074,23 @@  discard block
 block discarded – undo
3074 3074
 	 * @param string $message_type_name  The name of the message type being activated for the messenger
3075 3075
 	 * @return bool
3076 3076
 	 */
3077
-	protected function _activate_message_type_for_messenger( $messenger_name, $message_type_name ) {
3077
+	protected function _activate_message_type_for_messenger($messenger_name, $message_type_name) {
3078 3078
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3079
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3079
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3080 3080
 		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/
3081
-		$message_type_to_activate = $this->_message_resource_manager->get_message_type( $message_type_name );
3081
+		$message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name);
3082 3082
 
3083 3083
 		//ensure is active
3084
-		$this->_message_resource_manager->activate_messenger( $messenger_name, $message_type_name );
3084
+		$this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name);
3085 3085
 
3086 3086
 		//set response for load
3087
-		if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) {
3087
+		if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)) {
3088 3088
 			$this->_template_args['data']['active_mts'][] = $message_type_name;
3089
-			if ( $message_type_to_activate->get_admin_settings_fields() ) {
3089
+			if ($message_type_to_activate->get_admin_settings_fields()) {
3090 3090
 				$this->_template_args['data']['mt_reload'][] = $message_type_name;
3091 3091
 			}
3092 3092
 		}
3093
-		return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger, $message_type_to_activate );
3093
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger, $message_type_to_activate);
3094 3094
 	}
3095 3095
 
3096 3096
 
@@ -3102,13 +3102,13 @@  discard block
 block discarded – undo
3102 3102
 	 * @param string $message_type_name  The name of the message type being deactivated for the messenger
3103 3103
 	 * @return bool
3104 3104
 	 */
3105
-	protected function _deactivate_message_type_for_messenger( $messenger_name, $message_type_name ) {
3105
+	protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name) {
3106 3106
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3107
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3107
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3108 3108
 		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/
3109
-		$message_type_to_deactivate = $this->_message_resource_manager->get_message_type( $message_type_name );
3110
-		$this->_message_resource_manager->deactivate_message_type_for_messenger( $message_type_name, $messenger_name );
3111
-		return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger, $message_type_to_deactivate );
3109
+		$message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name);
3110
+		$this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name);
3111
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger, $message_type_to_deactivate);
3112 3112
 	}
3113 3113
 
3114 3114
 
@@ -3139,9 +3139,9 @@  discard block
 block discarded – undo
3139 3139
 		EE_Message_Type $message_type = null
3140 3140
 	) {
3141 3141
 		//if $messenger isn't a valid messenger object then get out.
3142
-		if ( ! $messenger instanceof EE_Messenger ) {
3142
+		if ( ! $messenger instanceof EE_Messenger) {
3143 3143
 			EE_Error::add_error(
3144
-				__( 'The messenger being activated is not a valid messenger', 'event_espresso' ),
3144
+				__('The messenger being activated is not a valid messenger', 'event_espresso'),
3145 3145
 				__FILE__,
3146 3146
 				__FUNCTION__,
3147 3147
 				__LINE__
@@ -3149,32 +3149,32 @@  discard block
 block discarded – undo
3149 3149
 			return false;
3150 3150
 		}
3151 3151
 		//activated
3152
-		if ( $this->_template_args['data']['active_mts'] ) {
3152
+		if ($this->_template_args['data']['active_mts']) {
3153 3153
 			EE_Error::overwrite_success();
3154 3154
 			//activated a message type with the messenger
3155
-			if ( $message_type instanceof EE_message_type ) {
3155
+			if ($message_type instanceof EE_message_type) {
3156 3156
 				EE_Error::add_success(
3157 3157
 					sprintf(
3158 3158
 						__('%s message type has been successfully activated with the %s messenger', 'event_espresso'),
3159
-						ucwords( $message_type->label['singular'] ),
3160
-						ucwords( $messenger->label['singular'] )
3159
+						ucwords($message_type->label['singular']),
3160
+						ucwords($messenger->label['singular'])
3161 3161
 					)
3162 3162
 				);
3163 3163
 
3164 3164
 				//if message type was invoice then let's make sure we activate the invoice payment method.
3165
-				if ( $message_type->name == 'invoice' ) {
3166
-					EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
3167
-					$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
3168
-					if ( $pm instanceof EE_Payment_Method ) {
3169
-						EE_Error::add_attention( __('Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso' ) );
3165
+				if ($message_type->name == 'invoice') {
3166
+					EE_Registry::instance()->load_lib('Payment_Method_Manager');
3167
+					$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
3168
+					if ($pm instanceof EE_Payment_Method) {
3169
+						EE_Error::add_attention(__('Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso'));
3170 3170
 					}
3171 3171
 				}
3172 3172
 			//just toggles the entire messenger
3173 3173
 			} else {
3174 3174
 				EE_Error::add_success(
3175 3175
 					sprintf(
3176
-						__( '%s messenger has been successfully activated', 'event_espresso' ),
3177
-						ucwords( $messenger->label[ 'singular' ] )
3176
+						__('%s messenger has been successfully activated', 'event_espresso'),
3177
+						ucwords($messenger->label['singular'])
3178 3178
 					)
3179 3179
 				);
3180 3180
 			}
@@ -3184,12 +3184,12 @@  discard block
 block discarded – undo
3184 3184
 		//message types after the activation process.  However its possible some messengers don't HAVE any default_message_types
3185 3185
 		//in which case we just give a success message for the messenger being successfully activated.
3186 3186
 		} else {
3187
-			if ( ! $messenger->get_default_message_types() ) {
3187
+			if ( ! $messenger->get_default_message_types()) {
3188 3188
 				//messenger doesn't have any default message types so still a success.
3189 3189
 				EE_Error::add_success(
3190 3190
 					sprintf(
3191
-						__('%s messenger was successfully activated.', 'event_espresso' ),
3192
-						ucwords( $messenger->label['singular'] )
3191
+						__('%s messenger was successfully activated.', 'event_espresso'),
3192
+						ucwords($messenger->label['singular'])
3193 3193
 						)
3194 3194
 				);
3195 3195
 				return true;
@@ -3197,13 +3197,13 @@  discard block
 block discarded – undo
3197 3197
 				EE_Error::add_error(
3198 3198
 					$message_type instanceof EE_message_type
3199 3199
 						? sprintf(
3200
-						__( '%s message type was not successfully activated with the %s messenger', 'event_espresso' ),
3201
-						ucwords( $message_type->label['singular'] ),
3202
-						ucwords( $messenger->label['singular'] )
3200
+						__('%s message type was not successfully activated with the %s messenger', 'event_espresso'),
3201
+						ucwords($message_type->label['singular']),
3202
+						ucwords($messenger->label['singular'])
3203 3203
 					)
3204 3204
 						: sprintf(
3205
-						__( '%s messenger was not successfully activated', 'event_espresso' ),
3206
-						ucwords( $messenger->label['singular'] )
3205
+						__('%s messenger was not successfully activated', 'event_espresso'),
3206
+						ucwords($messenger->label['singular'])
3207 3207
 					),
3208 3208
 					__FILE__,
3209 3209
 					__FUNCTION__,
@@ -3231,9 +3231,9 @@  discard block
 block discarded – undo
3231 3231
 		EE_Error::overwrite_success();
3232 3232
 
3233 3233
 		//if $messenger isn't a valid messenger object then get out.
3234
-		if ( ! $messenger instanceof EE_Messenger ) {
3234
+		if ( ! $messenger instanceof EE_Messenger) {
3235 3235
 			EE_Error::add_error(
3236
-				__( 'The messenger being deactivated is not a valid messenger', 'event_espresso' ),
3236
+				__('The messenger being deactivated is not a valid messenger', 'event_espresso'),
3237 3237
 				__FILE__,
3238 3238
 				__FUNCTION__,
3239 3239
 				__LINE__
@@ -3241,13 +3241,13 @@  discard block
 block discarded – undo
3241 3241
 			return false;
3242 3242
 		}
3243 3243
 
3244
-		if ( $message_type instanceof EE_message_type ) {
3244
+		if ($message_type instanceof EE_message_type) {
3245 3245
 			$message_type_name = $message_type->name;
3246 3246
 			EE_Error::add_success(
3247 3247
 				sprintf(
3248 3248
 					__('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'),
3249
-					ucwords( $message_type->label['singular'] ),
3250
-					ucwords ( $messenger->label['singular'] )
3249
+					ucwords($message_type->label['singular']),
3250
+					ucwords($messenger->label['singular'])
3251 3251
 				)
3252 3252
 			);
3253 3253
 		} else {
@@ -3255,20 +3255,20 @@  discard block
 block discarded – undo
3255 3255
 			EE_Error::add_success(
3256 3256
 				sprintf(
3257 3257
 					__('%s messenger has been successfully deactivated.', 'event_espresso'),
3258
-					ucwords( $messenger->label['singular'] )
3258
+					ucwords($messenger->label['singular'])
3259 3259
 				)
3260 3260
 			);
3261 3261
 		}
3262 3262
 
3263 3263
 		//if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
3264
-		if ( $messenger->name == 'html'  || $message_type_name == 'invoice') {
3265
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
3266
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' );
3267
-			if ( $count_updated > 0 ) {
3264
+		if ($messenger->name == 'html' || $message_type_name == 'invoice') {
3265
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
3266
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
3267
+			if ($count_updated > 0) {
3268 3268
 				$msg = $message_type_name == 'invoice'
3269
-					? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' )
3270
-					: __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' );
3271
-				EE_Error::add_attention( $msg );
3269
+					? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso')
3270
+					: __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso');
3271
+				EE_Error::add_attention($msg);
3272 3272
 			}
3273 3273
 		}
3274 3274
 		return true;
@@ -3279,17 +3279,17 @@  discard block
 block discarded – undo
3279 3279
 	 * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax)
3280 3280
 	 */
3281 3281
 	public function update_mt_form() {
3282
-		if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) {
3283
-			EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ );
3282
+		if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) {
3283
+			EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__);
3284 3284
 			$this->_return_json();
3285 3285
 		}
3286 3286
 
3287 3287
 		$message_types = $this->get_installed_message_types();
3288 3288
 
3289
-		$message_type = $message_types[ $this->_req_data['message_type'] ];
3290
-		$messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
3289
+		$message_type = $message_types[$this->_req_data['message_type']];
3290
+		$messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
3291 3291
 
3292
-		$content = $this->_message_type_settings_content ( $message_type, $messenger, true );
3292
+		$content = $this->_message_type_settings_content($message_type, $messenger, true);
3293 3293
 		$this->_template_args['success'] = true;
3294 3294
 		$this->_template_args['content'] = $content;
3295 3295
 		$this->_return_json();
@@ -3303,45 +3303,45 @@  discard block
 block discarded – undo
3303 3303
 	 *
3304 3304
 	 */
3305 3305
 	public function save_settings() {
3306
-		if ( !isset( $this->_req_data['type'] ) ) {
3307
-			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
3306
+		if ( ! isset($this->_req_data['type'])) {
3307
+			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
3308 3308
 			$this->_template_args['error'] = true;
3309 3309
 			$this->_return_json();
3310 3310
 		}
3311 3311
 
3312 3312
 
3313
-		if ( $this->_req_data['type'] == 'messenger' ) {
3313
+		if ($this->_req_data['type'] == 'messenger') {
3314 3314
 			$settings = $this->_req_data['messenger_settings']; //this should be an array.
3315 3315
 			$messenger = $settings['messenger'];
3316 3316
 			//let's setup the settings data
3317
-			foreach ( $settings as $key => $value ) {
3318
-				switch ( $key ) {
3317
+			foreach ($settings as $key => $value) {
3318
+				switch ($key) {
3319 3319
 					case 'messenger' :
3320
-						unset( $settings['messenger'] );
3320
+						unset($settings['messenger']);
3321 3321
 						break;
3322 3322
 					case 'message_types' :
3323
-						unset( $settings['message_types'] );
3323
+						unset($settings['message_types']);
3324 3324
 						break;
3325 3325
 					default :
3326 3326
 						$settings[$key] = $value;
3327 3327
 						break;
3328 3328
 				}
3329 3329
 			}
3330
-			$this->_message_resource_manager->add_settings_for_messenger( $messenger, $settings );
3330
+			$this->_message_resource_manager->add_settings_for_messenger($messenger, $settings);
3331 3331
 		}
3332 3332
 
3333
-		else if ( $this->_req_data['type'] == 'message_type' ) {
3333
+		else if ($this->_req_data['type'] == 'message_type') {
3334 3334
 			$settings = $this->_req_data['message_type_settings'];
3335 3335
 			$messenger = $settings['messenger'];
3336 3336
 			$message_type = $settings['message_type'];
3337 3337
 
3338
-			foreach ( $settings as $key => $value ) {
3339
-				switch ( $key ) {
3338
+			foreach ($settings as $key => $value) {
3339
+				switch ($key) {
3340 3340
 					case 'messenger' :
3341
-						unset( $settings['messenger'] );
3341
+						unset($settings['messenger']);
3342 3342
 						break;
3343 3343
 					case 'message_type' :
3344
-						unset( $settings['message_type'] );
3344
+						unset($settings['message_type']);
3345 3345
 						break;
3346 3346
 					default :
3347 3347
 						$settings[$key] = $value;
@@ -3349,16 +3349,16 @@  discard block
 block discarded – undo
3349 3349
 				}
3350 3350
 			}
3351 3351
 
3352
-			$this->_message_resource_manager->add_settings_for_message_type( $messenger, $message_type, $settings );
3352
+			$this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings);
3353 3353
 		}
3354 3354
 
3355 3355
 		//okay we should have the data all setup.  Now we just update!
3356 3356
 		$success = $this->_message_resource_manager->update_active_messengers_option();
3357 3357
 
3358
-		if ( $success ) {
3359
-			EE_Error::add_success( __('Settings updated', 'event_espresso') );
3358
+		if ($success) {
3359
+			EE_Error::add_success(__('Settings updated', 'event_espresso'));
3360 3360
 		} else {
3361
-			EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
3361
+			EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
3362 3362
 		}
3363 3363
 
3364 3364
 		$this->_template_args['success'] = $success;
@@ -3380,8 +3380,8 @@  discard block
 block discarded – undo
3380 3380
      */
3381 3381
 	protected function _generate_now() {
3382 3382
 		$msg_ids = $this->_get_msg_ids_from_request();
3383
-		EED_Messages::generate_now( $msg_ids );
3384
-		$this->_redirect_after_action( false, '', '', array(), true );
3383
+		EED_Messages::generate_now($msg_ids);
3384
+		$this->_redirect_after_action(false, '', '', array(), true);
3385 3385
 	}
3386 3386
 
3387 3387
 
@@ -3396,7 +3396,7 @@  discard block
 block discarded – undo
3396 3396
 	protected function _generate_and_send_now() {
3397 3397
 		$this->_generate_now();
3398 3398
 		$this->_send_now();
3399
-		$this->_redirect_after_action( false, '', '', array(), true );
3399
+		$this->_redirect_after_action(false, '', '', array(), true);
3400 3400
 	}
3401 3401
 
3402 3402
 
@@ -3410,8 +3410,8 @@  discard block
 block discarded – undo
3410 3410
      */
3411 3411
 	protected function _queue_for_resending() {
3412 3412
 		$msg_ids = $this->_get_msg_ids_from_request();
3413
-		EED_Messages::queue_for_resending( $msg_ids );
3414
-		$this->_redirect_after_action( false, '', '', array(), true );
3413
+		EED_Messages::queue_for_resending($msg_ids);
3414
+		$this->_redirect_after_action(false, '', '', array(), true);
3415 3415
 	}
3416 3416
 
3417 3417
 
@@ -3424,8 +3424,8 @@  discard block
 block discarded – undo
3424 3424
      */
3425 3425
 	protected function _send_now() {
3426 3426
 		$msg_ids = $this->_get_msg_ids_from_request();
3427
-		EED_Messages::send_now( $msg_ids );
3428
-		$this->_redirect_after_action( false, '', '', array(), true );
3427
+		EED_Messages::send_now($msg_ids);
3428
+		$this->_redirect_after_action(false, '', '', array(), true);
3429 3429
 	}
3430 3430
 
3431 3431
 
@@ -3439,23 +3439,23 @@  discard block
 block discarded – undo
3439 3439
 	protected function _delete_ee_messages() {
3440 3440
 		$msg_ids = $this->_get_msg_ids_from_request();
3441 3441
 		$deleted_count = 0;
3442
-		foreach ( $msg_ids as $msg_id ) {
3443
-			if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) {
3442
+		foreach ($msg_ids as $msg_id) {
3443
+			if (EEM_Message::instance()->delete_by_ID($msg_id)) {
3444 3444
 				$deleted_count++;
3445 3445
 			}
3446 3446
 		}
3447
-		if ( $deleted_count ) {
3447
+		if ($deleted_count) {
3448 3448
 			$this->_redirect_after_action(
3449 3449
 				true,
3450
-				_n( 'message', 'messages', $deleted_count, 'event_espresso' ),
3450
+				_n('message', 'messages', $deleted_count, 'event_espresso'),
3451 3451
 				__('deleted', 'event_espresso')
3452 3452
 			);
3453 3453
 		} else {
3454 3454
 			EE_Error::add_error(
3455
-				_n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ),
3455
+				_n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'),
3456 3456
 				__FILE__, __FUNCTION__, __LINE__
3457 3457
 			);
3458
-			$this->_redirect_after_action( false, '', '', array(), true );
3458
+			$this->_redirect_after_action(false, '', '', array(), true);
3459 3459
 		}
3460 3460
 	}
3461 3461
 
@@ -3468,10 +3468,10 @@  discard block
 block discarded – undo
3468 3468
      *  @return array
3469 3469
      */
3470 3470
 	protected function _get_msg_ids_from_request() {
3471
-		if ( ! isset( $this->_req_data['MSG_ID'] ) ) {
3471
+		if ( ! isset($this->_req_data['MSG_ID'])) {
3472 3472
 			return array();
3473 3473
 		}
3474
-		return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] );
3474
+		return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']);
3475 3475
 	}
3476 3476
 
3477 3477
 
Please login to merge, or discard this patch.
caffeinated/admin/extend/messages/Extend_Messages_Admin_Page.core.php 1 patch
Spacing   +22 added lines, -22 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
 /**
@@ -31,18 +31,18 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 
34
-	public function __construct( $routing = TRUE ) {
35
-		parent::__construct( $routing );
36
-		if ( !defined( 'EE_MSG_CAF_ASSETS_PATH' ) ) {
37
-			define( 'EE_MSG_CAF_ASSETS_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/assets/' );
38
-			define( 'EE_MSG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/' );
39
-			define( 'EE_MSG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/' );
40
-			define( 'EE_MSG_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/templates/' );
34
+	public function __construct($routing = TRUE) {
35
+		parent::__construct($routing);
36
+		if ( ! defined('EE_MSG_CAF_ASSETS_PATH')) {
37
+			define('EE_MSG_CAF_ASSETS_PATH', EE_CORE_CAF_ADMIN_EXTEND.'messages/assets/');
38
+			define('EE_MSG_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/');
39
+			define('EE_MSG_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/');
40
+			define('EE_MSG_CAF_TEMPLATE_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/templates/');
41 41
 		}
42 42
 	}
43 43
 
44 44
 	protected function _extend_page_config() {
45
-		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'messages';
45
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'messages';
46 46
 		$this->_page_routes['custom_mtps'] = array(
47 47
 			'func' => '_ee_custom_messages_overview_list_table',
48 48
 			'capability' => 'ee_read_messages' );
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
 				'require_nonce' => FALSE
71 71
 				);
72 72
 
73
-		add_action( 'current_screen', array( $this, 'dynamic_screen_hooks' ), 10 );
73
+		add_action('current_screen', array($this, 'dynamic_screen_hooks'), 10);
74 74
 	}
75 75
 
76 76
 
@@ -87,12 +87,12 @@  discard block
 block discarded – undo
87 87
 	public function dynamic_screen_hooks() {
88 88
 		global $admin_page_hooks;
89 89
 
90
-		if ( !empty( $admin_page_hooks['espresso_events'] ) ) {
90
+		if ( ! empty($admin_page_hooks['espresso_events'])) {
91 91
 			//we're on a EE specific page... good stuff!
92 92
 			$hook_prefix = $admin_page_hooks['espresso_events'];
93
-			$filter_ref = $hook_prefix . '_page_' . $this->page_slug;
94
-			add_filter( 'FHEE_manage_' . $filter_ref . '_columns', array( $this, 'add_custom_mtps_columns' ), 10, 2 );
95
-			add_action( 'AHEE__EE_Admin_List_Table__column_actions__' . $filter_ref, array( $this, 'custom_mtp_create_button_column'), 10, 2 );
93
+			$filter_ref = $hook_prefix.'_page_'.$this->page_slug;
94
+			add_filter('FHEE_manage_'.$filter_ref.'_columns', array($this, 'add_custom_mtps_columns'), 10, 2);
95
+			add_action('AHEE__EE_Admin_List_Table__column_actions__'.$filter_ref, array($this, 'custom_mtp_create_button_column'), 10, 2);
96 96
 		}
97 97
 	}
98 98
 
@@ -106,8 +106,8 @@  discard block
 block discarded – undo
106 106
 	 * @param array  $columns   Original defined list of columns
107 107
 	 * @param string $screen_id The unique screen id for the page.
108 108
 	 */
109
-	public function add_custom_mtps_columns( $columns, $screen_id ) {
110
-		if ( $screen_id !== 'espresso_messages_global_mtps' ) {
109
+	public function add_custom_mtps_columns($columns, $screen_id) {
110
+		if ($screen_id !== 'espresso_messages_global_mtps') {
111 111
 			return $columns;
112 112
 		}
113 113
 
@@ -128,13 +128,13 @@  discard block
 block discarded – undo
128 128
 	 *
129 129
 	 * @return string html content for the page.
130 130
 	 */
131
-	public function custom_mtp_create_button_column( $item, $screen_id ) {
132
-		if ( $screen_id !== 'espresso_messages_global_mtps' || ! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ) {
131
+	public function custom_mtp_create_button_column($item, $screen_id) {
132
+		if ($screen_id !== 'espresso_messages_global_mtps' || ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template')) {
133 133
 			return '';
134 134
 		}
135 135
 
136 136
 		//first we consider whether this template has override set.  If it does then that means no custom templates can be created from this template as a base.  So let's just skip the button creation.
137
-		if ( $item->get('MTP_is_override' ) )
137
+		if ($item->get('MTP_is_override'))
138 138
 			return '';
139 139
 
140 140
 
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 			'message_type' => $item->message_type(),
145 145
 			'action' => 'add_new_message_template'
146 146
 			);
147
-		$create_link = EE_Admin_Page::add_query_args_and_nonce( $create_args, EE_MSG_ADMIN_URL );
148
-		echo sprintf( '<a href="%s" class="button button-small">%s</a>', $create_link, __('Create Custom', 'event_espresso') );
147
+		$create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
148
+		echo sprintf('<a href="%s" class="button button-small">%s</a>', $create_link, __('Create Custom', 'event_espresso'));
149 149
 	}
150 150
 
151 151
 
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 				)
179 179
 			)
180 180
 		);
181
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'espresso_messages_trash_message_template' ) ) {
181
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'espresso_messages_trash_message_template')) {
182 182
 			$this->_views['trashed'] = array(
183 183
 				'slug' => 'trashed',
184 184
 				'label' => __('Trash', 'event_espresso'),
Please login to merge, or discard this patch.
message_type/newsletter/EE_Messages_Contacts_incoming_data.class.php 2 patches
Indentation   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -19,101 +19,101 @@
 block discarded – undo
19 19
 class EE_Messages_Contacts_incoming_data extends EE_Messages_incoming_data {
20 20
 
21 21
 
22
-    /**
23
-     * Constructor.
24
-     *
25
-     * @since    4.3.0
26
-     * @param  EE_Attendee[]     $data expecting an array of EE_Attendee objects.
27
-     * @throws EE_Error
28
-     * @access protected
29
-     */
30
-    public function __construct( $data = array() ) {
31
-
32
-        //validate that the first element in the array is an EE_Attendee object.  Note that the array may be indexed by REG_ID so we will just shift off the first element.
33
-        $ctc_chk = reset( $data );
34
-        if ( ! $ctc_chk instanceof EE_Attendee )
35
-            throw new EE_Error(__('The EE_Message_Contacts_incoming_data class expects an array of EE_Attendee objects.', 'event_espresso') );
36
-
37
-        parent::__construct( $data );
38
-    }
39
-
40
-
41
-    /**
42
-     * @see parent class for phpdocs.
43
-     * @param array $attendees
44
-     * @return array
45
-     */
46
-    public static function convert_data_for_persistent_storage( $attendees ) {
47
-        $attendee_ids = array_filter ( array_map(
48
-            function( $attendee ) {
49
-                if ( $attendee instanceof EE_Attendee ) {
50
-                    return $attendee->ID();
51
-                }
52
-            },
53
-            $attendees
54
-            ) );
55
-        return $attendee_ids;
56
-    }
57
-
58
-
59
-
60
-
61
-    /**
62
-     * @see parent class for phpdocs
63
-     * @param array $attendee_ids
64
-     * @return EE_Attendee[]
65
-     */
66
-    public static function convert_data_from_persistent_storage( $attendee_ids ) {
67
-        $attendee_ids = (array) $attendee_ids;
68
-        $attendees = EEM_Attendee::instance()->get_all(
69
-          array(
70
-              array( 'ATT_ID' => array( 'IN', $attendee_ids ) )
71
-          )
72
-        );
73
-        return $attendees;
74
-    }
75
-
76
-
77
-
78
-
79
-    /**
80
-     * setup the data.
81
-     *
82
-     * Sets up the expected data object for the messages prep using incoming registration objects.
83
-     *
84
-     * @since   4.3.0
85
-     *
86
-     * @return void
87
-     * @access protected
88
-     */
89
-    protected function _setup_data() {
90
-
91
-        //we'll loop through each contact and setup the data needed.  Note that many properties will just be set as empty because the contacts data handler is for a very specific set of data (i.e. just what's related to the contact).
92
-        $this->txn = NULL;
93
-        $this->taxes = NULL;
94
-        $this->grand_total_price_object = '';
95
-        $this->user_id = $this->ip_address = $this->user_agent = $this->init_access = '';
96
-        $this->payment = NULL;
97
-        $this->billing = array();
98
-        $this->reg_objs = array();
99
-        $this->attendees = $this->events = $this->tickets = $this->datetimes = $this->questions = $this->answer =  $this->registrations = array();
100
-        $this->total_ticket_count = 0;
101
-        $this->primary_attendee_data = array(
102
-            'registration_id' => 0,
103
-            'att_obj' => NULL,
104
-            'reg_obj' => NULL,
105
-            'primary_att_obj' => NULL,
106
-            'primary_reg_obj' => NULL
107
-            );
108
-
109
-        foreach ( $this->_data as $contact ) {
110
-            $id = $contact->ID();
111
-            $reg = $contact->get_first_related('Registration');
112
-            $this->attendees[$id]['att_obj'] = $contact;
113
-            $this->attendees[$id]['reg_objs'][$reg->ID()] = $reg;
114
-            $this->attendees[$id]['attendee_email'] = $contact->email();
115
-            $this->attendees[$id]['tkt_objs'] = array();
116
-            $this->attendees[$id]['evt_objs'] = array();
117
-        }
118
-    }
22
+	/**
23
+	 * Constructor.
24
+	 *
25
+	 * @since    4.3.0
26
+	 * @param  EE_Attendee[]     $data expecting an array of EE_Attendee objects.
27
+	 * @throws EE_Error
28
+	 * @access protected
29
+	 */
30
+	public function __construct( $data = array() ) {
31
+
32
+		//validate that the first element in the array is an EE_Attendee object.  Note that the array may be indexed by REG_ID so we will just shift off the first element.
33
+		$ctc_chk = reset( $data );
34
+		if ( ! $ctc_chk instanceof EE_Attendee )
35
+			throw new EE_Error(__('The EE_Message_Contacts_incoming_data class expects an array of EE_Attendee objects.', 'event_espresso') );
36
+
37
+		parent::__construct( $data );
38
+	}
39
+
40
+
41
+	/**
42
+	 * @see parent class for phpdocs.
43
+	 * @param array $attendees
44
+	 * @return array
45
+	 */
46
+	public static function convert_data_for_persistent_storage( $attendees ) {
47
+		$attendee_ids = array_filter ( array_map(
48
+			function( $attendee ) {
49
+				if ( $attendee instanceof EE_Attendee ) {
50
+					return $attendee->ID();
51
+				}
52
+			},
53
+			$attendees
54
+			) );
55
+		return $attendee_ids;
56
+	}
57
+
58
+
59
+
60
+
61
+	/**
62
+	 * @see parent class for phpdocs
63
+	 * @param array $attendee_ids
64
+	 * @return EE_Attendee[]
65
+	 */
66
+	public static function convert_data_from_persistent_storage( $attendee_ids ) {
67
+		$attendee_ids = (array) $attendee_ids;
68
+		$attendees = EEM_Attendee::instance()->get_all(
69
+		  array(
70
+			  array( 'ATT_ID' => array( 'IN', $attendee_ids ) )
71
+		  )
72
+		);
73
+		return $attendees;
74
+	}
75
+
76
+
77
+
78
+
79
+	/**
80
+	 * setup the data.
81
+	 *
82
+	 * Sets up the expected data object for the messages prep using incoming registration objects.
83
+	 *
84
+	 * @since   4.3.0
85
+	 *
86
+	 * @return void
87
+	 * @access protected
88
+	 */
89
+	protected function _setup_data() {
90
+
91
+		//we'll loop through each contact and setup the data needed.  Note that many properties will just be set as empty because the contacts data handler is for a very specific set of data (i.e. just what's related to the contact).
92
+		$this->txn = NULL;
93
+		$this->taxes = NULL;
94
+		$this->grand_total_price_object = '';
95
+		$this->user_id = $this->ip_address = $this->user_agent = $this->init_access = '';
96
+		$this->payment = NULL;
97
+		$this->billing = array();
98
+		$this->reg_objs = array();
99
+		$this->attendees = $this->events = $this->tickets = $this->datetimes = $this->questions = $this->answer =  $this->registrations = array();
100
+		$this->total_ticket_count = 0;
101
+		$this->primary_attendee_data = array(
102
+			'registration_id' => 0,
103
+			'att_obj' => NULL,
104
+			'reg_obj' => NULL,
105
+			'primary_att_obj' => NULL,
106
+			'primary_reg_obj' => NULL
107
+			);
108
+
109
+		foreach ( $this->_data as $contact ) {
110
+			$id = $contact->ID();
111
+			$reg = $contact->get_first_related('Registration');
112
+			$this->attendees[$id]['att_obj'] = $contact;
113
+			$this->attendees[$id]['reg_objs'][$reg->ID()] = $reg;
114
+			$this->attendees[$id]['attendee_email'] = $contact->email();
115
+			$this->attendees[$id]['tkt_objs'] = array();
116
+			$this->attendees[$id]['evt_objs'] = array();
117
+		}
118
+	}
119 119
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -27,14 +27,14 @@  discard block
 block discarded – undo
27 27
      * @throws EE_Error
28 28
      * @access protected
29 29
      */
30
-    public function __construct( $data = array() ) {
30
+    public function __construct($data = array()) {
31 31
 
32 32
         //validate that the first element in the array is an EE_Attendee object.  Note that the array may be indexed by REG_ID so we will just shift off the first element.
33
-        $ctc_chk = reset( $data );
34
-        if ( ! $ctc_chk instanceof EE_Attendee )
35
-            throw new EE_Error(__('The EE_Message_Contacts_incoming_data class expects an array of EE_Attendee objects.', 'event_espresso') );
33
+        $ctc_chk = reset($data);
34
+        if ( ! $ctc_chk instanceof EE_Attendee)
35
+            throw new EE_Error(__('The EE_Message_Contacts_incoming_data class expects an array of EE_Attendee objects.', 'event_espresso'));
36 36
 
37
-        parent::__construct( $data );
37
+        parent::__construct($data);
38 38
     }
39 39
 
40 40
 
@@ -43,15 +43,15 @@  discard block
 block discarded – undo
43 43
      * @param array $attendees
44 44
      * @return array
45 45
      */
46
-    public static function convert_data_for_persistent_storage( $attendees ) {
47
-        $attendee_ids = array_filter ( array_map(
48
-            function( $attendee ) {
49
-                if ( $attendee instanceof EE_Attendee ) {
46
+    public static function convert_data_for_persistent_storage($attendees) {
47
+        $attendee_ids = array_filter(array_map(
48
+            function($attendee) {
49
+                if ($attendee instanceof EE_Attendee) {
50 50
                     return $attendee->ID();
51 51
                 }
52 52
             },
53 53
             $attendees
54
-            ) );
54
+            ));
55 55
         return $attendee_ids;
56 56
     }
57 57
 
@@ -63,11 +63,11 @@  discard block
 block discarded – undo
63 63
      * @param array $attendee_ids
64 64
      * @return EE_Attendee[]
65 65
      */
66
-    public static function convert_data_from_persistent_storage( $attendee_ids ) {
66
+    public static function convert_data_from_persistent_storage($attendee_ids) {
67 67
         $attendee_ids = (array) $attendee_ids;
68 68
         $attendees = EEM_Attendee::instance()->get_all(
69 69
           array(
70
-              array( 'ATT_ID' => array( 'IN', $attendee_ids ) )
70
+              array('ATT_ID' => array('IN', $attendee_ids))
71 71
           )
72 72
         );
73 73
         return $attendees;
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
         $this->payment = NULL;
97 97
         $this->billing = array();
98 98
         $this->reg_objs = array();
99
-        $this->attendees = $this->events = $this->tickets = $this->datetimes = $this->questions = $this->answer =  $this->registrations = array();
99
+        $this->attendees = $this->events = $this->tickets = $this->datetimes = $this->questions = $this->answer = $this->registrations = array();
100 100
         $this->total_ticket_count = 0;
101 101
         $this->primary_attendee_data = array(
102 102
             'registration_id' => 0,
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
             'primary_reg_obj' => NULL
107 107
             );
108 108
 
109
-        foreach ( $this->_data as $contact ) {
109
+        foreach ($this->_data as $contact) {
110 110
             $id = $contact->ID();
111 111
             $reg = $contact->get_first_related('Registration');
112 112
             $this->attendees[$id]['att_obj'] = $contact;
Please login to merge, or discard this patch.
caffeinated/core/libraries/shortcodes/EE_Newsletter_Shortcodes.lib.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -30,14 +30,14 @@  discard block
 block discarded – undo
30 30
 
31 31
 
32 32
 
33
-    protected function _parser( $shortcode ) {
34
-        if ( $shortcode == '[NEWSLETTER_CONTENT]' ) {
33
+    protected function _parser($shortcode) {
34
+        if ($shortcode == '[NEWSLETTER_CONTENT]') {
35 35
             $this->_validate_list_requirements();
36 36
             $this->_set_shortcode_helper();
37 37
             $valid_shortcodes = array('recipient_details', 'organization');
38 38
             $template = $this->_data['template']['newsletter_content'];
39 39
             $data = $this->_data;
40
-            return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message );
40
+            return $this->_shortcode_helper->parse_message_template($template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message);
41 41
         }
42 42
     }
43 43
 
@@ -53,8 +53,8 @@  discard block
 block discarded – undo
53 53
      * @param  EE_messenger  $messenger
54 54
      * @return  array                                             new validator config.
55 55
      */
56
-    public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) {
57
-        if ( $messenger->name !== 'email' )
56
+    public static function messenger_validator_config($validator_config, EE_messenger $messenger) {
57
+        if ($messenger->name !== 'email')
58 58
             return $validator_config;
59 59
 
60 60
         $validator_config['content']['shortcodes'][] = 'newsletter';
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
      * @param  EE_messenger  $messenger
82 82
      * @return  array                                           new/modified template fields array.
83 83
      */
84
-    public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) {
85
-        if ( $messenger->name !== 'email' )
84
+    public static function messenger_template_fields($template_fields, EE_messenger $messenger) {
85
+        if ($messenger->name !== 'email')
86 86
             return $template_fields;
87 87
 
88 88
         $template_fields['extra']['content']['newsletter_content'] = array(
Please login to merge, or discard this patch.
Indentation   +65 added lines, -65 removed lines patch added patch discarded remove patch
@@ -20,81 +20,81 @@
 block discarded – undo
20 20
  */
21 21
 class EE_Newsletter_Shortcodes extends EE_Shortcodes {
22 22
 
23
-    protected function _init_props() {
24
-        $this->label = __("Newsletter Shortcodes", 'event_espresso');
25
-        $this->description = __('All shortcodes used for the newsletter message type', 'event_espresso');
26
-        $this->_shortcodes = array(
27
-            '[NEWSLETTER_CONTENT]' => __('This will parse to whatever is found in the related [newsletter_content] field.  Note that when triggering a newsletter message, whatever is added for the custom message will be inserted where this shortcode is placed', 'event_espresso')
28
-            );
29
-    }
23
+	protected function _init_props() {
24
+		$this->label = __("Newsletter Shortcodes", 'event_espresso');
25
+		$this->description = __('All shortcodes used for the newsletter message type', 'event_espresso');
26
+		$this->_shortcodes = array(
27
+			'[NEWSLETTER_CONTENT]' => __('This will parse to whatever is found in the related [newsletter_content] field.  Note that when triggering a newsletter message, whatever is added for the custom message will be inserted where this shortcode is placed', 'event_espresso')
28
+			);
29
+	}
30 30
 
31 31
 
32 32
 
33
-    protected function _parser( $shortcode ) {
34
-        if ( $shortcode == '[NEWSLETTER_CONTENT]' ) {
35
-            $this->_validate_list_requirements();
36
-            $valid_shortcodes = array('recipient_details', 'organization');
37
-            $template = $this->_data['template']['newsletter_content'];
38
-            $data = $this->_data;
39
-            return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message );
40
-        }
41
-    }
33
+	protected function _parser( $shortcode ) {
34
+		if ( $shortcode == '[NEWSLETTER_CONTENT]' ) {
35
+			$this->_validate_list_requirements();
36
+			$valid_shortcodes = array('recipient_details', 'organization');
37
+			$template = $this->_data['template']['newsletter_content'];
38
+			$data = $this->_data;
39
+			return $this->_shortcode_helper->parse_message_template( $template, $data['data'], $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message );
40
+		}
41
+	}
42 42
 
43 43
 
44
-    /**
45
-     * Callback set in args for EE_Register_Messages_Shortcode_Library::register for 'msgr_validator_callback'.
46
-     *
47
-     * EE_Register_Messages_Shortcode_Library::register registers this callback with the
48
-     * 'FHEE__EE_messenger__get_validator_config' filter.
49
-     *
50
-     * @since    4.3.0
51
-     * @param  array        $validator_config  current validator configuration array
52
-     * @param  EE_messenger $messenger
53
-     * @return  array                                             new validator config.
54
-     */
55
-    public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) {
56
-        if ( $messenger->name !== 'email' )
57
-            return $validator_config;
44
+	/**
45
+	 * Callback set in args for EE_Register_Messages_Shortcode_Library::register for 'msgr_validator_callback'.
46
+	 *
47
+	 * EE_Register_Messages_Shortcode_Library::register registers this callback with the
48
+	 * 'FHEE__EE_messenger__get_validator_config' filter.
49
+	 *
50
+	 * @since    4.3.0
51
+	 * @param  array        $validator_config  current validator configuration array
52
+	 * @param  EE_messenger $messenger
53
+	 * @return  array                                             new validator config.
54
+	 */
55
+	public static function messenger_validator_config( $validator_config, EE_messenger $messenger ) {
56
+		if ( $messenger->name !== 'email' )
57
+			return $validator_config;
58 58
 
59
-        $validator_config['content']['shortcodes'][] = 'newsletter';
60
-        $validator_config['newsletter_content'] = array(
61
-            'shortcodes' => array('recipient_details', 'organization'),
62
-            'required' => array('[NEWSLETTER_CONTENT]')
63
-            );
64
-        return $validator_config;
65
-    }
59
+		$validator_config['content']['shortcodes'][] = 'newsletter';
60
+		$validator_config['newsletter_content'] = array(
61
+			'shortcodes' => array('recipient_details', 'organization'),
62
+			'required' => array('[NEWSLETTER_CONTENT]')
63
+			);
64
+		return $validator_config;
65
+	}
66 66
 
67 67
 
68 68
 
69 69
 
70
-    /**
71
-     * Callback set in args for EE_Register_Messages_Shortcode_Library::register for
72
-     * 'msgr_template_fields_callback'.
73
-     *
74
-     * EE_Register_Messages_Shortcode_Library::register registers this callback with the
75
-     * FHEE__EE_messenger__get_template_fields filter.
76
-     *
77
-     * @since    4.3.0
78
-     *
79
-     * @param  array        $template_fields current template fields setup array.
80
-     * @param  EE_messenger $messenger
81
-     * @return  array                                           new/modified template fields array.
82
-     */
83
-    public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) {
84
-        if ( $messenger->name !== 'email' )
85
-            return $template_fields;
70
+	/**
71
+	 * Callback set in args for EE_Register_Messages_Shortcode_Library::register for
72
+	 * 'msgr_template_fields_callback'.
73
+	 *
74
+	 * EE_Register_Messages_Shortcode_Library::register registers this callback with the
75
+	 * FHEE__EE_messenger__get_template_fields filter.
76
+	 *
77
+	 * @since    4.3.0
78
+	 *
79
+	 * @param  array        $template_fields current template fields setup array.
80
+	 * @param  EE_messenger $messenger
81
+	 * @return  array                                           new/modified template fields array.
82
+	 */
83
+	public static function messenger_template_fields( $template_fields, EE_messenger $messenger ) {
84
+		if ( $messenger->name !== 'email' )
85
+			return $template_fields;
86 86
 
87
-        $template_fields['extra']['content']['newsletter_content'] = array(
88
-            'input' => 'wp_editor',
89
-            'label' => '[NEWSLETTER_CONTENT]',
90
-            'type' => 'string',
91
-            'required' => TRUE,
92
-            'validation' => TRUE,
93
-            'format' => '%s',
94
-            'rows' => '15',
95
-            'shortcodes_required' => array('[NEWSLETTER_CONTENT]')
96
-            );
97
-        return $template_fields;
98
-    }
87
+		$template_fields['extra']['content']['newsletter_content'] = array(
88
+			'input' => 'wp_editor',
89
+			'label' => '[NEWSLETTER_CONTENT]',
90
+			'type' => 'string',
91
+			'required' => TRUE,
92
+			'validation' => TRUE,
93
+			'format' => '%s',
94
+			'rows' => '15',
95
+			'shortcodes_required' => array('[NEWSLETTER_CONTENT]')
96
+			);
97
+		return $template_fields;
98
+	}
99 99
 
100 100
 } //end class EE_Newsletter_Shortcodes
Please login to merge, or discard this patch.
core/admin/templates/admin_details_legend.template.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -2,25 +2,25 @@
 block discarded – undo
2 2
 //this displays any legends with an array of $items that are indexed by id for each item and each item itself is an array of 'icon' and 'desc'.
3 3
 
4 4
 //figure out the columns based on the count of items (we want a max of 6 items per column).
5
-$per_col = isset( $per_column ) ? $per_column : 5;
5
+$per_col = isset($per_column) ? $per_column : 5;
6 6
 $count = 1;
7 7
 ?>
8 8
 <div class="ee-list-table-legend-container">
9 9
 	<h4><?php _e('Legend', 'event_espresso'); ?></h4>
10 10
 	<dl class="alignleft ee-list-table-legend">
11
-		<?php foreach ( $items as $item => $details ) : ?>
12
-			<?php if ( $per_col < $count ) : ?>
11
+		<?php foreach ($items as $item => $details) : ?>
12
+			<?php if ($per_col < $count) : ?>
13 13
 				</dl>
14 14
 				<dl class="alignleft ee-list-table-legend">
15 15
 			<?php $count = 1; endif; ?>
16 16
 			<dt id="ee-legend-item-<?php echo $item; ?>">
17
-				<?php $class = ! empty( $details['class'] ) ? $details['class'] : 'ee-legend-img-container'; ?>
18
-				<?php if ( strpos( $details[ 'class' ], '<span' ) !== false ) {
17
+				<?php $class = ! empty($details['class']) ? $details['class'] : 'ee-legend-img-container'; ?>
18
+				<?php if (strpos($details['class'], '<span') !== false) {
19 19
 					echo $class;
20 20
 				} else { ?>
21 21
 				<span class="<?php echo $class; ?>">
22
-					<?php if ( ! empty( $details[ 'icon' ] ) ) : ?>
23
-						<img src="<?php echo $details[ 'icon' ]; ?>" class="ee-legend-icon" alt="<?php echo esc_attr( $details[ 'desc' ] ); ?>"/>
22
+					<?php if ( ! empty($details['icon'])) : ?>
23
+						<img src="<?php echo $details['icon']; ?>" class="ee-legend-icon" alt="<?php echo esc_attr($details['desc']); ?>"/>
24 24
 					<?php endif; ?>
25 25
 				</span>
26 26
 				<?php } ?>
Please login to merge, or discard this patch.
core/db_classes/EE_WP_User.class.php 1 patch
Spacing   +11 added lines, -11 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_WP_User class
@@ -22,9 +22,9 @@  discard block
 block discarded – undo
22 22
 	 * @param array $props_n_values
23 23
 	 * @return EE_WP_User|mixed
24 24
 	 */
25
-	public static function new_instance( $props_n_values = array() ) {
26
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
27
-		return $has_object ? $has_object : new self( $props_n_values );
25
+	public static function new_instance($props_n_values = array()) {
26
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
27
+		return $has_object ? $has_object : new self($props_n_values);
28 28
 	}
29 29
 
30 30
 
@@ -33,8 +33,8 @@  discard block
 block discarded – undo
33 33
 	 * @param array $props_n_values
34 34
 	 * @return EE_WP_User
35 35
 	 */
36
-	public static function new_instance_from_db( $props_n_values = array() ) {
37
-		return new self( $props_n_values, TRUE );
36
+	public static function new_instance_from_db($props_n_values = array()) {
37
+		return new self($props_n_values, TRUE);
38 38
 	}
39 39
 
40 40
 	/**
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @return WP_User
43 43
 	 */
44 44
 	public function wp_user_obj() {
45
-		if( ! $this->_wp_user_obj ) {
46
-			$this->_wp_user_obj = get_user_by('ID', $this->ID() );
45
+		if ( ! $this->_wp_user_obj) {
46
+			$this->_wp_user_obj = get_user_by('ID', $this->ID());
47 47
 		}
48 48
 		return $this->_wp_user_obj;
49 49
 	}
@@ -69,7 +69,7 @@  discard block
 block discarded – undo
69 69
 						$_SERVER['REQUEST_URI']
70 70
 					)
71 71
 				),
72
-				get_edit_user_link( $this->ID() )
72
+				get_edit_user_link($this->ID())
73 73
 			)
74 74
 		);
75 75
 	}
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
 	 * @return string
88 88
 	 */
89 89
 	public function get_admin_overview_link() {
90
-		return admin_url( 'users.php' );
90
+		return admin_url('users.php');
91 91
 	}
92 92
 
93 93
 
Please login to merge, or discard this patch.
core/helpers/EEH_MSG_Template.helper.php 3 patches
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -421,7 +421,7 @@
 block discarded – undo
421 421
 		if ( ! empty( $sending_messenger ) ) {
422 422
 			$with_messengers = $message_type->with_messengers();
423 423
 			if ( ! isset( $with_messengers[$message->messenger()] )
424
-			     || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) {
424
+				 || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) {
425 425
 				throw new EE_Error( sprintf( __('The given sending messenger string (%s) does not match a valid sending messenger with the %s.  If this is incorrect, make sure that the message type has defined this messenger as a sending messenger in its $_with_messengers array.', 'event_espresso'), $sending_messenger, get_class( $message_type ) ) );
426 426
 			}
427 427
 		} else {
Please login to merge, or discard this patch.
Spacing   +197 added lines, -197 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
 /**
@@ -59,24 +59,24 @@  discard block
 block discarded – undo
59 59
 	 *                was not a new generated template but just reactivated (which only happens for global templates that
60 60
 	 *                already exist in the database.
61 61
 	 */
62
-	public static function generate_new_templates( $messenger, $message_types, $GRP_ID = 0, $global = false ) {
62
+	public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) {
63 63
 		//make sure message_type is an array.
64 64
 		$message_types = (array) $message_types;
65 65
 		$templates = array();
66 66
 
67
-		if ( empty( $messenger ) ) {
68
-			throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') );
67
+		if (empty($messenger)) {
68
+			throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso'));
69 69
 		}
70 70
 
71 71
 		//if we STILL have empty $message_types then we need to generate an error message b/c we NEED message types to do the template files.
72
-		if ( empty( $message_types ) ) {
73
-			throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') );
72
+		if (empty($message_types)) {
73
+			throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso'));
74 74
 		}
75 75
 
76 76
 		EEH_MSG_Template::_set_autoloader();
77
-		foreach ( $message_types as $message_type ) {
77
+		foreach ($message_types as $message_type) {
78 78
 			//if global then let's attempt to get the GRP_ID for this combo IF GRP_ID is empty.
79
-			if ( $global && empty( $GRP_ID ) ) {
79
+			if ($global && empty($GRP_ID)) {
80 80
 				$GRP_ID = EEM_Message_Template_Group::instance()->get_one(
81 81
 					array(
82 82
 						array(
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
 			// if this is global template generation.
92 92
 			// First let's determine if we already HAVE global templates for this messenger and message_type combination.
93 93
 			//  If we do then NO generation!!
94
-			if ( $global && EEH_MSG_Template::already_generated( $messenger, $message_type, $GRP_ID ) ) {
94
+			if ($global && EEH_MSG_Template::already_generated($messenger, $message_type, $GRP_ID)) {
95 95
 				$templates[] = array(
96 96
 					'GRP_ID' => $GRP_ID,
97 97
 					'MTP_context' => '',
@@ -99,9 +99,9 @@  discard block
 block discarded – undo
99 99
 				//we already have generated templates for this so let's go to the next message type.
100 100
 				continue;
101 101
 			}
102
-			$new_message_template_group = EEH_MSG_Template::create_new_templates( $messenger, $message_type, $GRP_ID, $global );
102
+			$new_message_template_group = EEH_MSG_Template::create_new_templates($messenger, $message_type, $GRP_ID, $global);
103 103
 
104
-			if ( ! $new_message_template_group ) {
104
+			if ( ! $new_message_template_group) {
105 105
 				continue;
106 106
 			}
107 107
 			$templates[] = $new_message_template_group;
@@ -118,10 +118,10 @@  discard block
 block discarded – undo
118 118
 	 * @param  int $GRP_ID        GRP ID ( if a custom template) (if not provided then we're just doing global template check)
119 119
 	 * @return bool                true = generated, false = hasn't been generated.
120 120
 	 */
121
-	public static function already_generated( $messenger, $message_type, $GRP_ID = 0 ) {
121
+	public static function already_generated($messenger, $message_type, $GRP_ID = 0) {
122 122
 		EEH_MSG_Template::_set_autoloader();
123 123
 		//what method we use depends on whether we have an GRP_ID or not
124
-		$count = empty( $GRP_ID )
124
+		$count = empty($GRP_ID)
125 125
 			? EEM_Message_Template::instance()->count(
126 126
 				array(
127 127
 					array(
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
 					)
132 132
 				)
133 133
 			)
134
-			: EEM_Message_Template::instance()->count( array( array( 'GRP_ID' => $GRP_ID ) ) );
134
+			: EEM_Message_Template::instance()->count(array(array('GRP_ID' => $GRP_ID)));
135 135
 
136 136
 		return $count > 0;
137 137
 	}
@@ -147,15 +147,15 @@  discard block
 block discarded – undo
147 147
 	 * @param  array  $message_type_names  Message type slug
148 148
 	 * @return  int 						count of updated records.
149 149
 	 */
150
-	public static function update_to_active( $messenger_names, $message_type_names ) {
151
-		$messenger_names = is_array( $messenger_names ) ? $messenger_names : array( $messenger_names );
152
-		$message_type_names = is_array( $message_type_names ) ? $message_type_names : array( $message_type_names );
150
+	public static function update_to_active($messenger_names, $message_type_names) {
151
+		$messenger_names = is_array($messenger_names) ? $messenger_names : array($messenger_names);
152
+		$message_type_names = is_array($message_type_names) ? $message_type_names : array($message_type_names);
153 153
 		return EEM_Message_Template_Group::instance()->update(
154
-			array( 'MTP_is_active' => 1 ),
154
+			array('MTP_is_active' => 1),
155 155
 			array(
156 156
 				array(
157
-					'MTP_messenger' 	=> array( 'IN', $messenger_names ),
158
-					'MTP_message_type'  => array( 'IN', $message_type_names )
157
+					'MTP_messenger' 	=> array('IN', $messenger_names),
158
+					'MTP_message_type'  => array('IN', $message_type_names)
159 159
 				)
160 160
 			)
161 161
 		);
@@ -176,7 +176,7 @@  discard block
 block discarded – undo
176 176
 	 *
177 177
 	 * @return int  count of updated records.
178 178
 	 */
179
-	public static function update_to_inactive( $messenger_names = array(), $message_type_names = array() ) {
179
+	public static function update_to_inactive($messenger_names = array(), $message_type_names = array()) {
180 180
 		return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for(
181 181
 			$messenger_names,
182 182
 			$message_type_names
@@ -193,9 +193,9 @@  discard block
 block discarded – undo
193 193
 	 * @param string $type
194 194
 	 * @return array array consisting of installed messenger objects and installed message type objects.
195 195
 	 */
196
-	public static function get_installed_message_objects( $type = 'all' ) {
196
+	public static function get_installed_message_objects($type = 'all') {
197 197
 		self::_set_autoloader();
198
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
198
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
199 199
 		return array(
200 200
 			'messenger' => $message_resource_manager->installed_messengers(),
201 201
 			'message_type' => $message_resource_manager->installed_message_types()
@@ -231,74 +231,74 @@  discard block
 block discarded – undo
231 231
 		$context = 'admin',
232 232
 		$merged = false
233 233
 	) {
234
-		$messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) );
235
-		$mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) );
234
+		$messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger)));
235
+		$mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type)));
236 236
 		/** @var EE_Message_Resource_Manager $message_resource_manager */
237
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
237
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
238 238
 		//convert slug to object
239
-		$messenger = $message_resource_manager->get_messenger( $messenger );
239
+		$messenger = $message_resource_manager->get_messenger($messenger);
240 240
 
241 241
 		//if messenger isn't a EE_messenger resource then bail.
242
-		if ( ! $messenger instanceof EE_messenger ) {
242
+		if ( ! $messenger instanceof EE_messenger) {
243 243
 			return array();
244 244
 		}
245 245
 
246 246
 		//validate class for getting our list of shortcodes
247
-		$classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator';
248
-		if ( ! class_exists( $classname ) ) {
249
-			$msg[] = __( 'The Validator class was unable to load', 'event_espresso' );
247
+		$classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator';
248
+		if ( ! class_exists($classname)) {
249
+			$msg[] = __('The Validator class was unable to load', 'event_espresso');
250 250
 			$msg[] = sprintf(
251
-				__( 'The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso' ),
251
+				__('The class name compiled was %s. Please check and make sure the spelling and case is correct for the class name and that there is an autoloader in place for this class', 'event_espresso'),
252 252
 				$classname
253 253
 			);
254
-			throw new EE_Error( implode( '||', $msg ) );
254
+			throw new EE_Error(implode('||', $msg));
255 255
 		}
256 256
 
257 257
 		/** @type EE_Messages_Validator $_VLD */
258
-		$_VLD = new $classname( array(), $context );
258
+		$_VLD = new $classname(array(), $context);
259 259
 		$valid_shortcodes = $_VLD->get_validators();
260 260
 
261 261
 		//let's make sure we're only getting the shortcode part of the validators
262 262
 		$shortcodes = array();
263
-		foreach ( $valid_shortcodes as $field => $validators ) {
264
-			$shortcodes[ $field ] = $validators['shortcodes'];
263
+		foreach ($valid_shortcodes as $field => $validators) {
264
+			$shortcodes[$field] = $validators['shortcodes'];
265 265
 		}
266 266
 		$valid_shortcodes = $shortcodes;
267 267
 
268 268
 		//if not all fields let's make sure we ONLY include the shortcodes for the specified fields.
269
-		if ( ! empty( $fields ) ) {
269
+		if ( ! empty($fields)) {
270 270
 			$specified_shortcodes = array();
271
-			foreach ( $fields as $field ) {
272
-				if ( isset( $valid_shortcodes[ $field ] ) ) {
273
-					$specified_shortcodes[ $field ] = $valid_shortcodes[ $field ];
271
+			foreach ($fields as $field) {
272
+				if (isset($valid_shortcodes[$field])) {
273
+					$specified_shortcodes[$field] = $valid_shortcodes[$field];
274 274
 				}
275 275
 			}
276 276
 			$valid_shortcodes = $specified_shortcodes;
277 277
 		}
278 278
 
279 279
 		//if not merged then let's replace the fields with the localized fields
280
-		if ( ! $merged ) {
280
+		if ( ! $merged) {
281 281
 			//let's get all the fields for the set messenger so that we can get the localized label and use that in the returned array.
282 282
 			$field_settings = $messenger->get_template_fields();
283 283
 			$localized = array();
284
-			foreach ( $valid_shortcodes as $field => $shortcodes ) {
284
+			foreach ($valid_shortcodes as $field => $shortcodes) {
285 285
 				//get localized field label
286
-				if ( isset( $field_settings[ $field ] ) ) {
286
+				if (isset($field_settings[$field])) {
287 287
 					//possible that this is used as a main field.
288
-					if ( empty( $field_settings[ $field ] ) ) {
289
-						if ( isset( $field_settings['extra'][ $field ] ) ) {
290
-							$_field = $field_settings['extra'][ $field ]['main']['label'];
288
+					if (empty($field_settings[$field])) {
289
+						if (isset($field_settings['extra'][$field])) {
290
+							$_field = $field_settings['extra'][$field]['main']['label'];
291 291
 						} else {
292 292
 							$_field = $field;
293 293
 						}
294 294
 					} else {
295
-						$_field = $field_settings[ $field ]['label'];
295
+						$_field = $field_settings[$field]['label'];
296 296
 					}
297
-				} else if ( isset( $field_settings['extra'] ) ) {
297
+				} else if (isset($field_settings['extra'])) {
298 298
 					//loop through extra "main fields" and see if any of their children have our field
299
-					foreach ( $field_settings['extra'] as $main_field => $fields ) {
300
-						if ( isset( $fields[ $field ] ) ) {
301
-							$_field = $fields[ $field ]['label'];
299
+					foreach ($field_settings['extra'] as $main_field => $fields) {
300
+						if (isset($fields[$field])) {
301
+							$_field = $fields[$field]['label'];
302 302
 						} else {
303 303
 							$_field = $field;
304 304
 						}
@@ -306,22 +306,22 @@  discard block
 block discarded – undo
306 306
 				} else {
307 307
 					$_field = $field;
308 308
 				}
309
-				if ( isset( $_field ) ) {
310
-					$localized[ $_field ] = $shortcodes;
309
+				if (isset($_field)) {
310
+					$localized[$_field] = $shortcodes;
311 311
 				}
312 312
 			}
313 313
 			$valid_shortcodes = $localized;
314 314
 		}
315 315
 
316 316
 		//if $merged then let's merge all the shortcodes into one list NOT indexed by field.
317
-		if ( $merged ) {
317
+		if ($merged) {
318 318
 			$merged_codes = array();
319
-			foreach ( $valid_shortcodes as $field => $shortcode ) {
320
-				foreach ( $shortcode as $code => $label ) {
321
-					if ( isset( $merged_codes[ $code ] ) ) {
319
+			foreach ($valid_shortcodes as $field => $shortcode) {
320
+				foreach ($shortcode as $code => $label) {
321
+					if (isset($merged_codes[$code])) {
322 322
 						continue;
323 323
 					} else {
324
-						$merged_codes[ $code ] = $label;
324
+						$merged_codes[$code] = $label;
325 325
 					}
326 326
 				}
327 327
 			}
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
 	 * @throws \EE_Error
342 342
 	 * @return EE_messenger
343 343
 	 */
344
-	public static function messenger_obj( $messenger ) {
344
+	public static function messenger_obj($messenger) {
345 345
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
346
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
347
-		return $Message_Resource_Manager->get_messenger( $messenger );
346
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
347
+		return $Message_Resource_Manager->get_messenger($messenger);
348 348
 	}
349 349
 
350 350
 
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 	 * @throws \EE_Error
358 358
 	 * @return EE_message_type
359 359
 	 */
360
-	public static function message_type_obj( $message_type ) {
360
+	public static function message_type_obj($message_type) {
361 361
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
362
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
363
-		return $Message_Resource_Manager->get_message_type( $message_type );
362
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
363
+		return $Message_Resource_Manager->get_message_type($message_type);
364 364
 	}
365 365
 
366 366
 
@@ -374,11 +374,11 @@  discard block
 block discarded – undo
374 374
 	 * @param  string   $message_type message type to check for.
375 375
 	 * @return boolean
376 376
 	 */
377
-	public static function is_mt_active( $message_type ) {
377
+	public static function is_mt_active($message_type) {
378 378
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
379
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
379
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
380 380
 		$active_mts = $Message_Resource_Manager->list_of_active_message_types();
381
-		return in_array( $message_type, $active_mts );
381
+		return in_array($message_type, $active_mts);
382 382
 	}
383 383
 
384 384
 
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 	 * @param  string  $messenger slug for messenger to check.
392 392
 	 * @return boolean
393 393
 	 */
394
-	public static function is_messenger_active( $messenger ) {
394
+	public static function is_messenger_active($messenger) {
395 395
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
396
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
397
-		$active_messenger = $Message_Resource_Manager->get_active_messenger( $messenger );
396
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
397
+		$active_messenger = $Message_Resource_Manager->get_active_messenger($messenger);
398 398
 		return $active_messenger instanceof EE_messenger ? true : false;
399 399
 	}
400 400
 
@@ -412,11 +412,11 @@  discard block
 block discarded – undo
412 412
 	public static function get_active_messengers_in_db() {
413 413
 		EE_Error::doing_it_wrong(
414 414
 			__METHOD__,
415
-			__( 'Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso' ),
415
+			__('Please use EE_Message_Resource_Manager::get_active_messengers_option() instead.', 'event_espresso'),
416 416
 			'4.9.0'
417 417
 		);
418 418
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
419
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
419
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
420 420
 		return $Message_Resource_Manager->get_active_messengers_option();
421 421
 	}
422 422
 
@@ -433,15 +433,15 @@  discard block
 block discarded – undo
433 433
 	 *
434 434
 	 * @return bool FALSE if not updated, TRUE if updated.
435 435
 	 */
436
-	public static function update_active_messengers_in_db( $data_to_save ) {
436
+	public static function update_active_messengers_in_db($data_to_save) {
437 437
 		EE_Error::doing_it_wrong(
438 438
 			__METHOD__,
439
-			__( 'Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso' ),
439
+			__('Please use EE_Message_Resource_Manager::update_active_messengers_option() instead.', 'event_espresso'),
440 440
 			'4.9.0'
441 441
 		);
442 442
 		/** @var EE_Message_Resource_Manager $Message_Resource_Manager */
443
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
444
-		return $Message_Resource_Manager->update_active_messengers_option( $data_to_save );
443
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
444
+		return $Message_Resource_Manager->update_active_messengers_option($data_to_save);
445 445
 	}
446 446
 
447 447
 
@@ -465,34 +465,34 @@  discard block
 block discarded – undo
465 465
 		$sending_messenger = ''
466 466
 	) {
467 467
 		//first determine if the url can be to the EE_Message object.
468
-		if ( ! $message_type->always_generate() ) {
469
-			return EEH_MSG_Template::generate_browser_trigger( $message );
468
+		if ( ! $message_type->always_generate()) {
469
+			return EEH_MSG_Template::generate_browser_trigger($message);
470 470
 		}
471 471
 
472 472
 		//if $registration object is not valid then exit early because there's nothing that can be generated.
473
-		if ( ! $registration instanceof EE_Registration ) {
473
+		if ( ! $registration instanceof EE_Registration) {
474 474
 			throw new EE_Error(
475
-				__( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' )
475
+				__('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso')
476 476
 			);
477 477
 		}
478 478
 
479 479
 		//validate given context
480 480
 		$contexts = $message_type->get_contexts();
481
-		if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) {
481
+		if ($message->context() !== '' && ! isset($contexts[$message->context()])) {
482 482
 			throw new EE_Error(
483 483
 				sprintf(
484
-					__( 'The context %s is not a valid context for %s.', 'event_espresso' ),
484
+					__('The context %s is not a valid context for %s.', 'event_espresso'),
485 485
 					$message->context(),
486
-					get_class( $message_type )
486
+					get_class($message_type)
487 487
 				)
488 488
 			);
489 489
 		}
490 490
 
491 491
 		//valid sending messenger but only if sending messenger set.  Otherwise generating messenger is used.
492
-		if ( ! empty( $sending_messenger ) ) {
492
+		if ( ! empty($sending_messenger)) {
493 493
 			$with_messengers = $message_type->with_messengers();
494
-			if ( ! isset( $with_messengers[$message->messenger()] )
495
-			     || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) {
494
+			if ( ! isset($with_messengers[$message->messenger()])
495
+			     || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) {
496 496
 				throw new EE_Error(
497 497
 					sprintf(
498 498
 						__(
@@ -500,7 +500,7 @@  discard block
 block discarded – undo
500 500
 							'event_espresso'
501 501
 						),
502 502
 						$sending_messenger,
503
-						get_class( $message_type )
503
+						get_class($message_type)
504 504
 					)
505 505
 				);
506 506
 			}
@@ -523,14 +523,14 @@  discard block
 block discarded – undo
523 523
 	 * @param EE_Message $message
524 524
 	 * @return string.
525 525
 	 */
526
-	public static function generate_browser_trigger( EE_Message $message ) {
526
+	public static function generate_browser_trigger(EE_Message $message) {
527 527
 		$query_args = array(
528 528
 			'ee' => 'msg_browser_trigger',
529 529
 			'token' => $message->MSG_token()
530 530
 		);
531 531
 		return apply_filters(
532 532
 			'FHEE__EEH_MSG_Template__generate_browser_trigger',
533
-			add_query_arg( $query_args, site_url() ),
533
+			add_query_arg($query_args, site_url()),
534 534
 			$message
535 535
 		);
536 536
 	}
@@ -545,7 +545,7 @@  discard block
 block discarded – undo
545 545
 	 * @param EE_Message $message
546 546
 	 * @return string
547 547
 	 */
548
-	public static function generate_error_display_trigger( EE_Message $message ) {
548
+	public static function generate_error_display_trigger(EE_Message $message) {
549 549
 		return apply_filters(
550 550
 			'FHEE__EEH_MSG_Template__generate_error_display_trigger',
551 551
 			add_query_arg(
@@ -595,7 +595,7 @@  discard block
 block discarded – undo
595 595
 			'GRP_ID' => $message_template_group,
596 596
 			'id' => $data_id
597 597
 			);
598
-		$url = add_query_arg( $query_args, get_site_url() );
598
+		$url = add_query_arg($query_args, get_site_url());
599 599
 
600 600
 		//made it here so now we can just get the url and filter it.  Filtered globally and by message type.
601 601
 		$url = apply_filters(
@@ -623,9 +623,9 @@  discard block
 block discarded – undo
623 623
 	 * @param string $type  What action to return.
624 624
 	 * @return string
625 625
 	 */
626
-	public static function get_message_action_icon( $type ) {
626
+	public static function get_message_action_icon($type) {
627 627
 		$action_icons = self::get_message_action_icons();
628
-		return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : '';
628
+		return isset($action_icons[$type]) ? $action_icons[$type] : '';
629 629
 	}
630 630
 
631 631
 
@@ -637,34 +637,34 @@  discard block
 block discarded – undo
637 637
 	 * @return array
638 638
 	 */
639 639
 	public static function get_message_action_icons() {
640
-		return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons',
640
+		return apply_filters('FHEE__EEH_MSG_Template__message_action_icons',
641 641
 			array(
642 642
 				'view' => array(
643
-					'label' => __( 'View Message', 'event_espresso' ),
643
+					'label' => __('View Message', 'event_espresso'),
644 644
 					'css_class' => 'dashicons dashicons-welcome-view-site',
645 645
 				),
646 646
 				'error' => array(
647
-					'label' => __( 'View Error Message', 'event_espresso' ),
647
+					'label' => __('View Error Message', 'event_espresso'),
648 648
 					'css_class' => 'dashicons dashicons-info',
649 649
 				),
650 650
 				'see_notifications_for' => array(
651
-					'label' => __( 'View Related Messages', 'event_espresso' ),
651
+					'label' => __('View Related Messages', 'event_espresso'),
652 652
 					'css_class' => 'dashicons dashicons-megaphone',
653 653
 				),
654 654
 				'generate_now' => array(
655
-					'label' => __( 'Generate the message now.', 'event_espresso' ),
655
+					'label' => __('Generate the message now.', 'event_espresso'),
656 656
 					'css_class' => 'dashicons dashicons-admin-tools',
657 657
 				),
658 658
 				'send_now' => array(
659
-					'label' => __( 'Send Immediately', 'event_espresso' ),
659
+					'label' => __('Send Immediately', 'event_espresso'),
660 660
 					'css_class' => 'dashicons dashicons-controls-forward',
661 661
 				),
662 662
 				'queue_for_resending' => array(
663
-					'label' => __( 'Queue for Resending', 'event_espresso' ),
663
+					'label' => __('Queue for Resending', 'event_espresso'),
664 664
 					'css_class' => 'dashicons dashicons-controls-repeat',
665 665
 				),
666 666
 				'view_transaction' => array(
667
-					'label' => __( 'View related Transaction', 'event_espresso' ),
667
+					'label' => __('View related Transaction', 'event_espresso'),
668 668
 					'css_class' => 'dashicons dashicons-cart',
669 669
 				)
670 670
 			)
@@ -683,9 +683,9 @@  discard block
 block discarded – undo
683 683
 	 *
684 684
 	 * @return string
685 685
 	 */
686
-	public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) {
687
-		$action_urls = self::get_message_action_urls( $message, $query_params );
688
-		return isset( $action_urls[ $type ] )  ? $action_urls[ $type ] : '';
686
+	public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) {
687
+		$action_urls = self::get_message_action_urls($message, $query_params);
688
+		return isset($action_urls[$type]) ? $action_urls[$type] : '';
689 689
 	}
690 690
 
691 691
 
@@ -700,15 +700,15 @@  discard block
 block discarded – undo
700 700
 	 *
701 701
 	 * @return array
702 702
 	 */
703
-	public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) {
704
-		EE_Registry::instance()->load_helper( 'URL' );
703
+	public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) {
704
+		EE_Registry::instance()->load_helper('URL');
705 705
 		//if $message is not an instance of EE_Message then let's just do a dummy.
706
-		$message = empty( $message ) ? EE_Message_Factory::create() : $message;
707
-		$action_urls =  apply_filters(
706
+		$message = empty($message) ? EE_Message_Factory::create() : $message;
707
+		$action_urls = apply_filters(
708 708
 			'FHEE__EEH_MSG_Template__get_message_action_url',
709 709
 			array(
710
-				'view' => EEH_MSG_Template::generate_browser_trigger( $message ),
711
-				'error' => EEH_MSG_Template::generate_error_display_trigger( $message ),
710
+				'view' => EEH_MSG_Template::generate_browser_trigger($message),
711
+				'error' => EEH_MSG_Template::generate_error_display_trigger($message),
712 712
 				'see_notifications_for' => EEH_URL::add_query_args_and_nonce(
713 713
 					array_merge(
714 714
 						array(
@@ -718,7 +718,7 @@  discard block
 block discarded – undo
718 718
 						),
719 719
 						$query_params
720 720
 					),
721
-					admin_url( 'admin.php' )
721
+					admin_url('admin.php')
722 722
 				),
723 723
 				'generate_now' => EEH_URL::add_query_args_and_nonce(
724 724
 					array(
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 						'action' => 'generate_now',
727 727
 						'MSG_ID' => $message->ID()
728 728
 					),
729
-					admin_url( 'admin.php' )
729
+					admin_url('admin.php')
730 730
 				),
731 731
 				'send_now' => EEH_URL::add_query_args_and_nonce(
732 732
 					array(
@@ -734,7 +734,7 @@  discard block
 block discarded – undo
734 734
 						'action' => 'send_now',
735 735
 						'MSG_ID' => $message->ID()
736 736
 					),
737
-					admin_url( 'admin.php' )
737
+					admin_url('admin.php')
738 738
 				),
739 739
 				'queue_for_resending' => EEH_URL::add_query_args_and_nonce(
740 740
 					array(
@@ -742,7 +742,7 @@  discard block
 block discarded – undo
742 742
 						'action' => 'queue_for_resending',
743 743
 						'MSG_ID' => $message->ID()
744 744
 					),
745
-					admin_url( 'admin.php' )
745
+					admin_url('admin.php')
746 746
 				),
747 747
 			)
748 748
 		);
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 					'action' => 'view_transaction',
761 761
 					'TXN_ID' => $message->TXN_ID()
762 762
 				),
763
-				admin_url( 'admin.php' )
763
+				admin_url('admin.php')
764 764
 			);
765 765
 		} else {
766 766
 			$action_urls['view_transaction'] = '';
@@ -781,26 +781,26 @@  discard block
 block discarded – undo
781 781
 	 *
782 782
 	 * @return string
783 783
 	 */
784
-	public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) {
785
-		$url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params );
786
-		$icon_css = EEH_MSG_Template::get_message_action_icon( $type );
787
-		$title = isset( $icon_css['label'] ) ? 'title="' . $icon_css['label'] . '"' : '';
784
+	public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) {
785
+		$url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params);
786
+		$icon_css = EEH_MSG_Template::get_message_action_icon($type);
787
+		$title = isset($icon_css['label']) ? 'title="'.$icon_css['label'].'"' : '';
788 788
 
789
-		if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) {
789
+		if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) {
790 790
 			return '';
791 791
 		}
792 792
 
793 793
 		$icon_css['css_class'] .= esc_attr(
794 794
 			apply_filters(
795 795
 				'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class',
796
-				' js-ee-message-action-link ee-message-action-link-' . $type,
796
+				' js-ee-message-action-link ee-message-action-link-'.$type,
797 797
 				$type,
798 798
 				$message,
799 799
 				$query_params
800 800
 			)
801 801
 		);
802 802
 
803
-		return '<a href="' . $url . '"' . $title . '><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>';
803
+		return '<a href="'.$url.'"'.$title.'><span class="'.esc_attr($icon_css['css_class']).'"></span></a>';
804 804
 
805 805
 	}
806 806
 
@@ -838,9 +838,9 @@  discard block
 block discarded – undo
838 838
 	 * @param $reg_status
839 839
 	 * @return string
840 840
 	 */
841
-	public static function convert_reg_status_to_message_type( $reg_status ) {
841
+	public static function convert_reg_status_to_message_type($reg_status) {
842 842
 		$reg_status_array = self::reg_status_to_message_type_array();
843
-		return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : '';
843
+		return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : '';
844 844
 	}
845 845
 
846 846
 
@@ -874,9 +874,9 @@  discard block
 block discarded – undo
874 874
 	 * @param $payment_status
875 875
 	 * @return string
876 876
 	 */
877
-	public static function convert_payment_status_to_message_type( $payment_status ) {
877
+	public static function convert_payment_status_to_message_type($payment_status) {
878 878
 		$payment_status_array = self::payment_status_to_message_type_array();
879
-		return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : '';
879
+		return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : '';
880 880
 	}
881 881
 
882 882
 
@@ -887,32 +887,32 @@  discard block
 block discarded – undo
887 887
 	 *
888 888
 	 * @return EE_Messages_Template_Pack
889 889
 	 */
890
-	public static function get_template_pack( $template_pack_name ) {
891
-		if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) {
890
+	public static function get_template_pack($template_pack_name) {
891
+		if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) {
892 892
 			self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection();
893 893
 		}
894 894
 
895 895
 		//first see if in collection already
896
-		$template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name );
896
+		$template_pack = self::$_template_pack_collection->get_by_name($template_pack_name);
897 897
 
898
-		if ( $template_pack instanceof EE_Messages_Template_Pack ) {
898
+		if ($template_pack instanceof EE_Messages_Template_Pack) {
899 899
 			return $template_pack;
900 900
 		}
901 901
 
902 902
 		//nope...let's get it.
903 903
 		//not set yet so let's attempt to get it.
904
-		$pack_class_name = 'EE_Messages_Template_Pack_' . str_replace(
904
+		$pack_class_name = 'EE_Messages_Template_Pack_'.str_replace(
905 905
 				' ',
906 906
 				'_',
907 907
 				ucwords(
908
-					str_replace( '_', ' ', $template_pack_name )
908
+					str_replace('_', ' ', $template_pack_name)
909 909
 				)
910 910
 			);
911
-		if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) {
912
-			return self::get_template_pack( 'default' );
911
+		if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') {
912
+			return self::get_template_pack('default');
913 913
 		} else {
914 914
 			$template_pack = new $pack_class_name;
915
-			self::$_template_pack_collection->add( $template_pack );
915
+			self::$_template_pack_collection->add($template_pack);
916 916
 			return $template_pack;
917 917
 		}
918 918
 	}
@@ -930,26 +930,26 @@  discard block
 block discarded – undo
930 930
 	 */
931 931
 	public static function get_template_pack_collection() {
932 932
 		$new_collection = false;
933
-		if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) {
933
+		if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) {
934 934
 			self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection();
935 935
 			$new_collection = true;
936 936
 		}
937 937
 
938 938
 		//glob the defaults directory for messages
939
-		$templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR );
940
-		foreach( $templates as $template_path ) {
939
+		$templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR);
940
+		foreach ($templates as $template_path) {
941 941
 			//grab folder name
942
-			$template = basename( $template_path );
942
+			$template = basename($template_path);
943 943
 
944
-			if ( ! $new_collection ) {
944
+			if ( ! $new_collection) {
945 945
 				//already have it?
946
-				if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) {
946
+				if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) {
947 947
 					continue;
948 948
 				}
949 949
 			}
950 950
 
951 951
 			//setup classname.
952
-			$template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace(
952
+			$template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace(
953 953
 					' ',
954 954
 					'_',
955 955
 					ucwords(
@@ -960,20 +960,20 @@  discard block
 block discarded – undo
960 960
 						)
961 961
 					)
962 962
 				);
963
-			if ( ! class_exists( $template_pack_class_name ) ) {
963
+			if ( ! class_exists($template_pack_class_name)) {
964 964
 				continue;
965 965
 			}
966
-			self::$_template_pack_collection->add( new $template_pack_class_name );
966
+			self::$_template_pack_collection->add(new $template_pack_class_name);
967 967
 		}
968 968
 
969 969
 		/**
970 970
 		 * Filter for plugins to add in any additional template packs
971 971
 		 * Note the filter name here is for backward compat, this used to be found in EED_Messages.
972 972
 		 */
973
-		$additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() );
974
-		foreach ( (array) $additional_template_packs as $template_pack ) {
975
-			if ( ! self::$_template_pack_collection->contains($template_pack ) ) {
976
-				self::$_template_pack_collection->add( $template_pack );
973
+		$additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array());
974
+		foreach ((array) $additional_template_packs as $template_pack) {
975
+			if ( ! self::$_template_pack_collection->contains($template_pack)) {
976
+				self::$_template_pack_collection->add($template_pack);
977 977
 			}
978 978
 		}
979 979
 		return self::$_template_pack_collection;
@@ -991,16 +991,16 @@  discard block
 block discarded – undo
991 991
 	 * @return array
992 992
 	 * @throws \EE_Error
993 993
 	 */
994
-	public static function create_new_templates( $messenger_name, $message_type_name, $GRP_ID = 0, $global = false ) {
994
+	public static function create_new_templates($messenger_name, $message_type_name, $GRP_ID = 0, $global = false) {
995 995
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
996
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
997
-		$messenger = $Message_Resource_Manager->valid_messenger( $messenger_name );
998
-		$message_type = $Message_Resource_Manager->valid_message_type( $message_type_name );
999
-		if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type, $global ) ) {
996
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
997
+		$messenger = $Message_Resource_Manager->valid_messenger($messenger_name);
998
+		$message_type = $Message_Resource_Manager->valid_message_type($message_type_name);
999
+		if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type, $global)) {
1000 1000
 			return array();
1001 1001
 		}
1002 1002
 		//whew made it this far!  Okay, let's go ahead and create the templates then
1003
-		return EEH_MSG_Template::_create_new_templates( $messenger, $message_type, $GRP_ID, $global );
1003
+		return EEH_MSG_Template::_create_new_templates($messenger, $message_type, $GRP_ID, $global);
1004 1004
 	}
1005 1005
 
1006 1006
 
@@ -1012,15 +1012,15 @@  discard block
 block discarded – undo
1012 1012
 	 * @param                  $global
1013 1013
 	 * @return array|mixed
1014 1014
 	 */
1015
-	protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) {
1015
+	protected static function _create_new_templates(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global) {
1016 1016
 		//if we're creating a custom template then we don't need to use the defaults class
1017
-		if ( ! $global ) {
1018
-			return EEH_MSG_Template::_create_custom_template_group( $messenger, $message_type, $GRP_ID );
1017
+		if ( ! $global) {
1018
+			return EEH_MSG_Template::_create_custom_template_group($messenger, $message_type, $GRP_ID);
1019 1019
 		}
1020 1020
 		/** @type EE_Messages_Template_Defaults $Message_Template_Defaults */
1021 1021
 		$Message_Template_Defaults = EE_Registry::factory(
1022 1022
 			'EE_Messages_Template_Defaults',
1023
-			array( $messenger, $message_type, $GRP_ID )
1023
+			array($messenger, $message_type, $GRP_ID)
1024 1024
 		);
1025 1025
 		//generate templates
1026 1026
 		$success = $Message_Template_Defaults->create_new_templates();
@@ -1028,10 +1028,10 @@  discard block
 block discarded – undo
1028 1028
 		//if creating the template failed.  Then we should deactivate the related message_type for the messenger because
1029 1029
 		//its not active if it doesn't have a template.  Note this is only happening for GLOBAL template creation
1030 1030
 		//attempts.
1031
-		if ( ! $success ) {
1031
+		if ( ! $success) {
1032 1032
 			/** @var EE_Message_Resource_Manager $message_resource_manager */
1033
-			$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
1034
-			$message_resource_manager->deactivate_message_type_for_messenger( $message_type->name, $messenger->name );
1033
+			$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1034
+			$message_resource_manager->deactivate_message_type_for_messenger($message_type->name, $messenger->name);
1035 1035
 		}
1036 1036
 
1037 1037
 		/**
@@ -1059,11 +1059,11 @@  discard block
 block discarded – undo
1059 1059
 	 * 										)
1060 1060
 	 * @access private
1061 1061
 	 */
1062
-	private static function _create_custom_template_group( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID ) {
1062
+	private static function _create_custom_template_group(EE_messenger $messenger, EE_message_type $message_type, $GRP_ID) {
1063 1063
 		//defaults
1064
-		$success = array( 'GRP_ID' => null, 'MTP_context' => '' );
1064
+		$success = array('GRP_ID' => null, 'MTP_context' => '');
1065 1065
 		//get the template group to use as a template from the db.  If $GRP_ID is empty then we'll assume the base will be the global template matching the messenger and message type.
1066
-		$Message_Template_Group = empty( $GRP_ID )
1066
+		$Message_Template_Group = empty($GRP_ID)
1067 1067
 			? EEM_Message_Template_Group::instance()->get_one(
1068 1068
 				array(
1069 1069
 					array(
@@ -1073,9 +1073,9 @@  discard block
 block discarded – undo
1073 1073
 					)
1074 1074
 				)
1075 1075
 			)
1076
-			: EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1076
+			: EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1077 1077
 		//if we don't have a mtg at this point then we need to bail.
1078
-		if ( ! $Message_Template_Group instanceof EE_Message_Template_Group ) {
1078
+		if ( ! $Message_Template_Group instanceof EE_Message_Template_Group) {
1079 1079
 			EE_Error::add_error(
1080 1080
 				sprintf(
1081 1081
 					__(
@@ -1094,42 +1094,42 @@  discard block
 block discarded – undo
1094 1094
 		$message_templates = $Message_Template_Group->message_templates();
1095 1095
 		//now we have what we need to setup the new template
1096 1096
 		$new_mtg = clone $Message_Template_Group;
1097
-		$new_mtg->set( 'GRP_ID', 0 );
1098
-		$new_mtg->set( 'MTP_is_global', false );
1099
-		$template_name = defined( 'DOING_AJAX' ) && ! empty( $_POST[ 'templateName' ] )
1100
-			? $_POST[ 'templateName' ]
1097
+		$new_mtg->set('GRP_ID', 0);
1098
+		$new_mtg->set('MTP_is_global', false);
1099
+		$template_name = defined('DOING_AJAX') && ! empty($_POST['templateName'])
1100
+			? $_POST['templateName']
1101 1101
 			: __(
1102 1102
 				'New Custom Template',
1103 1103
 				'event_espresso'
1104 1104
 			);
1105
-		$template_description = defined( "DOING_AJAX" ) && ! empty( $_POST[ 'templateDescription' ] )
1106
-			? $_POST[ 'templateDescription' ]
1105
+		$template_description = defined("DOING_AJAX") && ! empty($_POST['templateDescription'])
1106
+			? $_POST['templateDescription']
1107 1107
 			: sprintf(
1108 1108
 				__(
1109 1109
 					'This is a custom template that was created for the %s messenger and %s message type.',
1110 1110
 					'event_espresso'
1111 1111
 				),
1112
-				$new_mtg->messenger_obj()->label[ 'singular' ],
1113
-				$new_mtg->message_type_obj()->label[ 'singular' ]
1112
+				$new_mtg->messenger_obj()->label['singular'],
1113
+				$new_mtg->message_type_obj()->label['singular']
1114 1114
 			);
1115
-		$new_mtg->set( 'MTP_name', $template_name );
1116
-		$new_mtg->set( 'MTP_description', $template_description );
1115
+		$new_mtg->set('MTP_name', $template_name);
1116
+		$new_mtg->set('MTP_description', $template_description);
1117 1117
 		//remove ALL relations on this template group so they don't get saved!
1118
-		$new_mtg->_remove_relations( 'Message_Template' );
1118
+		$new_mtg->_remove_relations('Message_Template');
1119 1119
 		$new_mtg->save();
1120
-		$success[ 'GRP_ID' ] = $new_mtg->ID();
1121
-		$success[ 'template_name' ] = $template_name;
1120
+		$success['GRP_ID'] = $new_mtg->ID();
1121
+		$success['template_name'] = $template_name;
1122 1122
 		//add new message templates and add relation to.
1123
-		foreach ( $message_templates as $message_template ) {
1124
-			if ( ! $message_template instanceof EE_Message_Template ) {
1123
+		foreach ($message_templates as $message_template) {
1124
+			if ( ! $message_template instanceof EE_Message_Template) {
1125 1125
 				continue;
1126 1126
 			}
1127 1127
 			$new_message_template = clone $message_template;
1128
-			$new_message_template->set( 'MTP_ID', 0 );
1129
-			$new_message_template->set( 'GRP_ID', $new_mtg->ID() ); //relation
1128
+			$new_message_template->set('MTP_ID', 0);
1129
+			$new_message_template->set('GRP_ID', $new_mtg->ID()); //relation
1130 1130
 			$new_message_template->save();
1131
-			if ( empty( $success[ 'MTP_context' ] ) ) {
1132
-				$success[ 'MTP_context' ] = $new_message_template->get( 'MTP_context' );
1131
+			if (empty($success['MTP_context'])) {
1132
+				$success['MTP_context'] = $new_message_template->get('MTP_context');
1133 1133
 			}
1134 1134
 		}
1135 1135
 		return $success;
@@ -1151,7 +1151,7 @@  discard block
 block discarded – undo
1151 1151
 		$global = false
1152 1152
 	) {
1153 1153
 		//is given message_type valid for given messenger (if this is not a global save)
1154
-		if ( $global ) {
1154
+		if ($global) {
1155 1155
 			return true;
1156 1156
 		}
1157 1157
 		$active_templates = EEM_Message_Template_Group::instance()->count(
@@ -1163,7 +1163,7 @@  discard block
 block discarded – undo
1163 1163
 				)
1164 1164
 			)
1165 1165
 		);
1166
-		if ( $active_templates > 0 ) {
1166
+		if ($active_templates > 0) {
1167 1167
 			return true;
1168 1168
 		}
1169 1169
 		EE_Error::add_error(
@@ -1192,24 +1192,24 @@  discard block
 block discarded – undo
1192 1192
 	 * @param  string $message_type_name name of EE_message_type
1193 1193
 	 * @return array
1194 1194
 	 */
1195
-	public static function get_fields( $messenger_name, $message_type_name ) {
1195
+	public static function get_fields($messenger_name, $message_type_name) {
1196 1196
 		$template_fields = array();
1197 1197
 		/** @type EE_Message_Resource_Manager $Message_Resource_Manager */
1198
-		$Message_Resource_Manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
1199
-		$messenger = $Message_Resource_Manager->valid_messenger( $messenger_name );
1200
-		$message_type = $Message_Resource_Manager->valid_message_type( $message_type_name );
1201
-		if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger( $messenger, $message_type ) ) {
1198
+		$Message_Resource_Manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1199
+		$messenger = $Message_Resource_Manager->valid_messenger($messenger_name);
1200
+		$message_type = $Message_Resource_Manager->valid_message_type($message_type_name);
1201
+		if ( ! EEH_MSG_Template::message_type_has_active_templates_for_messenger($messenger, $message_type)) {
1202 1202
 			return array();
1203 1203
 		}
1204 1204
 		//okay now let's assemble an array with the messenger template fields added to the message_type contexts.
1205
-		foreach ( $message_type->get_contexts() as $context => $details ) {
1206
-			foreach ( $messenger->get_template_fields() as $field => $value ) {
1207
-				$template_fields[ $context ][ $field ] = $value;
1205
+		foreach ($message_type->get_contexts() as $context => $details) {
1206
+			foreach ($messenger->get_template_fields() as $field => $value) {
1207
+				$template_fields[$context][$field] = $value;
1208 1208
 			}
1209 1209
 		}
1210
-		if ( empty( $template_fields ) ) {
1210
+		if (empty($template_fields)) {
1211 1211
 			EE_Error::add_error(
1212
-				__( 'Something went wrong and we couldn\'t get any templates assembled', 'event_espresso' ),
1212
+				__('Something went wrong and we couldn\'t get any templates assembled', 'event_espresso'),
1213 1213
 				__FILE__,
1214 1214
 				__FUNCTION__,
1215 1215
 				__LINE__
Please login to merge, or discard this patch.
Doc Comments   +4 added lines, -3 removed lines patch added patch discarded remove patch
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
 	 * Updates all message templates matching the incoming messengers and message types to active status.
144 144
 	 *
145 145
 	 * @static
146
-	 * @param  array  $messenger_names     Messenger slug
146
+	 * @param  string[]  $messenger_names     Messenger slug
147 147
 	 * @param  array  $message_type_names  Message type slug
148 148
 	 * @return  int 						count of updated records.
149 149
 	 */
@@ -454,6 +454,7 @@  discard block
 block discarded – undo
454 454
 	 * @param EE_Registration | null $registration  The registration object must be included if this
455 455
 	 *                                              is going to be a registration trigger url.
456 456
 	 * @param string $sending_messenger             The (optional) sending messenger for the url.
457
+	 * @param EE_Registration $registration
457 458
 	 *
458 459
 	 * @return string
459 460
 	 * @throws EE_Error
@@ -1008,8 +1009,8 @@  discard block
 block discarded – undo
1008 1009
 	/**
1009 1010
 	 * @param \EE_messenger    $messenger
1010 1011
 	 * @param \EE_message_type $message_type
1011
-	 * @param                  $GRP_ID
1012
-	 * @param                  $global
1012
+	 * @param                  integer $GRP_ID
1013
+	 * @param                  boolean $global
1013 1014
 	 * @return array|mixed
1014 1015
 	 */
1015 1016
 	protected static function _create_new_templates( EE_messenger $messenger, EE_message_type $message_type, $GRP_ID, $global ) {
Please login to merge, or discard this patch.