Completed
Branch FET-9046-messages-queue (ac2959)
by
unknown
635:08 queued 618:09
created
admin/extend/messages/espresso_events_Messages_Hooks_Extend.class.php 1 patch
Spacing   +41 added lines, -41 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
 /**
@@ -22,21 +22,21 @@  discard block
 block discarded – undo
22 22
 	 *
23 23
 	 * @param \EE_Admin_Page $admin_page
24 24
 	 */
25
-	public function __construct( EE_Admin_Page $admin_page ) {
25
+	public function __construct(EE_Admin_Page $admin_page) {
26 26
 		/**
27 27
 		 * Add cap restriction ... metaboxes should not show if user does not have the ability to edit_custom_messages
28 28
 		 */
29 29
 		if (
30
-			! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'messages_events_editor_metabox' )
30
+			! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'messages_events_editor_metabox')
31 31
 		) {
32 32
 			return;
33 33
 		}
34 34
 		add_filter(
35 35
 			'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks',
36
-			array( $this, 'caf_updates' ),
36
+			array($this, 'caf_updates'),
37 37
 			10
38 38
 		);
39
-		parent::__construct( $admin_page );
39
+		parent::__construct($admin_page);
40 40
 	}
41 41
 
42 42
 
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 	 */
50 50
 	protected function _extend_properties() {
51 51
 
52
-		define( 'EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'messages/assets/' );
52
+		define('EE_MSGS_EXTEND_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'messages/assets/');
53 53
 		$this->_ajax_func = array(
54 54
 			'ee_msgs_create_new_custom' => 'create_new_custom'
55 55
 			);
56 56
 		$this->_metaboxes = array(
57 57
 			0 => array(
58
-				'page_route' => array('edit','create_new'),
58
+				'page_route' => array('edit', 'create_new'),
59 59
 				'func' => 'messages_metabox',
60 60
 				'label' => __('Notifications', 'event_espresso'),
61 61
 				'priority' => 'high'
@@ -66,11 +66,11 @@  discard block
 block discarded – undo
66 66
 		$this->_scripts_styles = array(
67 67
 			'registers' => array(
68 68
 				'events_msg_admin' => array(
69
-					'url' => EE_MSGS_EXTEND_ASSETS_URL . 'events_messages_admin.js',
69
+					'url' => EE_MSGS_EXTEND_ASSETS_URL.'events_messages_admin.js',
70 70
 					'depends' => array('ee-dialog', 'ee-parse-uri', 'ee-serialize-full-array')
71 71
 				),
72 72
 				'events_msg_admin_css' => array(
73
-					'url' => EE_MSGS_EXTEND_ASSETS_URL . 'ee_msg_events_admin.css',
73
+					'url' => EE_MSGS_EXTEND_ASSETS_URL.'ee_msg_events_admin.css',
74 74
 					'type' => 'css'
75 75
 				)
76 76
 			),
@@ -82,8 +82,8 @@  discard block
 block discarded – undo
82 82
 	}
83 83
 
84 84
 
85
-	public function caf_updates( $update_callbacks ) {
86
-		$update_callbacks[] = array( $this, 'attach_evt_message_templates' );
85
+	public function caf_updates($update_callbacks) {
86
+		$update_callbacks[] = array($this, 'attach_evt_message_templates');
87 87
 		return $update_callbacks;
88 88
 	}
89 89
 
@@ -97,12 +97,12 @@  discard block
 block discarded – undo
97 97
 	 * @param  array    $data   The request data from the form
98 98
 	 * @return bool     		success or fail
99 99
 	 */
100
-	public function attach_evt_message_templates( $event, $data ) {
100
+	public function attach_evt_message_templates($event, $data) {
101 101
 		//first we remove all existing relations on the Event for message types.
102 102
 		$event->_remove_relations('Message_Template_Group');
103 103
 		//now let's just loop through the selected templates and add relations!
104
-		foreach( $data['event_message_templates_relation'] as $grp_ID ) {
105
-			$event->_add_relation_to( $grp_ID, 'Message_Template_Group' );
104
+		foreach ($data['event_message_templates_relation'] as $grp_ID) {
105
+			$event->_add_relation_to($grp_ID, 'Message_Template_Group');
106 106
 		}
107 107
 		//now save
108 108
 		return $event->save();
@@ -116,25 +116,25 @@  discard block
 block discarded – undo
116 116
 	 * @return string
117 117
 	 * @throws \EE_Error
118 118
 	 */
119
-	public function messages_metabox( $event, $callback_args ) {
119
+	public function messages_metabox($event, $callback_args) {
120 120
 		//let's get the active messengers (b/c messenger objects have the active message templates)
121 121
 		//convert 'evt_id' to 'EVT_ID'
122
-		$this->_req_data['EVT_ID'] = isset( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : NULL;
123
-		$this->_req_data['EVT_ID'] = isset( $this->_req_data['post'] ) && empty( $this->_req_data['EVT_ID'] )
122
+		$this->_req_data['EVT_ID'] = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL;
123
+		$this->_req_data['EVT_ID'] = isset($this->_req_data['post']) && empty($this->_req_data['EVT_ID'])
124 124
 			? $this->_req_data['post']
125 125
 			: $this->_req_data['EVT_ID'];
126 126
 
127
-		$this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID'] ) && isset($this->_req_data['evt_id'] )
127
+		$this->_req_data['EVT_ID'] = empty($this->_req_data['EVT_ID']) && isset($this->_req_data['evt_id'])
128 128
 			? $this->_req_data['evt_id']
129 129
 			: $this->_req_data['EVT_ID'];
130 130
 		/** @type EE_Messages $messages_controller */
131
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
131
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
132 132
 		$active_messengers = $messages_controller->get_active_messengers();
133 133
 		$tabs = array();
134 134
 
135 135
 		//empty messengers?
136 136
 		//Note message types will always have at least one available because every messenger has a default message type associated with it (payment) if no other message types are selected.
137
-		if ( empty( $active_messengers ) ) {
137
+		if (empty($active_messengers)) {
138 138
 			$msg_activate_url = EE_Admin_Page::add_query_args_and_nonce(
139 139
 				array('action' => 'settings'),
140 140
 				EE_MSG_ADMIN_URL
@@ -143,11 +143,11 @@  discard block
 block discarded – undo
143 143
 				__('There are no active messengers. So no notifications will go out for %1$sany%2$s events.  You will want to %3$sActivate a Messenger%4$s.', 'event_espresso'),
144 144
 				'<strong>',
145 145
 				'</strong>',
146
-				'<a href="' . $msg_activate_url . '">',
146
+				'<a href="'.$msg_activate_url.'">',
147 147
 				'</a>'
148 148
 			);
149
-			$error_content = '<div class="error"><p>' . $error_msg . '</p></div>';
150
-			$internal_content = '<div id="messages-error"><p>' . $error_msg . '</p></div>';
149
+			$error_content = '<div class="error"><p>'.$error_msg.'</p></div>';
150
+			$internal_content = '<div id="messages-error"><p>'.$error_msg.'</p></div>';
151 151
 
152 152
 			echo $error_content;
153 153
 			echo $internal_content;
@@ -156,45 +156,45 @@  discard block
 block discarded – undo
156 156
 
157 157
 		$event_id = isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL;
158 158
 		//get content for active messengers
159
-		foreach ( $active_messengers as $name => $messenger ) {
159
+		foreach ($active_messengers as $name => $messenger) {
160 160
 			//first check if there are any active message types for this messenger.
161
-			$active_mts = $messages_controller->get_active_message_types_per_messenger( $name );
162
-			if ( empty( $active_mts ) ) {
161
+			$active_mts = $messages_controller->get_active_message_types_per_messenger($name);
162
+			if (empty($active_mts)) {
163 163
 				continue;
164 164
 			}
165 165
 
166 166
 			$tab_content = $messenger->get_messenger_admin_page_content(
167 167
 				'events',
168 168
 				'edit',
169
-				array( 'event' => $event_id )
169
+				array('event' => $event_id)
170 170
 			);
171 171
 
172
-			if ( ! empty( $tab_content ) ) {
172
+			if ( ! empty($tab_content)) {
173 173
 				$tabs[$name] = $tab_content;
174 174
 			}
175 175
 		}
176 176
 
177 177
 
178
-		EE_Registry::instance()->load_helper( 'Tabbed_Content' );
178
+		EE_Registry::instance()->load_helper('Tabbed_Content');
179 179
 		//we want this to be tabbed content so let's use the EEH_Tabbed_Content::display helper.
180 180
 		$tabbed_content = EEH_Tabbed_Content::display($tabs);
181
-		if ( $tabbed_content instanceof WP_Error ) {
181
+		if ($tabbed_content instanceof WP_Error) {
182 182
 			$tabbed_content = $tabbed_content->get_error_message();
183 183
 		}
184 184
 
185 185
 		$notices = '
186 186
 	<div id="espresso-ajax-loading" class="ajax-loader-grey">
187
-		<span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso') . '</span>
187
+		<span class="ee-spinner ee-spin"></span><span class="hidden">' . __('loading...', 'event_espresso').'</span>
188 188
 	</div>
189 189
 	<div class="ee-notices"></div>';
190 190
 
191
-		if ( defined('DOING_AJAX' ) ) {
191
+		if (defined('DOING_AJAX')) {
192 192
 			return $tabbed_content;
193 193
 		}
194 194
 
195
-		do_action( 'AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content' );
196
-		echo $notices . '<div class="messages-tabs-content">' . $tabbed_content . '</div>';
197
-		do_action( 'AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content' );
195
+		do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__before_content');
196
+		echo $notices.'<div class="messages-tabs-content">'.$tabbed_content.'</div>';
197
+		do_action('AHEE__espresso_events_Messages_Hooks_Extend__messages_metabox__after_content');
198 198
 
199 199
 	}
200 200
 
@@ -209,15 +209,15 @@  discard block
 block discarded – undo
209 209
 	 */
210 210
 	public function create_new_custom() {
211 211
 
212
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'create_new_custom_ajax' ) ) {
213
-			wp_die( __('You don\'t have privileges to do this action', 'event_espresso' ) );
212
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'create_new_custom_ajax')) {
213
+			wp_die(__('You don\'t have privileges to do this action', 'event_espresso'));
214 214
 		}
215 215
 
216 216
 		//let's clean up the _POST global a bit for downstream usage of name and description.
217
-		$_POST['templateName'] = !empty( $this->_req_data['custom_template_args']['MTP_name'] )
217
+		$_POST['templateName'] = ! empty($this->_req_data['custom_template_args']['MTP_name'])
218 218
 			? $this->_req_data['custom_template_args']['MTP_name']
219 219
 			: '';
220
-		$_POST['templateDescription'] = !empty( $this->_req_data['custom_template_args']['MTP_description'] )
220
+		$_POST['templateDescription'] = ! empty($this->_req_data['custom_template_args']['MTP_description'])
221 221
 			? $this->_req_data['custom_template_args']['MTP_description']
222 222
 			: '';
223 223
 
@@ -226,7 +226,7 @@  discard block
 block discarded – undo
226 226
 		$this->_set_page_object();
227 227
 
228 228
 		// is this a template switch if so EE_Admin_Page child needs this object
229
-		$this->_page_object->set_hook_object( $this );
229
+		$this->_page_object->set_hook_object($this);
230 230
 
231 231
 		$this->_page_object->add_message_template(
232 232
 			$this->_req_data['messageType'],
@@ -250,7 +250,7 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function edit_admin_footer() {
252 252
 		EEH_Template::display_template(
253
-			EE_CORE_CAF_ADMIN_EXTEND . 'messages/templates/create_custom_template_form.template.php'
253
+			EE_CORE_CAF_ADMIN_EXTEND.'messages/templates/create_custom_template_form.template.php'
254 254
 		);
255 255
 	}
256 256
 
Please login to merge, or discard this patch.
admin_pages/registrations/Registrations_Admin_Page.core.php 1 patch
Spacing   +511 added lines, -511 removed lines patch added patch discarded remove patch
@@ -42,8 +42,8 @@  discard block
 block discarded – undo
42 42
 	 * @param bool $routing
43 43
 	 * @return Registrations_Admin_Page
44 44
 	 */
45
-	public function __construct( $routing = TRUE ) {
46
-		parent::__construct( $routing );
45
+	public function __construct($routing = TRUE) {
46
+		parent::__construct($routing);
47 47
 	}
48 48
 
49 49
 
@@ -75,16 +75,16 @@  discard block
 block discarded – undo
75 75
 				'trash' => 'post.php'
76 76
 			);
77 77
 
78
-		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10 );
78
+		add_action('edit_form_after_title', array($this, 'after_title_form_fields'), 10);
79 79
 		//add filters so that the comment urls don't take users to a confusing 404 page
80
-		add_filter('get_comment_link', array( $this, 'clear_comment_link' ), 10, 3 );
80
+		add_filter('get_comment_link', array($this, 'clear_comment_link'), 10, 3);
81 81
 	}
82 82
 
83 83
 
84
-	public function clear_comment_link( $link, $comment, $args ) {
84
+	public function clear_comment_link($link, $comment, $args) {
85 85
 		//gotta make sure this only happens on this route
86
-		$post_type = get_post_type( $comment->comment_post_ID);
87
-		if ( $post_type == 'espresso_attendees' )
86
+		$post_type = get_post_type($comment->comment_post_ID);
87
+		if ($post_type == 'espresso_attendees')
88 88
 			return '#commentsdiv';
89 89
 		return $link;
90 90
 	}
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
 
93 93
 	protected function _ajax_hooks() {
94 94
 		//todo: all hooks for registrations ajax goes in here
95
-		add_action( 'wp_ajax_toggle_checkin_status', array( $this, 'toggle_checkin_status' ));
95
+		add_action('wp_ajax_toggle_checkin_status', array($this, 'toggle_checkin_status'));
96 96
 	}
97 97
 
98 98
 
@@ -107,8 +107,8 @@  discard block
 block discarded – undo
107 107
 					'add-attendee' => __('Add Contact', 'event_espresso'),
108 108
 					'edit' => __('Edit Contact', 'event_espresso'),
109 109
 					'report'=>  __("Event Registrations CSV Report", "event_espresso"),
110
-					'report_all' => __( 'All Registrations CSV Report', 'event_espresso' ),
111
-					'contact_list_report' => __( 'Contact List Report', 'event_espresso' ),
110
+					'report_all' => __('All Registrations CSV Report', 'event_espresso'),
111
+					'contact_list_report' => __('Contact List Report', 'event_espresso'),
112 112
 					'contact_list_export'=>  __("Export Data", "event_espresso"),
113 113
 				),
114 114
 			'publishbox' => array(
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
 
137 137
 		$this->_get_registration_status_array();
138 138
 
139
-		$reg_id = ! empty( $this->_req_data['_REG_ID'] ) && ! is_array( $this->_req_data['_REG_ID'] ) ? $this->_req_data['_REG_ID'] : 0;
140
-		$att_id = ! empty( $this->_req_data[ 'ATT_ID' ] ) && ! is_array( $this->_req_data['ATT_ID'] ) ? $this->_req_data['ATT_ID'] : 0;
141
-		$att_id = ! empty( $this->_req_data['post'] ) && ! is_array( $this->_req_data['post'] ) ? $this->_req_data['post'] : $att_id;
139
+		$reg_id = ! empty($this->_req_data['_REG_ID']) && ! is_array($this->_req_data['_REG_ID']) ? $this->_req_data['_REG_ID'] : 0;
140
+		$att_id = ! empty($this->_req_data['ATT_ID']) && ! is_array($this->_req_data['ATT_ID']) ? $this->_req_data['ATT_ID'] : 0;
141
+		$att_id = ! empty($this->_req_data['post']) && ! is_array($this->_req_data['post']) ? $this->_req_data['post'] : $att_id;
142 142
 
143 143
 		$this->_page_routes = array(
144 144
 
@@ -155,7 +155,7 @@  discard block
 block discarded – undo
155 155
 
156 156
 				'edit_registration'	=> array(
157 157
 						'func' => '_registration_details',
158
-						'args' => array( 'edit' ),
158
+						'args' => array('edit'),
159 159
 						'noheader' => TRUE,
160 160
 						'capability' => 'ee_edit_registration',
161 161
 						'obj_id' => $reg_id
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 
171 171
 				'restore_registrations' => array(
172 172
 					'func' => '_trash_or_restore_registrations',
173
-					'args' => array( 'trash' => FALSE ),
173
+					'args' => array('trash' => FALSE),
174 174
 					'noheader' => TRUE,
175 175
 					'capability' => 'ee_delete_registrations'
176 176
 					),
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
 						'filename' => 'registrations_overview_other'
405 405
 					)
406 406
                 ),
407
-				'help_tour' => array( 'Registration_Overview_Help_Tour' ),
407
+				'help_tour' => array('Registration_Overview_Help_Tour'),
408 408
 				'qtips' => array('Registration_List_Table_Tips'),
409 409
 				'list_table' => 'EE_Registrations_List_Table',
410 410
 				'require_nonce' => FALSE
@@ -414,7 +414,7 @@  discard block
 block discarded – undo
414 414
 				'nav' => array(
415 415
 					'label' => __('REG Details', 'event_espresso'),
416 416
 					'order' => 15,
417
-					'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url,
417
+					'url' => isset($this->_req_data['_REG_ID']) ? add_query_arg(array('_REG_ID' => $this->_req_data['_REG_ID']), $this->_current_page_view_url) : $this->_admin_base_url,
418 418
 					'persistent' => FALSE
419 419
 					),
420 420
                 'help_tabs' => array(
@@ -435,8 +435,8 @@  discard block
 block discarded – undo
435 435
 						'filename' => 'registrations_details_registrant_details'
436 436
 						)
437 437
 					),
438
-				'help_tour' => array( 'Registration_Details_Help_Tour' ),
439
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_registration_details_metaboxes' ) ),
438
+				'help_tour' => array('Registration_Details_Help_Tour'),
439
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_registration_details_metaboxes')),
440 440
 				'require_nonce' => FALSE
441 441
 				),
442 442
 
@@ -460,7 +460,7 @@  discard block
 block discarded – undo
460 460
 					'order' => 15,
461 461
 					'persistent' => FALSE
462 462
 					),
463
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes' ) ),
463
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box', 'attendee_editor_metaboxes')),
464 464
 				'require_nonce' => FALSE
465 465
 				),
466 466
 
@@ -469,7 +469,7 @@  discard block
 block discarded – undo
469 469
 					'label' => __('Edit Contact', 'event_espresso'),
470 470
 					'order' => 15,
471 471
 					'persistent' => FALSE,
472
-					'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
472
+					'url' => isset($this->_req_data['ATT_ID']) ? add_query_arg(array('ATT_ID' => $this->_req_data['ATT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
473 473
 					),
474 474
 				'metaboxes' => array('attendee_editor_metaboxes'),
475 475
 				'require_nonce' => FALSE
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 						'filename' => 'registrations_contact_list_other'
500 500
 					)
501 501
                 ),
502
-				'help_tour' => array( 'Contact_List_Help_Tour' ),
502
+				'help_tour' => array('Contact_List_Help_Tour'),
503 503
 				'metaboxes' => array(),
504 504
 				'require_nonce' => FALSE
505 505
 				),
@@ -518,7 +518,7 @@  discard block
 block discarded – undo
518 518
 	protected function _add_screen_options() {}
519 519
 	protected function _add_feature_pointers() {}
520 520
 	public function admin_init() {
521
-		EE_Registry::$i18n_js_strings[ 'update_att_qstns' ] = __( 'click "Update Registration Questions" to save your changes', 'event_espresso' );
521
+		EE_Registry::$i18n_js_strings['update_att_qstns'] = __('click "Update Registration Questions" to save your changes', 'event_espresso');
522 522
 	}
523 523
 	public function admin_notices() {}
524 524
 	public function admin_footer_scripts() {}
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	*		@return void
537 537
 	*/
538 538
 	private function _get_registration_status_array() {
539
-		self::$_reg_status = EEM_Registration::reg_status_array( array(), TRUE);
539
+		self::$_reg_status = EEM_Registration::reg_status_array(array(), TRUE);
540 540
 	}
541 541
 
542 542
 
@@ -559,11 +559,11 @@  discard block
 block discarded – undo
559 559
 	public function load_scripts_styles() {
560 560
 		//style
561 561
 		//wp_register_style('espresso_attendees', ATT_ASSETS_URL . 'espresso_attendees_admin.css', array(), EVENT_ESPRESSO_VERSION );
562
-		wp_register_style('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
562
+		wp_register_style('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
563 563
 		wp_enqueue_style('espresso_reg');
564 564
 
565 565
 		//script
566
-		wp_register_script('espresso_reg', REG_ASSETS_URL . 'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
566
+		wp_register_script('espresso_reg', REG_ASSETS_URL.'espresso_registrations_admin.js', array('jquery-ui-datepicker', 'jquery-ui-draggable', 'ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
567 567
 		wp_enqueue_script('espresso_reg');
568 568
 	}
569 569
 
@@ -572,9 +572,9 @@  discard block
 block discarded – undo
572 572
 	public function load_scripts_styles_edit_attendee() {
573 573
 		//stuff to only show up on our attendee edit details page.
574 574
 		$attendee_details_translations = array(
575
-			'att_publish_text' => sprintf( __('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created') )
575
+			'att_publish_text' => sprintf(__('Created on: <b>%1$s</b>', 'event_espresso'), $this->_cpt_model_obj->get_datetime('ATT_created'))
576 576
 			);
577
-		wp_localize_script( 'espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations );
577
+		wp_localize_script('espresso_reg', 'ATTENDEE_DETAILS', $attendee_details_translations);
578 578
 		wp_enqueue_script('jquery-validate');
579 579
 	}
580 580
 
@@ -592,7 +592,7 @@  discard block
 block discarded – undo
592 592
 
593 593
 	public function load_scripts_styles_contact_list() {
594 594
 		wp_deregister_style('espresso_reg');
595
-		wp_register_style('espresso_att', REG_ASSETS_URL . 'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
595
+		wp_register_style('espresso_att', REG_ASSETS_URL.'espresso_attendees_admin.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
596 596
 		wp_enqueue_style('espresso_att');
597 597
 	}
598 598
 
@@ -601,9 +601,9 @@  discard block
 block discarded – undo
601 601
 
602 602
 
603 603
 	public function load_scripts_styles_new_registration() {
604
-		wp_register_script( 'ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE );
604
+		wp_register_script('ee-spco-for-admin', REG_ASSETS_URL.'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE);
605 605
 		wp_enqueue_script('ee-spco-for-admin');
606
-		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' );
606
+		add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
607 607
 		EE_Form_Section_Proper::wp_enqueue_scripts();
608 608
 		EED_Ticket_Selector::load_tckt_slctr_assets();
609 609
 		EE_Datepicker_Input::enqueue_styles_and_scripts();
@@ -630,7 +630,7 @@  discard block
 block discarded – undo
630 630
 		//for notification related bulk actions we need to make sure only active messengers have an option.
631 631
 		EED_Messages::set_autoloaders();
632 632
 		/** @type EE_Messages $messages_controller */
633
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
633
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
634 634
 		$active_mts = $messages_controller->get_active_message_types();
635 635
 		//key= bulk_action_slug, value= message type.
636 636
 		$match_array = array(
@@ -643,23 +643,23 @@  discard block
 block discarded – undo
643 643
 
644 644
 		/** setup reg status bulk actions **/
645 645
 		$def_reg_status_actions['approve_registration'] = __('Approve Registrations', 'event_espresso');
646
-		if ( in_array( $match_array['approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
646
+		if (in_array($match_array['approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
647 647
 			$def_reg_status_actions['approve_and_notify_registration'] = __('Approve and Notify Registrations', 'event_espresso');
648 648
 		}
649 649
 		$def_reg_status_actions['decline_registration'] = __('Decline Registrations', 'event_espresso');
650
-		if ( in_array( $match_array['decline_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
650
+		if (in_array($match_array['decline_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
651 651
 			$def_reg_status_actions['decline_and_notify_registration'] = __('Decline and Notify Registrations', 'event_espresso');
652 652
 		}
653 653
 		$def_reg_status_actions['pending_registration'] = __('Set Registrations to Pending Payment', 'event_espresso');
654
-		if ( in_array( $match_array['pending_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
654
+		if (in_array($match_array['pending_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
655 655
 			$def_reg_status_actions['pending_and_notify_registration'] = __('Set Registrations to Pending Payment and Notify', 'event_espresso');
656 656
 		}
657 657
 		$def_reg_status_actions['no_approve_registration'] = __('Set Registrations to Not Approved', 'event_espresso');
658
-		if ( in_array( $match_array['no_approve_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
658
+		if (in_array($match_array['no_approve_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
659 659
 			$def_reg_status_actions['no_approve_and_notify_registration'] = __('Set Registrations to Not Approved and Notify', 'event_espresso');
660 660
 		}
661 661
 		$def_reg_status_actions['cancel_registration'] = __('Cancel Registrations', 'event_espresso');
662
-		if ( in_array( $match_array['cancel_registration'], $active_mts ) && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'batch_send_messages' ) ) {
662
+		if (in_array($match_array['cancel_registration'], $active_mts) && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'batch_send_messages')) {
663 663
 			$def_reg_status_actions['cancel_and_notify_registration'] = __('Cancel Registrations and Notify', 'event_espresso');
664 664
 		}
665 665
 
@@ -668,29 +668,29 @@  discard block
 block discarded – undo
668 668
 				'slug' => 'all',
669 669
 				'label' => __('View All Registrations', 'event_espresso'),
670 670
 				'count' => 0,
671
-				'bulk_action' => array_merge( $def_reg_status_actions, array(
671
+				'bulk_action' => array_merge($def_reg_status_actions, array(
672 672
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
673
-					) )
673
+					))
674 674
 				),
675 675
 			'month' => array(
676 676
 				'slug' => 'month',
677 677
 				'label' => __('This Month', 'event_espresso'),
678 678
 				'count' => 0,
679
-				'bulk_action' => array_merge( $def_reg_status_actions, array(
679
+				'bulk_action' => array_merge($def_reg_status_actions, array(
680 680
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
681 681
 					))
682 682
 				),
683 683
 			'today' => array(
684 684
 				'slug' => 'today',
685
-				'label' => sprintf( __('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp' ) ) ),
685
+				'label' => sprintf(__('Today - %s', 'event_espresso'), date('M d, Y', current_time('timestamp'))),
686 686
 				'count' => 0,
687
-				'bulk_action' => array_merge( $def_reg_status_actions,  array(
687
+				'bulk_action' => array_merge($def_reg_status_actions, array(
688 688
 					'trash_registrations' => __('Trash Registrations', 'event_espresso')
689 689
 					))
690 690
 				)
691 691
 			);
692 692
 
693
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_registrations', 'espresso_registrations_delete_registration' ) ) {
693
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_registrations', 'espresso_registrations_delete_registration')) {
694 694
 			$this->_views['incomplete'] = array(
695 695
 				'slug' => 'incomplete',
696 696
 				'label' => __('Incomplete', 'event_espresso'),
@@ -726,7 +726,7 @@  discard block
 block discarded – undo
726 726
 				)
727 727
 			);
728 728
 
729
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_contacts', 'espresso_registrations_trash_attendees' ) ) {
729
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_contacts', 'espresso_registrations_trash_attendees')) {
730 730
 			$this->_views['trash'] = array(
731 731
 				'slug' => 'trash',
732 732
 				'label' => __('Trash', 'event_espresso'),
@@ -765,42 +765,42 @@  discard block
 block discarded – undo
765 765
 				'desc' => __('View Transaction Invoice', 'event_espresso')
766 766
 				),
767 767
  			);
768
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) {
768
+		if (EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) {
769 769
 			$fc_items['resend_registration'] = array(
770 770
 				'class' => 'dashicons dashicons-email-alt',
771 771
 				'desc' => __('Resend Registration Details', 'event_espresso')
772 772
 				);
773 773
 		} else {
774
-			$fc_items['blank'] = array( 'class' => 'blank', 'desc' => '' );
774
+			$fc_items['blank'] = array('class' => 'blank', 'desc' => '');
775 775
 		}
776 776
 
777 777
 		$sc_items = array(
778 778
 			'approved_status' => array(
779
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_approved,
780
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' )
779
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_approved,
780
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence')
781 781
 				),
782 782
 			'pending_status' => array(
783
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_pending_payment,
784
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' )
783
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_pending_payment,
784
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence')
785 785
 				),
786 786
 			'incomplete_status' => array(
787
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_incomplete,
788
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_incomplete, FALSE, 'sentence' )
787
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_incomplete,
788
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_incomplete, FALSE, 'sentence')
789 789
 			),
790 790
 			'not_approved' => array(
791
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_not_approved,
792
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' )
791
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_not_approved,
792
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence')
793 793
 				),
794 794
 			'declined_status' => array(
795
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_declined,
796
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' )
795
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_declined,
796
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence')
797 797
 				),
798 798
 			'cancelled_status' => array(
799
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Registration::status_id_cancelled,
800
-				'desc' => EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' )
799
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Registration::status_id_cancelled,
800
+				'desc' => EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence')
801 801
 				)
802 802
 			);
803
-		return array_merge( $fc_items, $sc_items );
803
+		return array_merge($fc_items, $sc_items);
804 804
 	}
805 805
 
806 806
 
@@ -813,15 +813,15 @@  discard block
 block discarded – undo
813 813
 
814 814
 
815 815
 	protected function _registrations_overview_list_table() {
816
-		$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE;
817
-		if ( $EVT_ID ) {
818
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_registrations', 'espresso_registrations_new_registration', $EVT_ID ) ) {
819
-				$this->_admin_page_title .= $this->get_action_link_or_button( 'new_registration', 'add-registrant', array( 'event_id' => $EVT_ID ), 'add-new-h2' );
816
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE;
817
+		if ($EVT_ID) {
818
+			if (EE_Registry::instance()->CAP->current_user_can('ee_edit_registrations', 'espresso_registrations_new_registration', $EVT_ID)) {
819
+				$this->_admin_page_title .= $this->get_action_link_or_button('new_registration', 'add-registrant', array('event_id' => $EVT_ID), 'add-new-h2');
820 820
 			}
821
-			$event = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
822
-			$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf( __('%s Viewing registrations for the event: %s%s', 'event_espresso'), '<h2>', '<a href="' . EE_Admin_Page::add_query_args_and_nonce( array('action' => 'edit', 'post' => $event->ID() ), EVENTS_ADMIN_URL ) . '">' . $event->get('EVT_name') . '</a>', '</h2>' ) : '';
821
+			$event = EEM_Event::instance()->get_one_by_ID($EVT_ID);
822
+			$this->_template_args['admin_page_header'] = $event instanceof EE_Event ? sprintf(__('%s Viewing registrations for the event: %s%s', 'event_espresso'), '<h2>', '<a href="'.EE_Admin_Page::add_query_args_and_nonce(array('action' => 'edit', 'post' => $event->ID()), EVENTS_ADMIN_URL).'">'.$event->get('EVT_name').'</a>', '</h2>') : '';
823 823
 		}
824
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_registration_legend_items() );
824
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_registration_legend_items());
825 825
 		$this->display_admin_list_table_page_with_no_sidebar();
826 826
 	}
827 827
 
@@ -836,19 +836,19 @@  discard block
 block discarded – undo
836 836
 	 */
837 837
 	private function _set_registration_object() {
838 838
 		//get out if we've already set the object
839
-		if ( is_object( $this->_registration )) {
839
+		if (is_object($this->_registration)) {
840 840
 			return TRUE;
841 841
 		}
842 842
 
843 843
 	    $REG = EEM_Registration::instance();
844 844
 
845
-		$REG_ID = ( ! empty( $this->_req_data['_REG_ID'] )) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
845
+		$REG_ID = ( ! empty($this->_req_data['_REG_ID'])) ? absint($this->_req_data['_REG_ID']) : FALSE;
846 846
 
847
-		if ( $this->_registration = $REG->get_one_by_ID( $REG_ID ))
847
+		if ($this->_registration = $REG->get_one_by_ID($REG_ID))
848 848
 			return TRUE;
849 849
 		else {
850
-			$error_msg = sprintf( __('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID );
851
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
850
+			$error_msg = sprintf(__('An error occurred and the details for Registration ID #%s could not be retrieved.', 'event_espresso'), $REG_ID);
851
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
852 852
 			$this->_registration = NULL;
853 853
 			return FALSE;
854 854
 		}
@@ -867,25 +867,25 @@  discard block
 block discarded – undo
867 867
 	 * @internal param bool $all whether to ignore all query params and just return ALL registrations (or count if count is set)
868 868
 	 * @return mixed (int|array)  int = count || array of registration objects
869 869
 	 */
870
-	public function get_registrations( $per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE ) {
871
-
872
-		$EVT_ID = ! empty( $this->_req_data['event_id'] ) && $this->_req_data['event_id'] > 0 ? absint( $this->_req_data['event_id'] ) : FALSE;
873
-		$CAT_ID = ! empty( $this->_req_data['EVT_CAT'] ) && (int) $this->_req_data['EVT_CAT'] > 0? absint( $this->_req_data['EVT_CAT'] ) : FALSE;
874
-		$reg_status = ! empty( $this->_req_data['_reg_status'] ) ? sanitize_text_field( $this->_req_data['_reg_status'] ) : FALSE;
875
-		$month_range = ! empty( $this->_req_data['month_range'] ) ? sanitize_text_field( $this->_req_data['month_range'] ) : FALSE;//should be like 2013-april
876
-		$today_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'today' ? TRUE : FALSE;
877
-		$this_month_a = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'month' ? TRUE  : FALSE;
870
+	public function get_registrations($per_page = 10, $count = FALSE, $this_month = FALSE, $today = FALSE) {
871
+
872
+		$EVT_ID = ! empty($this->_req_data['event_id']) && $this->_req_data['event_id'] > 0 ? absint($this->_req_data['event_id']) : FALSE;
873
+		$CAT_ID = ! empty($this->_req_data['EVT_CAT']) && (int) $this->_req_data['EVT_CAT'] > 0 ? absint($this->_req_data['EVT_CAT']) : FALSE;
874
+		$reg_status = ! empty($this->_req_data['_reg_status']) ? sanitize_text_field($this->_req_data['_reg_status']) : FALSE;
875
+		$month_range = ! empty($this->_req_data['month_range']) ? sanitize_text_field($this->_req_data['month_range']) : FALSE; //should be like 2013-april
876
+		$today_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'today' ? TRUE : FALSE;
877
+		$this_month_a = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'month' ? TRUE : FALSE;
878 878
 		$start_date = FALSE;
879 879
 		$end_date = FALSE;
880 880
 		$_where = array();
881
-		$trash = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'trash' ? TRUE : FALSE;
882
-		$incomplete = ! empty( $this->_req_data['status'] ) && $this->_req_data['status'] == 'incomplete' ? TRUE : FALSE;
881
+		$trash = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'trash' ? TRUE : FALSE;
882
+		$incomplete = ! empty($this->_req_data['status']) && $this->_req_data['status'] == 'incomplete' ? TRUE : FALSE;
883 883
 
884 884
 		//set orderby
885 885
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
886 886
 
887 887
 
888
-		switch ( $this->_req_data['orderby'] ) {
888
+		switch ($this->_req_data['orderby']) {
889 889
 			case '_REG_ID':
890 890
 				$orderby = 'REG_ID';
891 891
 				break;
@@ -905,26 +905,26 @@  discard block
 block discarded – undo
905 905
 				$orderby = 'REG_date';
906 906
 		}
907 907
 
908
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
909
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
910
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
908
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
909
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
910
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
911 911
 
912 912
 
913
-		$offset = ($current_page-1)*$per_page;
914
-		$limit = $count  ? NULL : array( $offset, $per_page );
913
+		$offset = ($current_page - 1) * $per_page;
914
+		$limit = $count ? NULL : array($offset, $per_page);
915 915
 
916
-		if($EVT_ID){
917
-			$_where['EVT_ID']=$EVT_ID;
916
+		if ($EVT_ID) {
917
+			$_where['EVT_ID'] = $EVT_ID;
918 918
 		}
919
-		if($CAT_ID){
919
+		if ($CAT_ID) {
920 920
 			$_where['Event.Term_Taxonomy.term_id'] = $CAT_ID;
921 921
 		}
922
-		if ( $incomplete ) {
922
+		if ($incomplete) {
923 923
 			$_where['STS_ID'] = EEM_Registration::status_id_incomplete;
924 924
 		} else if ( ! $trash) {
925
-			$_where['STS_ID'] = array( '!=', EEM_Registration::status_id_incomplete );
925
+			$_where['STS_ID'] = array('!=', EEM_Registration::status_id_incomplete);
926 926
 		}
927
-		if($reg_status){
927
+		if ($reg_status) {
928 928
 			$_where['STS_ID'] = $reg_status;
929 929
 		}
930 930
 
@@ -936,105 +936,105 @@  discard block
 block discarded – undo
936 936
 		$time_start = ' 00:00:00';
937 937
 		$time_end = ' 23:59:59';
938 938
 
939
-		if($today_a || $today ){
939
+		if ($today_a || $today) {
940 940
 			$curdate = date('Y-m-d', current_time('timestamp'));
941
-			$_where['REG_date']= array('BETWEEN',
941
+			$_where['REG_date'] = array('BETWEEN',
942 942
 				array(
943
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_start, 'Y-m-d H:i:s' ),
944
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $curdate . $time_end, 'Y-m-d H:i:s' ),
943
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_start, 'Y-m-d H:i:s'),
944
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $curdate.$time_end, 'Y-m-d H:i:s'),
945 945
 			));
946
-		}elseif($this_month_a || $this_month){
946
+		}elseif ($this_month_a || $this_month) {
947 947
 			$this_month_r = date('m', current_time('timestamp'));
948
-			$days_this_month = date( 't', current_time('timestamp') );
949
-			$_where['REG_date']= array('BETWEEN',
948
+			$days_this_month = date('t', current_time('timestamp'));
949
+			$_where['REG_date'] = array('BETWEEN',
950 950
 				array(
951
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-01' . ' ' . $time_start, 'Y-m-d H:i:s' ),
952
-					EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' ' . $time_end, 'Y-m-d H:i:s' )
951
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-01'.' '.$time_start, 'Y-m-d H:i:s'),
952
+					EEM_Registration::instance()->convert_datetime_for_query('REG_date', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' '.$time_end, 'Y-m-d H:i:s')
953 953
 			));
954
-		}elseif($month_range){
954
+		}elseif ($month_range) {
955 955
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
956
-			$month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
957
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
958
-			$days_in_month = date('t', strtotime($year_r .  '-' . $month_r . '-' . '01') );
959
-			$_where['REG_date']= array('BETWEEN',
960
-				array(  EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query( 'REG_date', $year_r . '-' . $month_r . '-' . $days_in_month .  ' 23:59:59', 'Y-m-d H:i:s' ) ) );
961
-		}elseif($start_date && $end_date){
956
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
957
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
958
+			$days_in_month = date('t', strtotime($year_r.'-'.$month_r.'-'.'01'));
959
+			$_where['REG_date'] = array('BETWEEN',
960
+				array(EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-01 00:00:00', 'Y-m-d H:i:s'), EEM_Registration::instance()->convert_datetime_for_query('REG_date', $year_r.'-'.$month_r.'-'.$days_in_month.' 23:59:59', 'Y-m-d H:i:s')));
961
+		}elseif ($start_date && $end_date) {
962 962
 			throw new EE_Error("not yet supported");
963
-		}elseif($start_date){
963
+		}elseif ($start_date) {
964 964
 			throw new EE_Error("not yet supported");
965
-		}elseif($end_date){
965
+		}elseif ($end_date) {
966 966
 			throw new EE_Error("not yet supported");
967 967
 		}
968 968
 
969
-		if ( ! empty( $this->_req_data['s'] ) ) {
970
-			$sstr = '%' . $this->_req_data['s'] . '%';
969
+		if ( ! empty($this->_req_data['s'])) {
970
+			$sstr = '%'.$this->_req_data['s'].'%';
971 971
 			$_where['OR'] = array(
972
-				'Event.EVT_name' => array( 'LIKE', $sstr),
973
-				'Event.EVT_desc' => array( 'LIKE', $sstr ),
974
-				'Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
975
-				'Attendee.ATT_full_name' => array( 'LIKE', $sstr ),
976
-				'Attendee.ATT_fname' => array( 'LIKE', $sstr ),
977
-				'Attendee.ATT_lname' => array( 'LIKE', $sstr ),
978
-				'Attendee.ATT_short_bio' => array( 'LIKE', $sstr ),
979
-				'Attendee.ATT_email' => array('LIKE', $sstr ),
980
-				'Attendee.ATT_address' => array( 'LIKE', $sstr ),
981
-				'Attendee.ATT_address2' => array( 'LIKE', $sstr ),
982
-				'Attendee.ATT_city' => array( 'LIKE', $sstr ),
983
-				'REG_final_price' => array( 'LIKE', $sstr ),
984
-				'REG_code' => array( 'LIKE', $sstr ),
985
-				'REG_count' => array( 'LIKE' , $sstr ),
986
-				'REG_group_size' => array( 'LIKE' , $sstr ),
987
-				'Ticket.TKT_name' => array( 'LIKE', $sstr ),
988
-				'Ticket.TKT_description' => array( 'LIKE', $sstr ),
989
-				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array( 'LIKE', $sstr )
972
+				'Event.EVT_name' => array('LIKE', $sstr),
973
+				'Event.EVT_desc' => array('LIKE', $sstr),
974
+				'Event.EVT_short_desc' => array('LIKE', $sstr),
975
+				'Attendee.ATT_full_name' => array('LIKE', $sstr),
976
+				'Attendee.ATT_fname' => array('LIKE', $sstr),
977
+				'Attendee.ATT_lname' => array('LIKE', $sstr),
978
+				'Attendee.ATT_short_bio' => array('LIKE', $sstr),
979
+				'Attendee.ATT_email' => array('LIKE', $sstr),
980
+				'Attendee.ATT_address' => array('LIKE', $sstr),
981
+				'Attendee.ATT_address2' => array('LIKE', $sstr),
982
+				'Attendee.ATT_city' => array('LIKE', $sstr),
983
+				'REG_final_price' => array('LIKE', $sstr),
984
+				'REG_code' => array('LIKE', $sstr),
985
+				'REG_count' => array('LIKE', $sstr),
986
+				'REG_group_size' => array('LIKE', $sstr),
987
+				'Ticket.TKT_name' => array('LIKE', $sstr),
988
+				'Ticket.TKT_description' => array('LIKE', $sstr),
989
+				'Transaction.Payment.PAY_txn_id_chq_nmbr' => array('LIKE', $sstr)
990 990
 				);
991 991
 		}
992 992
 
993 993
 		//capability checks
994
-		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations' ) ) {
994
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'get_registrations')) {
995 995
 			$_where['AND'] = array(
996 996
 				'Event.EVT_wp_user' => get_current_user_id()
997 997
 				);
998 998
 		}
999 999
 
1000 1000
 
1001
-		if( $count ){
1002
-			if ( $trash ) {
1003
-				return EEM_Registration::instance()->count_deleted( array( $_where ));
1004
-			} else if ( $incomplete ) {
1005
-				return EEM_Registration::instance()->count( array( $_where ));
1001
+		if ($count) {
1002
+			if ($trash) {
1003
+				return EEM_Registration::instance()->count_deleted(array($_where));
1004
+			} else if ($incomplete) {
1005
+				return EEM_Registration::instance()->count(array($_where));
1006 1006
 			} else {
1007
-				return EEM_Registration::instance()->count( array( $_where, 'default_where_conditions' => 'this_model_only' ));
1007
+				return EEM_Registration::instance()->count(array($_where, 'default_where_conditions' => 'this_model_only'));
1008 1008
 			}
1009 1009
 		} else {
1010 1010
 			//make sure we remove default where conditions cause all registrations matching query are returned
1011
-			$query_params = array( $_where, 'order_by' => array( $orderby => $sort ), 'default_where_conditions' => 'this_model_only' );
1012
-			if ( $per_page !== -1 ) {
1011
+			$query_params = array($_where, 'order_by' => array($orderby => $sort), 'default_where_conditions' => 'this_model_only');
1012
+			if ($per_page !== -1) {
1013 1013
 				$query_params['limit'] = $limit;
1014 1014
 			}
1015
-			$registrations =  $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params);
1015
+			$registrations = $trash ? EEM_Registration::instance()->get_all_deleted($query_params) : EEM_Registration::instance()->get_all($query_params);
1016 1016
 
1017 1017
 
1018
-			if ( $EVT_ID && isset( $registrations[0] ) && $registrations[0] instanceof EE_Registration &&  $registrations[0]->event_obj()) {
1018
+			if ($EVT_ID && isset($registrations[0]) && $registrations[0] instanceof EE_Registration && $registrations[0]->event_obj()) {
1019 1019
 				$first_registration = $registrations[0];
1020 1020
 				//EEH_Debug_Tools::printr( $registrations[0], '$registrations  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1021 1021
 				$event_name = $first_registration->event_obj()->name();
1022
-				$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a');// isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1022
+				$event_date = $first_registration->date_obj()->start_date_and_time('l F j, Y,', 'g:i:s a'); // isset( $registrations[0]->DTT_EVT_start ) ? date( 'l F j, Y,    g:i:s a', $registrations[0]->DTT_EVT_start ) : '';
1023 1023
 				// edit event link
1024
-				if ( $event_name != '' ) {
1025
-					$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit_event', 'EVT_ID'=>$EVT_ID ), EVENTS_ADMIN_URL );
1026
-					$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $event_name . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
1027
-					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
1024
+				if ($event_name != '') {
1025
+					$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit_event', 'EVT_ID'=>$EVT_ID), EVENTS_ADMIN_URL);
1026
+					$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$event_name.'">'.__('Edit Event', 'event_espresso').'</a>';
1027
+					$event_name .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
1028 1028
 				}
1029 1029
 
1030
-				$back_2_reg_url = self::add_query_args_and_nonce( array( 'action'=>'default' ), REG_ADMIN_URL );
1031
-				$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="' . esc_attr__( 'click to return to viewing all registrations ', 'event_espresso' ) . '">&laquo; ' . __( 'Back to All Registrations', 'event_espresso' ) . '</a>';
1030
+				$back_2_reg_url = self::add_query_args_and_nonce(array('action'=>'default'), REG_ADMIN_URL);
1031
+				$back_2_reg_lnk = '<a href="'.$back_2_reg_url.'" title="'.esc_attr__('click to return to viewing all registrations ', 'event_espresso').'">&laquo; '.__('Back to All Registrations', 'event_espresso').'</a>';
1032 1032
 
1033 1033
 				$this->_template_args['before_admin_page_content'] = '
1034 1034
 			<div id="admin-page-header">
1035
-				<h1><span class="small-text not-bold">'.__( 'Event: ', 'event_espresso' ).'</span>'. $event_name .'</h1>
1036
-				<h3><span class="small-text not-bold">'.__( 'Date: ', 'event_espresso' ). '</span>'. $event_date .'</h3>
1037
-				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk . '</span>
1035
+				<h1><span class="small-text not-bold">'.__('Event: ', 'event_espresso').'</span>'.$event_name.'</h1>
1036
+				<h3><span class="small-text not-bold">'.__('Date: ', 'event_espresso').'</span>'.$event_date.'</h3>
1037
+				<span class="admin-page-header-go-back-lnk not-bold">' . $back_2_reg_lnk.'</span>
1038 1038
 			</div>
1039 1039
 			';
1040 1040
 
@@ -1072,7 +1072,7 @@  discard block
 block discarded – undo
1072 1072
 
1073 1073
 		$this->_set_registration_object();
1074 1074
 
1075
-		if ( is_object( $this->_registration )) {
1075
+		if (is_object($this->_registration)) {
1076 1076
 			$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
1077 1077
 			$this->_session = $transaction->session_data();
1078 1078
 
@@ -1080,10 +1080,10 @@  discard block
 block discarded – undo
1080 1080
 
1081 1081
 
1082 1082
 			$this->_template_args['reg_nmbr']['value'] = $this->_registration->ID();
1083
-			$this->_template_args['reg_nmbr']['label'] = __( 'Registration Number', 'event_espresso' );
1083
+			$this->_template_args['reg_nmbr']['label'] = __('Registration Number', 'event_espresso');
1084 1084
 
1085
-			$this->_template_args['reg_datetime']['value'] =  $this->_registration->pretty_date('l F j, Y','g:i:s a') ;
1086
-			$this->_template_args['reg_datetime']['label'] = __( 'Date', 'event_espresso' );
1085
+			$this->_template_args['reg_datetime']['value'] = $this->_registration->pretty_date('l F j, Y', 'g:i:s a');
1086
+			$this->_template_args['reg_datetime']['label'] = __('Date', 'event_espresso');
1087 1087
 
1088 1088
 			$this->_template_args['grand_total'] = $transaction->total();
1089 1089
 
@@ -1091,19 +1091,19 @@  discard block
 block discarded – undo
1091 1091
 			// link back to overview
1092 1092
 			$this->_template_args['reg_overview_url'] = REG_ADMIN_URL;
1093 1093
 			$this->_template_args['registration'] = $this->_registration;
1094
-			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $event_id ), REG_ADMIN_URL );
1095
-			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions' ), admin_url( 'admin.php' ) );
1096
-			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id ), admin_url( 'admin.php' ) );
1094
+			$this->_template_args['filtered_registrations_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $event_id), REG_ADMIN_URL);
1095
+			$this->_template_args['filtered_transactions_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'EVT_ID' => $event_id, 'page' => 'espresso_transactions'), admin_url('admin.php'));
1096
+			$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('page' => 'espresso_events', 'action' => 'edit', 'post' => $event_id), admin_url('admin.php'));
1097 1097
 
1098 1098
 			//next and previous links
1099
-			$next_reg = $this->_registration->next(null, array(), 'REG_ID' );
1100
-			$this->_template_args['next_registration'] = $next_reg ? $this->_next_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-right ee-icon-size-22' ) : '';
1101
-			$previous_reg = $this->_registration->previous( null, array(), 'REG_ID' );
1102
-			$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID'] ), REG_ADMIN_URL ), 'dashicons dashicons-arrow-left ee-icon-size-22' ) : '';
1099
+			$next_reg = $this->_registration->next(null, array(), 'REG_ID');
1100
+			$this->_template_args['next_registration'] = $next_reg ? $this->_next_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $next_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-right ee-icon-size-22') : '';
1101
+			$previous_reg = $this->_registration->previous(null, array(), 'REG_ID');
1102
+			$this->_template_args['previous_registration'] = $previous_reg ? $this->_previous_link(EE_Admin_Page::add_query_args_and_nonce(array('action' => 'view_registration', '_REG_ID' => $previous_reg['REG_ID']), REG_ADMIN_URL), 'dashicons dashicons-arrow-left ee-icon-size-22') : '';
1103 1103
 
1104 1104
 			// grab header
1105
-			$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_header.template.php';
1106
-			$this->_template_args['admin_page_header'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1105
+			$template_path = REG_TEMPLATE_PATH.'reg_admin_details_header.template.php';
1106
+			$this->_template_args['admin_page_header'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1107 1107
 
1108 1108
 		} else {
1109 1109
 
@@ -1124,14 +1124,14 @@  discard block
 block discarded – undo
1124 1124
 	protected function _registration_details_metaboxes() {
1125 1125
 		$this->_set_registration_object();
1126 1126
 		$attendee = $this->_registration instanceof EE_Registration ? $this->_registration->attendee() : null;
1127
-		add_meta_box( 'edit-reg-status-mbox', __( 'Registration Status', 'event_espresso' ), array( $this, 'set_reg_status_buttons_metabox' ), $this->wp_page_slug, 'normal', 'high' );
1128
-		add_meta_box( 'edit-reg-details-mbox', __( 'Registration Details', 'event_espresso' ), array( $this, '_reg_details_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1129
-		if ( $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox' ) ) {
1130
-			add_meta_box( 'edit-reg-questions-mbox', __( 'Registration Form Answers', 'event_espresso' ), array( $this, '_reg_questions_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1127
+		add_meta_box('edit-reg-status-mbox', __('Registration Status', 'event_espresso'), array($this, 'set_reg_status_buttons_metabox'), $this->wp_page_slug, 'normal', 'high');
1128
+		add_meta_box('edit-reg-details-mbox', __('Registration Details', 'event_espresso'), array($this, '_reg_details_meta_box'), $this->wp_page_slug, 'normal', 'high');
1129
+		if ($attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_edit_registration', 'edit-reg-questions-mbox')) {
1130
+			add_meta_box('edit-reg-questions-mbox', __('Registration Form Answers', 'event_espresso'), array($this, '_reg_questions_meta_box'), $this->wp_page_slug, 'normal', 'high');
1131 1131
 		}
1132
-		add_meta_box( 'edit-reg-registrant-mbox', __( 'Contact Details', 'event_espresso' ), array( $this, '_reg_registrant_side_meta_box' ), $this->wp_page_slug, 'side', 'high' );
1133
-		if ( $this->_registration->group_size() > 1 ) {
1134
-			add_meta_box( 'edit-reg-attendees-mbox', __( 'Other Registrations in this Transaction', 'event_espresso' ), array( $this, '_reg_attendees_meta_box' ), $this->wp_page_slug, 'normal', 'high' );
1132
+		add_meta_box('edit-reg-registrant-mbox', __('Contact Details', 'event_espresso'), array($this, '_reg_registrant_side_meta_box'), $this->wp_page_slug, 'side', 'high');
1133
+		if ($this->_registration->group_size() > 1) {
1134
+			add_meta_box('edit-reg-attendees-mbox', __('Other Registrations in this Transaction', 'event_espresso'), array($this, '_reg_attendees_meta_box'), $this->wp_page_slug, 'normal', 'high');
1135 1135
 		}
1136 1136
 	}
1137 1137
 
@@ -1152,23 +1152,23 @@  discard block
 block discarded – undo
1152 1152
 
1153 1153
 		//let's get an array of all possible buttons that we can just reference
1154 1154
 		$status_buttons = $this->_get_reg_status_buttons();
1155
-		$template_args[ 'reg_status_value' ] = $this->_registration->pretty_status();
1156
-		$template_args[ 'reg_status_class' ] = 'status-' . $this->_registration->status_ID();
1155
+		$template_args['reg_status_value'] = $this->_registration->pretty_status();
1156
+		$template_args['reg_status_class'] = 'status-'.$this->_registration->status_ID();
1157 1157
 		$template_args['attendee'] = $this->_registration->attendee();
1158
-		$template = REG_TEMPLATE_PATH . 'reg_status_change_buttons.template.php';
1159
-		if ( $this->_set_registration_object() ) {
1158
+		$template = REG_TEMPLATE_PATH.'reg_status_change_buttons.template.php';
1159
+		if ($this->_set_registration_object()) {
1160 1160
 			$current_status = $this->_registration->status_ID();
1161
-			unset( $status_buttons[$current_status] );
1162
-			if ( $current_status != EEM_Registration::status_id_pending_payment && $is_complete ) {
1163
-				unset( $status_buttons[EEM_Registration::status_id_pending_payment] );
1161
+			unset($status_buttons[$current_status]);
1162
+			if ($current_status != EEM_Registration::status_id_pending_payment && $is_complete) {
1163
+				unset($status_buttons[EEM_Registration::status_id_pending_payment]);
1164 1164
 			}
1165
-			$template_args['status_buttons'] = implode( "\n", $status_buttons );
1165
+			$template_args['status_buttons'] = implode("\n", $status_buttons);
1166 1166
 		}
1167 1167
 		$template_args['form_url'] = REG_ADMIN_URL;
1168 1168
 		$template_args['REG_ID'] = $this->_registration->ID();
1169
-		$template_args['nonce'] = wp_nonce_field( 'change_reg_status_nonce',  'change_reg_status_nonce', FALSE, FALSE );
1169
+		$template_args['nonce'] = wp_nonce_field('change_reg_status_nonce', 'change_reg_status_nonce', FALSE, FALSE);
1170 1170
 
1171
-		EEH_Template::display_template( $template, $template_args );
1171
+		EEH_Template::display_template($template, $template_args);
1172 1172
 
1173 1173
 	}
1174 1174
 
@@ -1182,11 +1182,11 @@  discard block
 block discarded – undo
1182 1182
 	private function _get_reg_status_buttons() {
1183 1183
 
1184 1184
 		$buttons = array(
1185
-			EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_approved, FALSE, 'sentence' ) . '">',
1186
-			EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_pending_payment . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, FALSE, 'sentence' ) . '">',
1187
-			EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_not_approved . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, FALSE, 'sentence' ) . '">',
1188
-			EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_declined . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_declined, FALSE, 'sentence' ) . '">',
1189
-			EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-' . EEM_Registration::status_id_cancelled . '" value="' . EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, FALSE, 'sentence' ) . '">',
1185
+			EEM_Registration::status_id_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_approved.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_approved, FALSE, 'sentence').'">',
1186
+			EEM_Registration::status_id_pending_payment => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_pending_payment.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, FALSE, 'sentence').'">',
1187
+			EEM_Registration::status_id_not_approved => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_not_approved.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, FALSE, 'sentence').'">',
1188
+			EEM_Registration::status_id_declined => '<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_declined.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_declined, FALSE, 'sentence').'">',
1189
+			EEM_Registration::status_id_cancelled =>'<input type="submit" name="_reg_status_id" class="button-secondary ee-status-strip reg-status-'.EEM_Registration::status_id_cancelled.'" value="'.EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, FALSE, 'sentence').'">',
1190 1190
 			);
1191 1191
 		return $buttons;
1192 1192
 	}
@@ -1200,13 +1200,13 @@  discard block
 block discarded – undo
1200 1200
 	 *
1201 1201
 	 * @return array  (array with reg_id(s) updated and whether update was successful.
1202 1202
 	 */
1203
-	protected function _set_registration_status_from_request( $status = false, $notify = false ) {
1204
-		$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? (array) $this->_req_data['_REG_ID'] : array();
1203
+	protected function _set_registration_status_from_request($status = false, $notify = false) {
1204
+		$REG_ID = isset($this->_req_data['_REG_ID']) ? (array) $this->_req_data['_REG_ID'] : array();
1205 1205
 
1206
-		$success = $this->_set_registration_status( $REG_ID, $status );
1206
+		$success = $this->_set_registration_status($REG_ID, $status);
1207 1207
 
1208 1208
 		//notify?
1209
-		if ( $success && $notify && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ) {
1209
+		if ($success && $notify && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration')) {
1210 1210
 			$this->_process_resend_registration();
1211 1211
 		}
1212 1212
 
@@ -1224,19 +1224,19 @@  discard block
 block discarded – undo
1224 1224
 	 * @param bool $status
1225 1225
 	 * @return array (an array with 'success' key representing whether status change was successful, and 'REG_ID' as the array of updated registrations).
1226 1226
 	 */
1227
-	protected function _set_registration_status( $REG_ID, $status = false ) {
1227
+	protected function _set_registration_status($REG_ID, $status = false) {
1228 1228
 		$success = true;
1229 1229
 		// set default status if none is passed
1230 1230
 		$status = $status ? $status : EEM_Registration::status_id_pending_payment;
1231 1231
 
1232 1232
 		//typecast and sanitize reg_id
1233
-		$reg_ids = array_filter( (array) $REG_ID, 'absint' );
1233
+		$reg_ids = array_filter((array) $REG_ID, 'absint');
1234 1234
 
1235 1235
 		//loop through REG_ID's and change status
1236
-		foreach ( $reg_ids as $r_id ) {
1237
-			$registration = EEM_Registration::instance()->get_one_by_ID( $r_id );
1238
-			if ( $registration instanceof EE_Registration ) {
1239
-				$registration->set_status( $status );
1236
+		foreach ($reg_ids as $r_id) {
1237
+			$registration = EEM_Registration::instance()->get_one_by_ID($r_id);
1238
+			if ($registration instanceof EE_Registration) {
1239
+				$registration->set_status($status);
1240 1240
 				$result = $registration->save();
1241 1241
 
1242 1242
 				//verifying explicit fails because update *may* just return 0 for 0 rows affected
@@ -1248,7 +1248,7 @@  discard block
 block discarded – undo
1248 1248
 		$this->_req_data['_REG_ID'] = $reg_ids;
1249 1249
 
1250 1250
 		//return $success and processed registrations
1251
-		return array( 'REG_ID' => $reg_ids, 'success' => $success );
1251
+		return array('REG_ID' => $reg_ids, 'success' => $success);
1252 1252
 	}
1253 1253
 
1254 1254
 
@@ -1260,37 +1260,37 @@  discard block
 block discarded – undo
1260 1260
 	 * @param   bool    $notify indicates whether the _set_registration_status_from_request does notifications or not.
1261 1261
 	 * @return void
1262 1262
 	 */
1263
-	protected function _reg_status_change_return( $STS_ID, $notify = false ) {
1263
+	protected function _reg_status_change_return($STS_ID, $notify = false) {
1264 1264
 
1265
-		$result = ! empty( $STS_ID ) ? $this->_set_registration_status_from_request( $STS_ID, $notify ) : array( 'success' => false );
1265
+		$result = ! empty($STS_ID) ? $this->_set_registration_status_from_request($STS_ID, $notify) : array('success' => false);
1266 1266
 
1267 1267
 
1268
-		$success = isset( $result['success'] ) && $result['success'];
1268
+		$success = isset($result['success']) && $result['success'];
1269 1269
 
1270 1270
 		//setup success message
1271
-		if ( $success ) {
1272
-			$msg = is_array( $result['REG_ID'] ) && count( $result['REG_ID'] ) > 1  ? sprintf( __('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) :  sprintf( __('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower' ) ) ;
1273
-			EE_Error::add_success( $msg );
1271
+		if ($success) {
1272
+			$msg = is_array($result['REG_ID']) && count($result['REG_ID']) > 1 ? sprintf(__('Registration status has been set to %s', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower')) : sprintf(__('Registrations have been set to %s.', 'event_espresso'), EEH_Template::pretty_status($STS_ID, false, 'lower'));
1273
+			EE_Error::add_success($msg);
1274 1274
 		} else {
1275
-			EE_Error::add_error( __('Something went wrong, and the status was not changed', 'event_espresso' ), __FILE__, __LINE__, __FUNCTION__ );
1275
+			EE_Error::add_error(__('Something went wrong, and the status was not changed', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
1276 1276
 		}
1277 1277
 
1278
-		$route = isset( $this->_req_data['return'] ) && $this->_req_data['return'] == 'view_registration' ? array( 'action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0] ) : array( 'action' => 'default' );
1278
+		$route = isset($this->_req_data['return']) && $this->_req_data['return'] == 'view_registration' ? array('action' => 'view_registration', '_REG_ID' => $result['REG_ID'][0]) : array('action' => 'default');
1279 1279
 		//unset nonces
1280
-		foreach ( $this->_req_data as $ref => $value ) {
1281
-			if ( strpos( $ref, 'nonce' ) !== false ) {
1282
-				unset( $this->_req_data[$ref] );
1280
+		foreach ($this->_req_data as $ref => $value) {
1281
+			if (strpos($ref, 'nonce') !== false) {
1282
+				unset($this->_req_data[$ref]);
1283 1283
 				continue;
1284 1284
 			}
1285 1285
 
1286
-			$value = is_array( $value ) ? array_map( 'urlencode', $value ) : urlencode( $value );
1286
+			$value = is_array($value) ? array_map('urlencode', $value) : urlencode($value);
1287 1287
 			$this->_req_data[$ref] = $value;
1288 1288
 		}
1289 1289
 
1290 1290
 		//merge request vars so that the reloaded list table contains any existing filter query params
1291
-		$route = array_merge( $this->_req_data, $route );
1291
+		$route = array_merge($this->_req_data, $route);
1292 1292
 
1293
-		$this->_redirect_after_action( $success, '', '', $route, true );
1293
+		$this->_redirect_after_action($success, '', '', $route, true);
1294 1294
 
1295 1295
 		}
1296 1296
 
@@ -1303,29 +1303,29 @@  discard block
 block discarded – undo
1303 1303
 	protected function _change_reg_status() {
1304 1304
 		$this->_req_data['return'] = 'view_registration';
1305 1305
 		//set notify based on whether the send notifications toggle is set or not
1306
-		$notify = ! empty( $this->_req_data['txn_reg_status_change']['send_notifications'] );
1307
-		$this->_req_data[ '_reg_status_id' ] = isset( $this->_req_data[ '_reg_status_id' ] ) ? $this->_req_data[ '_reg_status_id' ] : '';
1306
+		$notify = ! empty($this->_req_data['txn_reg_status_change']['send_notifications']);
1307
+		$this->_req_data['_reg_status_id'] = isset($this->_req_data['_reg_status_id']) ? $this->_req_data['_reg_status_id'] : '';
1308 1308
 
1309
-		switch ( $this->_req_data['_reg_status_id'] ) {
1310
-			case EEH_Template::pretty_status( EEM_Registration::status_id_approved, false, 'sentence' ) :
1311
-				$this->approve_registration( $notify );
1309
+		switch ($this->_req_data['_reg_status_id']) {
1310
+			case EEH_Template::pretty_status(EEM_Registration::status_id_approved, false, 'sentence') :
1311
+				$this->approve_registration($notify);
1312 1312
 				break;
1313
-			case EEH_Template::pretty_status( EEM_Registration::status_id_pending_payment, false, 'sentence' ) :
1314
-				$this->pending_registration( $notify );
1313
+			case EEH_Template::pretty_status(EEM_Registration::status_id_pending_payment, false, 'sentence') :
1314
+				$this->pending_registration($notify);
1315 1315
 				break;
1316
-			case EEH_Template::pretty_status( EEM_Registration::status_id_not_approved, false, 'sentence' ) :
1317
-				$this->not_approve_registration( $notify );
1316
+			case EEH_Template::pretty_status(EEM_Registration::status_id_not_approved, false, 'sentence') :
1317
+				$this->not_approve_registration($notify);
1318 1318
 				break;
1319
-			case EEH_Template::pretty_status( EEM_Registration::status_id_declined, false, 'sentence' ) :
1320
-				$this->decline_registration( $notify );
1319
+			case EEH_Template::pretty_status(EEM_Registration::status_id_declined, false, 'sentence') :
1320
+				$this->decline_registration($notify);
1321 1321
 				break;
1322
-			case EEH_Template::pretty_status( EEM_Registration::status_id_cancelled, false, 'sentence' ) :
1323
-				$this->cancel_registration( $notify );
1322
+			case EEH_Template::pretty_status(EEM_Registration::status_id_cancelled, false, 'sentence') :
1323
+				$this->cancel_registration($notify);
1324 1324
 				break;
1325 1325
 			default :
1326 1326
 				$result['success'] = false;
1327
-				unset( $this->_req_data['return'] );
1328
-				$this->_reg_status_change_return( '', false );
1327
+				unset($this->_req_data['return']);
1328
+				$this->_reg_status_change_return('', false);
1329 1329
 				break;
1330 1330
 		}
1331 1331
 	}
@@ -1338,8 +1338,8 @@  discard block
 block discarded – undo
1338 1338
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1339 1339
 	*		@return void
1340 1340
 	*/
1341
-	protected function approve_registration( $notify = false ) {
1342
-		$this->_reg_status_change_return( EEM_Registration::status_id_approved, $notify );
1341
+	protected function approve_registration($notify = false) {
1342
+		$this->_reg_status_change_return(EEM_Registration::status_id_approved, $notify);
1343 1343
 	}
1344 1344
 
1345 1345
 
@@ -1351,8 +1351,8 @@  discard block
 block discarded – undo
1351 1351
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1352 1352
 	*		@return void
1353 1353
 	*/
1354
-	protected function decline_registration( $notify = false ) {
1355
-		$this->_reg_status_change_return( EEM_Registration::status_id_declined, $notify );
1354
+	protected function decline_registration($notify = false) {
1355
+		$this->_reg_status_change_return(EEM_Registration::status_id_declined, $notify);
1356 1356
 	}
1357 1357
 
1358 1358
 
@@ -1364,8 +1364,8 @@  discard block
 block discarded – undo
1364 1364
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1365 1365
 	*		@return void
1366 1366
 	*/
1367
-	protected function cancel_registration( $notify = false ) {
1368
-		$this->_reg_status_change_return( EEM_Registration::status_id_cancelled, $notify );
1367
+	protected function cancel_registration($notify = false) {
1368
+		$this->_reg_status_change_return(EEM_Registration::status_id_cancelled, $notify);
1369 1369
 	}
1370 1370
 
1371 1371
 
@@ -1378,8 +1378,8 @@  discard block
 block discarded – undo
1378 1378
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1379 1379
 	*		@return void
1380 1380
 	*/
1381
-	protected function not_approve_registration( $notify = false ) {
1382
-		$this->_reg_status_change_return( EEM_Registration::status_id_not_approved, $notify );
1381
+	protected function not_approve_registration($notify = false) {
1382
+		$this->_reg_status_change_return(EEM_Registration::status_id_not_approved, $notify);
1383 1383
 	}
1384 1384
 
1385 1385
 
@@ -1390,8 +1390,8 @@  discard block
 block discarded – undo
1390 1390
 	*		@param bool $notify whether or not to notify the registrant about their approval.
1391 1391
 	*		@return void
1392 1392
 	*/
1393
-	protected function pending_registration( $notify = false ) {
1394
-		$this->_reg_status_change_return( EEM_Registration::status_id_pending_payment, $notify );
1393
+	protected function pending_registration($notify = false) {
1394
+		$this->_reg_status_change_return(EEM_Registration::status_id_pending_payment, $notify);
1395 1395
 	}
1396 1396
 
1397 1397
 
@@ -1405,75 +1405,75 @@  discard block
 block discarded – undo
1405 1405
 	public function _reg_details_meta_box() {
1406 1406
 		EEH_Autoloader::register_line_item_display_autoloaders();
1407 1407
 		EEH_Autoloader::register_line_item_filter_autoloaders();
1408
-		EE_Registry::instance()->load_Helper( 'Line_Item' );
1408
+		EE_Registry::instance()->load_Helper('Line_Item');
1409 1409
 		$transaction = $this->_registration->transaction() ? $this->_registration->transaction() : EE_Transaction::new_instance();
1410 1410
 		$this->_session = $transaction->session_data();
1411 1411
 
1412 1412
 		$filters = new EE_Line_Item_Filter_Collection();
1413
-		$filters->add( new EE_Single_Registration_Line_Item_Filter( $this->_registration ) );
1414
-		$filters->add( new EE_Non_Zero_Line_Item_Filter() );
1415
-		$line_item_filter_processor = new EE_Line_Item_Filter_Processor( $filters, $transaction->total_line_item() );
1413
+		$filters->add(new EE_Single_Registration_Line_Item_Filter($this->_registration));
1414
+		$filters->add(new EE_Non_Zero_Line_Item_Filter());
1415
+		$line_item_filter_processor = new EE_Line_Item_Filter_Processor($filters, $transaction->total_line_item());
1416 1416
 		$filtered_line_item_tree = $line_item_filter_processor->process();
1417 1417
 
1418 1418
 		$this->_template_args['REG_ID'] = $this->_registration->ID();
1419
-		$line_item_display = new EE_Line_Item_Display( 'reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy' );
1420
-		$this->_template_args['line_item_table'] = $line_item_display->display_line_item( $filtered_line_item_tree, array( 'EE_Registration' => $this->_registration ) );
1419
+		$line_item_display = new EE_Line_Item_Display('reg_admin_table', 'EE_Admin_Table_Registration_Line_Item_Display_Strategy');
1420
+		$this->_template_args['line_item_table'] = $line_item_display->display_line_item($filtered_line_item_tree, array('EE_Registration' => $this->_registration));
1421 1421
 
1422 1422
 
1423 1423
 		$attendee = $this->_registration->attendee();
1424 1424
 
1425 1425
 
1426
-		$this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction' ) ?EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array('action'=> 'view_transaction', 'TXN_ID' => $transaction->ID() ), TXN_ADMIN_URL ), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart' ) : '';
1427
-		$this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'espresso_registrations_resend_registration' ) ?EEH_Template::get_button_or_link( EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'resend_registration', '_REG_ID'=>$this->_registration->ID(), 'redirect_to' => 'view_registration' ), REG_ADMIN_URL ), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt' ) : '';
1426
+		$this->_template_args['view_transaction_button'] = EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action'=> 'view_transaction', 'TXN_ID' => $transaction->ID()), TXN_ADMIN_URL), __(' View Transaction'), 'button secondary-button right', 'dashicons dashicons-cart') : '';
1427
+		$this->_template_args['resend_registration_button'] = $attendee instanceof EE_Attendee && EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'espresso_registrations_resend_registration') ? EEH_Template::get_button_or_link(EE_Admin_Page::add_query_args_and_nonce(array('action'=>'resend_registration', '_REG_ID'=>$this->_registration->ID(), 'redirect_to' => 'view_registration'), REG_ADMIN_URL), __(' Resend Registration'), 'button secondary-button right', 'dashicons dashicons-email-alt') : '';
1428 1428
 
1429 1429
 
1430 1430
 		$this->_template_args['currency_sign'] = EE_Registry::instance()->CFG->currency->sign;
1431
-		$payment = $transaction->get_first_related( 'Payment' );
1431
+		$payment = $transaction->get_first_related('Payment');
1432 1432
 		$payment = ! $payment instanceof EE_Payment ? EE_Payment::new_instance() : $payment;
1433
-		$payment_method = $payment->get_first_related( 'Payment_Method' );
1433
+		$payment_method = $payment->get_first_related('Payment_Method');
1434 1434
 		$payment_method = ! $payment_method instanceof EE_Payment_Method ? EE_Payment_Method::new_instance() : $payment_method;
1435
-		$reg_status_class = 'status-' . $this->_registration->status_ID();
1435
+		$reg_status_class = 'status-'.$this->_registration->status_ID();
1436 1436
 		$reg_details = array(
1437 1437
 			'payment_method' => $payment_method->name(),
1438 1438
 			'response_msg' => $payment->gateway_response(),
1439
-			'registration_id' => $this->_registration->get( 'REG_code' ),
1439
+			'registration_id' => $this->_registration->get('REG_code'),
1440 1440
 			'registration_session' => $this->_registration->session_ID(),
1441
-			'ip_address' => isset( $this->_session['ip_address'] ) ? $this->_session['ip_address'] : '',
1442
-			'user_agent' => isset( $this->_session['user_agent'] ) ? $this->_session['user_agent'] : '',
1441
+			'ip_address' => isset($this->_session['ip_address']) ? $this->_session['ip_address'] : '',
1442
+			'user_agent' => isset($this->_session['user_agent']) ? $this->_session['user_agent'] : '',
1443 1443
 			);
1444 1444
 
1445 1445
 
1446
-		if ( isset( $reg_details['registration_id'] )) {
1446
+		if (isset($reg_details['registration_id'])) {
1447 1447
 			$this->_template_args['reg_details']['registration_id']['value'] = $reg_details['registration_id'];
1448
-			$this->_template_args['reg_details']['registration_id']['label'] = __( 'Registration ID', 'event_espresso' );
1448
+			$this->_template_args['reg_details']['registration_id']['label'] = __('Registration ID', 'event_espresso');
1449 1449
 			$this->_template_args['reg_details']['registration_id']['class'] = 'regular-text';
1450 1450
 		}
1451 1451
 
1452
-		if ( isset( $reg_details['payment_method'] ) ) {
1452
+		if (isset($reg_details['payment_method'])) {
1453 1453
 			$this->_template_args['reg_details']['payment_method']['value'] = $reg_details['payment_method'];
1454
-			$this->_template_args['reg_details']['payment_method']['label'] = __( 'Most Recent Payment Method', 'event_espresso' );
1454
+			$this->_template_args['reg_details']['payment_method']['label'] = __('Most Recent Payment Method', 'event_espresso');
1455 1455
 			$this->_template_args['reg_details']['payment_method']['class'] = 'regular-text';
1456 1456
 			$this->_template_args['reg_details']['response_msg']['value'] = $reg_details['response_msg'];
1457
-			$this->_template_args['reg_details']['response_msg']['label'] = __( 'Payment method response', 'event_espresso' );
1457
+			$this->_template_args['reg_details']['response_msg']['label'] = __('Payment method response', 'event_espresso');
1458 1458
 			$this->_template_args['reg_details']['response_msg']['class'] = 'regular-text';
1459 1459
 		}
1460 1460
 
1461 1461
 		$this->_template_args['reg_details']['registration_session']['value'] = $reg_details['registration_session'];
1462
-		$this->_template_args['reg_details']['registration_session']['label'] = __( 'Registration Session', 'event_espresso' );
1462
+		$this->_template_args['reg_details']['registration_session']['label'] = __('Registration Session', 'event_espresso');
1463 1463
 		$this->_template_args['reg_details']['registration_session']['class'] = 'regular-text';
1464 1464
 
1465 1465
 		$this->_template_args['reg_details']['ip_address']['value'] = $reg_details['ip_address'];
1466
-		$this->_template_args['reg_details']['ip_address']['label'] = __( 'Registration placed from IP', 'event_espresso' );
1466
+		$this->_template_args['reg_details']['ip_address']['label'] = __('Registration placed from IP', 'event_espresso');
1467 1467
 		$this->_template_args['reg_details']['ip_address']['class'] = 'regular-text';
1468 1468
 
1469 1469
 		$this->_template_args['reg_details']['user_agent']['value'] = $reg_details['user_agent'];
1470
-		$this->_template_args['reg_details']['user_agent']['label'] = __( 'Registrant User Agent', 'event_espresso' );
1470
+		$this->_template_args['reg_details']['user_agent']['label'] = __('Registrant User Agent', 'event_espresso');
1471 1471
 		$this->_template_args['reg_details']['user_agent']['class'] = 'large-text';
1472 1472
 
1473
-		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL );
1473
+		$this->_template_args['event_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'default', 'event_id' => $this->_registration->event_ID()), REG_ADMIN_URL);
1474 1474
 
1475
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_details.template.php';
1476
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1475
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_details.template.php';
1476
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1477 1477
 
1478 1478
 	}
1479 1479
 
@@ -1489,23 +1489,23 @@  discard block
 block discarded – undo
1489 1489
 	*/
1490 1490
 	public function _reg_questions_meta_box() {
1491 1491
 
1492
-		add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array( $this, 'form_before_question_group' ), 10, 1 );
1493
-		add_filter( 'FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array( $this, 'form_after_question_group' ), 10, 1 );
1494
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'form_form_field_label_wrap' ), 10, 1 );
1495
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'form_form_field_input__wrap' ), 10, 1 );
1492
+		add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__before_question_group_questions', array($this, 'form_before_question_group'), 10, 1);
1493
+		add_filter('FHEE__EEH_Form_Fields__generate_question_groups_html__after_question_group_questions', array($this, 'form_after_question_group'), 10, 1);
1494
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'form_form_field_label_wrap'), 10, 1);
1495
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'form_form_field_input__wrap'), 10, 1);
1496 1496
 
1497
-		$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options( $this->_registration, $this->_registration->get('EVT_ID') );
1497
+		$question_groups = EEM_Event::instance()->assemble_array_of_groups_questions_and_options($this->_registration, $this->_registration->get('EVT_ID'));
1498 1498
 
1499 1499
 		//EEH_Debug_Tools::printr( $question_groups, '$question_groups  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
1500 1500
 
1501
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
1502
-		$this->_template_args['att_questions'] = EEH_Form_Fields::generate_question_groups_html( $question_groups );
1501
+		EE_Registry::instance()->load_helper('Form_Fields');
1502
+		$this->_template_args['att_questions'] = EEH_Form_Fields::generate_question_groups_html($question_groups);
1503 1503
 
1504 1504
 		$this->_template_args['reg_questions_form_action'] = 'update_attendee_registration_form';
1505 1505
 		$this->_template_args['REG_ID'] = $this->_registration->ID();
1506 1506
 
1507
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_reg_questions.template.php';
1508
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1507
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_reg_questions.template.php';
1508
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1509 1509
 
1510 1510
 	}
1511 1511
 
@@ -1520,7 +1520,7 @@  discard block
 block discarded – undo
1520 1520
 	 * 		@param 		string 		$output
1521 1521
 	 * 		@return 		string
1522 1522
 	 */
1523
-	public function form_before_question_group( $output ) {
1523
+	public function form_before_question_group($output) {
1524 1524
 		return '
1525 1525
 	<table class="form-table ee-width-100">
1526 1526
 		<tbody>
@@ -1537,13 +1537,13 @@  discard block
 block discarded – undo
1537 1537
 	 * 		@param 		string 		$output
1538 1538
 	 * 		@return 		string
1539 1539
 	 */
1540
-	public function form_after_question_group( $output ) {
1540
+	public function form_after_question_group($output) {
1541 1541
 		return  '
1542 1542
 			<tr class="hide-if-no-js">
1543 1543
 				<th> </th>
1544 1544
 				<td class="reg-admin-edit-attendee-question-td">
1545
-					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__( 'click to edit question', 'event_espresso' ) . '">
1546
-						<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __( 'edit the above question group', 'event_espresso' ) . '</span>
1545
+					<a class="reg-admin-edit-attendee-question-lnk" href="#" title="' . esc_attr__('click to edit question', 'event_espresso').'">
1546
+						<span class="reg-admin-edit-question-group-spn lt-grey-txt">' . __('edit the above question group', 'event_espresso').'</span>
1547 1547
 						<div class="dashicons dashicons-edit"></div>
1548 1548
 					</a>
1549 1549
 				</td>
@@ -1563,11 +1563,11 @@  discard block
 block discarded – undo
1563 1563
 	 * 		@param 		string 		$label
1564 1564
 	 * 		@return 		string
1565 1565
 	 */
1566
-	public function form_form_field_label_wrap( $label ) {
1566
+	public function form_form_field_label_wrap($label) {
1567 1567
 		return '
1568 1568
 			<tr>
1569 1569
 				<th>
1570
-					' . $label  . '
1570
+					' . $label.'
1571 1571
 				</th>';
1572 1572
 	}
1573 1573
 
@@ -1581,10 +1581,10 @@  discard block
 block discarded – undo
1581 1581
 	 * 		@param 		string 		$label
1582 1582
 	 * 		@return 		string
1583 1583
 	 */
1584
-	public function form_form_field_input__wrap( $input ) {
1584
+	public function form_form_field_input__wrap($input) {
1585 1585
 		return '
1586 1586
 				<td class="reg-admin-attendee-questions-input-td disabled-input">
1587
-					' . $input . '
1587
+					' . $input.'
1588 1588
 				</td>
1589 1589
 			</tr>';
1590 1590
 	}
@@ -1598,13 +1598,13 @@  discard block
 block discarded – undo
1598 1598
 	*		@return void
1599 1599
 	*/
1600 1600
 	protected function _update_attendee_registration_form() {
1601
-		$qstns = isset( $this->_req_data['qstn'] ) ? $this->_req_data['qstn'] : FALSE;
1602
-		$REG_ID = isset( $this->_req_data['_REG_ID'] ) ? absint( $this->_req_data['_REG_ID'] ) : FALSE;
1603
-		$qstns = apply_filters( 'FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns );
1604
-		$success = $this->_save_attendee_registration_form( $REG_ID, $qstns );
1601
+		$qstns = isset($this->_req_data['qstn']) ? $this->_req_data['qstn'] : FALSE;
1602
+		$REG_ID = isset($this->_req_data['_REG_ID']) ? absint($this->_req_data['_REG_ID']) : FALSE;
1603
+		$qstns = apply_filters('FHEE__Registrations_Admin_Page___update_attendee_registration_form__qstns', $qstns);
1604
+		$success = $this->_save_attendee_registration_form($REG_ID, $qstns);
1605 1605
 		$what = __('Registration Form', 'event_espresso');
1606
-		$route = $REG_ID ? array( 'action' => 'view_registration', '_REG_ID' => $REG_ID ) : array( 'action' => 'default' );
1607
-		$this->_redirect_after_action( $success, $what, __('updated', 'event_espresso'), $route );
1606
+		$route = $REG_ID ? array('action' => 'view_registration', '_REG_ID' => $REG_ID) : array('action' => 'default');
1607
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), $route);
1608 1608
 
1609 1609
 	}
1610 1610
 
@@ -1617,26 +1617,26 @@  discard block
 block discarded – undo
1617 1617
 	 * @param bool $qstns
1618 1618
 	 * @return bool
1619 1619
 	 */
1620
-	private function _save_attendee_registration_form( $REG_ID = FALSE, $qstns = FALSE ) {
1620
+	private function _save_attendee_registration_form($REG_ID = FALSE, $qstns = FALSE) {
1621 1621
 
1622
-		if ( ! $REG_ID || ! $qstns ) {
1623
-			EE_Error::add_error( __('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1622
+		if ( ! $REG_ID || ! $qstns) {
1623
+			EE_Error::add_error(__('An error occurred. No registration ID and/or registration questions were received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1624 1624
 		}
1625 1625
 		$success = TRUE;
1626 1626
 
1627 1627
 		// allow others to get in on this awesome fun   :D
1628
-		do_action( 'AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns );
1628
+		do_action('AHEE__Registrations_Admin_Page___save_attendee_registration_form__after_reg_and_attendee_save', $REG_ID, $qstns);
1629 1629
 		// loop thru questions... FINALLY!!!
1630 1630
 
1631
-		foreach ( $qstns as $QST_ID => $qstn ) {
1631
+		foreach ($qstns as $QST_ID => $qstn) {
1632 1632
 			//if $qstn isn't an array then it doesn't already have an answer, so let's create the answer
1633
-			if ( !is_array($qstn) ) {
1634
-				$success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn);
1633
+			if ( ! is_array($qstn)) {
1634
+				$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
1635 1635
 				continue;
1636 1636
 			}
1637 1637
 
1638 1638
 
1639
-			foreach ( $qstn as $ANS_ID => $ANS_value ) {
1639
+			foreach ($qstn as $ANS_ID => $ANS_value) {
1640 1640
 				//get answer
1641 1641
 				$query_params = array(
1642 1642
 					0 => array(
@@ -1647,8 +1647,8 @@  discard block
 block discarded – undo
1647 1647
 					);
1648 1648
 				$answer = EEM_Answer::instance()->get_one($query_params);
1649 1649
 				//this MAY be an array but NOT have an answer because its multi select.  If so then we need to create the answer
1650
-				if ( ! $answer instanceof EE_Answer ) {
1651
-					$success = $this->_save_new_answer( $REG_ID, $QST_ID, $qstn);
1650
+				if ( ! $answer instanceof EE_Answer) {
1651
+					$success = $this->_save_new_answer($REG_ID, $QST_ID, $qstn);
1652 1652
 					continue 2;
1653 1653
 				}
1654 1654
 
@@ -1662,7 +1662,7 @@  discard block
 block discarded – undo
1662 1662
 
1663 1663
 
1664 1664
 	//TODO: try changing this to use the model directly... not indirectly through creating a default object...
1665
-	private function _save_new_answer( $REG_ID, $QST_ID, $ans ) {
1665
+	private function _save_new_answer($REG_ID, $QST_ID, $ans) {
1666 1666
 		$set_values = array(
1667 1667
 			'QST_ID' => $QST_ID,
1668 1668
 			'REG_ID' => $REG_ID,
@@ -1689,30 +1689,30 @@  discard block
 block discarded – undo
1689 1689
 		$registrations = $REG->get_all(array(
1690 1690
 			array(
1691 1691
 				'TXN_ID'=>$this->_registration->transaction_ID(),
1692
-				'REG_ID'=>array('!=',$this->_registration->ID())
1692
+				'REG_ID'=>array('!=', $this->_registration->ID())
1693 1693
 			),
1694 1694
 			'force_join'=>array('Attendee')));
1695 1695
 
1696 1696
 		$this->_template_args['attendees'] = array();
1697 1697
 		$this->_template_args['attendee_notice'] = '';
1698 1698
 		EE_Registry::instance()->load_helper('Array');
1699
-		if ( empty( $registrations)  || ( is_array($registrations) &&  ! EEH_Array::get_one_item_from_array($registrations) ) ) {
1700
-			EE_Error::add_error( __('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1699
+		if (empty($registrations) || (is_array($registrations) && ! EEH_Array::get_one_item_from_array($registrations))) {
1700
+			EE_Error::add_error(__('There are no records attached to this registration. Something may have gone wrong with the registration', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1701 1701
 			$this->_template_args['attendee_notice'] = EE_Error::get_notices();
1702 1702
 		} else {
1703 1703
 
1704 1704
 			$att_nmbr = 1;
1705
-			foreach ( $registrations as $registration ) {
1705
+			foreach ($registrations as $registration) {
1706 1706
 				/* @var $registration EE_Registration */
1707 1707
 				$attendee = $registration->attendee() ? $registration->attendee() : EEM_Attendee::instance()->create_default_object();
1708
-				$this->_template_args['attendees'][ $att_nmbr ]['fname'] = $attendee->fname();//( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1709
-				$this->_template_args['attendees'][ $att_nmbr ]['lname'] = $attendee->lname();//( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1710
-				$this->_template_args['attendees'][ $att_nmbr ]['email'] = $attendee->email();//( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1711
-				$this->_template_args['attendees'][ $att_nmbr ]['final_price'] = $registration->final_price();//( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1708
+				$this->_template_args['attendees'][$att_nmbr]['fname'] = $attendee->fname(); //( isset( $registration->ATT_fname ) & ! empty( $registration->ATT_fname ) ) ? $registration->ATT_fname : '';
1709
+				$this->_template_args['attendees'][$att_nmbr]['lname'] = $attendee->lname(); //( isset( $registration->ATT_lname ) & ! empty( $registration->ATT_lname ) ) ? $registration->ATT_lname : '';
1710
+				$this->_template_args['attendees'][$att_nmbr]['email'] = $attendee->email(); //( isset( $registration->ATT_email ) & ! empty( $registration->ATT_email ) ) ? $registration->ATT_email : '';
1711
+				$this->_template_args['attendees'][$att_nmbr]['final_price'] = $registration->final_price(); //( isset( $registration->REG_final_price ) & ! empty( $registration->REG_final_price ) ) ? $registration->REG_final_price : '';
1712 1712
 
1713
-				$this->_template_args['attendees'][ $att_nmbr ]['address'] = implode( ', ', $attendee->full_address_as_array() );
1713
+				$this->_template_args['attendees'][$att_nmbr]['address'] = implode(', ', $attendee->full_address_as_array());
1714 1714
 
1715
-				$this->_template_args['attendees'][ $att_nmbr ]['att_link'] = self::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL );
1715
+				$this->_template_args['attendees'][$att_nmbr]['att_link'] = self::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL);
1716 1716
 
1717 1717
 				$att_nmbr++;
1718 1718
 			}
@@ -1724,8 +1724,8 @@  discard block
 block discarded – undo
1724 1724
 
1725 1725
 	//			$this->_template_args['registration_form_url'] = add_query_arg( array( 'action' => 'edit_registration', 'process' => 'attendees'  ), REG_ADMIN_URL );
1726 1726
 		}
1727
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_main_meta_box_attendees.template.php';
1728
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1727
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_main_meta_box_attendees.template.php';
1728
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1729 1729
 
1730 1730
 	}
1731 1731
 
@@ -1746,11 +1746,11 @@  discard block
 block discarded – undo
1746 1746
 		$attendee = $att_check instanceof EE_Attendee ? $att_check : EEM_Attendee::instance()->create_default_object();
1747 1747
 
1748 1748
 		//now let's determine if this is not the primary registration.  If it isn't then we set the primary_registration object for reference BUT ONLY if the Attendee object loaded is not the same as the primary registration object (that way we know if we need to show cereate button or not)
1749
-		if ( ! $this->_registration->is_primary_registrant() ) {
1749
+		if ( ! $this->_registration->is_primary_registrant()) {
1750 1750
 			$primary_registration = $this->_registration->get_primary_registration();
1751 1751
 			$primary_attendee = $primary_registration->attendee();
1752 1752
 
1753
-			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID() ) {
1753
+			if ( ! $primary_attendee instanceof EE_Attendee || $attendee->ID() !== $primary_attendee->ID()) {
1754 1754
 				//in here?  This means the displayed registration is not the primary registrant but ALREADY HAS its own custom attendee object so let's not worry about the primary reg.
1755 1755
 				$primary_registration = NULL;
1756 1756
 			}
@@ -1759,28 +1759,28 @@  discard block
 block discarded – undo
1759 1759
 		}
1760 1760
 
1761 1761
 		$this->_template_args['ATT_ID'] = $attendee->ID();
1762
-		$this->_template_args['fname'] = $attendee->fname();//$this->_registration->ATT_fname;
1763
-		$this->_template_args['lname'] = $attendee->lname();//$this->_registration->ATT_lname;
1764
-		$this->_template_args['email'] = $attendee->email();//$this->_registration->ATT_email;
1762
+		$this->_template_args['fname'] = $attendee->fname(); //$this->_registration->ATT_fname;
1763
+		$this->_template_args['lname'] = $attendee->lname(); //$this->_registration->ATT_lname;
1764
+		$this->_template_args['email'] = $attendee->email(); //$this->_registration->ATT_email;
1765 1765
 		$this->_template_args['phone'] = $attendee->phone();
1766 1766
 
1767
-		EE_Registry::instance()->load_helper( 'Formatter' );
1768
-		$this->_template_args[ 'formatted_address' ] = EEH_Address::format( $attendee );
1767
+		EE_Registry::instance()->load_helper('Formatter');
1768
+		$this->_template_args['formatted_address'] = EEH_Address::format($attendee);
1769 1769
 
1770 1770
 
1771 1771
 		//edit link
1772
-		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_attendee', 'post'=>$attendee->ID() ), REG_ADMIN_URL );
1773
-		$this->_template_args['att_edit_label'] = __('View/Edit Contact' );
1772
+		$this->_template_args['att_edit_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_attendee', 'post'=>$attendee->ID()), REG_ADMIN_URL);
1773
+		$this->_template_args['att_edit_label'] = __('View/Edit Contact');
1774 1774
 
1775 1775
 		//create link
1776
-		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'duplicate_attendee',  '_REG_ID' => $this->_registration->ID() ), REG_ADMIN_URL ): '';
1776
+		$this->_template_args['create_link'] = $primary_registration instanceof EE_Registration ? EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_attendee', '_REG_ID' => $this->_registration->ID()), REG_ADMIN_URL) : '';
1777 1777
 		$this->_template_args['create_label'] = __('Create Contact', 'event_espresso');
1778 1778
 
1779 1779
 		$this->_template_args['att_check'] = $att_check;
1780 1780
 
1781 1781
 
1782
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_details_side_meta_box_registrant.template.php';
1783
-		echo EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
1782
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_details_side_meta_box_registrant.template.php';
1783
+		echo EEH_Template::display_template($template_path, $this->_template_args, TRUE);
1784 1784
 	}
1785 1785
 
1786 1786
 
@@ -1793,7 +1793,7 @@  discard block
 block discarded – undo
1793 1793
 	 * @access protected
1794 1794
 	 * @return void
1795 1795
 	 */
1796
-	protected function _trash_or_restore_registrations( $trash = TRUE ) {
1796
+	protected function _trash_or_restore_registrations($trash = TRUE) {
1797 1797
 		$REGM = EEM_Registration::instance();
1798 1798
 
1799 1799
 		$success = 1;
@@ -1803,26 +1803,26 @@  discard block
 block discarded – undo
1803 1803
 		$dtts = array();
1804 1804
 
1805 1805
 		//if empty _REG_ID then get out because there's nothing to do
1806
-		if ( empty( $this->_req_data['_REG_ID'] ) ) {
1806
+		if (empty($this->_req_data['_REG_ID'])) {
1807 1807
 			$msg = $trash ? __('In order to trash registrations you must select which ones you wish to trash by clicking the checkboxes.', 'event_espresso') : __('In order to restore registrations you must select which ones you wish to restore by clicking the checkboxes.', 'event_espresso');
1808
-			EE_Error::add_error( $msg, __FILE__, __LINE__, __FUNCTION__ );
1809
-			$this->_redirect_after_action(FALSE, '', '', array(), TRUE );
1808
+			EE_Error::add_error($msg, __FILE__, __LINE__, __FUNCTION__);
1809
+			$this->_redirect_after_action(FALSE, '', '', array(), TRUE);
1810 1810
 		}
1811 1811
 
1812 1812
 		//Checkboxes
1813
-		if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1813
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1814 1814
 			// if array has more than one element than success message should be plural
1815
-			$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1;
1815
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
1816 1816
 			// cycle thru checkboxes
1817
-			while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) {
1817
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
1818 1818
 
1819 1819
 				$REG = $REGM->get_one_by_ID($REG_ID);
1820 1820
 				$payment_count = $REG->get_first_related('Transaction')->count_related('Payment');
1821
-				if ( $payment_count > 0 ) {
1822
-					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __( 'Unknown Attendee', 'event_espresso' );
1821
+				if ($payment_count > 0) {
1822
+					$name = $REG->attendee() instanceof EE_Attendee ? $REG->attendee()->full_name() : __('Unknown Attendee', 'event_espresso');
1823 1823
 					$error = 1;
1824 1824
 					$success = 0;
1825
-					EE_Error::add_error( sprintf( __('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name ), __FILE__, __FUNCTION__, __LINE__ );
1825
+					EE_Error::add_error(sprintf(__('The registration for %s could not be trashed because it has payments attached to the related transaction.  If you wish to trash this registration you must first delete the payments on the related transaction.', 'event_espresso'), $name), __FILE__, __FUNCTION__, __LINE__);
1826 1826
 					continue; //can't trash this registration because it has payments.
1827 1827
 				}
1828 1828
 				$ticket = $REG->get_first_related('Ticket');
@@ -1831,7 +1831,7 @@  discard block
 block discarded – undo
1831 1831
 				$dtts = array_merge($dtts, $dtt);
1832 1832
 
1833 1833
 				$updated = $trash ? $REG->delete() : $REG->restore();
1834
-				if ( !$updated ) {
1834
+				if ( ! $updated) {
1835 1835
 					$success = 0;
1836 1836
 				} else {
1837 1837
 					$success = 2;
@@ -1846,7 +1846,7 @@  discard block
 block discarded – undo
1846 1846
 			$tickets[$ticket->ID()] = $ticket;
1847 1847
 			$dtts = $ticket->get_many_related('Datetime');
1848 1848
 			$updated = $trash ? $REG->delete() : $REG->restore();
1849
-			if ( ! $updated ) {
1849
+			if ( ! $updated) {
1850 1850
 				$success = 0;
1851 1851
 			}
1852 1852
 
@@ -1856,10 +1856,10 @@  discard block
 block discarded – undo
1856 1856
 		EEM_Ticket::instance()->update_tickets_sold($tickets);
1857 1857
 		EEM_Datetime::instance()->update_sold($dtts);
1858 1858
 
1859
-		$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' );
1860
-		$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' );
1859
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
1860
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
1861 1861
 		$overwrite_msgs = $error ? TRUE : FALSE;
1862
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), $overwrite_msgs );
1862
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), $overwrite_msgs);
1863 1863
 	}
1864 1864
 
1865 1865
 
@@ -1883,16 +1883,16 @@  discard block
 block discarded – undo
1883 1883
 		$success = 1;
1884 1884
 
1885 1885
 		//Checkboxes
1886
-		if (!empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1886
+		if ( ! empty($this->_req_data['_REG_ID']) && is_array($this->_req_data['_REG_ID'])) {
1887 1887
 			// if array has more than one element than success message should be plural
1888
-			$success = count( $this->_req_data['_REG_ID'] ) > 1 ? 2 : 1;
1888
+			$success = count($this->_req_data['_REG_ID']) > 1 ? 2 : 1;
1889 1889
 			// cycle thru checkboxes
1890
-			while (list( $ind, $REG_ID ) = each($this->_req_data['_REG_ID'])) {
1890
+			while (list($ind, $REG_ID) = each($this->_req_data['_REG_ID'])) {
1891 1891
 				$REG = $REG_MDL->get_one_by_ID($REG_ID);
1892
-				if ( ! $REG instanceof EE_Registration )
1892
+				if ( ! $REG instanceof EE_Registration)
1893 1893
 					continue;
1894 1894
 				$deleted = $this->_delete_registration($REG);
1895
-				if ( !$deleted ) {
1895
+				if ( ! $deleted) {
1896 1896
 					$success = 0;
1897 1897
 				}
1898 1898
 			}
@@ -1902,15 +1902,15 @@  discard block
 block discarded – undo
1902 1902
 			$REG_ID = $this->_req_data['_REG_ID'];
1903 1903
 			$REG = $REG_MDL->get_one_by_ID($REG_ID);
1904 1904
 			$deleted = $this->_delete_registration($REG);
1905
-			if ( ! $deleted ) {
1905
+			if ( ! $deleted) {
1906 1906
 				$success = 0;
1907 1907
 			}
1908 1908
 
1909 1909
 		}
1910 1910
 
1911
-		$what = $success > 1 ? __( 'Registrations', 'event_espresso' ) : __( 'Registration', 'event_espresso' );
1912
-		$action_desc = __( 'permanently deleted.', 'event_espresso' );
1913
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'default' ), TRUE );
1911
+		$what = $success > 1 ? __('Registrations', 'event_espresso') : __('Registration', 'event_espresso');
1912
+		$action_desc = __('permanently deleted.', 'event_espresso');
1913
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'default'), TRUE);
1914 1914
 	}
1915 1915
 
1916 1916
 
@@ -1922,31 +1922,31 @@  discard block
 block discarded – undo
1922 1922
 	 * @param  EE_Registration $REG registration to be deleted permenantly
1923 1923
 	 * @return boolean              true = successful deletion, false = fail.
1924 1924
 	 */
1925
-	protected function _delete_registration( EE_Registration $REG ) {
1925
+	protected function _delete_registration(EE_Registration $REG) {
1926 1926
 		//first we start with the transaction... ultimately, we WILL not delete permanently if there are any related registrations on the transaction that are NOT trashed.
1927 1927
 		$TXN = $REG->get_first_related('Transaction');
1928 1928
 		$REGS = $TXN->get_many_related('Registration');
1929 1929
 
1930 1930
 		$all_trashed = TRUE;
1931
-		foreach ( $REGS as $registration ) {
1932
-			if ( ! $registration->get('REG_deleted') )
1931
+		foreach ($REGS as $registration) {
1932
+			if ( ! $registration->get('REG_deleted'))
1933 1933
 				$all_trashed = FALSE;
1934 1934
 		}
1935 1935
 
1936
-		if ( ! $all_trashed ) {
1937
-			EE_Error::add_error( __('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1936
+		if ( ! $all_trashed) {
1937
+			EE_Error::add_error(__('Unable to permanently delete this registration. Before this registration can be permanently deleted, all registrations made in the same transaction must be trashed as well.  These registrations will be permanently deleted in the same action.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1938 1938
 			return false;
1939 1939
 		}
1940 1940
 
1941 1941
 		//k made it here so that means we can delete all the related transactions and their answers (but let's do them separately from THIS one).
1942
-		foreach ( $REGS as $registration ) {
1942
+		foreach ($REGS as $registration) {
1943 1943
 
1944 1944
 			//delete related answers
1945 1945
 			$registration->delete_related_permanently('Answer');
1946 1946
 
1947 1947
 			//remove relationship to EE_Attendee (but we ALWAYS leave the contact record intact)
1948 1948
 			$attendee = $registration->get_first_related('Attendee');
1949
-			if ( $attendee instanceof EE_Attendee ) {
1949
+			if ($attendee instanceof EE_Attendee) {
1950 1950
 				$registration->_remove_relation_to($attendee, 'Attendee');
1951 1951
 			}
1952 1952
 
@@ -1956,7 +1956,7 @@  discard block
 block discarded – undo
1956 1956
 			//now delete permanently the checkins related to this registration.
1957 1957
 			$registration->delete_related_permanently('Checkin');
1958 1958
 
1959
-			if ( $registration->ID() === $REG->ID() )
1959
+			if ($registration->ID() === $REG->ID())
1960 1960
 				continue; //we don't want to delete permanently the existing registration just yet.
1961 1961
 
1962 1962
 			//remove relation to transaction for these registrations if NOT the existing registrations
@@ -1989,34 +1989,34 @@  discard block
 block discarded – undo
1989 1989
 	 * @return void
1990 1990
 	 */
1991 1991
 	public function new_registration() {
1992
-		if ( ! $this->_set_reg_event() ) {
1993
-			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso') );
1992
+		if ( ! $this->_set_reg_event()) {
1993
+			throw new EE_Error(__('Unable to continue with registering because there is no Event ID in the request', 'event_espresso'));
1994 1994
 		}
1995
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
1995
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
1996 1996
 
1997 1997
 		// gotta start with a clean slate if we're not coming here via ajax
1998
-		if ( ! defined('DOING_AJAX' ) && ( ! isset( $this->_req_data['processing_registration'] ) || isset( $this->_req_data['step_error'] ))) {
1999
-			EE_Registry::instance()->SSN->clear_session( __CLASS__, __FUNCTION__ );
1998
+		if ( ! defined('DOING_AJAX') && ( ! isset($this->_req_data['processing_registration']) || isset($this->_req_data['step_error']))) {
1999
+			EE_Registry::instance()->SSN->clear_session(__CLASS__, __FUNCTION__);
2000 2000
 		}
2001 2001
 
2002
-		$this->_template_args['event_name'] = '' ;
2002
+		$this->_template_args['event_name'] = '';
2003 2003
 		// event name
2004
-		if ( $this->_reg_event ) {
2004
+		if ($this->_reg_event) {
2005 2005
 			$this->_template_args['event_name'] = $this->_reg_event->name();
2006
-			$edit_event_url = self::add_query_args_and_nonce( array( 'action'=>'edit', 'post'=>$this->_reg_event->ID() ), EVENTS_ADMIN_URL );
2007
-			$edit_event_lnk = '<a href="'.$edit_event_url.'" title="' . esc_attr__( 'Edit ', 'event_espresso' ) . $this->_reg_event->name() . '">' . __( 'Edit Event', 'event_espresso' ) . '</a>';
2008
-			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">' . $edit_event_lnk . '</span>' ;
2006
+			$edit_event_url = self::add_query_args_and_nonce(array('action'=>'edit', 'post'=>$this->_reg_event->ID()), EVENTS_ADMIN_URL);
2007
+			$edit_event_lnk = '<a href="'.$edit_event_url.'" title="'.esc_attr__('Edit ', 'event_espresso').$this->_reg_event->name().'">'.__('Edit Event', 'event_espresso').'</a>';
2008
+			$this->_template_args['event_name'] .= ' <span class="admin-page-header-edit-lnk not-bold">'.$edit_event_lnk.'</span>';
2009 2009
 		}
2010 2010
 
2011 2011
 		$this->_template_args['step_content'] = $this->_get_registration_step_content();
2012 2012
 
2013
-		if ( defined('DOING_AJAX' ) )
2013
+		if (defined('DOING_AJAX'))
2014 2014
 			$this->_return_json();
2015 2015
 
2016 2016
 
2017 2017
 		// grab header
2018
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee.template.php';
2019
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, $this->_template_args, TRUE );
2018
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee.template.php';
2019
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, $this->_template_args, TRUE);
2020 2020
 
2021 2021
 		//$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
2022 2022
 		// the details template wrapper
@@ -2034,7 +2034,7 @@  discard block
 block discarded – undo
2034 2034
 	 */
2035 2035
 	protected function _get_registration_step_content() {
2036 2036
 
2037
-		$template_path = REG_TEMPLATE_PATH . 'reg_admin_register_new_attendee_step_content.template.php';
2037
+		$template_path = REG_TEMPLATE_PATH.'reg_admin_register_new_attendee_step_content.template.php';
2038 2038
 		$template_args = array(
2039 2039
 			'title' => '',
2040 2040
 			'content' => '',
@@ -2055,11 +2055,11 @@  discard block
 block discarded – undo
2055 2055
 
2056 2056
 		//if the cart is empty then we know we're at step one so we'll display ticket selector
2057 2057
 		$cart = EE_Registry::instance()->SSN->get_session_data('cart');
2058
-		$step = empty( $cart ) ? 'ticket' : 'questions';
2059
-		switch ( $step ) {
2058
+		$step = empty($cart) ? 'ticket' : 'questions';
2059
+		switch ($step) {
2060 2060
 			case 'ticket' :
2061 2061
 				$template_args['title'] = __('Step One: Select the Ticket for this registration', 'event_espresso');
2062
-				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector( $this->_reg_event );
2062
+				$template_args['content'] = EED_Ticket_Selector::instance()->display_ticket_selector($this->_reg_event);
2063 2063
 				$template_args['step_button_text'] = __('Add Tickets and Continue to Registrant Details', 'event_espresso');
2064 2064
 				$template_args['show_notification_toggle'] = FALSE;
2065 2065
 				break;
@@ -2072,9 +2072,9 @@  discard block
 block discarded – undo
2072 2072
 				break;
2073 2073
 		}
2074 2074
 
2075
-		$this->_set_add_edit_form_tags( 'process_reg_step', $hidden_fields ); //we come back to the process_registration_step route.
2075
+		$this->_set_add_edit_form_tags('process_reg_step', $hidden_fields); //we come back to the process_registration_step route.
2076 2076
 
2077
-		return EEH_Template::display_template( $template_path, $template_args, TRUE );
2077
+		return EEH_Template::display_template($template_path, $template_args, TRUE);
2078 2078
 	}
2079 2079
 
2080 2080
 
@@ -2088,11 +2088,11 @@  discard block
 block discarded – undo
2088 2088
 	*		@return boolean
2089 2089
 	*/
2090 2090
 	private function _set_reg_event() {
2091
-		if ( is_object( $this->_reg_event )) {
2091
+		if (is_object($this->_reg_event)) {
2092 2092
 			return TRUE;
2093 2093
 		}
2094
-		$EVT_ID = ( ! empty( $this->_req_data['event_id'] )) ? absint( $this->_req_data['event_id'] ) : FALSE;
2095
-		if ( ! $EVT_ID ) {
2094
+		$EVT_ID = ( ! empty($this->_req_data['event_id'])) ? absint($this->_req_data['event_id']) : FALSE;
2095
+		if ( ! $EVT_ID) {
2096 2096
 			return FALSE;
2097 2097
 		}
2098 2098
 
@@ -2113,62 +2113,62 @@  discard block
 block discarded – undo
2113 2113
 	public function process_reg_step() {
2114 2114
 
2115 2115
 		$this->_set_reg_event();
2116
-		EE_Registry::instance()->REQ->set_espresso_page( TRUE );
2116
+		EE_Registry::instance()->REQ->set_espresso_page(TRUE);
2117 2117
 
2118 2118
 		//what step are we on?
2119
-		$cart = EE_Registry::instance()->SSN->get_session_data( 'cart' );
2120
-		$step = empty( $cart ) ? 'ticket' : 'questions';
2119
+		$cart = EE_Registry::instance()->SSN->get_session_data('cart');
2120
+		$step = empty($cart) ? 'ticket' : 'questions';
2121 2121
 
2122 2122
 		//if doing ajax then we need to verify the nonce
2123
-		if ( 'DOING_AJAX' ) {
2124
-			$nonce = isset( $this->_req_data[$this->_req_nonce] ) ? sanitize_text_field( $this->_req_data[$this->_req_nonce] ) : '';
2125
-			$this->_verify_nonce( $nonce, $this->_req_nonce );
2123
+		if ('DOING_AJAX') {
2124
+			$nonce = isset($this->_req_data[$this->_req_nonce]) ? sanitize_text_field($this->_req_data[$this->_req_nonce]) : '';
2125
+			$this->_verify_nonce($nonce, $this->_req_nonce);
2126 2126
 		}
2127 2127
 
2128
-		switch ( $step ) {
2128
+		switch ($step) {
2129 2129
 			case 'ticket' :
2130 2130
 				//process ticket selection
2131 2131
 				$success = EED_Ticket_Selector::instance()->process_ticket_selections();
2132
-				if ( $success ) {
2133
-					EE_Error::add_success( __('Tickets Selected. Now complete the registration.'), 'event_espresso');
2132
+				if ($success) {
2133
+					EE_Error::add_success(__('Tickets Selected. Now complete the registration.'), 'event_espresso');
2134 2134
 				} else {
2135 2135
 					$query_args['step_error'] = $this->_req_data['step_error'] = TRUE;
2136 2136
 				}
2137
-				if ( defined('DOING_AJAX') ) {
2137
+				if (defined('DOING_AJAX')) {
2138 2138
 					$this->new_registration(); //display next step
2139 2139
 				} else {
2140 2140
 					$query_args['action'] = 'new_registration';
2141 2141
 					$query_args['processing_registration'] = true;
2142 2142
 					$query_args['event_id'] = $this->_reg_event->ID();
2143
-					$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2143
+					$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2144 2144
 				}
2145 2145
 				break;
2146 2146
 			case 'questions' :
2147
-				if( ! isset( $this->_req_data[ 'txn_reg_status_change' ], $this->_req_data[ 'txn_reg_status_change' ][ 'send_notifications' ] ) ) {
2148
-					add_filter( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15 );
2147
+				if ( ! isset($this->_req_data['txn_reg_status_change'], $this->_req_data['txn_reg_status_change']['send_notifications'])) {
2148
+					add_filter('FHEE__EED_Messages___maybe_registration__deliver_notifications', '__return_false', 15);
2149 2149
 				}
2150 2150
 				//process registration
2151 2151
 				$transaction = EED_Single_Page_Checkout::instance()->process_registration_from_admin();
2152
-				if ( ! $transaction instanceof EE_Transaction ) {
2152
+				if ( ! $transaction instanceof EE_Transaction) {
2153 2153
 					$query_args = array(
2154 2154
 						'action' => 'new_registration',
2155 2155
 						'processing_registration' => true,
2156 2156
 						'event_id' => $this->_reg_event->ID()
2157 2157
 					);
2158 2158
 
2159
-					if ( defined('DOING_AJAX' )) {
2159
+					if (defined('DOING_AJAX')) {
2160 2160
 						//display registration form again because there are errors (maybe validation?)
2161 2161
 						$this->new_registration();
2162 2162
 						return;
2163 2163
 					} else {
2164
-						$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2164
+						$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2165 2165
 						return;
2166 2166
 					}
2167 2167
 				}
2168 2168
 				/** @type EE_Transaction_Payments $transaction_payments */
2169
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
2169
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
2170 2170
 				// maybe update status, and make sure to save transaction if not done already
2171
-				if ( ! $transaction_payments->update_transaction_status_based_on_total_paid( $transaction )) {
2171
+				if ( ! $transaction_payments->update_transaction_status_based_on_total_paid($transaction)) {
2172 2172
 					$transaction->save();
2173 2173
 				}
2174 2174
 				$query_args = array(
@@ -2176,8 +2176,8 @@  discard block
 block discarded – undo
2176 2176
 					'TXN_ID' => $transaction->ID(),
2177 2177
 					'page' => 'espresso_transactions'
2178 2178
 				);
2179
-				EE_Error::add_success( __('Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso') );
2180
-				$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
2179
+				EE_Error::add_success(__('Registration Created.  Please review the transaction and add any payments as necessary', 'event_espresso'));
2180
+				$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2181 2181
 				break;
2182 2182
 			}
2183 2183
 
@@ -2197,7 +2197,7 @@  discard block
 block discarded – undo
2197 2197
 	*		@return void
2198 2198
 	*/
2199 2199
 	protected function _attendee_contact_list_table() {
2200
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2200
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2201 2201
 		$this->_search_btn_label = __('Contacts', 'event_espresso');
2202 2202
 		$this->display_admin_list_table_page_with_no_sidebar();
2203 2203
 	}
@@ -2212,10 +2212,10 @@  discard block
 block discarded – undo
2212 2212
 	*		@access public
2213 2213
 	*		@return array
2214 2214
 	*/
2215
-	public function get_attendees( $per_page, $count = FALSE, $trash = FALSE ) {
2215
+	public function get_attendees($per_page, $count = FALSE, $trash = FALSE) {
2216 2216
 
2217
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2218
-		require_once( REG_ADMIN . 'EE_Attendee_Contact_List_Table.class.php' );
2217
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2218
+		require_once(REG_ADMIN.'EE_Attendee_Contact_List_Table.class.php');
2219 2219
 		$ATT_MDL = EEM_Attendee::instance();
2220 2220
 
2221 2221
 		$this->_req_data['orderby'] = ! empty($this->_req_data['orderby']) ? $this->_req_data['orderby'] : '';
@@ -2243,47 +2243,47 @@  discard block
 block discarded – undo
2243 2243
 				$orderby = 'ATT_lname';
2244 2244
 		}
2245 2245
 
2246
-		$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'ASC';
2246
+		$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
2247 2247
 
2248
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
2249
-		$per_page = isset( $per_page ) && !empty( $per_page ) ? $per_page : 10;
2250
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
2248
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
2249
+		$per_page = isset($per_page) && ! empty($per_page) ? $per_page : 10;
2250
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
2251 2251
 
2252 2252
 		$_where = array();
2253 2253
 
2254
-		if ( isset( $this->_req_data['s'] ) ) {
2255
-			$sstr = '%' . $this->_req_data['s'] . '%';
2254
+		if (isset($this->_req_data['s'])) {
2255
+			$sstr = '%'.$this->_req_data['s'].'%';
2256 2256
 			$_where['OR'] = array(
2257
-				'Registration.Event.EVT_name' => array( 'LIKE', $sstr),
2258
-				'Registration.Event.EVT_desc' => array( 'LIKE', $sstr ),
2259
-				'Registration.Event.EVT_short_desc' => array( 'LIKE' , $sstr ),
2260
-				'ATT_fname' => array( 'LIKE', $sstr ),
2261
-				'ATT_lname' => array( 'LIKE', $sstr ),
2262
-				'ATT_short_bio' => array( 'LIKE', $sstr ),
2263
-				'ATT_email' => array('LIKE', $sstr ),
2264
-				'ATT_address' => array( 'LIKE', $sstr ),
2265
-				'ATT_address2' => array( 'LIKE', $sstr ),
2266
-				'ATT_city' => array( 'LIKE', $sstr ),
2267
-				'Country.CNT_name' => array( 'LIKE', $sstr ),
2268
-				'State.STA_name' => array('LIKE', $sstr ),
2269
-				'ATT_phone' => array( 'LIKE', $sstr ),
2270
-				'Registration.REG_final_price' => array( 'LIKE', $sstr ),
2271
-				'Registration.REG_code' => array( 'LIKE', $sstr ),
2272
-				'Registration.REG_count' => array( 'LIKE' , $sstr ),
2273
-				'Registration.REG_group_size' => array( 'LIKE' , $sstr )
2257
+				'Registration.Event.EVT_name' => array('LIKE', $sstr),
2258
+				'Registration.Event.EVT_desc' => array('LIKE', $sstr),
2259
+				'Registration.Event.EVT_short_desc' => array('LIKE', $sstr),
2260
+				'ATT_fname' => array('LIKE', $sstr),
2261
+				'ATT_lname' => array('LIKE', $sstr),
2262
+				'ATT_short_bio' => array('LIKE', $sstr),
2263
+				'ATT_email' => array('LIKE', $sstr),
2264
+				'ATT_address' => array('LIKE', $sstr),
2265
+				'ATT_address2' => array('LIKE', $sstr),
2266
+				'ATT_city' => array('LIKE', $sstr),
2267
+				'Country.CNT_name' => array('LIKE', $sstr),
2268
+				'State.STA_name' => array('LIKE', $sstr),
2269
+				'ATT_phone' => array('LIKE', $sstr),
2270
+				'Registration.REG_final_price' => array('LIKE', $sstr),
2271
+				'Registration.REG_code' => array('LIKE', $sstr),
2272
+				'Registration.REG_count' => array('LIKE', $sstr),
2273
+				'Registration.REG_group_size' => array('LIKE', $sstr)
2274 2274
 				);
2275 2275
 		}
2276 2276
 
2277 2277
 
2278
-		$offset = ($current_page-1)*$per_page;
2279
-		$limit = $count ? NULL : array( $offset, $per_page );
2278
+		$offset = ($current_page - 1) * $per_page;
2279
+		$limit = $count ? NULL : array($offset, $per_page);
2280 2280
 
2281
-		if ( $trash ) {
2282
-			$_where['status'] = array( '!=', 'publish' );
2283
-			$all_attendees = $count ? $ATT_MDL->count( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit)): $ATT_MDL->get_all( array($_where,'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2281
+		if ($trash) {
2282
+			$_where['status'] = array('!=', 'publish');
2283
+			$all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2284 2284
 		} else {
2285
-			$_where['status'] = array( 'IN', array( 'publish' ) );
2286
-			$all_attendees = $count ? $ATT_MDL->count( array($_where, 'order_by'=>array($orderby=>$sort),'limit'=>$limit)) : $ATT_MDL->get_all( array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit) );
2285
+			$_where['status'] = array('IN', array('publish'));
2286
+			$all_attendees = $count ? $ATT_MDL->count(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit)) : $ATT_MDL->get_all(array($_where, 'order_by'=>array($orderby=>$sort), 'limit'=>$limit));
2287 2287
 		}
2288 2288
 
2289 2289
 		return $all_attendees;
@@ -2300,10 +2300,10 @@  discard block
 block discarded – undo
2300 2300
 	 */
2301 2301
 	protected function _resend_registration() {
2302 2302
 		$this->_process_resend_registration();
2303
-		$query_args = isset($this->_req_data['redirect_to'] ) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID'] ) : array(
2303
+		$query_args = isset($this->_req_data['redirect_to']) ? array('action' => $this->_req_data['redirect_to'], '_REG_ID' => $this->_req_data['_REG_ID']) : array(
2304 2304
 			'action' => 'default'
2305 2305
 		);
2306
-		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE );
2306
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
2307 2307
 	}
2308 2308
 
2309 2309
 
@@ -2311,27 +2311,27 @@  discard block
 block discarded – undo
2311 2311
 
2312 2312
 
2313 2313
 
2314
-	public function _registrations_report(){
2315
-		if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) {
2316
-			wp_redirect( EE_Admin_Page::add_query_args_and_nonce(
2314
+	public function _registrations_report() {
2315
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2316
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
2317 2317
 				array(
2318 2318
 					'page' => 'espresso_support',
2319 2319
 					'action' => 'batch_file_create',
2320
-					'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL,
2321
-					'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\RegistrationsReport' ),
2322
-					'redirect_url' => urlencode( $this->_req_data[ 'return_url' ] ),
2323
-				)) );
2320
+					'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL,
2321
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\RegistrationsReport'),
2322
+					'redirect_url' => urlencode($this->_req_data['return_url']),
2323
+				)));
2324 2324
 		} else {
2325
-			EE_Registry::instance()->load_helper( 'File' );
2325
+			EE_Registry::instance()->load_helper('File');
2326 2326
 			$new_request_args = array(
2327 2327
 				'export' => 'report',
2328 2328
 				'action' => 'registrations_report_for_event',
2329
-				'EVT_ID' => isset( $this->_req_data[ 'EVT_ID'] ) ? $this->_req_data[ 'EVT_ID' ] : NULL,
2329
+				'EVT_ID' => isset($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : NULL,
2330 2330
 			);
2331 2331
 			$this->_req_data = array_merge($this->_req_data, $new_request_args);
2332 2332
 
2333
-			if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2334
-				require_once(EE_CLASSES . 'EE_Export.class.php');
2333
+			if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2334
+				require_once(EE_CLASSES.'EE_Export.class.php');
2335 2335
 				$EE_Export = EE_Export::instance($this->_req_data);
2336 2336
 				$EE_Export->export();
2337 2337
 			}
@@ -2340,28 +2340,28 @@  discard block
 block discarded – undo
2340 2340
 
2341 2341
 
2342 2342
 
2343
-	public function _contact_list_export(){
2344
-		EE_Registry::instance()->load_helper( 'File' );
2345
-		if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2346
-			require_once(EE_CLASSES . 'EE_Export.class.php');
2343
+	public function _contact_list_export() {
2344
+		EE_Registry::instance()->load_helper('File');
2345
+		if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2346
+			require_once(EE_CLASSES.'EE_Export.class.php');
2347 2347
 			$EE_Export = EE_Export::instance($this->_req_data);
2348 2348
 			$EE_Export->export_attendees();
2349 2349
 		}
2350 2350
 	}
2351 2351
 
2352
-	public function _contact_list_report(){
2353
-		if( ! defined( 'EE_USE_OLD_CSV_REPORT_CLASS' ) ) {
2354
-			wp_redirect( EE_Admin_Page::add_query_args_and_nonce(
2352
+	public function _contact_list_report() {
2353
+		if ( ! defined('EE_USE_OLD_CSV_REPORT_CLASS')) {
2354
+			wp_redirect(EE_Admin_Page::add_query_args_and_nonce(
2355 2355
 				array(
2356 2356
 					'page' => 'espresso_support',
2357 2357
 					'action' => 'batch_file_create',
2358
-					'job_handler' => urlencode( 'EventEspressoBatchRequest\JobHandlers\AttendeesReport' ),
2359
-					'redirect_url' => urlencode( $this->_req_data[ 'return_url' ] ),
2360
-				)) );
2358
+					'job_handler' => urlencode('EventEspressoBatchRequest\JobHandlers\AttendeesReport'),
2359
+					'redirect_url' => urlencode($this->_req_data['return_url']),
2360
+				)));
2361 2361
 		} else {
2362
-			EE_Registry::instance()->load_helper( 'File' );
2363
-			if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
2364
-				require_once(EE_CLASSES . 'EE_Export.class.php');
2362
+			EE_Registry::instance()->load_helper('File');
2363
+			if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
2364
+				require_once(EE_CLASSES.'EE_Export.class.php');
2365 2365
 				$EE_Export = EE_Export::instance($this->_req_data);
2366 2366
 				$EE_Export->report_attendees();
2367 2367
 			}
@@ -2381,73 +2381,73 @@  discard block
 block discarded – undo
2381 2381
 	 * @return void
2382 2382
 	 */
2383 2383
 	protected function _duplicate_attendee() {
2384
-		$action = !empty( $this->_req_data['return'] ) ? $this->_req_data['return'] : 'default';
2384
+		$action = ! empty($this->_req_data['return']) ? $this->_req_data['return'] : 'default';
2385 2385
 		//verify we have necessary info
2386
-		if ( empty($this->_req_data['_REG_ID'] )  ) {
2387
-			EE_Error::add_error( __('Unable to create the contact for the registration because the required paramaters are not present (_REG_ID )', 'event_espresso'),  __FILE__, __LINE__, __FUNCTION__ );
2388
-			$query_args = array( 'action' => $action );
2386
+		if (empty($this->_req_data['_REG_ID'])) {
2387
+			EE_Error::add_error(__('Unable to create the contact for the registration because the required paramaters are not present (_REG_ID )', 'event_espresso'), __FILE__, __LINE__, __FUNCTION__);
2388
+			$query_args = array('action' => $action);
2389 2389
 			$this->_redirect_after_action('', '', '', $query_args, TRUE);
2390 2390
 		}
2391 2391
 
2392 2392
 		//okay necessary deets present... let's dupe the incoming attendee and attach to incoming registration.
2393
-		$registration = EEM_Registration::instance()->get_one_by_ID( $this->_req_data['_REG_ID'] );
2393
+		$registration = EEM_Registration::instance()->get_one_by_ID($this->_req_data['_REG_ID']);
2394 2394
 		$attendee = $registration->attendee();
2395 2395
 
2396 2396
 		//remove relation of existing attendee on registration
2397
-		$registration->_remove_relation_to($attendee, 'Attendee' );
2397
+		$registration->_remove_relation_to($attendee, 'Attendee');
2398 2398
 		//new attendee
2399 2399
 		$new_attendee = clone $attendee;
2400
-		$new_attendee->set( 'ATT_ID', 0 );
2400
+		$new_attendee->set('ATT_ID', 0);
2401 2401
 		$new_attendee->save();
2402 2402
 
2403 2403
 		//add new attendee to reg
2404
-		$registration->_add_relation_to( $new_attendee, 'Attendee');
2404
+		$registration->_add_relation_to($new_attendee, 'Attendee');
2405 2405
 
2406
-		EE_Error::add_success( __('New Contact record created.  Now make any edits you wish to make for this contact.', 'event_espresso') );
2406
+		EE_Error::add_success(__('New Contact record created.  Now make any edits you wish to make for this contact.', 'event_espresso'));
2407 2407
 
2408 2408
 		//redirect to edit page for attendee
2409
-		$query_args = array( 'post' => $new_attendee->ID(), 'action' => 'edit_attendee' );
2409
+		$query_args = array('post' => $new_attendee->ID(), 'action' => 'edit_attendee');
2410 2410
 
2411
-		$this->_redirect_after_action( '', '', '', $query_args, TRUE );
2411
+		$this->_redirect_after_action('', '', '', $query_args, TRUE);
2412 2412
 	}
2413 2413
 
2414 2414
 
2415 2415
 	//related to cpt routes
2416 2416
 	protected function _insert_update_cpt_item($post_id, $post) {
2417 2417
 		$success = true;
2418
-		$attendee = EEM_Attendee::instance()->get_one_by_ID( $post_id );
2418
+		$attendee = EEM_Attendee::instance()->get_one_by_ID($post_id);
2419 2419
 		//for attendee updates
2420
-		if ( $post->post_type = 'espresso_attendees' && !empty( $attendee ) ) {
2420
+		if ($post->post_type = 'espresso_attendees' && ! empty($attendee)) {
2421 2421
 			//note we should only be UPDATING attendees at this point.
2422 2422
 			$updated_fields = array(
2423 2423
 				'ATT_fname' => $this->_req_data['ATT_fname'],
2424 2424
 				'ATT_lname' => $this->_req_data['ATT_lname'],
2425
-				'ATT_full_name'=> $this->_req_data['ATT_fname'] . ' ' . $this->_req_data['ATT_lname'],
2425
+				'ATT_full_name'=> $this->_req_data['ATT_fname'].' '.$this->_req_data['ATT_lname'],
2426 2426
 				'ATT_address' => isset($this->_req_data['ATT_address']) ? $this->_req_data['ATT_address'] : '',
2427 2427
 				'ATT_address2' => isset($this->_req_data['ATT_address2']) ? $this->_req_data['ATT_address2'] : '',
2428
-				'ATT_city' => isset( $this->_req_data['ATT_city'] ) ? $this->_req_data['ATT_city'] : '',
2429
-				'STA_ID' => isset( $this->_req_data['STA_ID'] ) ? $this->_req_data['STA_ID'] : '',
2430
-				'CNT_ISO' => isset( $this->_req_data['CNT_ISO'] ) ? $this->_req_data['CNT_ISO'] : '',
2431
-				'ATT_zip' => isset( $this->_req_data['ATT_zip'] ) ? $this->_req_data['ATT_zip'] : '',
2432
-				'ATT_email' => isset( $this->_req_data['ATT_email'] ) ? $this->_req_data['ATT_email'] : '',
2433
-				'ATT_phone' => isset( $this->_req_data['ATT_phone'] ) ? $this->_req_data['ATT_phone'] : ''
2428
+				'ATT_city' => isset($this->_req_data['ATT_city']) ? $this->_req_data['ATT_city'] : '',
2429
+				'STA_ID' => isset($this->_req_data['STA_ID']) ? $this->_req_data['STA_ID'] : '',
2430
+				'CNT_ISO' => isset($this->_req_data['CNT_ISO']) ? $this->_req_data['CNT_ISO'] : '',
2431
+				'ATT_zip' => isset($this->_req_data['ATT_zip']) ? $this->_req_data['ATT_zip'] : '',
2432
+				'ATT_email' => isset($this->_req_data['ATT_email']) ? $this->_req_data['ATT_email'] : '',
2433
+				'ATT_phone' => isset($this->_req_data['ATT_phone']) ? $this->_req_data['ATT_phone'] : ''
2434 2434
 				);
2435
-			foreach ( $updated_fields as $field => $value ) {
2435
+			foreach ($updated_fields as $field => $value) {
2436 2436
 				$attendee->set($field, $value);
2437 2437
 			}
2438 2438
 
2439 2439
 			$success = $attendee->save();
2440 2440
 
2441
-			$attendee_update_callbacks = apply_filters( 'FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array() );
2442
-			foreach ( $attendee_update_callbacks as $a_callback ) {
2443
-				if ( FALSE === call_user_func_array( $a_callback, array($attendee, $this->_req_data ) ) ) {
2444
-					throw new EE_Error( sprintf( __('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback ) );
2441
+			$attendee_update_callbacks = apply_filters('FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update', array());
2442
+			foreach ($attendee_update_callbacks as $a_callback) {
2443
+				if (FALSE === call_user_func_array($a_callback, array($attendee, $this->_req_data))) {
2444
+					throw new EE_Error(sprintf(__('The %s callback given for the "FHEE__Registrations_Admin_Page__insert_update_cpt_item__attendee_update" filter is not a valid callback.  Please check the spelling.', 'event_espresso'), $a_callback));
2445 2445
 				}
2446 2446
 			}
2447 2447
 		}
2448 2448
 
2449
-		if ( $success === FALSE )
2450
-			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2449
+		if ($success === FALSE)
2450
+			EE_Error::add_error(__('Something went wrong with updating the meta table data for the registration.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2451 2451
 
2452 2452
 	}
2453 2453
 
@@ -2467,17 +2467,17 @@  discard block
 block discarded – undo
2467 2467
 		remove_meta_box('postexcerpt', __('Excerpt'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2468 2468
 		remove_meta_box('commentstatusdiv', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2469 2469
 
2470
-		if ( post_type_supports( 'espresso_attendees', 'excerpt') ) {
2471
-			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal' );
2470
+		if (post_type_supports('espresso_attendees', 'excerpt')) {
2471
+			add_meta_box('postexcerpt', __('Short Biography', 'event_espresso'), 'post_excerpt_meta_box', $this->_cpt_routes[$this->_req_action], 'normal');
2472 2472
 		}
2473 2473
 
2474
-		if ( post_type_supports( 'espresso_attendees', 'comments') ) {
2474
+		if (post_type_supports('espresso_attendees', 'comments')) {
2475 2475
 			add_meta_box('commentsdiv', __('Notes on the Contact', 'event_espresso'), 'post_comment_meta_box', $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2476 2476
 		}
2477 2477
 
2478
-		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array( $this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core' );
2479
-		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core' );
2480
-		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array( $this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2478
+		add_meta_box('attendee_contact_info', __('Contact Info', 'event_espresso'), array($this, 'attendee_contact_info'), $this->_cpt_routes[$this->_req_action], 'side', 'core');
2479
+		add_meta_box('attendee_details_address', __('Address Details', 'event_espresso'), array($this, 'attendee_address_details'), $this->_cpt_routes[$this->_req_action], 'normal', 'core');
2480
+		add_meta_box('attendee_registrations', __('Registrations for this Contact', 'event_espresso'), array($this, 'attendee_registrations_meta_box'), $this->_cpt_routes[$this->_req_action], 'normal', 'high');
2481 2481
 	}
2482 2482
 
2483 2483
 
@@ -2486,10 +2486,10 @@  discard block
 block discarded – undo
2486 2486
 	 * @param  WP_Post $post wp post object
2487 2487
 	 * @return string        attendee contact info ( and form )
2488 2488
 	 */
2489
-	public function attendee_contact_info( $post ) {
2489
+	public function attendee_contact_info($post) {
2490 2490
 		//get attendee object ( should already have it )
2491 2491
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2492
-		$template = REG_TEMPLATE_PATH . 'attendee_contact_info_metabox_content.template.php';
2492
+		$template = REG_TEMPLATE_PATH.'attendee_contact_info_metabox_content.template.php';
2493 2493
 		EEH_Template::display_template($template, $this->_template_args);
2494 2494
 	}
2495 2495
 
@@ -2505,12 +2505,12 @@  discard block
 block discarded – undo
2505 2505
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2506 2506
 		$this->_template_args['state_html'] = EEH_Form_Fields::generate_form_input(
2507 2507
 				new EE_Question_Form_Input(
2508
-				EE_Question::new_instance( array(
2508
+				EE_Question::new_instance(array(
2509 2509
 					'QST_ID' => 0,
2510 2510
 					'QST_display_text' => __('State/Province', 'event_espresso'),
2511 2511
 					'QST_system' => 'admin-state'
2512 2512
 					)),
2513
-				EE_Answer::new_instance( array(
2513
+				EE_Answer::new_instance(array(
2514 2514
 					'ANS_ID' => 0,
2515 2515
 					'ANS_value' => $this->_cpt_model_obj->state_ID()
2516 2516
 					)),
@@ -2523,12 +2523,12 @@  discard block
 block discarded – undo
2523 2523
 			));
2524 2524
 		$this->_template_args['country_html'] = EEH_Form_Fields::generate_form_input(
2525 2525
 				new EE_Question_Form_Input(
2526
-				EE_Question::new_instance( array(
2526
+				EE_Question::new_instance(array(
2527 2527
 					'QST_ID' => 0,
2528 2528
 					'QST_display_text' => __('Country', 'event_espresso'),
2529 2529
 					'QST_system' => 'admin-country'
2530 2530
 					)),
2531
-				EE_Answer::new_instance( array(
2531
+				EE_Answer::new_instance(array(
2532 2532
 					'ANS_ID' => 0,
2533 2533
 					'ANS_value' => $this->_cpt_model_obj->country_ID()
2534 2534
 					)),
@@ -2539,8 +2539,8 @@  discard block
 block discarded – undo
2539 2539
 					'append_qstn_id' => FALSE
2540 2540
 					)
2541 2541
 				));
2542
-		$template = REG_TEMPLATE_PATH . 'attendee_address_details_metabox_content.template.php';
2543
-		EEH_Template::display_template($template, $this->_template_args );
2542
+		$template = REG_TEMPLATE_PATH.'attendee_address_details_metabox_content.template.php';
2543
+		EEH_Template::display_template($template, $this->_template_args);
2544 2544
 
2545 2545
 	}
2546 2546
 
@@ -2550,11 +2550,11 @@  discard block
 block discarded – undo
2550 2550
 	*		@access protected
2551 2551
 	*		@return void
2552 2552
 	*/
2553
-	public function attendee_registrations_meta_box( $post ) {
2553
+	public function attendee_registrations_meta_box($post) {
2554 2554
 
2555 2555
 		$this->_template_args['attendee'] = $this->_cpt_model_obj;
2556 2556
 		$this->_template_args['registrations'] = $this->_cpt_model_obj->get_many_related('Registration');
2557
-		$template = REG_TEMPLATE_PATH . 'attendee_registrations_main_meta_box.template.php';
2557
+		$template = REG_TEMPLATE_PATH.'attendee_registrations_main_meta_box.template.php';
2558 2558
 		EEH_Template::display_template($template, $this->_template_args);
2559 2559
 
2560 2560
 	}
@@ -2568,8 +2568,8 @@  discard block
 block discarded – undo
2568 2568
 	 * @return string        html for new form.
2569 2569
 	 */
2570 2570
 	public function after_title_form_fields($post) {
2571
-		if ( $post->post_type == 'espresso_attendees' ) {
2572
-			$template = REG_TEMPLATE_PATH . 'attendee_details_after_title_form_fields.template.php';
2571
+		if ($post->post_type == 'espresso_attendees') {
2572
+			$template = REG_TEMPLATE_PATH.'attendee_details_after_title_form_fields.template.php';
2573 2573
 			$template_args['attendee'] = $this->_cpt_model_obj;
2574 2574
 			EEH_Template::display_template($template, $template_args);
2575 2575
 		}
@@ -2586,21 +2586,21 @@  discard block
 block discarded – undo
2586 2586
 	*		@access protected
2587 2587
 	*		@return void
2588 2588
 	*/
2589
-	protected function _trash_or_restore_attendees( $trash = TRUE ) {
2589
+	protected function _trash_or_restore_attendees($trash = TRUE) {
2590 2590
 
2591
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2591
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2592 2592
 
2593 2593
 		$ATT_MDL = EEM_Attendee::instance();
2594 2594
 
2595 2595
 		$success = 1;
2596 2596
 		//Checkboxes
2597
-		if (!empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2597
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2598 2598
 			// if array has more than one element than success message should be plural
2599
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2599
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2600 2600
 			// cycle thru checkboxes
2601
-			while (list( $ATT_ID, $value ) = each($this->_req_data['checkbox'])) {
2602
-				$updated = $trash ? $ATT_MDL->update_by_ID(array( 'status' => 'trash' ), $ATT_ID) : $ATT_MDL->update_by_ID( array('status' => 'publish' ), $ATT_ID);
2603
-				if ( !$updated ) {
2601
+			while (list($ATT_ID, $value) = each($this->_req_data['checkbox'])) {
2602
+				$updated = $trash ? $ATT_MDL->update_by_ID(array('status' => 'trash'), $ATT_ID) : $ATT_MDL->update_by_ID(array('status' => 'publish'), $ATT_ID);
2603
+				if ( ! $updated) {
2604 2604
 					$success = 0;
2605 2605
 				}
2606 2606
 			}
@@ -2609,18 +2609,18 @@  discard block
 block discarded – undo
2609 2609
 			// grab single id and delete
2610 2610
 			$ATT_ID = absint($this->_req_data['ATT_ID']);
2611 2611
 			//get attendee
2612
-			$att = $ATT_MDL->get_one_by_ID( $ATT_ID );
2612
+			$att = $ATT_MDL->get_one_by_ID($ATT_ID);
2613 2613
 			$updated = $trash ? $att->set_status('trash') : $att->set_status('publish');
2614 2614
 			$updated = $att->save();
2615
-			if ( ! $updated ) {
2615
+			if ( ! $updated) {
2616 2616
 				$success = 0;
2617 2617
 			}
2618 2618
 
2619 2619
 		}
2620 2620
 
2621
-		$what = $success > 1 ? __( 'Contacts', 'event_espresso' ) : __( 'Contact', 'event_espresso' );
2622
-		$action_desc = $trash ? __( 'moved to the trash', 'event_espresso' ) : __( 'restored', 'event_espresso' );
2623
-		$this->_redirect_after_action( $success, $what, $action_desc, array( 'action' => 'contact_list' ) );
2621
+		$what = $success > 1 ? __('Contacts', 'event_espresso') : __('Contact', 'event_espresso');
2622
+		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2623
+		$this->_redirect_after_action($success, $what, $action_desc, array('action' => 'contact_list'));
2624 2624
 
2625 2625
 	}
2626 2626
 
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page.core.php 1 patch
Spacing   +561 added lines, -561 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
  * Event Espresso
@@ -75,12 +75,12 @@  discard block
 block discarded – undo
75 75
 	/**
76 76
 	 * @param bool $routing
77 77
 	 */
78
-	public function __construct( $routing = true ) {
78
+	public function __construct($routing = true) {
79 79
 		//make sure MSG Template helper is loaded.
80
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
80
+		EE_Registry::instance()->load_helper('MSG_Template');
81 81
 		//make sure messages autoloader is running
82 82
 		EED_Messages::set_autoloaders();
83
-		parent::__construct( $routing );
83
+		parent::__construct($routing);
84 84
 	}
85 85
 
86 86
 
@@ -94,13 +94,13 @@  discard block
 block discarded – undo
94 94
 
95 95
 		$this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array();
96 96
 
97
-		$this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null;
97
+		$this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null;
98 98
 
99 99
 
100 100
 		//we're also going to set the active messengers and active message types in here.
101 101
 		$this->_active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
102
-		$this->_active_messengers = !empty($this->_active_messengers) ?  $this->_active_messengers : array();
103
-		$this->_active_message_types = !empty($this->_active_messenger) && !empty($this->_active_messengers[$this->_active_messenger]) && ! empty(  $this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger . '-message_types'] ) ? array_keys($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger . '-message_types']) : array();
102
+		$this->_active_messengers = ! empty($this->_active_messengers) ? $this->_active_messengers : array();
103
+		$this->_active_message_types = ! empty($this->_active_messenger) && ! empty($this->_active_messengers[$this->_active_messenger]) && ! empty($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger.'-message_types']) ? array_keys($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger.'-message_types']) : array();
104 104
 
105 105
 
106 106
 		//what about saving the objects in the active_messengers and active_message_types?
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
 	 * @throws EE_Error
119 119
 	*/
120 120
 	protected function _load_messages_controller() {
121
-		$this->_messages_controller = EE_Registry::instance()->load_lib( 'messages' );
121
+		$this->_messages_controller = EE_Registry::instance()->load_lib('messages');
122 122
 	}
123 123
 
124 124
 
@@ -131,14 +131,14 @@  discard block
 block discarded – undo
131 131
 	 * @throws EE_Error
132 132
 	*/
133 133
 	protected function _load_active_messenger_objects() {
134
-		foreach ( $this->_active_messengers as $messenger => $values ) {
135
-			$ref = ucwords( str_replace( '_' , ' ', $messenger) );
136
-			$ref = str_replace( ' ', '_', $ref );
137
-			$classname = 'EE_' . $ref . '_messenger';
138
-			require_once( EE_LIBRARIES . 'messages'. DS .'messenger' . DS . $classname . '.class.php' );
139
-			if ( ! class_exists( $classname ) ) {
134
+		foreach ($this->_active_messengers as $messenger => $values) {
135
+			$ref = ucwords(str_replace('_', ' ', $messenger));
136
+			$ref = str_replace(' ', '_', $ref);
137
+			$classname = 'EE_'.$ref.'_messenger';
138
+			require_once(EE_LIBRARIES.'messages'.DS.'messenger'.DS.$classname.'.class.php');
139
+			if ( ! class_exists($classname)) {
140 140
 				throw new EE_Error(
141
-					sprintf( __( 'There is no messenger for the given classname (%s)', 'event_espresso' ), $classname )
141
+					sprintf(__('There is no messenger for the given classname (%s)', 'event_espresso'), $classname)
142 142
 				);
143 143
 			}
144 144
 			$this->_active_messengers[$messenger]['obj'] = new $classname;
@@ -154,15 +154,15 @@  discard block
 block discarded – undo
154 154
 	 * @throws EE_Error
155 155
 	*/
156 156
 	protected function _load_active_message_type_objects() {
157
-		if ( empty($this->_active_message_types) ) {return;}
158
-		foreach ( $this->_active_message_types as $message_type ) {
159
-			$ref = ucwords( str_replace( '_' , ' ', $message_type) );
160
-			$ref = str_replace( ' ', '_', $ref );
161
-			$classname = 'EE_' . $ref . '_message_type';
162
-			if ( ! class_exists( $classname ) ) {
157
+		if (empty($this->_active_message_types)) {return; }
158
+		foreach ($this->_active_message_types as $message_type) {
159
+			$ref = ucwords(str_replace('_', ' ', $message_type));
160
+			$ref = str_replace(' ', '_', $ref);
161
+			$classname = 'EE_'.$ref.'_message_type';
162
+			if ( ! class_exists($classname)) {
163 163
 				throw new EE_Error(
164 164
 					sprintf(
165
-						__( 'There is no message type for the given classname (%s)', 'event_espresso' ),
165
+						__('There is no message type for the given classname (%s)', 'event_espresso'),
166 166
 						$classname
167 167
 					)
168 168
 				);
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
 	protected function _ajax_hooks() {
177
-		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) );
178
-		add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') );
179
-		add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') );
180
-		add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) );
181
-		add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) );
177
+		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle'));
178
+		add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle'));
179
+		add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings'));
180
+		add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form'));
181
+		add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack'));
182 182
 	}
183 183
 
184 184
 
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
 	*		@return void
211 211
 	*/
212 212
 	protected function _set_page_routes() {
213
-		$grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] )
213
+		$grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID'])
214 214
 			? $this->_req_data['GRP_ID']
215 215
 			: 0;
216
-		$grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] )
216
+		$grp_id = empty($grp_id) && ! empty($this->_req_data['id'])
217 217
 			? $this->_req_data['id']
218 218
 			: $grp_id;
219
-		$msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] )
219
+		$msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID'])
220 220
 			? $this->_req_data['MSG_ID']
221 221
 			: 0;
222 222
 
@@ -258,35 +258,35 @@  discard block
 block discarded – undo
258 258
 			'insert_message_template' => array(
259 259
 				'func' => '_insert_or_update_message_template',
260 260
 				'capability' => 'ee_edit_messages',
261
-				'args' => array( 'new_template' => true ),
261
+				'args' => array('new_template' => true),
262 262
 				'noheader' => true
263 263
 			 ),
264 264
 			'update_message_template' => array(
265 265
 				'func' => '_insert_or_update_message_template',
266 266
 				'capability' => 'ee_edit_message',
267 267
 				'obj_id' => $grp_id,
268
-				'args' => array( 'new_template' => false ),
268
+				'args' => array('new_template' => false),
269 269
 				'noheader' => true
270 270
 			),
271 271
 			'trash_message_template' => array(
272 272
 				'func' => '_trash_or_restore_message_template',
273 273
 				'capability' => 'ee_delete_message',
274 274
 				'obj_id' => $grp_id,
275
-				'args' => array( 'trash' => true, 'all' => true ),
275
+				'args' => array('trash' => true, 'all' => true),
276 276
 				'noheader' => true
277 277
 			),
278 278
 			'trash_message_template_context' => array(
279 279
 				'func' => '_trash_or_restore_message_template',
280 280
 				'capability' => 'ee_delete_message',
281 281
 				'obj_id' => $grp_id,
282
-				'args' => array( 'trash' => true ),
282
+				'args' => array('trash' => true),
283 283
 				'noheader' => true
284 284
 			),
285 285
 			'restore_message_template' => array(
286 286
 				'func' => '_trash_or_restore_message_template',
287 287
 				'capability' => 'ee_delete_message',
288 288
 				'obj_id' => $grp_id,
289
-				'args' => array( 'trash' => false, 'all' => true ),
289
+				'args' => array('trash' => false, 'all' => true),
290 290
 				'noheader' => true
291 291
 			),
292 292
 			'restore_message_template_context' => array(
@@ -361,7 +361,7 @@  discard block
 block discarded – undo
361 361
 					'order' => 10
362 362
 				),
363 363
 				'list_table' => 'EE_Message_List_Table',
364
-				'qtips' => array( 'EE_Message_List_Table_Tips' ),
364
+				'qtips' => array('EE_Message_List_Table_Tips'),
365 365
 				'require_nonce' => false
366 366
 			),
367 367
 			'global_mtps' => array(
@@ -400,7 +400,7 @@  discard block
 block discarded – undo
400 400
 						'filename' => 'messages_overview_other',
401 401
 					),
402 402
 				),
403
-				'help_tour' => array( 'Messages_Overview_Help_Tour' ),
403
+				'help_tour' => array('Messages_Overview_Help_Tour'),
404 404
 				'require_nonce' => false
405 405
 			),
406 406
 			'custom_mtps' => array(
@@ -435,7 +435,7 @@  discard block
 block discarded – undo
435 435
 				),
436 436
 				'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'),
437 437
 				'has_metaboxes' => true,
438
-				'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ),
438
+				'help_tour' => array('Message_Templates_Edit_Help_Tour'),
439 439
 				'help_tabs' => array(
440 440
 					'edit_message_template' => array(
441 441
 						'title' => __('Message Template Editor', 'event_espresso'),
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 						'filename' => 'messages_settings_messengers'
492 492
 					),
493 493
 				),
494
-				'help_tour' => array( 'Messages_Settings_Help_Tour' ),
494
+				'help_tour' => array('Messages_Settings_Help_Tour'),
495 495
 				'require_nonce' => false
496 496
 			)
497 497
 		);
@@ -524,7 +524,7 @@  discard block
 block discarded – undo
524 524
 
525 525
 
526 526
 	protected function _add_screen_options_default() {
527
-		$this->_admin_page_title = __( 'Message Activity', 'event_espresso' );
527
+		$this->_admin_page_title = __('Message Activity', 'event_espresso');
528 528
 		$this->_per_page_screen_option();
529 529
 	}
530 530
 
@@ -546,37 +546,37 @@  discard block
 block discarded – undo
546 546
 
547 547
 
548 548
 	public function messages_help_tab() {
549
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' );
549
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php');
550 550
 	}
551 551
 
552 552
 
553 553
 	public function messengers_help_tab() {
554
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' );
554
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php');
555 555
 	}
556 556
 
557 557
 
558 558
 	public function message_types_help_tab() {
559
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' );
559
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php');
560 560
 	}
561 561
 
562 562
 
563 563
 	public function messages_overview_help_tab() {
564
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' );
564
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php');
565 565
 	}
566 566
 
567 567
 
568 568
 	public function message_templates_help_tab() {
569
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' );
569
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php');
570 570
 	}
571 571
 
572 572
 
573 573
 	public function edit_message_template_help_tab() {
574
-		$args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />';
575
-		$args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />';
576
-		$args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />';
577
-		$args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />';
578
-		$args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />';
579
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args);
574
+		$args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />';
575
+		$args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />';
576
+		$args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />';
577
+		$args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />';
578
+		$args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />';
579
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args);
580 580
 	}
581 581
 
582 582
 
@@ -584,22 +584,22 @@  discard block
 block discarded – undo
584 584
 	public function message_template_shortcodes_help_tab() {
585 585
 		$this->_set_shortcodes();
586 586
 		$args['shortcodes'] = $this->_shortcodes;
587
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args );
587
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args);
588 588
 	}
589 589
 
590 590
 
591 591
 
592 592
 	public function preview_message_help_tab() {
593
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' );
593
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php');
594 594
 	}
595 595
 
596 596
 
597 597
 	public function settings_help_tab() {
598
-		$args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
599
-		$args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
598
+		$args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />';
599
+		$args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />';
600 600
 		$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>';
601 601
 		$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>';
602
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
602
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args);
603 603
 	}
604 604
 
605 605
 
@@ -607,31 +607,31 @@  discard block
 block discarded – undo
607 607
 
608 608
 
609 609
 	public function load_scripts_styles() {
610
-		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION );
610
+		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
611 611
 		wp_enqueue_style('espresso_ee_msg');
612 612
 
613
-		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 );
614
-		wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION );
613
+		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);
614
+		wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION);
615 615
 	}
616 616
 
617 617
 
618 618
 
619 619
 	public function load_scripts_styles_default() {
620
-		wp_enqueue_script( 'ee-msg-list-table-js' );
620
+		wp_enqueue_script('ee-msg-list-table-js');
621 621
 	}
622 622
 
623 623
 
624 624
 
625 625
 
626 626
 
627
-	public function wp_editor_css( $mce_css ) {
627
+	public function wp_editor_css($mce_css) {
628 628
 		//if we're on the edit_message_template route
629
-		if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_Messenger  ) {
629
+		if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_Messenger) {
630 630
 			$message_type_name = $this->_active_message_type_name;
631 631
 
632 632
 			//we're going to REPLACE the existing mce css
633 633
 			//we need to get the css file location from the active messenger
634
-			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation );
634
+			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation);
635 635
 		}
636 636
 
637 637
 		return $mce_css;
@@ -649,37 +649,37 @@  discard block
 block discarded – undo
649 649
 			$this->_message_template_group->messenger_obj()->label['singular'],
650 650
 			$this->_message_template_group->message_type_obj()->label['singular']
651 651
 		);
652
-		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' );
652
+		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');
653 653
 
654
-		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION );
654
+		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION);
655 655
 
656 656
 		wp_enqueue_script('ee_admin_js');
657 657
 		wp_enqueue_script('ee_msgs_edit_js');
658 658
 
659 659
 		//add in special css for tiny_mce
660
-		add_filter( 'mce_css', array( $this, 'wp_editor_css' ) );
660
+		add_filter('mce_css', array($this, 'wp_editor_css'));
661 661
 	}
662 662
 
663 663
 
664 664
 
665 665
 	public function load_scripts_styles_display_preview_message() {
666 666
 		$this->_set_message_template_group();
667
-		if ( isset( $this->_req_data['messenger'] ) ) {
667
+		if (isset($this->_req_data['messenger'])) {
668 668
 			$this->_active_messenger = $this->_active_messengers[$this->_req_data['messenger']]['obj'];
669 669
 		}
670 670
 
671
-		$message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : '';
671
+		$message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : '';
672 672
 
673 673
 
674
-		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) );
674
+		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation));
675 675
 	}
676 676
 
677 677
 
678 678
 
679 679
 	public function load_scripts_styles_settings() {
680
-		wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION );
681
-		wp_enqueue_style( 'ee-text-links' );
682
-		wp_enqueue_style( 'ee-message-settings' );
680
+		wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION);
681
+		wp_enqueue_style('ee-text-links');
682
+		wp_enqueue_style('ee-message-settings');
683 683
 
684 684
 		wp_enqueue_script('ee-messages-settings');
685 685
 	}
@@ -709,37 +709,37 @@  discard block
 block discarded – undo
709 709
 	 * set views array for message queue list table
710 710
 	 */
711 711
 	public function _set_list_table_views_default() {
712
-		EE_Registry::instance()->load_helper( 'Template' );
712
+		EE_Registry::instance()->load_helper('Template');
713 713
 
714
-		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' )
714
+		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions')
715 715
 			? array(
716
-				'generate_now' => __( 'Generate Now', 'event_espresso' ),
717
-		        'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ),
718
-		        'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ),
719
-		        'send_now' => __( 'Send Now', 'event_espresso' )
716
+				'generate_now' => __('Generate Now', 'event_espresso'),
717
+		        'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'),
718
+		        'queue_for_resending' => __('Queue for Resending', 'event_espresso'),
719
+		        'send_now' => __('Send Now', 'event_espresso')
720 720
 				)
721 721
 			: array();
722 722
 
723
-		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' )
724
-			? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) )
723
+		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions')
724
+			? array('delete_ee_messages' => __('Delete Messages', 'event_espresso'))
725 725
 			: array();
726 726
 
727 727
 
728 728
 		$this->_views = array(
729 729
 			 'all' => array(
730 730
 			    'slug' => 'all',
731
-			    'label' => __( 'All', 'event_espresso' ),
731
+			    'label' => __('All', 'event_espresso'),
732 732
 			    'count' => 0,
733
-			    'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action )
733
+			    'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action)
734 734
 			 )
735 735
 		);
736 736
 
737 737
 
738
-		foreach ( EEM_Message::instance()->all_statuses() as $status ) {
738
+		foreach (EEM_Message::instance()->all_statuses() as $status) {
739 739
 			$status_bulk_actions = $common_bulk_actions;
740 740
 			//unset bulk actions not applying to status
741
-			if ( ! empty( $status_bulk_actions ) ) {
742
-				switch ( $status ) {
741
+			if ( ! empty($status_bulk_actions)) {
742
+				switch ($status) {
743 743
 					case EEM_Message::status_idle :
744 744
 					case EEM_Message::status_resend :
745 745
 						$status_bulk_actions['send_now'] = $common_bulk_actions['send_now'];
@@ -750,20 +750,20 @@  discard block
 block discarded – undo
750 750
 						break;
751 751
 
752 752
 					case EEM_Message::status_incomplete :
753
-						unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] );
753
+						unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']);
754 754
 						break;
755 755
 
756 756
 					case EEM_Message::status_retry :
757 757
 					case EEM_Message::status_sent :
758
-						unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] );
758
+						unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']);
759 759
 						break;
760 760
 				}
761 761
 			}
762
-			$this->_views[ strtolower( $status ) ] = array(
763
-				'slug' => strtolower( $status ),
764
-				'label' => EEH_Template::pretty_status( $status, false, 'sentence' ),
762
+			$this->_views[strtolower($status)] = array(
763
+				'slug' => strtolower($status),
764
+				'label' => EEH_Template::pretty_status($status, false, 'sentence'),
765 765
 				'count' => 0,
766
-				'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action )
766
+				'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action)
767 767
 			);
768 768
 		}
769 769
 	}
@@ -782,7 +782,7 @@  discard block
 block discarded – undo
782 782
 	protected function _message_queue_list_table() {
783 783
 		$this->_search_btn_label = __('Message Activity', 'event_espresso');
784 784
 		$this->_template_args['per_column'] = 6;
785
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() );
785
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items());
786 786
 		$this->display_admin_list_table_page_with_no_sidebar();
787 787
 	}
788 788
 
@@ -790,12 +790,12 @@  discard block
 block discarded – undo
790 790
 
791 791
 
792 792
 	protected function _message_legend_items() {
793
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
793
+		EE_Registry::instance()->load_helper('MSG_Template');
794 794
 		$action_css_classes = EEH_MSG_Template::get_message_action_icons();
795 795
 		$action_items = array();
796 796
 
797
-		foreach( $action_css_classes as $action_item => $action_details ) {
798
-			if ( $action_item === 'see_notifications_for' ) {
797
+		foreach ($action_css_classes as $action_item => $action_details) {
798
+			if ($action_item === 'see_notifications_for') {
799 799
 				continue;
800 800
 			}
801 801
 			$action_items[$action_item] = array(
@@ -807,31 +807,31 @@  discard block
 block discarded – undo
807 807
 		/** @type array $status_items status legend setup*/
808 808
 		$status_items = array(
809 809
 			'sent_status' => array(
810
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent,
811
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, FALSE, 'sentence' )
810
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent,
811
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, FALSE, 'sentence')
812 812
 				),
813 813
 			'idle_status' => array(
814
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle,
815
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, FALSE, 'sentence' )
814
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle,
815
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, FALSE, 'sentence')
816 816
 				),
817 817
 			'failed_status' => array(
818
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed,
819
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, FALSE, 'sentence' )
818
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed,
819
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, FALSE, 'sentence')
820 820
 			),
821 821
 			'resend_status' => array(
822
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend,
823
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, FALSE, 'sentence' )
822
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend,
823
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, FALSE, 'sentence')
824 824
 				),
825 825
 			'incomplete_status' => array(
826
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete,
827
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, FALSE, 'sentence' )
826
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete,
827
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, FALSE, 'sentence')
828 828
 				),
829 829
 			'retry_status' => array(
830
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry,
831
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, FALSE, 'sentence' )
830
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry,
831
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, FALSE, 'sentence')
832 832
 				)
833 833
 		);
834
-		return array_merge( $action_items, $status_items );
834
+		return array_merge($action_items, $status_items);
835 835
 	}
836 836
 
837 837
 
@@ -841,9 +841,9 @@  discard block
 block discarded – undo
841 841
 
842 842
 	protected function _custom_mtps_preview() {
843 843
 		$this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso');
844
-		$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' ) . '" />';
844
+		$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').'" />';
845 845
 		$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>';
846
-		$this->display_admin_caf_preview_page( 'custom_message_types', false );
846
+		$this->display_admin_caf_preview_page('custom_message_types', false);
847 847
 	}
848 848
 
849 849
 
@@ -867,31 +867,31 @@  discard block
 block discarded – undo
867 867
 	 *
868 868
 	 * @return array
869 869
 	 */
870
-	public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) {
870
+	public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) {
871 871
 
872 872
 		$MTP = EEM_Message_Template_Group::instance();
873 873
 
874 874
 		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby'];
875 875
 		$orderby = $this->_req_data['orderby'];
876 876
 
877
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC';
877
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
878 878
 
879
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
880
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage;
879
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
880
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage;
881 881
 
882
-		$offset = ($current_page-1)*$per_page;
883
-		$limit = $all ? null : array( $offset, $per_page );
882
+		$offset = ($current_page - 1) * $per_page;
883
+		$limit = $all ? null : array($offset, $per_page);
884 884
 
885 885
 
886 886
 		//options will match what is in the _views array property
887
-		switch( $type ) {
887
+		switch ($type) {
888 888
 
889 889
 			case 'in_use':
890
-				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true );
890
+				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true);
891 891
 				break;
892 892
 
893 893
 			default:
894
-				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global );
894
+				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global);
895 895
 
896 896
 		}
897 897
 
@@ -927,7 +927,7 @@  discard block
 block discarded – undo
927 927
 		$imts = $installed_objects['message_types'];
928 928
 		$installed = array();
929 929
 
930
-		foreach ( $imts as $message_type ) {
930
+		foreach ($imts as $message_type) {
931 931
 			$installed[$message_type->name]['obj'] = $message_type;
932 932
 		}
933 933
 
@@ -963,24 +963,24 @@  discard block
 block discarded – undo
963 963
 	 *
964 964
 	 * @throws EE_error
965 965
 	 */
966
-	protected function _add_message_template(  $message_type = '', $messenger='', $GRP_ID = '' ) {
966
+	protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') {
967 967
 		//set values override any request data
968
-		$message_type = !empty( $message_type ) ? $message_type : '';
969
-		$message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type;
968
+		$message_type = ! empty($message_type) ? $message_type : '';
969
+		$message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type;
970 970
 
971
-		$messenger = !empty( $messenger ) ? $messenger : '';
972
-		$messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger;
971
+		$messenger = ! empty($messenger) ? $messenger : '';
972
+		$messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger;
973 973
 
974
-		$GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : '';
975
-		$GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID;
974
+		$GRP_ID = ! empty($GRP_ID) ? $GRP_ID : '';
975
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID;
976 976
 
977 977
 		//we need messenger and message type.  They should be coming from the event editor. If not here then return error
978
-		if ( empty( $message_type ) || empty( $messenger )  )
979
-			{throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));}
978
+		if (empty($message_type) || empty($messenger))
979
+			{throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); }
980 980
 
981 981
 		//we need the GRP_ID for the template being used as the base for the new template
982
-		if ( empty( $GRP_ID ) )
983
-			{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' ) );}
982
+		if (empty($GRP_ID))
983
+			{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')); }
984 984
 
985 985
 		//let's just make sure the template gets generated!
986 986
 
@@ -1001,8 +1001,8 @@  discard block
 block discarded – undo
1001 1001
 	 * @param int      $GRP_ID         GRP_ID for the related message template group this new template will be based
1002 1002
 	 *                                 off of.
1003 1003
 	 */
1004
-	public function add_message_template( $message_type, $messenger, $GRP_ID ) {
1005
-		$this->_add_message_template( $message_type, $messenger, $GRP_ID );
1004
+	public function add_message_template($message_type, $messenger, $GRP_ID) {
1005
+		$this->_add_message_template($message_type, $messenger, $GRP_ID);
1006 1006
 	}
1007 1007
 
1008 1008
 
@@ -1013,36 +1013,36 @@  discard block
 block discarded – undo
1013 1013
 	 * @return void
1014 1014
 	 */
1015 1015
 	protected function _edit_message_template() {
1016
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '');
1016
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1017 1017
 
1018 1018
 		//we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates.
1019
-		add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 );
1019
+		add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2);
1020 1020
 
1021
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false;
1021
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false;
1022 1022
 
1023 1023
 		$this->_set_shortcodes(); //this also sets the _message_template property.
1024 1024
 		$message_template_group = $this->_message_template_group;
1025 1025
 		$c_label = $message_template_group->context_label();
1026 1026
 		$c_config = $message_template_group->contexts_config();
1027 1027
 
1028
-		reset( $c_config );
1029
-		$context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) ? strtolower($this->_req_data['context']) : key($c_config);
1028
+		reset($c_config);
1029
+		$context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) ? strtolower($this->_req_data['context']) : key($c_config);
1030 1030
 
1031 1031
 
1032
-		if ( empty($GRP_ID) ) {
1032
+		if (empty($GRP_ID)) {
1033 1033
 			$action = 'insert_message_template';
1034 1034
 			$button_both = false;
1035
-			$button_text = array( __( 'Save','event_espresso') );
1035
+			$button_text = array(__('Save', 'event_espresso'));
1036 1036
 			$button_actions = array('something_different');
1037 1037
 			$referrer = false;
1038
-			$edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => true ), EE_MSG_ADMIN_URL );
1038
+			$edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => true), EE_MSG_ADMIN_URL);
1039 1039
 		} else {
1040 1040
 			$action = 'update_message_template';
1041 1041
 			$button_both = true;
1042 1042
 			$button_text = array();
1043 1043
 			$button_actions = array();
1044 1044
 			$referrer = $this->_admin_base_url;
1045
-			$edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => true ), EE_MSG_ADMIN_URL );
1045
+			$edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => true), EE_MSG_ADMIN_URL);
1046 1046
 		}
1047 1047
 
1048 1048
 		//set active messenger for this view
@@ -1052,13 +1052,13 @@  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
-		$context_label = sprintf( __('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'] ));
1059
+		$context_label = sprintf(__('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label']));
1060 1060
 
1061
-		$title = sprintf( __(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label );
1061
+		$title = sprintf(__(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label);
1062 1062
 
1063 1063
 		$this->_template_args['GRP_ID'] = $GRP_ID;
1064 1064
 		$this->_template_args['message_template'] = $message_template_group;
@@ -1071,7 +1071,7 @@  discard block
 block discarded – undo
1071 1071
 
1072 1072
 		$template_field_structure = $this->_messages_controller->get_fields($message_template_group->messenger(), $message_template_group->message_type());
1073 1073
 
1074
-		if ( !$template_field_structure ) {
1074
+		if ( ! $template_field_structure) {
1075 1075
 			$template_field_structure = false;
1076 1076
 			$template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso');
1077 1077
 		}
@@ -1081,38 +1081,38 @@  discard block
 block discarded – undo
1081 1081
 
1082 1082
 
1083 1083
 		//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.
1084
-		if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) {
1085
-			foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) {
1086
-				unset( $template_field_structure[$context][$reference_field] );
1084
+		if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) {
1085
+			foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) {
1086
+				unset($template_field_structure[$context][$reference_field]);
1087 1087
 			}
1088 1088
 		}
1089 1089
 
1090 1090
 		//let's loop through the template_field_structure and actually assemble the input fields!
1091
-		if ( !empty($template_field_structure) ) {
1092
-			$id_prefix= 'ee-msg-edit-template-fields-';
1093
-			foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) {
1091
+		if ( ! empty($template_field_structure)) {
1092
+			$id_prefix = 'ee-msg-edit-template-fields-';
1093
+			foreach ($template_field_structure[$context] as $template_field => $field_setup_array) {
1094 1094
 				//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.
1095
-				if ( $template_field == 'extra' ) {
1095
+				if ($template_field == 'extra') {
1096 1096
 					$this->_template_args['is_extra_fields'] = true;
1097
-					foreach ( $field_setup_array as $reference_field => $new_fields_array ) {
1098
-						foreach ( $new_fields_array as $extra_field =>  $extra_array ) {
1097
+					foreach ($field_setup_array as $reference_field => $new_fields_array) {
1098
+						foreach ($new_fields_array as $extra_field =>  $extra_array) {
1099 1099
 							//let's verify if we need this extra field via the shortcodes parameter.
1100 1100
 							$continue = false;
1101
-							if ( isset( $extra_array['shortcodes_required'] ) ) {
1102
-								foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) {
1103
-									if ( !array_key_exists( $shortcode, $this->_shortcodes ) )
1104
-										{$continue = true;}
1101
+							if (isset($extra_array['shortcodes_required'])) {
1102
+								foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
1103
+									if ( ! array_key_exists($shortcode, $this->_shortcodes))
1104
+										{$continue = true; }
1105 1105
 								}
1106
-								if ( $continue ) {continue;}
1106
+								if ($continue) {continue; }
1107 1107
 							}
1108 1108
 
1109
-							$field_id = $reference_field . '-' . $extra_field . '-content';
1109
+							$field_id = $reference_field.'-'.$extra_field.'-content';
1110 1110
 							$template_form_fields[$field_id] = $extra_array;
1111
-							$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']';
1112
-							$css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : '';
1113
-							$template_form_fields[$field_id]['css_class'] = !empty( $v_fields ) && in_array($extra_field, $v_fields) && ( is_array($validators[$extra_field] ) && isset( $validators[$extra_field]['msg'] ) ) ? 'validate-error ' . $css_class : $css_class;
1111
+							$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']';
1112
+							$css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : '';
1113
+							$template_form_fields[$field_id]['css_class'] = ! empty($v_fields) && in_array($extra_field, $v_fields) && (is_array($validators[$extra_field]) && isset($validators[$extra_field]['msg'])) ? 'validate-error '.$css_class : $css_class;
1114 1114
 							$content = $message_templates[$context][$reference_field]->get('MTP_content');
1115
-							$template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) : '';
1115
+							$template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) : '';
1116 1116
 
1117 1117
 							//do we have a validation error?  if we do then let's use that value instead
1118 1118
 							$template_form_fields[$field_id]['value'] = isset($validators[$extra_field]) ? $validators[$extra_field]['value'] : $template_form_fields[$field_id]['value'];
@@ -1122,32 +1122,32 @@  discard block
 block discarded – undo
1122 1122
 
1123 1123
 							//shortcode selector
1124 1124
 							$field_name_to_use = $extra_field == 'main' ? 'content' : $extra_field;
1125
-							$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $field_name_to_use, $field_id );
1125
+							$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($field_name_to_use, $field_id);
1126 1126
 
1127
-							if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) {
1127
+							if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') {
1128 1128
 								//we want to decode the entities
1129
-								$template_form_fields[$field_id]['value'] = stripslashes( html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") );
1129
+								$template_form_fields[$field_id]['value'] = stripslashes(html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8"));
1130 1130
 
1131 1131
 							}/**/
1132 1132
 						}
1133
-						$templatefield_MTP_id = $reference_field . '-MTP_ID';
1134
-						$templatefield_templatename_id = $reference_field . '-name';
1133
+						$templatefield_MTP_id = $reference_field.'-MTP_ID';
1134
+						$templatefield_templatename_id = $reference_field.'-name';
1135 1135
 
1136 1136
 						$template_form_fields[$templatefield_MTP_id] = array(
1137
-							'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1137
+							'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]',
1138 1138
 							'label' => null,
1139 1139
 							'input' => 'hidden',
1140 1140
 							'type' => 'int',
1141 1141
 							'required' => false,
1142 1142
 							'validation' => false,
1143
-							'value' => !empty($message_templates) ? $message_templates[$context][$reference_field]->ID() : '',
1143
+							'value' => ! empty($message_templates) ? $message_templates[$context][$reference_field]->ID() : '',
1144 1144
 							'css_class' => '',
1145 1145
 							'format' => '%d',
1146 1146
 							'db-col' => 'MTP_ID'
1147 1147
 						);
1148 1148
 
1149 1149
 						$template_form_fields[$templatefield_templatename_id] = array(
1150
-							'name' => 'MTP_template_fields[' . $reference_field . '][name]',
1150
+							'name' => 'MTP_template_fields['.$reference_field.'][name]',
1151 1151
 							'label' => null,
1152 1152
 							'input' => 'hidden',
1153 1153
 							'type' => 'string',
@@ -1161,10 +1161,10 @@  discard block
 block discarded – undo
1161 1161
 					}
1162 1162
 					continue; //skip the next stuff, we got the necessary fields here for this dataset.
1163 1163
 				} else {
1164
-					$field_id = $template_field . '-content';
1164
+					$field_id = $template_field.'-content';
1165 1165
 					$template_form_fields[$field_id] = $field_setup_array;
1166
-					$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]';
1167
-					$template_form_fields[$field_id]['value'] = !empty($message_templates) && is_array($message_templates[$context]) && isset($message_templates[$context][$template_field]) ?$message_templates[$context][$template_field]->get('MTP_content') : '';
1166
+					$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]';
1167
+					$template_form_fields[$field_id]['value'] = ! empty($message_templates) && is_array($message_templates[$context]) && isset($message_templates[$context][$template_field]) ? $message_templates[$context][$template_field]->get('MTP_content') : '';
1168 1168
 
1169 1169
 					//do we have a validator error for this field?  if we do then we'll use that value instead
1170 1170
 					$template_form_fields[$field_id]['value'] = isset($validators[$template_field]) ? $validators[$template_field]['value'] : $template_form_fields[$field_id]['value'];
@@ -1172,12 +1172,12 @@  discard block
 block discarded – undo
1172 1172
 
1173 1173
 					$template_form_fields[$field_id]['db-col'] = 'MTP_content';
1174 1174
 					$css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : '';
1175
-					$template_form_fields[$field_id]['css_class'] = !empty( $v_fields ) && in_array( $template_field, $v_fields ) && isset( $validators[$template_field]['msg'] ) ? 'validate-error ' . $css_class : $css_class;
1175
+					$template_form_fields[$field_id]['css_class'] = ! empty($v_fields) && in_array($template_field, $v_fields) && isset($validators[$template_field]['msg']) ? 'validate-error '.$css_class : $css_class;
1176 1176
 
1177 1177
 					//shortcode selector
1178
-					$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $template_field, $field_id );
1178
+					$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($template_field, $field_id);
1179 1179
 
1180
-					if ( isset( $field_setup_array['input'] ) && $field_setup_array['input'] == 'wp_editor' ) {
1180
+					if (isset($field_setup_array['input']) && $field_setup_array['input'] == 'wp_editor') {
1181 1181
 						//we want to decode the entities
1182 1182
 						$template_form_fields[$field_id]['value'] = $template_form_fields[$field_id]['value'];
1183 1183
 					}/**/
@@ -1185,25 +1185,25 @@  discard block
 block discarded – undo
1185 1185
 
1186 1186
 				//k took care of content field(s) now let's take care of others.
1187 1187
 
1188
-				$templatefield_MTP_id = $template_field . '-MTP_ID';
1189
-				$templatefield_field_templatename_id = $template_field . '-name';
1188
+				$templatefield_MTP_id = $template_field.'-MTP_ID';
1189
+				$templatefield_field_templatename_id = $template_field.'-name';
1190 1190
 
1191 1191
 				//foreach template field there are actually two form fields created
1192 1192
 				$template_form_fields[$templatefield_MTP_id] = array(
1193
-					'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1193
+					'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]',
1194 1194
 					'label' => null,
1195 1195
 					'input' => 'hidden',
1196 1196
 					'type' => 'int',
1197 1197
 					'required' => false,
1198 1198
 					'validation' => true,
1199
-					'value' => !empty($message_templates) ? $message_templates[$context][$template_field]->ID() : '',
1199
+					'value' => ! empty($message_templates) ? $message_templates[$context][$template_field]->ID() : '',
1200 1200
 					'css_class' => '',
1201 1201
 					'format' => '%d',
1202 1202
 					'db-col' => 'MTP_ID'
1203 1203
 				);
1204 1204
 
1205 1205
 				$template_form_fields[$templatefield_field_templatename_id] = array(
1206
-					'name' => 'MTP_template_fields[' . $template_field . '][name]',
1206
+					'name' => 'MTP_template_fields['.$template_field.'][name]',
1207 1207
 					'label' => null,
1208 1208
 					'input' => 'hidden',
1209 1209
 					'type' => 'string',
@@ -1347,15 +1347,15 @@  discard block
 block discarded – undo
1347 1347
 				'value' => $GRP_ID
1348 1348
 				);
1349 1349
 			$sidebar_form_fields['ee-msg-evt-nonce'] = array(
1350
-				'name' => $action . '_nonce',
1350
+				'name' => $action.'_nonce',
1351 1351
 				'input' => 'hidden',
1352 1352
 				'type' => 'string',
1353
-				'value' => wp_create_nonce( $action . '_nonce')
1353
+				'value' => wp_create_nonce($action.'_nonce')
1354 1354
 				);
1355 1355
 
1356 1356
 			$sidebar_array = array('ee-msg-is-global', 'ee-msg-is-override', 'ee-msg-deleted', 'ee-msg-is-active');
1357 1357
 
1358
-			if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) {
1358
+			if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
1359 1359
 				$sidebar_form_fields['ee-msg-template-switch'] = array(
1360 1360
 					'name' => 'template_switch',
1361 1361
 					'input' => 'hidden',
@@ -1365,8 +1365,8 @@  discard block
 block discarded – undo
1365 1365
 			}
1366 1366
 
1367 1367
 
1368
-			$template_fields = $this->_generate_admin_form_fields( $template_form_fields );
1369
-			$sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields );
1368
+			$template_fields = $this->_generate_admin_form_fields($template_form_fields);
1369
+			$sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields);
1370 1370
 
1371 1371
 
1372 1372
 		} //end if ( !empty($template_field_structure) )
@@ -1378,14 +1378,14 @@  discard block
 block discarded – undo
1378 1378
 			 $GRP_ID,
1379 1379
 			 false,
1380 1380
 			 add_query_arg(
1381
-			    array( 'action' => 'global_mtps' ),
1381
+			    array('action' => 'global_mtps'),
1382 1382
 			    $this->_admin_base_url
1383 1383
 			 )
1384 1384
 		);
1385 1385
 
1386 1386
 		//add preview button
1387
-		$preview_url = parent::add_query_args_and_nonce( array( 'message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context,'GRP_ID' => $GRP_ID, 'action' => 'preview_message' ), $this->_admin_base_url );
1388
-		$preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>';
1387
+		$preview_url = parent::add_query_args_and_nonce(array('message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context, 'GRP_ID' => $GRP_ID, 'action' => 'preview_message'), $this->_admin_base_url);
1388
+		$preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>';
1389 1389
 
1390 1390
 
1391 1391
 		//setup context switcher
@@ -1413,17 +1413,17 @@  discard block
 block discarded – undo
1413 1413
 		$this->_template_args['after_admin_page_content'] = $this->_add_form_element_after();
1414 1414
 
1415 1415
 		$this->_template_path = $this->_template_args['GRP_ID']
1416
-			? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1417
-			: EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1416
+			? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php'
1417
+			: EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php';
1418 1418
 
1419 1419
 		//send along EE_Message_Template_Group object for further template use.
1420 1420
 		$this->_template_args['MTP'] = $message_template_group;
1421 1421
 
1422
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true );
1422
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true);
1423 1423
 
1424 1424
 
1425 1425
 		//finally, let's set the admin_page title
1426
-		$this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title );
1426
+		$this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title);
1427 1427
 
1428 1428
 
1429 1429
 		//we need to take care of setting the shortcodes property for use elsewhere.
@@ -1436,7 +1436,7 @@  discard block
 block discarded – undo
1436 1436
 	}
1437 1437
 
1438 1438
 
1439
-	public function filter_tinymce_init( $mceInit, $editor_id ) {
1439
+	public function filter_tinymce_init($mceInit, $editor_id) {
1440 1440
 		return $mceInit;
1441 1441
 	}
1442 1442
 
@@ -1447,7 +1447,7 @@  discard block
 block discarded – undo
1447 1447
 	}
1448 1448
 
1449 1449
 	public function _add_form_element_before() {
1450
-		return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">';
1450
+		return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">';
1451 1451
 	}
1452 1452
 
1453 1453
 	public function _add_form_element_after() {
@@ -1465,32 +1465,32 @@  discard block
 block discarded – undo
1465 1465
 	 * @return string json object
1466 1466
 	 */
1467 1467
 	public function switch_template_pack() {
1468
-		$GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1469
-		$template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : '';
1468
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1469
+		$template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : '';
1470 1470
 
1471 1471
 		//verify we have needed values.
1472
-		if ( empty( $GRP_ID ) || empty( $template_pack ) ) {
1472
+		if (empty($GRP_ID) || empty($template_pack)) {
1473 1473
 			$this->_template_args['error'] = true;
1474
-			EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__  );
1474
+			EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1475 1475
 		} else {
1476 1476
 			//get template, set the new template_pack and then reset to default
1477
-			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1477
+			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1478 1478
 
1479
-			$mtpg->set_template_pack_name( $template_pack );
1479
+			$mtpg->set_template_pack_name($template_pack);
1480 1480
 			$this->_req_data['msgr'] = $mtpg->messenger();
1481 1481
 			$this->_req_data['mt'] = $mtpg->message_type();
1482 1482
 
1483 1483
 			$query_args = $this->_reset_to_default_template();
1484 1484
 
1485
-			if ( empty( $query_args['id'] ) ) {
1486
-				EE_Error::add_error( __('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1485
+			if (empty($query_args['id'])) {
1486
+				EE_Error::add_error(__('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1487 1487
 				$this->_template_args['error'] = true;
1488 1488
 			} else {
1489
-				$template_label =$mtpg->get_template_pack()->label;
1489
+				$template_label = $mtpg->get_template_pack()->label;
1490 1490
 				$template_pack_labels = $mtpg->messenger_obj()->get_supports_labels();
1491
-				EE_Error::add_success( sprintf( __('This message template has been successfully switched to use the %s %s.  Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack ) );
1491
+				EE_Error::add_success(sprintf(__('This message template has been successfully switched to use the %s %s.  Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack));
1492 1492
 				//generate the redirect url for js.
1493
-				$url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1493
+				$url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1494 1494
 				$this->_template_args['data']['redirect_url'] = $url;
1495 1495
 				$this->_template_args['success'] = true;
1496 1496
 			}
@@ -1512,56 +1512,56 @@  discard block
 block discarded – undo
1512 1512
 	protected function _reset_to_default_template() {
1513 1513
 		$success = true;
1514 1514
 		$templates = array();
1515
-		$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1515
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1516 1516
 		//we need to make sure we've got the info we need.
1517
-		if ( !isset( $this->_req_data['msgr'] ) && !isset( $this->_req_data['mt'] ) && !isset( $this->_req_data['GRP_ID'] ) ) {
1518
-			EE_Error::add_error( __('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.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1517
+		if ( ! isset($this->_req_data['msgr']) && ! isset($this->_req_data['mt']) && ! isset($this->_req_data['GRP_ID'])) {
1518
+			EE_Error::add_error(__('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.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1519 1519
 			$success = false;
1520 1520
 		}
1521 1521
 
1522 1522
 		//all templates will be reset to whatever the defaults are for the global template matching the messenger and message type.
1523
-		$success = !empty( $GRP_ID ) ? true : false;
1523
+		$success = ! empty($GRP_ID) ? true : false;
1524 1524
 
1525
-		if ( $success ) {
1525
+		if ($success) {
1526 1526
 
1527 1527
 			//let's first determine if the incoming template is a global template, if it isn't then we need to get the global template matching messenger and message type.
1528
-			$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1528
+			$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1529 1529
 
1530 1530
 
1531 1531
 			//note this is ONLY deleting the template fields (Message Template rows) NOT the message template group.
1532
-			$success = $this->_delete_mtp_permanently( $GRP_ID, false );
1532
+			$success = $this->_delete_mtp_permanently($GRP_ID, false);
1533 1533
 
1534
-			if ( $success ) {
1534
+			if ($success) {
1535 1535
 				//if successfully deleted, lets generate the new ones.  Note. We set GLOBAL to true, because resets on ANY template will use the related global template defaults for regeneration.  This means that if a custom template is reset it resets to whatever the related global template is.  HOWEVER, we DO keep the template pack and template variation set for the current custom template when resetting.
1536
-				$templates = $this->_generate_new_templates( $this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, true );
1536
+				$templates = $this->_generate_new_templates($this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, true);
1537 1537
 			}
1538 1538
 
1539 1539
 		}
1540 1540
 
1541 1541
 		//any error messages?
1542
-		if ( !$success ) {
1543
-			EE_Error::add_error( __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1542
+		if ( ! $success) {
1543
+			EE_Error::add_error(__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1544 1544
 		}
1545 1545
 
1546 1546
 		//all good, let's add a success message!
1547
-		if ( $success && ! empty( $templates ) ) {
1547
+		if ($success && ! empty($templates)) {
1548 1548
 			$templates = $templates[0]; //the info for the template we generated is the first element in the returned array.
1549 1549
 			EE_Error::overwrite_success();
1550
-			EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') );
1550
+			EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso'));
1551 1551
 		}
1552 1552
 
1553 1553
 
1554 1554
 		$query_args = array(
1555
-			'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null,
1556
-			'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null,
1557
-			'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps'
1555
+			'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null,
1556
+			'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null,
1557
+			'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps'
1558 1558
 			);
1559 1559
 
1560 1560
 		//if called via ajax then we return query args otherwise redirect
1561
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
1561
+		if (defined('DOING_AJAX') && DOING_AJAX) {
1562 1562
 			return $query_args;
1563 1563
 		} else {
1564
-			$this->_redirect_after_action( false, '', '', $query_args, true );
1564
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1565 1565
 		}
1566 1566
 
1567 1567
 	}
@@ -1574,19 +1574,19 @@  discard block
 block discarded – undo
1574 1574
 	 * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
1575 1575
 	 * @return string
1576 1576
 	 */
1577
-	public function _preview_message( $send = false ) {
1577
+	public function _preview_message($send = false) {
1578 1578
 		//first make sure we've got the necessary parameters
1579
-		if ( !isset( $this->_req_data['message_type'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['GRP_ID'] ) ) {
1580
-			EE_Error::add_error( __('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1579
+		if ( ! isset($this->_req_data['message_type']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['GRP_ID'])) {
1580
+			EE_Error::add_error(__('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1581 1581
 		}
1582 1582
 
1583
-		EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] );
1583
+		EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']);
1584 1584
 
1585 1585
 
1586 1586
 		//get the preview!
1587
-		$preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send );
1587
+		$preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send);
1588 1588
 
1589
-		if ( $send ) {
1589
+		if ($send) {
1590 1590
 			return $preview;
1591 1591
 		}
1592 1592
 
@@ -1596,16 +1596,16 @@  discard block
 block discarded – undo
1596 1596
 			'context' => $this->_req_data['context'],
1597 1597
 			'action' => 'edit_message_template'
1598 1598
 			);
1599
-		$go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1600
-		$preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>';
1599
+		$go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1600
+		$preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>';
1601 1601
 
1602 1602
 		//let's provide a helpful title for context
1603
-		$preview_title = sprintf( __('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular']) );
1603
+		$preview_title = sprintf(__('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular']));
1604 1604
 
1605 1605
 
1606 1606
 		//setup display of preview.
1607 1607
 		$this->_admin_page_title = $preview_title;
1608
-		$this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview);
1608
+		$this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview);
1609 1609
 		$this->_template_args['data']['force_json'] = true;
1610 1610
 	}
1611 1611
 
@@ -1634,9 +1634,9 @@  discard block
 block discarded – undo
1634 1634
 	 * @return void
1635 1635
 	 */
1636 1636
 	protected function _register_edit_meta_boxes() {
1637
-		add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' );
1638
-		add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1639
-		add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1637
+		add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default');
1638
+		add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high');
1639
+		add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high');
1640 1640
 	}
1641 1641
 
1642 1642
 
@@ -1655,10 +1655,10 @@  discard block
 block discarded – undo
1655 1655
 
1656 1656
 		$tp_select_values = array();
1657 1657
 
1658
-		foreach ( $tp_collection as $tp ) {
1658
+		foreach ($tp_collection as $tp) {
1659 1659
 			//only include template packs that support this messenger and message type!
1660 1660
 			$supports = $tp->get_supports();
1661
-			if ( ! isset( $supports[$this->_message_template_group->messenger()] ) || ! in_array( $this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()] ) ) {
1661
+			if ( ! isset($supports[$this->_message_template_group->messenger()]) || ! in_array($this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()])) {
1662 1662
 				//not supported
1663 1663
 				continue;
1664 1664
 			}
@@ -1670,7 +1670,7 @@  discard block
 block discarded – undo
1670 1670
 		}
1671 1671
 
1672 1672
 		//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.
1673
-		if ( empty( $tp_select_values ) ) {
1673
+		if (empty($tp_select_values)) {
1674 1674
 			$tp_select_values[] = array(
1675 1675
 				'text' => __('Default', 'event_espresso'),
1676 1676
 				'id' => 'default'
@@ -1678,27 +1678,27 @@  discard block
 block discarded – undo
1678 1678
 		}
1679 1679
 
1680 1680
 		//setup variation select values for the currently selected template.
1681
-		$variations = $this->_message_template_group->get_template_pack()->get_variations( $this->_message_template_group->messenger(), $this->_message_template_group->message_type() );
1681
+		$variations = $this->_message_template_group->get_template_pack()->get_variations($this->_message_template_group->messenger(), $this->_message_template_group->message_type());
1682 1682
 		$variations_select_values = array();
1683
-		foreach ( $variations as $variation => $label ) {
1683
+		foreach ($variations as $variation => $label) {
1684 1684
 			$variations_select_values[] = array(
1685 1685
 				'text' => $label,
1686 1686
 				'id' => $variation
1687 1687
 				);
1688 1688
 		}
1689 1689
 
1690
-		$template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels();
1690
+		$template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
1691 1691
 
1692
-		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input( 'MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name() );
1693
-		$template_args['variations_selector'] = EEH_Form_Fields::select_input( 'MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation() );
1692
+		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input('MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name());
1693
+		$template_args['variations_selector'] = EEH_Form_Fields::select_input('MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation());
1694 1694
 		$template_args['template_pack_label'] = $template_pack_labels->template_pack;
1695 1695
 		$template_args['template_variation_label'] = $template_pack_labels->template_variation;
1696 1696
 		$template_args['template_pack_description'] = $template_pack_labels->template_pack_description;
1697 1697
 		$template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
1698 1698
 
1699
-		$template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
1699
+		$template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php';
1700 1700
 
1701
-		EEH_Template::display_template( $template, $template_args );
1701
+		EEH_Template::display_template($template, $template_args);
1702 1702
 	}
1703 1703
 
1704 1704
 
@@ -1719,52 +1719,52 @@  discard block
 block discarded – undo
1719 1719
 			'GRP_ID' => $this->_message_template_group->GRP_ID()
1720 1720
 			);
1721 1721
 
1722
-		$button = $this->get_action_link_or_button( 'reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button' );
1722
+		$button = $this->get_action_link_or_button('reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button');
1723 1723
 
1724 1724
 
1725 1725
 		//test button
1726 1726
 		//first we need to see if there are any fields
1727 1727
 		$fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
1728 1728
 
1729
-		if ( !empty( $fields ) ) {
1729
+		if ( ! empty($fields)) {
1730 1730
 			//yup there be fields
1731
-			foreach ( $fields as $field => $config ) {
1732
-				$field_id = $this->_message_template_group->messenger() . '_' . $field;
1731
+			foreach ($fields as $field => $config) {
1732
+				$field_id = $this->_message_template_group->messenger().'_'.$field;
1733 1733
 				$existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
1734
-				$default = isset( $config['default'] ) ? $config['default'] : '';
1735
-				$default = isset( $config['value'] ) ? $config['value'] : $default;
1734
+				$default = isset($config['default']) ? $config['default'] : '';
1735
+				$default = isset($config['value']) ? $config['value'] : $default;
1736 1736
 
1737 1737
 				//if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults
1738 1738
 				$fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : '';
1739
-				$existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix;
1739
+				$existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix;
1740 1740
 
1741 1741
 				$template_form_fields[$field_id] = array(
1742
-					'name' => 'test_settings_fld[' . $field . ']',
1742
+					'name' => 'test_settings_fld['.$field.']',
1743 1743
 					'label' => $config['label'],
1744 1744
 					'input' => $config['input'],
1745 1745
 					'type' => $config['type'],
1746 1746
 					'required' => $config['required'],
1747 1747
 					'validation' => $config['validation'],
1748
-					'value' => isset( $existing[$field] ) ? $existing[$field] : $default,
1748
+					'value' => isset($existing[$field]) ? $existing[$field] : $default,
1749 1749
 					'css_class' => $config['css_class'],
1750
-					'options' => isset( $config['options'] ) ? $config['options'] : array(),
1750
+					'options' => isset($config['options']) ? $config['options'] : array(),
1751 1751
 					'default' => $default,
1752 1752
 					'format' => $config['format']
1753 1753
 					);
1754 1754
 			}
1755 1755
 		}
1756 1756
 
1757
-		$test_settings_fields = !empty( $template_form_fields) ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) : '';
1757
+		$test_settings_fields = ! empty($template_form_fields) ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') : '';
1758 1758
 
1759 1759
 		$test_settings_html = '';
1760 1760
 		//print out $test_settings_fields
1761
-		if ( !empty( $test_settings_fields ) ) {
1761
+		if ( ! empty($test_settings_fields)) {
1762 1762
 			echo $test_settings_fields;
1763
-			$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>';
1763
+			$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>';
1764 1764
 		}
1765 1765
 
1766 1766
 		//and button
1767
-		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>';
1767
+		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>';
1768 1768
 	}
1769 1769
 
1770 1770
 
@@ -1779,13 +1779,13 @@  discard block
 block discarded – undo
1779 1779
      * @param string $linked_input_id The css id of the input that the shortcodes get added to.
1780 1780
      * @return string
1781 1781
     */
1782
-	protected function _get_shortcode_selector( $field, $linked_input_id ) {
1782
+	protected function _get_shortcode_selector($field, $linked_input_id) {
1783 1783
 		$template_args = array(
1784
-			'shortcodes' => $this->_get_shortcodes( array( $field ), true ),
1784
+			'shortcodes' => $this->_get_shortcodes(array($field), true),
1785 1785
 			'fieldname' => $field,
1786 1786
 			'linked_input_id' => $linked_input_id
1787 1787
 		);
1788
-		return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true );
1788
+		return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true);
1789 1789
 	}
1790 1790
 
1791 1791
 
@@ -1800,13 +1800,13 @@  discard block
 block discarded – undo
1800 1800
 		$shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set
1801 1801
 		$messenger = $this->_message_template_group->messenger_obj();
1802 1802
 		//now let's set the content depending on the status of the shortcodes array
1803
-		if ( empty( $shortcodes ) ) {
1804
-			$content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>';
1803
+		if (empty($shortcodes)) {
1804
+			$content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>';
1805 1805
 			echo $content;
1806 1806
 		} else {
1807 1807
 			$alt = 0;
1808 1808
 			?>
1809
-			<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>
1809
+			<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>
1810 1810
 			<?php
1811 1811
 		}
1812 1812
 
@@ -1823,7 +1823,7 @@  discard block
 block discarded – undo
1823 1823
 	protected function _set_shortcodes() {
1824 1824
 
1825 1825
 		//no need to run this if the property is already set
1826
-		if ( !empty($this->_shortcodes ) ) {return;}
1826
+		if ( ! empty($this->_shortcodes)) {return; }
1827 1827
 
1828 1828
 		$this->_shortcodes = $this->_get_shortcodes();
1829 1829
 	}
@@ -1845,14 +1845,14 @@  discard block
 block discarded – undo
1845 1845
 	 * @return array          Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true
1846 1846
 	 *                       just an array of shortcode/label pairs.
1847 1847
 	 */
1848
-	protected function _get_shortcodes( $fields = array(), $merged = true ) {
1848
+	protected function _get_shortcodes($fields = array(), $merged = true) {
1849 1849
 		$this->_set_message_template_group();
1850 1850
 
1851 1851
 		//we need the messenger and message template to retrieve the valid shortcodes array.
1852
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false;
1853
-		$context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() );
1852
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false;
1853
+		$context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config());
1854 1854
 
1855
-		return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array();
1855
+		return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array();
1856 1856
 	}
1857 1857
 
1858 1858
 
@@ -1865,19 +1865,19 @@  discard block
 block discarded – undo
1865 1865
 	 */
1866 1866
 	protected function _set_message_template_group() {
1867 1867
 
1868
-		if ( !empty( $this->_message_template_group ) )
1869
-			{return;} //get out if this is already set.
1868
+		if ( ! empty($this->_message_template_group))
1869
+			{return; } //get out if this is already set.
1870 1870
 
1871
-		$GRP_ID =  ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false;
1872
-		$GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID;
1871
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false;
1872
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID;
1873 1873
 
1874 1874
 		//let's get the message templates
1875 1875
 		$MTP = EEM_Message_Template_Group::instance();
1876 1876
 
1877
-		if ( empty($GRP_ID) )
1878
-			{$this->_message_template_group = $MTP->create_default_object();}
1877
+		if (empty($GRP_ID))
1878
+			{$this->_message_template_group = $MTP->create_default_object(); }
1879 1879
 		else
1880
-			{$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );}
1880
+			{$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); }
1881 1881
 
1882 1882
 		$this->_template_pack = $this->_message_template_group->get_template_pack();
1883 1883
 		$this->_variation = $this->_message_template_group->get_template_pack_variation();
@@ -1896,7 +1896,7 @@  discard block
 block discarded – undo
1896 1896
 	 * @param array $args various things the context switcher needs.
1897 1897
 	 *
1898 1898
 	 */
1899
-	protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) {
1899
+	protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) {
1900 1900
 		$context_details = $template_group_object->contexts_config();
1901 1901
 		$context_label = $template_group_object->context_label();
1902 1902
 		ob_start();
@@ -1904,26 +1904,26 @@  discard block
 block discarded – undo
1904 1904
 		<div class="ee-msg-switcher-container">
1905 1905
 			<form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm">
1906 1906
 				<?php
1907
-					foreach ( $args as $name => $value ) {
1908
-						if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;}
1907
+					foreach ($args as $name => $value) {
1908
+						if ($name == 'context' || empty($value) || $name == 'extra') {continue; }
1909 1909
 						?>
1910 1910
 						<input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" />
1911 1911
 						<?php
1912 1912
 					}
1913 1913
 					//setup nonce_url
1914
-					wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
1914
+					wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false);
1915 1915
 				?>
1916 1916
 				<select name="context">
1917 1917
 					<?php
1918 1918
 					$context_templates = $template_group_object->context_templates();
1919
-					if ( is_array($context_templates) ) :
1920
-							foreach ( $context_templates as $context => $template_fields ) :
1919
+					if (is_array($context_templates)) :
1920
+							foreach ($context_templates as $context => $template_fields) :
1921 1921
 								$checked = ($context == $args['context']) ? 'selected="selected"' : '';
1922 1922
 					?>
1923 1923
 					<option value="<?php echo $context; ?>" <?php echo $checked; ?>><?php echo $context_details[$context]['label']; ?></option>
1924 1924
 					<?php endforeach; endif; ?>
1925 1925
 				</select>
1926
-				<?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?>
1926
+				<?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?>
1927 1927
 				<input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>">
1928 1928
 			</form>
1929 1929
 			<?php echo $args['extra']; ?>
@@ -1950,8 +1950,8 @@  discard block
 block discarded – undo
1950 1950
 	 * @return array
1951 1951
 	 */
1952 1952
 	protected function _set_message_template_column_values($index) {
1953
-		if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) {
1954
-			foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) {
1953
+		if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) {
1954
+			foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) {
1955 1955
 				$this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value;
1956 1956
 			}
1957 1957
 		} else {
@@ -1983,27 +1983,27 @@  discard block
 block discarded – undo
1983 1983
 
1984 1984
 
1985 1985
 
1986
-	protected function _insert_or_update_message_template($new = false ) {
1986
+	protected function _insert_or_update_message_template($new = false) {
1987 1987
 
1988
-		do_action ( 'AHEE_log', __FILE__, __FUNCTION__, '');
1988
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1989 1989
 		$success = 0;
1990 1990
 		$override = false;
1991 1991
 
1992 1992
 		//setup notices description
1993
-		$messenger = !empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'] ) ) : false;
1994
-		$message_type = !empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'] ) ) : false;
1995
-		$context = !empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'] ) ) : false;
1993
+		$messenger = ! empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) : false;
1994
+		$message_type = ! empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) : false;
1995
+		$context = ! empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) : false;
1996 1996
 
1997
-		$item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : '';
1997
+		$item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : '';
1998 1998
 		$item_desc .= 'Message Template';
1999 1999
 		$query_args = array();
2000 2000
 		$validates = '';
2001 2001
 
2002 2002
 		//if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit.
2003
-		if ( $new ) {
2004
-			$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
2005
-			if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) {
2006
-				if ( empty($edit_array) ) {
2003
+		if ($new) {
2004
+			$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
2005
+			if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) {
2006
+				if (empty($edit_array)) {
2007 2007
 					$success = 0;
2008 2008
 				} else {
2009 2009
 					$success = 1;
@@ -2022,34 +2022,34 @@  discard block
 block discarded – undo
2022 2022
 
2023 2023
 
2024 2024
 			//run update for each template field in displayed context
2025
-			if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) {
2026
-				EE_Error::add_error( __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2025
+			if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) {
2026
+				EE_Error::add_error(__('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2027 2027
 				$success = 0;
2028 2028
 				$action_desc = '';
2029 2029
 
2030 2030
 			} else {
2031 2031
 				//first validate all fields!
2032
-				$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']);
2032
+				$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']);
2033 2033
 
2034 2034
 				//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.
2035
-				if ( is_array($validates) && !empty($validates) ) {
2035
+				if (is_array($validates) && ! empty($validates)) {
2036 2036
 					//add the transient so when the form loads we know which fields to highlight
2037
-					$this->_add_transient( 'edit_message_template', $validates );
2037
+					$this->_add_transient('edit_message_template', $validates);
2038 2038
 
2039 2039
 					$success = 0;
2040
-					$action_desc ='';
2040
+					$action_desc = '';
2041 2041
 
2042 2042
 					//setup notices
2043
-					foreach ( $validates as $field => $error ) {
2044
-						if ( isset($error['msg'] ) )
2045
-							{EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );}
2043
+					foreach ($validates as $field => $error) {
2044
+						if (isset($error['msg']))
2045
+							{EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__); }
2046 2046
 					}
2047 2047
 
2048 2048
 				} else {
2049
-					foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) {
2049
+					foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) {
2050 2050
 						$set_column_values = $this->_set_message_template_column_values($template_field);
2051 2051
 
2052
-						$where_cols_n_values = array( 'MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']);
2052
+						$where_cols_n_values = array('MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']);
2053 2053
 
2054 2054
 						$message_template_fields = array(
2055 2055
 							'GRP_ID' => $set_column_values['GRP_ID'],
@@ -2057,10 +2057,10 @@  discard block
 block discarded – undo
2057 2057
 							'MTP_context' => $set_column_values['MTP_context'],
2058 2058
 							'MTP_content' => $set_column_values['MTP_content']
2059 2059
 							);
2060
-						if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) {
2061
-							if ( $updated === false ) {
2062
-								$msg = sprintf( __('%s field was NOT updated for some reason', 'event_espresso'), $template_field );
2063
-								EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ );
2060
+						if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) {
2061
+							if ($updated === false) {
2062
+								$msg = sprintf(__('%s field was NOT updated for some reason', 'event_espresso'), $template_field);
2063
+								EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2064 2064
 							} else {
2065 2065
 								$success = 1;
2066 2066
 							}
@@ -2077,24 +2077,24 @@  discard block
 block discarded – undo
2077 2077
 						'MTP_is_override' => $set_column_values['MTP_is_override'],
2078 2078
 						'MTP_deleted' => $set_column_values['MTP_deleted'],
2079 2079
 						'MTP_is_active' => $set_column_values['MTP_is_active'],
2080
-						'MTP_name' => !empty( $this->_req_data['ee_msg_non_global_fields']['MTP_name'] ) ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] : '',
2081
-						'MTP_description' => !empty( $this->_req_data['ee_msg_non_global_fields']['MTP_description'] ) ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] : ''
2080
+						'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] : '',
2081
+						'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] : ''
2082 2082
 						);
2083 2083
 
2084
-					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] );
2085
-					$updated = $MTPG->update( $mtpg_fields, array($mtpg_where) );
2084
+					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']);
2085
+					$updated = $MTPG->update($mtpg_fields, array($mtpg_where));
2086 2086
 
2087
-					if ( $updated === false ) {
2088
-						$msg = sprintf( __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), $set_column_values['GRP_ID'] );
2089
-						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ );
2087
+					if ($updated === false) {
2088
+						$msg = sprintf(__('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), $set_column_values['GRP_ID']);
2089
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2090 2090
 					} else {
2091 2091
 						//k now we need to ensure the template_pack and template_variation fields are set.
2092
-						$template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) ? $this->_req_data['MTP_template_pack'] : 'default';
2093
-						$template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) ? $this->_req_data['MTP_template_variation'] : 'default';
2094
-						$mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] );
2095
-						if ( $mtpg_obj instanceof EE_Message_Template_Group ) {
2096
-							$mtpg_obj->set_template_pack_name( $template_pack );
2097
-							$mtpg_obj->set_template_pack_variation( $template_variation );
2092
+						$template_pack = ! empty($this->_req_data['MTP_template_pack']) ? $this->_req_data['MTP_template_pack'] : 'default';
2093
+						$template_variation = ! empty($this->_req_data['MTP_template_variation']) ? $this->_req_data['MTP_template_variation'] : 'default';
2094
+						$mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']);
2095
+						if ($mtpg_obj instanceof EE_Message_Template_Group) {
2096
+							$mtpg_obj->set_template_pack_name($template_pack);
2097
+							$mtpg_obj->set_template_pack_variation($template_variation);
2098 2098
 						}
2099 2099
 						$success = 1;
2100 2100
 					}
@@ -2104,7 +2104,7 @@  discard block
 block discarded – undo
2104 2104
 		}
2105 2105
 
2106 2106
 		//we return things differently if doing ajax
2107
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
2107
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2108 2108
 			$this->_template_args['success'] = $success;
2109 2109
 			$this->_template_args['error'] = ! $success ? true : false;
2110 2110
 			$this->_template_args['content'] = '';
@@ -2112,9 +2112,9 @@  discard block
 block discarded – undo
2112 2112
 				'grpID' => $edit_array['GRP_ID'],
2113 2113
 				'templateName' => $edit_array['template_name']
2114 2114
 				);
2115
-			if ( $success ) {
2115
+			if ($success) {
2116 2116
 				EE_Error::overwrite_success();
2117
-				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') );
2117
+				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'));
2118 2118
 			}
2119 2119
 
2120 2120
 			$this->_return_json();
@@ -2122,13 +2122,13 @@  discard block
 block discarded – undo
2122 2122
 
2123 2123
 
2124 2124
 		//was a test send triggered?
2125
-		if ( isset( $this->_req_data['test_button'] ) ) {
2125
+		if (isset($this->_req_data['test_button'])) {
2126 2126
 			EE_Error::overwrite_success();
2127
-			$this->_do_test_send( $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] );
2127
+			$this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2128 2128
 			$override = true;
2129 2129
 		}
2130 2130
 
2131
-		if ( empty( $query_args ) ) {
2131
+		if (empty($query_args)) {
2132 2132
 			$query_args = array(
2133 2133
 				'id' => $this->_req_data['GRP_ID'],
2134 2134
 				'context' => $this->_req_data['MTP_context'],
@@ -2136,7 +2136,7 @@  discard block
 block discarded – undo
2136 2136
 				);
2137 2137
 		}
2138 2138
 
2139
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override );
2139
+		$this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
2140 2140
 	}
2141 2141
 
2142 2142
 
@@ -2150,24 +2150,24 @@  discard block
 block discarded – undo
2150 2150
 	 * @param  string $message_type message type being tested
2151 2151
 	 *
2152 2152
 	 */
2153
-	protected function _do_test_send( $context, $messenger, $message_type ) {
2153
+	protected function _do_test_send($context, $messenger, $message_type) {
2154 2154
 		//set things up for preview
2155 2155
 		$this->_req_data['messenger'] = $messenger;
2156 2156
 		$this->_req_data['message_type'] = $message_type;
2157 2157
 		$this->_req_data['context'] = $context;
2158
-		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : '';
2158
+		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : '';
2159 2159
 
2160 2160
 		//let's save any existing fields that might be required by the messenger
2161
-		if ( isset( $this->_req_data['test_settings_fld'] ) ) {
2162
-			$this->_active_messengers[$messenger]['obj']->set_existing_test_settings( $this->_req_data['test_settings_fld'] );
2161
+		if (isset($this->_req_data['test_settings_fld'])) {
2162
+			$this->_active_messengers[$messenger]['obj']->set_existing_test_settings($this->_req_data['test_settings_fld']);
2163 2163
 		}
2164 2164
 
2165 2165
 		$success = $this->_preview_message(true);
2166 2166
 
2167
-		if ( $success ) {
2168
-			EE_Error::add_success( __('Test message sent', 'event_espresso') );
2167
+		if ($success) {
2168
+			EE_Error::add_success(__('Test message sent', 'event_espresso'));
2169 2169
 		} else {
2170
-			EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
2170
+			EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2171 2171
 		}
2172 2172
 	}
2173 2173
 
@@ -2194,12 +2194,12 @@  discard block
 block discarded – undo
2194 2194
 	protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) {
2195 2195
 
2196 2196
 		//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.
2197
-		if ( empty( $message_types ) )
2198
-			{return true;}
2197
+		if (empty($message_types))
2198
+			{return true; }
2199 2199
 
2200
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
2200
+		EE_Registry::instance()->load_helper('MSG_Template');
2201 2201
 
2202
-		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID,  $global);
2202
+		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
2203 2203
 
2204 2204
 	}
2205 2205
 
@@ -2216,33 +2216,33 @@  discard block
 block discarded – undo
2216 2216
 	 *
2217 2217
 	 * @return void
2218 2218
 	 */
2219
-	protected function _trash_or_restore_message_template($trash = true, $all = false ) {
2220
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2219
+	protected function _trash_or_restore_message_template($trash = true, $all = false) {
2220
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2221 2221
 		$MTP = EEM_Message_Template_Group::instance();
2222 2222
 
2223 2223
 		$success = 1;
2224 2224
 
2225 2225
 		//incoming GRP_IDs
2226
-		if ( $all ) {
2226
+		if ($all) {
2227 2227
 			//Checkboxes
2228
-			if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) {
2228
+			if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2229 2229
 				//if array has more than one element then success message should be plural.
2230 2230
 				//todo: what about nonce?
2231
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2231
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2232 2232
 
2233 2233
 				//cycle through checkboxes
2234
-				while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) {
2235
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2236
-					if ( ! $trashed_or_restored ) {
2234
+				while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2235
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2236
+					if ( ! $trashed_or_restored) {
2237 2237
 						$success = 0;
2238 2238
 					}
2239 2239
 				}
2240 2240
 			} else {
2241 2241
 				//grab single GRP_ID and handle
2242
-				$GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0;
2243
-				if ( ! empty( $GRP_ID ) ) {
2244
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2245
-					if ( ! $trashed_or_restored ) {
2242
+				$GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
2243
+				if ( ! empty($GRP_ID)) {
2244
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2245
+					if ( ! $trashed_or_restored) {
2246 2246
 						$success = 0;
2247 2247
 					}
2248 2248
 				} else {
@@ -2254,13 +2254,13 @@  discard block
 block discarded – undo
2254 2254
 
2255 2255
 		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2256 2256
 
2257
-		$action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc;
2257
+		$action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc;
2258 2258
 
2259 2259
 		$item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
2260 2260
 
2261
-		$item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2261
+		$item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2262 2262
 
2263
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, array() );
2263
+		$this->_redirect_after_action($success, $item_desc, $action_desc, array());
2264 2264
 
2265 2265
 	}
2266 2266
 
@@ -2276,26 +2276,26 @@  discard block
 block discarded – undo
2276 2276
 	 * @return void
2277 2277
 	 */
2278 2278
 	protected function _delete_message_template() {
2279
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2279
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2280 2280
 
2281 2281
 		$success = 1;
2282 2282
 
2283 2283
 		//checkboxes
2284
-		if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) {
2284
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2285 2285
 			//if array has more than one element then success message should be plural
2286
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2286
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2287 2287
 
2288 2288
 			//cycle through bulk action checkboxes
2289
-			while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) {
2290
-				$success = $this->_delete_mtp_permanently( $GRP_ID );
2289
+			while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2290
+				$success = $this->_delete_mtp_permanently($GRP_ID);
2291 2291
 			}
2292 2292
 		} else {
2293 2293
 			//grab single grp_id and delete
2294
-			$GRP_ID = absint($this->_req_data['id'] );
2295
-			$success = $this->_delete_mtp_permanently( $GRP_ID );
2294
+			$GRP_ID = absint($this->_req_data['id']);
2295
+			$success = $this->_delete_mtp_permanently($GRP_ID);
2296 2296
 		}
2297 2297
 
2298
-		$this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() );
2298
+		$this->_redirect_after_action($success, 'Message Templates', 'deleted', array());
2299 2299
 
2300 2300
 	}
2301 2301
 
@@ -2310,20 +2310,20 @@  discard block
 block discarded – undo
2310 2310
 	 *
2311 2311
 	 * @return success        boolean to indicate the success of the deletes or not.
2312 2312
 	 */
2313
-	private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) {
2313
+	private function _delete_mtp_permanently($GRP_ID, $include_group = true) {
2314 2314
 		$success = 1;
2315 2315
 		$MTPG = EEM_Message_Template_Group::instance();
2316 2316
 		//first let's GET this group
2317
-		$MTG = $MTPG->get_one_by_ID( $GRP_ID );
2317
+		$MTG = $MTPG->get_one_by_ID($GRP_ID);
2318 2318
 		//then delete permanently all the related Message Templates
2319
-		$deleted = $MTG->delete_related_permanently( 'Message_Template' );
2319
+		$deleted = $MTG->delete_related_permanently('Message_Template');
2320 2320
 
2321
-		if ( $deleted === 0 )
2322
-			{$success = 0;}
2321
+		if ($deleted === 0)
2322
+			{$success = 0; }
2323 2323
 
2324 2324
 		//now delete permanently this particular group
2325 2325
 
2326
-		if ( $include_group && ! $MTG->delete_permanently() ) {
2326
+		if ($include_group && ! $MTG->delete_permanently()) {
2327 2327
 			$success = 0;
2328 2328
 		}
2329 2329
 		return $success;
@@ -2341,7 +2341,7 @@  discard block
 block discarded – undo
2341 2341
 	*	@return string
2342 2342
 	*/
2343 2343
 	protected function _learn_more_about_message_templates_link() {
2344
-		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>';
2344
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>';
2345 2345
 	}
2346 2346
 
2347 2347
 
@@ -2356,14 +2356,14 @@  discard block
 block discarded – undo
2356 2356
 	 */
2357 2357
 	protected function _settings() {
2358 2358
 
2359
-		EE_Registry::instance()->load_helper( 'Tabbed_Content' );
2359
+		EE_Registry::instance()->load_helper('Tabbed_Content');
2360 2360
 
2361 2361
 		$this->_set_m_mt_settings();
2362 2362
 
2363
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2363
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2364 2364
 
2365 2365
 		//let's setup the messenger tabs
2366
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger );
2366
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger);
2367 2367
 		$this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
2368 2368
 		$this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->';
2369 2369
 
@@ -2382,10 +2382,10 @@  discard block
 block discarded – undo
2382 2382
 	 */
2383 2383
 	protected function _set_m_mt_settings() {
2384 2384
 		//first if this is already set then lets get out no need to regenerate data.
2385
-		if ( !empty($this->_m_mt_settings) )
2386
-			{return;}
2385
+		if ( ! empty($this->_m_mt_settings))
2386
+			{return; }
2387 2387
 
2388
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2388
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2389 2389
 
2390 2390
 		//get all installed messengers and message_types
2391 2391
 		$installed_message_objects = $this->_get_installed_message_objects();
@@ -2395,10 +2395,10 @@  discard block
 block discarded – undo
2395 2395
 
2396 2396
 		//assemble the array for the _tab_text_links helper
2397 2397
 
2398
-		foreach ( $messengers as $messenger ) {
2398
+		foreach ($messengers as $messenger) {
2399 2399
 			$this->_m_mt_settings['messenger_tabs'][$messenger->name] = array(
2400 2400
 				'label' => ucwords($messenger->label['singular']),
2401
-				'class' => isset( $this->_active_messengers[$messenger->name] ) ? 'messenger-active' : '',
2401
+				'class' => isset($this->_active_messengers[$messenger->name]) ? 'messenger-active' : '',
2402 2402
 				'href' => $messenger->name,
2403 2403
 				'title' => __('Modify this Messenger', 'event_espresso'),
2404 2404
 				'slug' => $messenger->name,
@@ -2408,23 +2408,23 @@  discard block
 block discarded – undo
2408 2408
 			$message_types_for_messenger = $messenger->get_valid_message_types();
2409 2409
 
2410 2410
 			//assemble the array for the ACTIVE and INACTIVE message types with the selected messenger //note that all message types will be in the inactive box if the messenger is NOT active.
2411
-			$selected_settings = isset( $this->_active_messengers[$messenger->name]['settings'] ) ? $this->_active_messengers[$messenger->name]['settings'] : array();
2412
-			foreach ( $message_types as $message_type ) {
2411
+			$selected_settings = isset($this->_active_messengers[$messenger->name]['settings']) ? $this->_active_messengers[$messenger->name]['settings'] : array();
2412
+			foreach ($message_types as $message_type) {
2413 2413
 				//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.
2414
-				if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) {
2414
+				if ( ! in_array($message_type->name, $message_types_for_messenger)) {
2415 2415
 					continue;
2416 2416
 				}
2417 2417
 
2418
-				$a_or_i = isset( $selected_settings[$messenger->name . '-message_types'][$message_type->name] ) && $selected_settings[$messenger->name . '-message_types'][$message_type->name] ? 'active' : 'inactive';
2418
+				$a_or_i = isset($selected_settings[$messenger->name.'-message_types'][$message_type->name]) && $selected_settings[$messenger->name.'-message_types'][$message_type->name] ? 'active' : 'inactive';
2419 2419
 
2420 2420
 				$this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
2421 2421
 						'label' => ucwords($message_type->label['singular']),
2422
-						'class' => 'message-type-' . $a_or_i,
2423
-						'slug_id' => $message_type->name . '-messagetype-' . $messenger->name,
2424
-						'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'),
2425
-						'href' => 'espresso_' . $message_type->name . '_message_type_settings',
2422
+						'class' => 'message-type-'.$a_or_i,
2423
+						'slug_id' => $message_type->name.'-messagetype-'.$messenger->name,
2424
+						'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'),
2425
+						'href' => 'espresso_'.$message_type->name.'_message_type_settings',
2426 2426
 						'title' => $a_or_i == 'active' ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') : __('Drag this message type to the messenger to activate', 'event_espresso'),
2427
-						'content' => $a_or_i == 'active' ? $this->_message_type_settings_content( $message_type, $messenger, true ) : $this->_message_type_settings_content( $message_type, $messenger ),
2427
+						'content' => $a_or_i == 'active' ? $this->_message_type_settings_content($message_type, $messenger, true) : $this->_message_type_settings_content($message_type, $messenger),
2428 2428
 						'slug' => $message_type->name,
2429 2429
 						'active' => $a_or_i == 'active' ? true : false,
2430 2430
 						'obj' => $message_type
@@ -2443,34 +2443,34 @@  discard block
 block discarded – undo
2443 2443
 	 *
2444 2444
 	 * @return string                html output for the content
2445 2445
 	 */
2446
-	protected function _message_type_settings_content( $message_type, $messenger, $active = false ) {
2446
+	protected function _message_type_settings_content($message_type, $messenger, $active = false) {
2447 2447
 		//get message type fields
2448 2448
 		$fields = $message_type->get_admin_settings_fields();
2449
-		$settings_template_args['template_form_fields']= '';
2449
+		$settings_template_args['template_form_fields'] = '';
2450 2450
 
2451
-		if ( !empty( $fields ) && $active ) {
2451
+		if ( ! empty($fields) && $active) {
2452 2452
 
2453
-			$existing_settings = $message_type->get_existing_admin_settings( $messenger->name );
2453
+			$existing_settings = $message_type->get_existing_admin_settings($messenger->name);
2454 2454
 
2455
-			foreach( $fields as $fldname => $fldprops ) {
2456
-				$field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname;
2455
+			foreach ($fields as $fldname => $fldprops) {
2456
+				$field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname;
2457 2457
 				$template_form_field[$field_id] = array(
2458
-					'name' => 'message_type_settings[' . $fldname . ']',
2458
+					'name' => 'message_type_settings['.$fldname.']',
2459 2459
 					'label' => $fldprops['label'],
2460 2460
 					'input' => $fldprops['field_type'],
2461 2461
 					'type' => $fldprops['value_type'],
2462 2462
 					'required' => $fldprops['required'],
2463 2463
 					'validation' => $fldprops['validation'],
2464
-					'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2465
-					'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(),
2466
-					'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'],
2464
+					'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2465
+					'options' => isset($fldprops['options']) ? $fldprops['options'] : array(),
2466
+					'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2467 2467
 					'css_class' => 'no-drag',
2468 2468
 					'format' => $fldprops['format']
2469 2469
 					);
2470 2470
 			}
2471 2471
 
2472 2472
 
2473
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : '';
2473
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : '';
2474 2474
 		}
2475 2475
 
2476 2476
 		$settings_template_args['description'] = $message_type->description;
@@ -2490,13 +2490,13 @@  discard block
 block discarded – undo
2490 2490
 					)
2491 2491
 				);
2492 2492
 
2493
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2494
-		$settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : '';
2493
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2494
+		$settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : '';
2495 2495
 
2496 2496
 
2497 2497
 
2498
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
2499
-		$content = EEH_Template::display_template( $template, $settings_template_args, true );
2498
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php';
2499
+		$content = EEH_Template::display_template($template, $settings_template_args, true);
2500 2500
 		return $content;
2501 2501
 	}
2502 2502
 
@@ -2513,21 +2513,21 @@  discard block
 block discarded – undo
2513 2513
 		$m_boxes = $mt_boxes = array();
2514 2514
 		$m_template_args = $mt_template_args = array();
2515 2515
 
2516
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2516
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2517 2517
 
2518
-		foreach ( $this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array ) {
2518
+		foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
2519 2519
 
2520
-			$hide_on_message = isset( $this->_active_messengers[$messenger] ) ? '' : 'hidden';
2521
-			$hide_off_message = isset( $this->_active_messengers[$messenger] ) ? 'hidden' : '';
2520
+			$hide_on_message = isset($this->_active_messengers[$messenger]) ? '' : 'hidden';
2521
+			$hide_off_message = isset($this->_active_messengers[$messenger]) ? 'hidden' : '';
2522 2522
 
2523 2523
 			//messenger meta boxes
2524 2524
 			$active = $selected_messenger == $messenger ? true : false;
2525
-			$active_mt_tabs = isset(  $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] ) ?  $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : '';
2526
-			$m_boxes[$messenger . '_a_box'] = sprintf( __('%s Settings', 'event_espresso'), $tab_array['label'] );
2527
-			$m_template_args[$messenger . '_a_box'] = array(
2528
-					'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2529
-					'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '',
2530
-					'content' => $this->_get_messenger_box_content( $tab_array['obj'] ),
2525
+			$active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : '';
2526
+			$m_boxes[$messenger.'_a_box'] = sprintf(__('%s Settings', 'event_espresso'), $tab_array['label']);
2527
+			$m_template_args[$messenger.'_a_box'] = array(
2528
+					'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2529
+					'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '',
2530
+					'content' => $this->_get_messenger_box_content($tab_array['obj']),
2531 2531
 					'hidden' => $active ? '' : ' hidden',
2532 2532
 					'hide_on_message' => $hide_on_message,
2533 2533
 					'messenger' => $messenger,
@@ -2536,10 +2536,10 @@  discard block
 block discarded – undo
2536 2536
 
2537 2537
 
2538 2538
 			//message type meta boxes (which is really just the inactive container for each messenger showing inactive message types for that messenger)
2539
-			$mt_boxes[$messenger . '_i_box'] = __('Inactive Message Types', 'event_espresso');
2540
-			$mt_template_args[$messenger . '_i_box'] = array(
2541
-				'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2542
-				'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '',
2539
+			$mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso');
2540
+			$mt_template_args[$messenger.'_i_box'] = array(
2541
+				'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2542
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '',
2543 2543
 				'hidden' => $active ? '' : ' hidden',
2544 2544
 				'hide_on_message' => $hide_on_message,
2545 2545
 				'hide_off_message' => $hide_off_message,
@@ -2549,19 +2549,19 @@  discard block
 block discarded – undo
2549 2549
 		}
2550 2550
 
2551 2551
 		//register messenger metaboxes
2552
-		$m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
2553
-		foreach ( $m_boxes as $box => $label ) {
2554
-			$callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] );
2555
-			$msgr = str_replace( '_a_box', '', $box );
2556
-			add_meta_box( 'espresso_' . $msgr . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args );
2552
+		$m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php';
2553
+		foreach ($m_boxes as $box => $label) {
2554
+			$callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
2555
+			$msgr = str_replace('_a_box', '', $box);
2556
+			add_meta_box('espresso_'.$msgr.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
2557 2557
 		}
2558 2558
 
2559 2559
 		//register message type metaboxes
2560
-		$mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
2561
-		foreach ( $mt_boxes as $box => $label ) {
2562
-			$callback_args = array( 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] );
2563
-			$mt = str_replace( '_i_box', '', $box );
2564
-			add_meta_box( 'espresso_' . $mt . '_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args );
2560
+		$mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php';
2561
+		foreach ($mt_boxes as $box => $label) {
2562
+			$callback_args = array('template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]);
2563
+			$mt = str_replace('_i_box', '', $box);
2564
+			add_meta_box('espresso_'.$mt.'_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args);
2565 2565
 		}
2566 2566
 
2567 2567
 	}
@@ -2574,13 +2574,13 @@  discard block
 block discarded – undo
2574 2574
 	 *
2575 2575
 	 * @return string            html formatted tabs
2576 2576
 	 */
2577
-	protected function _get_mt_tabs( $tab_array ) {
2577
+	protected function _get_mt_tabs($tab_array) {
2578 2578
 		$tab_array = (array) $tab_array;
2579
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
2579
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php';
2580 2580
 		$tabs = '';
2581 2581
 
2582
-		foreach ( $tab_array as $tab ) {
2583
-			$tabs .=  EEH_Template::display_template( $template, $tab, true );
2582
+		foreach ($tab_array as $tab) {
2583
+			$tabs .= EEH_Template::display_template($template, $tab, true);
2584 2584
 		}
2585 2585
 
2586 2586
 		return $tabs;
@@ -2596,7 +2596,7 @@  discard block
 block discarded – undo
2596 2596
 	 *
2597 2597
 	 * @return string            html formatted content
2598 2598
 	 */
2599
-	protected function _get_messenger_box_content( $messenger ) {
2599
+	protected function _get_messenger_box_content($messenger) {
2600 2600
 
2601 2601
 		$fields = $messenger->get_admin_settings_fields();
2602 2602
 		$settings_template_args['template_form_fields'] = '';
@@ -2605,27 +2605,27 @@  discard block
 block discarded – undo
2605 2605
 		$settings_template_args['active'] = isset($this->_active_messengers[$messenger->name]) ? true : false;
2606 2606
 
2607 2607
 
2608
-		if ( !empty( $fields ) ) {
2608
+		if ( ! empty($fields)) {
2609 2609
 
2610 2610
 			$existing_settings = $messenger->get_existing_admin_settings();
2611 2611
 
2612
-			foreach( $fields as $fldname => $fldprops ) {
2613
-				$field_id = $messenger->name . '-' . $fldname;
2612
+			foreach ($fields as $fldname => $fldprops) {
2613
+				$field_id = $messenger->name.'-'.$fldname;
2614 2614
 				$template_form_field[$field_id] = array(
2615
-					'name' => 'messenger_settings[' . $field_id . ']',
2615
+					'name' => 'messenger_settings['.$field_id.']',
2616 2616
 					'label' => $fldprops['label'],
2617 2617
 					'input' => $fldprops['field_type'],
2618 2618
 					'type' => $fldprops['value_type'],
2619 2619
 					'required' => $fldprops['required'],
2620 2620
 					'validation' => $fldprops['validation'],
2621
-					'value' => isset( $existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'],
2621
+					'value' => isset($existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'],
2622 2622
 					'css_class' => '',
2623 2623
 					'format' => $fldprops['format']
2624 2624
 					);
2625 2625
 			}
2626 2626
 
2627 2627
 
2628
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) : '';
2628
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') : '';
2629 2629
 		}
2630 2630
 
2631 2631
 		//we also need some hidden fields
@@ -2641,8 +2641,8 @@  discard block
 block discarded – undo
2641 2641
 			);
2642 2642
 
2643 2643
 		//make sure any active message types that are existing are included in the hidden fields
2644
-		if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) {
2645
-			foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) {
2644
+		if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
2645
+			foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
2646 2646
 				$settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array(
2647 2647
 						'type' => 'hidden',
2648 2648
 						'value' => $mt
@@ -2650,25 +2650,25 @@  discard block
 block discarded – undo
2650 2650
 			}
2651 2651
 		}
2652 2652
 
2653
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2653
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2654 2654
 
2655
-		$active = isset( $this->_active_messengers[$messenger->name] ) ? true : false;
2655
+		$active = isset($this->_active_messengers[$messenger->name]) ? true : false;
2656 2656
 
2657 2657
 		$settings_template_args['messenger'] = $messenger->name;
2658 2658
 		$settings_template_args['description'] = $messenger->description;
2659 2659
 		$settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
2660 2660
 
2661 2661
 
2662
-		$settings_template_args['show_hide_edit_form'] = isset( $this->_active_messengers[$messenger->name] ) ? $settings_template_args['show_hide_edit_form'] : ' hidden';
2662
+		$settings_template_args['show_hide_edit_form'] = isset($this->_active_messengers[$messenger->name]) ? $settings_template_args['show_hide_edit_form'] : ' hidden';
2663 2663
 
2664
-		$settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : $settings_template_args['show_hide_edit_form'];
2664
+		$settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : $settings_template_args['show_hide_edit_form'];
2665 2665
 
2666 2666
 
2667 2667
 		$settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
2668
-		$settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
2668
+		$settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce');
2669 2669
 		$settings_template_args['on_off_status'] = $active ? true : false;
2670
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
2671
-		$content = EEH_Template::display_template( $template, $settings_template_args, true);
2670
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php';
2671
+		$content = EEH_Template::display_template($template, $settings_template_args, true);
2672 2672
 		return $content;
2673 2673
 	}
2674 2674
 
@@ -2682,39 +2682,39 @@  discard block
 block discarded – undo
2682 2682
 	public function activate_messenger_toggle() {
2683 2683
 		$success = true;
2684 2684
 		//let's check that we have required data
2685
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
2686
-			EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2685
+		if ( ! isset($this->_req_data['messenger'])) {
2686
+			EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2687 2687
 			$success = false;
2688 2688
 		}
2689 2689
 
2690 2690
 		//do a nonce check here since we're not arriving via a normal route
2691
-		$nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : '';
2692
-		$nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
2691
+		$nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : '';
2692
+		$nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce';
2693 2693
 
2694
-		$this->_verify_nonce( $nonce, $nonce_ref );
2694
+		$this->_verify_nonce($nonce, $nonce_ref);
2695 2695
 
2696 2696
 
2697 2697
 
2698
-		if ( !isset( $this->_req_data[ 'status' ])) {
2699
-			EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2698
+		if ( ! isset($this->_req_data['status'])) {
2699
+			EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2700 2700
 			$success = false;
2701 2701
 		}
2702 2702
 
2703 2703
 		//do check to verify we have a valid status.
2704 2704
 		$status = $this->_req_data['status'];
2705 2705
 
2706
-		if ( $status != 'off' && $status != 'on' ) {
2707
-			EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ );
2706
+		if ($status != 'off' && $status != 'on') {
2707
+			EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__);
2708 2708
 			$success = false;
2709 2709
 		}
2710 2710
 
2711
-		if ( $success ) {
2711
+		if ($success) {
2712 2712
 			//made it here?  Stop dawdling then!!
2713
-			if ( $status == 'off' ) {
2713
+			if ($status == 'off') {
2714 2714
 				//off = deactivate.  get it?
2715
-				$success = $this->_activate_messenger( $this->_req_data['messenger'], true );
2715
+				$success = $this->_activate_messenger($this->_req_data['messenger'], true);
2716 2716
 			} else {
2717
-				$success = $this->_activate_messenger( $this->_req_data['messenger'] );
2717
+				$success = $this->_activate_messenger($this->_req_data['messenger']);
2718 2718
 			}
2719 2719
 		}
2720 2720
 
@@ -2740,26 +2740,26 @@  discard block
 block discarded – undo
2740 2740
 
2741 2741
 
2742 2742
 		//let's make sure we have the necessary data
2743
-		if ( !isset( $this->_req_data[ 'message_type' ] ) ) {
2744
-			EE_Error::add_error( __('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2743
+		if ( ! isset($this->_req_data['message_type'])) {
2744
+			EE_Error::add_error(__('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2745 2745
 			$success = false;
2746 2746
 		}
2747 2747
 
2748 2748
 
2749 2749
 		//do a nonce check here since we're not arriving via a normal route
2750
-		$nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : '';
2751
-		$nonce_ref = $this->_req_data['message_type'] . '_nonce';
2750
+		$nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
2751
+		$nonce_ref = $this->_req_data['message_type'].'_nonce';
2752 2752
 
2753
-		$this->_verify_nonce( $nonce, $nonce_ref );
2753
+		$this->_verify_nonce($nonce, $nonce_ref);
2754 2754
 
2755 2755
 
2756
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
2757
-			EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2756
+		if ( ! isset($this->_req_data['messenger'])) {
2757
+			EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2758 2758
 			$success = false;
2759 2759
 		}
2760 2760
 
2761
-		if ( !isset( $this->_req_data[ 'status' ])) {
2762
-			EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2761
+		if ( ! isset($this->_req_data['status'])) {
2762
+			EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2763 2763
 			$success = false;
2764 2764
 		}
2765 2765
 
@@ -2767,16 +2767,16 @@  discard block
 block discarded – undo
2767 2767
 		//do check to verify we have a valid status.
2768 2768
 		$status = $this->_req_data['status'];
2769 2769
 
2770
-		if ( $status != 'activate' && $status != 'deactivate' ) {
2771
-			EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ );
2770
+		if ($status != 'activate' && $status != 'deactivate') {
2771
+			EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__);
2772 2772
 			$success = false;
2773 2773
 		}
2774 2774
 
2775 2775
 
2776
-		if ( $success ) {
2776
+		if ($success) {
2777 2777
 			//made it here? um, what are you waiting for then?
2778 2778
 			$deactivate = $status == 'deactivate' ? true : false;
2779
-			$success = $this->_activate_messenger( $this->_req_data['messenger'], $deactivate, $this->_req_data['message_type'] );
2779
+			$success = $this->_activate_messenger($this->_req_data['messenger'], $deactivate, $this->_req_data['message_type']);
2780 2780
 		}
2781 2781
 
2782 2782
 		$this->_template_args['success'] = $success;
@@ -2807,28 +2807,28 @@  discard block
 block discarded – undo
2807 2807
 		$templates = true;
2808 2808
 		$this->_set_m_mt_settings();
2809 2809
 
2810
-		if ( !$deactivate ) {
2810
+		if ( ! $deactivate) {
2811 2811
 
2812 2812
 
2813 2813
 			//we are activating.  we can use $this->_m_mt_settings to get all the installed messengers
2814
-			$this->_active_messengers[$messenger]['settings'] = !isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings'];
2814
+			$this->_active_messengers[$messenger]['settings'] = ! isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings'];
2815 2815
 			$this->_active_messengers[$messenger]['obj'] = $this->_m_mt_settings['messenger_tabs'][$messenger]['obj'];
2816 2816
 
2817 2817
 			//get has_active so we can sure its kept up to date.
2818
-			$has_activated = get_option( 'ee_has_activated_messages' );
2818
+			$has_activated = get_option('ee_has_activated_messages');
2819 2819
 
2820
-			if ( empty( $has_activated[$messenger] ) ) {
2820
+			if (empty($has_activated[$messenger])) {
2821 2821
 				$has_activated[$messenger] = array();
2822 2822
 			}
2823 2823
 
2824 2824
 			//k we need to get what default message types are to be associated with the messenger that's been activated.
2825 2825
 			$default_types = $message_type ? (array) $message_type : $this->_active_messengers[$messenger]['obj']->get_default_message_types();
2826 2826
 
2827
-			foreach ( $default_types as $type ) {
2827
+			foreach ($default_types as $type) {
2828 2828
 				$settings_fields = $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$type]['obj']->get_admin_settings_fields();
2829
-				if ( !empty( $settings_fields ) ) {
2829
+				if ( ! empty($settings_fields)) {
2830 2830
 					//we have fields for this message type so let's get the defaults for saving.
2831
-					foreach ( $settings_fields as $field => $values ) {
2831
+					foreach ($settings_fields as $field => $values) {
2832 2832
 						$settings[$field] = $values['default'];
2833 2833
 					}
2834 2834
 					//let's set the data for reloading this message type form in ajax
@@ -2836,9 +2836,9 @@  discard block
 block discarded – undo
2836 2836
 				} else {
2837 2837
 					$settings = array();
2838 2838
 				}
2839
-				$this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$type]['settings'] =  $settings;
2839
+				$this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$type]['settings'] = $settings;
2840 2840
 
2841
-				if ( ! in_array( $type, $has_activated[$messenger] ) ) {
2841
+				if ( ! in_array($type, $has_activated[$messenger])) {
2842 2842
 					$has_activated[$messenger][] = $type;
2843 2843
 				}
2844 2844
 			}
@@ -2846,41 +2846,41 @@  discard block
 block discarded – undo
2846 2846
 			//any default settings for the messenger?
2847 2847
 			$msgr_settings = $this->_active_messengers[$messenger]['obj']->get_admin_settings_fields();
2848 2848
 
2849
-			if ( !empty( $msgr_settings ) ) {
2850
-				foreach ( $msgr_settings as $field => $value ) {
2849
+			if ( ! empty($msgr_settings)) {
2850
+				foreach ($msgr_settings as $field => $value) {
2851 2851
 					$this->_active_messengers[$messenger]['settings'][$field] = $value;
2852 2852
 				}
2853 2853
 			}
2854 2854
 
2855 2855
 			//update settings in database
2856
-			EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2857
-			update_option( 'ee_has_activated_messages', $has_activated );
2856
+			EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2857
+			update_option('ee_has_activated_messages', $has_activated);
2858 2858
 
2859 2859
 
2860 2860
 			//generate new templates (if necessary)
2861
-			$templates = $this->_generate_new_templates( $messenger, $default_types, 0, true );
2861
+			$templates = $this->_generate_new_templates($messenger, $default_types, 0, true);
2862 2862
 
2863 2863
 			EE_Error::overwrite_success();
2864 2864
 
2865 2865
 			//if generation failed then we need to remove the active messenger.
2866
-			if ( !$templates ) {
2866
+			if ( ! $templates) {
2867 2867
 				unset($this->_active_messengers[$messenger]);
2868
-				EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2868
+				EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2869 2869
 			} else {
2870 2870
 				//all is good let's do a success message
2871
-				if ( $message_type ) {
2872
-					EE_Error::add_success( sprintf( __('%s message type has been successfully activated with the %s messenger', 'event_espresso'),ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords( $this->_active_messengers[$messenger]['obj']->label['singular'] ) ) );
2871
+				if ($message_type) {
2872
+					EE_Error::add_success(sprintf(__('%s message type has been successfully activated with the %s messenger', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords($this->_active_messengers[$messenger]['obj']->label['singular'])));
2873 2873
 
2874 2874
 					//if message type was invoice then let's make sure we activate the invoice payment method.
2875
-					if ( $message_type == 'invoice' ) {
2876
-						EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
2877
-						$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
2878
-						if ( $pm instanceof EE_Payment_Method ) {
2879
-							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' ) );
2875
+					if ($message_type == 'invoice') {
2876
+						EE_Registry::instance()->load_lib('Payment_Method_Manager');
2877
+						$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
2878
+						if ($pm instanceof EE_Payment_Method) {
2879
+							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'));
2880 2880
 						}
2881 2881
 					}
2882 2882
 				} else {
2883
-					EE_Error::add_success( sprintf( __('%s messenger has been successfully activated', 'event_espresso'), ucwords( $this->_active_messengers[$messenger]['obj']->label['singular'] ) ) );
2883
+					EE_Error::add_success(sprintf(__('%s messenger has been successfully activated', 'event_espresso'), ucwords($this->_active_messengers[$messenger]['obj']->label['singular'])));
2884 2884
 				}
2885 2885
 			}
2886 2886
 
@@ -2896,36 +2896,36 @@  discard block
 block discarded – undo
2896 2896
 			$update_array = array(
2897 2897
 				'MTP_messenger' => $messenger);
2898 2898
 
2899
-			if ( $message_type ) {
2899
+			if ($message_type) {
2900 2900
 				$update_array['MTP_message_type'] = $message_type;
2901 2901
 			}
2902 2902
 
2903
-			$success = $MTP->update( array( 'MTP_is_active' => 0 ), array($update_array) );
2903
+			$success = $MTP->update(array('MTP_is_active' => 0), array($update_array));
2904 2904
 
2905 2905
 			$messenger_obj = $this->_active_messengers[$messenger]['obj'];
2906 2906
 
2907 2907
 			//if this is a message type deactivation then we're only unsetting the message type otherwise unset the messenger
2908
-			if ( $message_type ) {
2909
-				unset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] );
2908
+			if ($message_type) {
2909
+				unset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type]);
2910 2910
 			} else {
2911
-				unset( $this->_active_messengers[$messenger] );
2911
+				unset($this->_active_messengers[$messenger]);
2912 2912
 			}
2913 2913
 
2914
-			EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2914
+			EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2915 2915
 			EE_Error::overwrite_success();
2916
-			if ( $message_type ) {
2917
-				EE_Error::add_success( sprintf( __('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular']) ) );
2916
+			if ($message_type) {
2917
+				EE_Error::add_success(sprintf(__('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular'])));
2918 2918
 			} else {
2919
-				EE_Error::add_success( sprintf( __('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'] ) ) );
2919
+				EE_Error::add_success(sprintf(__('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'])));
2920 2920
 			}
2921 2921
 
2922 2922
 			//if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
2923
-			if ( $messenger == 'html'  || $message_type == 'invoice') {
2924
-				EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
2925
-				$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' );
2926
-				if ( $count_updated > 0 ) {
2927
-					$msg = $message_type == 'invoice' ? __('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 vist the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ) : __('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' );
2928
-					EE_Error::add_attention( $msg );
2923
+			if ($messenger == 'html' || $message_type == 'invoice') {
2924
+				EE_Registry::instance()->load_lib('Payment_Method_Manager');
2925
+				$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
2926
+				if ($count_updated > 0) {
2927
+					$msg = $message_type == 'invoice' ? __('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 vist the payment methods admin page to reactivate the invoice payment method.', 'event_espresso') : __('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');
2928
+					EE_Error::add_attention($msg);
2929 2929
 				}
2930 2930
 			}
2931 2931
 
@@ -2942,8 +2942,8 @@  discard block
 block discarded – undo
2942 2942
 	 * @return string html data
2943 2943
 	 */
2944 2944
 	public function update_mt_form() {
2945
-		if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) {
2946
-			EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ );
2945
+		if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) {
2946
+			EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__);
2947 2947
 			$this->_return_json();
2948 2948
 		}
2949 2949
 
@@ -2952,7 +2952,7 @@  discard block
 block discarded – undo
2952 2952
 		$message_type = $message_types[$this->_req_data['message_type']]['obj'];
2953 2953
 		$messenger = $this->_active_messengers[$this->_req_data['messenger']]['obj'];
2954 2954
 
2955
-		$content = $this->_message_type_settings_content ( $message_type, $messenger, true, true );
2955
+		$content = $this->_message_type_settings_content($message_type, $messenger, true, true);
2956 2956
 		$this->_template_args['success'] = true;
2957 2957
 		$this->_template_args['content'] = $content;
2958 2958
 		$this->_return_json();
@@ -2966,36 +2966,36 @@  discard block
 block discarded – undo
2966 2966
 	 * @return json success or fail message
2967 2967
 	 */
2968 2968
 	public function save_settings() {
2969
-		if ( !isset( $this->_req_data['type'] ) ) {
2970
-			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2969
+		if ( ! isset($this->_req_data['type'])) {
2970
+			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2971 2971
 			$this->_template_args['error'] = true;
2972 2972
 			$this->_return_json();
2973 2973
 		}
2974 2974
 
2975 2975
 
2976
-		if ( $this->_req_data['type'] == 'messenger' ) {
2976
+		if ($this->_req_data['type'] == 'messenger') {
2977 2977
 			$settings = $this->_req_data['messenger_settings']; //this should be an array.
2978 2978
 			$messenger = $settings['messenger'];
2979 2979
 			//let's setup the settings data
2980
-			foreach ( $settings as $key => $value ) {
2981
-				switch ( $key ) {
2980
+			foreach ($settings as $key => $value) {
2981
+				switch ($key) {
2982 2982
 					case 'messenger' :
2983
-						unset( $settings['messenger'] );
2983
+						unset($settings['messenger']);
2984 2984
 						break;
2985 2985
 					case 'message_types' :
2986
-						if ( isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] ) ) {
2987
-							foreach ( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] as $mt => $v ) {
2988
-								if ( isset( $settings['message_types'][$mt] ) )
2989
-									{$settings[$messenger . '-message_types'][$mt]['settings'] = isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) ? $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] : array();}
2986
+						if (isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'])) {
2987
+							foreach ($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'] as $mt => $v) {
2988
+								if (isset($settings['message_types'][$mt]))
2989
+									{$settings[$messenger.'-message_types'][$mt]['settings'] = isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) ? $this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt] : array(); }
2990 2990
 							}
2991 2991
 						} else {
2992
-							foreach ( $value as $mt => $v ) {
2992
+							foreach ($value as $mt => $v) {
2993 2993
 								//let's see if this message type is already present and has settings.
2994
-								$settings[$messenger . '-message_types'][$mt]['settings'] = array();
2994
+								$settings[$messenger.'-message_types'][$mt]['settings'] = array();
2995 2995
 							}
2996 2996
 						}
2997 2997
 						//k settings are set let's get rid of the message types index
2998
-						unset( $settings['message_types'] );
2998
+						unset($settings['message_types']);
2999 2999
 						break;
3000 3000
 					default :
3001 3001
 						$settings[$key] = $value;
@@ -3005,36 +3005,36 @@  discard block
 block discarded – undo
3005 3005
 			$this->_active_messengers[$messenger]['settings'] = $settings;
3006 3006
 		}
3007 3007
 
3008
-		else if ( $this->_req_data['type'] == 'message_type' ) {
3008
+		else if ($this->_req_data['type'] == 'message_type') {
3009 3009
 			$settings = $this->_req_data['message_type_settings'];
3010 3010
 			$messenger = $settings['messenger'];
3011 3011
 			$message_type = $settings['message_type'];
3012 3012
 
3013
-			foreach ( $settings as $key => $value ) {
3014
-				switch ( $key ) {
3013
+			foreach ($settings as $key => $value) {
3014
+				switch ($key) {
3015 3015
 					case 'messenger' :
3016
-						unset( $settings['messenger'] );
3016
+						unset($settings['messenger']);
3017 3017
 						break;
3018 3018
 					case 'message_type' :
3019
-						unset( $settings['message_type'] );
3019
+						unset($settings['message_type']);
3020 3020
 						break;
3021 3021
 					default :
3022 3022
 						$settings['settings'][$key] = $value;
3023
-						unset( $settings[$key] );
3023
+						unset($settings[$key]);
3024 3024
 						break;
3025 3025
 				}
3026 3026
 			}
3027 3027
 
3028
-			$this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] = $settings;
3028
+			$this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type] = $settings;
3029 3029
 		}
3030 3030
 
3031 3031
 		//okay we should have the data all setup.  Now we just update!
3032
-		$success = EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
3032
+		$success = EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
3033 3033
 
3034
-		if ( $success ) {
3035
-			EE_Error::add_success( __('Settings updated', 'event_espresso') );
3034
+		if ($success) {
3035
+			EE_Error::add_success(__('Settings updated', 'event_espresso'));
3036 3036
 		} else {
3037
-			EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
3037
+			EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
3038 3038
 		}
3039 3039
 
3040 3040
 		$this->_template_args['success'] = $success;
@@ -3056,8 +3056,8 @@  discard block
 block discarded – undo
3056 3056
      */
3057 3057
 	protected function _generate_now() {
3058 3058
 		$msg_ids = $this->_get_msg_ids_from_request();
3059
-		EED_Messages::generate_now( $msg_ids );
3060
-		$this->_redirect_after_action( false, '', '', array(), true );
3059
+		EED_Messages::generate_now($msg_ids);
3060
+		$this->_redirect_after_action(false, '', '', array(), true);
3061 3061
 	}
3062 3062
 
3063 3063
 
@@ -3072,7 +3072,7 @@  discard block
 block discarded – undo
3072 3072
 	protected function _generate_and_send_now() {
3073 3073
 		$this->_generate_now();
3074 3074
 		$this->_send_now();
3075
-		$this->_redirect_after_action( false, '', '', array(), true );
3075
+		$this->_redirect_after_action(false, '', '', array(), true);
3076 3076
 	}
3077 3077
 
3078 3078
 
@@ -3086,8 +3086,8 @@  discard block
 block discarded – undo
3086 3086
      */
3087 3087
 	protected function _queue_for_resending() {
3088 3088
 		$msg_ids = $this->_get_msg_ids_from_request();
3089
-		EED_Messages::queue_for_resending( $msg_ids );
3090
-		$this->_redirect_after_action( false, '', '', array(), true );
3089
+		EED_Messages::queue_for_resending($msg_ids);
3090
+		$this->_redirect_after_action(false, '', '', array(), true);
3091 3091
 	}
3092 3092
 
3093 3093
 
@@ -3100,8 +3100,8 @@  discard block
 block discarded – undo
3100 3100
      */
3101 3101
 	protected function _send_now() {
3102 3102
 		$msg_ids = $this->_get_msg_ids_from_request();
3103
-		EED_Messages::send_now( $msg_ids );
3104
-		$this->_redirect_after_action( false, '', '', array(), true );
3103
+		EED_Messages::send_now($msg_ids);
3104
+		$this->_redirect_after_action(false, '', '', array(), true);
3105 3105
 	}
3106 3106
 
3107 3107
 
@@ -3115,23 +3115,23 @@  discard block
 block discarded – undo
3115 3115
 	protected function _delete_ee_messages() {
3116 3116
 		$msg_ids = $this->_get_msg_ids_from_request();
3117 3117
 		$deleted_count = 0;
3118
-		foreach ( $msg_ids as $msg_id ) {
3119
-			if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) {
3118
+		foreach ($msg_ids as $msg_id) {
3119
+			if (EEM_Message::instance()->delete_by_ID($msg_id)) {
3120 3120
 				$deleted_count++;
3121 3121
 			}
3122 3122
 		}
3123
-		if ( $deleted_count ) {
3123
+		if ($deleted_count) {
3124 3124
 			$this->_redirect_after_action(
3125 3125
 				true,
3126
-				_n( 'message', 'messages', $deleted_count, 'event_espresso' ),
3126
+				_n('message', 'messages', $deleted_count, 'event_espresso'),
3127 3127
 				__('deleted', 'event_espresso')
3128 3128
 			);
3129 3129
 		} else {
3130 3130
 			EE_Error::add_error(
3131
-				_n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ),
3131
+				_n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'),
3132 3132
 				__FILE__, __FUNCTION__, __LINE__
3133 3133
 			);
3134
-			$this->_redirect_after_action( false, '', '', array(), true );
3134
+			$this->_redirect_after_action(false, '', '', array(), true);
3135 3135
 		}
3136 3136
 	}
3137 3137
 
@@ -3144,10 +3144,10 @@  discard block
 block discarded – undo
3144 3144
      *  @return array
3145 3145
      */
3146 3146
 	protected function _get_msg_ids_from_request() {
3147
-		if ( ! isset( $this->_req_data['MSG_ID'] ) ) {
3147
+		if ( ! isset($this->_req_data['MSG_ID'])) {
3148 3148
 			return array();
3149 3149
 		}
3150
-		return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] );
3150
+		return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']);
3151 3151
 	}
3152 3152
 
3153 3153
 
Please login to merge, or discard this patch.
admin_pages/messages/EE_Message_List_Table.class.php 1 patch
Spacing   +110 added lines, -110 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
 /**
@@ -15,8 +15,8 @@  discard block
 block discarded – undo
15 15
 class EE_Message_List_Table extends EE_Admin_List_Table {
16 16
 
17 17
 	protected function _setup_data() {
18
-		$this->_data = $this->_get_messages( $this->_per_page, $this->_view );
19
-		$this->_all_data_count = $this->_get_messages( $this->_per_page, $this->_view, true );
18
+		$this->_data = $this->_get_messages($this->_per_page, $this->_view);
19
+		$this->_all_data_count = $this->_get_messages($this->_per_page, $this->_view, true);
20 20
 	}
21 21
 
22 22
 
@@ -24,8 +24,8 @@  discard block
 block discarded – undo
24 24
 
25 25
 	protected function _set_properties() {
26 26
 		$this->_wp_list_args = array(
27
-			'singular' => __( 'Message', 'event_espresso' ),
28
-			'plural' => __( 'Messages', 'event_espresso' ),
27
+			'singular' => __('Message', 'event_espresso'),
28
+			'plural' => __('Messages', 'event_espresso'),
29 29
 			'ajax' => true,
30 30
 			'screen' => $this->_admin_page->get_current_screen()->id
31 31
 		);
@@ -33,24 +33,24 @@  discard block
 block discarded – undo
33 33
 		$this->_columns = array(
34 34
 			'msg_status' => '',
35 35
 			'cb' => '<input type="checkbox" />',
36
-			'msg_id' => __( 'ID', 'event_espresso' ),
37
-			'to' => __( 'To', 'event_espresso' ),
38
-			'from' => __( 'From', 'event_espresso' ),
39
-			'messenger' => __( 'Messenger', 'event_espresso' ),
40
-			'message_type' => __( 'Message Type', 'event_espresso' ),
41
-			'context' => __( 'Context', 'event_espresso' ),
42
-			'modified' => __( 'Modified', 'event_espresso' ),
43
-			'action' => __( 'Actions', 'event_espresso' )
36
+			'msg_id' => __('ID', 'event_espresso'),
37
+			'to' => __('To', 'event_espresso'),
38
+			'from' => __('From', 'event_espresso'),
39
+			'messenger' => __('Messenger', 'event_espresso'),
40
+			'message_type' => __('Message Type', 'event_espresso'),
41
+			'context' => __('Context', 'event_espresso'),
42
+			'modified' => __('Modified', 'event_espresso'),
43
+			'action' => __('Actions', 'event_espresso')
44 44
 		);
45 45
 
46 46
 		$this->_sortable_columns = array(
47
-			'modified' => array( 'MSG_modified' => true ),
48
-			'msg_id' => array( 'MSG_ID', false ),
49
-			'message_type' => array( 'MSG_message_type' => false ),
50
-			'messenger' => array( 'MSG_messenger' => false ),
51
-			'to' => array( 'MSG_to' => false ),
52
-			'from' => array( 'MSG_from' => false ),
53
-			'context' => array( 'MSG_context' => false )
47
+			'modified' => array('MSG_modified' => true),
48
+			'msg_id' => array('MSG_ID', false),
49
+			'message_type' => array('MSG_message_type' => false),
50
+			'messenger' => array('MSG_messenger' => false),
51
+			'to' => array('MSG_to' => false),
52
+			'from' => array('MSG_from' => false),
53
+			'context' => array('MSG_context' => false)
54 54
 		);
55 55
 
56 56
 		$this->_hidden_columns = array(
@@ -62,96 +62,96 @@  discard block
 block discarded – undo
62 62
 
63 63
 	protected function _get_table_filters() {
64 64
 		$filters = array();
65
-		EE_Registry::instance()->load_helper( 'Form_Fields' );
65
+		EE_Registry::instance()->load_helper('Form_Fields');
66 66
 		/** @type EE_Messages $messages_controller */
67
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
67
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
68 68
 		$messengers = $this->_admin_page->get_active_messengers();
69 69
 		$message_types = $this->_admin_page->get_installed_message_types();
70 70
 		$contexts = $messages_controller->get_all_contexts();
71 71
 
72 72
 		//setup messengers for selects
73 73
 		$i = 1;
74
-		foreach ( $messengers as $messenger => $args ) {
75
-			$m_values[ $i ]['id'] = $messenger;
76
-			$m_values[ $i ]['text'] = ucwords( $args['obj']->label['singular'] );
74
+		foreach ($messengers as $messenger => $args) {
75
+			$m_values[$i]['id'] = $messenger;
76
+			$m_values[$i]['text'] = ucwords($args['obj']->label['singular']);
77 77
 			$i++;
78 78
 		}
79 79
 
80 80
 		//lets do the same for message types
81 81
 		$i = 1;
82
-		foreach ( $message_types as $message_type => $args ) {
83
-			$mt_values[ $i ]['id'] = $message_type;
84
-			$mt_values[ $i ]['text'] = ucwords( $args['obj']->label['singular'] );
82
+		foreach ($message_types as $message_type => $args) {
83
+			$mt_values[$i]['id'] = $message_type;
84
+			$mt_values[$i]['text'] = ucwords($args['obj']->label['singular']);
85 85
 			$i++;
86 86
 		}
87 87
 
88 88
 		//and the same for contexts
89 89
 		$i = 1;
90 90
 		$labels = $c_values = array();
91
-		foreach ( $contexts as $context => $label ) {
91
+		foreach ($contexts as $context => $label) {
92 92
 			//some message types may have the same label for a different context, so we're grouping these together so the end user
93 93
 			//doesn't get confused.
94
-			if ( isset( $labels[ $label ] ) ) {
95
-				$c_values[ $labels[ $label ] ]['id'] .= ',' . $context;
94
+			if (isset($labels[$label])) {
95
+				$c_values[$labels[$label]]['id'] .= ','.$context;
96 96
 				continue;
97 97
 			}
98
-			$c_values[ $i ]['id'] = $context;
99
-			$c_values[ $i ]['text'] = $label;
100
-			$labels[ $label ] = $i;
98
+			$c_values[$i]['id'] = $context;
99
+			$c_values[$i]['text'] = $label;
100
+			$labels[$label] = $i;
101 101
 			$i++;
102 102
 		}
103 103
 
104 104
 		$msgr_default[0] = array(
105 105
 			'id' => 'none_selected',
106
-			'text' => __( 'All Messengers', 'event_espresso' )
106
+			'text' => __('All Messengers', 'event_espresso')
107 107
 		);
108 108
 
109 109
 		$mt_default[0] = array(
110 110
 			'id' => 'none_selected',
111
-			'text' => __( 'All Message Types', 'event_espresso' )
111
+			'text' => __('All Message Types', 'event_espresso')
112 112
 		);
113 113
 
114 114
 		$c_default[0] = array(
115 115
 			'id' => 'none_selected',
116
-			'text' => __( 'All Contexts', 'event_espresso ' )
116
+			'text' => __('All Contexts', 'event_espresso ')
117 117
 		);
118 118
 
119
-		$msgr_filters = ! empty( $m_values ) ? array_merge( $msgr_default, $m_values ) : array();
120
-		$mt_filters = ! empty( $mt_values ) ? array_merge( $mt_default, $mt_values ) : array();
121
-		$c_filters = ! empty( $c_values ) ? array_merge( $c_default, $c_values ): array();
119
+		$msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array();
120
+		$mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array();
121
+		$c_filters = ! empty($c_values) ? array_merge($c_default, $c_values) : array();
122 122
 
123
-		if ( empty( $m_values ) ) {
123
+		if (empty($m_values)) {
124 124
 			$msgr_filters[0] = array(
125 125
 				'id'   => 'none_selected',
126
-				'text' => __( 'No Messengers active', 'event_espresso' )
126
+				'text' => __('No Messengers active', 'event_espresso')
127 127
 			);
128 128
 		}
129 129
 
130
-		if ( empty( $mt_values ) ) {
130
+		if (empty($mt_values)) {
131 131
 			$mt_filters[0] = array(
132 132
 				'id'   => 'none_selected',
133
-				'text' => __( 'No Message Types active', 'event_espresso' )
133
+				'text' => __('No Message Types active', 'event_espresso')
134 134
 			);
135 135
 		}
136 136
 
137
-		if ( empty( $c_values ) ) {
137
+		if (empty($c_values)) {
138 138
 			$c_filters[0] = array(
139 139
 				'id'   => 'none_selected',
140
-				'text' => __( 'No Contexts (because no message types active)', 'event_espresso' )
140
+				'text' => __('No Contexts (because no message types active)', 'event_espresso')
141 141
 			);
142 142
 		}
143 143
 
144
-		$filters[] = EEH_Form_Fields::select_input( 'ee_messenger_filter_by', $msgr_filters, isset( $this->_req_data['ee_messenger_filter_by'] ) ? sanitize_title( $this->_req_data['ee_messenger_filter_by'] ) : '' );
145
-		$filters[] = EEH_Form_Fields::select_input( 'ee_message_type_filter_by', $mt_filters, isset( $this->_req_data['ee_message_type_filter_by'] ) ? sanitize_title( $this->_req_data['ee_message_type_filter_by'] ) : '' );
146
-		$filters[] = EEH_Form_Fields::select_input( 'ee_context_filter_by', $c_filters, isset( $this->_req_data['ee_context_filter_by'] ) ? sanitize_text_field( $this->_req_data['ee_context_filter_by'] ) : '' );
144
+		$filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_title($this->_req_data['ee_messenger_filter_by']) : '');
145
+		$filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_title($this->_req_data['ee_message_type_filter_by']) : '');
146
+		$filters[] = EEH_Form_Fields::select_input('ee_context_filter_by', $c_filters, isset($this->_req_data['ee_context_filter_by']) ? sanitize_text_field($this->_req_data['ee_context_filter_by']) : '');
147 147
 		return $filters;
148 148
 	}
149 149
 
150 150
 
151 151
 
152 152
 	protected function _add_view_counts() {
153
-		foreach ( $this->_views as $view => $args ) {
154
-			$this->_views[ $view ]['count'] = $this->_get_messages( $this->_per_page, $view, true, true );
153
+		foreach ($this->_views as $view => $args) {
154
+			$this->_views[$view]['count'] = $this->_get_messages($this->_per_page, $view, true, true);
155 155
 		}
156 156
 	}
157 157
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	 *
162 162
 	 * @return string    EE_Message status.
163 163
 	 */
164
-	public function column_msg_status( $message ) {
165
-		return '<span class="ee-status-strip ee-status-strip-td msg-status-' . $message->STS_ID() . '"></span>';
164
+	public function column_msg_status($message) {
165
+		return '<span class="ee-status-strip ee-status-strip-td msg-status-'.$message->STS_ID().'"></span>';
166 166
 	}
167 167
 
168 168
 
@@ -171,14 +171,14 @@  discard block
 block discarded – undo
171 171
 	 *
172 172
 	 * @return string   checkbox
173 173
 	 */
174
-	public function column_cb( $message ) {
175
-		return sprintf( '<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID() );
174
+	public function column_cb($message) {
175
+		return sprintf('<input type="checkbox" name="MSG_ID[%s]" value="1" />', $message->ID());
176 176
 	}
177 177
 
178 178
 
179 179
 
180 180
 
181
-	public function column_msg_id( $message ) {
181
+	public function column_msg_id($message) {
182 182
 		return $message->ID();
183 183
 	}
184 184
 
@@ -188,13 +188,13 @@  discard block
 block discarded – undo
188 188
 	 * @param EE_Message $message
189 189
 	 * @return string    The recipient of the message
190 190
 	 */
191
-	public function column_to( $message ) {
192
-		EE_Registry::instance()->load_helper( 'URL' );
191
+	public function column_to($message) {
192
+		EE_Registry::instance()->load_helper('URL');
193 193
 		$actions = array();
194
-		if ( $recipient_object = $message->recipient_object() ) {
194
+		if ($recipient_object = $message->recipient_object()) {
195 195
 			$view_details_link = $recipient_object instanceof EEI_Admin_Links ? $recipient_object->get_admin_details_link() : '';
196
-			if ( ! empty( $view_details_link ) ) {
197
-				$actions['view'] = '<a href="' . $view_details_link . '">' . __( 'View Recipient Details', 'event_espresso' ) . '</a>';
196
+			if ( ! empty($view_details_link)) {
197
+				$actions['view'] = '<a href="'.$view_details_link.'">'.__('View Recipient Details', 'event_espresso').'</a>';
198 198
 			}
199 199
 		}
200 200
 
@@ -205,10 +205,10 @@  discard block
 block discarded – undo
205 205
 					'action' => 'delete_ee_message',
206 206
 					'MSG_ID' => $message->ID()
207 207
 				),
208
-				admin_url( 'admin.php' )
208
+				admin_url('admin.php')
209 209
 			)
210
-			. '">' . __( 'Delete', 'event_espresso' ) . '</a>';
211
-		return $message->to() . $this->row_actions( $actions );
210
+			. '">'.__('Delete', 'event_espresso').'</a>';
211
+		return $message->to().$this->row_actions($actions);
212 212
 	}
213 213
 
214 214
 
@@ -216,7 +216,7 @@  discard block
 block discarded – undo
216 216
 	 * @param EE_Message $message
217 217
 	 * @return string   The sender of the message
218 218
 	 */
219
-	public function column_from( $message ) {
219
+	public function column_from($message) {
220 220
 		return $message->from();
221 221
 	}
222 222
 
@@ -226,8 +226,8 @@  discard block
 block discarded – undo
226 226
 	 * @param EE_Message $message
227 227
 	 * @return string  The messenger used to send the message.
228 228
 	 */
229
-	public function column_messenger( $message ) {
230
-		return ucwords( $message->messenger_label() );
229
+	public function column_messenger($message) {
230
+		return ucwords($message->messenger_label());
231 231
 	}
232 232
 
233 233
 
@@ -235,8 +235,8 @@  discard block
 block discarded – undo
235 235
 	 * @param EE_Message $message
236 236
 	 * @return string  The message type used to generate the message.
237 237
 	 */
238
-	public function column_message_type( $message ) {
239
-		return ucwords( $message->message_type_label() );
238
+	public function column_message_type($message) {
239
+		return ucwords($message->message_type_label());
240 240
 	}
241 241
 
242 242
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	 * @param EE_Message $message
245 245
 	 * @return string  The context the message was generated for.
246 246
 	 */
247
-	public function column_context( $message ) {
247
+	public function column_context($message) {
248 248
 		return $message->context_label();
249 249
 	}
250 250
 
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
 	 * @param EE_Message $message
254 254
 	 * @return string    The timestamp when this message was last modified.
255 255
 	 */
256
-	public function column_modified( $message ) {
256
+	public function column_modified($message) {
257 257
 		return $message->modified();
258 258
 	}
259 259
 
@@ -262,35 +262,35 @@  discard block
 block discarded – undo
262 262
 	 * @param EE_Message $message
263 263
 	 * @return string   Actions that can be done on the current message.
264 264
 	 */
265
-	public function column_action( $message ) {
266
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
265
+	public function column_action($message) {
266
+		EE_Registry::instance()->load_helper('MSG_Template');
267 267
 		$action_links = array(
268
-			'view' => EEH_MSG_Template::get_message_action_link( 'view', $message ),
269
-			'error' => EEH_MSG_Template::get_message_action_link( 'error', $message ),
270
-			'generate_now' => EEH_MSG_Template::get_message_action_link( 'generate_now', $message ),
271
-			'send_now' => EEH_MSG_Template::get_message_action_link( 'send_now', $message ),
272
-			'queue_for_resending' => EEH_MSG_Template::get_message_action_link( 'queue_for_resending', $message ),
273
-			'view_transaction' => EEH_MSG_Template::get_message_action_link( 'view_transaction', $message ),
268
+			'view' => EEH_MSG_Template::get_message_action_link('view', $message),
269
+			'error' => EEH_MSG_Template::get_message_action_link('error', $message),
270
+			'generate_now' => EEH_MSG_Template::get_message_action_link('generate_now', $message),
271
+			'send_now' => EEH_MSG_Template::get_message_action_link('send_now', $message),
272
+			'queue_for_resending' => EEH_MSG_Template::get_message_action_link('queue_for_resending', $message),
273
+			'view_transaction' => EEH_MSG_Template::get_message_action_link('view_transaction', $message),
274 274
 		);
275 275
 		$content = '';
276
-		switch ( $message->STS_ID() ) {
276
+		switch ($message->STS_ID()) {
277 277
 			case EEM_Message::status_sent :
278
-				$content = $action_links['view'] . $action_links['queue_for_resending'] . $action_links['view_transaction'];
278
+				$content = $action_links['view'].$action_links['queue_for_resending'].$action_links['view_transaction'];
279 279
 				break;
280 280
 			case EEM_Message::status_resend :
281
-				$content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
281
+				$content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction'];
282 282
 				break;
283 283
 			case EEM_Message::status_retry :
284
-				$content = $action_links['view'] . $action_links['send_now'] . $action_links['error'] . $action_links['view_transaction'];
284
+				$content = $action_links['view'].$action_links['send_now'].$action_links['error'].$action_links['view_transaction'];
285 285
 				break;
286 286
 			case EEM_Message::status_failed :
287
-				$content = $action_links['error'] . $action_links['view_transaction'];
287
+				$content = $action_links['error'].$action_links['view_transaction'];
288 288
 				break;
289 289
 			case EEM_Message::status_idle :
290
-				$content = $action_links['view'] . $action_links['send_now'] . $action_links['view_transaction'];
290
+				$content = $action_links['view'].$action_links['send_now'].$action_links['view_transaction'];
291 291
 				break;
292 292
 			case EEM_Message::status_incomplete;
293
-				$content = $action_links['generate_now'] . $action_links['view_transaction'];
293
+				$content = $action_links['generate_now'].$action_links['view_transaction'];
294 294
 				break;
295 295
 		}
296 296
 		return $content;
@@ -305,51 +305,51 @@  discard block
 block discarded – undo
305 305
 	 * @param bool       $all       Disregard any paging info (no limit on data returned).
306 306
 	 * @return int | EE_Message[]
307 307
 	 */
308
-	protected function _get_messages( $perpage = 10, $view = 'all', $count = false, $all = false ) {
309
-		$current_page = isset( $this->_req_data['paged'] ) && ! empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
310
-		$per_page = isset( $this->_req_data['perpage'] ) && ! empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage;
311
-		$offset = ( $current_page - 1 ) * $per_page;
312
-		$limit = $all || $count ? null : array( $offset, $per_page );
308
+	protected function _get_messages($perpage = 10, $view = 'all', $count = false, $all = false) {
309
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
310
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage;
311
+		$offset = ($current_page - 1) * $per_page;
312
+		$limit = $all || $count ? null : array($offset, $per_page);
313 313
 
314 314
 		$query_params = array(
315
-			'order_by' => empty( $this->_req_data['orderby'] ) ? 'MSG_modified' : $this->_req_data['orderby'],
316
-			'order' => empty( $this->_req_data['order'] ) ? 'DESC' : $this->_req_data['order'],
315
+			'order_by' => empty($this->_req_data['orderby']) ? 'MSG_modified' : $this->_req_data['orderby'],
316
+			'order' => empty($this->_req_data['order']) ? 'DESC' : $this->_req_data['order'],
317 317
 			'limit' => $limit,
318 318
 		);
319 319
 
320 320
 		/**
321 321
 		 * Any filters coming in from other routes?
322 322
 		 */
323
-		if ( ! $all && isset( $this->_req_data['filterby'] ) ) {
324
-			$query_params = array_merge( $query_params, EEM_Message::instance()->filter_by_query_params() );
323
+		if ( ! $all && isset($this->_req_data['filterby'])) {
324
+			$query_params = array_merge($query_params, EEM_Message::instance()->filter_by_query_params());
325 325
 		}
326 326
 
327 327
 		//view conditionals
328
-		if ( $view !== 'all' && $count && $all ) {
328
+		if ($view !== 'all' && $count && $all) {
329 329
 			$query_params[0]['AND*view_conditional'] = array(
330
-				'STS_ID' => strtoupper( $view ),
330
+				'STS_ID' => strtoupper($view),
331 331
 			);
332 332
 		}
333 333
 
334
-		if ( ! empty( $this->_req_data['status'] )  && ! $all && $this->_req_data['status'] !== 'all' ) {
334
+		if ( ! empty($this->_req_data['status']) && ! $all && $this->_req_data['status'] !== 'all') {
335 335
 			$query_params[0]['AND*view_conditional'] = array(
336
-				'STS_ID' => strtoupper( $this->_req_data['status'] ),
336
+				'STS_ID' => strtoupper($this->_req_data['status']),
337 337
 			);
338 338
 		}
339 339
 
340
-		if ( ! $all && ! empty( $this->_req_data['s'] ) ) {
341
-			$search_string = '%' . $this->_req_data['s'] . '%';
340
+		if ( ! $all && ! empty($this->_req_data['s'])) {
341
+			$search_string = '%'.$this->_req_data['s'].'%';
342 342
 			$query_params[0]['OR'] = array(
343
-				'MSG_to' => array( 'LIKE', $search_string ),
344
-				'MSG_from' => array( 'LIKE', $search_string ),
345
-				'MSG_subject' => array( 'LIKE', $search_string ),
346
-				'MSG_content' => array( 'LIKE', $search_string ),
343
+				'MSG_to' => array('LIKE', $search_string),
344
+				'MSG_from' => array('LIKE', $search_string),
345
+				'MSG_subject' => array('LIKE', $search_string),
346
+				'MSG_content' => array('LIKE', $search_string),
347 347
 			);
348 348
 		}
349 349
 
350 350
 		//account for filters
351 351
 		if ( ! $all
352
-		     && isset( $this->_req_data['ee_messenger_filter_by'] )
352
+		     && isset($this->_req_data['ee_messenger_filter_by'])
353 353
 		     && $this->_req_data['ee_messenger_filter_by'] !== 'none_selected'
354 354
 		) {
355 355
 			$query_params[0]['AND*messenger_filter'] = array(
@@ -357,7 +357,7 @@  discard block
 block discarded – undo
357 357
 			);
358 358
 		}
359 359
 		if ( ! $all
360
-		     && ! empty( $this->_req_data['ee_message_type_filter_by'] )
360
+		     && ! empty($this->_req_data['ee_message_type_filter_by'])
361 361
 			 && $this->_req_data['ee_message_type_filter_by'] !== 'none_selected'
362 362
 		) {
363 363
 			$query_params[0]['AND*message_type_filter'] = array(
@@ -366,15 +366,15 @@  discard block
 block discarded – undo
366 366
 		}
367 367
 
368 368
 		if ( ! $all
369
-		     && ! empty( $this->_req_data['ee_context_filter_by'] )
369
+		     && ! empty($this->_req_data['ee_context_filter_by'])
370 370
 		     && $this->_req_data['ee_context_filter_by'] !== 'none_selected'
371 371
 		) {
372 372
 			$query_params[0]['AND*context_filter'] = array(
373
-				'MSG_context' => array( 'IN', explode( ',', $this->_req_data['ee_context_filter_by'] ) )
373
+				'MSG_context' => array('IN', explode(',', $this->_req_data['ee_context_filter_by']))
374 374
 			);
375 375
 		}
376 376
 
377
-		return $count ? EEM_Message::instance()->count( $query_params ) : EEM_Message::instance()->get_all( $query_params );
377
+		return $count ? EEM_Message::instance()->count($query_params) : EEM_Message::instance()->get_all($query_params);
378 378
 
379 379
 	}
380 380
 } //end EE_Message_List_Table class
381 381
\ No newline at end of file
Please login to merge, or discard this patch.
modules/messages/EED_Messages.module.php 1 patch
Spacing   +177 added lines, -177 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
 	 * @return EED_Module
67 67
 	 */
68 68
 	public static function instance() {
69
-		return parent::get_instance( __CLASS__ );
69
+		return parent::get_instance(__CLASS__);
70 70
 	}
71 71
 
72 72
 
@@ -81,11 +81,11 @@  discard block
 block discarded – undo
81 81
 	 */
82 82
 	public static function set_hooks() {
83 83
 		//actions
84
-		add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 );
85
-		add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 2 );
84
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
85
+		add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 2);
86 86
 		//filters
87
-		add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 );
88
-		add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 );
87
+		add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
88
+		add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
89 89
 		//register routes
90 90
 		self::_register_routes();
91 91
 	}
@@ -98,16 +98,16 @@  discard block
 block discarded – undo
98 98
 	 */
99 99
 	public static function set_hooks_admin() {
100 100
 		//actions
101
-		add_action( 'AHEE__EE_Payment_Processor__update_txn_based_on_payment', array( 'EED_Messages', 'payment' ), 10, 2 );
102
-		add_action( 'AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array( 'EED_Messages', 'payment_reminder' ), 10 );
103
-		add_action( 'AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array( 'EED_Messages', 'maybe_registration' ), 10, 3 );
104
-		add_action( 'AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', array( 'EED_Messages', 'send_newsletter_message' ), 10, 2 );
105
-		add_action( 'AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array( 'EED_Messages', 'cancelled_registration' ), 10 );
106
-		add_action( 'AHEE__EE_Admin_Page___process_admin_payment_notification', array( 'EED_Messages', 'process_admin_payment' ), 10, 1 );
101
+		add_action('AHEE__EE_Payment_Processor__update_txn_based_on_payment', array('EED_Messages', 'payment'), 10, 2);
102
+		add_action('AHEE__Transactions_Admin_Page___send_payment_reminder__process_admin_payment_reminder', array('EED_Messages', 'payment_reminder'), 10);
103
+		add_action('AHEE__EE_Registration_Processor__trigger_registration_update_notifications', array('EED_Messages', 'maybe_registration'), 10, 3);
104
+		add_action('AHEE__Extend_Registrations_Admin_Page___newsletter_selected_send', array('EED_Messages', 'send_newsletter_message'), 10, 2);
105
+		add_action('AHEE__EES_Espresso_Cancelled__process_shortcode__transaction', array('EED_Messages', 'cancelled_registration'), 10);
106
+		add_action('AHEE__EE_Admin_Page___process_admin_payment_notification', array('EED_Messages', 'process_admin_payment'), 10, 1);
107 107
 		//filters
108
-		add_filter( 'FHEE__EE_Admin_Page___process_resend_registration__success', array( 'EED_Messages', 'process_resend' ), 10, 2 );
109
-		add_filter( 'FHEE__EE_Registration__receipt_url__receipt_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 );
110
-		add_filter( 'FHEE__EE_Registration__invoice_url__invoice_url', array( 'EED_Messages', 'registration_message_trigger_url' ), 10, 4 );
108
+		add_filter('FHEE__EE_Admin_Page___process_resend_registration__success', array('EED_Messages', 'process_resend'), 10, 2);
109
+		add_filter('FHEE__EE_Registration__receipt_url__receipt_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
110
+		add_filter('FHEE__EE_Registration__invoice_url__invoice_url', array('EED_Messages', 'registration_message_trigger_url'), 10, 4);
111 111
 	}
112 112
 
113 113
 
@@ -121,11 +121,11 @@  discard block
 block discarded – undo
121 121
 	 * @return void
122 122
 	 */
123 123
 	protected static function _register_routes() {
124
-		EE_Config::register_route( 'msg_url_trigger', 'Messages', 'run' );
125
-		EE_Config::register_route( 'msg_cron_trigger', 'Messages', 'run_cron' );
126
-		EE_Config::register_route( 'msg_browser_trigger', 'Messages', 'browser_trigger' );
127
-		EE_Config::register_route( 'msg_browser_error_trigger', 'Messages', 'browser_error_trigger' );
128
-		do_action( 'AHEE__EED_Messages___register_routes' );
124
+		EE_Config::register_route('msg_url_trigger', 'Messages', 'run');
125
+		EE_Config::register_route('msg_cron_trigger', 'Messages', 'run_cron');
126
+		EE_Config::register_route('msg_browser_trigger', 'Messages', 'browser_trigger');
127
+		EE_Config::register_route('msg_browser_error_trigger', 'Messages', 'browser_error_trigger');
128
+		do_action('AHEE__EED_Messages___register_routes');
129 129
 	}
130 130
 
131 131
 
@@ -136,18 +136,18 @@  discard block
 block discarded – undo
136 136
 	 * @since 4.9.0
137 137
 	 * @param WP $WP
138 138
 	 */
139
-	public function browser_trigger( $WP ) {
139
+	public function browser_trigger($WP) {
140 140
 		//ensure controller is loaded
141 141
 		self::_load_controller();
142
-		$token = EE_Registry::instance()->REQ->get( 'token' );
142
+		$token = EE_Registry::instance()->REQ->get('token');
143 143
 		try {
144
-			$mtg = new EE_Message_Generated_From_Token( $token, 'html', self::$_EEMSG );
145
-			self::$_MSG_PROCESSOR->generate_and_send_now( $mtg );
146
-		} catch( EE_Error $e ) {
147
-			$error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' );
144
+			$mtg = new EE_Message_Generated_From_Token($token, 'html', self::$_EEMSG);
145
+			self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
146
+		} catch (EE_Error $e) {
147
+			$error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso');
148 148
 			// add specific message for developers if WP_DEBUG in on
149
-			$error_msg .= '||' . $e->getMessage();
150
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
149
+			$error_msg .= '||'.$e->getMessage();
150
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
151 151
 		}
152 152
 	}
153 153
 
@@ -163,21 +163,21 @@  discard block
 block discarded – undo
163 163
 	 * @since 4.9.0
164 164
 	 * @param $WP
165 165
 	 */
166
-	public function browser_error_trigger( $WP ) {
167
-		$token = EE_Registry::instance()->REQ->get( 'token' );
168
-		if ( $token ) {
169
-			$message = EEM_Message::instance()->get_one_by_token( $token );
170
-			if ( $message instanceof EE_Message ) {
171
-				header( 'HTTP/1.1 200 OK' );
166
+	public function browser_error_trigger($WP) {
167
+		$token = EE_Registry::instance()->REQ->get('token');
168
+		if ($token) {
169
+			$message = EEM_Message::instance()->get_one_by_token($token);
170
+			if ($message instanceof EE_Message) {
171
+				header('HTTP/1.1 200 OK');
172 172
 				$error_msg = $message->error_message();
173 173
 				?>
174 174
 				<!DOCTYPE html>
175 175
 				<html>
176 176
 					<head></head>
177 177
 					<body>
178
-						<?php echo empty( $error_msg )
179
-						? esc_html__( 'Unfortunately, we were unable to capture the error message for this message.', 'event_espresso' )
180
-						: wp_kses( $error_msg, array( 'a', 'span', 'div', 'p', 'strong', 'em', 'br' ) ); ?>
178
+						<?php echo empty($error_msg)
179
+						? esc_html__('Unfortunately, we were unable to capture the error message for this message.', 'event_espresso')
180
+						: wp_kses($error_msg, array('a', 'span', 'div', 'p', 'strong', 'em', 'br')); ?>
181 181
 					</body>
182 182
 				</html>
183 183
 				<?php
@@ -197,18 +197,18 @@  discard block
 block discarded – undo
197 197
 	 * @throws EE_Error
198 198
 	 * @return    void
199 199
 	 */
200
-	public function run( $WP ) {
200
+	public function run($WP) {
201 201
 		//ensure controller is loaded
202 202
 		self::_load_controller();
203 203
 		// attempt to process message
204 204
 		try {
205
-			$mtg = new EE_Message_To_Generate_From_Request( self::$_EEMSG, EE_Registry::instance()->REQ );
206
-			self::$_MSG_PROCESSOR->generate_and_send_now( $mtg );
207
-		} catch ( EE_Error $e ) {
208
-			$error_msg = __( 'Please note that a system message failed to send due to a technical issue.', 'event_espresso' );
205
+			$mtg = new EE_Message_To_Generate_From_Request(self::$_EEMSG, EE_Registry::instance()->REQ);
206
+			self::$_MSG_PROCESSOR->generate_and_send_now($mtg);
207
+		} catch (EE_Error $e) {
208
+			$error_msg = __('Please note that a system message failed to send due to a technical issue.', 'event_espresso');
209 209
 			// add specific message for developers if WP_DEBUG in on
210
-			$error_msg .= '||' . $e->getMessage();
211
-			EE_Error::add_error( $error_msg, __FILE__, __FUNCTION__, __LINE__ );
210
+			$error_msg .= '||'.$e->getMessage();
211
+			EE_Error::add_error($error_msg, __FILE__, __FUNCTION__, __LINE__);
212 212
 		}
213 213
 	}
214 214
 
@@ -217,30 +217,30 @@  discard block
 block discarded – undo
217 217
 	 * This is triggered by the 'msg_cron_trigger' route.
218 218
 	 * @param WP $WP
219 219
 	 */
220
-	public function run_cron( $WP ) {
220
+	public function run_cron($WP) {
221 221
 		self::_load_controller();
222 222
 		//get required vars
223
-		$cron_type = EE_Registry::instance()->REQ->get( 'type' );
224
-		$nonce = EE_Registry::instance()->REQ->get( '_nonce' );
225
-		header( 'HTTP/1.1 200 OK' );
223
+		$cron_type = EE_Registry::instance()->REQ->get('type');
224
+		$nonce = EE_Registry::instance()->REQ->get('_nonce');
225
+		header('HTTP/1.1 200 OK');
226 226
 
227 227
 		//now let's verify nonce, if not valid exit immediately
228
-		if ( ! wp_verify_nonce( $nonce, 'EE_Messages_Scheduler_' . $cron_type ) ) {
228
+		if ( ! wp_verify_nonce($nonce, 'EE_Messages_Scheduler_'.$cron_type)) {
229 229
 			/**
230 230
 			 * trigger error so this gets in the error logs.  This is important because it happens on a non-user request.
231 231
 			 */
232
-			trigger_error( esc_attr__( 'Invalid Nonce', 'event_espresso' ) );
232
+			trigger_error(esc_attr__('Invalid Nonce', 'event_espresso'));
233 233
 		}
234 234
 
235
-		$method = 'batch_' . $cron_type . '_from_queue';
236
-		if ( method_exists( self::$_MSG_PROCESSOR, $method ) ) {
235
+		$method = 'batch_'.$cron_type.'_from_queue';
236
+		if (method_exists(self::$_MSG_PROCESSOR, $method)) {
237 237
 			self::$_MSG_PROCESSOR->$method();
238 238
 		} else {
239 239
 			//no matching task
240 240
 			/**
241 241
 			 * trigger error so this gets in the error logs.  This is important because it happens on a non user request.
242 242
 			 */
243
-			trigger_error( esc_attr( sprintf( __( 'There is no task corresponding to this route %s', 'event_espresso' ), $cron_type ) ) );
243
+			trigger_error(esc_attr(sprintf(__('There is no task corresponding to this route %s', 'event_espresso'), $cron_type)));
244 244
 		}
245 245
 		exit();
246 246
 	}
@@ -258,9 +258,9 @@  discard block
 block discarded – undo
258 258
 	 *
259 259
 	 * @return EE_Messages_Template_Pack
260 260
 	 */
261
-	public static function get_template_pack( $template_pack_name ) {
262
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
263
-		return EEH_MSG_Template::get_template_pack( $template_pack_name );
261
+	public static function get_template_pack($template_pack_name) {
262
+		EE_Registry::instance()->load_helper('MSG_Template');
263
+		return EEH_MSG_Template::get_template_pack($template_pack_name);
264 264
 	}
265 265
 
266 266
 
@@ -274,14 +274,14 @@  discard block
 block discarded – undo
274 274
 	 * @return EE_Messages_Template_Pack[]
275 275
 	 */
276 276
 	public static function get_template_packs() {
277
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
277
+		EE_Registry::instance()->load_helper('MSG_Template');
278 278
 
279 279
 		//for backward compat, let's make sure this returns in the same format as originally.
280 280
 		$template_pack_collection = EEH_MSG_Template::get_template_pack_collection();
281 281
 		$template_pack_collection->rewind();
282 282
 		$template_packs = array();
283
-		while ( $template_pack_collection->valid() ) {
284
-			$template_packs[ $template_pack_collection->current()->dbref ] = $template_pack_collection->current();
283
+		while ($template_pack_collection->valid()) {
284
+			$template_packs[$template_pack_collection->current()->dbref] = $template_pack_collection->current();
285 285
 			$template_pack_collection->next();
286 286
 		}
287 287
 		return $template_packs;
@@ -297,16 +297,16 @@  discard block
 block discarded – undo
297 297
 	 * @return void
298 298
 	 */
299 299
 	public static function set_autoloaders() {
300
-		if ( empty( self::$_MSG_PATHS ) ) {
300
+		if (empty(self::$_MSG_PATHS)) {
301 301
 			self::_set_messages_paths();
302
-			EE_Registry::instance()->load_helper( 'Autoloader' );
303
-			foreach ( self::$_MSG_PATHS as $path ) {
304
-				EEH_Autoloader::register_autoloaders_for_each_file_in_folder( $path );
302
+			EE_Registry::instance()->load_helper('Autoloader');
303
+			foreach (self::$_MSG_PATHS as $path) {
304
+				EEH_Autoloader::register_autoloaders_for_each_file_in_folder($path);
305 305
 			}
306 306
 		}
307 307
 		// add aliases
308
-		EEH_Autoloader::add_alias( 'EE_messages', 'EE_Messages');
309
-		EEH_Autoloader::add_alias( 'EE_messenger', 'EE_Messenger');
308
+		EEH_Autoloader::add_alias('EE_messages', 'EE_Messages');
309
+		EEH_Autoloader::add_alias('EE_messenger', 'EE_Messenger');
310 310
 	}
311 311
 
312 312
 
@@ -334,10 +334,10 @@  discard block
 block discarded – undo
334 334
 			'shortcodes',
335 335
 			);
336 336
 		$paths = array();
337
-		foreach ( $dir_ref as $index => $dir ) {
338
-			$paths[ $index ] = EE_LIBRARIES . $dir;
337
+		foreach ($dir_ref as $index => $dir) {
338
+			$paths[$index] = EE_LIBRARIES.$dir;
339 339
 		}
340
-		self::$_MSG_PATHS = apply_filters( 'FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths );
340
+		self::$_MSG_PATHS = apply_filters('FHEE__EED_Messages___set_messages_paths___MSG_PATHS', $paths);
341 341
 	}
342 342
 
343 343
 
@@ -349,11 +349,11 @@  discard block
 block discarded – undo
349 349
 	 * @return void
350 350
 	 */
351 351
 	protected static function _load_controller() {
352
-		if ( ! self::$_EEMSG instanceof EE_Messages ) {
353
-			EE_Registry::instance()->load_core( 'Request_Handler' );
352
+		if ( ! self::$_EEMSG instanceof EE_Messages) {
353
+			EE_Registry::instance()->load_core('Request_Handler');
354 354
 			self::set_autoloaders();
355
-			self::$_EEMSG = EE_Registry::instance()->load_lib( 'messages' );
356
-			self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib( 'Messages_Processor', self::$_EEMSG );
355
+			self::$_EEMSG = EE_Registry::instance()->load_lib('messages');
356
+			self::$_MSG_PROCESSOR = EE_Registry::instance()->load_lib('Messages_Processor', self::$_EEMSG);
357 357
 		}
358 358
 	}
359 359
 
@@ -362,10 +362,10 @@  discard block
 block discarded – undo
362 362
 	/**
363 363
 	 * @param EE_Transaction $transaction
364 364
 	 */
365
-	public static function payment_reminder( EE_Transaction $transaction ) {
365
+	public static function payment_reminder(EE_Transaction $transaction) {
366 366
 		self::_load_controller();
367
-		$data = array( $transaction, null );
368
-		self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'payment_reminder', $data );
367
+		$data = array($transaction, null);
368
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('payment_reminder', $data);
369 369
 	}
370 370
 
371 371
 
@@ -376,14 +376,14 @@  discard block
 block discarded – undo
376 376
 	 * @param  EE_Payment object
377 377
 	 * @return void
378 378
 	 */
379
-	public static function payment( EE_Transaction $transaction, EE_Payment $payment ) {
379
+	public static function payment(EE_Transaction $transaction, EE_Payment $payment) {
380 380
 		self::_load_controller();
381
-		$data = array( $transaction, $payment );
382
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
383
-		$message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() );
381
+		$data = array($transaction, $payment);
382
+		EE_Registry::instance()->load_helper('MSG_Template');
383
+		$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
384 384
 		//if payment amount is less than 0 then switch to payment_refund message type.
385 385
 		$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
386
-		self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data );
386
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
387 387
 	}
388 388
 
389 389
 
@@ -391,10 +391,10 @@  discard block
 block discarded – undo
391 391
 	/**
392 392
 	 * @param EE_Transaction $transaction
393 393
 	 */
394
-	public static function cancelled_registration( EE_Transaction $transaction ) {
394
+	public static function cancelled_registration(EE_Transaction $transaction) {
395 395
 		self::_load_controller();
396
-		$data = array( $transaction, null );
397
-		self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'cancelled_registration', $data );
396
+		$data = array($transaction, null);
397
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('cancelled_registration', $data);
398 398
 	}
399 399
 
400 400
 
@@ -407,14 +407,14 @@  discard block
 block discarded – undo
407 407
 	 * @param array $extra_details
408 408
 	 * @return void
409 409
 	 */
410
-	public static function maybe_registration( EE_Registration $registration, $extra_details = array() ) {
410
+	public static function maybe_registration(EE_Registration $registration, $extra_details = array()) {
411 411
 
412
-		if ( ! self::_verify_registration_notification_send( $registration, $extra_details ) ) {
412
+		if ( ! self::_verify_registration_notification_send($registration, $extra_details)) {
413 413
 			//no messages please
414 414
 			return;
415 415
 		}
416 416
 
417
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
417
+		EE_Registry::instance()->load_helper('MSG_Template');
418 418
 
419 419
 		//get all registrations so we make sure we send messages for the right status.
420 420
 		$all_registrations = $registration->transaction()->registrations();
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 		$mtgs = array();
426 426
 
427 427
 		//loop through registrations and trigger messages once per status.
428
-		foreach ( $all_registrations as $reg ) {
428
+		foreach ($all_registrations as $reg) {
429 429
 
430 430
 			//already triggered?
431
-			if ( in_array( $reg->status_ID(), $statuses_sent ) ) {
431
+			if (in_array($reg->status_ID(), $statuses_sent)) {
432 432
 				continue;
433 433
 			}
434 434
 
435
-			$message_type = EEH_MSG_Template::convert_reg_status_to_message_type( $reg->status_ID() );
436
-			$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( $message_type, array( $registration->transaction(), null, $reg->status_ID() ) );
435
+			$message_type = EEH_MSG_Template::convert_reg_status_to_message_type($reg->status_ID());
436
+			$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers($message_type, array($registration->transaction(), null, $reg->status_ID()));
437 437
 			$statuses_sent[] = $reg->status_ID();
438 438
 		}
439 439
 
440
-		$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers( 'registration_summary', array( $registration->transaction(), null ) );
440
+		$mtgs = $mtgs + self::$_MSG_PROCESSOR->setup_mtgs_for_all_active_messengers('registration_summary', array($registration->transaction(), null));
441 441
 
442 442
 		//batch queue and initiate request
443
-		self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $mtgs );
443
+		self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($mtgs);
444 444
 		self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
445 445
 	}
446 446
 
@@ -455,39 +455,39 @@  discard block
 block discarded – undo
455 455
 	 *
456 456
 	 * @return bool          true = send away, false = nope halt the presses.
457 457
 	 */
458
-	protected static function _verify_registration_notification_send( EE_Registration $registration, $extra_details = array() ) {
458
+	protected static function _verify_registration_notification_send(EE_Registration $registration, $extra_details = array()) {
459 459
 		 //self::log(
460 460
 		 //	__CLASS__, __FUNCTION__, __LINE__,
461 461
 		 //	$registration->transaction(),
462 462
 		 //	array( '$extra_details' => $extra_details )
463 463
 		 //);
464 464
 		// currently only using this to send messages for the primary registrant
465
-		if ( ! $registration->is_primary_registrant() ) {
465
+		if ( ! $registration->is_primary_registrant()) {
466 466
 			return false;
467 467
 		}
468 468
 		// first we check if we're in admin and not doing front ajax
469
-		if ( is_admin() && ! EE_FRONT_AJAX ) {
469
+		if (is_admin() && ! EE_FRONT_AJAX) {
470 470
 			//make sure appropriate admin params are set for sending messages
471
-			if ( empty( $_REQUEST['txn_reg_status_change']['send_notifications'] ) || ! absint( $_REQUEST['txn_reg_status_change']['send_notifications'] ) ) {
471
+			if (empty($_REQUEST['txn_reg_status_change']['send_notifications']) || ! absint($_REQUEST['txn_reg_status_change']['send_notifications'])) {
472 472
 				//no messages sent please.
473 473
 				return false;
474 474
 			}
475 475
 		} else {
476 476
 			// frontend request (either regular or via AJAX)
477 477
 			// TXN is NOT finalized ?
478
-			if ( ! isset( $extra_details['finalized'] ) || $extra_details['finalized'] === false ) {
478
+			if ( ! isset($extra_details['finalized']) || $extra_details['finalized'] === false) {
479 479
 				return false;
480 480
 			}
481 481
 			// return visit but nothing changed ???
482 482
 			if (
483
-				isset( $extra_details['revisit'], $extra_details['status_updates'] ) &&
483
+				isset($extra_details['revisit'], $extra_details['status_updates']) &&
484 484
 				$extra_details['revisit'] && ! $extra_details['status_updates']
485 485
 			) {
486 486
 				return false;
487 487
 			}
488 488
 			// NOT sending messages && reg status is something other than "Not-Approved"
489 489
 			if (
490
-				! apply_filters( 'FHEE__EED_Messages___maybe_registration__deliver_notifications', false ) &&
490
+				! apply_filters('FHEE__EED_Messages___maybe_registration__deliver_notifications', false) &&
491 491
 				$registration->status_ID() !== EEM_Registration::status_id_not_approved
492 492
 			) {
493 493
 				return false;
@@ -509,10 +509,10 @@  discard block
 block discarded – undo
509 509
 	 *
510 510
 	 * @return array
511 511
 	 */
512
-	protected static function _get_reg_status_array( $reg_status = '' ) {
513
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
514
-		return EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status )
515
-			? EEH_MSG_Template::convert_reg_status_to_message_type( $reg_status )
512
+	protected static function _get_reg_status_array($reg_status = '') {
513
+		EE_Registry::instance()->load_helper('MSG_Template');
514
+		return EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
515
+			? EEH_MSG_Template::convert_reg_status_to_message_type($reg_status)
516 516
 			: EEH_MSG_Template::reg_status_to_message_type_array();
517 517
 	}
518 518
 
@@ -528,10 +528,10 @@  discard block
 block discarded – undo
528 528
 	 *
529 529
 	 * @return string|bool The payment message type slug matching the status or false if no match.
530 530
 	 */
531
-	protected static function _get_payment_message_type( $payment_status ) {
532
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
533
-		return EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status )
534
-			? EEH_MSG_Template::convert_payment_status_to_message_type( $payment_status )
531
+	protected static function _get_payment_message_type($payment_status) {
532
+		EE_Registry::instance()->load_helper('MSG_Template');
533
+		return EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
534
+			? EEH_MSG_Template::convert_payment_status_to_message_type($payment_status)
535 535
 			: false;
536 536
 	}
537 537
 
@@ -545,23 +545,23 @@  discard block
 block discarded – undo
545 545
 	 * @param array $req_data This is the $_POST & $_GET data sent from EE_Admin Pages
546 546
 	 * @return bool          success/fail
547 547
 	 */
548
-	public static function process_resend( $req_data ) {
548
+	public static function process_resend($req_data) {
549 549
 		self::_load_controller();
550 550
 
551 551
 		//if $msgID in this request then skip to the new resend_message
552
-		if ( EE_Registry::instance()->REQ->get( 'MSG_ID' ) ) {
552
+		if (EE_Registry::instance()->REQ->get('MSG_ID')) {
553 553
 			return self::resend_message();
554 554
 		}
555 555
 
556
-		if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request() ) {
556
+		if ( ! $messages_to_send = self::$_MSG_PROCESSOR->setup_messages_to_generate_from_registration_ids_in_request()) {
557 557
 			return false;
558 558
 		}
559 559
 
560 560
 		try {
561
-			self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist( $messages_to_send );
561
+			self::$_MSG_PROCESSOR->batch_queue_for_generation_and_persist($messages_to_send);
562 562
 			self::$_MSG_PROCESSOR->get_queue()->initiate_request_by_priority();
563
-		} catch( EE_Error $e ) {
564
-			EE_Error::add_error( $e->getMessage(), __FILE__, __FUNCTION__, __LINE__ );
563
+		} catch (EE_Error $e) {
564
+			EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);
565 565
 			return false;
566 566
 		}
567 567
 		return true; //everything got queued.
@@ -575,17 +575,17 @@  discard block
 block discarded – undo
575 575
 	public static function resend_message() {
576 576
 		self::_load_controller();
577 577
 
578
-		$msgID = EE_Registry::instance()->REQ->get( 'MSG_ID' );
579
-		if ( ! $msgID ) {
580
-			EE_Error::add_error( __( 'Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
578
+		$msgID = EE_Registry::instance()->REQ->get('MSG_ID');
579
+		if ( ! $msgID) {
580
+			EE_Error::add_error(__('Something went wrong because there is no "MSG_ID" value in the request', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
581 581
 			return false;
582 582
 		}
583 583
 
584
-		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( (array) $msgID );
584
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send((array) $msgID);
585 585
 
586 586
 		//setup success message.
587
-		$count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend );
588
-		EE_Error::add_success( sprintf(
587
+		$count_ready_for_resend = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
588
+		EE_Error::add_success(sprintf(
589 589
 			_n(
590 590
 				'There was %d message queued for resending.',
591 591
 				'There were %d messages queued for resending.',
@@ -593,7 +593,7 @@  discard block
 block discarded – undo
593 593
 				'event_espresso'
594 594
 			),
595 595
 			$count_ready_for_resend
596
-		) );
596
+		));
597 597
 		return true;
598 598
 	}
599 599
 
@@ -606,13 +606,13 @@  discard block
 block discarded – undo
606 606
 	 * @param  EE_Payment $payment EE_payment object
607 607
 	 * @return bool              success/fail
608 608
 	 */
609
-	public static function process_admin_payment( EE_Payment $payment ) {
610
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
609
+	public static function process_admin_payment(EE_Payment $payment) {
610
+		EE_Registry::instance()->load_helper('MSG_Template');
611 611
 		//we need to get the transaction object
612 612
 		$transaction = $payment->transaction();
613
-		if ( $transaction instanceof EE_Transaction ) {
614
-			$data = array( $transaction, $payment );
615
-			$message_type = EEH_MSG_Template::convert_payment_status_to_message_type( $payment->STS_ID() );
613
+		if ($transaction instanceof EE_Transaction) {
614
+			$data = array($transaction, $payment);
615
+			$message_type = EEH_MSG_Template::convert_payment_status_to_message_type($payment->STS_ID());
616 616
 
617 617
 			//if payment amount is less than 0 then switch to payment_refund message type.
618 618
 			$message_type = $payment->amount() < 0 ? 'payment_refund' : $message_type;
@@ -622,17 +622,17 @@  discard block
 block discarded – undo
622 622
 
623 623
 			self::_load_controller();
624 624
 
625
-			self::$_MSG_PROCESSOR->generate_for_all_active_messengers( $message_type, $data );
625
+			self::$_MSG_PROCESSOR->generate_for_all_active_messengers($message_type, $data);
626 626
 
627 627
 			//get count of queued for generation
628
-			$count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_incomplete );
628
+			$count_to_generate = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_incomplete);
629 629
 
630
-			if ( $count_to_generate > 0 ) {
631
-				add_filter( 'FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true' );
630
+			if ($count_to_generate > 0) {
631
+				add_filter('FHEE__EE_Admin_Page___process_admin_payment_notification__success', '__return_true');
632 632
 				return true;
633 633
 			} else {
634
-				$count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::instance()->stati_indicating_failed_sending() );
635
-				EE_Error::add_error( sprintf(
634
+				$count_failed = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::instance()->stati_indicating_failed_sending());
635
+				EE_Error::add_error(sprintf(
636 636
 					_n(
637 637
 						'The payment notification generation failed.',
638 638
 						'%d payment notifications failed being sent.',
@@ -640,7 +640,7 @@  discard block
 block discarded – undo
640 640
 						'event_espresso'
641 641
 					),
642 642
 					$count_failed
643
-				), __FILE__, __FUNCTION__, __LINE__ );
643
+				), __FILE__, __FUNCTION__, __LINE__);
644 644
 				return false;
645 645
 			}
646 646
 		} else {
@@ -663,11 +663,11 @@  discard block
 block discarded – undo
663 663
 	 * @param  int      	      $grp_id     a specific message template group id.
664 664
 	 * @return void
665 665
 	 */
666
-	public static function send_newsletter_message( $contacts, $grp_id ) {
666
+	public static function send_newsletter_message($contacts, $grp_id) {
667 667
 		//make sure mtp is id and set it in the EE_Request Handler later messages setup.
668
-		EE_Registry::instance()->REQ->set( 'GRP_ID', (int) $grp_id );
668
+		EE_Registry::instance()->REQ->set('GRP_ID', (int) $grp_id);
669 669
 		self::_load_controller();
670
-		self::$_MSG_PROCESSOR->generate_for_all_active_messengers( 'newsletter', $contacts );
670
+		self::$_MSG_PROCESSOR->generate_for_all_active_messengers('newsletter', $contacts);
671 671
 	}
672 672
 
673 673
 
@@ -682,10 +682,10 @@  discard block
 block discarded – undo
682 682
 	 * @param string 	$message_type
683 683
 	 * @return 	string
684 684
 	 */
685
-	public static function registration_message_trigger_url( $registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice' ) {
686
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
685
+	public static function registration_message_trigger_url($registration_message_trigger_url, EE_Registration $registration, $messenger = 'html', $message_type = 'invoice') {
686
+		EE_Registry::instance()->load_helper('MSG_Template');
687 687
 		// whitelist $messenger
688
-		switch ( $messenger ) {
688
+		switch ($messenger) {
689 689
 			case 'pdf' :
690 690
 				$sending_messenger = 'pdf';
691 691
 				$generating_messenger = 'html';
@@ -697,7 +697,7 @@  discard block
 block discarded – undo
697 697
 				break;
698 698
 		}
699 699
 		// whitelist $message_type
700
-		switch ( $message_type ) {
700
+		switch ($message_type) {
701 701
 			case 'receipt' :
702 702
 				$message_type = 'receipt';
703 703
 				break;
@@ -707,7 +707,7 @@  discard block
 block discarded – undo
707 707
 				break;
708 708
 		}
709 709
 		// verify that both the messenger AND the message type are active
710
-		if ( EEH_MSG_Template::is_messenger_active( $sending_messenger ) && EEH_MSG_Template::is_mt_active( $message_type ) ) {
710
+		if (EEH_MSG_Template::is_messenger_active($sending_messenger) && EEH_MSG_Template::is_mt_active($message_type)) {
711 711
 			//need to get the correct message template group for this (i.e. is there a custom invoice for the event this registration is registered for?)
712 712
 			$template_query_params = array(
713 713
 				'MTP_is_active' => true,
@@ -716,16 +716,16 @@  discard block
 block discarded – undo
716 716
 				'Event.EVT_ID' => $registration->event_ID()
717 717
 			);
718 718
 			//get the message template group.
719
-			$msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) );
719
+			$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
720 720
 			//if we don't have an EE_Message_Template_Group then return
721
-			if ( ! $msg_template_group instanceof EE_Message_Template_Group ) {
721
+			if ( ! $msg_template_group instanceof EE_Message_Template_Group) {
722 722
 				// remove EVT_ID from query params so that global templates get picked up
723
-				unset( $template_query_params['Event.EVT_ID'] );
723
+				unset($template_query_params['Event.EVT_ID']);
724 724
 				//get global template as the fallback
725
-				$msg_template_group = EEM_Message_Template_Group::instance()->get_one( array( $template_query_params ) );
725
+				$msg_template_group = EEM_Message_Template_Group::instance()->get_one(array($template_query_params));
726 726
 			}
727 727
 			//if we don't have an EE_Message_Template_Group then return
728
-			if ( ! $msg_template_group instanceof EE_Message_Template_Group ) {
728
+			if ( ! $msg_template_group instanceof EE_Message_Template_Group) {
729 729
 				return '';
730 730
 			}
731 731
 			// generate the URL
@@ -754,7 +754,7 @@  discard block
 block discarded – undo
754 754
 	 * @param bool 	  $send true we will do a test send using the messenger delivery, false we just do a regular preview
755 755
 	 * @return string          The body of the message.
756 756
 	 */
757
-	public static function preview_message( $type, $context, $messenger, $send = false ) {
757
+	public static function preview_message($type, $context, $messenger, $send = false) {
758 758
 		self::_load_controller();
759 759
 		$mtg = new EE_Message_To_Generate(
760 760
 			$messenger,
@@ -764,8 +764,8 @@  discard block
 block discarded – undo
764 764
 			$context,
765 765
 			true
766 766
 		);
767
-		$generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview( $mtg );
768
-		if ( $generated_preview_queue instanceof EE_Messages_Queue ) {
767
+		$generated_preview_queue = self::$_MSG_PROCESSOR->generate_for_preview($mtg);
768
+		if ($generated_preview_queue instanceof EE_Messages_Queue) {
769 769
 			return $generated_preview_queue->get_queue()->current()->content();
770 770
 		} else {
771 771
 			return $generated_preview_queue;
@@ -789,7 +789,7 @@  discard block
 block discarded – undo
789 789
 	 *
790 790
 	 * @return bool          success or fail.
791 791
 	 */
792
-	public static function send_message_with_messenger_only( $messenger, $message_type, EE_Messages_Queue $queue ) {
792
+	public static function send_message_with_messenger_only($messenger, $message_type, EE_Messages_Queue $queue) {
793 793
 		self::_load_controller();
794 794
 		//set mtg
795 795
 		$mtg = new EE_Message_To_Generate_From_Queue(
@@ -799,7 +799,7 @@  discard block
 block discarded – undo
799 799
 			$queue
800 800
 		);
801 801
 
802
-		return self::$_MSG_PROCESSOR->queue_for_sending( $mtg );
802
+		return self::$_MSG_PROCESSOR->queue_for_sending($mtg);
803 803
 	}
804 804
 
805 805
 
@@ -812,22 +812,22 @@  discard block
 block discarded – undo
812 812
 	 * @param array     $message_ids An array of message ids
813 813
 	 * @return bool | EE_Messages_Queue     false if nothing was generated, EE_Messages_Queue containing generated messages.
814 814
 	 */
815
-	public static function generate_now( $message_ids ) {
815
+	public static function generate_now($message_ids) {
816 816
 		self::_load_controller();
817 817
 		$messages = EEM_Message::instance()->get_all(
818 818
 			array(
819 819
 				0 => array(
820
-					'MSG_ID' => array( 'IN', $message_ids ),
820
+					'MSG_ID' => array('IN', $message_ids),
821 821
 					'STS_ID' => EEM_Message::status_incomplete,
822 822
 				)
823 823
 			)
824 824
 		);
825 825
 
826
-		$generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue( $messages );
826
+		$generated_queue = self::$_MSG_PROCESSOR->batch_generate_from_queue($messages);
827 827
 
828
-		if ( ! $generated_queue instanceof EE_Messages_Queue ) {
828
+		if ( ! $generated_queue instanceof EE_Messages_Queue) {
829 829
 			EE_Error::add_error(
830
-				__( 'The messages were not generated.  This is usually because there is already a batch being generated on a separate request.  You can wait a minute or two and try again.', 'event_espresso' ),
830
+				__('The messages were not generated.  This is usually because there is already a batch being generated on a separate request.  You can wait a minute or two and try again.', 'event_espresso'),
831 831
 				__FILE__, __FUNCTION__, __LINE__
832 832
 			);
833 833
 		}
@@ -846,28 +846,28 @@  discard block
 block discarded – undo
846 846
 	 *
847 847
 	 * @return bool | EE_Messages_Queue  false if no messages sent.
848 848
 	 */
849
-	public static function send_now( $message_ids ) {
849
+	public static function send_now($message_ids) {
850 850
 		self::_load_controller();
851 851
 		$messages = EEM_Message::instance()->get_all(
852 852
 			array(
853 853
 				0 => array(
854
-					'MSG_ID' => array( 'IN', $message_ids ),
855
-					'STS_ID' => array( 'IN', array( EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry ) )
854
+					'MSG_ID' => array('IN', $message_ids),
855
+					'STS_ID' => array('IN', array(EEM_Message::status_idle, EEM_Message::status_resend, EEM_Message::status_retry))
856 856
 				)
857 857
 			)
858 858
 		);
859 859
 
860
-		$sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue( $messages );
860
+		$sent_queue = self::$_MSG_PROCESSOR->batch_send_from_queue($messages);
861 861
 
862
-		if ( ! $sent_queue instanceof EE_Messages_Queue ) {
862
+		if ( ! $sent_queue instanceof EE_Messages_Queue) {
863 863
 			EE_Error::add_error(
864
-				__( 'The messages were not sent.  This is usually because there is already a batch being sent on a separate request.  You can wait a minute or two and try again.', 'event_espresso' ),
864
+				__('The messages were not sent.  This is usually because there is already a batch being sent on a separate request.  You can wait a minute or two and try again.', 'event_espresso'),
865 865
 				__FILE__, __FUNCTION__, __LINE__
866 866
 			);
867 867
 		} else {
868 868
 			//can count how many sent by using the messages in the queue
869
-			$sent_count = $sent_queue->count_STS_in_queue( array( EEM_Message::instance()->stati_indicating_sent() ) );
870
-			if ( $sent_count > 0 ) {
869
+			$sent_count = $sent_queue->count_STS_in_queue(array(EEM_Message::instance()->stati_indicating_sent()));
870
+			if ($sent_count > 0) {
871 871
 				EE_Error::add_success(
872 872
 					sprintf(
873 873
 						_n(
@@ -882,8 +882,8 @@  discard block
 block discarded – undo
882 882
 			} else {
883 883
 				EE_Error::overwrite_errors();
884 884
 				EE_Error::add_error(
885
-					__( 'No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, or there was an error.
886
-					If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso' ),
885
+					__('No message was sent because of problems with sending. Either all the messages you selected were not a sendable message, or there was an error.
886
+					If there was an error, you can look at the messages in the message activity list table for any error messages.', 'event_espresso'),
887 887
 					__FILE__, __FUNCTION__, __LINE__
888 888
 				);
889 889
 			}
@@ -904,13 +904,13 @@  discard block
 block discarded – undo
904 904
 	 *
905 905
 	 * @return bool  true means messages were successfully queued for resending, false means none were queued for resending.
906 906
 	 */
907
-	public static function queue_for_resending( $message_ids ) {
907
+	public static function queue_for_resending($message_ids) {
908 908
 		self::_load_controller();
909
-		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send( $message_ids );
909
+		self::$_MSG_PROCESSOR->setup_messages_from_ids_and_send($message_ids);
910 910
 
911 911
 		//get queue and count
912
-		$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue( EEM_Message::status_resend );
913
-		if ( $queue_count > 0 ) {
912
+		$queue_count = self::$_MSG_PROCESSOR->get_queue()->count_STS_in_queue(EEM_Message::status_resend);
913
+		if ($queue_count > 0) {
914 914
 			EE_Error::add_success(
915 915
 				sprintf(
916 916
 					_n(
@@ -924,7 +924,7 @@  discard block
 block discarded – undo
924 924
 			);
925 925
 		} else {
926 926
 			EE_Error::add_error(
927
-				__( 'No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso' ),
927
+				__('No messages were queued for resending. This usually only happens when all the messages flagged for resending are not a status that can be resent.', 'event_espresso'),
928 928
 				__FILE__, __FUNCTION__, __LINE__
929 929
 			);
930 930
 		}
@@ -946,17 +946,17 @@  discard block
 block discarded – undo
946 946
 	 * @param array $info
947 947
 	 * @param bool $display_request
948 948
 	 */
949
-	protected static function log( $class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false ) {
950
-		EE_Registry::instance()->load_helper( 'Debug_Tools' );
951
-		if ( WP_DEBUG && false ) {
952
-			if ( $transaction instanceof EE_Transaction ) {
949
+	protected static function log($class = '', $func = '', $line = '', EE_Transaction $transaction, $info = array(), $display_request = false) {
950
+		EE_Registry::instance()->load_helper('Debug_Tools');
951
+		if (WP_DEBUG && false) {
952
+			if ($transaction instanceof EE_Transaction) {
953 953
 				// don't serialize objects
954
-				$info = EEH_Debug_Tools::strip_objects( $info );
954
+				$info = EEH_Debug_Tools::strip_objects($info);
955 955
 				$info['TXN_status'] = $transaction->status_ID();
956 956
 				$info['TXN_reg_steps'] = $transaction->reg_steps();
957
-				if ( $transaction->ID() ) {
958
-					$index = 'EE_Transaction: ' . $transaction->ID();
959
-					EEH_Debug_Tools::log( $class, $func, $line, $info, $display_request, $index );
957
+				if ($transaction->ID()) {
958
+					$index = 'EE_Transaction: '.$transaction->ID();
959
+					EEH_Debug_Tools::log($class, $func, $line, $info, $display_request, $index);
960 960
 				}
961 961
 			}
962 962
 		}
Please login to merge, or discard this patch.
core/db_classes/EE_Message.class.php 1 patch
Spacing   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
2
-	exit( 'No direct script access allowed' );
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {
2
+	exit('No direct script access allowed');
3 3
 }
4 4
 /**
5 5
  * EE_Message class
@@ -48,14 +48,14 @@  discard block
 block discarded – undo
48 48
 	 * @param array $date_formats incoming date formats in an array.  First value is the date_format, second is time format.
49 49
 	 * @return EE_Message
50 50
 	 */
51
-	public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) {
52
-		$has_object = parent::_check_for_object( $props_n_values, __CLASS__ );
51
+	public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) {
52
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__);
53 53
 		//if object doesn't exist, let's generate a unique token on instantiation so that its available even before saving to db.
54
-		if ( ! $has_object ) {
55
-			EE_Registry::instance()->load_helper( 'URL' );
54
+		if ( ! $has_object) {
55
+			EE_Registry::instance()->load_helper('URL');
56 56
 			$props_n_values['MSG_token'] = EEH_URL::generate_unique_token();
57 57
 		}
58
-		return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats );
58
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats);
59 59
 	}
60 60
 
61 61
 
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 	 * @param string $timezone
67 67
 	 * @return EE_Message
68 68
 	 */
69
-	public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) {
70
-		return new self( $props_n_values, true, $timezone );
69
+	public static function new_instance_from_db($props_n_values = array(), $timezone = null) {
70
+		return new self($props_n_values, true, $timezone);
71 71
 	}
72 72
 
73 73
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return int
79 79
 	 */
80 80
 	public function MSG_token() {
81
-		return $this->get( 'MSG_token' );
81
+		return $this->get('MSG_token');
82 82
 	}
83 83
 
84 84
 
@@ -88,8 +88,8 @@  discard block
 block discarded – undo
88 88
 	 *
89 89
 	 * @param int $MSG_token
90 90
 	 */
91
-	public function set_MSG_token( $MSG_token) {
92
-		$this->set( 'MSG_token', $MSG_token );
91
+	public function set_MSG_token($MSG_token) {
92
+		$this->set('MSG_token', $MSG_token);
93 93
 	}
94 94
 
95 95
 
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
 	 * @return int
102 102
 	 */
103 103
 	public function GRP_ID() {
104
-		return $this->get( 'GRP_ID' );
104
+		return $this->get('GRP_ID');
105 105
 	}
106 106
 
107 107
 
@@ -111,8 +111,8 @@  discard block
 block discarded – undo
111 111
 	 *
112 112
 	 * @param int $GRP_ID
113 113
 	 */
114
-	public function set_GRP_ID( $GRP_ID ) {
115
-		$this->set( 'GRP_ID', $GRP_ID );
114
+	public function set_GRP_ID($GRP_ID) {
115
+		$this->set('GRP_ID', $GRP_ID);
116 116
 	}
117 117
 
118 118
 
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 	 * @return int
125 125
 	 */
126 126
 	public function TXN_ID() {
127
-		return $this->get( 'TXN_ID' );
127
+		return $this->get('TXN_ID');
128 128
 	}
129 129
 
130 130
 
@@ -134,8 +134,8 @@  discard block
 block discarded – undo
134 134
 	 *
135 135
 	 * @param int $TXN_ID
136 136
 	 */
137
-	public function set_TXN_ID( $TXN_ID) {
138
-		$this->set( 'TXN_ID', $TXN_ID );
137
+	public function set_TXN_ID($TXN_ID) {
138
+		$this->set('TXN_ID', $TXN_ID);
139 139
 	}
140 140
 
141 141
 
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
 	 * @return string
148 148
 	 */
149 149
 	public function messenger() {
150
-		return $this->get( 'MSG_messenger' );
150
+		return $this->get('MSG_messenger');
151 151
 	}
152 152
 
153 153
 
@@ -157,8 +157,8 @@  discard block
 block discarded – undo
157 157
 	 *
158 158
 	 * @param string $messenger
159 159
 	 */
160
-	public function set_messenger( $messenger ) {
161
-		$this->set( 'MSG_messenger', $messenger );
160
+	public function set_messenger($messenger) {
161
+		$this->set('MSG_messenger', $messenger);
162 162
 	}
163 163
 
164 164
 
@@ -181,7 +181,7 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @param EE_Messenger $messenger
183 183
 	 */
184
-	public function set_messenger_object( EE_Messenger $messenger ) {
184
+	public function set_messenger_object(EE_Messenger $messenger) {
185 185
 		$this->_messenger = $messenger;
186 186
 	}
187 187
 
@@ -194,11 +194,11 @@  discard block
 block discarded – undo
194 194
 	 * @return bool
195 195
 	 * @throws \EE_Error
196 196
 	 */
197
-	public function valid_messenger( $throw_exceptions = false ) {
198
-		if ( $this->_messenger instanceof EE_Messenger ) {
197
+	public function valid_messenger($throw_exceptions = false) {
198
+		if ($this->_messenger instanceof EE_Messenger) {
199 199
 			return true;
200 200
 		}
201
-		if ( $throw_exceptions ) {
201
+		if ($throw_exceptions) {
202 202
 			throw new EE_Error(
203 203
 				sprintf(
204 204
 					__(
@@ -222,10 +222,10 @@  discard block
 block discarded – undo
222 222
 	 * @param   bool    $plural whether to return the plural label or not.
223 223
 	 * @return string
224 224
 	 */
225
-	public function messenger_label( $plural = false ) {
225
+	public function messenger_label($plural = false) {
226 226
 		$label_type = $plural ? 'plural' : 'singular';
227 227
 		$messenger = $this->messenger_object();
228
-		return $messenger instanceof EE_Messenger ? $messenger->label[ $label_type ] : $this->messenger();
228
+		return $messenger instanceof EE_Messenger ? $messenger->label[$label_type] : $this->messenger();
229 229
 	}
230 230
 
231 231
 
@@ -236,7 +236,7 @@  discard block
 block discarded – undo
236 236
 	 * @return string
237 237
 	 */
238 238
 	public function message_type() {
239
-		return $this->get( 'MSG_message_type' );
239
+		return $this->get('MSG_message_type');
240 240
 	}
241 241
 
242 242
 
@@ -246,8 +246,8 @@  discard block
 block discarded – undo
246 246
 	 *
247 247
 	 * @param string $message_type
248 248
 	 */
249
-	public function set_message_type( $message_type ) {
250
-		$this->set( 'MSG_message_type', $message_type );
249
+	public function set_message_type($message_type) {
250
+		$this->set('MSG_message_type', $message_type);
251 251
 	}
252 252
 
253 253
 
@@ -270,7 +270,7 @@  discard block
 block discarded – undo
270 270
 	 *
271 271
 	 * @param EE_Message_Type $message_type
272 272
 	 */
273
-	public function set_message_type_object( EE_Message_Type $message_type ) {
273
+	public function set_message_type_object(EE_Message_Type $message_type) {
274 274
 		$this->_message_type = $message_type;
275 275
 	}
276 276
 
@@ -283,11 +283,11 @@  discard block
 block discarded – undo
283 283
 	 * @return bool
284 284
 	 * @throws \EE_Error
285 285
 	 */
286
-	public function valid_message_type( $throw_exceptions = false ) {
287
-		if ( $this->_message_type instanceof EE_Message_Type ) {
286
+	public function valid_message_type($throw_exceptions = false) {
287
+		if ($this->_message_type instanceof EE_Message_Type) {
288 288
 			return true;
289 289
 		}
290
-		if ( $throw_exceptions ) {
290
+		if ($throw_exceptions) {
291 291
 			throw new EE_Error(
292 292
 				sprintf(
293 293
 					__(
@@ -311,10 +311,10 @@  discard block
 block discarded – undo
311 311
 	 * @param   bool    $plural whether to return the plural label or not.
312 312
 	 * @return string
313 313
 	 */
314
-	public function message_type_label( $plural = false ) {
314
+	public function message_type_label($plural = false) {
315 315
 		$label_type = $plural ? 'plural' : 'singular';
316 316
 		$message_type = $this->message_type_object();
317
-		return $message_type instanceof EE_message_type ? $message_type->label[ $label_type ] : $this->message_type();
317
+		return $message_type instanceof EE_message_type ? $message_type->label[$label_type] : $this->message_type();
318 318
 	}
319 319
 
320 320
 
@@ -325,7 +325,7 @@  discard block
 block discarded – undo
325 325
 	 * @return string
326 326
 	 */
327 327
 	public function context() {
328
-		return $this->get( 'MSG_context' );
328
+		return $this->get('MSG_context');
329 329
 	}
330 330
 
331 331
 
@@ -339,9 +339,9 @@  discard block
 block discarded – undo
339 339
 	 */
340 340
 	public function context_label() {
341 341
 		/** @type EE_Messages $messages_controller */
342
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
342
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
343 343
 		$contexts = $messages_controller->get_all_contexts();
344
-		return isset( $contexts[ $this->context() ] ) ? $contexts[ $this->context() ] : $this->context();
344
+		return isset($contexts[$this->context()]) ? $contexts[$this->context()] : $this->context();
345 345
 	}
346 346
 
347 347
 
@@ -351,8 +351,8 @@  discard block
 block discarded – undo
351 351
 	 *
352 352
 	 * @param string $context
353 353
 	 */
354
-	public function set_context( $context ) {
355
-		$this->set( 'MSG_context', $context );
354
+	public function set_context($context) {
355
+		$this->set('MSG_context', $context);
356 356
 	}
357 357
 
358 358
 
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 	 * @return int
364 364
 	 */
365 365
 	public function recipient_ID() {
366
-		return $this->get( 'MSG_recipient_ID' );
366
+		return $this->get('MSG_recipient_ID');
367 367
 	}
368 368
 
369 369
 
@@ -373,8 +373,8 @@  discard block
 block discarded – undo
373 373
 	 *
374 374
 	 * @param string $recipient_ID
375 375
 	 */
376
-	public function set_recipient_ID( $recipient_ID ) {
377
-		$this->set( 'MSG_recipient_ID', $recipient_ID );
376
+	public function set_recipient_ID($recipient_ID) {
377
+		$this->set('MSG_recipient_ID', $recipient_ID);
378 378
 	}
379 379
 
380 380
 
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
 	 * @return string
386 386
 	 */
387 387
 	public function recipient_type() {
388
-		return $this->get( 'MSG_recipient_type' );
388
+		return $this->get('MSG_recipient_type');
389 389
 	}
390 390
 
391 391
 
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 * @return EE_Base_Class | null
398 398
 	 */
399 399
 	public function recipient_object() {
400
-		if ( ! $this->recipient_type() || ! $this->recipient_ID() ) {
400
+		if ( ! $this->recipient_type() || ! $this->recipient_ID()) {
401 401
 			return null;
402 402
 		}
403 403
 
404
-		return $this->get_first_related( $this->recipient_type() );
404
+		return $this->get_first_related($this->recipient_type());
405 405
 	}
406 406
 
407 407
 
@@ -411,8 +411,8 @@  discard block
 block discarded – undo
411 411
 	 *
412 412
 	 * @param string $recipient_type
413 413
 	 */
414
-	public function set_recipient_type( $recipient_type ) {
415
-		$this->set( 'MSG_recipient_type', $recipient_type );
414
+	public function set_recipient_type($recipient_type) {
415
+		$this->set('MSG_recipient_type', $recipient_type);
416 416
 	}
417 417
 
418 418
 
@@ -423,7 +423,7 @@  discard block
 block discarded – undo
423 423
 	 * @return string
424 424
 	 */
425 425
 	public function content() {
426
-		return $this->get( 'MSG_content' );
426
+		return $this->get('MSG_content');
427 427
 	}
428 428
 
429 429
 
@@ -433,8 +433,8 @@  discard block
 block discarded – undo
433 433
 	 *
434 434
 	 * @param string $content
435 435
 	 */
436
-	public function set_content( $content ) {
437
-		$this->set( 'MSG_content', $content );
436
+	public function set_content($content) {
437
+		$this->set('MSG_content', $content);
438 438
 	}
439 439
 
440 440
 
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 	 * @return string
446 446
 	 */
447 447
 	public function subject() {
448
-		return $this->get( 'MSG_subject' );
448
+		return $this->get('MSG_subject');
449 449
 	}
450 450
 
451 451
 
@@ -455,8 +455,8 @@  discard block
 block discarded – undo
455 455
 	 *
456 456
 	 * @param string $subject
457 457
 	 */
458
-	public function set_subject( $subject ) {
459
-		$this->set( 'MSG_subject', $subject );
458
+	public function set_subject($subject) {
459
+		$this->set('MSG_subject', $subject);
460 460
 	}
461 461
 
462 462
 
@@ -467,8 +467,8 @@  discard block
 block discarded – undo
467 467
 	 * @return string
468 468
 	 */
469 469
 	public function to() {
470
-		$to = $this->get( 'MSG_to' );
471
-		return empty( $to ) ? __( 'No recipient', 'event_espresso' ) : $to;
470
+		$to = $this->get('MSG_to');
471
+		return empty($to) ? __('No recipient', 'event_espresso') : $to;
472 472
 	}
473 473
 
474 474
 
@@ -478,8 +478,8 @@  discard block
 block discarded – undo
478 478
 	 *
479 479
 	 * @param string $to
480 480
 	 */
481
-	public function set_to( $to ) {
482
-		$this->set( 'MSG_to', $to );
481
+	public function set_to($to) {
482
+		$this->set('MSG_to', $to);
483 483
 	}
484 484
 
485 485
 
@@ -490,7 +490,7 @@  discard block
 block discarded – undo
490 490
 	 * @return string
491 491
 	 */
492 492
 	public function from() {
493
-		return $this->get( 'MSG_from' );
493
+		return $this->get('MSG_from');
494 494
 	}
495 495
 
496 496
 
@@ -500,8 +500,8 @@  discard block
 block discarded – undo
500 500
 	 *
501 501
 	 * @param string $from
502 502
 	 */
503
-	public function set_from( $from ) {
504
-		$this->set( 'MSG_from', $from );
503
+	public function set_from($from) {
504
+		$this->set('MSG_from', $from);
505 505
 	}
506 506
 
507 507
 
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 	 * @return int
515 515
 	 */
516 516
 	public function priority() {
517
-		return $this->get( 'MSG_priority' );
517
+		return $this->get('MSG_priority');
518 518
 	}
519 519
 
520 520
 
@@ -524,8 +524,8 @@  discard block
 block discarded – undo
524 524
 	 *
525 525
 	 * @param int $priority
526 526
 	 */
527
-	public function set_priority( $priority ) {
528
-		$this->set( 'MSG_priority', $priority );
527
+	public function set_priority($priority) {
528
+		$this->set('MSG_priority', $priority);
529 529
 	}
530 530
 
531 531
 
@@ -536,7 +536,7 @@  discard block
 block discarded – undo
536 536
 	 * @return string
537 537
 	 */
538 538
 	public function STS_ID() {
539
-		return $this->get( 'STS_ID' );
539
+		return $this->get('STS_ID');
540 540
 	}
541 541
 
542 542
 
@@ -546,8 +546,8 @@  discard block
 block discarded – undo
546 546
 	 *
547 547
 	 * @param string $STS_ID
548 548
 	 */
549
-	public function set_STS_ID( $STS_ID ) {
550
-		$this->set( 'STS_ID', $STS_ID );
549
+	public function set_STS_ID($STS_ID) {
550
+		$this->set('STS_ID', $STS_ID);
551 551
 	}
552 552
 
553 553
 
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 	 * @return string
559 559
 	 */
560 560
 	public function created() {
561
-		return $this->get( 'MSG_created' );
561
+		return $this->get('MSG_created');
562 562
 	}
563 563
 
564 564
 
@@ -568,8 +568,8 @@  discard block
 block discarded – undo
568 568
 	 *
569 569
 	 * @param string $created
570 570
 	 */
571
-	public function set_created( $created ) {
572
-		$this->set( 'MSG_created', $created );
571
+	public function set_created($created) {
572
+		$this->set('MSG_created', $created);
573 573
 	}
574 574
 
575 575
 
@@ -580,7 +580,7 @@  discard block
 block discarded – undo
580 580
 	 * @return string
581 581
 	 */
582 582
 	public function modified() {
583
-		return $this->get( 'MSG_modified' );
583
+		return $this->get('MSG_modified');
584 584
 	}
585 585
 
586 586
 
@@ -590,8 +590,8 @@  discard block
 block discarded – undo
590 590
 	 *
591 591
 	 * @param string $modified
592 592
 	 */
593
-	public function set_modified( $modified ) {
594
-		$this->set( 'MSG_modified', $modified );
593
+	public function set_modified($modified) {
594
+		$this->set('MSG_modified', $modified);
595 595
 	}
596 596
 
597 597
 
@@ -601,8 +601,8 @@  discard block
 block discarded – undo
601 601
 	 * Sets generation data for this message.
602 602
 	 * @param mixed $data
603 603
 	 */
604
-	public function set_generation_data( $data ) {
605
-		$this->set_field_or_extra_meta( 'MSG_generation_data', $data );
604
+	public function set_generation_data($data) {
605
+		$this->set_field_or_extra_meta('MSG_generation_data', $data);
606 606
 	}
607 607
 
608 608
 
@@ -614,7 +614,7 @@  discard block
 block discarded – undo
614 614
 	 * @return mixed|null
615 615
 	 */
616 616
 	public function get_generation_data() {
617
-		return $this->get_field_or_extra_meta( 'MSG_generation_data' );
617
+		return $this->get_field_or_extra_meta('MSG_generation_data');
618 618
 	}
619 619
 
620 620
 
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	 * @return mixed|null
626 626
 	 */
627 627
 	public function error_message() {
628
-		return $this->get_field_or_extra_meta( 'MSG_error' );
628
+		return $this->get_field_or_extra_meta('MSG_error');
629 629
 	}
630 630
 
631 631
 
@@ -634,8 +634,8 @@  discard block
 block discarded – undo
634 634
 	 * @param $message
635 635
 	 * @return bool|int
636 636
 	 */
637
-	public function set_error_message( $message ) {
638
-		return $this->set_field_or_extra_meta( 'MSG_error', $message );
637
+	public function set_error_message($message) {
638
+		return $this->set_field_or_extra_meta('MSG_error', $message);
639 639
 	}
640 640
 
641 641
 
@@ -649,18 +649,18 @@  discard block
 block discarded – undo
649 649
 		/**
650 650
 		 * This is deprecated functionality that will be removed eventually but included here now for backward compat.
651 651
 		 */
652
-		if ( ! empty( $this->template_pack ) ) {
652
+		if ( ! empty($this->template_pack)) {
653 653
 			return $this->template_pack;
654 654
 		}
655 655
 		/** @type EE_Message_Template_Group $grp */
656
-		$grp = $this->get_first_related( 'Message_Template_Group' );
656
+		$grp = $this->get_first_related('Message_Template_Group');
657 657
 		//if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
658
-		if ( ! $grp instanceof EE_Message_Template_Group ) {
659
-			$grp = EEM_Message_Template_Group::instance()->get_one( array( array(
658
+		if ( ! $grp instanceof EE_Message_Template_Group) {
659
+			$grp = EEM_Message_Template_Group::instance()->get_one(array(array(
660 660
 				'MTP_messenger' => $this->messenger(),
661 661
 				'MTP_message_type' => $this->message_type(),
662 662
 				'MTP_is_global' => true
663
-			) ) );
663
+			)));
664 664
 		}
665 665
 
666 666
 		return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack() : null;
@@ -677,20 +677,20 @@  discard block
 block discarded – undo
677 677
 		/**
678 678
 		 * This is deprecated functionality that will be removed eventually but included here now for backward compat.
679 679
 		 */
680
-		if ( ! empty( $this->template_variation ) ) {
680
+		if ( ! empty($this->template_variation)) {
681 681
 			return $this->template_variation;
682 682
 		}
683 683
 
684 684
 		/** @type EE_Message_Template_Group $grp */
685
-		$grp = $this->get_first_related( 'Message_Template_Group' );
685
+		$grp = $this->get_first_related('Message_Template_Group');
686 686
 
687 687
 		//if no group then let's try to get the first related group by internal messenger and message type (will use global grp).
688
-		if ( ! $grp instanceof EE_Message_Template_Group ) {
689
-			$grp = EEM_Message_Template_Group::instance()->get_one( array( array(
688
+		if ( ! $grp instanceof EE_Message_Template_Group) {
689
+			$grp = EEM_Message_Template_Group::instance()->get_one(array(array(
690 690
 				'MTP_messenger' => $this->messenger(),
691 691
 				'MTP_message_type' => $this->message_type(),
692 692
 				'MTP_is_global' => true
693
-			) ) );
693
+			)));
694 694
 		}
695 695
 
696 696
 		return $grp instanceof EE_Message_Template_Group ? $grp->get_template_pack_variation() : '';
@@ -701,15 +701,15 @@  discard block
 block discarded – undo
701 701
 	 * @return string
702 702
 	 */
703 703
 	public function get_admin_details_link() {
704
-		EE_Registry::instance()->load_helper( 'URL' );
705
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
706
-		switch ( $this->STS_ID() ) {
704
+		EE_Registry::instance()->load_helper('URL');
705
+		EE_Registry::instance()->load_helper('MSG_Template');
706
+		switch ($this->STS_ID()) {
707 707
 			case EEM_Message::status_failed :
708
-				return EEH_MSG_Template::generate_error_display_trigger( $this );
708
+				return EEH_MSG_Template::generate_error_display_trigger($this);
709 709
 				break;
710 710
 
711 711
 			case EEM_Message::status_sent :
712
-				return EEH_MSG_Template::generate_browser_trigger( $this );
712
+				return EEH_MSG_Template::generate_browser_trigger($this);
713 713
 				break;
714 714
 
715 715
 			default :
@@ -730,13 +730,13 @@  discard block
 block discarded – undo
730 730
 	 * @return string
731 731
 	 */
732 732
 	public function get_admin_settings_link() {
733
-		EE_Registry::instance()->load_helper( 'URL' );
733
+		EE_Registry::instance()->load_helper('URL');
734 734
 		return EEH_URL::add_query_args_and_nonce(
735 735
 			array(
736 736
 				'page' => 'espresso_messages',
737 737
 				'action' => 'settings',
738 738
 			),
739
-			admin_url( 'admin.php' )
739
+			admin_url('admin.php')
740 740
 		);
741 741
 	}
742 742
 
@@ -745,13 +745,13 @@  discard block
 block discarded – undo
745 745
 	 * @return string
746 746
 	 */
747 747
 	public function get_admin_overview_link() {
748
-		EE_Registry::instance()->load_helper( 'URL' );
748
+		EE_Registry::instance()->load_helper('URL');
749 749
 		return EEH_URL::add_query_args_and_nonce(
750 750
 			array(
751 751
 				'page' => 'espresso_messages',
752 752
 				'action' => 'default',
753 753
 			),
754
-			admin_url( 'admin.php' )
754
+			admin_url('admin.php')
755 755
 		);
756 756
 	}
757 757
 
Please login to merge, or discard this patch.
core/helpers/EEH_MSG_Template.helper.php 1 patch
Spacing   +134 added lines, -134 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
 /**
@@ -55,44 +55,44 @@  discard block
 block discarded – undo
55 55
 	 * @throws \EE_Error
56 56
 	 * @return array|bool array of data required for the redirect to the correct edit page or FALSE if encountering problems.
57 57
 	 */
58
-	public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0,  $global = FALSE) {
58
+	public static function generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) {
59 59
 		//make sure message_type is an array.
60 60
 		$message_types = (array) $message_types;
61 61
 		$templates = array();
62 62
 		$success = TRUE;
63 63
 
64
-		if ( empty($messenger) ) {
65
-			throw new EE_Error( __('We need a messenger to generate templates!', 'event_espresso') );
64
+		if (empty($messenger)) {
65
+			throw new EE_Error(__('We need a messenger to generate templates!', 'event_espresso'));
66 66
 		}
67 67
 
68 68
 		//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.
69
-		if ( empty($message_types) ) {
70
-			throw new EE_Error( __('We need at least one message type to generate templates!', 'event_espresso') );
69
+		if (empty($message_types)) {
70
+			throw new EE_Error(__('We need at least one message type to generate templates!', 'event_espresso'));
71 71
 		}
72 72
 
73 73
 		self::_set_autoloader();
74 74
 		/** @type EE_Messages $messages_controller */
75
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
75
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
76 76
 
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 ) ) {
80
-				$GRP_ID = EEM_Message_Template_Group::instance()->get_one( array( array( 'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE ) ) );
79
+			if ($global && empty($GRP_ID)) {
80
+				$GRP_ID = EEM_Message_Template_Group::instance()->get_one(array(array('MTP_messenger' => $messenger, 'MTP_message_type' => $message_type, 'MTP_is_global' => TRUE)));
81 81
 				$GRP_ID = $GRP_ID instanceof EE_Message_Template_Group ? $GRP_ID->ID() : 0;
82 82
 			}
83 83
 			//if this is global template generation. First let's determine if we already HAVE global templates for this messenger and message_type combination.  If we do then NO generation!!
84
-			if ( $global && self::already_generated($messenger, $message_type, $GRP_ID  ) ) {
84
+			if ($global && self::already_generated($messenger, $message_type, $GRP_ID)) {
85 85
 				$templates = TRUE;
86 86
 				continue; //get out we've already got generated templates for this.
87 87
 			}
88 88
 
89 89
 			$new_message_template_group = $messages_controller->create_new_templates($messenger, $message_type, $GRP_ID, $global);
90 90
 
91
-			if ( !$new_message_template_group ) {
91
+			if ( ! $new_message_template_group) {
92 92
 				$success = FALSE;
93 93
 				continue;
94 94
 			}
95
-			if ( $templates === TRUE ) $templates = array();
95
+			if ($templates === TRUE) $templates = array();
96 96
 			$templates[] = $new_message_template_group;
97 97
 		}
98 98
 
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
 	 * @param  bool  $update_to_active if true then we also toggle the template to active.
109 109
 	 * @return bool                true = generated, false = hasn't been generated.
110 110
 	 */
111
-	public static function already_generated( $messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE ) {
111
+	public static function already_generated($messenger, $message_type, $GRP_ID = 0, $update_to_active = TRUE) {
112 112
 		self::_set_autoloader();
113 113
 		$MTP = EEM_Message_Template::instance();
114 114
 
115 115
 		//what method we use depends on whether we have an GRP_ID or not
116
-		$count = empty( $GRP_ID ) ? EEM_Message_Template::instance()->count( array( array( 'Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE ) ) ) :  $MTP->count( array( array( 'GRP_ID' => $GRP_ID ) ) );
116
+		$count = empty($GRP_ID) ? EEM_Message_Template::instance()->count(array(array('Message_Template_Group.MTP_messenger' => $messenger, 'Message_Template_Group.MTP_message_type' => $message_type, 'Message_Template_Group.MTP_is_global' => TRUE))) : $MTP->count(array(array('GRP_ID' => $GRP_ID)));
117 117
 
118
-		if ( $update_to_active ) {
119
-			self::update_to_active( $messenger, $message_type );
118
+		if ($update_to_active) {
119
+			self::update_to_active($messenger, $message_type);
120 120
 		}
121 121
 
122
-		return ( $count > 0 ) ? TRUE : FALSE;
122
+		return ($count > 0) ? TRUE : FALSE;
123 123
 	}
124 124
 
125 125
 
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 	 * @static
134 134
 	 * @return  int 						count of updated records.
135 135
 	 */
136
-	public static function update_to_active( $messenger, $message_type ) {
136
+	public static function update_to_active($messenger, $message_type) {
137 137
 		return EEM_Message_Template_Group::instance()->update(
138
-			array( 'MTP_is_active' => 1 ),
138
+			array('MTP_is_active' => 1),
139 139
 			array(
140 140
 				array(
141 141
 					'MTP_messenger' => $messenger, 'MTP_message_type' => $message_type
@@ -158,7 +158,7 @@  discard block
 block discarded – undo
158 158
 	 *
159 159
 	 * @return int  count of updated records.
160 160
 	 */
161
-	public static function update_to_inactive( $messenger = '', $message_type = '' ) {
161
+	public static function update_to_inactive($messenger = '', $message_type = '') {
162 162
 		return EEM_Message_Template_Group::instance()->deactivate_message_template_groups_for(
163 163
 			$messenger,
164 164
 			$message_type
@@ -177,7 +177,7 @@  discard block
 block discarded – undo
177 177
 		self::_set_autoloader();
178 178
 		//get all installed messengers and message_types
179 179
 		/** @type EE_Messages $messages_controller */
180
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
180
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
181 181
 		$installed_message_objects = $messages_controller->get_installed($type);
182 182
 		return $installed_message_objects;
183 183
 	}
@@ -211,38 +211,38 @@  discard block
 block discarded – undo
211 211
 		$context = 'admin',
212 212
 		$merged = false
213 213
 	) {
214
-		$messenger_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $messenger ) ) );
215
-		$mt_name = str_replace( ' ', '_', ucwords( str_replace( '_', ' ', $message_type ) ) );
214
+		$messenger_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $messenger)));
215
+		$mt_name = str_replace(' ', '_', ucwords(str_replace('_', ' ', $message_type)));
216 216
 
217 217
 		//convert slug to object
218
-		$messenger = self::messenger_obj( $messenger );
218
+		$messenger = self::messenger_obj($messenger);
219 219
 
220 220
 		//validate class for getting our list of shortcodes
221
-		$classname = 'EE_Messages_' . $messenger_name . '_' . $mt_name . '_Validator';
222
-		if ( !class_exists( $classname ) ) {
223
-			$msg[] = __( 'The Validator class was unable to load', 'event_espresso');
221
+		$classname = 'EE_Messages_'.$messenger_name.'_'.$mt_name.'_Validator';
222
+		if ( ! class_exists($classname)) {
223
+			$msg[] = __('The Validator class was unable to load', 'event_espresso');
224 224
 			$msg[] = sprintf(
225 225
 				__('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'),
226 226
 				$classname
227 227
 			);
228
-			throw new EE_Error( implode( '||', $msg ) );
228
+			throw new EE_Error(implode('||', $msg));
229 229
 		}
230 230
 		/** @type EE_Messages_Validator $_VLD */
231
-		$_VLD = new $classname( array(), $context );
231
+		$_VLD = new $classname(array(), $context);
232 232
 		$valid_shortcodes = $_VLD->get_validators();
233 233
 
234 234
 		//let's make sure we're only getting the shortcode part of the validators
235 235
 		$shortcodes = array();
236
-		foreach( $valid_shortcodes as $field => $validators ) {
236
+		foreach ($valid_shortcodes as $field => $validators) {
237 237
 			$shortcodes[$field] = $validators['shortcodes'];
238 238
 		}
239 239
 		$valid_shortcodes = $shortcodes;
240 240
 
241 241
 		//if not all fields let's make sure we ONLY include the shortcodes for the specified fields.
242
-		if ( ! empty( $fields ) ) {
242
+		if ( ! empty($fields)) {
243 243
 			$specified_shortcodes = array();
244
-			foreach ( $fields as $field ) {
245
-				if ( isset( $valid_shortcodes[$field] ) )
244
+			foreach ($fields as $field) {
245
+				if (isset($valid_shortcodes[$field]))
246 246
 					$specified_shortcodes[$field] = $valid_shortcodes[$field];
247 247
 			}
248 248
 			$valid_shortcodes = $specified_shortcodes;
@@ -250,16 +250,16 @@  discard block
 block discarded – undo
250 250
 
251 251
 
252 252
 		//if not merged then let's replace the fields with the localized fields
253
-		if ( ! $merged ) {
253
+		if ( ! $merged) {
254 254
 			//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.
255 255
 			$field_settings = $messenger->get_template_fields();
256 256
 			$localized = array();
257
-			foreach ( $valid_shortcodes as $field => $shortcodes ) {
257
+			foreach ($valid_shortcodes as $field => $shortcodes) {
258 258
 				//get localized field label
259
-				if ( isset( $field_settings[$field] ) ) {
259
+				if (isset($field_settings[$field])) {
260 260
 					//possible that this is used as a main field.
261
-					if ( empty( $field_settings[$field] ) ) {
262
-						if ( isset( $field_settings['extra'][$field] ) ) {
261
+					if (empty($field_settings[$field])) {
262
+						if (isset($field_settings['extra'][$field])) {
263 263
 							$_field = $field_settings['extra'][$field]['main']['label'];
264 264
 						} else {
265 265
 							$_field = $field;
@@ -267,10 +267,10 @@  discard block
 block discarded – undo
267 267
 					} else {
268 268
 						$_field = $field_settings[$field]['label'];
269 269
 					}
270
-				} else if ( isset( $field_settings['extra'] ) ) {
270
+				} else if (isset($field_settings['extra'])) {
271 271
 					//loop through extra "main fields" and see if any of their children have our field
272
-					foreach ( $field_settings['extra'] as $main_field => $fields ) {
273
-						if ( isset( $fields[$field] ) )
272
+					foreach ($field_settings['extra'] as $main_field => $fields) {
273
+						if (isset($fields[$field]))
274 274
 							$_field = $fields[$field]['label'];
275 275
 						else
276 276
 							$_field = $field;
@@ -278,8 +278,8 @@  discard block
 block discarded – undo
278 278
 				} else {
279 279
 					$_field = $field;
280 280
 				}
281
-				if ( isset( $_field )) {
282
-					$localized[ $_field ] = $shortcodes;
281
+				if (isset($_field)) {
282
+					$localized[$_field] = $shortcodes;
283 283
 				}
284 284
 			}
285 285
 			$valid_shortcodes = $localized;
@@ -287,11 +287,11 @@  discard block
 block discarded – undo
287 287
 
288 288
 
289 289
 		//if $merged then let's merge all the shortcodes into one list NOT indexed by field.
290
-		if ( $merged ) {
290
+		if ($merged) {
291 291
 			$merged_codes = array();
292
-			foreach ( $valid_shortcodes as $field => $shortcode ) {
293
-				foreach ( $shortcode as $code => $label ) {
294
-					if ( isset( $merged_codes[$code] ) )
292
+			foreach ($valid_shortcodes as $field => $shortcode) {
293
+				foreach ($shortcode as $code => $label) {
294
+					if (isset($merged_codes[$code]))
295 295
 						continue;
296 296
 					else
297 297
 						$merged_codes[$code] = $label;
@@ -313,11 +313,11 @@  discard block
 block discarded – undo
313 313
 	 * @throws \EE_Error
314 314
 	 * @return EE_Messenger
315 315
 	 */
316
-	public static function messenger_obj( $messenger ) {
316
+	public static function messenger_obj($messenger) {
317 317
 		/** @type EE_Messages $messages_controller */
318
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
318
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
319 319
 		$installed_messengers = $messages_controller->get_installed_messengers();
320
-		return isset( $installed_messengers[ $messenger ] ) ? $installed_messengers[ $messenger ] : null;
320
+		return isset($installed_messengers[$messenger]) ? $installed_messengers[$messenger] : null;
321 321
 	}
322 322
 
323 323
 
@@ -330,11 +330,11 @@  discard block
 block discarded – undo
330 330
 	 * @throws \EE_Error
331 331
 	 * @return EE_message_type
332 332
 	 */
333
-	public static function message_type_obj( $message_type ) {
333
+	public static function message_type_obj($message_type) {
334 334
 		/** @type EE_Messages $messages_controller */
335
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
335
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
336 336
 		$installed_message_types = $messages_controller->get_installed_message_types();
337
-		return isset( $installed_message_types[ $message_type ] ) ? $installed_message_types[ $message_type ] : null;
337
+		return isset($installed_message_types[$message_type]) ? $installed_message_types[$message_type] : null;
338 338
 	}
339 339
 
340 340
 
@@ -348,12 +348,12 @@  discard block
 block discarded – undo
348 348
 	 * @param  string   $message_type message type to check for.
349 349
 	 * @return boolean
350 350
 	 */
351
-	public static function is_mt_active( $message_type ) {
351
+	public static function is_mt_active($message_type) {
352 352
 		self::_set_autoloader();
353 353
 		/** @type EE_Messages $messages_controller */
354
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
354
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
355 355
 		$active_mts = $messages_controller->get_active_message_types();
356
-		return in_array( $message_type, $active_mts );
356
+		return in_array($message_type, $active_mts);
357 357
 	}
358 358
 
359 359
 
@@ -366,12 +366,12 @@  discard block
 block discarded – undo
366 366
 	 * @param  string  $messenger slug for messenger to check.
367 367
 	 * @return boolean
368 368
 	 */
369
-	public static function is_messenger_active( $messenger ) {
369
+	public static function is_messenger_active($messenger) {
370 370
 		self::_set_autoloader();
371 371
 		/** @type EE_Messages $messages_controller */
372
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
372
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
373 373
 		$active_messengers = $messages_controller->get_active_messengers();
374
-		return isset( $active_messengers[ $messenger ] );
374
+		return isset($active_messengers[$messenger]);
375 375
 	}
376 376
 
377 377
 
@@ -387,7 +387,7 @@  discard block
 block discarded – undo
387 387
 	public static function get_active_messengers_in_db() {
388 388
 		return apply_filters(
389 389
 			'FHEE__EEH_MSG_Template__get_active_messengers_in_db',
390
-			get_option( 'ee_active_messengers', array() )
390
+			get_option('ee_active_messengers', array())
391 391
 		);
392 392
 	}
393 393
 
@@ -403,8 +403,8 @@  discard block
 block discarded – undo
403 403
 	 *
404 404
 	 * @return bool FALSE if not updated, TRUE if updated.
405 405
 	 */
406
-	public static function update_active_messengers_in_db( $data_to_save ) {
407
-		return update_option( 'ee_active_messengers', $data_to_save );
406
+	public static function update_active_messengers_in_db($data_to_save) {
407
+		return update_option('ee_active_messengers', $data_to_save);
408 408
 	}
409 409
 
410 410
 
@@ -428,34 +428,34 @@  discard block
 block discarded – undo
428 428
 		$sending_messenger = ''
429 429
 	) {
430 430
 		//first determine if the url can be to the EE_Message object.
431
-		if ( ! $message_type->always_generate() ) {
432
-			return EEH_MSG_Template::generate_browser_trigger( $message );
431
+		if ( ! $message_type->always_generate()) {
432
+			return EEH_MSG_Template::generate_browser_trigger($message);
433 433
 		}
434 434
 
435 435
 		//if $registration object is not valid then exit early because there's nothing that can be generated.
436
-		if ( ! $registration instanceof EE_Registration ) {
436
+		if ( ! $registration instanceof EE_Registration) {
437 437
 			throw new EE_Error(
438
-				__( 'Incoming value for registration is not a valid EE_Registration object.', 'event_espresso' )
438
+				__('Incoming value for registration is not a valid EE_Registration object.', 'event_espresso')
439 439
 			);
440 440
 		}
441 441
 
442 442
 		//validate given context
443 443
 		$contexts = $message_type->get_contexts();
444
-		if ( $message->context() !== '' && ! isset( $contexts[$message->context()] ) ) {
444
+		if ($message->context() !== '' && ! isset($contexts[$message->context()])) {
445 445
 			throw new EE_Error(
446 446
 				sprintf(
447
-					__( 'The context %s is not a valid context for %s.', 'event_espresso' ),
447
+					__('The context %s is not a valid context for %s.', 'event_espresso'),
448 448
 					$message->context(),
449
-					get_class( $message_type )
449
+					get_class($message_type)
450 450
 				)
451 451
 			);
452 452
 		}
453 453
 
454 454
 		//valid sending messenger but only if sending messenger set.  Otherwise generating messenger is used.
455
-		if ( ! empty( $sending_messenger ) ) {
455
+		if ( ! empty($sending_messenger)) {
456 456
 			$with_messengers = $message_type->with_messengers();
457
-			if ( ! isset( $with_messengers[$message->messenger()] )
458
-			     || ! in_array( $sending_messenger, $with_messengers[$message->messenger()] ) ) {
457
+			if ( ! isset($with_messengers[$message->messenger()])
458
+			     || ! in_array($sending_messenger, $with_messengers[$message->messenger()])) {
459 459
 				throw new EE_Error(
460 460
 					sprintf(
461 461
 						__(
@@ -463,7 +463,7 @@  discard block
 block discarded – undo
463 463
 							'event_espresso'
464 464
 						),
465 465
 						$sending_messenger,
466
-						get_class( $message_type )
466
+						get_class($message_type)
467 467
 					)
468 468
 				);
469 469
 			}
@@ -486,14 +486,14 @@  discard block
 block discarded – undo
486 486
 	 * @param EE_Message $message
487 487
 	 * @return string.
488 488
 	 */
489
-	public static function generate_browser_trigger( EE_Message $message ) {
489
+	public static function generate_browser_trigger(EE_Message $message) {
490 490
 		$query_args = array(
491 491
 			'ee' => 'msg_browser_trigger',
492 492
 			'token' => $message->MSG_token()
493 493
 		);
494 494
 		return apply_filters(
495 495
 			'FHEE__EEH_MSG_Template__generate_browser_trigger',
496
-			add_query_arg( $query_args, site_url() ),
496
+			add_query_arg($query_args, site_url()),
497 497
 			$message
498 498
 		);
499 499
 	}
@@ -508,7 +508,7 @@  discard block
 block discarded – undo
508 508
 	 * @param EE_Message $message
509 509
 	 * @return string
510 510
 	 */
511
-	public static function generate_error_display_trigger( EE_Message $message ) {
511
+	public static function generate_error_display_trigger(EE_Message $message) {
512 512
 		return apply_filters(
513 513
 			'FHEE__EEH_MSG_Template__generate_error_display_trigger',
514 514
 			add_query_arg(
@@ -558,7 +558,7 @@  discard block
 block discarded – undo
558 558
 			'GRP_ID' => $message_template_group,
559 559
 			'id' => $data_id
560 560
 			);
561
-		$url = add_query_arg( $query_args, get_site_url() );
561
+		$url = add_query_arg($query_args, get_site_url());
562 562
 
563 563
 		//made it here so now we can just get the url and filter it.  Filtered globally and by message type.
564 564
 		$url = apply_filters(
@@ -586,9 +586,9 @@  discard block
 block discarded – undo
586 586
 	 * @param string $type  What action to return.
587 587
 	 * @return string
588 588
 	 */
589
-	public static function get_message_action_icon( $type ) {
589
+	public static function get_message_action_icon($type) {
590 590
 		$action_icons = self::get_message_action_icons();
591
-		return isset( $action_icons[ $type ] ) ? $action_icons[ $type ] : '';
591
+		return isset($action_icons[$type]) ? $action_icons[$type] : '';
592 592
 	}
593 593
 
594 594
 
@@ -600,34 +600,34 @@  discard block
 block discarded – undo
600 600
 	 * @return array
601 601
 	 */
602 602
 	public static function get_message_action_icons() {
603
-		return apply_filters( 'FHEE__EEH_MSG_Template__message_action_icons',
603
+		return apply_filters('FHEE__EEH_MSG_Template__message_action_icons',
604 604
 			array(
605 605
 				'view' => array(
606
-					'label' => __( 'View Message', 'event_espresso' ),
606
+					'label' => __('View Message', 'event_espresso'),
607 607
 					'css_class' => 'dashicons dashicons-welcome-view-site',
608 608
 				),
609 609
 				'error' => array(
610
-					'label' => __( 'View Error Message', 'event_espresso' ),
610
+					'label' => __('View Error Message', 'event_espresso'),
611 611
 					'css_class' => 'dashicons dashicons-info',
612 612
 				),
613 613
 				'see_notifications_for' => array(
614
-					'label' => __( 'View Related Messages', 'event_espresso' ),
614
+					'label' => __('View Related Messages', 'event_espresso'),
615 615
 					'css_class' => 'dashicons dashicons-images-alt',
616 616
 				),
617 617
 				'generate_now' => array(
618
-					'label' => __( 'Generate the message now.', 'event_espresso' ),
618
+					'label' => __('Generate the message now.', 'event_espresso'),
619 619
 					'css_class' => 'dashicons dashicons-admin-tools',
620 620
 				),
621 621
 				'send_now' => array(
622
-					'label' => __( 'Send Immediately', 'event_espresso' ),
622
+					'label' => __('Send Immediately', 'event_espresso'),
623 623
 					'css_class' => 'dashicons dashicons-controls-forward',
624 624
 				),
625 625
 				'queue_for_resending' => array(
626
-					'label' => __( 'Queue for Resending', 'event_espresso' ),
626
+					'label' => __('Queue for Resending', 'event_espresso'),
627 627
 					'css_class' => 'dashicons dashicons-controls-repeat',
628 628
 				),
629 629
 				'view_transaction' => array(
630
-					'label' => __( 'View related Transaction', 'event_espresso' ),
630
+					'label' => __('View related Transaction', 'event_espresso'),
631 631
 					'css_class' => 'dashicons dashicons-cart',
632 632
 				)
633 633
 			)
@@ -646,9 +646,9 @@  discard block
 block discarded – undo
646 646
 	 *
647 647
 	 * @return string
648 648
 	 */
649
-	public static function get_message_action_url( $type, EE_Message $message = null, $query_params = array() ) {
650
-		$action_urls = self::get_message_action_urls( $message, $query_params );
651
-		return isset( $action_urls[ $type ] )  ? $action_urls[ $type ] : '';
649
+	public static function get_message_action_url($type, EE_Message $message = null, $query_params = array()) {
650
+		$action_urls = self::get_message_action_urls($message, $query_params);
651
+		return isset($action_urls[$type]) ? $action_urls[$type] : '';
652 652
 	}
653 653
 
654 654
 
@@ -662,15 +662,15 @@  discard block
 block discarded – undo
662 662
 	 *
663 663
 	 * @return array
664 664
 	 */
665
-	public static function get_message_action_urls( EE_Message $message = null, $query_params = array() ) {
666
-		EE_Registry::instance()->load_helper( 'URL' );
665
+	public static function get_message_action_urls(EE_Message $message = null, $query_params = array()) {
666
+		EE_Registry::instance()->load_helper('URL');
667 667
 		//if $message is not an instance of EE_Message then let's just do a dummy.
668
-		$message = empty( $message ) ? EE_Message_Factory::create() : $message;
669
-		$action_urls =  apply_filters(
668
+		$message = empty($message) ? EE_Message_Factory::create() : $message;
669
+		$action_urls = apply_filters(
670 670
 			'FHEE__EEH_MSG_Template__get_message_action_url',
671 671
 			array(
672
-				'view' => EEH_MSG_Template::generate_browser_trigger( $message ),
673
-				'error' => EEH_MSG_Template::generate_error_display_trigger( $message ),
672
+				'view' => EEH_MSG_Template::generate_browser_trigger($message),
673
+				'error' => EEH_MSG_Template::generate_error_display_trigger($message),
674 674
 				'see_notifications_for' => EEH_URL::add_query_args_and_nonce(
675 675
 					array_merge(
676 676
 						array(
@@ -680,7 +680,7 @@  discard block
 block discarded – undo
680 680
 						),
681 681
 						$query_params
682 682
 					),
683
-					admin_url( 'admin.php' )
683
+					admin_url('admin.php')
684 684
 				),
685 685
 				'generate_now' => EEH_URL::add_query_args_and_nonce(
686 686
 					array(
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 						'action' => 'generate_now',
689 689
 						'MSG_ID' => $message->ID()
690 690
 					),
691
-					admin_url( 'admin.php' )
691
+					admin_url('admin.php')
692 692
 				),
693 693
 				'send_now' => EEH_URL::add_query_args_and_nonce(
694 694
 					array(
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 						'action' => 'send_now',
697 697
 						'MSG_ID' => $message->ID()
698 698
 					),
699
-					admin_url( 'admin.php' )
699
+					admin_url('admin.php')
700 700
 				),
701 701
 				'queue_for_resending' => EEH_URL::add_query_args_and_nonce(
702 702
 					array(
@@ -704,7 +704,7 @@  discard block
 block discarded – undo
704 704
 						'action' => 'queue_for_resending',
705 705
 						'MSG_ID' => $message->ID()
706 706
 					),
707
-					admin_url( 'admin.php' )
707
+					admin_url('admin.php')
708 708
 				),
709 709
 			)
710 710
 		);
@@ -722,7 +722,7 @@  discard block
 block discarded – undo
722 722
 					'action' => 'view_transaction',
723 723
 					'TXN_ID' => $message->TXN_ID()
724 724
 				),
725
-				admin_url( 'admin.php' )
725
+				admin_url('admin.php')
726 726
 			);
727 727
 		} else {
728 728
 			$action_urls['view_transaction'] = '';
@@ -743,24 +743,24 @@  discard block
 block discarded – undo
743 743
 	 *
744 744
 	 * @return string
745 745
 	 */
746
-	public static function get_message_action_link( $type, EE_Message $message = null, $query_params = array() ) {
747
-		$url = EEH_MSG_Template::get_message_action_url( $type, $message, $query_params );
748
-		$icon_css = EEH_MSG_Template::get_message_action_icon( $type );
749
-		if ( empty( $url ) || empty( $icon_css ) || ! isset( $icon_css['css_class'] ) ) {
746
+	public static function get_message_action_link($type, EE_Message $message = null, $query_params = array()) {
747
+		$url = EEH_MSG_Template::get_message_action_url($type, $message, $query_params);
748
+		$icon_css = EEH_MSG_Template::get_message_action_icon($type);
749
+		if (empty($url) || empty($icon_css) || ! isset($icon_css['css_class'])) {
750 750
 			return '';
751 751
 		}
752 752
 
753 753
 		$icon_css['css_class'] .= esc_attr(
754 754
 			apply_filters(
755 755
 				'FHEE__EEH_MSG_Template__get_message_action_link__icon_css_class',
756
-				' js-ee-message-action-link ee-message-action-link-' . $type,
756
+				' js-ee-message-action-link ee-message-action-link-'.$type,
757 757
 				$type,
758 758
 				$message,
759 759
 				$query_params
760 760
 			)
761 761
 		);
762 762
 
763
-		return '<a href="' . $url . '"><span class="' . esc_attr( $icon_css['css_class'] ) . '"></span></a>';
763
+		return '<a href="'.$url.'"><span class="'.esc_attr($icon_css['css_class']).'"></span></a>';
764 764
 
765 765
 	}
766 766
 
@@ -798,9 +798,9 @@  discard block
 block discarded – undo
798 798
 	 * @param $reg_status
799 799
 	 * @return string
800 800
 	 */
801
-	public static function convert_reg_status_to_message_type( $reg_status ) {
801
+	public static function convert_reg_status_to_message_type($reg_status) {
802 802
 		$reg_status_array = self::reg_status_to_message_type_array();
803
-		return isset( $reg_status_array[$reg_status] ) ? $reg_status_array[$reg_status] : '';
803
+		return isset($reg_status_array[$reg_status]) ? $reg_status_array[$reg_status] : '';
804 804
 	}
805 805
 
806 806
 
@@ -834,9 +834,9 @@  discard block
 block discarded – undo
834 834
 	 * @param $payment_status
835 835
 	 * @return string
836 836
 	 */
837
-	public static function convert_payment_status_to_message_type( $payment_status ) {
837
+	public static function convert_payment_status_to_message_type($payment_status) {
838 838
 		$payment_status_array = self::payment_status_to_message_type_array();
839
-		return isset( $payment_status_array[$payment_status] ) ? $payment_status_array[$payment_status] : '';
839
+		return isset($payment_status_array[$payment_status]) ? $payment_status_array[$payment_status] : '';
840 840
 	}
841 841
 
842 842
 
@@ -847,32 +847,32 @@  discard block
 block discarded – undo
847 847
 	 *
848 848
 	 * @return EE_Messages_Template_Pack
849 849
 	 */
850
-	public static function get_template_pack( $template_pack_name ) {
851
-		if ( ! self::$_template_pack_collection instanceof EE_Object_Collection ) {
850
+	public static function get_template_pack($template_pack_name) {
851
+		if ( ! self::$_template_pack_collection instanceof EE_Object_Collection) {
852 852
 			self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection();
853 853
 		}
854 854
 
855 855
 		//first see if in collection already
856
-		$template_pack = self::$_template_pack_collection->get_by_name( $template_pack_name );
856
+		$template_pack = self::$_template_pack_collection->get_by_name($template_pack_name);
857 857
 
858
-		if ( $template_pack instanceof EE_Messages_Template_Pack ) {
858
+		if ($template_pack instanceof EE_Messages_Template_Pack) {
859 859
 			return $template_pack;
860 860
 		}
861 861
 
862 862
 		//nope...let's get it.
863 863
 		//not set yet so let's attempt to get it.
864
-		$pack_class_name = 'EE_Messages_Template_Pack_' . str_replace(
864
+		$pack_class_name = 'EE_Messages_Template_Pack_'.str_replace(
865 865
 				' ',
866 866
 				'_',
867 867
 				ucwords(
868
-					str_replace( '_', ' ', $template_pack_name )
868
+					str_replace('_', ' ', $template_pack_name)
869 869
 				)
870 870
 			);
871
-		if ( ! class_exists( $pack_class_name ) && $template_pack_name !== 'default' ) {
872
-			return self::get_template_pack( 'default' );
871
+		if ( ! class_exists($pack_class_name) && $template_pack_name !== 'default') {
872
+			return self::get_template_pack('default');
873 873
 		} else {
874 874
 			$template_pack = new $pack_class_name;
875
-			self::$_template_pack_collection->add( $template_pack );
875
+			self::$_template_pack_collection->add($template_pack);
876 876
 			return $template_pack;
877 877
 		}
878 878
 	}
@@ -890,26 +890,26 @@  discard block
 block discarded – undo
890 890
 	 */
891 891
 	public static function get_template_pack_collection() {
892 892
 		$new_collection = false;
893
-		if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection ) {
893
+		if ( ! self::$_template_pack_collection instanceof EE_Messages_Template_Pack_Collection) {
894 894
 			self::$_template_pack_collection = new EE_Messages_Template_Pack_Collection();
895 895
 			$new_collection = true;
896 896
 		}
897 897
 
898 898
 		//glob the defaults directory for messages
899
-		$templates = glob( EE_LIBRARIES . 'messages/defaults/*', GLOB_ONLYDIR );
900
-		foreach( $templates as $template_path ) {
899
+		$templates = glob(EE_LIBRARIES.'messages/defaults/*', GLOB_ONLYDIR);
900
+		foreach ($templates as $template_path) {
901 901
 			//grab folder name
902
-			$template = basename( $template_path );
902
+			$template = basename($template_path);
903 903
 
904
-			if ( ! $new_collection ) {
904
+			if ( ! $new_collection) {
905 905
 				//already have it?
906
-				if ( self::$_template_pack_collection->get_by_name( $template ) instanceof EE_Messages_Template_Pack ) {
906
+				if (self::$_template_pack_collection->get_by_name($template) instanceof EE_Messages_Template_Pack) {
907 907
 					continue;
908 908
 				}
909 909
 			}
910 910
 
911 911
 			//setup classname.
912
-			$template_pack_class_name = 'EE_Messages_Template_Pack_' . str_replace(
912
+			$template_pack_class_name = 'EE_Messages_Template_Pack_'.str_replace(
913 913
 					' ',
914 914
 					'_',
915 915
 					ucwords(
@@ -920,20 +920,20 @@  discard block
 block discarded – undo
920 920
 						)
921 921
 					)
922 922
 				);
923
-			if ( ! class_exists( $template_pack_class_name ) ) {
923
+			if ( ! class_exists($template_pack_class_name)) {
924 924
 				continue;
925 925
 			}
926
-			self::$_template_pack_collection->add( new $template_pack_class_name );
926
+			self::$_template_pack_collection->add(new $template_pack_class_name);
927 927
 		}
928 928
 
929 929
 		/**
930 930
 		 * Filter for plugins to add in any additional template packs
931 931
 		 * Note the filter name here is for backward compat, this used to be found in EED_Messages.
932 932
 		 */
933
-		$additional_template_packs = apply_filters( 'FHEE__EED_Messages__get_template_packs__template_packs', array() );
934
-		foreach ( (array) $additional_template_packs as $template_pack ) {
935
-			if ( ! self::$_template_pack_collection->contains($template_pack ) ) {
936
-				self::$_template_pack_collection->add( $template_pack );
933
+		$additional_template_packs = apply_filters('FHEE__EED_Messages__get_template_packs__template_packs', array());
934
+		foreach ((array) $additional_template_packs as $template_pack) {
935
+			if ( ! self::$_template_pack_collection->contains($template_pack)) {
936
+				self::$_template_pack_collection->add($template_pack);
937 937
 			}
938 938
 		}
939 939
 		return self::$_template_pack_collection;
Please login to merge, or discard this patch.
core/libraries/plugin_api/EE_Register_Message_Type.lib.php 1 patch
Spacing   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -50,33 +50,33 @@  discard block
 block discarded – undo
50 50
 	 * @throws \EE_Error
51 51
 	 * }
52 52
 	 */
53
-    public static function register( $mt_name = NULL, $setup_args = array() ) {
53
+    public static function register($mt_name = NULL, $setup_args = array()) {
54 54
 
55 55
         //required fields MUST be present, so let's make sure they are.
56 56
         if (
57
-			! isset( $mt_name )
58
-			|| ! is_array( $setup_args )
59
-			|| empty( $setup_args['mtfilename'] ) || empty( $setup_args['autoloadpaths'] )
60
-		){
57
+			! isset($mt_name)
58
+			|| ! is_array($setup_args)
59
+			|| empty($setup_args['mtfilename']) || empty($setup_args['autoloadpaths'])
60
+		) {
61 61
             throw new EE_Error(
62
-				__( 'In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso' )
62
+				__('In order to register a message type with EE_Register_Message_Type::register, you must include a unique name for the message type, plus an array containing the following keys: "mtfilename", "autoloadpaths"', 'event_espresso')
63 63
 			);
64 64
 		}
65 65
 
66 66
 		//make sure we don't register twice
67
-		if( isset( self::$_ee_message_type_registry[ $mt_name ] ) ){
67
+		if (isset(self::$_ee_message_type_registry[$mt_name])) {
68 68
 			return;
69 69
 		}
70 70
 
71 71
         //make sure this was called in the right place!
72 72
         if (
73
-			! did_action( 'EE_Brewing_Regular___messages_caf' )
74
-			|| did_action( 'AHEE__EE_System__perform_activations_upgrades_and_migrations' )
73
+			! did_action('EE_Brewing_Regular___messages_caf')
74
+			|| did_action('AHEE__EE_System__perform_activations_upgrades_and_migrations')
75 75
 		) {
76 76
             EE_Error::doing_it_wrong(
77 77
 				__METHOD__,
78 78
 				sprintf(
79
-					__('A message type named "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.','event_espresso'),
79
+					__('A message type named "%s" has been attempted to be registered with the EE Messages System.  It may or may not work because it should be only called on the "EE_Brewing_Regular___messages_caf" hook.', 'event_espresso'),
80 80
 					$mt_name
81 81
 				),
82 82
 				'4.3.0'
@@ -84,47 +84,47 @@  discard block
 block discarded – undo
84 84
         }
85 85
 
86 86
 		//setup $__ee_message_type_registry array from incoming values.
87
-		self::$_ee_message_type_registry[ $mt_name ] = array(
87
+		self::$_ee_message_type_registry[$mt_name] = array(
88 88
 			'mtfilename' => (string) $setup_args['mtfilename'],
89 89
 			'autoloadpaths' => (array) $setup_args['autoloadpaths'],
90
-			'messengers_to_activate_with' => ! empty( $setup_args['messengers_to_activate_with'] )
90
+			'messengers_to_activate_with' => ! empty($setup_args['messengers_to_activate_with'])
91 91
 				? (array) $setup_args['messengers_to_activate_with']
92 92
 				: array(),
93
-			'messengers_to_validate_with' => ! empty( $setup_args['messengers_to_validate_with'] )
93
+			'messengers_to_validate_with' => ! empty($setup_args['messengers_to_validate_with'])
94 94
 				? (array) $setup_args['messengers_to_validate_with']
95 95
 				: array(),
96
-			'force_activation' => ! empty( $setup_args['force_activation'] )
96
+			'force_activation' => ! empty($setup_args['force_activation'])
97 97
 				? (bool) $setup_args['force_activation']
98 98
 				: array()
99 99
 		);
100 100
 		//add filters
101 101
 		add_filter(
102 102
 			'FHEE__EED_Messages___set_messages_paths___MSG_PATHS',
103
-			array( 'EE_Register_Message_Type', 'register_msgs_autoload_paths' ),
103
+			array('EE_Register_Message_Type', 'register_msgs_autoload_paths'),
104 104
 			10
105 105
 		);
106 106
 		add_filter(
107 107
 			'FHEE__EE_messages__get_installed__messagetype_files',
108
-			array( 'EE_Register_Message_Type', 'register_messagetype_files' ),
108
+			array('EE_Register_Message_Type', 'register_messagetype_files'),
109 109
 			10,
110 110
 			1
111 111
 		);
112 112
 		add_filter(
113 113
 			'FHEE__EE_messenger__get_default_message_types__default_types',
114
-			array( 'EE_Register_Message_Type', 'register_messengers_to_activate_mt_with' ),
114
+			array('EE_Register_Message_Type', 'register_messengers_to_activate_mt_with'),
115 115
 			10,
116 116
 			2
117 117
 		);
118 118
 		add_filter(
119 119
 			'FHEE__EE_messenger__get_valid_message_types__valid_types',
120
-			array( 'EE_Register_Message_Type', 'register_messengers_to_validate_mt_with' ),
120
+			array('EE_Register_Message_Type', 'register_messengers_to_validate_mt_with'),
121 121
 			10,
122 122
 			2
123 123
 		);
124 124
 		//actions
125 125
 		add_action(
126 126
 			'AHEE__EE_Addon__initialize_default_data__begin',
127
-			array( 'EE_Register_Message_Type', 'set_defaults' )
127
+			array('EE_Register_Message_Type', 'set_defaults')
128 128
 		);
129 129
 	}
130 130
 
@@ -138,12 +138,12 @@  discard block
 block discarded – undo
138 138
     	EE_Registry::instance()->load_helper('Activation');
139 139
     	EEH_Activation::generate_default_message_templates();
140 140
 		/** @type EE_Messages $messages_controller */
141
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
141
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
142 142
 		//for any message types with force activation, let's ensure they are activated
143
-		foreach ( self::$_ee_message_type_registry as $message_type_name => $settings ) {
144
-			if ( $settings['force_activation'] ) {
145
-				foreach ( $settings['messengers_to_activate_with'] as $messenger ) {
146
-					$messages_controller->ensure_message_type_is_active( $message_type_name, $messenger );
143
+		foreach (self::$_ee_message_type_registry as $message_type_name => $settings) {
144
+			if ($settings['force_activation']) {
145
+				foreach ($settings['messengers_to_activate_with'] as $messenger) {
146
+					$messages_controller->ensure_message_type_is_active($message_type_name, $messenger);
147 147
 				}
148 148
 			}
149 149
 		}
@@ -159,19 +159,19 @@  discard block
 block discarded – undo
159 159
      * @param string  $message_type_name the name for the message type that was previously registered
160 160
      * @return void
161 161
      */
162
-    public static function deregister( $message_type_name = NULL ) {
163
-    	if ( ! empty( self::$_ee_message_type_registry[$message_type_name] ) ) {
162
+    public static function deregister($message_type_name = NULL) {
163
+    	if ( ! empty(self::$_ee_message_type_registry[$message_type_name])) {
164 164
 			//let's make sure that we remove any place this message type was made active
165
-			EE_Registry::instance()->load_helper( 'MSG_Template' );
165
+			EE_Registry::instance()->load_helper('MSG_Template');
166 166
 			$active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
167
-			foreach( $active_messengers as $messenger => $settings ) {
168
-				if ( !empty( $settings['settings'][$messenger . '-message_types'][$message_type_name] ) ) {
169
-					unset( $active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type_name] );
167
+			foreach ($active_messengers as $messenger => $settings) {
168
+				if ( ! empty($settings['settings'][$messenger.'-message_types'][$message_type_name])) {
169
+					unset($active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type_name]);
170 170
 				}
171 171
 			}
172
-			EEH_MSG_Template::update_to_inactive( '', $message_type_name );
173
-			EEH_MSG_Template::update_active_messengers_in_db( $active_messengers );
174
-    		unset( self::$_ee_message_type_registry[$message_type_name] );
172
+			EEH_MSG_Template::update_to_inactive('', $message_type_name);
173
+			EEH_MSG_Template::update_active_messengers_in_db($active_messengers);
174
+    		unset(self::$_ee_message_type_registry[$message_type_name]);
175 175
         }
176 176
     }
177 177
 
@@ -185,12 +185,12 @@  discard block
 block discarded – undo
185 185
      * @param  array  $messagetype_files The current array of message type file names
186 186
      * @return  array                                 Array of message type file names
187 187
      */
188
-    public static function register_messagetype_files( $messagetype_files ) {
189
-        if ( empty( self::$_ee_message_type_registry ) ) {
188
+    public static function register_messagetype_files($messagetype_files) {
189
+        if (empty(self::$_ee_message_type_registry)) {
190 190
             return $messagetype_files;
191 191
 		}
192
-        foreach ( self::$_ee_message_type_registry as $mt_reg ) {
193
-            if ( empty( $mt_reg['mtfilename' ] ) ) {
192
+        foreach (self::$_ee_message_type_registry as $mt_reg) {
193
+            if (empty($mt_reg['mtfilename'])) {
194 194
                 continue;
195 195
 			}
196 196
             $messagetype_files[] = $mt_reg['mtfilename'];
@@ -210,13 +210,13 @@  discard block
 block discarded – undo
210 210
      * @param array $paths array of paths to be checked by EE_Messages autoloader.
211 211
      * @return array
212 212
      */
213
-    public static function register_msgs_autoload_paths( $paths  ) {
214
-        if ( ! empty( self::$_ee_message_type_registry ) ) {
215
-            foreach ( self::$_ee_message_type_registry as $mt_reg ) {
216
-                if ( empty( $mt_reg['autoloadpaths'] ) ) {
213
+    public static function register_msgs_autoload_paths($paths) {
214
+        if ( ! empty(self::$_ee_message_type_registry)) {
215
+            foreach (self::$_ee_message_type_registry as $mt_reg) {
216
+                if (empty($mt_reg['autoloadpaths'])) {
217 217
                     continue;
218 218
 				}
219
-                $paths = array_merge( $paths, $mt_reg['autoloadpaths'] );
219
+                $paths = array_merge($paths, $mt_reg['autoloadpaths']);
220 220
             }
221 221
         }
222 222
         return $paths;
@@ -235,18 +235,18 @@  discard block
 block discarded – undo
235 235
      * @param  EE_Messenger $messenger      The EE_messenger the filter is called from.
236 236
      * @return array
237 237
      */
238
-    public static function register_messengers_to_activate_mt_with( $default_types, EE_Messenger $messenger ) {
239
-        if ( empty( self::$_ee_message_type_registry ) ) {
238
+    public static function register_messengers_to_activate_mt_with($default_types, EE_Messenger $messenger) {
239
+        if (empty(self::$_ee_message_type_registry)) {
240 240
             return $default_types;
241 241
 		}
242
-        foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) {
243
-            if ( empty( $mt_reg['messengers_to_activate_with'] ) || empty( $mt_reg['mtfilename'] ) ) {
242
+        foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) {
243
+            if (empty($mt_reg['messengers_to_activate_with']) || empty($mt_reg['mtfilename'])) {
244 244
                 continue;
245 245
 			}
246 246
             // loop through each of the messengers and if it matches the loaded class
247 247
 			// then we add this message type to the
248
-            foreach ( $mt_reg['messengers_to_activate_with'] as $msgr ) {
249
-                if ( $messenger->name == $msgr ) {
248
+            foreach ($mt_reg['messengers_to_activate_with'] as $msgr) {
249
+                if ($messenger->name == $msgr) {
250 250
                     $default_types[] = $message_type_name;
251 251
                 }
252 252
             }
@@ -266,18 +266,18 @@  discard block
 block discarded – undo
266 266
      * @param  EE_Messenger $messenger      The EE_messenger the filter is called from.
267 267
      * @return  array
268 268
      */
269
-    public static function register_messengers_to_validate_mt_with( $valid_types, EE_Messenger $messenger ) {
270
-        if ( empty( self::$_ee_message_type_registry ) ) {
269
+    public static function register_messengers_to_validate_mt_with($valid_types, EE_Messenger $messenger) {
270
+        if (empty(self::$_ee_message_type_registry)) {
271 271
             return $valid_types;
272 272
 		}
273
-        foreach ( self::$_ee_message_type_registry as $message_type_name => $mt_reg ) {
274
-            if ( empty( $mt_reg['messengers_to_validate_with'] ) || empty( $mt_reg['mtfilename'] ) ) {
273
+        foreach (self::$_ee_message_type_registry as $message_type_name => $mt_reg) {
274
+            if (empty($mt_reg['messengers_to_validate_with']) || empty($mt_reg['mtfilename'])) {
275 275
                 continue;
276 276
 			}
277 277
             // loop through each of the messengers and if it matches the loaded class
278 278
 			// then we add this message type to the
279
-            foreach ( $mt_reg['messengers_to_validate_with'] as $msgr ) {
280
-                if ( $messenger->name == $msgr ) {
279
+            foreach ($mt_reg['messengers_to_validate_with'] as $msgr) {
280
+                if ($messenger->name == $msgr) {
281 281
                     $valid_types[] = $message_type_name;
282 282
                 }
283 283
             }
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Messenger_Shortcodes.lib.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -41,22 +41,22 @@  discard block
 block discarded – undo
41 41
 		$this->label = __('Messenger Shortcodes', 'event_espresso');
42 42
 		$this->description = __('All shortcodes that are messenger specific.', 'event_espresso');
43 43
 		/** @type EE_Messages $messages_controller */
44
-		$messages_controller = EE_Registry::instance()->load_lib( 'messages' );
44
+		$messages_controller = EE_Registry::instance()->load_lib('messages');
45 45
 		//add messages about what happens  when the messenger is active.
46 46
 		$this->_active_messengers = $messages_controller->get_active_messengers();
47 47
 
48
-		$this->_shortcodes['[DISPLAY_HTML_URL]'] =__('This will return a link to view the template in a browser if the html messenger is active.', 'event_espresso');
49
-		$this->_shortcodes['[DISPLAY_PDF_URL]'] = __('This will return a link to generate a pdf for the template if the pdf messenger is active.', 'event_espresso' );
48
+		$this->_shortcodes['[DISPLAY_HTML_URL]'] = __('This will return a link to view the template in a browser if the html messenger is active.', 'event_espresso');
49
+		$this->_shortcodes['[DISPLAY_PDF_URL]'] = __('This will return a link to generate a pdf for the template if the pdf messenger is active.', 'event_espresso');
50 50
 		$this->_shortcodes['[DISPLAY_PDF_BUTTON]'] = __('This will return html for a download pdf button trigger if the pdf messenger is active.', 'event_espresso');
51 51
 
52 52
 		//show error message about buttons/urls not working as expected if messenger deactivated.
53
-		if ( is_admin() && isset( $_REQUEST['action'] ) && $_REQUEST['action'] == 'update_message_template' ) {
54
-			if ( ! isset( $this->_active_messengers['pdf'] ) ) {
55
-				EE_Error::add_attention( __('Be aware that the pdf messenger is inactive.  This means that any pdf related shortcodes will parse to an empty string.', 'event_espresso' ) );
53
+		if (is_admin() && isset($_REQUEST['action']) && $_REQUEST['action'] == 'update_message_template') {
54
+			if ( ! isset($this->_active_messengers['pdf'])) {
55
+				EE_Error::add_attention(__('Be aware that the pdf messenger is inactive.  This means that any pdf related shortcodes will parse to an empty string.', 'event_espresso'));
56 56
 			}
57 57
 
58
-			if ( !isset( $this->_active_messengers['html'] ) ) {
59
-				EE_Error::add_attention( __('Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.', 'event_espresso' ) );
58
+			if ( ! isset($this->_active_messengers['html'])) {
59
+				EE_Error::add_attention(__('Be aware that the html messenger is inactive. This means that any html related shortcodes will parse to an empty string.', 'event_espresso'));
60 60
 			}
61 61
 		}
62 62
 
@@ -64,24 +64,24 @@  discard block
 block discarded – undo
64 64
 
65 65
 
66 66
 
67
-	protected function _parser( $shortcode ) {
67
+	protected function _parser($shortcode) {
68 68
 		//make sure we end up with a copy of the EE_Messages_Addressee object
69 69
 		$recipient = $this->_data instanceof EE_Messages_Addressee ? $this->_data : NULL;
70
-		$recipient = ! $recipient instanceof EE_Messages_Addressee && is_array($this->_data) && isset( $this->_data['data'] ) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] : $recipient;
71
-		$recipient = ! $recipient instanceof EE_Messages_Addressee && !empty( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $recipient;
70
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && is_array($this->_data) && isset($this->_data['data']) && $this->_data['data'] instanceof EE_Messages_Addressee ? $this->_data['data'] : $recipient;
71
+		$recipient = ! $recipient instanceof EE_Messages_Addressee && ! empty($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data'] : $recipient;
72 72
 
73
-		if ( ! $recipient instanceof EE_Messages_Addressee )
73
+		if ( ! $recipient instanceof EE_Messages_Addressee)
74 74
 			return '';
75 75
 
76
-		switch ( $shortcode ) {
76
+		switch ($shortcode) {
77 77
 			case '[DISPLAY_HTML_URL]' :
78
-				return  isset( $this->_active_messengers['html'] ) ? $this->_get_url( $recipient, 'html' ) : '';
78
+				return  isset($this->_active_messengers['html']) ? $this->_get_url($recipient, 'html') : '';
79 79
 				break;
80 80
 			case '[DISPLAY_PDF_URL]' :
81
-				return  isset( $this->_active_messengers['pdf'] ) ? $this->_get_url( $recipient, 'pdf' ) : '';
81
+				return  isset($this->_active_messengers['pdf']) ? $this->_get_url($recipient, 'pdf') : '';
82 82
 				break;
83 83
 			case '[DISPLAY_PDF_BUTTON]' :
84
-				return  isset( $this->_active_messengers['pdf'] ) ? $this->_get_button( $recipient, 'pdf' ) : '';
84
+				return  isset($this->_active_messengers['pdf']) ? $this->_get_button($recipient, 'pdf') : '';
85 85
 				break;
86 86
 		}
87 87
 		return '';
@@ -99,11 +99,11 @@  discard block
 block discarded – undo
99 99
 	 *
100 100
 	 * @return string                Generated html
101 101
 	 */
102
-	private function _get_button( EE_Messages_Addressee $recipient, $sending_messenger ) {
103
-		$download_text = $sending_messenger == 'pdf' ? __('Download PDF', 'event_espresso') : __('Show HTML', 'event_espresso' );
102
+	private function _get_button(EE_Messages_Addressee $recipient, $sending_messenger) {
103
+		$download_text = $sending_messenger == 'pdf' ? __('Download PDF', 'event_espresso') : __('Show HTML', 'event_espresso');
104 104
 		$content = '
105
-<form method="post" action="' . $this->_get_url( $recipient, $sending_messenger ) . '" >
106
-	<input class="print_button" type="submit" value="' . $download_text . '" />
105
+<form method="post" action="' . $this->_get_url($recipient, $sending_messenger).'" >
106
+	<input class="print_button" type="submit" value="' . $download_text.'" />
107 107
 </form>
108 108
 		';
109 109
 		return $content;
@@ -122,18 +122,18 @@  discard block
 block discarded – undo
122 122
 	 * @return string The generated url for displaying the link.
123 123
 	 * @throws EE_Error
124 124
 	 */
125
-	private function _get_url( EE_Messages_Addressee $recipient, $sending_messenger ) {
125
+	private function _get_url(EE_Messages_Addressee $recipient, $sending_messenger) {
126 126
 
127 127
 		$reg = $recipient->reg_obj;
128 128
 		$reg = ! $reg instanceof EE_Registration ? $recipient->primary_reg_obj : $reg;
129 129
 
130 130
 
131
-		if ( $this->_message_type instanceof EE_message_type && $this->_message instanceof EE_Message ) {
132
-			EE_Registry::instance()->load_helper( 'MSG_Template' );
131
+		if ($this->_message_type instanceof EE_message_type && $this->_message instanceof EE_Message) {
132
+			EE_Registry::instance()->load_helper('MSG_Template');
133 133
 			try {
134
-				return EEH_MSG_Template::get_url_trigger( $this->_message_type, $this->_message, $reg, $sending_messenger );
135
-			} catch( EE_Error $e ) {
136
-				if ( WP_DEBUG ) {
134
+				return EEH_MSG_Template::get_url_trigger($this->_message_type, $this->_message, $reg, $sending_messenger);
135
+			} catch (EE_Error $e) {
136
+				if (WP_DEBUG) {
137 137
 					$e->get_error();
138 138
 				}
139 139
 			}
Please login to merge, or discard this patch.