Completed
Branch FET-10416-autoload-b4-bootstra... (fc73d2)
by
unknown
105:49 queued 94:33
created
acceptance_tests/tests/e-TestContextActivationToggleCept.php 1 patch
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -8,8 +8,8 @@  discard block
 block discarded – undo
8 8
 $event_label = 'Testing Context Deactivation';
9 9
 
10 10
 $I->wantTo(
11
-    'Test that the context activation toggle for turning on or off specific contexts for message sending works as'
12
-    . ' expected'
11
+	'Test that the context activation toggle for turning on or off specific contexts for message sending works as'
12
+	. ' expected'
13 13
 );
14 14
 
15 15
 $I->loginAsAdmin();
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
 $I->see('The template for Primary Registrant Recipient is currently inactive.');
35 35
 
36 36
 $I->amGoingTo(
37
-    'Trigger Registration Approved Messages and verify primary registrant context is excluded from sent messages.'
37
+	'Trigger Registration Approved Messages and verify primary registrant context is excluded from sent messages.'
38 38
 );
39 39
 $I->amOnDefaultEventsListTablePage();
40 40
 $I->click(EventsAdmin::ADD_NEW_EVENT_BUTTON_SELECTOR);
@@ -44,9 +44,9 @@  discard block
 block discarded – undo
44 44
 $event_link = $I->observeLinkUrlAt(EventsAdmin::EVENT_EDITOR_VIEW_LINK_AFTER_PUBLISH_SELECTOR);
45 45
 $event_id = $I->observeValueFromInputAt(EventsAdmin::EVENT_EDITOR_EVT_ID_SELECTOR);
46 46
 $test_registration_details = array(
47
-    'fname' => 'ContextTestGuy',
48
-    'lname' => 'ContextTestDude',
49
-    'email' => '[email protected]',
47
+	'fname' => 'ContextTestGuy',
48
+	'lname' => 'ContextTestDude',
49
+	'email' => '[email protected]',
50 50
 );
51 51
 $I->logOut();
52 52
 $I->amOnUrl($event_link);
@@ -63,48 +63,48 @@  discard block
 block discarded – undo
63 63
 $I->amOnMessagesActivityListTablePage();
64 64
 //verify registrant context
65 65
 $I->see(
66
-    $test_registration_details['email'],
67
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
68
-        'to',
69
-        'Registration Approved',
70
-        MessagesAdmin::MESSAGE_STATUS_SENT,
71
-        '',
72
-        'Registrant'
73
-    )
66
+	$test_registration_details['email'],
67
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
68
+		'to',
69
+		'Registration Approved',
70
+		MessagesAdmin::MESSAGE_STATUS_SENT,
71
+		'',
72
+		'Registrant'
73
+	)
74 74
 );
75 75
 $I->deleteMessageInMessagesListTableFor(
76
-    'Registration Approved',
77
-    MessagesAdmin::MESSAGE_STATUS_SENT,
78
-    'Email',
79
-    'Registrant'
76
+	'Registration Approved',
77
+	MessagesAdmin::MESSAGE_STATUS_SENT,
78
+	'Email',
79
+	'Registrant'
80 80
 );
81 81
 //verify admin context
82 82
 $I->see(
83
-    '[email protected]',
84
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
85
-        'to',
86
-        'Registration Approved',
87
-        MessagesAdmin::MESSAGE_STATUS_SENT
88
-    )
83
+	'[email protected]',
84
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
85
+		'to',
86
+		'Registration Approved',
87
+		MessagesAdmin::MESSAGE_STATUS_SENT
88
+	)
89 89
 );
90 90
 $I->deleteMessageInMessagesListTableFor(
91
-    'Registration Approved'
91
+	'Registration Approved'
92 92
 );
93 93
 //verify primary registrant context is NOT present.
94 94
 $I->dontSee(
95
-    $test_registration_details['email'],
96
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
97
-        'to',
98
-        'Registration Approved',
99
-        MessagesAdmin::MESSAGE_STATUS_SENT,
100
-        '',
101
-        'Primary Registrant'
102
-    )
95
+	$test_registration_details['email'],
96
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
97
+		'to',
98
+		'Registration Approved',
99
+		MessagesAdmin::MESSAGE_STATUS_SENT,
100
+		'',
101
+		'Primary Registrant'
102
+	)
103 103
 );
104 104
 
105 105
 $I->amGoingTo(
106
-    'Deactivate primary registrant context for Registration Approved Message Templates and restore the "To"'
107
-    . ' field to an empty string to verify the message does not send for that context.'
106
+	'Deactivate primary registrant context for Registration Approved Message Templates and restore the "To"'
107
+	. ' field to an empty string to verify the message does not send for that context.'
108 108
 );
109 109
 $I->amOnDefaultMessageTemplateListTablePage();
110 110
 $I->clickToEditMessageTemplateByMessageType('registration', 'primary_attendee');
@@ -128,41 +128,41 @@  discard block
 block discarded – undo
128 128
 $I->amOnMessagesActivityListTablePage();
129 129
 //verify registrant context
130 130
 $I->see(
131
-    $test_registration_details['email'],
132
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
133
-        'to',
134
-        'Registration Approved',
135
-        MessagesAdmin::MESSAGE_STATUS_SENT,
136
-        '',
137
-        'Registrant'
138
-    )
131
+	$test_registration_details['email'],
132
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
133
+		'to',
134
+		'Registration Approved',
135
+		MessagesAdmin::MESSAGE_STATUS_SENT,
136
+		'',
137
+		'Registrant'
138
+	)
139 139
 );
140 140
 $I->deleteMessageInMessagesListTableFor(
141
-    'Registration Approved',
142
-    MessagesAdmin::MESSAGE_STATUS_SENT,
143
-    'Email',
144
-    'Registrant'
141
+	'Registration Approved',
142
+	MessagesAdmin::MESSAGE_STATUS_SENT,
143
+	'Email',
144
+	'Registrant'
145 145
 );
146 146
 //verify admin context
147 147
 $I->see(
148
-    '[email protected]',
149
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
150
-        'to',
151
-        'Registration Approved',
152
-        MessagesAdmin::MESSAGE_STATUS_SENT
153
-    )
148
+	'[email protected]',
149
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
150
+		'to',
151
+		'Registration Approved',
152
+		MessagesAdmin::MESSAGE_STATUS_SENT
153
+	)
154 154
 );
155 155
 $I->deleteMessageInMessagesListTableFor(
156
-    'Registration Approved'
156
+	'Registration Approved'
157 157
 );
158 158
 //verify primary registrant context is NOT present.
159 159
 $I->dontSee(
160
-    $test_registration_details['email'],
161
-    MessagesAdmin::messagesActivityListTableCellSelectorFor(
162
-        'to',
163
-        'Registration Approved',
164
-        MessagesAdmin::MESSAGE_STATUS_SENT,
165
-        '',
166
-        'Primary Registrant'
167
-    )
160
+	$test_registration_details['email'],
161
+	MessagesAdmin::messagesActivityListTableCellSelectorFor(
162
+		'to',
163
+		'Registration Approved',
164
+		MessagesAdmin::MESSAGE_STATUS_SENT,
165
+		'',
166
+		'Primary Registrant'
167
+	)
168 168
 );
169 169
\ No newline at end of file
Please login to merge, or discard this patch.
modules/events_archive_filters/EED_Events_Archive_Filters.module.php 1 patch
Spacing   +166 added lines, -166 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
 	 * @return EED_Events_Archive_Filters
30 30
 	 */
31 31
 	public static function instance() {
32
-		return parent::get_instance( __CLASS__ );
32
+		return parent::get_instance(__CLASS__);
33 33
 	}
34 34
 
35 35
 
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
 	 *	@var 	$_types
72 72
 	 * 	@access 	protected
73 73
 	 */
74
-	protected static $_types = array( 'grid', 'text', 'dates' );
74
+	protected static $_types = array('grid', 'text', 'dates');
75 75
 
76 76
 
77 77
 //	public static $espresso_event_list_ID = 0;
@@ -125,7 +125,7 @@  discard block
 block discarded – undo
125 125
 	 *  @access 	public
126 126
 	 *  @return 	void
127 127
 	 */
128
-	public function run( $WP ) {
128
+	public function run($WP) {
129 129
 //		do_action( 'AHEE__EED_Events_Archive_Filters__before_run' );
130 130
 //		// set config
131 131
 //		if ( ! isset( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters ) || ! EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters instanceof EE_Events_Archive_Config ) {
@@ -170,9 +170,9 @@  discard block
 block discarded – undo
170 170
 	 */
171 171
 	private function _filter_query_parts() {
172 172
 		// build event list query
173
-		add_filter( 'posts_join', array( $this, 'posts_join' ), 1, 2 );
174
-		add_filter( 'posts_where', array( $this, 'posts_where' ), 1, 2 );
175
-		add_filter( 'posts_orderby', array( $this, 'posts_orderby' ), 1, 2 );
173
+		add_filter('posts_join', array($this, 'posts_join'), 1, 2);
174
+		add_filter('posts_where', array($this, 'posts_where'), 1, 2);
175
+		add_filter('posts_orderby', array($this, 'posts_orderby'), 1, 2);
176 176
 	}
177 177
 
178 178
 	/**
@@ -182,13 +182,13 @@  discard block
 block discarded – undo
182 182
 	 *  @return 	string
183 183
 	 */
184 184
 	public static function set_type() {
185
-		do_action( 'AHEE__EED_Events_Archive_Filters__before_set_type' );
186
-		EED_Events_Archive_Filters::$_types = apply_filters( 'EED_Events_Archive_Filters__set_type__types', EED_Events_Archive_Filters::$_types );
187
-		$view = isset( EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type'] ) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type'] : 'grid';
188
-		$elf_type = EE_Registry::instance()->REQ->is_set( 'elf_type' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'elf_type' )) : '';
189
-		$view = ! empty( $elf_type ) ? $elf_type : $view;
190
-		$view = apply_filters( 'EED_Events_Archive_Filters__set_type__type', $view );
191
-		if ( ! empty( $view ) && in_array( $view, EED_Events_Archive_Filters::$_types )) {
185
+		do_action('AHEE__EED_Events_Archive_Filters__before_set_type');
186
+		EED_Events_Archive_Filters::$_types = apply_filters('EED_Events_Archive_Filters__set_type__types', EED_Events_Archive_Filters::$_types);
187
+		$view = isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type']) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['default_type'] : 'grid';
188
+		$elf_type = EE_Registry::instance()->REQ->is_set('elf_type') ? sanitize_text_field(EE_Registry::instance()->REQ->get('elf_type')) : '';
189
+		$view = ! empty($elf_type) ? $elf_type : $view;
190
+		$view = apply_filters('EED_Events_Archive_Filters__set_type__type', $view);
191
+		if ( ! empty($view) && in_array($view, EED_Events_Archive_Filters::$_types)) {
192 192
 			self::$_type = $view;
193 193
 		}
194 194
 	}
@@ -200,11 +200,11 @@  discard block
 block discarded – undo
200 200
 	 *  @param	boolean	$req_only if TRUE, then ignore defaults and only return $_POST value
201 201
 	 *  @return 	boolean
202 202
 	 */
203
-	private static function _show_expired( $req_only = FALSE ) {
203
+	private static function _show_expired($req_only = FALSE) {
204 204
 		// get default value for "display_expired_events" as set in the EE General Settings > Templates > Event Listings
205
-		$show_expired = ! $req_only && isset( EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] ) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : FALSE;
205
+		$show_expired = ! $req_only && isset(EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events']) ? EE_Registry::instance()->CFG->EED_Events_Archive_Filters['display_expired_events'] : FALSE;
206 206
 		// override default expired option if set via filter
207
-		$show_expired = EE_Registry::instance()->REQ->is_set( 'elf_expired_chk' ) ? absint( EE_Registry::instance()->REQ->get( 'elf_expired_chk' )) : $show_expired;
207
+		$show_expired = EE_Registry::instance()->REQ->is_set('elf_expired_chk') ? absint(EE_Registry::instance()->REQ->get('elf_expired_chk')) : $show_expired;
208 208
 		return $show_expired ? TRUE : FALSE;
209 209
 	}
210 210
 
@@ -215,7 +215,7 @@  discard block
 block discarded – undo
215 215
 	 *  @return 	string
216 216
 	 */
217 217
 	private static function _event_category_slug() {
218
-		return EE_Registry::instance()->REQ->is_set( 'elf_category_dd' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'elf_category_dd' )) : '';
218
+		return EE_Registry::instance()->REQ->is_set('elf_category_dd') ? sanitize_text_field(EE_Registry::instance()->REQ->get('elf_category_dd')) : '';
219 219
 	}
220 220
 
221 221
 	/**
@@ -225,7 +225,7 @@  discard block
 block discarded – undo
225 225
 	 *  @return 	string
226 226
 	 */
227 227
 	private static function _display_month() {
228
-		return EE_Registry::instance()->REQ->is_set( 'elf_month_dd' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'elf_month_dd' )) : '';
228
+		return EE_Registry::instance()->REQ->is_set('elf_month_dd') ? sanitize_text_field(EE_Registry::instance()->REQ->get('elf_month_dd')) : '';
229 229
 	}
230 230
 
231 231
 
@@ -239,7 +239,7 @@  discard block
 block discarded – undo
239 239
 	public function get_post_data() {
240 240
 		$this->_elf_month = EED_Events_Archive_Filters::_display_month();
241 241
 		$this->_elf_category = EED_Events_Archive_Filters::_event_category_slug();
242
-		$this->_show_expired = EED_Events_Archive_Filters::_show_expired( TRUE );
242
+		$this->_show_expired = EED_Events_Archive_Filters::_show_expired(TRUE);
243 243
 //		EEH_Debug_Tools::printr( EE_Registry::instance()->REQ, 'EE_Registry::instance()->REQ  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
244 244
 //		echo '<h4>$this->_elf_month : ' . $this->_elf_month . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
245 245
 //		echo '<h4>$this->_elf_category : ' . $this->_elf_category . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
@@ -256,11 +256,11 @@  discard block
 block discarded – undo
256 256
 	 *  @access 	public
257 257
 	 *  @return 	void
258 258
 	 */
259
-	public function posts_join( $SQL, WP_Query $wp_query ) {
260
-		if ( isset( $wp_query->query ) && isset( $wp_query->query['post_type'] ) && $wp_query->query['post_type'] == 'espresso_events' ) {
259
+	public function posts_join($SQL, WP_Query $wp_query) {
260
+		if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
261 261
 			// Category
262 262
 //			$elf_category = EE_Registry::instance()->REQ->is_set( 'elf_category_dd' ) ? sanitize_text_field( EE_Registry::instance()->REQ->get( 'elf_category_dd' )) : '';
263
-			$SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms( EED_Events_Archive_Filters::_event_category_slug() );
263
+			$SQL .= EED_Events_Archive_Filters::posts_join_sql_for_terms(EED_Events_Archive_Filters::_event_category_slug());
264 264
 		}
265 265
 		return $SQL;
266 266
 	}
@@ -273,9 +273,9 @@  discard block
 block discarded – undo
273 273
 	 *  @param	mixed boolean|string	$join_terms pass TRUE or term string, doesn't really matter since this value doesn't really get used for anything yet
274 274
 	 *  @return 	string
275 275
 	 */
276
-	public static function posts_join_sql_for_terms( $join_terms = NULL ) {
277
-		$SQL= '';
278
-		if ( ! empty( $join_terms )) {
276
+	public static function posts_join_sql_for_terms($join_terms = NULL) {
277
+		$SQL = '';
278
+		if ( ! empty($join_terms)) {
279 279
 			global $wpdb;
280 280
 			$SQL .= " LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)";
281 281
 			$SQL .= " LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)";
@@ -293,28 +293,28 @@  discard block
 block discarded – undo
293 293
 	 *  @param	array	$orderby_params
294 294
 	 *  @return 	string
295 295
 	 */
296
-	public static function posts_join_for_orderby( $orderby_params = array() ) {
296
+	public static function posts_join_for_orderby($orderby_params = array()) {
297 297
 		global $wpdb;
298
-		$SQL= '';
299
-		$orderby_params = is_array( $orderby_params ) ? $orderby_params : array( $orderby_params );
300
-		foreach( $orderby_params as $orderby ) {
301
-			switch ( $orderby ) {
298
+		$SQL = '';
299
+		$orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
300
+		foreach ($orderby_params as $orderby) {
301
+			switch ($orderby) {
302 302
 
303 303
 				case 'ticket_start' :
304 304
 				case 'ticket_end' :
305
-					$SQL .= ' LEFT JOIN ' . EEM_Datetime_Ticket::instance()->table() . ' ON (' . EEM_Datetime::instance()->table() . '.DTT_ID = ' . EEM_Datetime_Ticket::instance()->table() . '.DTT_ID )';
306
-					$SQL .= ' LEFT JOIN ' . EEM_Ticket::instance()->table() . ' ON (' . EEM_Datetime_Ticket::instance()->table() . '.TKT_ID = ' . EEM_Ticket::instance()->table() . '.TKT_ID )';
305
+					$SQL .= ' LEFT JOIN '.EEM_Datetime_Ticket::instance()->table().' ON ('.EEM_Datetime::instance()->table().'.DTT_ID = '.EEM_Datetime_Ticket::instance()->table().'.DTT_ID )';
306
+					$SQL .= ' LEFT JOIN '.EEM_Ticket::instance()->table().' ON ('.EEM_Datetime_Ticket::instance()->table().'.TKT_ID = '.EEM_Ticket::instance()->table().'.TKT_ID )';
307 307
 					break;
308 308
 
309 309
 				case 'venue_title' :
310 310
 				case 'city' :
311
-					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = ' . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
312
-					$SQL .= ' LEFT JOIN ' . EEM_Venue::instance()->table() . ' ON (' . EEM_Event_Venue::instance()->table() . '.VNU_ID = ' . EEM_Venue::instance()->table() . '.VNU_ID )';
311
+					$SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->table().' ON ('.$wpdb->posts.'.ID = '.EEM_Event_Venue::instance()->table().'.EVT_ID )';
312
+					$SQL .= ' LEFT JOIN '.EEM_Venue::instance()->table().' ON ('.EEM_Event_Venue::instance()->table().'.VNU_ID = '.EEM_Venue::instance()->table().'.VNU_ID )';
313 313
 					break;
314 314
 
315 315
 				case 'state' :
316
-					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->table() . ' ON (' . $wpdb->posts . '.ID = ' . EEM_Event_Venue::instance()->table() . '.EVT_ID )';
317
-					$SQL .= ' LEFT JOIN ' . EEM_Event_Venue::instance()->second_table() . ' ON (' . EEM_Event_Venue::instance()->table() . '.VNU_ID = ' . EEM_Event_Venue::instance()->second_table() . '.VNU_ID )';
316
+					$SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->table().' ON ('.$wpdb->posts.'.ID = '.EEM_Event_Venue::instance()->table().'.EVT_ID )';
317
+					$SQL .= ' LEFT JOIN '.EEM_Event_Venue::instance()->second_table().' ON ('.EEM_Event_Venue::instance()->table().'.VNU_ID = '.EEM_Event_Venue::instance()->second_table().'.VNU_ID )';
318 318
 					break;
319 319
 
320 320
 				break;
@@ -331,16 +331,16 @@  discard block
 block discarded – undo
331 331
 	 *  @access 	public
332 332
 	 *  @return 	void
333 333
 	 */
334
-	public function posts_where( $SQL, WP_Query $wp_query ) {
335
-		if ( isset( $wp_query->query_vars ) && isset( $wp_query->query_vars['post_type'] ) && $wp_query->query_vars['post_type'] == 'espresso_events'  ) {
334
+	public function posts_where($SQL, WP_Query $wp_query) {
335
+		if (isset($wp_query->query_vars) && isset($wp_query->query_vars['post_type']) && $wp_query->query_vars['post_type'] == 'espresso_events') {
336 336
 			// Show Expired ?
337
-			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired( EED_Events_Archive_Filters::_show_expired() );
337
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_show_expired(EED_Events_Archive_Filters::_show_expired());
338 338
 			// Category
339 339
 			//$elf_category = EED_Events_Archive_Filters::_event_category_slug();
340
-			$SQL .=  EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug( EED_Events_Archive_Filters::_event_category_slug() );
340
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_category_slug(EED_Events_Archive_Filters::_event_category_slug());
341 341
 			// Start Date
342 342
 			//$elf_month = EED_Events_Archive_Filters::_display_month();
343
-			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month( EED_Events_Archive_Filters::_display_month() );
343
+			$SQL .= EED_Events_Archive_Filters::posts_where_sql_for_event_list_month(EED_Events_Archive_Filters::_display_month());
344 344
 		}
345 345
 		return $SQL;
346 346
 	}
@@ -353,8 +353,8 @@  discard block
 block discarded – undo
353 353
 	 *  @param	boolean	$show_expired if TRUE, then displayed past events
354 354
 	 *  @return 	string
355 355
 	 */
356
-	public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) {
357
-		return  ! $show_expired ? ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end > "' . date('Y-m-d H:s:i') . '" ' : '';
356
+	public static function posts_where_sql_for_show_expired($show_expired = FALSE) {
357
+		return  ! $show_expired ? ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end > "'.date('Y-m-d H:s:i').'" ' : '';
358 358
 	}
359 359
 
360 360
 
@@ -365,9 +365,9 @@  discard block
 block discarded – undo
365 365
 	 *  @param	boolean	$event_category_slug
366 366
 	 *  @return 	string
367 367
 	 */
368
-	public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) {
368
+	public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) {
369 369
 		global $wpdb;
370
-		return  ! empty( $event_category_slug ) ? ' AND ' . $wpdb->terms . '.slug = "' . $event_category_slug . '" ' : '';
370
+		return  ! empty($event_category_slug) ? ' AND '.$wpdb->terms.'.slug = "'.$event_category_slug.'" ' : '';
371 371
 	}
372 372
 
373 373
 	/**
@@ -377,15 +377,15 @@  discard block
 block discarded – undo
377 377
 	 *  @param	boolean	$month
378 378
 	 *  @return 	string
379 379
 	 */
380
-	public static function posts_where_sql_for_event_list_month( $month = NULL ) {
381
-		$SQL= '';
382
-		if ( ! empty( $month )) {
380
+	public static function posts_where_sql_for_event_list_month($month = NULL) {
381
+		$SQL = '';
382
+		if ( ! empty($month)) {
383 383
 			// event start date is LESS than the end of the month ( so nothing that doesn't start until next month )
384
-			$SQL = ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_start';
385
-			$SQL .= ' <= "' . date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '"';
384
+			$SQL = ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_start';
385
+			$SQL .= ' <= "'.date('Y-m-t 23:59:59', \EEH_DTT_Helper::first_of_month_timestamp($month)).'"';
386 386
 			// event end date is GREATER than the start of the month ( so nothing that ended before this month )
387
-			$SQL .= ' AND ' . EEM_Datetime::instance()->table() . '.DTT_EVT_end';
388
-			$SQL .= ' >= "' . date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)) . '" ';
387
+			$SQL .= ' AND '.EEM_Datetime::instance()->table().'.DTT_EVT_end';
388
+			$SQL .= ' >= "'.date('Y-m-d 0:0:00', \EEH_DTT_Helper::first_of_month_timestamp($month)).'" ';
389 389
 		}
390 390
 		return $SQL;
391 391
 	}
@@ -397,9 +397,9 @@  discard block
 block discarded – undo
397 397
 	 *  @access 	public
398 398
 	 *  @return 	void
399 399
 	 */
400
-	public function posts_orderby( $SQL, WP_Query $wp_query ) {
401
-		if ( isset( $wp_query->query ) && isset( $wp_query->query['post_type'] ) && $wp_query->query['post_type'] == 'espresso_events' ) {
402
-			$SQL = EED_Events_Archive_Filters::posts_orderby_sql( array( 'start_date' ));
400
+	public function posts_orderby($SQL, WP_Query $wp_query) {
401
+		if (isset($wp_query->query) && isset($wp_query->query['post_type']) && $wp_query->query['post_type'] == 'espresso_events') {
402
+			$SQL = EED_Events_Archive_Filters::posts_orderby_sql(array('start_date'));
403 403
 		}
404 404
 		return $SQL;
405 405
 	}
@@ -428,54 +428,54 @@  discard block
 block discarded – undo
428 428
 	 *  @param	boolean	$orderby_params
429 429
 	 *  @return 	string
430 430
 	 */
431
-	public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) {
431
+	public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') {
432 432
 		global $wpdb;
433 433
 		$SQL = '';
434 434
 		$cntr = 1;
435
-		$orderby_params = is_array( $orderby_params ) ? $orderby_params : array( $orderby_params );
436
-		foreach( $orderby_params as $orderby ) {
437
-			$glue = $cntr == 1 || $cntr == count( $orderby_params ) ? ' ' : ', ';
438
-			switch ( $orderby ) {
435
+		$orderby_params = is_array($orderby_params) ? $orderby_params : array($orderby_params);
436
+		foreach ($orderby_params as $orderby) {
437
+			$glue = $cntr == 1 || $cntr == count($orderby_params) ? ' ' : ', ';
438
+			switch ($orderby) {
439 439
 
440 440
 				case 'id' :
441 441
 				case 'ID' :
442
-					$SQL .= $glue . $wpdb->posts . '.ID ' . $sort;
442
+					$SQL .= $glue.$wpdb->posts.'.ID '.$sort;
443 443
 					break;
444 444
 
445 445
 				case 'start_date' :
446
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_start ' . $sort;
446
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_start '.$sort;
447 447
 					break;
448 448
 
449 449
 				case 'end_date' :
450
-					$SQL .= $glue . EEM_Datetime::instance()->table() . '.DTT_EVT_end ' . $sort;
450
+					$SQL .= $glue.EEM_Datetime::instance()->table().'.DTT_EVT_end '.$sort;
451 451
 					break;
452 452
 
453 453
 				case 'event_name' :
454
-					$SQL .= $glue . $wpdb->posts . '.post_title ' . $sort;
454
+					$SQL .= $glue.$wpdb->posts.'.post_title '.$sort;
455 455
 					break;
456 456
 
457 457
 				case 'category_slug' :
458
-					$SQL .= $glue . $wpdb->terms . '.slug ' . $sort;
458
+					$SQL .= $glue.$wpdb->terms.'.slug '.$sort;
459 459
 					break;
460 460
 
461 461
 				case 'ticket_start' :
462
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_start_date ' . $sort;
462
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_start_date '.$sort;
463 463
 					break;
464 464
 
465 465
 				case 'ticket_end' :
466
-					$SQL .= $glue . EEM_Ticket::instance()->table() . '.TKT_end_date ' . $sort;
466
+					$SQL .= $glue.EEM_Ticket::instance()->table().'.TKT_end_date '.$sort;
467 467
 					break;
468 468
 
469 469
 				case 'venue_title' :
470
-					$SQL .= $glue . 'venue_title ' . $sort;
470
+					$SQL .= $glue.'venue_title '.$sort;
471 471
 					break;
472 472
 
473 473
 				case 'city' :
474
-					$SQL .= $glue . EEM_Venue::instance()->second_table() . '.VNU_city ' . $sort;
474
+					$SQL .= $glue.EEM_Venue::instance()->second_table().'.VNU_city '.$sort;
475 475
 				break;
476 476
 
477 477
 				case 'state' :
478
-					$SQL .= $glue . EEM_State::instance()->table() . '.STA_name ' . $sort;
478
+					$SQL .= $glue.EEM_State::instance()->table().'.STA_name '.$sort;
479 479
 				break;
480 480
 
481 481
 			}
@@ -495,26 +495,26 @@  discard block
 block discarded – undo
495 495
 	 */
496 496
 	public function template_redirect() {
497 497
 		// add event list filters
498
-		add_action( 'loop_start', array( $this, 'event_list_template_filters' ));
498
+		add_action('loop_start', array($this, 'event_list_template_filters'));
499 499
 		// and pagination
500
-		add_action( 'loop_start', array( $this, 'event_list_pagination' ));
501
-		add_action( 'loop_end', array( $this, 'event_list_pagination' ));
500
+		add_action('loop_start', array($this, 'event_list_pagination'));
501
+		add_action('loop_end', array($this, 'event_list_pagination'));
502 502
 		// if NOT a custom template
503
-		if ( EE_Registry::instance()->load_core( 'Front_Controller', array(), false, true )->get_selected_template() != 'archive-espresso_events.php' ) {
503
+		if (EE_Registry::instance()->load_core('Front_Controller', array(), false, true)->get_selected_template() != 'archive-espresso_events.php') {
504 504
 			// don't know if theme uses the_excerpt
505
-			add_filter( 'the_excerpt', array( $this, 'event_details' ), 100 );
506
-			add_filter( 'the_excerpt', array( $this, 'event_tickets' ), 110 );
507
-			add_filter( 'the_excerpt', array( $this, 'event_datetimes' ), 120 );
508
-			add_filter( 'the_excerpt', array( $this, 'event_venues' ), 130 );
505
+			add_filter('the_excerpt', array($this, 'event_details'), 100);
506
+			add_filter('the_excerpt', array($this, 'event_tickets'), 110);
507
+			add_filter('the_excerpt', array($this, 'event_datetimes'), 120);
508
+			add_filter('the_excerpt', array($this, 'event_venues'), 130);
509 509
 			// or the_content
510
-			add_filter( 'the_content', array( $this, 'event_details' ), 100 );
511
-			add_filter( 'the_content', array( $this, 'event_tickets' ), 110 );
512
-			add_filter( 'the_content', array( $this, 'event_datetimes' ), 120 );
513
-			add_filter( 'the_content', array( $this, 'event_venues' ), 130 );
510
+			add_filter('the_content', array($this, 'event_details'), 100);
511
+			add_filter('the_content', array($this, 'event_tickets'), 110);
512
+			add_filter('the_content', array($this, 'event_datetimes'), 120);
513
+			add_filter('the_content', array($this, 'event_venues'), 130);
514 514
 		} else {
515
-			remove_all_filters( 'excerpt_length' );
516
-			add_filter( 'excerpt_length', array( $this, 'excerpt_length' ), 10 );
517
-			add_filter( 'excerpt_more', array( $this, 'excerpt_more' ), 10 );
515
+			remove_all_filters('excerpt_length');
516
+			add_filter('excerpt_length', array($this, 'excerpt_length'), 10);
517
+			add_filter('excerpt_more', array($this, 'excerpt_more'), 10);
518 518
 		}
519 519
 	}
520 520
 
@@ -527,7 +527,7 @@  discard block
 block discarded – undo
527 527
 	 *  	@return 		void
528 528
 	 */
529 529
 	public function event_list_pagination() {
530
-		echo '<div class="ee-pagination-dv ee-clear-float">' . espresso_event_list_pagination() . '</div>';
530
+		echo '<div class="ee-pagination-dv ee-clear-float">'.espresso_event_list_pagination().'</div>';
531 531
 	}
532 532
 
533 533
 
@@ -538,8 +538,8 @@  discard block
 block discarded – undo
538 538
 	 * 	@param		string 	$content
539 539
 	 *  	@return 		void
540 540
 	 */
541
-	public function event_details( $content ) {
542
-		return EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-details.php', array( 'the_content' => $content ), TRUE );
541
+	public function event_details($content) {
542
+		return EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-details.php', array('the_content' => $content), TRUE);
543 543
 	}
544 544
 
545 545
 
@@ -550,8 +550,8 @@  discard block
 block discarded – undo
550 550
 	 * 	@param		string 	$content
551 551
 	 *  	@return 		void
552 552
 	 */
553
-	public function event_tickets( $content ) {
554
-		return $content . EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-tickets.php', array(), TRUE );
553
+	public function event_tickets($content) {
554
+		return $content.EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-tickets.php', array(), TRUE);
555 555
 	}
556 556
 
557 557
 	/**
@@ -561,8 +561,8 @@  discard block
 block discarded – undo
561 561
 	 * 	@param		string 	$content
562 562
 	 *  	@return 		void
563 563
 	 */
564
-	public function event_datetimes( $content ) {
565
-		return $content . EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-datetimes.php', array(), TRUE );
564
+	public function event_datetimes($content) {
565
+		return $content.EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-datetimes.php', array(), TRUE);
566 566
 	}
567 567
 
568 568
 	/**
@@ -572,8 +572,8 @@  discard block
 block discarded – undo
572 572
 	 * 	@param		string 	$content
573 573
 	 *  	@return 		void
574 574
 	 */
575
-	public function event_venues( $content ) {
576
-		return $content . EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'content-espresso_events-venues.php', array(), TRUE );
575
+	public function event_venues($content) {
576
+		return $content.EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'content-espresso_events-venues.php', array(), TRUE);
577 577
 	}
578 578
 
579 579
 
@@ -588,13 +588,13 @@  discard block
 block discarded – undo
588 588
 	 *  @return 	void
589 589
 	 */
590 590
 	private function _load_assests() {
591
-		do_action( 'AHEE__EED_Events_Archive_Filters__before_load_assests' );
591
+		do_action('AHEE__EED_Events_Archive_Filters__before_load_assests');
592 592
         wp_enqueue_style('espresso_default');
593 593
         wp_enqueue_style('espresso_custom_css');
594
-        add_filter( 'FHEE_load_EE_Session', '__return_true' );
595
-		add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 );
596
-		if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) {
597
-			add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 );
594
+        add_filter('FHEE_load_EE_Session', '__return_true');
595
+		add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10);
596
+		if (EE_Registry::instance()->CFG->map_settings->use_google_maps) {
597
+			add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11);
598 598
 		}
599 599
 		//add_filter( 'the_excerpt', array( $this, 'the_excerpt' ), 999 );
600 600
 	}
@@ -609,8 +609,8 @@  discard block
 block discarded – undo
609 609
 	 *  @access 	private
610 610
 	 *  @return 	string
611 611
 	 */
612
-	private function _get_template( $which = 'part' ) {
613
-		return EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
612
+	private function _get_template($which = 'part') {
613
+		return EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php';
614 614
 	}
615 615
 
616 616
 
@@ -621,13 +621,13 @@  discard block
 block discarded – undo
621 621
 	 *  @access 	public
622 622
 	 *  @return 	void
623 623
 	 */
624
-	public function excerpt_length( $length ) {
624
+	public function excerpt_length($length) {
625 625
 
626
-		if ( self::$_type == 'grid' ) {
626
+		if (self::$_type == 'grid') {
627 627
 			return 36;
628 628
 		}
629 629
 
630
-		switch ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size ) {
630
+		switch (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) {
631 631
 			case 'tiny' :
632 632
 				return 12;
633 633
 				break;
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
 	 *  @access 	public
652 652
 	 *  @return 	void
653 653
 	 */
654
-	public function excerpt_more( $more ) {
654
+	public function excerpt_more($more) {
655 655
 		return '&hellip;';
656 656
 	}
657 657
 
@@ -681,22 +681,22 @@  discard block
 block discarded – undo
681 681
 	 */
682 682
 	public function wp_enqueue_scripts() {
683 683
 		// get some style
684
-		if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) {
684
+		if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) {
685 685
 			// first check uploads folder
686
-			if ( is_readable( get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css' )) {
687
-				wp_register_style( 'archive-espresso_events', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css', array( 'dashicons', 'espresso_default' ));
686
+			if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'archive-espresso_events.css')) {
687
+				wp_register_style('archive-espresso_events', get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'archive-espresso_events.css', array('dashicons', 'espresso_default'));
688 688
 			} else {
689
-				wp_register_style( 'archive-espresso_events', EE_TEMPLATES_URL . EE_Config::get_current_theme() . DS . 'archive-espresso_events.css', array( 'dashicons', 'espresso_default' ));
689
+				wp_register_style('archive-espresso_events', EE_TEMPLATES_URL.EE_Config::get_current_theme().DS.'archive-espresso_events.css', array('dashicons', 'espresso_default'));
690 690
 			}
691
-			if ( is_readable( get_stylesheet_directory() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js' )) {
692
-				wp_register_script( 'archive-espresso_events', get_stylesheet_directory_uri() . EE_Config::get_current_theme() . DS . 'archive-espresso_events.js', array( 'jquery-masonry' ), '1.0', TRUE  );
691
+			if (is_readable(get_stylesheet_directory().EE_Config::get_current_theme().DS.'archive-espresso_events.js')) {
692
+				wp_register_script('archive-espresso_events', get_stylesheet_directory_uri().EE_Config::get_current_theme().DS.'archive-espresso_events.js', array('jquery-masonry'), '1.0', TRUE);
693 693
 			} else {
694
-				wp_register_script( 'archive-espresso_events', EVENTS_ARCHIVE_ASSETS_URL . 'archive-espresso_events.js', array( 'jquery-masonry' ), '1.0', TRUE );
694
+				wp_register_script('archive-espresso_events', EVENTS_ARCHIVE_ASSETS_URL.'archive-espresso_events.js', array('jquery-masonry'), '1.0', TRUE);
695 695
 			}
696
-			wp_enqueue_style( 'archive-espresso_events' );
697
-			wp_enqueue_script( 'jquery-masonry' );
698
-			wp_enqueue_script( 'archive-espresso_events' );
699
-			add_action( 'wp_footer', array( 'EED_Events_Archive_Filters', 'localize_grid_event_lists' ), 1 );
696
+			wp_enqueue_style('archive-espresso_events');
697
+			wp_enqueue_script('jquery-masonry');
698
+			wp_enqueue_script('archive-espresso_events');
699
+			add_action('wp_footer', array('EED_Events_Archive_Filters', 'localize_grid_event_lists'), 1);
700 700
 		}
701 701
 	}
702 702
 
@@ -711,7 +711,7 @@  discard block
 block discarded – undo
711 711
 	 *  @return 	void
712 712
 	 */
713 713
 	public static function localize_grid_event_lists() {
714
-		wp_localize_script( 'archive-espresso_events', 'espresso_grid_event_lists', EED_Events_Archive_Filters::$espresso_grid_event_lists );
714
+		wp_localize_script('archive-espresso_events', 'espresso_grid_event_lists', EED_Events_Archive_Filters::$espresso_grid_event_lists);
715 715
 	}
716 716
 
717 717
 
@@ -726,9 +726,9 @@  discard block
 block discarded – undo
726 726
 	 */
727 727
 	public static function template_settings_form() {
728 728
 		$EE = EE_Registry::instance();
729
-		$EE->CFG->template_settings->EED_Events_Archive_Filters = isset( $EE->CFG->template_settings->EED_Events_Archive_Filters ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config();
730
-		$EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters( 'FHEE__Event_List__template_settings_form__event_list_config', $EE->CFG->template_settings->EED_Events_Archive_Filters );
731
-		EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $EE->CFG->template_settings->EED_Events_Archive_Filters );
729
+		$EE->CFG->template_settings->EED_Events_Archive_Filters = isset($EE->CFG->template_settings->EED_Events_Archive_Filters) ? $EE->CFG->template_settings->EED_Events_Archive_Filters : new EE_Events_Archive_Config();
730
+		$EE->CFG->template_settings->EED_Events_Archive_Filters = apply_filters('FHEE__Event_List__template_settings_form__event_list_config', $EE->CFG->template_settings->EED_Events_Archive_Filters);
731
+		EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $EE->CFG->template_settings->EED_Events_Archive_Filters);
732 732
 	}
733 733
 
734 734
 
@@ -742,16 +742,16 @@  discard block
 block discarded – undo
742 742
 	 *  @static
743 743
 	 *  @return 	void
744 744
 	 */
745
-	public static function set_default_settings( $CFG ) {
745
+	public static function set_default_settings($CFG) {
746 746
 		//EEH_Debug_Tools::printr( $CFG, '$CFG  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
747
-		$CFG->display_description = isset( $CFG->display_description ) && ! empty( $CFG->display_description ) ? $CFG->display_description : 1;
748
-		$CFG->display_address = isset( $CFG->display_address ) && ! empty( $CFG->display_address ) ? $CFG->display_address : TRUE;
749
-		$CFG->display_venue_details = isset( $CFG->display_venue_details ) && ! empty( $CFG->display_venue_details ) ? $CFG->display_venue_details : TRUE;
750
-		$CFG->display_expired_events = isset( $CFG->display_expired_events ) && ! empty( $CFG->display_expired_events ) ? $CFG->display_expired_events : FALSE;
751
-		$CFG->default_type = isset( $CFG->default_type ) && ! empty( $CFG->default_type ) ? $CFG->default_type : 'grid';
752
-		$CFG->event_list_grid_size = isset( $CFG->event_list_grid_size ) && ! empty( $CFG->event_list_grid_size ) ? $CFG->event_list_grid_size : 'medium';
753
-		$CFG->templates['full'] = isset( $CFG->templates['full'] ) && ! empty( $CFG->templates['full'] ) ? $CFG->templates['full'] : EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php';
754
-		$CFG->templates['part'] = isset( $CFG->templates['part'] ) && ! empty( $CFG->templates['part'] ) ? $CFG->templates['part'] : EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-grid-view.php';
747
+		$CFG->display_description = isset($CFG->display_description) && ! empty($CFG->display_description) ? $CFG->display_description : 1;
748
+		$CFG->display_address = isset($CFG->display_address) && ! empty($CFG->display_address) ? $CFG->display_address : TRUE;
749
+		$CFG->display_venue_details = isset($CFG->display_venue_details) && ! empty($CFG->display_venue_details) ? $CFG->display_venue_details : TRUE;
750
+		$CFG->display_expired_events = isset($CFG->display_expired_events) && ! empty($CFG->display_expired_events) ? $CFG->display_expired_events : FALSE;
751
+		$CFG->default_type = isset($CFG->default_type) && ! empty($CFG->default_type) ? $CFG->default_type : 'grid';
752
+		$CFG->event_list_grid_size = isset($CFG->event_list_grid_size) && ! empty($CFG->event_list_grid_size) ? $CFG->event_list_grid_size : 'medium';
753
+		$CFG->templates['full'] = isset($CFG->templates['full']) && ! empty($CFG->templates['full']) ? $CFG->templates['full'] : EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php';
754
+		$CFG->templates['part'] = isset($CFG->templates['part']) && ! empty($CFG->templates['part']) ? $CFG->templates['part'] : EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-grid-view.php';
755 755
 		return $CFG;
756 756
 	}
757 757
 
@@ -763,7 +763,7 @@  discard block
 block discarded – undo
763 763
 	 *  @access 	public
764 764
 	 *  @return 	void
765 765
 	 */
766
-	public function filter_config( $CFG ) {
766
+	public function filter_config($CFG) {
767 767
 		return $CFG;
768 768
 	}
769 769
 
@@ -776,32 +776,32 @@  discard block
 block discarded – undo
776 776
 	 *  @access 	public
777 777
 	 *  @return 	void
778 778
 	 */
779
-	public static function update_template_settings( $CFG, $REQ ) {
779
+	public static function update_template_settings($CFG, $REQ) {
780 780
 //		EEH_Debug_Tools::printr( $REQ, '$REQ  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
781 781
 //		EEH_Debug_Tools::printr( $CFG, '$CFG  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
782 782
 		//$CFG->template_settings->EED_Events_Archive_Filters = new stdClass();
783
-		$CFG->EED_Events_Archive_Filters->display_description = isset( $REQ['display_description_in_event_list'] ) ? absint( $REQ['display_description_in_event_list'] ) : 1;
784
-		$CFG->EED_Events_Archive_Filters->display_address = isset( $REQ['display_address_in_event_list'] ) ? absint( $REQ['display_address_in_event_list'] ) : TRUE;
785
-		$CFG->EED_Events_Archive_Filters->display_venue_details = isset( $REQ['display_venue_details_in_event_list'] ) ? absint( $REQ['display_venue_details_in_event_list'] ) : TRUE;
786
-		$CFG->EED_Events_Archive_Filters->display_expired_events = isset( $REQ['display_expired_events'] ) ? absint( $REQ['display_expired_events'] ) : FALSE;
787
-		$CFG->EED_Events_Archive_Filters->default_type = isset( $REQ['default_type'] ) ? sanitize_text_field( $REQ['default_type'] ) : 'grid';
788
-		$CFG->EED_Events_Archive_Filters->event_list_grid_size = isset( $REQ['event_list_grid_size'] ) ? sanitize_text_field( $REQ['event_list_grid_size'] ) : 'medium';
783
+		$CFG->EED_Events_Archive_Filters->display_description = isset($REQ['display_description_in_event_list']) ? absint($REQ['display_description_in_event_list']) : 1;
784
+		$CFG->EED_Events_Archive_Filters->display_address = isset($REQ['display_address_in_event_list']) ? absint($REQ['display_address_in_event_list']) : TRUE;
785
+		$CFG->EED_Events_Archive_Filters->display_venue_details = isset($REQ['display_venue_details_in_event_list']) ? absint($REQ['display_venue_details_in_event_list']) : TRUE;
786
+		$CFG->EED_Events_Archive_Filters->display_expired_events = isset($REQ['display_expired_events']) ? absint($REQ['display_expired_events']) : FALSE;
787
+		$CFG->EED_Events_Archive_Filters->default_type = isset($REQ['default_type']) ? sanitize_text_field($REQ['default_type']) : 'grid';
788
+		$CFG->EED_Events_Archive_Filters->event_list_grid_size = isset($REQ['event_list_grid_size']) ? sanitize_text_field($REQ['event_list_grid_size']) : 'medium';
789 789
 		$CFG->EED_Events_Archive_Filters->templates = array(
790
-				'full'  => EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events.php'
790
+				'full'  => EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events.php'
791 791
 			);
792 792
 
793
-		switch ( $CFG->EED_Events_Archive_Filters->default_type ) {
793
+		switch ($CFG->EED_Events_Archive_Filters->default_type) {
794 794
 			case 'dates' :
795
-					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-dates-view.php';
795
+					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-dates-view.php';
796 796
 				break;
797 797
 			case 'text' :
798
-					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-text-view.php';
798
+					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-text-view.php';
799 799
 				break;
800 800
 			default :
801
-					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-grid-view.php';
801
+					$CFG->EED_Events_Archive_Filters->templates['part'] = EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-grid-view.php';
802 802
 		}
803 803
 
804
-		$CFG->EED_Events_Archive_Filters = isset( $REQ['reset_event_list_settings'] ) && absint( $REQ['reset_event_list_settings'] ) == 1 ? new EE_Events_Archive_Config() : $CFG->EED_Events_Archive_Filters;
804
+		$CFG->EED_Events_Archive_Filters = isset($REQ['reset_event_list_settings']) && absint($REQ['reset_event_list_settings']) == 1 ? new EE_Events_Archive_Config() : $CFG->EED_Events_Archive_Filters;
805 805
 		return $CFG;
806 806
 	}
807 807
 
@@ -816,7 +816,7 @@  discard block
 block discarded – undo
816 816
 	 *  @return 	void
817 817
 	 */
818 818
 	public static function get_template_part() {
819
-		switch ( self::$_type ) {
819
+		switch (self::$_type) {
820 820
 			case 'dates' :
821 821
 					return 'archive-espresso_events-dates-view.php';
822 822
 				break;
@@ -840,13 +840,13 @@  discard block
 block discarded – undo
840 840
 	 */
841 841
 	public function event_list_template_filters() {
842 842
 		$args = array(
843
-			'form_url' => get_post_type_archive_link( 'espresso_events' ), //add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ),
843
+			'form_url' => get_post_type_archive_link('espresso_events'), //add_query_arg( array( 'post_type' => 'espresso_events' ), home_url() ),
844 844
 			'elf_month' => EED_Events_Archive_Filters::_display_month(),
845 845
 			'elf_category' => EED_Events_Archive_Filters::_event_category_slug(),
846 846
 			'elf_show_expired' => EED_Events_Archive_Filters::_show_expired(),
847 847
 			'elf_type' => self::$_type
848 848
 		);
849
-		EEH_Template::display_template( EE_TEMPLATES . EE_Config::get_current_theme() . DS . 'archive-espresso_events-filters.php', $args );
849
+		EEH_Template::display_template(EE_TEMPLATES.EE_Config::get_current_theme().DS.'archive-espresso_events-filters.php', $args);
850 850
 	}
851 851
 
852 852
 
@@ -859,16 +859,16 @@  discard block
 block discarded – undo
859 859
 	 *  @access 	public
860 860
 	 *  @return 	void
861 861
 	 */
862
-	public static function event_list_css( $extra_class = '' ) {
862
+	public static function event_list_css($extra_class = '') {
863 863
 		$EE = EE_Registry::instance();
864
-		$event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array();
864
+		$event_list_css = ! empty($extra_class) ? array($extra_class) : array();
865 865
 		$event_list_css[] = 'espresso-event-list-event';
866
-		if ( self::$_type == 'grid' ) {
867
-			$event_list_grid_size = isset( $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
868
-			$event_list_css[] = $event_list_grid_size . '-event-list-grid';
866
+		if (self::$_type == 'grid') {
867
+			$event_list_grid_size = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->event_list_grid_size : 'medium';
868
+			$event_list_css[] = $event_list_grid_size.'-event-list-grid';
869 869
 		}
870
-		$event_list_css = apply_filters( 'EED_Events_Archive_Filters__event_list_css__event_list_css_array', $event_list_css );
871
-		return implode( ' ', $event_list_css );
870
+		$event_list_css = apply_filters('EED_Events_Archive_Filters__event_list_css__event_list_css_array', $event_list_css);
871
+		return implode(' ', $event_list_css);
872 872
 	}
873 873
 
874 874
 
@@ -894,9 +894,9 @@  discard block
 block discarded – undo
894 894
 	 *  @access 	public
895 895
 	 *  @return 	void
896 896
 	 */
897
-	public static function display_description( $value ) {
897
+	public static function display_description($value) {
898 898
 		$EE = EE_Registry::instance();
899
-		$display_description= isset( $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1;
899
+		$display_description = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_description) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_description : 1;
900 900
 		return $display_description === $value ? TRUE : FALSE;
901 901
 	}
902 902
 
@@ -910,9 +910,9 @@  discard block
 block discarded – undo
910 910
 	 */
911 911
 	public static function display_venue_details() {
912 912
 		$EE = EE_Registry::instance();
913
-		$display_venue_details= isset( $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : TRUE;
913
+		$display_venue_details = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_venue_details : TRUE;
914 914
 		$venue_name = EEH_Venue_View::venue_name();
915
-		return $display_venue_details && ! empty( $venue_name ) ? TRUE : FALSE;
915
+		return $display_venue_details && ! empty($venue_name) ? TRUE : FALSE;
916 916
 	}
917 917
 
918 918
 
@@ -924,9 +924,9 @@  discard block
 block discarded – undo
924 924
 	 */
925 925
 	public static function display_address() {
926 926
 		$EE = EE_Registry::instance();
927
-		$display_address= isset( $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address ) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : FALSE;
927
+		$display_address = isset($EE->CFG->template_settings->EED_Events_Archive_Filters->display_address) ? $EE->CFG->template_settings->EED_Events_Archive_Filters->display_address : FALSE;
928 928
 		$venue_name = EEH_Venue_View::venue_name();
929
-		return $display_address && ! empty( $venue_name ) ? TRUE : FALSE;
929
+		return $display_address && ! empty($venue_name) ? TRUE : FALSE;
930 930
 	}
931 931
 
932 932
 
@@ -940,22 +940,22 @@  discard block
 block discarded – undo
940 940
 	public static function pagination() {
941 941
 		global $wp_query;
942 942
 		$big = 999999999; // need an unlikely integer
943
-		$pagination = paginate_links( array(
944
-			'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
943
+		$pagination = paginate_links(array(
944
+			'base' => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
945 945
 			'format' => '?paged=%#%',
946
-			'current' => max( 1, get_query_var('paged') ),
946
+			'current' => max(1, get_query_var('paged')),
947 947
 			'total' => $wp_query->max_num_pages,
948 948
 			'show_all'     => TRUE,
949 949
 			'end_size'     => 10,
950 950
 			'mid_size'     => 6,
951 951
 			'prev_next'    => TRUE,
952
-			'prev_text'    => __( '&lsaquo; PREV', 'event_espresso' ),
953
-			'next_text'    => __( 'NEXT &rsaquo;', 'event_espresso' ),
952
+			'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
953
+			'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
954 954
 			'type'         => 'plain',
955 955
 			'add_args'     => FALSE,
956 956
 			'add_fragment' => ''
957 957
 		));
958
-		return ! empty( $pagination ) ? '<div class="ee-pagination-dv clear">' . $pagination . '</div>' : '';
958
+		return ! empty($pagination) ? '<div class="ee-pagination-dv clear">'.$pagination.'</div>' : '';
959 959
 	}
960 960
 
961 961
 
@@ -969,7 +969,7 @@  discard block
 block discarded – undo
969 969
 	 *  @return 	void
970 970
 	 */
971 971
 	public static function event_list_title() {
972
-		return apply_filters( 'EED_Events_Archive_Filters__event_list_title__event_list_title', __( 'Upcoming Events', 'event_espresso' ));
972
+		return apply_filters('EED_Events_Archive_Filters__event_list_title__event_list_title', __('Upcoming Events', 'event_espresso'));
973 973
 	}
974 974
 
975 975
 
Please login to merge, or discard this patch.
public/Espresso_Arabica_2014/functions.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
  * @ link			http://www.eventespresso.com
10 10
  * @ version		4+
11 11
  */
12
-define( 'EE_THEME_FUNCTIONS_LOADED', TRUE );
12
+define('EE_THEME_FUNCTIONS_LOADED', TRUE);
13 13
 
14
-if ( ! function_exists( 'espresso_pagination' ) ) {
14
+if ( ! function_exists('espresso_pagination')) {
15 15
 	/**
16 16
 	 *    espresso_pagination
17 17
 	 *
@@ -23,21 +23,21 @@  discard block
 block discarded – undo
23 23
 		$big = 999999999; // need an unlikely integer
24 24
 		$pagination = paginate_links(
25 25
 			array(
26
-				'base'         => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
26
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
27 27
 				'format'       => '?paged=%#%',
28
-				'current'      => max( 1, get_query_var( 'paged' ) ),
28
+				'current'      => max(1, get_query_var('paged')),
29 29
 				'total'        => $wp_query->max_num_pages,
30 30
 				'show_all'     => true,
31 31
 				'end_size'     => 10,
32 32
 				'mid_size'     => 6,
33 33
 				'prev_next'    => true,
34
-				'prev_text'    => __( '&lsaquo; PREV', 'event_espresso' ),
35
-				'next_text'    => __( 'NEXT &rsaquo;', 'event_espresso' ),
34
+				'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
35
+				'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
36 36
 				'type'         => 'plain',
37 37
 				'add_args'     => false,
38 38
 				'add_fragment' => ''
39 39
 			)
40 40
 		);
41
-		echo ! empty( $pagination ) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
41
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
42 42
 	}
43 43
 }
44 44
\ No newline at end of file
Please login to merge, or discard this patch.
core/helpers/EEH_Template.helper.php 2 patches
Indentation   +930 added lines, -930 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 if (! defined('EVENT_ESPRESSO_VERSION')) {
3
-    exit('NO direct script access allowed');
3
+	exit('NO direct script access allowed');
4 4
 }
5 5
 /**
6 6
  * Event Espresso
@@ -16,35 +16,35 @@  discard block
 block discarded – undo
16 16
 
17 17
 
18 18
 if ( ! function_exists('espresso_get_template_part')) {
19
-    /**
20
-     * espresso_get_template_part
21
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
22
-     * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
23
-     *
24
-     * @param string $slug The slug name for the generic template.
25
-     * @param string $name The name of the specialised template.
26
-     * @return string        the html output for the formatted money value
27
-     */
28
-    function espresso_get_template_part($slug = null, $name = null)
29
-    {
30
-        EEH_Template::get_template_part($slug, $name);
31
-    }
19
+	/**
20
+	 * espresso_get_template_part
21
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead, and doesn't add base versions of files
22
+	 * so not a very useful function at all except that it adds familiarity PLUS filtering based off of the entire template part name
23
+	 *
24
+	 * @param string $slug The slug name for the generic template.
25
+	 * @param string $name The name of the specialised template.
26
+	 * @return string        the html output for the formatted money value
27
+	 */
28
+	function espresso_get_template_part($slug = null, $name = null)
29
+	{
30
+		EEH_Template::get_template_part($slug, $name);
31
+	}
32 32
 }
33 33
 
34 34
 
35 35
 if ( ! function_exists('espresso_get_object_css_class')) {
36
-    /**
37
-     * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38
-     *
39
-     * @param EE_Base_Class $object the EE object the css class is being generated for
40
-     * @param  string       $prefix added to the beginning of the generated class
41
-     * @param  string       $suffix added to the end of the generated class
42
-     * @return string
43
-     */
44
-    function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
45
-    {
46
-        return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47
-    }
36
+	/**
37
+	 * espresso_get_object_css_class - attempts to generate a css class based on the type of EE object passed
38
+	 *
39
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
40
+	 * @param  string       $prefix added to the beginning of the generated class
41
+	 * @param  string       $suffix added to the end of the generated class
42
+	 * @return string
43
+	 */
44
+	function espresso_get_object_css_class($object = null, $prefix = '', $suffix = '')
45
+	{
46
+		return EEH_Template::get_object_css_class($object, $prefix, $suffix);
47
+	}
48 48
 }
49 49
 
50 50
 
@@ -59,650 +59,650 @@  discard block
 block discarded – undo
59 59
 class EEH_Template
60 60
 {
61 61
 
62
-    private static $_espresso_themes = array();
63
-
64
-
65
-    /**
66
-     *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
67
-     *
68
-     * @return boolean
69
-     */
70
-    public static function is_espresso_theme()
71
-    {
72
-        return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
73
-    }
74
-
75
-    /**
76
-     *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
77
-     *    load it's functions.php file ( if not already loaded )
78
-     *
79
-     * @return void
80
-     */
81
-    public static function load_espresso_theme_functions()
82
-    {
83
-        if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
86
-            }
87
-        }
88
-    }
89
-
90
-
91
-    /**
92
-     *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
93
-     *
94
-     * @return array
95
-     */
96
-    public static function get_espresso_themes()
97
-    {
98
-        if (empty(EEH_Template::$_espresso_themes)) {
99
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
100
-            if (empty($espresso_themes)) {
101
-                return array();
102
-            }
103
-            if (($key = array_search('global_assets', $espresso_themes)) !== false) {
104
-                unset($espresso_themes[$key]);
105
-            }
106
-            EEH_Template::$_espresso_themes = array();
107
-            foreach ($espresso_themes as $espresso_theme) {
108
-                EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
109
-            }
110
-        }
111
-        return EEH_Template::$_espresso_themes;
112
-    }
113
-
114
-
115
-    /**
116
-     * EEH_Template::get_template_part
117
-     * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
118
-     * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
119
-     * filtering based off of the entire template part name
120
-     *
121
-     * @param string $slug The slug name for the generic template.
122
-     * @param string $name The name of the specialised template.
123
-     * @param array  $template_args
124
-     * @param bool   $return_string
125
-     * @return string        the html output for the formatted money value
126
-     */
127
-    public static function get_template_part(
128
-        $slug = null,
129
-        $name = null,
130
-        $template_args = array(),
131
-        $return_string = false
132
-    ) {
133
-        do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134
-        $templates = array();
135
-        $name      = (string)$name;
136
-        if ($name != '') {
137
-            $templates[] = "{$slug}-{$name}.php";
138
-        }
139
-        // allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
140
-        if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
141
-            EEH_Template::locate_template($templates, $template_args, true, $return_string);
142
-        }
143
-    }
144
-
145
-
146
-    /**
147
-     *    locate_template
148
-     *    locate a template file by looking in the following places, in the following order:
149
-     *        <server path up to>/wp-content/themes/<current active WordPress theme>/
150
-     *        <assumed full absolute server path>
151
-     *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
152
-     *        <server path up to>/wp-content/uploads/espresso/templates/
153
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
154
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
155
-     *        <server path up to>/wp-content/plugins/<EE4 folder>/
156
-     *    as soon as the template is found in one of these locations, it will be returned or loaded
157
-     *        Example:
158
-     *          You are using the WordPress Twenty Sixteen theme,
159
-     *        and you want to customize the "some-event.template.php" template,
160
-     *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
161
-     *          Assuming WP is installed on your server in the "/home/public_html/" folder,
162
-     *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
163
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
164
-     *        /relative/path/to/some-event.template.php
165
-     *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
166
-     *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
167
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
168
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
169
-     *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
170
-     *          Had you passed an absolute path to your template that was in some other location,
171
-     *        ie: "/absolute/path/to/some-event.template.php"
172
-     *          then the search would have been :
173
-     *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
174
-     *        /absolute/path/to/some-event.template.php
175
-     *          and stopped there upon finding it in the second location
176
-     *
177
-     * @param array|string $templates       array of template file names including extension (or just a single string)
178
-     * @param  array       $template_args   an array of arguments to be extracted for use in the template
179
-     * @param  boolean     $load            whether to pass the located template path on to the
180
-     *                                      EEH_Template::display_template() method or simply return it
181
-     * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
182
-     *                                      string
183
-     * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
184
-     *                                      generate a custom template or not. Used in places where you don't actually
185
-     *                                      load the template, you just want to know if there's a custom version of it.
186
-     * @return mixed
187
-     */
188
-    public static function locate_template(
189
-        $templates = array(),
190
-        $template_args = array(),
191
-        $load = true,
192
-        $return_string = true,
193
-        $check_if_custom = false
194
-    ) {
195
-        // first use WP locate_template to check for template in the current theme folder
196
-        $template_path = locate_template($templates);
197
-
198
-        if ($check_if_custom && ! empty($template_path)) {
199
-            return true;
200
-        }
201
-
202
-        // not in the theme
203
-        if (empty($template_path)) {
204
-            // not even a template to look for ?
205
-            if (empty($templates)) {
206
-                // get post_type
207
-                $post_type = EE_Registry::instance()->REQ->get('post_type');
208
-                // get array of EE Custom Post Types
209
-                $EE_CPTs = EE_Register_CPTs::get_CPTs();
210
-                // build template name based on request
211
-                if (isset($EE_CPTs[$post_type])) {
212
-                    $archive_or_single = is_archive() ? 'archive' : '';
213
-                    $archive_or_single = is_single() ? 'single' : $archive_or_single;
214
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
215
-                }
216
-            }
217
-            // currently active EE template theme
218
-            $current_theme = EE_Config::get_current_theme();
219
-
220
-            // array of paths to folders that may contain templates
221
-            $template_folder_paths = array(
222
-                // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
224
-                // then in the root of the /wp-content/uploads/espresso/templates/ folder
225
-                EVENT_ESPRESSO_TEMPLATE_DIR,
226
-            );
227
-
228
-            //add core plugin folders for checking only if we're not $check_if_custom
229
-            if ( ! $check_if_custom) {
230
-                $core_paths            = array(
231
-                    // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
-                    EE_PUBLIC . $current_theme,
233
-                    // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
-                    EE_TEMPLATES . $current_theme,
235
-                    // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236
-                    EE_PLUGIN_DIR_PATH,
237
-                );
238
-                $template_folder_paths = array_merge($template_folder_paths, $core_paths);
239
-            }
240
-
241
-            // now filter that array
242
-            $template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths',
243
-                $template_folder_paths);
244
-            $templates             = is_array($templates) ? $templates : array($templates);
245
-            $template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
246
-            // array to hold all possible template paths
247
-            $full_template_paths = array();
248
-
249
-            // loop through $templates
250
-            foreach ($templates as $template) {
251
-                // normalize directory separators
252
-                $template                      = EEH_File::standardise_directory_separators($template);
253
-                $file_name                     = basename($template);
254
-                $template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
255
-                // while looping through all template folder paths
256
-                foreach ($template_folder_paths as $template_folder_path) {
257
-                    // normalize directory separators
258
-                    $template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
259
-                    // determine if any common base path exists between the two paths
260
-                    $common_base_path = EEH_Template::_find_common_base_path(
261
-                        array($template_folder_path, $template_path_minus_file_name)
262
-                    );
263
-                    if ($common_base_path !== '') {
264
-                        // both paths have a common base, so just tack the filename onto our search path
265
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
266
-                    } else {
267
-                        // no common base path, so let's just concatenate
268
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
269
-                    }
270
-                    // build up our template locations array by adding our resolved paths
271
-                    $full_template_paths[] = $resolved_path;
272
-                }
273
-                // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274
-                array_unshift($full_template_paths, $template);
275
-                // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
-                array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
277
-            }
278
-            // filter final array of full template paths
279
-            $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280
-                $full_template_paths, $file_name);
281
-            // now loop through our final array of template location paths and check each location
282
-            foreach ((array)$full_template_paths as $full_template_path) {
283
-                if (is_readable($full_template_path)) {
284
-                    $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285
-                    break;
286
-                }
287
-            }
288
-        }
289
-
290
-        // hook that can be used to display the full template path that will be used
291
-        do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
292
-
293
-        // if we got it and you want to see it...
294
-        if ($template_path && $load && ! $check_if_custom) {
295
-            if ($return_string) {
296
-                return EEH_Template::display_template($template_path, $template_args, true);
297
-            } else {
298
-                EEH_Template::display_template($template_path, $template_args, false);
299
-            }
300
-        }
301
-        return $check_if_custom && ! empty($template_path) ? true : $template_path;
302
-    }
303
-
304
-
305
-    /**
306
-     * _find_common_base_path
307
-     * given two paths, this determines if there is a common base path between the two
308
-     *
309
-     * @param array $paths
310
-     * @return string
311
-     */
312
-    protected static function _find_common_base_path($paths)
313
-    {
314
-        $last_offset      = 0;
315
-        $common_base_path = '';
316
-        while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
317
-            $dir_length = $index - $last_offset + 1;
318
-            $directory  = substr($paths[0], $last_offset, $dir_length);
319
-            foreach ($paths as $path) {
320
-                if (substr($path, $last_offset, $dir_length) != $directory) {
321
-                    return $common_base_path;
322
-                }
323
-            }
324
-            $common_base_path .= $directory;
325
-            $last_offset = $index + 1;
326
-        }
327
-        return substr($common_base_path, 0, -1);
328
-    }
329
-
330
-
331
-    /**
332
-     * load and display a template
333
-     *
334
-     * @param bool|string $template_path server path to the file to be loaded, including file name and extension
335
-     * @param  array      $template_args an array of arguments to be extracted for use in the template
336
-     * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
337
-     * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
338
-     *                                      not found or is not readable
339
-     * @return mixed string
340
-     * @throws \DomainException
341
-     */
62
+	private static $_espresso_themes = array();
63
+
64
+
65
+	/**
66
+	 *    is_espresso_theme - returns TRUE or FALSE on whether the currently active WP theme is an espresso theme
67
+	 *
68
+	 * @return boolean
69
+	 */
70
+	public static function is_espresso_theme()
71
+	{
72
+		return wp_get_theme()->get('TextDomain') == 'event_espresso' ? true : false;
73
+	}
74
+
75
+	/**
76
+	 *    load_espresso_theme_functions - if current theme is an espresso theme, or uses ee theme template parts, then
77
+	 *    load it's functions.php file ( if not already loaded )
78
+	 *
79
+	 * @return void
80
+	 */
81
+	public static function load_espresso_theme_functions()
82
+	{
83
+		if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
+			if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
+				require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
86
+			}
87
+		}
88
+	}
89
+
90
+
91
+	/**
92
+	 *    get_espresso_themes - returns an array of Espresso Child themes located in the /templates/ directory
93
+	 *
94
+	 * @return array
95
+	 */
96
+	public static function get_espresso_themes()
97
+	{
98
+		if (empty(EEH_Template::$_espresso_themes)) {
99
+			$espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
100
+			if (empty($espresso_themes)) {
101
+				return array();
102
+			}
103
+			if (($key = array_search('global_assets', $espresso_themes)) !== false) {
104
+				unset($espresso_themes[$key]);
105
+			}
106
+			EEH_Template::$_espresso_themes = array();
107
+			foreach ($espresso_themes as $espresso_theme) {
108
+				EEH_Template::$_espresso_themes[basename($espresso_theme)] = $espresso_theme;
109
+			}
110
+		}
111
+		return EEH_Template::$_espresso_themes;
112
+	}
113
+
114
+
115
+	/**
116
+	 * EEH_Template::get_template_part
117
+	 * basically a copy of the WordPress get_template_part() function but uses EEH_Template::locate_template() instead,
118
+	 * and doesn't add base versions of files so not a very useful function at all except that it adds familiarity PLUS
119
+	 * filtering based off of the entire template part name
120
+	 *
121
+	 * @param string $slug The slug name for the generic template.
122
+	 * @param string $name The name of the specialised template.
123
+	 * @param array  $template_args
124
+	 * @param bool   $return_string
125
+	 * @return string        the html output for the formatted money value
126
+	 */
127
+	public static function get_template_part(
128
+		$slug = null,
129
+		$name = null,
130
+		$template_args = array(),
131
+		$return_string = false
132
+	) {
133
+		do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134
+		$templates = array();
135
+		$name      = (string)$name;
136
+		if ($name != '') {
137
+			$templates[] = "{$slug}-{$name}.php";
138
+		}
139
+		// allow template parts to be turned off via something like: add_filter( 'FHEE__content_espresso_events_tickets_template__display_datetimes', '__return_false' );
140
+		if (apply_filters("FHEE__EEH_Template__get_template_part__display__{$slug}_{$name}", true)) {
141
+			EEH_Template::locate_template($templates, $template_args, true, $return_string);
142
+		}
143
+	}
144
+
145
+
146
+	/**
147
+	 *    locate_template
148
+	 *    locate a template file by looking in the following places, in the following order:
149
+	 *        <server path up to>/wp-content/themes/<current active WordPress theme>/
150
+	 *        <assumed full absolute server path>
151
+	 *        <server path up to>/wp-content/uploads/espresso/templates/<current EE theme>/
152
+	 *        <server path up to>/wp-content/uploads/espresso/templates/
153
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/public/<current EE theme>/
154
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/core/templates/<current EE theme>/
155
+	 *        <server path up to>/wp-content/plugins/<EE4 folder>/
156
+	 *    as soon as the template is found in one of these locations, it will be returned or loaded
157
+	 *        Example:
158
+	 *          You are using the WordPress Twenty Sixteen theme,
159
+	 *        and you want to customize the "some-event.template.php" template,
160
+	 *          which is located in the "/relative/path/to/" folder relative to the main EE plugin folder.
161
+	 *          Assuming WP is installed on your server in the "/home/public_html/" folder,
162
+	 *        EEH_Template::locate_template() will look at the following paths in order until the template is found:
163
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
164
+	 *        /relative/path/to/some-event.template.php
165
+	 *        /home/public_html/wp-content/uploads/espresso/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
166
+	 *        /home/public_html/wp-content/uploads/espresso/templates/relative/path/to/some-event.template.php
167
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/public/Espresso_Arabica_2014/relative/path/to/some-event.template.php
168
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/core/templates/Espresso_Arabica_2014/relative/path/to/some-event.template.php
169
+	 *        /home/public_html/wp-content/plugins/event-espresso-core-reg/relative/path/to/some-event.template.php
170
+	 *          Had you passed an absolute path to your template that was in some other location,
171
+	 *        ie: "/absolute/path/to/some-event.template.php"
172
+	 *          then the search would have been :
173
+	 *        /home/public_html/wp-content/themes/twentysixteen/some-event.template.php
174
+	 *        /absolute/path/to/some-event.template.php
175
+	 *          and stopped there upon finding it in the second location
176
+	 *
177
+	 * @param array|string $templates       array of template file names including extension (or just a single string)
178
+	 * @param  array       $template_args   an array of arguments to be extracted for use in the template
179
+	 * @param  boolean     $load            whether to pass the located template path on to the
180
+	 *                                      EEH_Template::display_template() method or simply return it
181
+	 * @param  boolean     $return_string   whether to send output immediately to screen, or capture and return as a
182
+	 *                                      string
183
+	 * @param boolean      $check_if_custom If TRUE, this flags this method to return boolean for whether this will
184
+	 *                                      generate a custom template or not. Used in places where you don't actually
185
+	 *                                      load the template, you just want to know if there's a custom version of it.
186
+	 * @return mixed
187
+	 */
188
+	public static function locate_template(
189
+		$templates = array(),
190
+		$template_args = array(),
191
+		$load = true,
192
+		$return_string = true,
193
+		$check_if_custom = false
194
+	) {
195
+		// first use WP locate_template to check for template in the current theme folder
196
+		$template_path = locate_template($templates);
197
+
198
+		if ($check_if_custom && ! empty($template_path)) {
199
+			return true;
200
+		}
201
+
202
+		// not in the theme
203
+		if (empty($template_path)) {
204
+			// not even a template to look for ?
205
+			if (empty($templates)) {
206
+				// get post_type
207
+				$post_type = EE_Registry::instance()->REQ->get('post_type');
208
+				// get array of EE Custom Post Types
209
+				$EE_CPTs = EE_Register_CPTs::get_CPTs();
210
+				// build template name based on request
211
+				if (isset($EE_CPTs[$post_type])) {
212
+					$archive_or_single = is_archive() ? 'archive' : '';
213
+					$archive_or_single = is_single() ? 'single' : $archive_or_single;
214
+					$templates         = $archive_or_single . '-' . $post_type . '.php';
215
+				}
216
+			}
217
+			// currently active EE template theme
218
+			$current_theme = EE_Config::get_current_theme();
219
+
220
+			// array of paths to folders that may contain templates
221
+			$template_folder_paths = array(
222
+				// first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
+				EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
224
+				// then in the root of the /wp-content/uploads/espresso/templates/ folder
225
+				EVENT_ESPRESSO_TEMPLATE_DIR,
226
+			);
227
+
228
+			//add core plugin folders for checking only if we're not $check_if_custom
229
+			if ( ! $check_if_custom) {
230
+				$core_paths            = array(
231
+					// in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
+					EE_PUBLIC . $current_theme,
233
+					// in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
+					EE_TEMPLATES . $current_theme,
235
+					// or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236
+					EE_PLUGIN_DIR_PATH,
237
+				);
238
+				$template_folder_paths = array_merge($template_folder_paths, $core_paths);
239
+			}
240
+
241
+			// now filter that array
242
+			$template_folder_paths = apply_filters('FHEE__EEH_Template__locate_template__template_folder_paths',
243
+				$template_folder_paths);
244
+			$templates             = is_array($templates) ? $templates : array($templates);
245
+			$template_folder_paths = is_array($template_folder_paths) ? $template_folder_paths : array($template_folder_paths);
246
+			// array to hold all possible template paths
247
+			$full_template_paths = array();
248
+
249
+			// loop through $templates
250
+			foreach ($templates as $template) {
251
+				// normalize directory separators
252
+				$template                      = EEH_File::standardise_directory_separators($template);
253
+				$file_name                     = basename($template);
254
+				$template_path_minus_file_name = substr($template, 0, (strlen($file_name) * -1));
255
+				// while looping through all template folder paths
256
+				foreach ($template_folder_paths as $template_folder_path) {
257
+					// normalize directory separators
258
+					$template_folder_path = EEH_File::standardise_directory_separators($template_folder_path);
259
+					// determine if any common base path exists between the two paths
260
+					$common_base_path = EEH_Template::_find_common_base_path(
261
+						array($template_folder_path, $template_path_minus_file_name)
262
+					);
263
+					if ($common_base_path !== '') {
264
+						// both paths have a common base, so just tack the filename onto our search path
265
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
266
+					} else {
267
+						// no common base path, so let's just concatenate
268
+						$resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
269
+					}
270
+					// build up our template locations array by adding our resolved paths
271
+					$full_template_paths[] = $resolved_path;
272
+				}
273
+				// if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274
+				array_unshift($full_template_paths, $template);
275
+				// path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
+				array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
277
+			}
278
+			// filter final array of full template paths
279
+			$full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280
+				$full_template_paths, $file_name);
281
+			// now loop through our final array of template location paths and check each location
282
+			foreach ((array)$full_template_paths as $full_template_path) {
283
+				if (is_readable($full_template_path)) {
284
+					$template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285
+					break;
286
+				}
287
+			}
288
+		}
289
+
290
+		// hook that can be used to display the full template path that will be used
291
+		do_action('AHEE__EEH_Template__locate_template__full_template_path', $template_path);
292
+
293
+		// if we got it and you want to see it...
294
+		if ($template_path && $load && ! $check_if_custom) {
295
+			if ($return_string) {
296
+				return EEH_Template::display_template($template_path, $template_args, true);
297
+			} else {
298
+				EEH_Template::display_template($template_path, $template_args, false);
299
+			}
300
+		}
301
+		return $check_if_custom && ! empty($template_path) ? true : $template_path;
302
+	}
303
+
304
+
305
+	/**
306
+	 * _find_common_base_path
307
+	 * given two paths, this determines if there is a common base path between the two
308
+	 *
309
+	 * @param array $paths
310
+	 * @return string
311
+	 */
312
+	protected static function _find_common_base_path($paths)
313
+	{
314
+		$last_offset      = 0;
315
+		$common_base_path = '';
316
+		while (($index = strpos($paths[0], DS, $last_offset)) !== false) {
317
+			$dir_length = $index - $last_offset + 1;
318
+			$directory  = substr($paths[0], $last_offset, $dir_length);
319
+			foreach ($paths as $path) {
320
+				if (substr($path, $last_offset, $dir_length) != $directory) {
321
+					return $common_base_path;
322
+				}
323
+			}
324
+			$common_base_path .= $directory;
325
+			$last_offset = $index + 1;
326
+		}
327
+		return substr($common_base_path, 0, -1);
328
+	}
329
+
330
+
331
+	/**
332
+	 * load and display a template
333
+	 *
334
+	 * @param bool|string $template_path server path to the file to be loaded, including file name and extension
335
+	 * @param  array      $template_args an array of arguments to be extracted for use in the template
336
+	 * @param  boolean    $return_string whether to send output immediately to screen, or capture and return as a string
337
+	 * @param bool        $throw_exceptions if set to true, will throw an exception if the template is either
338
+	 *                                      not found or is not readable
339
+	 * @return mixed string
340
+	 * @throws \DomainException
341
+	 */
342 342
 	public static function display_template(
343
-        $template_path    = false,
344
-        $template_args    = array(),
345
-        $return_string    = false,
346
-        $throw_exceptions = false
347
-    ) {
348
-
349
-        /**
350
-         * These two filters are intended for last minute changes to templates being loaded and/or template arg
351
-         * modifications.  NOTE... modifying these things can cause breakage as most templates running through
352
-         * the display_template method are templates we DON'T want modified (usually because of js
353
-         * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
354
-         * using this.
355
-         *
356
-         * @since 4.6.0
357
-         */
358
-        $template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
359
-        $template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
360
-
361
-        // you gimme nuttin - YOU GET NUTTIN !!
362
-        if ( ! $template_path || ! is_readable($template_path)) {
363
-            return '';
364
-        }
365
-        // if $template_args are not in an array, then make it so
366
-        if ( ! is_array($template_args) && ! is_object($template_args)) {
367
-            $template_args = array($template_args);
368
-        }
369
-        extract( $template_args, EXTR_SKIP );
370
-        // ignore whether template is accessible ?
371
-        if ( $throw_exceptions && ! is_readable( $template_path ) ) {
372
-            throw new \DomainException(
373
-                    esc_html__(
374
-                            'Invalid, unreadable, or missing file.',
375
-                            'event_espresso'
376
-                    )
377
-            );
378
-        }
379
-
380
-
381
-        if ($return_string) {
382
-            // because we want to return a string, we are going to capture the output
383
-            ob_start();
384
-            include($template_path);
385
-            return ob_get_clean();
386
-        } else {
387
-            include($template_path);
388
-        }
389
-        return '';
390
-    }
391
-
392
-
393
-    /**
394
-     * get_object_css_class - attempts to generate a css class based on the type of EE object passed
395
-     *
396
-     * @param EE_Base_Class $object the EE object the css class is being generated for
397
-     * @param  string       $prefix added to the beginning of the generated class
398
-     * @param  string       $suffix added to the end of the generated class
399
-     * @return string
400
-     */
401
-    public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402
-    {
403
-        // in the beginning...
404
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
405
-        // da muddle
406
-        $class = '';
407
-        // the end
408
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
409
-        // is the passed object an EE object ?
410
-        if ($object instanceof EE_Base_Class) {
411
-            // grab the exact type of object
412
-            $obj_class = get_class($object);
413
-            // depending on the type of object...
414
-            switch ($obj_class) {
415
-                // no specifics just yet...
416
-                default :
417
-                    $class = strtolower(str_replace('_', '-', $obj_class));
418
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
419
-
420
-            }
421
-        }
422
-        return $prefix . $class . $suffix;
423
-    }
424
-
425
-
426
-
427
-    /**
428
-     * EEH_Template::format_currency
429
-     * This helper takes a raw float value and formats it according to the default config country currency settings, or
430
-     * the country currency settings from the supplied country ISO code
431
-     *
432
-     * @param  float   $amount       raw money value
433
-     * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
434
-     * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
435
-     * @param string   $CNT_ISO      2 letter ISO code for a country
436
-     * @param string   $cur_code_span_class
437
-     * @return string        the html output for the formatted money value
438
-     * @throws \EE_Error
439
-     */
440
-    public static function format_currency(
441
-        $amount = null,
442
-        $return_raw = false,
443
-        $display_code = true,
444
-        $CNT_ISO = '',
445
-        $cur_code_span_class = 'currency-code'
446
-    ) {
447
-        // ensure amount was received
448
-        if ($amount === null) {
449
-            $msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
450
-            EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
451
-            return '';
452
-        }
453
-        //ensure amount is float
454
-        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
455
-        $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
456
-        // filter raw amount (allows 0.00 to be changed to "free" for example)
457
-        $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
458
-        // still a number or was amount converted to a string like "free" ?
459
-        if (is_float($amount_formatted)) {
460
-            // was a country ISO code passed ? if so generate currency config object for that country
461
-            $mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
462
-            // verify results
463
-            if ( ! $mny instanceof EE_Currency_Config) {
464
-                // set default config country currency settings
465
-                $mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
466
-                    ? EE_Registry::instance()->CFG->currency
467
-                    : new EE_Currency_Config();
468
-            }
469
-            // format float
470
-            $amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
471
-            // add formatting ?
472
-            if ( ! $return_raw) {
473
-                // add currency sign
474
-                if ($mny->sign_b4) {
475
-                    if ($amount >= 0) {
476
-                        $amount_formatted = $mny->sign . $amount_formatted;
477
-                    } else {
478
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
479
-                    }
480
-
481
-                } else {
482
-                    $amount_formatted = $amount_formatted . $mny->sign;
483
-                }
484
-
485
-                // filter to allow global setting of display_code
486
-                $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
487
-
488
-                // add currency code ?
489
-                $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
490
-            }
491
-            // filter results
492
-            $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
493
-                $amount_formatted, $mny, $return_raw);
494
-        }
495
-        // clean up vars
496
-        unset($mny);
497
-        // return formatted currency amount
498
-        return $amount_formatted;
499
-    }
500
-
501
-
502
-    /**
503
-     * This function is used for outputting the localized label for a given status id in the schema requested (and
504
-     * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
505
-     * related status model or model object (i.e. in documentation etc.)
506
-     *
507
-     * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
508
-     *                            match, then 'Unknown' will be returned.
509
-     * @param  boolean $plural    Whether to return plural or not
510
-     * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
511
-     * @return string             The localized label for the status id.
512
-     */
513
-    public static function pretty_status($status_id, $plural = false, $schema = 'upper')
514
-    {
515
-        /** @type EEM_Status $EEM_Status */
516
-        $EEM_Status = EE_Registry::instance()->load_model('Status');
517
-        $status     = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural,
518
-            $schema);
519
-        return $status[$status_id];
520
-    }
521
-
522
-
523
-    /**
524
-     * This helper just returns a button or link for the given parameters
525
-     *
526
-     * @param  string $url   the url for the link
527
-     * @param  string $label What is the label you want displayed for the button
528
-     * @param  string $class what class is used for the button (defaults to 'button-primary')
529
-     * @param string  $icon
530
-     * @param string  $title
531
-     * @return string the html output for the button
532
-     */
533
-    public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
534
-    {
535
-        $icon_html = '';
536
-        if ( ! empty($icon)) {
537
-            $dashicons = preg_split("(ee-icon |dashicons )", $icon);
538
-            $dashicons = array_filter($dashicons);
539
-            $count     = count($dashicons);
540
-            $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
541
-            foreach ($dashicons as $dashicon) {
542
-                $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
543
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
544
-            }
545
-            $icon_html .= $count > 1 ? '</span>' : '';
546
-        }
547
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
548
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
549
-        return $button;
550
-    }
551
-
552
-
553
-    /**
554
-     * This returns a generated link that will load the related help tab on admin pages.
555
-     *
556
-     * @param  string     $help_tab_id the id for the connected help tab
557
-     * @param bool|string $page        The page identifier for the page the help tab is on
558
-     * @param bool|string $action      The action (route) for the admin page the help tab is on.
559
-     * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
560
-     * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
561
-     * @return string              generated link
562
-     */
563
-    public static function get_help_tab_link(
564
-        $help_tab_id,
565
-        $page = false,
566
-        $action = false,
567
-        $icon_style = false,
568
-        $help_text = false
569
-    ) {
570
-
571
-        if ( ! $page) {
572
-            $page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
573
-        }
574
-
575
-        if ( ! $action) {
576
-            $action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
577
-        }
578
-
579
-        $action = empty($action) ? 'default' : $action;
580
-
581
-
582
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
583
-        $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
584
-        $help_text    = ! $help_text ? '' : $help_text;
585
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
586
-                'event_espresso') . '" > ' . $help_text . ' </a>';
587
-    }
588
-
589
-
590
-    /**
591
-     * This helper generates the html structure for the jquery joyride plugin with the given params.
592
-     *
593
-     * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
594
-     * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
595
-     * @param EE_Help_Tour
596
-     * @return string         html
597
-     */
598
-    public static function help_tour_stops_generator(EE_Help_Tour $tour)
599
-    {
600
-        $id    = $tour->get_slug();
601
-        $stops = $tour->get_stops();
602
-
603
-        $content = '<ol style="display:none" id="' . $id . '">';
604
-
605
-        foreach ($stops as $stop) {
606
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
607
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
608
-
609
-            //if container is set to modal then let's make sure we set the options accordingly
610
-            if (empty($data_id) && empty($data_class)) {
611
-                $stop['options']['modal']  = true;
612
-                $stop['options']['expose'] = true;
613
-            }
614
-
615
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
616
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
617
-            $inner_content = isset($stop['content']) ? $stop['content'] : '';
618
-
619
-            //options
620
-            if (isset($stop['options']) && is_array($stop['options'])) {
621
-                $options = ' data-options="';
622
-                foreach ($stop['options'] as $option => $value) {
623
-                    $options .= $option . ':' . $value . ';';
624
-                }
625
-                $options .= '"';
626
-            } else {
627
-                $options = '';
628
-            }
629
-
630
-            //let's put all together
631
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
632
-        }
633
-
634
-        $content .= '</ol>';
635
-        return $content;
636
-    }
637
-
638
-
639
-    /**
640
-     * This is a helper method to generate a status legend for a given status array.
641
-     * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
642
-     * status_array.
643
-     *
644
-     * @param  array  $status_array  array of statuses that will make up the legend. In format:
645
-     *                               array(
646
-     *                               'status_item' => 'status_name'
647
-     *                               )
648
-     * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
649
-     *                               the legend.
650
-     * @throws EE_Error
651
-     * @return string               html structure for status.
652
-     */
653
-    public static function status_legend($status_array, $active_status = '')
654
-    {
655
-        if ( ! is_array($status_array)) {
656
-            throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
657
-                'event_espresso'));
658
-        }
659
-
660
-        $setup_array = array();
661
-        foreach ($status_array as $item => $status) {
662
-            $setup_array[$item] = array(
663
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
664
-                'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
665
-                'status' => $status,
666
-            );
667
-        }
668
-
669
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
670
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
671
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
672
-        foreach ($setup_array as $item => $details) {
673
-            $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
674
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
675
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
676
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
677
-            $content .= '</dt>' . "\n";
678
-        }
679
-        $content .= '</dl>' . "\n";
680
-        $content .= '</div>' . "\n";
681
-        return $content;
682
-    }
683
-
684
-
685
-    /**
686
-     * Gets HTML for laying out a deeply-nested array (and objects) in a format
687
-     * that's nice for presenting in the wp admin
688
-     *
689
-     * @param mixed $data
690
-     * @return string
691
-     */
692
-    public static function layout_array_as_table($data)
693
-    {
694
-        if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
695
-            $data = (array)$data;
696
-        }
697
-        ob_start();
698
-        if (is_array($data)) {
699
-            if (EEH_Array::is_associative_array($data)) {
700
-                ?>
343
+		$template_path    = false,
344
+		$template_args    = array(),
345
+		$return_string    = false,
346
+		$throw_exceptions = false
347
+	) {
348
+
349
+		/**
350
+		 * These two filters are intended for last minute changes to templates being loaded and/or template arg
351
+		 * modifications.  NOTE... modifying these things can cause breakage as most templates running through
352
+		 * the display_template method are templates we DON'T want modified (usually because of js
353
+		 * dependencies etc).  So unless you know what you are doing, do NOT filter templates or template args
354
+		 * using this.
355
+		 *
356
+		 * @since 4.6.0
357
+		 */
358
+		$template_path = (string) apply_filters('FHEE__EEH_Template__display_template__template_path', $template_path);
359
+		$template_args = (array) apply_filters('FHEE__EEH_Template__display_template__template_args', $template_args);
360
+
361
+		// you gimme nuttin - YOU GET NUTTIN !!
362
+		if ( ! $template_path || ! is_readable($template_path)) {
363
+			return '';
364
+		}
365
+		// if $template_args are not in an array, then make it so
366
+		if ( ! is_array($template_args) && ! is_object($template_args)) {
367
+			$template_args = array($template_args);
368
+		}
369
+		extract( $template_args, EXTR_SKIP );
370
+		// ignore whether template is accessible ?
371
+		if ( $throw_exceptions && ! is_readable( $template_path ) ) {
372
+			throw new \DomainException(
373
+					esc_html__(
374
+							'Invalid, unreadable, or missing file.',
375
+							'event_espresso'
376
+					)
377
+			);
378
+		}
379
+
380
+
381
+		if ($return_string) {
382
+			// because we want to return a string, we are going to capture the output
383
+			ob_start();
384
+			include($template_path);
385
+			return ob_get_clean();
386
+		} else {
387
+			include($template_path);
388
+		}
389
+		return '';
390
+	}
391
+
392
+
393
+	/**
394
+	 * get_object_css_class - attempts to generate a css class based on the type of EE object passed
395
+	 *
396
+	 * @param EE_Base_Class $object the EE object the css class is being generated for
397
+	 * @param  string       $prefix added to the beginning of the generated class
398
+	 * @param  string       $suffix added to the end of the generated class
399
+	 * @return string
400
+	 */
401
+	public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402
+	{
403
+		// in the beginning...
404
+		$prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
405
+		// da muddle
406
+		$class = '';
407
+		// the end
408
+		$suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
409
+		// is the passed object an EE object ?
410
+		if ($object instanceof EE_Base_Class) {
411
+			// grab the exact type of object
412
+			$obj_class = get_class($object);
413
+			// depending on the type of object...
414
+			switch ($obj_class) {
415
+				// no specifics just yet...
416
+				default :
417
+					$class = strtolower(str_replace('_', '-', $obj_class));
418
+					$class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
419
+
420
+			}
421
+		}
422
+		return $prefix . $class . $suffix;
423
+	}
424
+
425
+
426
+
427
+	/**
428
+	 * EEH_Template::format_currency
429
+	 * This helper takes a raw float value and formats it according to the default config country currency settings, or
430
+	 * the country currency settings from the supplied country ISO code
431
+	 *
432
+	 * @param  float   $amount       raw money value
433
+	 * @param  boolean $return_raw   whether to return the formatted float value only with no currency sign or code
434
+	 * @param  boolean $display_code whether to display the country code (USD). Default = TRUE
435
+	 * @param string   $CNT_ISO      2 letter ISO code for a country
436
+	 * @param string   $cur_code_span_class
437
+	 * @return string        the html output for the formatted money value
438
+	 * @throws \EE_Error
439
+	 */
440
+	public static function format_currency(
441
+		$amount = null,
442
+		$return_raw = false,
443
+		$display_code = true,
444
+		$CNT_ISO = '',
445
+		$cur_code_span_class = 'currency-code'
446
+	) {
447
+		// ensure amount was received
448
+		if ($amount === null) {
449
+			$msg = __('In order to format currency, an amount needs to be passed.', 'event_espresso');
450
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
451
+			return '';
452
+		}
453
+		//ensure amount is float
454
+		$amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
455
+		$CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
456
+		// filter raw amount (allows 0.00 to be changed to "free" for example)
457
+		$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
458
+		// still a number or was amount converted to a string like "free" ?
459
+		if (is_float($amount_formatted)) {
460
+			// was a country ISO code passed ? if so generate currency config object for that country
461
+			$mny = $CNT_ISO !== '' ? new EE_Currency_Config($CNT_ISO) : null;
462
+			// verify results
463
+			if ( ! $mny instanceof EE_Currency_Config) {
464
+				// set default config country currency settings
465
+				$mny = EE_Registry::instance()->CFG->currency instanceof EE_Currency_Config
466
+					? EE_Registry::instance()->CFG->currency
467
+					: new EE_Currency_Config();
468
+			}
469
+			// format float
470
+			$amount_formatted = number_format($amount, $mny->dec_plc, $mny->dec_mrk, $mny->thsnds);
471
+			// add formatting ?
472
+			if ( ! $return_raw) {
473
+				// add currency sign
474
+				if ($mny->sign_b4) {
475
+					if ($amount >= 0) {
476
+						$amount_formatted = $mny->sign . $amount_formatted;
477
+					} else {
478
+						$amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
479
+					}
480
+
481
+				} else {
482
+					$amount_formatted = $amount_formatted . $mny->sign;
483
+				}
484
+
485
+				// filter to allow global setting of display_code
486
+				$display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
487
+
488
+				// add currency code ?
489
+				$amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
490
+			}
491
+			// filter results
492
+			$amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
493
+				$amount_formatted, $mny, $return_raw);
494
+		}
495
+		// clean up vars
496
+		unset($mny);
497
+		// return formatted currency amount
498
+		return $amount_formatted;
499
+	}
500
+
501
+
502
+	/**
503
+	 * This function is used for outputting the localized label for a given status id in the schema requested (and
504
+	 * possibly plural).  The intended use of this function is only for cases where wanting a label outside of a
505
+	 * related status model or model object (i.e. in documentation etc.)
506
+	 *
507
+	 * @param  string  $status_id Status ID matching a registered status in the esp_status table.  If there is no
508
+	 *                            match, then 'Unknown' will be returned.
509
+	 * @param  boolean $plural    Whether to return plural or not
510
+	 * @param  string  $schema    'UPPER', 'lower', or 'Sentence'
511
+	 * @return string             The localized label for the status id.
512
+	 */
513
+	public static function pretty_status($status_id, $plural = false, $schema = 'upper')
514
+	{
515
+		/** @type EEM_Status $EEM_Status */
516
+		$EEM_Status = EE_Registry::instance()->load_model('Status');
517
+		$status     = $EEM_Status->localized_status(array($status_id => __('unknown', 'event_espresso')), $plural,
518
+			$schema);
519
+		return $status[$status_id];
520
+	}
521
+
522
+
523
+	/**
524
+	 * This helper just returns a button or link for the given parameters
525
+	 *
526
+	 * @param  string $url   the url for the link
527
+	 * @param  string $label What is the label you want displayed for the button
528
+	 * @param  string $class what class is used for the button (defaults to 'button-primary')
529
+	 * @param string  $icon
530
+	 * @param string  $title
531
+	 * @return string the html output for the button
532
+	 */
533
+	public static function get_button_or_link($url, $label, $class = 'button-primary', $icon = '', $title = '')
534
+	{
535
+		$icon_html = '';
536
+		if ( ! empty($icon)) {
537
+			$dashicons = preg_split("(ee-icon |dashicons )", $icon);
538
+			$dashicons = array_filter($dashicons);
539
+			$count     = count($dashicons);
540
+			$icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
541
+			foreach ($dashicons as $dashicon) {
542
+				$type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
543
+				$icon_html .= '<span class="' . $type . $dashicon . '"></span>';
544
+			}
545
+			$icon_html .= $count > 1 ? '</span>' : '';
546
+		}
547
+		$label  = ! empty($icon) ? $icon_html . $label : $label;
548
+		$button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
549
+		return $button;
550
+	}
551
+
552
+
553
+	/**
554
+	 * This returns a generated link that will load the related help tab on admin pages.
555
+	 *
556
+	 * @param  string     $help_tab_id the id for the connected help tab
557
+	 * @param bool|string $page        The page identifier for the page the help tab is on
558
+	 * @param bool|string $action      The action (route) for the admin page the help tab is on.
559
+	 * @param bool|string $icon_style  (optional) include css class for the style you want to use for the help icon.
560
+	 * @param bool|string $help_text   (optional) send help text you want to use for the link if default not to be used
561
+	 * @return string              generated link
562
+	 */
563
+	public static function get_help_tab_link(
564
+		$help_tab_id,
565
+		$page = false,
566
+		$action = false,
567
+		$icon_style = false,
568
+		$help_text = false
569
+	) {
570
+
571
+		if ( ! $page) {
572
+			$page = isset($_REQUEST['page']) && ! empty($_REQUEST['page']) ? sanitize_key($_REQUEST['page']) : $page;
573
+		}
574
+
575
+		if ( ! $action) {
576
+			$action = isset($_REQUEST['action']) && ! empty($_REQUEST['action']) ? sanitize_key($_REQUEST['action']) : $action;
577
+		}
578
+
579
+		$action = empty($action) ? 'default' : $action;
580
+
581
+
582
+		$help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
583
+		$icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
584
+		$help_text    = ! $help_text ? '' : $help_text;
585
+		return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
586
+				'event_espresso') . '" > ' . $help_text . ' </a>';
587
+	}
588
+
589
+
590
+	/**
591
+	 * This helper generates the html structure for the jquery joyride plugin with the given params.
592
+	 *
593
+	 * @link http://zurb.com/playground/jquery-joyride-feature-tour-plugin
594
+	 * @see  EE_Admin_Page->_stop_callback() for the construct expected for the $stops param.
595
+	 * @param EE_Help_Tour
596
+	 * @return string         html
597
+	 */
598
+	public static function help_tour_stops_generator(EE_Help_Tour $tour)
599
+	{
600
+		$id    = $tour->get_slug();
601
+		$stops = $tour->get_stops();
602
+
603
+		$content = '<ol style="display:none" id="' . $id . '">';
604
+
605
+		foreach ($stops as $stop) {
606
+			$data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
607
+			$data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
608
+
609
+			//if container is set to modal then let's make sure we set the options accordingly
610
+			if (empty($data_id) && empty($data_class)) {
611
+				$stop['options']['modal']  = true;
612
+				$stop['options']['expose'] = true;
613
+			}
614
+
615
+			$custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
616
+			$button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
617
+			$inner_content = isset($stop['content']) ? $stop['content'] : '';
618
+
619
+			//options
620
+			if (isset($stop['options']) && is_array($stop['options'])) {
621
+				$options = ' data-options="';
622
+				foreach ($stop['options'] as $option => $value) {
623
+					$options .= $option . ':' . $value . ';';
624
+				}
625
+				$options .= '"';
626
+			} else {
627
+				$options = '';
628
+			}
629
+
630
+			//let's put all together
631
+			$content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
632
+		}
633
+
634
+		$content .= '</ol>';
635
+		return $content;
636
+	}
637
+
638
+
639
+	/**
640
+	 * This is a helper method to generate a status legend for a given status array.
641
+	 * Note this will only work if the incoming statuses have a key in the EEM_Status->localized_status() methods
642
+	 * status_array.
643
+	 *
644
+	 * @param  array  $status_array  array of statuses that will make up the legend. In format:
645
+	 *                               array(
646
+	 *                               'status_item' => 'status_name'
647
+	 *                               )
648
+	 * @param  string $active_status This is used to indicate what the active status is IF that is to be highlighted in
649
+	 *                               the legend.
650
+	 * @throws EE_Error
651
+	 * @return string               html structure for status.
652
+	 */
653
+	public static function status_legend($status_array, $active_status = '')
654
+	{
655
+		if ( ! is_array($status_array)) {
656
+			throw new EE_Error(esc_html__('The EEH_Template::status_legend helper required the incoming status_array argument to be an array!',
657
+				'event_espresso'));
658
+		}
659
+
660
+		$setup_array = array();
661
+		foreach ($status_array as $item => $status) {
662
+			$setup_array[$item] = array(
663
+				'class'  => 'ee-status-legend ee-status-legend-' . $status,
664
+				'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
665
+				'status' => $status,
666
+			);
667
+		}
668
+
669
+		$content = '<div class="ee-list-table-legend-container">' . "\n";
670
+		$content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
671
+		$content .= '<dl class="ee-list-table-legend">' . "\n\t";
672
+		foreach ($setup_array as $item => $details) {
673
+			$active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
674
+			$content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
675
+			$content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
676
+			$content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
677
+			$content .= '</dt>' . "\n";
678
+		}
679
+		$content .= '</dl>' . "\n";
680
+		$content .= '</div>' . "\n";
681
+		return $content;
682
+	}
683
+
684
+
685
+	/**
686
+	 * Gets HTML for laying out a deeply-nested array (and objects) in a format
687
+	 * that's nice for presenting in the wp admin
688
+	 *
689
+	 * @param mixed $data
690
+	 * @return string
691
+	 */
692
+	public static function layout_array_as_table($data)
693
+	{
694
+		if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
695
+			$data = (array)$data;
696
+		}
697
+		ob_start();
698
+		if (is_array($data)) {
699
+			if (EEH_Array::is_associative_array($data)) {
700
+				?>
701 701
                 <table class="widefat">
702 702
                     <tbody>
703 703
                     <?php
704
-                    foreach ($data as $data_key => $data_values) {
705
-                        ?>
704
+					foreach ($data as $data_key => $data_values) {
705
+						?>
706 706
                         <tr>
707 707
                             <td>
708 708
                                 <?php echo $data_key; ?>
@@ -712,248 +712,248 @@  discard block
 block discarded – undo
712 712
                             </td>
713 713
                         </tr>
714 714
                         <?php
715
-                    } ?>
715
+					} ?>
716 716
                     </tbody>
717 717
                 </table>
718 718
                 <?php
719
-            } else {
720
-                ?>
719
+			} else {
720
+				?>
721 721
                 <ul>
722 722
                     <?php
723
-                    foreach ($data as $datum) {
724
-                        echo "<li>";
725
-                        echo self::layout_array_as_table($datum);
726
-                        echo "</li>";
727
-                    } ?>
723
+					foreach ($data as $datum) {
724
+						echo "<li>";
725
+						echo self::layout_array_as_table($datum);
726
+						echo "</li>";
727
+					} ?>
728 728
                 </ul>
729 729
                 <?php
730
-            }
731
-        } else {
732
-            //simple value
733
-            echo esc_html($data);
734
-        }
735
-        return ob_get_clean();
736
-    }
737
-
738
-
739
-    /**
740
-     * wrapper for self::get_paging_html() that simply echos the generated paging html
741
-     *
742
-     * @since 4.4.0
743
-     * @see   self:get_paging_html() for argument docs.
744
-     * @param        $total_items
745
-     * @param        $current
746
-     * @param        $per_page
747
-     * @param        $url
748
-     * @param bool   $show_num_field
749
-     * @param string $paged_arg_name
750
-     * @param array  $items_label
751
-     * @return string
752
-     */
753
-    public static function paging_html(
754
-        $total_items,
755
-        $current,
756
-        $per_page,
757
-        $url,
758
-        $show_num_field = true,
759
-        $paged_arg_name = 'paged',
760
-        $items_label = array()
761
-    ) {
762
-        echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name,
763
-            $items_label);
764
-    }
765
-
766
-
767
-    /**
768
-     * A method for generating paging similar to WP_List_Table
769
-     *
770
-     * @since    4.4.0
771
-     * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
772
-     * @param  integer $total_items     How many total items there are to page.
773
-     * @param  integer $current         What the current page is.
774
-     * @param  integer $per_page        How many items per page.
775
-     * @param  string  $url             What the base url for page links is.
776
-     * @param  boolean $show_num_field  Whether to show the input for changing page number.
777
-     * @param  string  $paged_arg_name  The name of the key for the paged query argument.
778
-     * @param  array   $items_label     An array of singular/plural values for the items label:
779
-     *                                  array(
780
-     *                                  'single' => 'item',
781
-     *                                  'plural' => 'items'
782
-     *                                  )
783
-     * @return  string
784
-     */
785
-    public static function get_paging_html(
786
-        $total_items,
787
-        $current,
788
-        $per_page,
789
-        $url,
790
-        $show_num_field = true,
791
-        $paged_arg_name = 'paged',
792
-        $items_label = array()
793
-    ) {
794
-        $page_links     = array();
795
-        $disable_first  = $disable_last = '';
796
-        $total_items    = (int)$total_items;
797
-        $per_page       = (int)$per_page;
798
-        $current        = (int)$current;
799
-        $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
800
-
801
-        //filter items_label
802
-        $items_label = apply_filters(
803
-            'FHEE__EEH_Template__get_paging_html__items_label',
804
-            $items_label
805
-        );
806
-
807
-        if (empty($items_label)
808
-            || ! is_array($items_label)
809
-            || ! isset($items_label['single'])
810
-            || ! isset($items_label['plural'])
811
-        ) {
812
-            $items_label = array(
813
-                'single' => __('1 item', 'event_espresso'),
814
-                'plural' => __('%s items', 'event_espresso'),
815
-            );
816
-        } else {
817
-            $items_label = array(
818
-                'single' => '1 ' . esc_html($items_label['single']),
819
-                'plural' => '%s ' . esc_html($items_label['plural']),
820
-            );
821
-        }
822
-
823
-        $total_pages = ceil($total_items / $per_page);
824
-
825
-        if ($total_pages <= 1) {
826
-            return '';
827
-        }
828
-
829
-        $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
830
-
831
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
832
-
833
-        if ($current === 1) {
834
-            $disable_first = ' disabled';
835
-        }
836
-        if ($current == $total_pages) {
837
-            $disable_last = ' disabled';
838
-        }
839
-
840
-        $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
841
-            'first-page' . $disable_first,
842
-            esc_attr__('Go to the first page'),
843
-            esc_url(remove_query_arg($paged_arg_name, $url)),
844
-            '&laquo;'
845
-        );
846
-
847
-        $page_links[] = sprintf(
848
-            '<a class="%s" title="%s" href="%s">%s</a>',
849
-            'prev-page' . $disable_first,
850
-            esc_attr__('Go to the previous page'),
851
-            esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
852
-            '&lsaquo;'
853
-        );
854
-
855
-        if ( ! $show_num_field) {
856
-            $html_current_page = $current;
857
-        } else {
858
-            $html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
859
-                esc_attr__('Current page'),
860
-                $current,
861
-                strlen($total_pages)
862
-            );
863
-        }
864
-
865
-        $html_total_pages = sprintf(
866
-            '<span class="total-pages">%s</span>',
867
-            number_format_i18n($total_pages)
868
-        );
869
-        $page_links[]     = sprintf(
870
-            _x('%3$s%1$s of %2$s%4$s', 'paging'),
871
-            $html_current_page,
872
-            $html_total_pages,
873
-            '<span class="paging-input">',
874
-            '</span>'
875
-        );
876
-
877
-        $page_links[] = sprintf(
878
-            '<a class="%s" title="%s" href="%s">%s</a>',
879
-            'next-page' . $disable_last,
880
-            esc_attr__('Go to the next page'),
881
-            esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
882
-            '&rsaquo;'
883
-        );
884
-
885
-        $page_links[] = sprintf(
886
-            '<a class="%s" title="%s" href="%s">%s</a>',
887
-            'last-page' . $disable_last,
888
-            esc_attr__('Go to the last page'),
889
-            esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
890
-            '&raquo;'
891
-        );
892
-
893
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
894
-        // set page class
895
-        if ($total_pages) {
896
-            $page_class = $total_pages < 2 ? ' one-page' : '';
897
-        } else {
898
-            $page_class = ' no-pages';
899
-        }
900
-
901
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
902
-    }
903
-
904
-
905
-    /**
906
-     * @param string $wrap_class
907
-     * @param string $wrap_id
908
-     * @return string
909
-     */
910
-    public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
911
-    {
912
-        $admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
913
-        if (
914
-            ! $admin &&
915
-            ! apply_filters(
916
-                'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
917
-                EE_Registry::instance()->CFG->admin->show_reg_footer
918
-            )
919
-        ) {
920
-            return '';
921
-        }
922
-        $tag        = $admin ? 'span' : 'div';
923
-        $attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
924
-        $wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
925
-        $attributes .= ! empty($wrap_class)
926
-            ? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
927
-            : ' class="powered-by-event-espresso-credit"';
928
-        $query_args = array_merge(
929
-            array(
930
-                'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
931
-                'utm_source'   => 'powered_by_event_espresso',
932
-                'utm_medium'   => 'link',
933
-                'utm_campaign' => 'powered_by',
934
-            ),
935
-            $query_args
936
-        );
937
-        $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
938
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
939
-        $url        = add_query_arg($query_args, 'https://eventespresso.com/');
940
-        $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
941
-        return (string)apply_filters(
942
-            'FHEE__EEH_Template__powered_by_event_espresso__html',
943
-            sprintf(
944
-                esc_html_x(
945
-                    '%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
946
-                    'Online event registration and ticketing powered by [link to eventespresso.com]',
947
-                    'event_espresso'
948
-                ),
949
-                "<{$tag}{$attributes}>",
950
-                "<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
951
-                $admin ? '' : '<br />'
952
-            ),
953
-            $wrap_class,
954
-            $wrap_id
955
-        );
956
-    }
730
+			}
731
+		} else {
732
+			//simple value
733
+			echo esc_html($data);
734
+		}
735
+		return ob_get_clean();
736
+	}
737
+
738
+
739
+	/**
740
+	 * wrapper for self::get_paging_html() that simply echos the generated paging html
741
+	 *
742
+	 * @since 4.4.0
743
+	 * @see   self:get_paging_html() for argument docs.
744
+	 * @param        $total_items
745
+	 * @param        $current
746
+	 * @param        $per_page
747
+	 * @param        $url
748
+	 * @param bool   $show_num_field
749
+	 * @param string $paged_arg_name
750
+	 * @param array  $items_label
751
+	 * @return string
752
+	 */
753
+	public static function paging_html(
754
+		$total_items,
755
+		$current,
756
+		$per_page,
757
+		$url,
758
+		$show_num_field = true,
759
+		$paged_arg_name = 'paged',
760
+		$items_label = array()
761
+	) {
762
+		echo self::get_paging_html($total_items, $current, $per_page, $url, $show_num_field, $paged_arg_name,
763
+			$items_label);
764
+	}
765
+
766
+
767
+	/**
768
+	 * A method for generating paging similar to WP_List_Table
769
+	 *
770
+	 * @since    4.4.0
771
+	 * @see      wp-admin/includes/class-wp-list-table.php WP_List_Table::pagination()
772
+	 * @param  integer $total_items     How many total items there are to page.
773
+	 * @param  integer $current         What the current page is.
774
+	 * @param  integer $per_page        How many items per page.
775
+	 * @param  string  $url             What the base url for page links is.
776
+	 * @param  boolean $show_num_field  Whether to show the input for changing page number.
777
+	 * @param  string  $paged_arg_name  The name of the key for the paged query argument.
778
+	 * @param  array   $items_label     An array of singular/plural values for the items label:
779
+	 *                                  array(
780
+	 *                                  'single' => 'item',
781
+	 *                                  'plural' => 'items'
782
+	 *                                  )
783
+	 * @return  string
784
+	 */
785
+	public static function get_paging_html(
786
+		$total_items,
787
+		$current,
788
+		$per_page,
789
+		$url,
790
+		$show_num_field = true,
791
+		$paged_arg_name = 'paged',
792
+		$items_label = array()
793
+	) {
794
+		$page_links     = array();
795
+		$disable_first  = $disable_last = '';
796
+		$total_items    = (int)$total_items;
797
+		$per_page       = (int)$per_page;
798
+		$current        = (int)$current;
799
+		$paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
800
+
801
+		//filter items_label
802
+		$items_label = apply_filters(
803
+			'FHEE__EEH_Template__get_paging_html__items_label',
804
+			$items_label
805
+		);
806
+
807
+		if (empty($items_label)
808
+			|| ! is_array($items_label)
809
+			|| ! isset($items_label['single'])
810
+			|| ! isset($items_label['plural'])
811
+		) {
812
+			$items_label = array(
813
+				'single' => __('1 item', 'event_espresso'),
814
+				'plural' => __('%s items', 'event_espresso'),
815
+			);
816
+		} else {
817
+			$items_label = array(
818
+				'single' => '1 ' . esc_html($items_label['single']),
819
+				'plural' => '%s ' . esc_html($items_label['plural']),
820
+			);
821
+		}
822
+
823
+		$total_pages = ceil($total_items / $per_page);
824
+
825
+		if ($total_pages <= 1) {
826
+			return '';
827
+		}
828
+
829
+		$item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
830
+
831
+		$output = '<span class="displaying-num">' . $item_label . '</span>';
832
+
833
+		if ($current === 1) {
834
+			$disable_first = ' disabled';
835
+		}
836
+		if ($current == $total_pages) {
837
+			$disable_last = ' disabled';
838
+		}
839
+
840
+		$page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
841
+			'first-page' . $disable_first,
842
+			esc_attr__('Go to the first page'),
843
+			esc_url(remove_query_arg($paged_arg_name, $url)),
844
+			'&laquo;'
845
+		);
846
+
847
+		$page_links[] = sprintf(
848
+			'<a class="%s" title="%s" href="%s">%s</a>',
849
+			'prev-page' . $disable_first,
850
+			esc_attr__('Go to the previous page'),
851
+			esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
852
+			'&lsaquo;'
853
+		);
854
+
855
+		if ( ! $show_num_field) {
856
+			$html_current_page = $current;
857
+		} else {
858
+			$html_current_page = sprintf("<input class='current-page' title='%s' type='text' name=$paged_arg_name value='%s' size='%d' />",
859
+				esc_attr__('Current page'),
860
+				$current,
861
+				strlen($total_pages)
862
+			);
863
+		}
864
+
865
+		$html_total_pages = sprintf(
866
+			'<span class="total-pages">%s</span>',
867
+			number_format_i18n($total_pages)
868
+		);
869
+		$page_links[]     = sprintf(
870
+			_x('%3$s%1$s of %2$s%4$s', 'paging'),
871
+			$html_current_page,
872
+			$html_total_pages,
873
+			'<span class="paging-input">',
874
+			'</span>'
875
+		);
876
+
877
+		$page_links[] = sprintf(
878
+			'<a class="%s" title="%s" href="%s">%s</a>',
879
+			'next-page' . $disable_last,
880
+			esc_attr__('Go to the next page'),
881
+			esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
882
+			'&rsaquo;'
883
+		);
884
+
885
+		$page_links[] = sprintf(
886
+			'<a class="%s" title="%s" href="%s">%s</a>',
887
+			'last-page' . $disable_last,
888
+			esc_attr__('Go to the last page'),
889
+			esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
890
+			'&raquo;'
891
+		);
892
+
893
+		$output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
894
+		// set page class
895
+		if ($total_pages) {
896
+			$page_class = $total_pages < 2 ? ' one-page' : '';
897
+		} else {
898
+			$page_class = ' no-pages';
899
+		}
900
+
901
+		return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
902
+	}
903
+
904
+
905
+	/**
906
+	 * @param string $wrap_class
907
+	 * @param string $wrap_id
908
+	 * @return string
909
+	 */
910
+	public static function powered_by_event_espresso($wrap_class = '', $wrap_id = '', array $query_args = array())
911
+	{
912
+		$admin = is_admin() && ! (defined('DOING_AJAX') && DOING_AJAX);
913
+		if (
914
+			! $admin &&
915
+			! apply_filters(
916
+				'FHEE__EEH_Template__powered_by_event_espresso__show_reg_footer',
917
+				EE_Registry::instance()->CFG->admin->show_reg_footer
918
+			)
919
+		) {
920
+			return '';
921
+		}
922
+		$tag        = $admin ? 'span' : 'div';
923
+		$attributes = ! empty($wrap_id) ? " id=\"{$wrap_id}\"" : '';
924
+		$wrap_class = $admin ? "{$wrap_class} float-left" : $wrap_class;
925
+		$attributes .= ! empty($wrap_class)
926
+			? " class=\"{$wrap_class} powered-by-event-espresso-credit\""
927
+			: ' class="powered-by-event-espresso-credit"';
928
+		$query_args = array_merge(
929
+			array(
930
+				'ap_id'        => EE_Registry::instance()->CFG->admin->affiliate_id(),
931
+				'utm_source'   => 'powered_by_event_espresso',
932
+				'utm_medium'   => 'link',
933
+				'utm_campaign' => 'powered_by',
934
+			),
935
+			$query_args
936
+		);
937
+		$powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
938
+			$admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
939
+		$url        = add_query_arg($query_args, 'https://eventespresso.com/');
940
+		$url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
941
+		return (string)apply_filters(
942
+			'FHEE__EEH_Template__powered_by_event_espresso__html',
943
+			sprintf(
944
+				esc_html_x(
945
+					'%3$s%1$sOnline event registration and ticketing powered by %2$s%3$s',
946
+					'Online event registration and ticketing powered by [link to eventespresso.com]',
947
+					'event_espresso'
948
+				),
949
+				"<{$tag}{$attributes}>",
950
+				"<a href=\"{$url}\" target=\"_blank\" rel=\"nofollow\">{$powered_by}</a></{$tag}>",
951
+				$admin ? '' : '<br />'
952
+			),
953
+			$wrap_class,
954
+			$wrap_id
955
+		);
956
+	}
957 957
 
958 958
 
959 959
 } //end EEH_Template class
@@ -962,33 +962,33 @@  discard block
 block discarded – undo
962 962
 
963 963
 
964 964
 if ( ! function_exists('espresso_pagination')) {
965
-    /**
966
-     *    espresso_pagination
967
-     *
968
-     * @access    public
969
-     * @return    void
970
-     */
971
-    function espresso_pagination()
972
-    {
973
-        global $wp_query;
974
-        $big        = 999999999; // need an unlikely integer
975
-        $pagination = paginate_links(
976
-            array(
977
-                'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
978
-                'format'       => '?paged=%#%',
979
-                'current'      => max(1, get_query_var('paged')),
980
-                'total'        => $wp_query->max_num_pages,
981
-                'show_all'     => true,
982
-                'end_size'     => 10,
983
-                'mid_size'     => 6,
984
-                'prev_next'    => true,
985
-                'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
986
-                'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
987
-                'type'         => 'plain',
988
-                'add_args'     => false,
989
-                'add_fragment' => '',
990
-            )
991
-        );
992
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
993
-    }
965
+	/**
966
+	 *    espresso_pagination
967
+	 *
968
+	 * @access    public
969
+	 * @return    void
970
+	 */
971
+	function espresso_pagination()
972
+	{
973
+		global $wp_query;
974
+		$big        = 999999999; // need an unlikely integer
975
+		$pagination = paginate_links(
976
+			array(
977
+				'base'         => str_replace($big, '%#%', esc_url(get_pagenum_link($big))),
978
+				'format'       => '?paged=%#%',
979
+				'current'      => max(1, get_query_var('paged')),
980
+				'total'        => $wp_query->max_num_pages,
981
+				'show_all'     => true,
982
+				'end_size'     => 10,
983
+				'mid_size'     => 6,
984
+				'prev_next'    => true,
985
+				'prev_text'    => __('&lsaquo; PREV', 'event_espresso'),
986
+				'next_text'    => __('NEXT &rsaquo;', 'event_espresso'),
987
+				'type'         => 'plain',
988
+				'add_args'     => false,
989
+				'add_fragment' => '',
990
+			)
991
+		);
992
+		echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
993
+	}
994 994
 }
995 995
\ No newline at end of file
Please login to merge, or discard this patch.
Spacing   +65 added lines, -65 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
 /**
@@ -81,8 +81,8 @@  discard block
 block discarded – undo
81 81
     public static function load_espresso_theme_functions()
82 82
     {
83 83
         if ( ! defined('EE_THEME_FUNCTIONS_LOADED')) {
84
-            if (is_readable(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php')) {
85
-                require_once(EE_PUBLIC . EE_Config::get_current_theme() . DS . 'functions.php');
84
+            if (is_readable(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php')) {
85
+                require_once(EE_PUBLIC.EE_Config::get_current_theme().DS.'functions.php');
86 86
             }
87 87
         }
88 88
     }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
     public static function get_espresso_themes()
97 97
     {
98 98
         if (empty(EEH_Template::$_espresso_themes)) {
99
-            $espresso_themes = glob(EE_PUBLIC . '*', GLOB_ONLYDIR);
99
+            $espresso_themes = glob(EE_PUBLIC.'*', GLOB_ONLYDIR);
100 100
             if (empty($espresso_themes)) {
101 101
                 return array();
102 102
             }
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
     ) {
133 133
         do_action("get_template_part_{$slug}-{$name}", $slug, $name);
134 134
         $templates = array();
135
-        $name      = (string)$name;
135
+        $name      = (string) $name;
136 136
         if ($name != '') {
137 137
             $templates[] = "{$slug}-{$name}.php";
138 138
         }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
                 if (isset($EE_CPTs[$post_type])) {
212 212
                     $archive_or_single = is_archive() ? 'archive' : '';
213 213
                     $archive_or_single = is_single() ? 'single' : $archive_or_single;
214
-                    $templates         = $archive_or_single . '-' . $post_type . '.php';
214
+                    $templates         = $archive_or_single.'-'.$post_type.'.php';
215 215
                 }
216 216
             }
217 217
             // currently active EE template theme
@@ -220,18 +220,18 @@  discard block
 block discarded – undo
220 220
             // array of paths to folders that may contain templates
221 221
             $template_folder_paths = array(
222 222
                 // first check the /wp-content/uploads/espresso/templates/(current EE theme)/  folder for an EE theme template file
223
-                EVENT_ESPRESSO_TEMPLATE_DIR . $current_theme,
223
+                EVENT_ESPRESSO_TEMPLATE_DIR.$current_theme,
224 224
                 // then in the root of the /wp-content/uploads/espresso/templates/ folder
225 225
                 EVENT_ESPRESSO_TEMPLATE_DIR,
226 226
             );
227 227
 
228 228
             //add core plugin folders for checking only if we're not $check_if_custom
229 229
             if ( ! $check_if_custom) {
230
-                $core_paths            = array(
230
+                $core_paths = array(
231 231
                     // in the  /wp-content/plugins/(EE4 folder)/public/(current EE theme)/ folder within the plugin
232
-                    EE_PUBLIC . $current_theme,
232
+                    EE_PUBLIC.$current_theme,
233 233
                     // in the  /wp-content/plugins/(EE4 folder)/core/templates/(current EE theme)/ folder within the plugin
234
-                    EE_TEMPLATES . $current_theme,
234
+                    EE_TEMPLATES.$current_theme,
235 235
                     // or maybe relative from the plugin root: /wp-content/plugins/(EE4 folder)/
236 236
                     EE_PLUGIN_DIR_PATH,
237 237
                 );
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
                     );
263 263
                     if ($common_base_path !== '') {
264 264
                         // both paths have a common base, so just tack the filename onto our search path
265
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $file_name;
265
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$file_name;
266 266
                     } else {
267 267
                         // no common base path, so let's just concatenate
268
-                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path) . $template;
268
+                        $resolved_path = EEH_File::end_with_directory_separator($template_folder_path).$template;
269 269
                     }
270 270
                     // build up our template locations array by adding our resolved paths
271 271
                     $full_template_paths[] = $resolved_path;
@@ -273,13 +273,13 @@  discard block
 block discarded – undo
273 273
                 // if $template is an absolute path, then we'll tack it onto the start of our array so that it gets searched first
274 274
                 array_unshift($full_template_paths, $template);
275 275
                 // path to the directory of the current theme: /wp-content/themes/(current WP theme)/
276
-                array_unshift($full_template_paths, get_stylesheet_directory() . DS . $file_name);
276
+                array_unshift($full_template_paths, get_stylesheet_directory().DS.$file_name);
277 277
             }
278 278
             // filter final array of full template paths
279 279
             $full_template_paths = apply_filters('FHEE__EEH_Template__locate_template__full_template_paths',
280 280
                 $full_template_paths, $file_name);
281 281
             // now loop through our final array of template location paths and check each location
282
-            foreach ((array)$full_template_paths as $full_template_path) {
282
+            foreach ((array) $full_template_paths as $full_template_path) {
283 283
                 if (is_readable($full_template_path)) {
284 284
                     $template_path = str_replace(array('\\', '/'), DIRECTORY_SEPARATOR, $full_template_path);
285 285
                     break;
@@ -366,9 +366,9 @@  discard block
 block discarded – undo
366 366
         if ( ! is_array($template_args) && ! is_object($template_args)) {
367 367
             $template_args = array($template_args);
368 368
         }
369
-        extract( $template_args, EXTR_SKIP );
369
+        extract($template_args, EXTR_SKIP);
370 370
         // ignore whether template is accessible ?
371
-        if ( $throw_exceptions && ! is_readable( $template_path ) ) {
371
+        if ($throw_exceptions && ! is_readable($template_path)) {
372 372
             throw new \DomainException(
373 373
                     esc_html__(
374 374
                             'Invalid, unreadable, or missing file.',
@@ -401,11 +401,11 @@  discard block
 block discarded – undo
401 401
     public static function get_object_css_class($object = null, $prefix = '', $suffix = '')
402 402
     {
403 403
         // in the beginning...
404
-        $prefix = ! empty($prefix) ? rtrim($prefix, '-') . '-' : '';
404
+        $prefix = ! empty($prefix) ? rtrim($prefix, '-').'-' : '';
405 405
         // da muddle
406 406
         $class = '';
407 407
         // the end
408
-        $suffix = ! empty($suffix) ? '-' . ltrim($suffix, '-') : '';
408
+        $suffix = ! empty($suffix) ? '-'.ltrim($suffix, '-') : '';
409 409
         // is the passed object an EE object ?
410 410
         if ($object instanceof EE_Base_Class) {
411 411
             // grab the exact type of object
@@ -415,11 +415,11 @@  discard block
 block discarded – undo
415 415
                 // no specifics just yet...
416 416
                 default :
417 417
                     $class = strtolower(str_replace('_', '-', $obj_class));
418
-                    $class .= method_exists($obj_class, 'name') ? '-' . sanitize_title($object->name()) : '';
418
+                    $class .= method_exists($obj_class, 'name') ? '-'.sanitize_title($object->name()) : '';
419 419
 
420 420
             }
421 421
         }
422
-        return $prefix . $class . $suffix;
422
+        return $prefix.$class.$suffix;
423 423
     }
424 424
 
425 425
 
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
             return '';
452 452
         }
453 453
         //ensure amount is float
454
-        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float)$amount);
454
+        $amount  = apply_filters('FHEE__EEH_Template__format_currency__raw_amount', (float) $amount);
455 455
         $CNT_ISO = apply_filters('FHEE__EEH_Template__format_currency__CNT_ISO', $CNT_ISO, $amount);
456 456
         // filter raw amount (allows 0.00 to be changed to "free" for example)
457 457
         $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount', $amount, $return_raw);
@@ -473,20 +473,20 @@  discard block
 block discarded – undo
473 473
                 // add currency sign
474 474
                 if ($mny->sign_b4) {
475 475
                     if ($amount >= 0) {
476
-                        $amount_formatted = $mny->sign . $amount_formatted;
476
+                        $amount_formatted = $mny->sign.$amount_formatted;
477 477
                     } else {
478
-                        $amount_formatted = '-' . $mny->sign . str_replace('-', '', $amount_formatted);
478
+                        $amount_formatted = '-'.$mny->sign.str_replace('-', '', $amount_formatted);
479 479
                     }
480 480
 
481 481
                 } else {
482
-                    $amount_formatted = $amount_formatted . $mny->sign;
482
+                    $amount_formatted = $amount_formatted.$mny->sign;
483 483
                 }
484 484
 
485 485
                 // filter to allow global setting of display_code
486 486
                 $display_code = apply_filters('FHEE__EEH_Template__format_currency__display_code', $display_code);
487 487
 
488 488
                 // add currency code ?
489
-                $amount_formatted = $display_code ? $amount_formatted . ' <span class="' . $cur_code_span_class . '">(' . $mny->code . ')</span>' : $amount_formatted;
489
+                $amount_formatted = $display_code ? $amount_formatted.' <span class="'.$cur_code_span_class.'">('.$mny->code.')</span>' : $amount_formatted;
490 490
             }
491 491
             // filter results
492 492
             $amount_formatted = apply_filters('FHEE__EEH_Template__format_currency__amount_formatted',
@@ -540,12 +540,12 @@  discard block
 block discarded – undo
540 540
             $icon_html .= $count > 1 ? '<span class="ee-composite-dashicon">' : '';
541 541
             foreach ($dashicons as $dashicon) {
542 542
                 $type = strpos($dashicon, 'ee-icon') !== false ? 'ee-icon ' : 'dashicons ';
543
-                $icon_html .= '<span class="' . $type . $dashicon . '"></span>';
543
+                $icon_html .= '<span class="'.$type.$dashicon.'"></span>';
544 544
             }
545 545
             $icon_html .= $count > 1 ? '</span>' : '';
546 546
         }
547
-        $label  = ! empty($icon) ? $icon_html . $label : $label;
548
-        $button = '<a id="' . sanitize_title_with_dashes($label) . '" href="' . $url . '" class="' . $class . '" title="' . $title . '">' . $label . '</a>';
547
+        $label  = ! empty($icon) ? $icon_html.$label : $label;
548
+        $button = '<a id="'.sanitize_title_with_dashes($label).'" href="'.$url.'" class="'.$class.'" title="'.$title.'">'.$label.'</a>';
549 549
         return $button;
550 550
     }
551 551
 
@@ -579,11 +579,11 @@  discard block
 block discarded – undo
579 579
         $action = empty($action) ? 'default' : $action;
580 580
 
581 581
 
582
-        $help_tab_lnk = $page . '-' . $action . '-' . $help_tab_id;
582
+        $help_tab_lnk = $page.'-'.$action.'-'.$help_tab_id;
583 583
         $icon         = ! $icon_style ? ' dashicons-editor-help' : $icon_style;
584 584
         $help_text    = ! $help_text ? '' : $help_text;
585
-        return '<a id="' . $help_tab_lnk . '" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22' . $icon . '" title="' . esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
586
-                'event_espresso') . '" > ' . $help_text . ' </a>';
585
+        return '<a id="'.$help_tab_lnk.'" class="ee-clickable dashicons espresso-help-tab-lnk ee-icon-size-22'.$icon.'" title="'.esc_attr__('Click to open the \'Help\' tab for more information about this feature.',
586
+                'event_espresso').'" > '.$help_text.' </a>';
587 587
     }
588 588
 
589 589
 
@@ -600,11 +600,11 @@  discard block
 block discarded – undo
600 600
         $id    = $tour->get_slug();
601 601
         $stops = $tour->get_stops();
602 602
 
603
-        $content = '<ol style="display:none" id="' . $id . '">';
603
+        $content = '<ol style="display:none" id="'.$id.'">';
604 604
 
605 605
         foreach ($stops as $stop) {
606
-            $data_id    = ! empty($stop['id']) ? ' data-id="' . $stop['id'] . '"' : '';
607
-            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="' . $stop['class'] . '"' : '';
606
+            $data_id    = ! empty($stop['id']) ? ' data-id="'.$stop['id'].'"' : '';
607
+            $data_class = empty($data_id) && ! empty($stop['class']) ? ' data-class="'.$stop['class'].'"' : '';
608 608
 
609 609
             //if container is set to modal then let's make sure we set the options accordingly
610 610
             if (empty($data_id) && empty($data_class)) {
@@ -612,15 +612,15 @@  discard block
 block discarded – undo
612 612
                 $stop['options']['expose'] = true;
613 613
             }
614 614
 
615
-            $custom_class  = ! empty($stop['custom_class']) ? ' class="' . $stop['custom_class'] . '"' : '';
616
-            $button_text   = ! empty($stop['button_text']) ? ' data-button="' . $stop['button_text'] . '"' : '';
615
+            $custom_class  = ! empty($stop['custom_class']) ? ' class="'.$stop['custom_class'].'"' : '';
616
+            $button_text   = ! empty($stop['button_text']) ? ' data-button="'.$stop['button_text'].'"' : '';
617 617
             $inner_content = isset($stop['content']) ? $stop['content'] : '';
618 618
 
619 619
             //options
620 620
             if (isset($stop['options']) && is_array($stop['options'])) {
621 621
                 $options = ' data-options="';
622 622
                 foreach ($stop['options'] as $option => $value) {
623
-                    $options .= $option . ':' . $value . ';';
623
+                    $options .= $option.':'.$value.';';
624 624
                 }
625 625
                 $options .= '"';
626 626
             } else {
@@ -628,7 +628,7 @@  discard block
 block discarded – undo
628 628
             }
629 629
 
630 630
             //let's put all together
631
-            $content .= '<li' . $data_id . $data_class . $custom_class . $button_text . $options . '>' . $inner_content . '</li>';
631
+            $content .= '<li'.$data_id.$data_class.$custom_class.$button_text.$options.'>'.$inner_content.'</li>';
632 632
         }
633 633
 
634 634
         $content .= '</ol>';
@@ -660,24 +660,24 @@  discard block
 block discarded – undo
660 660
         $setup_array = array();
661 661
         foreach ($status_array as $item => $status) {
662 662
             $setup_array[$item] = array(
663
-                'class'  => 'ee-status-legend ee-status-legend-' . $status,
663
+                'class'  => 'ee-status-legend ee-status-legend-'.$status,
664 664
                 'desc'   => EEH_Template::pretty_status($status, false, 'sentence'),
665 665
                 'status' => $status,
666 666
             );
667 667
         }
668 668
 
669
-        $content = '<div class="ee-list-table-legend-container">' . "\n";
670
-        $content .= '<h4 class="status-legend-title">' . esc_html__('Status Legend', 'event_espresso') . '</h4>' . "\n";
671
-        $content .= '<dl class="ee-list-table-legend">' . "\n\t";
669
+        $content = '<div class="ee-list-table-legend-container">'."\n";
670
+        $content .= '<h4 class="status-legend-title">'.esc_html__('Status Legend', 'event_espresso').'</h4>'."\n";
671
+        $content .= '<dl class="ee-list-table-legend">'."\n\t";
672 672
         foreach ($setup_array as $item => $details) {
673 673
             $active_class = $active_status == $details['status'] ? ' class="ee-is-active-status"' : '';
674
-            $content .= '<dt id="ee-legend-item-tooltip-' . $item . '"' . $active_class . '>' . "\n\t\t";
675
-            $content .= '<span class="' . $details['class'] . '"></span>' . "\n\t\t";
676
-            $content .= '<span class="ee-legend-description">' . $details['desc'] . '</span>' . "\n\t";
677
-            $content .= '</dt>' . "\n";
674
+            $content .= '<dt id="ee-legend-item-tooltip-'.$item.'"'.$active_class.'>'."\n\t\t";
675
+            $content .= '<span class="'.$details['class'].'"></span>'."\n\t\t";
676
+            $content .= '<span class="ee-legend-description">'.$details['desc'].'</span>'."\n\t";
677
+            $content .= '</dt>'."\n";
678 678
         }
679
-        $content .= '</dl>' . "\n";
680
-        $content .= '</div>' . "\n";
679
+        $content .= '</dl>'."\n";
680
+        $content .= '</div>'."\n";
681 681
         return $content;
682 682
     }
683 683
 
@@ -692,7 +692,7 @@  discard block
 block discarded – undo
692 692
     public static function layout_array_as_table($data)
693 693
     {
694 694
         if (is_object($data) || $data instanceof __PHP_Incomplete_Class) {
695
-            $data = (array)$data;
695
+            $data = (array) $data;
696 696
         }
697 697
         ob_start();
698 698
         if (is_array($data)) {
@@ -793,9 +793,9 @@  discard block
 block discarded – undo
793 793
     ) {
794 794
         $page_links     = array();
795 795
         $disable_first  = $disable_last = '';
796
-        $total_items    = (int)$total_items;
797
-        $per_page       = (int)$per_page;
798
-        $current        = (int)$current;
796
+        $total_items    = (int) $total_items;
797
+        $per_page       = (int) $per_page;
798
+        $current        = (int) $current;
799 799
         $paged_arg_name = empty($paged_arg_name) ? 'paged' : sanitize_key($paged_arg_name);
800 800
 
801 801
         //filter items_label
@@ -815,8 +815,8 @@  discard block
 block discarded – undo
815 815
             );
816 816
         } else {
817 817
             $items_label = array(
818
-                'single' => '1 ' . esc_html($items_label['single']),
819
-                'plural' => '%s ' . esc_html($items_label['plural']),
818
+                'single' => '1 '.esc_html($items_label['single']),
819
+                'plural' => '%s '.esc_html($items_label['plural']),
820 820
             );
821 821
         }
822 822
 
@@ -828,7 +828,7 @@  discard block
 block discarded – undo
828 828
 
829 829
         $item_label = $total_items > 1 ? sprintf($items_label['plural'], $total_items) : $items_label['single'];
830 830
 
831
-        $output = '<span class="displaying-num">' . $item_label . '</span>';
831
+        $output = '<span class="displaying-num">'.$item_label.'</span>';
832 832
 
833 833
         if ($current === 1) {
834 834
             $disable_first = ' disabled';
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
         }
839 839
 
840 840
         $page_links[] = sprintf("<a class='%s' title='%s' href='%s'>%s</a>",
841
-            'first-page' . $disable_first,
841
+            'first-page'.$disable_first,
842 842
             esc_attr__('Go to the first page'),
843 843
             esc_url(remove_query_arg($paged_arg_name, $url)),
844 844
             '&laquo;'
@@ -846,7 +846,7 @@  discard block
 block discarded – undo
846 846
 
847 847
         $page_links[] = sprintf(
848 848
             '<a class="%s" title="%s" href="%s">%s</a>',
849
-            'prev-page' . $disable_first,
849
+            'prev-page'.$disable_first,
850 850
             esc_attr__('Go to the previous page'),
851 851
             esc_url(add_query_arg($paged_arg_name, max(1, $current - 1), $url)),
852 852
             '&lsaquo;'
@@ -866,7 +866,7 @@  discard block
 block discarded – undo
866 866
             '<span class="total-pages">%s</span>',
867 867
             number_format_i18n($total_pages)
868 868
         );
869
-        $page_links[]     = sprintf(
869
+        $page_links[] = sprintf(
870 870
             _x('%3$s%1$s of %2$s%4$s', 'paging'),
871 871
             $html_current_page,
872 872
             $html_total_pages,
@@ -876,7 +876,7 @@  discard block
 block discarded – undo
876 876
 
877 877
         $page_links[] = sprintf(
878 878
             '<a class="%s" title="%s" href="%s">%s</a>',
879
-            'next-page' . $disable_last,
879
+            'next-page'.$disable_last,
880 880
             esc_attr__('Go to the next page'),
881 881
             esc_url(add_query_arg($paged_arg_name, min($total_pages, $current + 1), $url)),
882 882
             '&rsaquo;'
@@ -884,13 +884,13 @@  discard block
 block discarded – undo
884 884
 
885 885
         $page_links[] = sprintf(
886 886
             '<a class="%s" title="%s" href="%s">%s</a>',
887
-            'last-page' . $disable_last,
887
+            'last-page'.$disable_last,
888 888
             esc_attr__('Go to the last page'),
889 889
             esc_url(add_query_arg($paged_arg_name, $total_pages, $url)),
890 890
             '&raquo;'
891 891
         );
892 892
 
893
-        $output .= "\n" . '<span class="pagination-links">' . join("\n", $page_links) . '</span>';
893
+        $output .= "\n".'<span class="pagination-links">'.join("\n", $page_links).'</span>';
894 894
         // set page class
895 895
         if ($total_pages) {
896 896
             $page_class = $total_pages < 2 ? ' one-page' : '';
@@ -898,7 +898,7 @@  discard block
 block discarded – undo
898 898
             $page_class = ' no-pages';
899 899
         }
900 900
 
901
-        return '<div class="tablenav"><div class="tablenav-pages' . $page_class . '">' . $output . '</div></div>';
901
+        return '<div class="tablenav"><div class="tablenav-pages'.$page_class.'">'.$output.'</div></div>';
902 902
     }
903 903
 
904 904
 
@@ -935,10 +935,10 @@  discard block
 block discarded – undo
935 935
             $query_args
936 936
         );
937 937
         $powered_by = apply_filters('FHEE__EEH_Template__powered_by_event_espresso_text',
938
-            $admin ? 'Event Espresso - ' . EVENT_ESPRESSO_VERSION : 'Event Espresso');
938
+            $admin ? 'Event Espresso - '.EVENT_ESPRESSO_VERSION : 'Event Espresso');
939 939
         $url        = add_query_arg($query_args, 'https://eventespresso.com/');
940 940
         $url        = apply_filters('FHEE__EEH_Template__powered_by_event_espresso__url', $url);
941
-        return (string)apply_filters(
941
+        return (string) apply_filters(
942 942
             'FHEE__EEH_Template__powered_by_event_espresso__html',
943 943
             sprintf(
944 944
                 esc_html_x(
@@ -989,6 +989,6 @@  discard block
 block discarded – undo
989 989
                 'add_fragment' => '',
990 990
             )
991 991
         );
992
-        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">' . $pagination . '</div>' : '';
992
+        echo ! empty($pagination) ? '<div class="ee-pagination-dv ee-clear-float">'.$pagination.'</div>' : '';
993 993
     }
994 994
 }
995 995
\ No newline at end of file
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page.core.php 3 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -3065,7 +3065,7 @@
 block discarded – undo
3065 3065
      *
3066 3066
      * @param  int  $GRP_ID        The group being deleted
3067 3067
      * @param  bool $include_group whether to delete the Message Template Group as well.
3068
-     * @return bool boolean to indicate the success of the deletes or not.
3068
+     * @return integer boolean to indicate the success of the deletes or not.
3069 3069
      * @throws EE_Error
3070 3070
      * @throws InvalidArgumentException
3071 3071
      * @throws InvalidDataTypeException
Please login to merge, or discard this patch.
Spacing   +114 added lines, -114 removed lines patch added patch discarded remove patch
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
         $this->_admin_base_url  = EE_MSG_ADMIN_URL;
94 94
         $this->_admin_base_path = EE_MSG_ADMIN;
95 95
         
96
-        $this->_activate_state = isset($this->_req_data['activate_state']) ? (array)$this->_req_data['activate_state'] : array();
96
+        $this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array();
97 97
         
98 98
         $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null;
99 99
         $this->_load_message_resource_manager();
@@ -252,7 +252,7 @@  discard block
 block discarded – undo
252 252
             array('none_selected' => esc_html__('Show All Messengers', 'event_espresso')),
253 253
             $messenger_options
254 254
         );
255
-        $input             = new EE_Select_Input(
255
+        $input = new EE_Select_Input(
256 256
             $messenger_options,
257 257
             array(
258 258
                 'html_name'  => 'ee_messenger_filter_by',
@@ -290,7 +290,7 @@  discard block
 block discarded – undo
290 290
             array('none_selected' => esc_html__('Show All Message Types', 'event_espresso')),
291 291
             $message_type_options
292 292
         );
293
-        $input                = new EE_Select_Input(
293
+        $input = new EE_Select_Input(
294 294
             $message_type_options,
295 295
             array(
296 296
                 'html_name'  => 'ee_message_type_filter_by',
@@ -328,7 +328,7 @@  discard block
 block discarded – undo
328 328
             array('none_selected' => esc_html__('Show all Contexts', 'event_espresso')),
329 329
             $context_options
330 330
         );
331
-        $input           = new EE_Select_Input(
331
+        $input = new EE_Select_Input(
332 332
             $context_options,
333 333
             array(
334 334
                 'html_name'  => 'ee_context_filter_by',
@@ -710,53 +710,53 @@  discard block
 block discarded – undo
710 710
     
711 711
     public function messages_help_tab()
712 712
     {
713
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php');
713
+        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php');
714 714
     }
715 715
     
716 716
     
717 717
     public function messengers_help_tab()
718 718
     {
719
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php');
719
+        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php');
720 720
     }
721 721
     
722 722
     
723 723
     public function message_types_help_tab()
724 724
     {
725
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php');
725
+        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php');
726 726
     }
727 727
     
728 728
     
729 729
     public function messages_overview_help_tab()
730 730
     {
731
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php');
731
+        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php');
732 732
     }
733 733
     
734 734
     
735 735
     public function message_templates_help_tab()
736 736
     {
737
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php');
737
+        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php');
738 738
     }
739 739
     
740 740
     
741 741
     public function edit_message_template_help_tab()
742 742
     {
743
-        $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="'
743
+        $args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'
744 744
                         . esc_attr__('Editor Title', 'event_espresso')
745 745
                         . '" />';
746
-        $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="'
746
+        $args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'
747 747
                         . esc_attr__('Context Switcher and Preview', 'event_espresso')
748 748
                         . '" />';
749
-        $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="'
749
+        $args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'
750 750
                         . esc_attr__('Message Template Form Fields', 'event_espresso')
751 751
                         . '" />';
752
-        $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="'
752
+        $args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'
753 753
                         . esc_attr__('Shortcodes Metabox', 'event_espresso')
754 754
                         . '" />';
755
-        $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="'
755
+        $args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'
756 756
                         . esc_attr__('Publish Metabox', 'event_espresso')
757 757
                         . '" />';
758 758
         EEH_Template::display_template(
759
-            EE_MSG_TEMPLATE_PATH  . 'ee_msg_messages_templates_editor_help_tab.template.php',
759
+            EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php',
760 760
             $args
761 761
         );
762 762
     }
@@ -767,7 +767,7 @@  discard block
 block discarded – undo
767 767
         $this->_set_shortcodes();
768 768
         $args['shortcodes'] = $this->_shortcodes;
769 769
         EEH_Template::display_template(
770
-            EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php',
770
+            EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php',
771 771
             $args
772 772
         );
773 773
     }
@@ -775,16 +775,16 @@  discard block
 block discarded – undo
775 775
     
776 776
     public function preview_message_help_tab()
777 777
     {
778
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php');
778
+        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php');
779 779
     }
780 780
     
781 781
     
782 782
     public function settings_help_tab()
783 783
     {
784
-        $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png'
785
-                        . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
786
-        $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
787
-                        . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
784
+        $args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'
785
+                        . '" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />';
786
+        $args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'
787
+                        . '" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />';
788 788
         $args['img3'] = '<div class="switch">'
789 789
                         . '<input class="ee-on-off-toggle ee-toggle-round-flat"'
790 790
                         . ' type="checkbox" checked="checked">'
@@ -795,18 +795,18 @@  discard block
 block discarded – undo
795 795
                         . ' type="checkbox">'
796 796
                         . '<label for="ee-on-off-toggle-on"></label>'
797 797
                         . '</div>';
798
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
798
+        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args);
799 799
     }
800 800
     
801 801
     
802 802
     public function load_scripts_styles()
803 803
     {
804
-        wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
804
+        wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
805 805
         wp_enqueue_style('espresso_ee_msg');
806 806
         
807
-        wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js',
807
+        wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js',
808 808
             array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true);
809
-        wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL . 'ee_message_admin_list_table.js',
809
+        wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js',
810 810
             array('ee-dialog'), EVENT_ESPRESSO_VERSION);
811 811
     }
812 812
     
@@ -838,7 +838,7 @@  discard block
 block discarded – undo
838 838
         
839 839
         $this->_set_shortcodes();
840 840
         
841
-        EE_Registry::$i18n_js_strings['confirm_default_reset']        = sprintf(
841
+        EE_Registry::$i18n_js_strings['confirm_default_reset'] = sprintf(
842 842
             esc_html__(
843 843
                 'Are you sure you want to reset the %s %s message templates?  Remember continuing will reset the templates for all contexts in this messenger and message type group.',
844 844
                 'event_espresso'
@@ -853,7 +853,7 @@  discard block
 block discarded – undo
853 853
         
854 854
         wp_register_script(
855 855
             'ee_msgs_edit_js',
856
-            EE_MSG_ASSETS_URL . 'ee_message_editor.js',
856
+            EE_MSG_ASSETS_URL.'ee_message_editor.js',
857 857
             array('jquery'),
858 858
             EVENT_ESPRESSO_VERSION
859 859
         );
@@ -896,7 +896,7 @@  discard block
 block discarded – undo
896 896
     {
897 897
         wp_register_style(
898 898
             'ee-message-settings',
899
-            EE_MSG_ASSETS_URL . 'ee_message_settings.css',
899
+            EE_MSG_ASSETS_URL.'ee_message_settings.css',
900 900
             array(),
901 901
             EVENT_ESPRESSO_VERSION
902 902
         );
@@ -982,7 +982,7 @@  discard block
 block discarded – undo
982 982
             }
983 983
             $status_bulk_actions = $common_bulk_actions;
984 984
             //unset bulk actions not applying to status
985
-            if (! empty($status_bulk_actions)) {
985
+            if ( ! empty($status_bulk_actions)) {
986 986
                 switch ($status) {
987 987
                     case EEM_Message::status_idle:
988 988
                     case EEM_Message::status_resend:
@@ -1007,7 +1007,7 @@  discard block
 block discarded – undo
1007 1007
             }
1008 1008
 
1009 1009
             //skip adding messenger executing status to views because it will be included with the Failed view.
1010
-            if ( $status === EEM_Message::status_messenger_executing ) {
1010
+            if ($status === EEM_Message::status_messenger_executing) {
1011 1011
                 continue;
1012 1012
             }
1013 1013
             
@@ -1059,37 +1059,37 @@  discard block
 block discarded – undo
1059 1059
         /** @type array $status_items status legend setup */
1060 1060
         $status_items = array(
1061 1061
             'sent_status'       => array(
1062
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent,
1062
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent,
1063 1063
                 'desc'  => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence')
1064 1064
             ),
1065 1065
             'idle_status'       => array(
1066
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle,
1066
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle,
1067 1067
                 'desc'  => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence')
1068 1068
             ),
1069 1069
             'failed_status'     => array(
1070
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed,
1070
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed,
1071 1071
                 'desc'  => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence')
1072 1072
             ),
1073 1073
             'messenger_executing_status' => array(
1074
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_messenger_executing,
1074
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_messenger_executing,
1075 1075
                 'desc' => EEH_Template::pretty_status(EEM_Message::status_messenger_executing, false, 'sentence')
1076 1076
             ),
1077 1077
             'resend_status'     => array(
1078
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend,
1078
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend,
1079 1079
                 'desc'  => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence')
1080 1080
             ),
1081 1081
             'incomplete_status' => array(
1082
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete,
1082
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete,
1083 1083
                 'desc'  => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence')
1084 1084
             ),
1085 1085
             'retry_status'      => array(
1086
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry,
1086
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry,
1087 1087
                 'desc'  => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence')
1088 1088
             )
1089 1089
         );
1090 1090
         if (EEM_Message::debug()) {
1091 1091
             $status_items['debug_only_status'] = array(
1092
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only,
1092
+                'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only,
1093 1093
                 'desc'  => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence')
1094 1094
             );
1095 1095
         }
@@ -1101,8 +1101,8 @@  discard block
 block discarded – undo
1101 1101
     protected function _custom_mtps_preview()
1102 1102
     {
1103 1103
         $this->_admin_page_title              = esc_html__('Custom Message Templates (Preview)', 'event_espresso');
1104
-        $this->_template_args['preview_img']  = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png"'
1105
-            . ' alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso') . '" />';
1104
+        $this->_template_args['preview_img']  = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png"'
1105
+            . ' alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />';
1106 1106
         $this->_template_args['preview_text'] = '<strong>'
1107 1107
             . esc_html__(
1108 1108
                 'Custom Message Templates is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Custom Message Templates feature, you are able to create custom message templates and assign them on a per-event basis.',
@@ -1384,7 +1384,7 @@  discard block
 block discarded – undo
1384 1384
                             //let's verify if we need this extra field via the shortcodes parameter.
1385 1385
                             $continue = false;
1386 1386
                             if (isset($extra_array['shortcodes_required'])) {
1387
-                                foreach ((array)$extra_array['shortcodes_required'] as $shortcode) {
1387
+                                foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
1388 1388
                                     if ( ! array_key_exists($shortcode, $this->_shortcodes)) {
1389 1389
                                         $continue = true;
1390 1390
                                     }
@@ -1394,7 +1394,7 @@  discard block
 block discarded – undo
1394 1394
                                 }
1395 1395
                             }
1396 1396
                             
1397
-                            $field_id                                = $reference_field
1397
+                            $field_id = $reference_field
1398 1398
                                                                        . '-'
1399 1399
                                                                        . $extra_field
1400 1400
                                                                        . '-content';
@@ -1402,8 +1402,8 @@  discard block
 block discarded – undo
1402 1402
                             $template_form_fields[$field_id]['name'] = 'MTP_template_fields['
1403 1403
                                                                        . $reference_field
1404 1404
                                                                        . '][content]['
1405
-                                                                       . $extra_field . ']';
1406
-                            $css_class                               = isset($extra_array['css_class'])
1405
+                                                                       . $extra_field.']';
1406
+                            $css_class = isset($extra_array['css_class'])
1407 1407
                                 ? $extra_array['css_class']
1408 1408
                                 : '';
1409 1409
                             
@@ -1414,7 +1414,7 @@  discard block
 block discarded – undo
1414 1414
                                     is_array($validators[$extra_field])
1415 1415
                                     && isset($validators[$extra_field]['msg'])
1416 1416
                                 )
1417
-                                ? 'validate-error ' . $css_class
1417
+                                ? 'validate-error '.$css_class
1418 1418
                                 : $css_class;
1419 1419
                             
1420 1420
                             $template_form_fields[$field_id]['value'] = ! empty($message_templates)
@@ -1450,11 +1450,11 @@  discard block
 block discarded – undo
1450 1450
                                 
1451 1451
                             }/**/
1452 1452
                         }
1453
-                        $templatefield_MTP_id          = $reference_field . '-MTP_ID';
1454
-                        $templatefield_templatename_id = $reference_field . '-name';
1453
+                        $templatefield_MTP_id          = $reference_field.'-MTP_ID';
1454
+                        $templatefield_templatename_id = $reference_field.'-name';
1455 1455
                         
1456 1456
                         $template_form_fields[$templatefield_MTP_id] = array(
1457
-                            'name'       => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1457
+                            'name'       => 'MTP_template_fields['.$reference_field.'][MTP_ID]',
1458 1458
                             'label'      => null,
1459 1459
                             'input'      => 'hidden',
1460 1460
                             'type'       => 'int',
@@ -1467,7 +1467,7 @@  discard block
 block discarded – undo
1467 1467
                         );
1468 1468
                         
1469 1469
                         $template_form_fields[$templatefield_templatename_id] = array(
1470
-                            'name'       => 'MTP_template_fields[' . $reference_field . '][name]',
1470
+                            'name'       => 'MTP_template_fields['.$reference_field.'][name]',
1471 1471
                             'label'      => null,
1472 1472
                             'input'      => 'hidden',
1473 1473
                             'type'       => 'string',
@@ -1481,9 +1481,9 @@  discard block
 block discarded – undo
1481 1481
                     }
1482 1482
                     continue; //skip the next stuff, we got the necessary fields here for this dataset.
1483 1483
                 } else {
1484
-                    $field_id                                 = $template_field . '-content';
1484
+                    $field_id                                 = $template_field.'-content';
1485 1485
                     $template_form_fields[$field_id]          = $field_setup_array;
1486
-                    $template_form_fields[$field_id]['name']  = 'MTP_template_fields[' . $template_field . '][content]';
1486
+                    $template_form_fields[$field_id]['name']  = 'MTP_template_fields['.$template_field.'][content]';
1487 1487
                     $message_template                         = isset($message_templates[$context][$template_field])
1488 1488
                         ? $message_templates[$context][$template_field]
1489 1489
                         : null;
@@ -1506,7 +1506,7 @@  discard block
 block discarded – undo
1506 1506
                     $template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1507 1507
                                                                     && in_array($template_field, $v_fields, true)
1508 1508
                                                                     && isset($validators[$template_field]['msg'])
1509
-                        ? 'validate-error ' . $css_class
1509
+                        ? 'validate-error '.$css_class
1510 1510
                         : $css_class;
1511 1511
                     
1512 1512
                     //shortcode selector
@@ -1517,12 +1517,12 @@  discard block
 block discarded – undo
1517 1517
                 
1518 1518
                 //k took care of content field(s) now let's take care of others.
1519 1519
                 
1520
-                $templatefield_MTP_id                = $template_field . '-MTP_ID';
1521
-                $templatefield_field_templatename_id = $template_field . '-name';
1520
+                $templatefield_MTP_id                = $template_field.'-MTP_ID';
1521
+                $templatefield_field_templatename_id = $template_field.'-name';
1522 1522
                 
1523 1523
                 //foreach template field there are actually two form fields created
1524 1524
                 $template_form_fields[$templatefield_MTP_id] = array(
1525
-                    'name'       => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1525
+                    'name'       => 'MTP_template_fields['.$template_field.'][MTP_ID]',
1526 1526
                     'label'      => null,
1527 1527
                     'input'      => 'hidden',
1528 1528
                     'type'       => 'int',
@@ -1535,7 +1535,7 @@  discard block
 block discarded – undo
1535 1535
                 );
1536 1536
                 
1537 1537
                 $template_form_fields[$templatefield_field_templatename_id] = array(
1538
-                    'name'       => 'MTP_template_fields[' . $template_field . '][name]',
1538
+                    'name'       => 'MTP_template_fields['.$template_field.'][name]',
1539 1539
                     'label'      => null,
1540 1540
                     'input'      => 'hidden',
1541 1541
                     'type'       => 'string',
@@ -1653,7 +1653,7 @@  discard block
 block discarded – undo
1653 1653
                 'format'     => '%d',
1654 1654
                 'db-col'     => 'MTP_deleted'
1655 1655
             );
1656
-            $sidebar_form_fields['ee-msg-author']  = array(
1656
+            $sidebar_form_fields['ee-msg-author'] = array(
1657 1657
                 'name'       => 'MTP_user_id',
1658 1658
                 'label'      => esc_html__('Author', 'event_espresso'),
1659 1659
                 'input'      => 'hidden',
@@ -1672,17 +1672,17 @@  discard block
 block discarded – undo
1672 1672
                 'value' => $action
1673 1673
             );
1674 1674
             
1675
-            $sidebar_form_fields['ee-msg-id']        = array(
1675
+            $sidebar_form_fields['ee-msg-id'] = array(
1676 1676
                 'name'  => 'id',
1677 1677
                 'input' => 'hidden',
1678 1678
                 'type'  => 'int',
1679 1679
                 'value' => $GRP_ID
1680 1680
             );
1681 1681
             $sidebar_form_fields['ee-msg-evt-nonce'] = array(
1682
-                'name'  => $action . '_nonce',
1682
+                'name'  => $action.'_nonce',
1683 1683
                 'input' => 'hidden',
1684 1684
                 'type'  => 'string',
1685
-                'value' => wp_create_nonce($action . '_nonce')
1685
+                'value' => wp_create_nonce($action.'_nonce')
1686 1686
             );
1687 1687
             
1688 1688
             if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
@@ -1714,7 +1714,7 @@  discard block
 block discarded – undo
1714 1714
         );
1715 1715
         
1716 1716
         //add preview button
1717
-        $preview_url    = parent::add_query_args_and_nonce(
1717
+        $preview_url = parent::add_query_args_and_nonce(
1718 1718
             array(
1719 1719
                 'message_type' => $message_template_group->message_type(),
1720 1720
                 'messenger'    => $message_template_group->messenger(),
@@ -1724,7 +1724,7 @@  discard block
 block discarded – undo
1724 1724
             ),
1725 1725
             $this->_admin_base_url
1726 1726
         );
1727
-        $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">'
1727
+        $preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'
1728 1728
                           . esc_html__('Preview', 'event_espresso')
1729 1729
                           . '</a>';
1730 1730
         
@@ -1761,7 +1761,7 @@  discard block
 block discarded – undo
1761 1761
         
1762 1762
         $this->_template_path = $this->_template_args['GRP_ID']
1763 1763
             ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1764
-            : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1764
+            : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php';
1765 1765
         
1766 1766
         //send along EE_Message_Template_Group object for further template use.
1767 1767
         $this->_template_args['MTP'] = $message_template_group;
@@ -1816,7 +1816,7 @@  discard block
 block discarded – undo
1816 1816
     ) {
1817 1817
         $template_args = array(
1818 1818
             'context' => $context,
1819
-            'nonce' => wp_create_nonce('activate_' . $context . '_toggle_nonce'),
1819
+            'nonce' => wp_create_nonce('activate_'.$context.'_toggle_nonce'),
1820 1820
             'is_active' => $message_template_group->is_context_active($context),
1821 1821
             'on_off_action' => $message_template_group->is_context_active($context)
1822 1822
                 ? 'context-off'
@@ -1825,7 +1825,7 @@  discard block
 block discarded – undo
1825 1825
             'message_template_group_id' => $message_template_group->ID()
1826 1826
         );
1827 1827
         return EEH_Template::display_template(
1828
-          EE_MSG_TEMPLATE_PATH . 'ee_msg_editor_active_context_element.template.php',
1828
+          EE_MSG_TEMPLATE_PATH.'ee_msg_editor_active_context_element.template.php',
1829 1829
           $template_args,
1830 1830
           true
1831 1831
         );
@@ -1845,7 +1845,7 @@  discard block
 block discarded – undo
1845 1845
     {
1846 1846
         $success = true;
1847 1847
         //check for required data
1848
-        if (!isset(
1848
+        if ( ! isset(
1849 1849
             $this->_req_data['message_template_group_id'],
1850 1850
             $this->_req_data['context'],
1851 1851
             $this->_req_data['status']
@@ -1862,10 +1862,10 @@  discard block
 block discarded – undo
1862 1862
         $nonce = isset($this->_req_data['toggle_context_nonce'])
1863 1863
             ? sanitize_text_field($this->_req_data['toggle_context_nonce'])
1864 1864
             : '';
1865
-        $nonce_ref = 'activate_' . $this->_req_data['context'] . '_toggle_nonce';
1865
+        $nonce_ref = 'activate_'.$this->_req_data['context'].'_toggle_nonce';
1866 1866
         $this->_verify_nonce($nonce, $nonce_ref);
1867 1867
         $status = $this->_req_data['status'];
1868
-        if ($status !== 'off' && $status !=='on') {
1868
+        if ($status !== 'off' && $status !== 'on') {
1869 1869
             EE_Error::add_error(
1870 1870
                 sprintf(
1871 1871
                     esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
@@ -1880,7 +1880,7 @@  discard block
 block discarded – undo
1880 1880
         $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID(
1881 1881
             $this->_req_data['message_template_group_id']
1882 1882
         );
1883
-        if (! $message_template_group instanceof EE_Message_Template_Group) {
1883
+        if ( ! $message_template_group instanceof EE_Message_Template_Group) {
1884 1884
             EE_Error::add_error(
1885 1885
                 sprintf(
1886 1886
                     esc_html__(
@@ -2124,7 +2124,7 @@  discard block
 block discarded – undo
2124 2124
         }
2125 2125
         
2126 2126
         //let's add a button to go back to the edit view
2127
-        $query_args             = array(
2127
+        $query_args = array(
2128 2128
             'id'      => $this->_req_data['GRP_ID'],
2129 2129
             'context' => $this->_req_data['context'],
2130 2130
             'action'  => 'edit_message_template'
@@ -2150,7 +2150,7 @@  discard block
 block discarded – undo
2150 2150
         );
2151 2151
         //setup display of preview.
2152 2152
         $this->_admin_page_title                    = $preview_title;
2153
-        $this->_template_args['admin_page_content'] = $preview_button . '<br />' . stripslashes($preview);
2153
+        $this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview);
2154 2154
         $this->_template_args['data']['force_json'] = true;
2155 2155
         
2156 2156
         return '';
@@ -2256,7 +2256,7 @@  discard block
 block discarded – undo
2256 2256
         }
2257 2257
         
2258 2258
         //setup variation select values for the currently selected template.
2259
-        $variations               = $this->_message_template_group->get_template_pack()->get_variations(
2259
+        $variations = $this->_message_template_group->get_template_pack()->get_variations(
2260 2260
             $this->_message_template_group->messenger(),
2261 2261
             $this->_message_template_group->message_type()
2262 2262
         );
@@ -2270,12 +2270,12 @@  discard block
 block discarded – undo
2270 2270
         
2271 2271
         $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
2272 2272
         
2273
-        $template_args['template_packs_selector']        = EEH_Form_Fields::select_input(
2273
+        $template_args['template_packs_selector'] = EEH_Form_Fields::select_input(
2274 2274
             'MTP_template_pack',
2275 2275
             $tp_select_values,
2276 2276
             $this->_message_template_group->get_template_pack_name()
2277 2277
         );
2278
-        $template_args['variations_selector']            = EEH_Form_Fields::select_input(
2278
+        $template_args['variations_selector'] = EEH_Form_Fields::select_input(
2279 2279
             'MTP_template_variation',
2280 2280
             $variations_select_values,
2281 2281
             $this->_message_template_group->get_template_pack_variation()
@@ -2285,7 +2285,7 @@  discard block
 block discarded – undo
2285 2285
         $template_args['template_pack_description']      = $template_pack_labels->template_pack_description;
2286 2286
         $template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
2287 2287
         
2288
-        $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
2288
+        $template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php';
2289 2289
         
2290 2290
         EEH_Template::display_template($template, $template_args);
2291 2291
     }
@@ -2314,14 +2314,14 @@  discard block
 block discarded – undo
2314 2314
         if ( ! empty($fields)) {
2315 2315
             //yup there be fields
2316 2316
             foreach ($fields as $field => $config) {
2317
-                $field_id = $this->_message_template_group->messenger() . '_' . $field;
2317
+                $field_id = $this->_message_template_group->messenger().'_'.$field;
2318 2318
                 $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
2319 2319
                 $default  = isset($config['default']) ? $config['default'] : '';
2320 2320
                 $default  = isset($config['value']) ? $config['value'] : $default;
2321 2321
                 
2322 2322
                 // if type is hidden and the value is empty
2323 2323
                 // something may have gone wrong so let's correct with the defaults
2324
-                $fix              = $config['input'] === 'hidden'
2324
+                $fix = $config['input'] === 'hidden'
2325 2325
                                     && isset($existing[$field])
2326 2326
                                     && empty($existing[$field])
2327 2327
                     ? $default
@@ -2331,7 +2331,7 @@  discard block
 block discarded – undo
2331 2331
                     : $fix;
2332 2332
                 
2333 2333
                 $template_form_fields[$field_id] = array(
2334
-                    'name'       => 'test_settings_fld[' . $field . ']',
2334
+                    'name'       => 'test_settings_fld['.$field.']',
2335 2335
                     'label'      => $config['label'],
2336 2336
                     'input'      => $config['input'],
2337 2337
                     'type'       => $config['type'],
@@ -2399,7 +2399,7 @@  discard block
 block discarded – undo
2399 2399
         );
2400 2400
         
2401 2401
         return EEH_Template::display_template(
2402
-            EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php',
2402
+            EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php',
2403 2403
             $template_args,
2404 2404
             true
2405 2405
         );
@@ -2424,7 +2424,7 @@  discard block
 block discarded – undo
2424 2424
         //$messenger = $this->_message_template_group->messenger_obj();
2425 2425
         //now let's set the content depending on the status of the shortcodes array
2426 2426
         if (empty($shortcodes)) {
2427
-            $content = '<p>' . esc_html__('There are no valid shortcodes available', 'event_espresso') . '</p>';
2427
+            $content = '<p>'.esc_html__('There are no valid shortcodes available', 'event_espresso').'</p>';
2428 2428
             echo $content;
2429 2429
         } else {
2430 2430
             //$alt = 0;
@@ -2561,7 +2561,7 @@  discard block
 block discarded – undo
2561 2561
                     <?php
2562 2562
                 }
2563 2563
                 //setup nonce_url
2564
-                wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
2564
+                wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false);
2565 2565
                 ?>
2566 2566
                 <select name="context">
2567 2567
                     <?php
@@ -2662,7 +2662,7 @@  discard block
 block discarded – undo
2662 2662
         $context      = ucwords(str_replace('_', ' ', $context_slug));
2663 2663
         
2664 2664
         $item_desc = $messenger_label && $message_type_label
2665
-            ? $messenger_label . ' ' . $message_type_label . ' ' . $context . ' '
2665
+            ? $messenger_label.' '.$message_type_label.' '.$context.' '
2666 2666
             : '';
2667 2667
         $item_desc .= 'Message Template';
2668 2668
         $query_args  = array();
@@ -2764,7 +2764,7 @@  discard block
 block discarded – undo
2764 2764
                                 //default setup for it.
2765 2765
                                 //@link https://events.codebasehq.com/projects/event-espresso/tickets/9465
2766 2766
                                 $updated = $MTP->insert($message_template_fields);
2767
-                                if (! $updated || is_wp_error($updated)) {
2767
+                                if ( ! $updated || is_wp_error($updated)) {
2768 2768
                                     EE_Error::add_error(
2769 2769
                                         sprintf(
2770 2770
                                             esc_html__('%s field could not be updated.', 'event_espresso'),
@@ -3125,7 +3125,7 @@  discard block
 block discarded – undo
3125 3125
             : 'email';
3126 3126
         
3127 3127
         //let's setup the messenger tabs
3128
-        $this->_template_args['admin_page_header']         = EEH_Tabbed_Content::tab_text_links(
3128
+        $this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links(
3129 3129
             $this->_m_mt_settings['messenger_tabs'],
3130 3130
             'messenger_links',
3131 3131
             '|',
@@ -3193,10 +3193,10 @@  discard block
 block discarded – undo
3193 3193
                 
3194 3194
                 $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
3195 3195
                     'label'    => ucwords($message_type->label['singular']),
3196
-                    'class'    => 'message-type-' . $a_or_i,
3197
-                    'slug_id'  => $message_type->name . '-messagetype-' . $messenger->name,
3198
-                    'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'),
3199
-                    'href'     => 'espresso_' . $message_type->name . '_message_type_settings',
3196
+                    'class'    => 'message-type-'.$a_or_i,
3197
+                    'slug_id'  => $message_type->name.'-messagetype-'.$messenger->name,
3198
+                    'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'),
3199
+                    'href'     => 'espresso_'.$message_type->name.'_message_type_settings',
3200 3200
                     'title'    => $a_or_i === 'active'
3201 3201
                         ? esc_html__('Drag this message type to the Inactive window to deactivate', 'event_espresso')
3202 3202
                         : esc_html__('Drag this message type to the messenger to activate', 'event_espresso'),
@@ -3232,9 +3232,9 @@  discard block
 block discarded – undo
3232 3232
             $existing_settings = $message_type->get_existing_admin_settings($messenger->name);
3233 3233
             
3234 3234
             foreach ($fields as $fldname => $fldprops) {
3235
-                $field_id                       = $messenger->name . '-' . $message_type->name . '-' . $fldname;
3235
+                $field_id                       = $messenger->name.'-'.$message_type->name.'-'.$fldname;
3236 3236
                 $template_form_field[$field_id] = array(
3237
-                    'name'       => 'message_type_settings[' . $fldname . ']',
3237
+                    'name'       => 'message_type_settings['.$fldname.']',
3238 3238
                     'label'      => $fldprops['label'],
3239 3239
                     'input'      => $fldprops['field_type'],
3240 3240
                     'type'       => $fldprops['value_type'],
@@ -3285,12 +3285,12 @@  discard block
 block discarded – undo
3285 3285
             $settings_template_args['hidden_fields'],
3286 3286
             'array'
3287 3287
         );
3288
-        $settings_template_args['show_form']     = empty($settings_template_args['template_form_fields'])
3288
+        $settings_template_args['show_form'] = empty($settings_template_args['template_form_fields'])
3289 3289
             ? ' hidden'
3290 3290
             : '';
3291 3291
         
3292 3292
         
3293
-        $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
3293
+        $template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php';
3294 3294
         $content  = EEH_Template::display_template($template, $settings_template_args, true);
3295 3295
         
3296 3296
         return $content;
@@ -3325,11 +3325,11 @@  discard block
 block discarded – undo
3325 3325
                 )
3326 3326
                     ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active']
3327 3327
                     : '';
3328
-                $m_boxes[$messenger . '_a_box']         = sprintf(
3328
+                $m_boxes[$messenger.'_a_box'] = sprintf(
3329 3329
                     esc_html__('%s Settings', 'event_espresso'),
3330 3330
                     $tab_array['label']
3331 3331
                 );
3332
-                $m_template_args[$messenger . '_a_box'] = array(
3332
+                $m_template_args[$messenger.'_a_box'] = array(
3333 3333
                     'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3334 3334
                     'inactive_message_types' => isset(
3335 3335
                         $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']
@@ -3345,8 +3345,8 @@  discard block
 block discarded – undo
3345 3345
                 // message type meta boxes
3346 3346
                 // (which is really just the inactive container for each messenger
3347 3347
                 // showing inactive message types for that messenger)
3348
-                $mt_boxes[$messenger . '_i_box']         = esc_html__('Inactive Message Types', 'event_espresso');
3349
-                $mt_template_args[$messenger . '_i_box'] = array(
3348
+                $mt_boxes[$messenger.'_i_box']         = esc_html__('Inactive Message Types', 'event_espresso');
3349
+                $mt_template_args[$messenger.'_i_box'] = array(
3350 3350
                     'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3351 3351
                     'inactive_message_types' => isset(
3352 3352
                         $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']
@@ -3364,14 +3364,14 @@  discard block
 block discarded – undo
3364 3364
         
3365 3365
         
3366 3366
         //register messenger metaboxes
3367
-        $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
3367
+        $m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php';
3368 3368
         foreach ($m_boxes as $box => $label) {
3369 3369
             $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
3370 3370
             $msgr          = str_replace('_a_box', '', $box);
3371 3371
             add_meta_box(
3372
-                'espresso_' . $msgr . '_settings',
3372
+                'espresso_'.$msgr.'_settings',
3373 3373
                 $label,
3374
-                function ($post, $metabox) {
3374
+                function($post, $metabox) {
3375 3375
                     echo EEH_Template::display_template(
3376 3376
                             $metabox["args"]["template_path"],
3377 3377
                             $metabox["args"]["template_args"],
@@ -3386,17 +3386,17 @@  discard block
 block discarded – undo
3386 3386
         }
3387 3387
         
3388 3388
         //register message type metaboxes
3389
-        $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
3389
+        $mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php';
3390 3390
         foreach ($mt_boxes as $box => $label) {
3391 3391
             $callback_args = array(
3392 3392
                 'template_path' => $mt_template_path,
3393 3393
                 'template_args' => $mt_template_args[$box]
3394 3394
             );
3395
-            $mt            = str_replace('_i_box', '', $box);
3395
+            $mt = str_replace('_i_box', '', $box);
3396 3396
             add_meta_box(
3397
-                'espresso_' . $mt . '_inactive_mts',
3397
+                'espresso_'.$mt.'_inactive_mts',
3398 3398
                 $label,
3399
-                function ($post, $metabox) {
3399
+                function($post, $metabox) {
3400 3400
                     echo EEH_Template::display_template(
3401 3401
                             $metabox["args"]["template_path"],
3402 3402
                             $metabox["args"]["template_args"],
@@ -3543,7 +3543,7 @@  discard block
 block discarded – undo
3543 3543
             if ($form->is_valid()) {
3544 3544
                 $valid_data = $form->valid_data();
3545 3545
                 foreach ($valid_data as $property => $value) {
3546
-                    $setter = 'set_' . $property;
3546
+                    $setter = 'set_'.$property;
3547 3547
                     if (method_exists($network_config, $setter)) {
3548 3548
                         $network_config->{$setter}($value);
3549 3549
                     } else if (
@@ -3578,8 +3578,8 @@  discard block
 block discarded – undo
3578 3578
      */
3579 3579
     protected function _get_mt_tabs($tab_array)
3580 3580
     {
3581
-        $tab_array = (array)$tab_array;
3582
-        $template  = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
3581
+        $tab_array = (array) $tab_array;
3582
+        $template  = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php';
3583 3583
         $tabs      = '';
3584 3584
         
3585 3585
         foreach ($tab_array as $tab) {
@@ -3612,9 +3612,9 @@  discard block
 block discarded – undo
3612 3612
             $existing_settings = $messenger->get_existing_admin_settings();
3613 3613
             
3614 3614
             foreach ($fields as $fldname => $fldprops) {
3615
-                $field_id                       = $messenger->name . '-' . $fldname;
3615
+                $field_id                       = $messenger->name.'-'.$fldname;
3616 3616
                 $template_form_field[$field_id] = array(
3617
-                    'name'       => 'messenger_settings[' . $field_id . ']',
3617
+                    'name'       => 'messenger_settings['.$field_id.']',
3618 3618
                     'label'      => $fldprops['label'],
3619 3619
                     'input'      => $fldprops['field_type'],
3620 3620
                     'type'       => $fldprops['value_type'],
@@ -3649,7 +3649,7 @@  discard block
 block discarded – undo
3649 3649
         //make sure any active message types that are existing are included in the hidden fields
3650 3650
         if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
3651 3651
             foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
3652
-                $settings_template_args['hidden_fields']['messenger_settings[message_types][' . $mt . ']'] = array(
3652
+                $settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array(
3653 3653
                     'type'  => 'hidden',
3654 3654
                     'value' => $mt
3655 3655
                 );
@@ -3678,9 +3678,9 @@  discard block
 block discarded – undo
3678 3678
         
3679 3679
         
3680 3680
         $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
3681
-        $settings_template_args['nonce']         = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
3681
+        $settings_template_args['nonce']         = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce');
3682 3682
         $settings_template_args['on_off_status'] = $active ? true : false;
3683
-        $template                                = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
3683
+        $template                                = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php';
3684 3684
         $content                                 = EEH_Template::display_template(
3685 3685
             $template,
3686 3686
             $settings_template_args,
@@ -3720,7 +3720,7 @@  discard block
 block discarded – undo
3720 3720
         $nonce     = isset($this->_req_data['activate_nonce'])
3721 3721
             ? sanitize_text_field($this->_req_data['activate_nonce'])
3722 3722
             : '';
3723
-        $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
3723
+        $nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce';
3724 3724
         
3725 3725
         $this->_verify_nonce($nonce, $nonce_ref);
3726 3726
         
@@ -3836,7 +3836,7 @@  discard block
 block discarded – undo
3836 3836
         
3837 3837
         //do a nonce check here since we're not arriving via a normal route
3838 3838
         $nonce     = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
3839
-        $nonce_ref = $this->_req_data['message_type'] . '_nonce';
3839
+        $nonce_ref = $this->_req_data['message_type'].'_nonce';
3840 3840
         
3841 3841
         $this->_verify_nonce($nonce, $nonce_ref);
3842 3842
         
@@ -4197,7 +4197,7 @@  discard block
 block discarded – undo
4197 4197
         $message_type = $message_types[$this->_req_data['message_type']];
4198 4198
         $messenger    = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
4199 4199
         
4200
-        $content                         = $this->_message_type_settings_content(
4200
+        $content = $this->_message_type_settings_content(
4201 4201
             $message_type,
4202 4202
             $messenger,
4203 4203
             true
Please login to merge, or discard this patch.
Indentation   +4043 added lines, -4043 removed lines patch added patch discarded remove patch
@@ -5,7 +5,7 @@  discard block
 block discarded – undo
5 5
 use EventEspresso\core\exceptions\InvalidInterfaceException;
6 6
 
7 7
 if ( ! defined('EVENT_ESPRESSO_VERSION')) {
8
-    exit('NO direct script access allowed');
8
+	exit('NO direct script access allowed');
9 9
 }
10 10
 
11 11
 /**
@@ -23,2557 +23,2557 @@  discard block
 block discarded – undo
23 23
 class Messages_Admin_Page extends EE_Admin_Page
24 24
 {
25 25
     
26
-    /**
27
-     * @type EE_Message_Resource_Manager $_message_resource_manager
28
-     */
29
-    protected $_message_resource_manager;
26
+	/**
27
+	 * @type EE_Message_Resource_Manager $_message_resource_manager
28
+	 */
29
+	protected $_message_resource_manager;
30 30
     
31
-    /**
32
-     * @type string $_active_message_type_name
33
-     */
34
-    protected $_active_message_type_name = '';
31
+	/**
32
+	 * @type string $_active_message_type_name
33
+	 */
34
+	protected $_active_message_type_name = '';
35 35
     
36
-    /**
37
-     * @type EE_messenger $_active_messenger
38
-     */
39
-    protected $_active_messenger;
40
-    protected $_activate_state;
41
-    protected $_activate_meta_box_type;
42
-    protected $_current_message_meta_box;
43
-    protected $_current_message_meta_box_object;
44
-    protected $_context_switcher;
45
-    protected $_shortcodes = array();
46
-    protected $_active_messengers = array();
47
-    protected $_active_message_types = array();
36
+	/**
37
+	 * @type EE_messenger $_active_messenger
38
+	 */
39
+	protected $_active_messenger;
40
+	protected $_activate_state;
41
+	protected $_activate_meta_box_type;
42
+	protected $_current_message_meta_box;
43
+	protected $_current_message_meta_box_object;
44
+	protected $_context_switcher;
45
+	protected $_shortcodes = array();
46
+	protected $_active_messengers = array();
47
+	protected $_active_message_types = array();
48 48
     
49
-    /**
50
-     * @var EE_Message_Template_Group $_message_template_group
51
-     */
52
-    protected $_message_template_group;
53
-    protected $_m_mt_settings = array();
49
+	/**
50
+	 * @var EE_Message_Template_Group $_message_template_group
51
+	 */
52
+	protected $_message_template_group;
53
+	protected $_m_mt_settings = array();
54 54
     
55 55
     
56
-    /**
57
-     * This is set via the _set_message_template_group method and holds whatever the template pack for the group is.
58
-     * IF there is no group then it gets automatically set to the Default template pack.
59
-     *
60
-     * @since 4.5.0
61
-     *
62
-     * @var EE_Messages_Template_Pack
63
-     */
64
-    protected $_template_pack;
56
+	/**
57
+	 * This is set via the _set_message_template_group method and holds whatever the template pack for the group is.
58
+	 * IF there is no group then it gets automatically set to the Default template pack.
59
+	 *
60
+	 * @since 4.5.0
61
+	 *
62
+	 * @var EE_Messages_Template_Pack
63
+	 */
64
+	protected $_template_pack;
65 65
     
66 66
     
67
-    /**
68
-     * This is set via the _set_message_template_group method and holds whatever the template pack variation for the
69
-     * group is.  If there is no group then it automatically gets set to default.
70
-     *
71
-     * @since 4.5.0
72
-     *
73
-     * @var string
74
-     */
75
-    protected $_variation;
67
+	/**
68
+	 * This is set via the _set_message_template_group method and holds whatever the template pack variation for the
69
+	 * group is.  If there is no group then it automatically gets set to default.
70
+	 *
71
+	 * @since 4.5.0
72
+	 *
73
+	 * @var string
74
+	 */
75
+	protected $_variation;
76 76
     
77 77
     
78
-    /**
79
-     * @param bool $routing
80
-     */
81
-    public function __construct($routing = true)
82
-    {
83
-        //make sure messages autoloader is running
84
-        EED_Messages::set_autoloaders();
85
-        parent::__construct($routing);
86
-    }
78
+	/**
79
+	 * @param bool $routing
80
+	 */
81
+	public function __construct($routing = true)
82
+	{
83
+		//make sure messages autoloader is running
84
+		EED_Messages::set_autoloaders();
85
+		parent::__construct($routing);
86
+	}
87 87
     
88 88
     
89
-    protected function _init_page_props()
90
-    {
91
-        $this->page_slug        = EE_MSG_PG_SLUG;
92
-        $this->page_label       = esc_html__('Messages Settings', 'event_espresso');
93
-        $this->_admin_base_url  = EE_MSG_ADMIN_URL;
94
-        $this->_admin_base_path = EE_MSG_ADMIN;
95
-        
96
-        $this->_activate_state = isset($this->_req_data['activate_state']) ? (array)$this->_req_data['activate_state'] : array();
97
-        
98
-        $this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null;
99
-        $this->_load_message_resource_manager();
100
-    }
89
+	protected function _init_page_props()
90
+	{
91
+		$this->page_slug        = EE_MSG_PG_SLUG;
92
+		$this->page_label       = esc_html__('Messages Settings', 'event_espresso');
93
+		$this->_admin_base_url  = EE_MSG_ADMIN_URL;
94
+		$this->_admin_base_path = EE_MSG_ADMIN;
95
+        
96
+		$this->_activate_state = isset($this->_req_data['activate_state']) ? (array)$this->_req_data['activate_state'] : array();
97
+        
98
+		$this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null;
99
+		$this->_load_message_resource_manager();
100
+	}
101 101
 
102 102
 
103
-    /**
104
-     * loads messenger objects into the $_active_messengers property (so we can access the needed methods)
105
-     *
106
-     * @throws EE_Error
107
-     * @throws InvalidDataTypeException
108
-     * @throws InvalidInterfaceException
109
-     * @throws InvalidArgumentException
110
-     * @throws ReflectionException
111
-     */
112
-    protected function _load_message_resource_manager()
113
-    {
114
-        $this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
115
-    }
103
+	/**
104
+	 * loads messenger objects into the $_active_messengers property (so we can access the needed methods)
105
+	 *
106
+	 * @throws EE_Error
107
+	 * @throws InvalidDataTypeException
108
+	 * @throws InvalidInterfaceException
109
+	 * @throws InvalidArgumentException
110
+	 * @throws ReflectionException
111
+	 */
112
+	protected function _load_message_resource_manager()
113
+	{
114
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
115
+	}
116 116
 
117 117
 
118
-    /**
119
-     * @deprecated 4.9.9.rc.014
120
-     * @return array
121
-     * @throws EE_Error
122
-     * @throws InvalidArgumentException
123
-     * @throws InvalidDataTypeException
124
-     * @throws InvalidInterfaceException
125
-     */
126
-    public function get_messengers_for_list_table()
127
-    {
128
-        EE_Error::doing_it_wrong(
129
-            __METHOD__,
130
-            sprintf(
131
-                esc_html__(
132
-                    'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a messenger filter dropdown which is now generated differently via %s',
133
-                    'event_espresso'
134
-                ),
135
-                'Messages_Admin_Page::get_messengers_select_input()'
136
-            ),
137
-            '4.9.9.rc.014'
138
-        );
139
-        
140
-        $m_values          = array();
141
-        $active_messengers = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
142
-        //setup messengers for selects
143
-        $i = 1;
144
-        foreach ($active_messengers as $active_messenger) {
145
-            if ($active_messenger instanceof EE_Message) {
146
-                $m_values[$i]['id']   = $active_messenger->messenger();
147
-                $m_values[$i]['text'] = ucwords($active_messenger->messenger_label());
148
-                $i++;
149
-            }
150
-        }
151
-        
152
-        return $m_values;
153
-    }
118
+	/**
119
+	 * @deprecated 4.9.9.rc.014
120
+	 * @return array
121
+	 * @throws EE_Error
122
+	 * @throws InvalidArgumentException
123
+	 * @throws InvalidDataTypeException
124
+	 * @throws InvalidInterfaceException
125
+	 */
126
+	public function get_messengers_for_list_table()
127
+	{
128
+		EE_Error::doing_it_wrong(
129
+			__METHOD__,
130
+			sprintf(
131
+				esc_html__(
132
+					'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a messenger filter dropdown which is now generated differently via %s',
133
+					'event_espresso'
134
+				),
135
+				'Messages_Admin_Page::get_messengers_select_input()'
136
+			),
137
+			'4.9.9.rc.014'
138
+		);
139
+        
140
+		$m_values          = array();
141
+		$active_messengers = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
142
+		//setup messengers for selects
143
+		$i = 1;
144
+		foreach ($active_messengers as $active_messenger) {
145
+			if ($active_messenger instanceof EE_Message) {
146
+				$m_values[$i]['id']   = $active_messenger->messenger();
147
+				$m_values[$i]['text'] = ucwords($active_messenger->messenger_label());
148
+				$i++;
149
+			}
150
+		}
151
+        
152
+		return $m_values;
153
+	}
154 154
 
155 155
 
156
-    /**
157
-     * @deprecated 4.9.9.rc.014
158
-     * @return array
159
-     * @throws EE_Error
160
-     * @throws InvalidArgumentException
161
-     * @throws InvalidDataTypeException
162
-     * @throws InvalidInterfaceException
163
-     */
164
-    public function get_message_types_for_list_table()
165
-    {
166
-        EE_Error::doing_it_wrong(
167
-            __METHOD__,
168
-            sprintf(
169
-                esc_html__(
170
-                    'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a message type filter dropdown which is now generated differently via %s',
171
-                    'event_espresso'
172
-                ),
173
-                'Messages_Admin_Page::get_message_types_select_input()'
174
-            ),
175
-            '4.9.9.rc.014'
176
-        );
177
-        
178
-        $mt_values       = array();
179
-        $active_messages = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type'));
180
-        $i               = 1;
181
-        foreach ($active_messages as $active_message) {
182
-            if ($active_message instanceof EE_Message) {
183
-                $mt_values[$i]['id']   = $active_message->message_type();
184
-                $mt_values[$i]['text'] = ucwords($active_message->message_type_label());
185
-                $i++;
186
-            }
187
-        }
188
-        
189
-        return $mt_values;
190
-    }
156
+	/**
157
+	 * @deprecated 4.9.9.rc.014
158
+	 * @return array
159
+	 * @throws EE_Error
160
+	 * @throws InvalidArgumentException
161
+	 * @throws InvalidDataTypeException
162
+	 * @throws InvalidInterfaceException
163
+	 */
164
+	public function get_message_types_for_list_table()
165
+	{
166
+		EE_Error::doing_it_wrong(
167
+			__METHOD__,
168
+			sprintf(
169
+				esc_html__(
170
+					'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a message type filter dropdown which is now generated differently via %s',
171
+					'event_espresso'
172
+				),
173
+				'Messages_Admin_Page::get_message_types_select_input()'
174
+			),
175
+			'4.9.9.rc.014'
176
+		);
177
+        
178
+		$mt_values       = array();
179
+		$active_messages = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type'));
180
+		$i               = 1;
181
+		foreach ($active_messages as $active_message) {
182
+			if ($active_message instanceof EE_Message) {
183
+				$mt_values[$i]['id']   = $active_message->message_type();
184
+				$mt_values[$i]['text'] = ucwords($active_message->message_type_label());
185
+				$i++;
186
+			}
187
+		}
188
+        
189
+		return $mt_values;
190
+	}
191 191
 
192 192
 
193
-    /**
194
-     * @deprecated 4.9.9.rc.014
195
-     * @return array
196
-     * @throws EE_Error
197
-     * @throws InvalidArgumentException
198
-     * @throws InvalidDataTypeException
199
-     * @throws InvalidInterfaceException
200
-     */
201
-    public function get_contexts_for_message_types_for_list_table()
202
-    {
203
-        EE_Error::doing_it_wrong(
204
-            __METHOD__,
205
-            sprintf(
206
-                esc_html__(
207
-                    'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a message type context filter dropdown which is now generated differently via %s',
208
-                    'event_espresso'
209
-                ),
210
-                'Messages_Admin_Page::get_contexts_for_message_types_select_input()'
211
-            ),
212
-            '4.9.9.rc.014'
213
-        );
214
-        
215
-        $contexts                = array();
216
-        $active_message_contexts = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
217
-        foreach ($active_message_contexts as $active_message) {
218
-            if ($active_message instanceof EE_Message) {
219
-                $message_type = $active_message->message_type_object();
220
-                if ($message_type instanceof EE_message_type) {
221
-                    $message_type_contexts = $message_type->get_contexts();
222
-                    foreach ($message_type_contexts as $context => $context_details) {
223
-                        $contexts[$context] = $context_details['label'];
224
-                    }
225
-                }
226
-            }
227
-        }
228
-        
229
-        return $contexts;
230
-    }
193
+	/**
194
+	 * @deprecated 4.9.9.rc.014
195
+	 * @return array
196
+	 * @throws EE_Error
197
+	 * @throws InvalidArgumentException
198
+	 * @throws InvalidDataTypeException
199
+	 * @throws InvalidInterfaceException
200
+	 */
201
+	public function get_contexts_for_message_types_for_list_table()
202
+	{
203
+		EE_Error::doing_it_wrong(
204
+			__METHOD__,
205
+			sprintf(
206
+				esc_html__(
207
+					'This method is no longer in use.  There is no replacement for it. The method was used to generate a set of values for use in creating a message type context filter dropdown which is now generated differently via %s',
208
+					'event_espresso'
209
+				),
210
+				'Messages_Admin_Page::get_contexts_for_message_types_select_input()'
211
+			),
212
+			'4.9.9.rc.014'
213
+		);
214
+        
215
+		$contexts                = array();
216
+		$active_message_contexts = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
217
+		foreach ($active_message_contexts as $active_message) {
218
+			if ($active_message instanceof EE_Message) {
219
+				$message_type = $active_message->message_type_object();
220
+				if ($message_type instanceof EE_message_type) {
221
+					$message_type_contexts = $message_type->get_contexts();
222
+					foreach ($message_type_contexts as $context => $context_details) {
223
+						$contexts[$context] = $context_details['label'];
224
+					}
225
+				}
226
+			}
227
+		}
228
+        
229
+		return $contexts;
230
+	}
231 231
 
232 232
 
233
-    /**
234
-     * Generate select input with provided messenger options array.
235
-     *
236
-     * @param array $messenger_options Array of messengers indexed by messenger slug and values are the messenger
237
-     *                                 labels.
238
-     * @return string
239
-     * @throws EE_Error
240
-     */
241
-    public function get_messengers_select_input($messenger_options)
242
-    {
243
-        //if empty or just one value then just return an empty string
244
-        if (empty($messenger_options)
245
-            || ! is_array($messenger_options)
246
-            || count($messenger_options) === 1
247
-        ) {
248
-            return '';
249
-        }
250
-        //merge in default
251
-        $messenger_options = array_merge(
252
-            array('none_selected' => esc_html__('Show All Messengers', 'event_espresso')),
253
-            $messenger_options
254
-        );
255
-        $input             = new EE_Select_Input(
256
-            $messenger_options,
257
-            array(
258
-                'html_name'  => 'ee_messenger_filter_by',
259
-                'html_id'    => 'ee_messenger_filter_by',
260
-                'html_class' => 'wide',
261
-                'default'    => isset($this->_req_data['ee_messenger_filter_by'])
262
-                    ? sanitize_title($this->_req_data['ee_messenger_filter_by'])
263
-                    : 'none_selected'
264
-            )
265
-        );
266
-        
267
-        return $input->get_html_for_input();
268
-    }
233
+	/**
234
+	 * Generate select input with provided messenger options array.
235
+	 *
236
+	 * @param array $messenger_options Array of messengers indexed by messenger slug and values are the messenger
237
+	 *                                 labels.
238
+	 * @return string
239
+	 * @throws EE_Error
240
+	 */
241
+	public function get_messengers_select_input($messenger_options)
242
+	{
243
+		//if empty or just one value then just return an empty string
244
+		if (empty($messenger_options)
245
+			|| ! is_array($messenger_options)
246
+			|| count($messenger_options) === 1
247
+		) {
248
+			return '';
249
+		}
250
+		//merge in default
251
+		$messenger_options = array_merge(
252
+			array('none_selected' => esc_html__('Show All Messengers', 'event_espresso')),
253
+			$messenger_options
254
+		);
255
+		$input             = new EE_Select_Input(
256
+			$messenger_options,
257
+			array(
258
+				'html_name'  => 'ee_messenger_filter_by',
259
+				'html_id'    => 'ee_messenger_filter_by',
260
+				'html_class' => 'wide',
261
+				'default'    => isset($this->_req_data['ee_messenger_filter_by'])
262
+					? sanitize_title($this->_req_data['ee_messenger_filter_by'])
263
+					: 'none_selected'
264
+			)
265
+		);
266
+        
267
+		return $input->get_html_for_input();
268
+	}
269 269
 
270 270
 
271
-    /**
272
-     * Generate select input with provided message type options array.
273
-     *
274
-     * @param array $message_type_options Array of message types indexed by message type slug, and values are the
275
-     *                                    message type labels
276
-     * @return string
277
-     * @throws EE_Error
278
-     */
279
-    public function get_message_types_select_input($message_type_options)
280
-    {
281
-        //if empty or count of options is 1 then just return an empty string
282
-        if (empty($message_type_options)
283
-            || ! is_array($message_type_options)
284
-            || count($message_type_options) === 1
285
-        ) {
286
-            return '';
287
-        }
288
-        //merge in default
289
-        $message_type_options = array_merge(
290
-            array('none_selected' => esc_html__('Show All Message Types', 'event_espresso')),
291
-            $message_type_options
292
-        );
293
-        $input                = new EE_Select_Input(
294
-            $message_type_options,
295
-            array(
296
-                'html_name'  => 'ee_message_type_filter_by',
297
-                'html_id'    => 'ee_message_type_filter_by',
298
-                'html_class' => 'wide',
299
-                'default'    => isset($this->_req_data['ee_message_type_filter_by'])
300
-                    ? sanitize_title($this->_req_data['ee_message_type_filter_by'])
301
-                    : 'none_selected',
302
-            )
303
-        );
304
-        
305
-        return $input->get_html_for_input();
306
-    }
271
+	/**
272
+	 * Generate select input with provided message type options array.
273
+	 *
274
+	 * @param array $message_type_options Array of message types indexed by message type slug, and values are the
275
+	 *                                    message type labels
276
+	 * @return string
277
+	 * @throws EE_Error
278
+	 */
279
+	public function get_message_types_select_input($message_type_options)
280
+	{
281
+		//if empty or count of options is 1 then just return an empty string
282
+		if (empty($message_type_options)
283
+			|| ! is_array($message_type_options)
284
+			|| count($message_type_options) === 1
285
+		) {
286
+			return '';
287
+		}
288
+		//merge in default
289
+		$message_type_options = array_merge(
290
+			array('none_selected' => esc_html__('Show All Message Types', 'event_espresso')),
291
+			$message_type_options
292
+		);
293
+		$input                = new EE_Select_Input(
294
+			$message_type_options,
295
+			array(
296
+				'html_name'  => 'ee_message_type_filter_by',
297
+				'html_id'    => 'ee_message_type_filter_by',
298
+				'html_class' => 'wide',
299
+				'default'    => isset($this->_req_data['ee_message_type_filter_by'])
300
+					? sanitize_title($this->_req_data['ee_message_type_filter_by'])
301
+					: 'none_selected',
302
+			)
303
+		);
304
+        
305
+		return $input->get_html_for_input();
306
+	}
307 307
 
308 308
 
309
-    /**
310
-     * Generate select input with provide message type contexts array.
311
-     *
312
-     * @param array $context_options Array of message type contexts indexed by context slug, and values are the
313
-     *                               context label.
314
-     * @return string
315
-     * @throws EE_Error
316
-     */
317
-    public function get_contexts_for_message_types_select_input($context_options)
318
-    {
319
-        //if empty or count of options is one then just return empty string
320
-        if (empty($context_options)
321
-            || ! is_array($context_options)
322
-            || count($context_options) === 1
323
-        ) {
324
-            return '';
325
-        }
326
-        //merge in default
327
-        $context_options = array_merge(
328
-            array('none_selected' => esc_html__('Show all Contexts', 'event_espresso')),
329
-            $context_options
330
-        );
331
-        $input           = new EE_Select_Input(
332
-            $context_options,
333
-            array(
334
-                'html_name'  => 'ee_context_filter_by',
335
-                'html_id'    => 'ee_context_filter_by',
336
-                'html_class' => 'wide',
337
-                'default'    => isset($this->_req_data['ee_context_filter_by'])
338
-                    ? sanitize_title($this->_req_data['ee_context_filter_by'])
339
-                    : 'none_selected',
340
-            )
341
-        );
342
-        
343
-        return $input->get_html_for_input();
344
-    }
309
+	/**
310
+	 * Generate select input with provide message type contexts array.
311
+	 *
312
+	 * @param array $context_options Array of message type contexts indexed by context slug, and values are the
313
+	 *                               context label.
314
+	 * @return string
315
+	 * @throws EE_Error
316
+	 */
317
+	public function get_contexts_for_message_types_select_input($context_options)
318
+	{
319
+		//if empty or count of options is one then just return empty string
320
+		if (empty($context_options)
321
+			|| ! is_array($context_options)
322
+			|| count($context_options) === 1
323
+		) {
324
+			return '';
325
+		}
326
+		//merge in default
327
+		$context_options = array_merge(
328
+			array('none_selected' => esc_html__('Show all Contexts', 'event_espresso')),
329
+			$context_options
330
+		);
331
+		$input           = new EE_Select_Input(
332
+			$context_options,
333
+			array(
334
+				'html_name'  => 'ee_context_filter_by',
335
+				'html_id'    => 'ee_context_filter_by',
336
+				'html_class' => 'wide',
337
+				'default'    => isset($this->_req_data['ee_context_filter_by'])
338
+					? sanitize_title($this->_req_data['ee_context_filter_by'])
339
+					: 'none_selected',
340
+			)
341
+		);
342
+        
343
+		return $input->get_html_for_input();
344
+	}
345 345
     
346 346
     
347
-    protected function _ajax_hooks()
348
-    {
349
-        add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle'));
350
-        add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle'));
351
-        add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings'));
352
-        add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form'));
353
-        add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack'));
354
-        add_action('wp_ajax_toggle_context_template', array($this, 'toggle_context_template'));
355
-    }
347
+	protected function _ajax_hooks()
348
+	{
349
+		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle'));
350
+		add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle'));
351
+		add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings'));
352
+		add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form'));
353
+		add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack'));
354
+		add_action('wp_ajax_toggle_context_template', array($this, 'toggle_context_template'));
355
+	}
356 356
     
357 357
     
358
-    protected function _define_page_props()
359
-    {
360
-        $this->_admin_page_title = $this->page_label;
361
-        $this->_labels           = array(
362
-            'buttons'    => array(
363
-                'add'    => esc_html__('Add New Message Template', 'event_espresso'),
364
-                'edit'   => esc_html__('Edit Message Template', 'event_espresso'),
365
-                'delete' => esc_html__('Delete Message Template', 'event_espresso')
366
-            ),
367
-            'publishbox' => esc_html__('Update Actions', 'event_espresso')
368
-        );
369
-    }
358
+	protected function _define_page_props()
359
+	{
360
+		$this->_admin_page_title = $this->page_label;
361
+		$this->_labels           = array(
362
+			'buttons'    => array(
363
+				'add'    => esc_html__('Add New Message Template', 'event_espresso'),
364
+				'edit'   => esc_html__('Edit Message Template', 'event_espresso'),
365
+				'delete' => esc_html__('Delete Message Template', 'event_espresso')
366
+			),
367
+			'publishbox' => esc_html__('Update Actions', 'event_espresso')
368
+		);
369
+	}
370 370
     
371 371
     
372
-    /**
373
-     *        an array for storing key => value pairs of request actions and their corresponding methods
374
-     * @access protected
375
-     * @return void
376
-     */
377
-    protected function _set_page_routes()
378
-    {
379
-        $grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID'])
380
-            ? $this->_req_data['GRP_ID']
381
-            : 0;
382
-        $grp_id = empty($grp_id) && ! empty($this->_req_data['id'])
383
-            ? $this->_req_data['id']
384
-            : $grp_id;
385
-        $msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID'])
386
-            ? $this->_req_data['MSG_ID']
387
-            : 0;
388
-        
389
-        $this->_page_routes = array(
390
-            'default'                          => array(
391
-                'func'       => '_message_queue_list_table',
392
-                'capability' => 'ee_read_global_messages'
393
-            ),
394
-            'global_mtps'                      => array(
395
-                'func'       => '_ee_default_messages_overview_list_table',
396
-                'capability' => 'ee_read_global_messages'
397
-            ),
398
-            'custom_mtps'                      => array(
399
-                'func'       => '_custom_mtps_preview',
400
-                'capability' => 'ee_read_messages'
401
-            ),
402
-            'add_new_message_template'         => array(
403
-                'func'       => '_add_message_template',
404
-                'capability' => 'ee_edit_messages',
405
-                'noheader'   => true
406
-            ),
407
-            'edit_message_template'            => array(
408
-                'func'       => '_edit_message_template',
409
-                'capability' => 'ee_edit_message',
410
-                'obj_id'     => $grp_id
411
-            ),
412
-            'preview_message'                  => array(
413
-                'func'               => '_preview_message',
414
-                'capability'         => 'ee_read_message',
415
-                'obj_id'             => $grp_id,
416
-                'noheader'           => true,
417
-                'headers_sent_route' => 'display_preview_message'
418
-            ),
419
-            'display_preview_message'          => array(
420
-                'func'       => '_display_preview_message',
421
-                'capability' => 'ee_read_message',
422
-                'obj_id'     => $grp_id
423
-            ),
424
-            'insert_message_template'          => array(
425
-                'func'       => '_insert_or_update_message_template',
426
-                'capability' => 'ee_edit_messages',
427
-                'args'       => array('new_template' => true),
428
-                'noheader'   => true
429
-            ),
430
-            'update_message_template'          => array(
431
-                'func'       => '_insert_or_update_message_template',
432
-                'capability' => 'ee_edit_message',
433
-                'obj_id'     => $grp_id,
434
-                'args'       => array('new_template' => false),
435
-                'noheader'   => true
436
-            ),
437
-            'trash_message_template'           => array(
438
-                'func'       => '_trash_or_restore_message_template',
439
-                'capability' => 'ee_delete_message',
440
-                'obj_id'     => $grp_id,
441
-                'args'       => array('trash' => true, 'all' => true),
442
-                'noheader'   => true
443
-            ),
444
-            'trash_message_template_context'   => array(
445
-                'func'       => '_trash_or_restore_message_template',
446
-                'capability' => 'ee_delete_message',
447
-                'obj_id'     => $grp_id,
448
-                'args'       => array('trash' => true),
449
-                'noheader'   => true
450
-            ),
451
-            'restore_message_template'         => array(
452
-                'func'       => '_trash_or_restore_message_template',
453
-                'capability' => 'ee_delete_message',
454
-                'obj_id'     => $grp_id,
455
-                'args'       => array('trash' => false, 'all' => true),
456
-                'noheader'   => true
457
-            ),
458
-            'restore_message_template_context' => array(
459
-                'func'       => '_trash_or_restore_message_template',
460
-                'capability' => 'ee_delete_message',
461
-                'obj_id'     => $grp_id,
462
-                'args'       => array('trash' => false),
463
-                'noheader'   => true
464
-            ),
465
-            'delete_message_template'          => array(
466
-                'func'       => '_delete_message_template',
467
-                'capability' => 'ee_delete_message',
468
-                'obj_id'     => $grp_id,
469
-                'noheader'   => true
470
-            ),
471
-            'reset_to_default'                 => array(
472
-                'func'       => '_reset_to_default_template',
473
-                'capability' => 'ee_edit_message',
474
-                'obj_id'     => $grp_id,
475
-                'noheader'   => true
476
-            ),
477
-            'settings'                         => array(
478
-                'func'       => '_settings',
479
-                'capability' => 'manage_options'
480
-            ),
481
-            'update_global_settings'           => array(
482
-                'func'       => '_update_global_settings',
483
-                'capability' => 'manage_options',
484
-                'noheader'   => true
485
-            ),
486
-            'generate_now'                     => array(
487
-                'func'       => '_generate_now',
488
-                'capability' => 'ee_send_message',
489
-                'noheader'   => true
490
-            ),
491
-            'generate_and_send_now'            => array(
492
-                'func'       => '_generate_and_send_now',
493
-                'capability' => 'ee_send_message',
494
-                'noheader'   => true
495
-            ),
496
-            'queue_for_resending'              => array(
497
-                'func'       => '_queue_for_resending',
498
-                'capability' => 'ee_send_message',
499
-                'noheader'   => true
500
-            ),
501
-            'send_now'                         => array(
502
-                'func'       => '_send_now',
503
-                'capability' => 'ee_send_message',
504
-                'noheader'   => true
505
-            ),
506
-            'delete_ee_message'                => array(
507
-                'func'       => '_delete_ee_messages',
508
-                'capability' => 'ee_delete_messages',
509
-                'noheader'   => true
510
-            ),
511
-            'delete_ee_messages'               => array(
512
-                'func'       => '_delete_ee_messages',
513
-                'capability' => 'ee_delete_messages',
514
-                'noheader'   => true,
515
-                'obj_id'     => $msg_id
516
-            )
517
-        );
518
-    }
372
+	/**
373
+	 *        an array for storing key => value pairs of request actions and their corresponding methods
374
+	 * @access protected
375
+	 * @return void
376
+	 */
377
+	protected function _set_page_routes()
378
+	{
379
+		$grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID'])
380
+			? $this->_req_data['GRP_ID']
381
+			: 0;
382
+		$grp_id = empty($grp_id) && ! empty($this->_req_data['id'])
383
+			? $this->_req_data['id']
384
+			: $grp_id;
385
+		$msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID'])
386
+			? $this->_req_data['MSG_ID']
387
+			: 0;
388
+        
389
+		$this->_page_routes = array(
390
+			'default'                          => array(
391
+				'func'       => '_message_queue_list_table',
392
+				'capability' => 'ee_read_global_messages'
393
+			),
394
+			'global_mtps'                      => array(
395
+				'func'       => '_ee_default_messages_overview_list_table',
396
+				'capability' => 'ee_read_global_messages'
397
+			),
398
+			'custom_mtps'                      => array(
399
+				'func'       => '_custom_mtps_preview',
400
+				'capability' => 'ee_read_messages'
401
+			),
402
+			'add_new_message_template'         => array(
403
+				'func'       => '_add_message_template',
404
+				'capability' => 'ee_edit_messages',
405
+				'noheader'   => true
406
+			),
407
+			'edit_message_template'            => array(
408
+				'func'       => '_edit_message_template',
409
+				'capability' => 'ee_edit_message',
410
+				'obj_id'     => $grp_id
411
+			),
412
+			'preview_message'                  => array(
413
+				'func'               => '_preview_message',
414
+				'capability'         => 'ee_read_message',
415
+				'obj_id'             => $grp_id,
416
+				'noheader'           => true,
417
+				'headers_sent_route' => 'display_preview_message'
418
+			),
419
+			'display_preview_message'          => array(
420
+				'func'       => '_display_preview_message',
421
+				'capability' => 'ee_read_message',
422
+				'obj_id'     => $grp_id
423
+			),
424
+			'insert_message_template'          => array(
425
+				'func'       => '_insert_or_update_message_template',
426
+				'capability' => 'ee_edit_messages',
427
+				'args'       => array('new_template' => true),
428
+				'noheader'   => true
429
+			),
430
+			'update_message_template'          => array(
431
+				'func'       => '_insert_or_update_message_template',
432
+				'capability' => 'ee_edit_message',
433
+				'obj_id'     => $grp_id,
434
+				'args'       => array('new_template' => false),
435
+				'noheader'   => true
436
+			),
437
+			'trash_message_template'           => array(
438
+				'func'       => '_trash_or_restore_message_template',
439
+				'capability' => 'ee_delete_message',
440
+				'obj_id'     => $grp_id,
441
+				'args'       => array('trash' => true, 'all' => true),
442
+				'noheader'   => true
443
+			),
444
+			'trash_message_template_context'   => array(
445
+				'func'       => '_trash_or_restore_message_template',
446
+				'capability' => 'ee_delete_message',
447
+				'obj_id'     => $grp_id,
448
+				'args'       => array('trash' => true),
449
+				'noheader'   => true
450
+			),
451
+			'restore_message_template'         => array(
452
+				'func'       => '_trash_or_restore_message_template',
453
+				'capability' => 'ee_delete_message',
454
+				'obj_id'     => $grp_id,
455
+				'args'       => array('trash' => false, 'all' => true),
456
+				'noheader'   => true
457
+			),
458
+			'restore_message_template_context' => array(
459
+				'func'       => '_trash_or_restore_message_template',
460
+				'capability' => 'ee_delete_message',
461
+				'obj_id'     => $grp_id,
462
+				'args'       => array('trash' => false),
463
+				'noheader'   => true
464
+			),
465
+			'delete_message_template'          => array(
466
+				'func'       => '_delete_message_template',
467
+				'capability' => 'ee_delete_message',
468
+				'obj_id'     => $grp_id,
469
+				'noheader'   => true
470
+			),
471
+			'reset_to_default'                 => array(
472
+				'func'       => '_reset_to_default_template',
473
+				'capability' => 'ee_edit_message',
474
+				'obj_id'     => $grp_id,
475
+				'noheader'   => true
476
+			),
477
+			'settings'                         => array(
478
+				'func'       => '_settings',
479
+				'capability' => 'manage_options'
480
+			),
481
+			'update_global_settings'           => array(
482
+				'func'       => '_update_global_settings',
483
+				'capability' => 'manage_options',
484
+				'noheader'   => true
485
+			),
486
+			'generate_now'                     => array(
487
+				'func'       => '_generate_now',
488
+				'capability' => 'ee_send_message',
489
+				'noheader'   => true
490
+			),
491
+			'generate_and_send_now'            => array(
492
+				'func'       => '_generate_and_send_now',
493
+				'capability' => 'ee_send_message',
494
+				'noheader'   => true
495
+			),
496
+			'queue_for_resending'              => array(
497
+				'func'       => '_queue_for_resending',
498
+				'capability' => 'ee_send_message',
499
+				'noheader'   => true
500
+			),
501
+			'send_now'                         => array(
502
+				'func'       => '_send_now',
503
+				'capability' => 'ee_send_message',
504
+				'noheader'   => true
505
+			),
506
+			'delete_ee_message'                => array(
507
+				'func'       => '_delete_ee_messages',
508
+				'capability' => 'ee_delete_messages',
509
+				'noheader'   => true
510
+			),
511
+			'delete_ee_messages'               => array(
512
+				'func'       => '_delete_ee_messages',
513
+				'capability' => 'ee_delete_messages',
514
+				'noheader'   => true,
515
+				'obj_id'     => $msg_id
516
+			)
517
+		);
518
+	}
519 519
     
520 520
     
521
-    protected function _set_page_config()
522
-    {
523
-        $this->_page_config = array(
524
-            'default'                  => array(
525
-                'nav'           => array(
526
-                    'label' => esc_html__('Message Activity', 'event_espresso'),
527
-                    'order' => 10
528
-                ),
529
-                'list_table'    => 'EE_Message_List_Table',
530
-                // 'qtips' => array( 'EE_Message_List_Table_Tips' ),
531
-                'require_nonce' => false
532
-            ),
533
-            'global_mtps'              => array(
534
-                'nav'           => array(
535
-                    'label' => esc_html__('Default Message Templates', 'event_espresso'),
536
-                    'order' => 20
537
-                ),
538
-                'list_table'    => 'Messages_Template_List_Table',
539
-                'help_tabs'     => array(
540
-                    'messages_overview_help_tab'                                => array(
541
-                        'title'    => esc_html__('Messages Overview', 'event_espresso'),
542
-                        'filename' => 'messages_overview'
543
-                    ),
544
-                    'messages_overview_messages_table_column_headings_help_tab' => array(
545
-                        'title'    => esc_html__('Messages Table Column Headings', 'event_espresso'),
546
-                        'filename' => 'messages_overview_table_column_headings'
547
-                    ),
548
-                    'messages_overview_messages_filters_help_tab'               => array(
549
-                        'title'    => esc_html__('Message Filters', 'event_espresso'),
550
-                        'filename' => 'messages_overview_filters'
551
-                    ),
552
-                    'messages_overview_messages_views_help_tab'                 => array(
553
-                        'title'    => esc_html__('Message Views', 'event_espresso'),
554
-                        'filename' => 'messages_overview_views'
555
-                    ),
556
-                    'message_overview_message_types_help_tab'                   => array(
557
-                        'title'    => esc_html__('Message Types', 'event_espresso'),
558
-                        'filename' => 'messages_overview_types'
559
-                    ),
560
-                    'messages_overview_messengers_help_tab'                     => array(
561
-                        'title'    => esc_html__('Messengers', 'event_espresso'),
562
-                        'filename' => 'messages_overview_messengers',
563
-                    ),
564
-                ),
565
-                'help_tour'     => array('Messages_Overview_Help_Tour'),
566
-                'require_nonce' => false
567
-            ),
568
-            'custom_mtps'              => array(
569
-                'nav'           => array(
570
-                    'label' => esc_html__('Custom Message Templates', 'event_espresso'),
571
-                    'order' => 30
572
-                ),
573
-                'help_tabs'     => array(),
574
-                'help_tour'     => array(),
575
-                'require_nonce' => false
576
-            ),
577
-            'add_new_message_template' => array(
578
-                'nav'           => array(
579
-                    'label'      => esc_html__('Add New Message Templates', 'event_espresso'),
580
-                    'order'      => 5,
581
-                    'persistent' => false
582
-                ),
583
-                'require_nonce' => false
584
-            ),
585
-            'edit_message_template'    => array(
586
-                'labels'        => array(
587
-                    'buttons'    => array(
588
-                        'reset' => esc_html__('Reset Templates'),
589
-                    ),
590
-                    'publishbox' => esc_html__('Update Actions', 'event_espresso')
591
-                ),
592
-                'nav'           => array(
593
-                    'label'      => esc_html__('Edit Message Templates', 'event_espresso'),
594
-                    'order'      => 5,
595
-                    'persistent' => false,
596
-                    'url'        => ''
597
-                ),
598
-                'metaboxes'     => array('_publish_post_box', '_register_edit_meta_boxes'),
599
-                'has_metaboxes' => true,
600
-                'help_tour'     => array('Message_Templates_Edit_Help_Tour'),
601
-                'help_tabs'     => array(
602
-                    'edit_message_template'       => array(
603
-                        'title'    => esc_html__('Message Template Editor', 'event_espresso'),
604
-                        'callback' => 'edit_message_template_help_tab'
605
-                    ),
606
-                    'message_templates_help_tab'  => array(
607
-                        'title'    => esc_html__('Message Templates', 'event_espresso'),
608
-                        'filename' => 'messages_templates'
609
-                    ),
610
-                    'message_template_shortcodes' => array(
611
-                        'title'    => esc_html__('Message Shortcodes', 'event_espresso'),
612
-                        'callback' => 'message_template_shortcodes_help_tab'
613
-                    ),
614
-                    'message_preview_help_tab'    => array(
615
-                        'title'    => esc_html__('Message Preview', 'event_espresso'),
616
-                        'filename' => 'messages_preview'
617
-                    ),
618
-                    'messages_overview_other_help_tab'                          => array(
619
-                        'title'    => esc_html__('Messages Other', 'event_espresso'),
620
-                        'filename' => 'messages_overview_other',
621
-                    ),
622
-                ),
623
-                'require_nonce' => false
624
-            ),
625
-            'display_preview_message'  => array(
626
-                'nav'           => array(
627
-                    'label'      => esc_html__('Message Preview', 'event_espresso'),
628
-                    'order'      => 5,
629
-                    'url'        => '',
630
-                    'persistent' => false
631
-                ),
632
-                'help_tabs'     => array(
633
-                    'preview_message' => array(
634
-                        'title'    => esc_html__('About Previews', 'event_espresso'),
635
-                        'callback' => 'preview_message_help_tab'
636
-                    )
637
-                ),
638
-                'require_nonce' => false
639
-            ),
640
-            'settings'                 => array(
641
-                'nav'           => array(
642
-                    'label' => esc_html__('Settings', 'event_espresso'),
643
-                    'order' => 40
644
-                ),
645
-                'metaboxes'     => array('_messages_settings_metaboxes'),
646
-                'help_tabs'     => array(
647
-                    'messages_settings_help_tab'               => array(
648
-                        'title'    => esc_html__('Messages Settings', 'event_espresso'),
649
-                        'filename' => 'messages_settings'
650
-                    ),
651
-                    'messages_settings_message_types_help_tab' => array(
652
-                        'title'    => esc_html__('Activating / Deactivating Message Types', 'event_espresso'),
653
-                        'filename' => 'messages_settings_message_types'
654
-                    ),
655
-                    'messages_settings_messengers_help_tab'    => array(
656
-                        'title'    => esc_html__('Activating / Deactivating Messengers', 'event_espresso'),
657
-                        'filename' => 'messages_settings_messengers'
658
-                    ),
659
-                ),
660
-                'help_tour'     => array('Messages_Settings_Help_Tour'),
661
-                'require_nonce' => false
662
-            )
663
-        );
664
-    }
521
+	protected function _set_page_config()
522
+	{
523
+		$this->_page_config = array(
524
+			'default'                  => array(
525
+				'nav'           => array(
526
+					'label' => esc_html__('Message Activity', 'event_espresso'),
527
+					'order' => 10
528
+				),
529
+				'list_table'    => 'EE_Message_List_Table',
530
+				// 'qtips' => array( 'EE_Message_List_Table_Tips' ),
531
+				'require_nonce' => false
532
+			),
533
+			'global_mtps'              => array(
534
+				'nav'           => array(
535
+					'label' => esc_html__('Default Message Templates', 'event_espresso'),
536
+					'order' => 20
537
+				),
538
+				'list_table'    => 'Messages_Template_List_Table',
539
+				'help_tabs'     => array(
540
+					'messages_overview_help_tab'                                => array(
541
+						'title'    => esc_html__('Messages Overview', 'event_espresso'),
542
+						'filename' => 'messages_overview'
543
+					),
544
+					'messages_overview_messages_table_column_headings_help_tab' => array(
545
+						'title'    => esc_html__('Messages Table Column Headings', 'event_espresso'),
546
+						'filename' => 'messages_overview_table_column_headings'
547
+					),
548
+					'messages_overview_messages_filters_help_tab'               => array(
549
+						'title'    => esc_html__('Message Filters', 'event_espresso'),
550
+						'filename' => 'messages_overview_filters'
551
+					),
552
+					'messages_overview_messages_views_help_tab'                 => array(
553
+						'title'    => esc_html__('Message Views', 'event_espresso'),
554
+						'filename' => 'messages_overview_views'
555
+					),
556
+					'message_overview_message_types_help_tab'                   => array(
557
+						'title'    => esc_html__('Message Types', 'event_espresso'),
558
+						'filename' => 'messages_overview_types'
559
+					),
560
+					'messages_overview_messengers_help_tab'                     => array(
561
+						'title'    => esc_html__('Messengers', 'event_espresso'),
562
+						'filename' => 'messages_overview_messengers',
563
+					),
564
+				),
565
+				'help_tour'     => array('Messages_Overview_Help_Tour'),
566
+				'require_nonce' => false
567
+			),
568
+			'custom_mtps'              => array(
569
+				'nav'           => array(
570
+					'label' => esc_html__('Custom Message Templates', 'event_espresso'),
571
+					'order' => 30
572
+				),
573
+				'help_tabs'     => array(),
574
+				'help_tour'     => array(),
575
+				'require_nonce' => false
576
+			),
577
+			'add_new_message_template' => array(
578
+				'nav'           => array(
579
+					'label'      => esc_html__('Add New Message Templates', 'event_espresso'),
580
+					'order'      => 5,
581
+					'persistent' => false
582
+				),
583
+				'require_nonce' => false
584
+			),
585
+			'edit_message_template'    => array(
586
+				'labels'        => array(
587
+					'buttons'    => array(
588
+						'reset' => esc_html__('Reset Templates'),
589
+					),
590
+					'publishbox' => esc_html__('Update Actions', 'event_espresso')
591
+				),
592
+				'nav'           => array(
593
+					'label'      => esc_html__('Edit Message Templates', 'event_espresso'),
594
+					'order'      => 5,
595
+					'persistent' => false,
596
+					'url'        => ''
597
+				),
598
+				'metaboxes'     => array('_publish_post_box', '_register_edit_meta_boxes'),
599
+				'has_metaboxes' => true,
600
+				'help_tour'     => array('Message_Templates_Edit_Help_Tour'),
601
+				'help_tabs'     => array(
602
+					'edit_message_template'       => array(
603
+						'title'    => esc_html__('Message Template Editor', 'event_espresso'),
604
+						'callback' => 'edit_message_template_help_tab'
605
+					),
606
+					'message_templates_help_tab'  => array(
607
+						'title'    => esc_html__('Message Templates', 'event_espresso'),
608
+						'filename' => 'messages_templates'
609
+					),
610
+					'message_template_shortcodes' => array(
611
+						'title'    => esc_html__('Message Shortcodes', 'event_espresso'),
612
+						'callback' => 'message_template_shortcodes_help_tab'
613
+					),
614
+					'message_preview_help_tab'    => array(
615
+						'title'    => esc_html__('Message Preview', 'event_espresso'),
616
+						'filename' => 'messages_preview'
617
+					),
618
+					'messages_overview_other_help_tab'                          => array(
619
+						'title'    => esc_html__('Messages Other', 'event_espresso'),
620
+						'filename' => 'messages_overview_other',
621
+					),
622
+				),
623
+				'require_nonce' => false
624
+			),
625
+			'display_preview_message'  => array(
626
+				'nav'           => array(
627
+					'label'      => esc_html__('Message Preview', 'event_espresso'),
628
+					'order'      => 5,
629
+					'url'        => '',
630
+					'persistent' => false
631
+				),
632
+				'help_tabs'     => array(
633
+					'preview_message' => array(
634
+						'title'    => esc_html__('About Previews', 'event_espresso'),
635
+						'callback' => 'preview_message_help_tab'
636
+					)
637
+				),
638
+				'require_nonce' => false
639
+			),
640
+			'settings'                 => array(
641
+				'nav'           => array(
642
+					'label' => esc_html__('Settings', 'event_espresso'),
643
+					'order' => 40
644
+				),
645
+				'metaboxes'     => array('_messages_settings_metaboxes'),
646
+				'help_tabs'     => array(
647
+					'messages_settings_help_tab'               => array(
648
+						'title'    => esc_html__('Messages Settings', 'event_espresso'),
649
+						'filename' => 'messages_settings'
650
+					),
651
+					'messages_settings_message_types_help_tab' => array(
652
+						'title'    => esc_html__('Activating / Deactivating Message Types', 'event_espresso'),
653
+						'filename' => 'messages_settings_message_types'
654
+					),
655
+					'messages_settings_messengers_help_tab'    => array(
656
+						'title'    => esc_html__('Activating / Deactivating Messengers', 'event_espresso'),
657
+						'filename' => 'messages_settings_messengers'
658
+					),
659
+				),
660
+				'help_tour'     => array('Messages_Settings_Help_Tour'),
661
+				'require_nonce' => false
662
+			)
663
+		);
664
+	}
665 665
     
666 666
     
667
-    protected function _add_screen_options()
668
-    {
669
-        //todo
670
-    }
667
+	protected function _add_screen_options()
668
+	{
669
+		//todo
670
+	}
671 671
     
672 672
     
673
-    protected function _add_screen_options_global_mtps()
674
-    {
675
-        /**
676
-         * Note: the reason for the value swap here on $this->_admin_page_title is because $this->_per_page_screen_options
677
-         * uses the $_admin_page_title property and we want different outputs in the different spots.
678
-         */
679
-        $page_title              = $this->_admin_page_title;
680
-        $this->_admin_page_title = esc_html__('Global Message Templates', 'event_espresso');
681
-        $this->_per_page_screen_option();
682
-        $this->_admin_page_title = $page_title;
683
-    }
673
+	protected function _add_screen_options_global_mtps()
674
+	{
675
+		/**
676
+		 * Note: the reason for the value swap here on $this->_admin_page_title is because $this->_per_page_screen_options
677
+		 * uses the $_admin_page_title property and we want different outputs in the different spots.
678
+		 */
679
+		$page_title              = $this->_admin_page_title;
680
+		$this->_admin_page_title = esc_html__('Global Message Templates', 'event_espresso');
681
+		$this->_per_page_screen_option();
682
+		$this->_admin_page_title = $page_title;
683
+	}
684 684
     
685 685
     
686
-    protected function _add_screen_options_default()
687
-    {
688
-        $this->_admin_page_title = esc_html__('Message Activity', 'event_espresso');
689
-        $this->_per_page_screen_option();
690
-    }
686
+	protected function _add_screen_options_default()
687
+	{
688
+		$this->_admin_page_title = esc_html__('Message Activity', 'event_espresso');
689
+		$this->_per_page_screen_option();
690
+	}
691 691
     
692 692
     
693
-    //none of the below group are currently used for Messages
694
-    protected function _add_feature_pointers()
695
-    {
696
-    }
693
+	//none of the below group are currently used for Messages
694
+	protected function _add_feature_pointers()
695
+	{
696
+	}
697 697
     
698
-    public function admin_init()
699
-    {
700
-    }
698
+	public function admin_init()
699
+	{
700
+	}
701 701
     
702
-    public function admin_notices()
703
-    {
704
-    }
702
+	public function admin_notices()
703
+	{
704
+	}
705 705
     
706
-    public function admin_footer_scripts()
707
-    {
708
-    }
706
+	public function admin_footer_scripts()
707
+	{
708
+	}
709 709
     
710 710
     
711
-    public function messages_help_tab()
712
-    {
713
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php');
714
-    }
711
+	public function messages_help_tab()
712
+	{
713
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php');
714
+	}
715 715
     
716 716
     
717
-    public function messengers_help_tab()
718
-    {
719
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php');
720
-    }
717
+	public function messengers_help_tab()
718
+	{
719
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php');
720
+	}
721 721
     
722 722
     
723
-    public function message_types_help_tab()
724
-    {
725
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php');
726
-    }
723
+	public function message_types_help_tab()
724
+	{
725
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php');
726
+	}
727 727
     
728 728
     
729
-    public function messages_overview_help_tab()
730
-    {
731
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php');
732
-    }
729
+	public function messages_overview_help_tab()
730
+	{
731
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php');
732
+	}
733 733
     
734 734
     
735
-    public function message_templates_help_tab()
736
-    {
737
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php');
738
-    }
735
+	public function message_templates_help_tab()
736
+	{
737
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php');
738
+	}
739 739
     
740 740
     
741
-    public function edit_message_template_help_tab()
742
-    {
743
-        $args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="'
744
-                        . esc_attr__('Editor Title', 'event_espresso')
745
-                        . '" />';
746
-        $args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="'
747
-                        . esc_attr__('Context Switcher and Preview', 'event_espresso')
748
-                        . '" />';
749
-        $args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="'
750
-                        . esc_attr__('Message Template Form Fields', 'event_espresso')
751
-                        . '" />';
752
-        $args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="'
753
-                        . esc_attr__('Shortcodes Metabox', 'event_espresso')
754
-                        . '" />';
755
-        $args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="'
756
-                        . esc_attr__('Publish Metabox', 'event_espresso')
757
-                        . '" />';
758
-        EEH_Template::display_template(
759
-            EE_MSG_TEMPLATE_PATH  . 'ee_msg_messages_templates_editor_help_tab.template.php',
760
-            $args
761
-        );
762
-    }
741
+	public function edit_message_template_help_tab()
742
+	{
743
+		$args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="'
744
+						. esc_attr__('Editor Title', 'event_espresso')
745
+						. '" />';
746
+		$args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="'
747
+						. esc_attr__('Context Switcher and Preview', 'event_espresso')
748
+						. '" />';
749
+		$args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="'
750
+						. esc_attr__('Message Template Form Fields', 'event_espresso')
751
+						. '" />';
752
+		$args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="'
753
+						. esc_attr__('Shortcodes Metabox', 'event_espresso')
754
+						. '" />';
755
+		$args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="'
756
+						. esc_attr__('Publish Metabox', 'event_espresso')
757
+						. '" />';
758
+		EEH_Template::display_template(
759
+			EE_MSG_TEMPLATE_PATH  . 'ee_msg_messages_templates_editor_help_tab.template.php',
760
+			$args
761
+		);
762
+	}
763 763
     
764 764
     
765
-    public function message_template_shortcodes_help_tab()
766
-    {
767
-        $this->_set_shortcodes();
768
-        $args['shortcodes'] = $this->_shortcodes;
769
-        EEH_Template::display_template(
770
-            EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php',
771
-            $args
772
-        );
773
-    }
765
+	public function message_template_shortcodes_help_tab()
766
+	{
767
+		$this->_set_shortcodes();
768
+		$args['shortcodes'] = $this->_shortcodes;
769
+		EEH_Template::display_template(
770
+			EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php',
771
+			$args
772
+		);
773
+	}
774 774
     
775 775
     
776
-    public function preview_message_help_tab()
777
-    {
778
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php');
779
-    }
776
+	public function preview_message_help_tab()
777
+	{
778
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php');
779
+	}
780 780
     
781 781
     
782
-    public function settings_help_tab()
783
-    {
784
-        $args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png'
785
-                        . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
786
-        $args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
787
-                        . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
788
-        $args['img3'] = '<div class="switch">'
789
-                        . '<input class="ee-on-off-toggle ee-toggle-round-flat"'
790
-                        . ' type="checkbox" checked="checked">'
791
-                        . '<label for="ee-on-off-toggle-on"></label>'
792
-                        . '</div>';
793
-        $args['img4'] = '<div class="switch">'
794
-                        . '<input class="ee-on-off-toggle ee-toggle-round-flat"'
795
-                        . ' type="checkbox">'
796
-                        . '<label for="ee-on-off-toggle-on"></label>'
797
-                        . '</div>';
798
-        EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
799
-    }
782
+	public function settings_help_tab()
783
+	{
784
+		$args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png'
785
+						. '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
786
+		$args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
787
+						. '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
788
+		$args['img3'] = '<div class="switch">'
789
+						. '<input class="ee-on-off-toggle ee-toggle-round-flat"'
790
+						. ' type="checkbox" checked="checked">'
791
+						. '<label for="ee-on-off-toggle-on"></label>'
792
+						. '</div>';
793
+		$args['img4'] = '<div class="switch">'
794
+						. '<input class="ee-on-off-toggle ee-toggle-round-flat"'
795
+						. ' type="checkbox">'
796
+						. '<label for="ee-on-off-toggle-on"></label>'
797
+						. '</div>';
798
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
799
+	}
800 800
     
801 801
     
802
-    public function load_scripts_styles()
803
-    {
804
-        wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
805
-        wp_enqueue_style('espresso_ee_msg');
806
-        
807
-        wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js',
808
-            array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true);
809
-        wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL . 'ee_message_admin_list_table.js',
810
-            array('ee-dialog'), EVENT_ESPRESSO_VERSION);
811
-    }
802
+	public function load_scripts_styles()
803
+	{
804
+		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
805
+		wp_enqueue_style('espresso_ee_msg');
806
+        
807
+		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js',
808
+			array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true);
809
+		wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL . 'ee_message_admin_list_table.js',
810
+			array('ee-dialog'), EVENT_ESPRESSO_VERSION);
811
+	}
812 812
     
813 813
     
814
-    public function load_scripts_styles_default()
815
-    {
816
-        wp_enqueue_script('ee-msg-list-table-js');
817
-    }
814
+	public function load_scripts_styles_default()
815
+	{
816
+		wp_enqueue_script('ee-msg-list-table-js');
817
+	}
818 818
     
819 819
     
820
-    public function wp_editor_css($mce_css)
821
-    {
822
-        //if we're on the edit_message_template route
823
-        if ($this->_req_action === 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
824
-            $message_type_name = $this->_active_message_type_name;
820
+	public function wp_editor_css($mce_css)
821
+	{
822
+		//if we're on the edit_message_template route
823
+		if ($this->_req_action === 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
824
+			$message_type_name = $this->_active_message_type_name;
825 825
             
826
-            //we're going to REPLACE the existing mce css
827
-            //we need to get the css file location from the active messenger
828
-            $mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true,
829
-                'wpeditor', $this->_variation);
830
-        }
831
-        
832
-        return $mce_css;
833
-    }
826
+			//we're going to REPLACE the existing mce css
827
+			//we need to get the css file location from the active messenger
828
+			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true,
829
+				'wpeditor', $this->_variation);
830
+		}
831
+        
832
+		return $mce_css;
833
+	}
834 834
     
835 835
     
836
-    public function load_scripts_styles_edit_message_template()
837
-    {
838
-        
839
-        $this->_set_shortcodes();
840
-        
841
-        EE_Registry::$i18n_js_strings['confirm_default_reset']        = sprintf(
842
-            esc_html__(
843
-                'Are you sure you want to reset the %s %s message templates?  Remember continuing will reset the templates for all contexts in this messenger and message type group.',
844
-                'event_espresso'
845
-            ),
846
-            $this->_message_template_group->messenger_obj()->label['singular'],
847
-            $this->_message_template_group->message_type_obj()->label['singular']
848
-        );
849
-        EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = esc_html__(
850
-            '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?',
851
-            'event_espresso'
852
-        );
853
-        EE_Registry::$i18n_js_strings['server_error'] = esc_html__(
854
-            'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
855
-            'event_espresso'
856
-        );
857
-        
858
-        wp_register_script(
859
-            'ee_msgs_edit_js',
860
-            EE_MSG_ASSETS_URL . 'ee_message_editor.js',
861
-            array('jquery'),
862
-            EVENT_ESPRESSO_VERSION
863
-        );
864
-        
865
-        wp_enqueue_script('ee_admin_js');
866
-        wp_enqueue_script('ee_msgs_edit_js');
867
-        
868
-        //add in special css for tiny_mce
869
-        add_filter('mce_css', array($this, 'wp_editor_css'));
870
-    }
836
+	public function load_scripts_styles_edit_message_template()
837
+	{
838
+        
839
+		$this->_set_shortcodes();
840
+        
841
+		EE_Registry::$i18n_js_strings['confirm_default_reset']        = sprintf(
842
+			esc_html__(
843
+				'Are you sure you want to reset the %s %s message templates?  Remember continuing will reset the templates for all contexts in this messenger and message type group.',
844
+				'event_espresso'
845
+			),
846
+			$this->_message_template_group->messenger_obj()->label['singular'],
847
+			$this->_message_template_group->message_type_obj()->label['singular']
848
+		);
849
+		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = esc_html__(
850
+			'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?',
851
+			'event_espresso'
852
+		);
853
+		EE_Registry::$i18n_js_strings['server_error'] = esc_html__(
854
+			'An unknown error occurred on the server while attempting to process your request. Please refresh the page and try again or contact support.',
855
+			'event_espresso'
856
+		);
857
+        
858
+		wp_register_script(
859
+			'ee_msgs_edit_js',
860
+			EE_MSG_ASSETS_URL . 'ee_message_editor.js',
861
+			array('jquery'),
862
+			EVENT_ESPRESSO_VERSION
863
+		);
864
+        
865
+		wp_enqueue_script('ee_admin_js');
866
+		wp_enqueue_script('ee_msgs_edit_js');
867
+        
868
+		//add in special css for tiny_mce
869
+		add_filter('mce_css', array($this, 'wp_editor_css'));
870
+	}
871 871
     
872 872
     
873
-    public function load_scripts_styles_display_preview_message()
874
-    {
875
-        
876
-        $this->_set_message_template_group();
877
-        
878
-        if (isset($this->_req_data['messenger'])) {
879
-            $this->_active_messenger = $this->_message_resource_manager->get_active_messenger(
880
-                $this->_req_data['messenger']
881
-            );
882
-        }
883
-        
884
-        $message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : '';
885
-        
886
-        
887
-        wp_enqueue_style('espresso_preview_css',
888
-            $this->_active_messenger->get_variation(
889
-                $this->_template_pack,
890
-                $message_type_name,
891
-                true,
892
-                'preview',
893
-                $this->_variation
894
-            )
895
-        );
896
-    }
873
+	public function load_scripts_styles_display_preview_message()
874
+	{
875
+        
876
+		$this->_set_message_template_group();
877
+        
878
+		if (isset($this->_req_data['messenger'])) {
879
+			$this->_active_messenger = $this->_message_resource_manager->get_active_messenger(
880
+				$this->_req_data['messenger']
881
+			);
882
+		}
883
+        
884
+		$message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : '';
885
+        
886
+        
887
+		wp_enqueue_style('espresso_preview_css',
888
+			$this->_active_messenger->get_variation(
889
+				$this->_template_pack,
890
+				$message_type_name,
891
+				true,
892
+				'preview',
893
+				$this->_variation
894
+			)
895
+		);
896
+	}
897 897
     
898 898
     
899
-    public function load_scripts_styles_settings()
900
-    {
901
-        wp_register_style(
902
-            'ee-message-settings',
903
-            EE_MSG_ASSETS_URL . 'ee_message_settings.css',
904
-            array(),
905
-            EVENT_ESPRESSO_VERSION
906
-        );
907
-        wp_enqueue_style('ee-text-links');
908
-        wp_enqueue_style('ee-message-settings');
909
-        wp_enqueue_script('ee-messages-settings');
910
-    }
899
+	public function load_scripts_styles_settings()
900
+	{
901
+		wp_register_style(
902
+			'ee-message-settings',
903
+			EE_MSG_ASSETS_URL . 'ee_message_settings.css',
904
+			array(),
905
+			EVENT_ESPRESSO_VERSION
906
+		);
907
+		wp_enqueue_style('ee-text-links');
908
+		wp_enqueue_style('ee-message-settings');
909
+		wp_enqueue_script('ee-messages-settings');
910
+	}
911 911
     
912 912
     
913
-    /**
914
-     * set views array for List Table
915
-     */
916
-    public function _set_list_table_views_global_mtps()
917
-    {
918
-        $this->_views = array(
919
-            'in_use' => array(
920
-                'slug'        => 'in_use',
921
-                'label'       => esc_html__('In Use', 'event_espresso'),
922
-                'count'       => 0,
923
-            )
924
-        );
925
-    }
913
+	/**
914
+	 * set views array for List Table
915
+	 */
916
+	public function _set_list_table_views_global_mtps()
917
+	{
918
+		$this->_views = array(
919
+			'in_use' => array(
920
+				'slug'        => 'in_use',
921
+				'label'       => esc_html__('In Use', 'event_espresso'),
922
+				'count'       => 0,
923
+			)
924
+		);
925
+	}
926 926
 
927 927
 
928
-    /**
929
-     * Set views array for the Custom Template List Table
930
-     */
931
-    public function _set_list_table_views_custom_mtps()
932
-    {
933
-        $this->_set_list_table_views_global_mtps();
934
-        $this->_views['in_use']['bulk_action'] = array(
935
-                'trash_message_template' => esc_html__('Move to Trash', 'event_espresso')
936
-        );
937
-    }
928
+	/**
929
+	 * Set views array for the Custom Template List Table
930
+	 */
931
+	public function _set_list_table_views_custom_mtps()
932
+	{
933
+		$this->_set_list_table_views_global_mtps();
934
+		$this->_views['in_use']['bulk_action'] = array(
935
+				'trash_message_template' => esc_html__('Move to Trash', 'event_espresso')
936
+		);
937
+	}
938 938
 
939 939
 
940
-    /**
941
-     * set views array for message queue list table
942
-     *
943
-     * @throws InvalidDataTypeException
944
-     * @throws InvalidInterfaceException
945
-     * @throws InvalidArgumentException
946
-     * @throws EE_Error
947
-     * @throws ReflectionException
948
-     */
949
-    public function _set_list_table_views_default()
950
-    {
951
-        EE_Registry::instance()->load_helper('Template');
952
-        
953
-        $common_bulk_actions = EE_Registry::instance()->CAP->current_user_can(
954
-            'ee_send_message',
955
-            'message_list_table_bulk_actions'
956
-        )
957
-            ? array(
958
-                'generate_now'          => esc_html__('Generate Now', 'event_espresso'),
959
-                'generate_and_send_now' => esc_html__('Generate and Send Now', 'event_espresso'),
960
-                'queue_for_resending'   => esc_html__('Queue for Resending', 'event_espresso'),
961
-                'send_now'              => esc_html__('Send Now', 'event_espresso')
962
-            )
963
-            : array();
964
-        
965
-        $delete_bulk_action = EE_Registry::instance()->CAP->current_user_can(
966
-            'ee_delete_messages',
967
-            'message_list_table_bulk_actions'
968
-        )
969
-            ? array('delete_ee_messages' => esc_html__('Delete Messages', 'event_espresso'))
970
-            : array();
971
-        
972
-        
973
-        $this->_views = array(
974
-            'all' => array(
975
-                'slug'        => 'all',
976
-                'label'       => esc_html__('All', 'event_espresso'),
977
-                'count'       => 0,
978
-                'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action)
979
-            )
980
-        );
981
-        
982
-        
983
-        foreach (EEM_Message::instance()->all_statuses() as $status) {
984
-            if ($status === EEM_Message::status_debug_only && ! EEM_Message::debug()) {
985
-                continue;
986
-            }
987
-            $status_bulk_actions = $common_bulk_actions;
988
-            //unset bulk actions not applying to status
989
-            if (! empty($status_bulk_actions)) {
990
-                switch ($status) {
991
-                    case EEM_Message::status_idle:
992
-                    case EEM_Message::status_resend:
993
-                        $status_bulk_actions['send_now'] = $common_bulk_actions['send_now'];
994
-                        break;
940
+	/**
941
+	 * set views array for message queue list table
942
+	 *
943
+	 * @throws InvalidDataTypeException
944
+	 * @throws InvalidInterfaceException
945
+	 * @throws InvalidArgumentException
946
+	 * @throws EE_Error
947
+	 * @throws ReflectionException
948
+	 */
949
+	public function _set_list_table_views_default()
950
+	{
951
+		EE_Registry::instance()->load_helper('Template');
952
+        
953
+		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can(
954
+			'ee_send_message',
955
+			'message_list_table_bulk_actions'
956
+		)
957
+			? array(
958
+				'generate_now'          => esc_html__('Generate Now', 'event_espresso'),
959
+				'generate_and_send_now' => esc_html__('Generate and Send Now', 'event_espresso'),
960
+				'queue_for_resending'   => esc_html__('Queue for Resending', 'event_espresso'),
961
+				'send_now'              => esc_html__('Send Now', 'event_espresso')
962
+			)
963
+			: array();
964
+        
965
+		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can(
966
+			'ee_delete_messages',
967
+			'message_list_table_bulk_actions'
968
+		)
969
+			? array('delete_ee_messages' => esc_html__('Delete Messages', 'event_espresso'))
970
+			: array();
971
+        
972
+        
973
+		$this->_views = array(
974
+			'all' => array(
975
+				'slug'        => 'all',
976
+				'label'       => esc_html__('All', 'event_espresso'),
977
+				'count'       => 0,
978
+				'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action)
979
+			)
980
+		);
981
+        
982
+        
983
+		foreach (EEM_Message::instance()->all_statuses() as $status) {
984
+			if ($status === EEM_Message::status_debug_only && ! EEM_Message::debug()) {
985
+				continue;
986
+			}
987
+			$status_bulk_actions = $common_bulk_actions;
988
+			//unset bulk actions not applying to status
989
+			if (! empty($status_bulk_actions)) {
990
+				switch ($status) {
991
+					case EEM_Message::status_idle:
992
+					case EEM_Message::status_resend:
993
+						$status_bulk_actions['send_now'] = $common_bulk_actions['send_now'];
994
+						break;
995 995
                     
996
-                    case EEM_Message::status_failed:
997
-                    case EEM_Message::status_debug_only:
998
-                    case EEM_Message::status_messenger_executing:
999
-                        $status_bulk_actions = array();
1000
-                        break;
996
+					case EEM_Message::status_failed:
997
+					case EEM_Message::status_debug_only:
998
+					case EEM_Message::status_messenger_executing:
999
+						$status_bulk_actions = array();
1000
+						break;
1001 1001
                     
1002
-                    case EEM_Message::status_incomplete:
1003
-                        unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']);
1004
-                        break;
1002
+					case EEM_Message::status_incomplete:
1003
+						unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']);
1004
+						break;
1005 1005
                     
1006
-                    case EEM_Message::status_retry:
1007
-                    case EEM_Message::status_sent:
1008
-                        unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']);
1009
-                        break;
1010
-                }
1011
-            }
1006
+					case EEM_Message::status_retry:
1007
+					case EEM_Message::status_sent:
1008
+						unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']);
1009
+						break;
1010
+				}
1011
+			}
1012 1012
 
1013
-            //skip adding messenger executing status to views because it will be included with the Failed view.
1014
-            if ( $status === EEM_Message::status_messenger_executing ) {
1015
-                continue;
1016
-            }
1013
+			//skip adding messenger executing status to views because it will be included with the Failed view.
1014
+			if ( $status === EEM_Message::status_messenger_executing ) {
1015
+				continue;
1016
+			}
1017 1017
             
1018
-            $this->_views[strtolower($status)] = array(
1019
-                'slug'        => strtolower($status),
1020
-                'label'       => EEH_Template::pretty_status($status, false, 'sentence'),
1021
-                'count'       => 0,
1022
-                'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action)
1023
-            );
1024
-        }
1025
-    }
1018
+			$this->_views[strtolower($status)] = array(
1019
+				'slug'        => strtolower($status),
1020
+				'label'       => EEH_Template::pretty_status($status, false, 'sentence'),
1021
+				'count'       => 0,
1022
+				'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action)
1023
+			);
1024
+		}
1025
+	}
1026 1026
     
1027 1027
     
1028
-    protected function _ee_default_messages_overview_list_table()
1029
-    {
1030
-        $this->_admin_page_title = esc_html__('Default Message Templates', 'event_espresso');
1031
-        $this->display_admin_list_table_page_with_no_sidebar();
1032
-    }
1028
+	protected function _ee_default_messages_overview_list_table()
1029
+	{
1030
+		$this->_admin_page_title = esc_html__('Default Message Templates', 'event_espresso');
1031
+		$this->display_admin_list_table_page_with_no_sidebar();
1032
+	}
1033 1033
     
1034 1034
     
1035
-    protected function _message_queue_list_table()
1036
-    {
1037
-        $this->_search_btn_label                   = esc_html__('Message Activity', 'event_espresso');
1038
-        $this->_template_args['per_column']        = 6;
1039
-        $this->_template_args['after_list_table']  = $this->_display_legend($this->_message_legend_items());
1040
-        $this->_template_args['before_list_table'] = '<h3>'
1041
-                                                     . EEM_Message::instance()->get_pretty_label_for_results()
1042
-                                                     . '</h3>';
1043
-        $this->display_admin_list_table_page_with_no_sidebar();
1044
-    }
1035
+	protected function _message_queue_list_table()
1036
+	{
1037
+		$this->_search_btn_label                   = esc_html__('Message Activity', 'event_espresso');
1038
+		$this->_template_args['per_column']        = 6;
1039
+		$this->_template_args['after_list_table']  = $this->_display_legend($this->_message_legend_items());
1040
+		$this->_template_args['before_list_table'] = '<h3>'
1041
+													 . EEM_Message::instance()->get_pretty_label_for_results()
1042
+													 . '</h3>';
1043
+		$this->display_admin_list_table_page_with_no_sidebar();
1044
+	}
1045 1045
     
1046 1046
     
1047
-    protected function _message_legend_items()
1048
-    {
1049
-        
1050
-        $action_css_classes = EEH_MSG_Template::get_message_action_icons();
1051
-        $action_items       = array();
1052
-        
1053
-        foreach ($action_css_classes as $action_item => $action_details) {
1054
-            if ($action_item === 'see_notifications_for') {
1055
-                continue;
1056
-            }
1057
-            $action_items[$action_item] = array(
1058
-                'class' => $action_details['css_class'],
1059
-                'desc'  => $action_details['label']
1060
-            );
1061
-        }
1062
-        
1063
-        /** @type array $status_items status legend setup */
1064
-        $status_items = array(
1065
-            'sent_status'       => array(
1066
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent,
1067
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence')
1068
-            ),
1069
-            'idle_status'       => array(
1070
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle,
1071
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence')
1072
-            ),
1073
-            'failed_status'     => array(
1074
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed,
1075
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence')
1076
-            ),
1077
-            'messenger_executing_status' => array(
1078
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_messenger_executing,
1079
-                'desc' => EEH_Template::pretty_status(EEM_Message::status_messenger_executing, false, 'sentence')
1080
-            ),
1081
-            'resend_status'     => array(
1082
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend,
1083
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence')
1084
-            ),
1085
-            'incomplete_status' => array(
1086
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete,
1087
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence')
1088
-            ),
1089
-            'retry_status'      => array(
1090
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry,
1091
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence')
1092
-            )
1093
-        );
1094
-        if (EEM_Message::debug()) {
1095
-            $status_items['debug_only_status'] = array(
1096
-                'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only,
1097
-                'desc'  => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence')
1098
-            );
1099
-        }
1100
-        
1101
-        return array_merge($action_items, $status_items);
1102
-    }
1047
+	protected function _message_legend_items()
1048
+	{
1049
+        
1050
+		$action_css_classes = EEH_MSG_Template::get_message_action_icons();
1051
+		$action_items       = array();
1052
+        
1053
+		foreach ($action_css_classes as $action_item => $action_details) {
1054
+			if ($action_item === 'see_notifications_for') {
1055
+				continue;
1056
+			}
1057
+			$action_items[$action_item] = array(
1058
+				'class' => $action_details['css_class'],
1059
+				'desc'  => $action_details['label']
1060
+			);
1061
+		}
1062
+        
1063
+		/** @type array $status_items status legend setup */
1064
+		$status_items = array(
1065
+			'sent_status'       => array(
1066
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent,
1067
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence')
1068
+			),
1069
+			'idle_status'       => array(
1070
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle,
1071
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence')
1072
+			),
1073
+			'failed_status'     => array(
1074
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed,
1075
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence')
1076
+			),
1077
+			'messenger_executing_status' => array(
1078
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_messenger_executing,
1079
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_messenger_executing, false, 'sentence')
1080
+			),
1081
+			'resend_status'     => array(
1082
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend,
1083
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence')
1084
+			),
1085
+			'incomplete_status' => array(
1086
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete,
1087
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence')
1088
+			),
1089
+			'retry_status'      => array(
1090
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry,
1091
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence')
1092
+			)
1093
+		);
1094
+		if (EEM_Message::debug()) {
1095
+			$status_items['debug_only_status'] = array(
1096
+				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only,
1097
+				'desc'  => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence')
1098
+			);
1099
+		}
1100
+        
1101
+		return array_merge($action_items, $status_items);
1102
+	}
1103 1103
     
1104 1104
     
1105
-    protected function _custom_mtps_preview()
1106
-    {
1107
-        $this->_admin_page_title              = esc_html__('Custom Message Templates (Preview)', 'event_espresso');
1108
-        $this->_template_args['preview_img']  = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png"'
1109
-            . ' alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso') . '" />';
1110
-        $this->_template_args['preview_text'] = '<strong>'
1111
-            . esc_html__(
1112
-                'Custom Message Templates is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Custom Message Templates feature, you are able to create custom message templates and assign them on a per-event basis.',
1113
-                'event_espresso'
1114
-            )
1115
-            . '</strong>';
1105
+	protected function _custom_mtps_preview()
1106
+	{
1107
+		$this->_admin_page_title              = esc_html__('Custom Message Templates (Preview)', 'event_espresso');
1108
+		$this->_template_args['preview_img']  = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png"'
1109
+			. ' alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso') . '" />';
1110
+		$this->_template_args['preview_text'] = '<strong>'
1111
+			. esc_html__(
1112
+				'Custom Message Templates is a feature that is only available in the premium version of Event Espresso 4 which is available with a support license purchase on EventEspresso.com. With the Custom Message Templates feature, you are able to create custom message templates and assign them on a per-event basis.',
1113
+				'event_espresso'
1114
+			)
1115
+			. '</strong>';
1116 1116
 
1117
-        $this->display_admin_caf_preview_page('custom_message_types', false);
1118
-    }
1117
+		$this->display_admin_caf_preview_page('custom_message_types', false);
1118
+	}
1119 1119
 
1120 1120
 
1121
-    /**
1122
-     * get_message_templates
1123
-     * This gets all the message templates for listing on the overview list.
1124
-     *
1125
-     * @access public
1126
-     * @param int    $perpage the amount of templates groups to show per page
1127
-     * @param string $type    the current _view we're getting templates for
1128
-     * @param bool   $count   return count?
1129
-     * @param bool   $all     disregard any paging info (get all data);
1130
-     * @param bool   $global  whether to return just global (true) or custom templates (false)
1131
-     * @return array
1132
-     * @throws EE_Error
1133
-     * @throws InvalidArgumentException
1134
-     * @throws InvalidDataTypeException
1135
-     * @throws InvalidInterfaceException
1136
-     */
1137
-    public function get_message_templates(
1138
-        $perpage = 10,
1139
-        $type = 'in_use',
1140
-        $count = false,
1141
-        $all = false,
1142
-        $global = true)
1143
-    {
1144
-        
1145
-        $MTP = EEM_Message_Template_Group::instance();
1146
-        
1147
-        $this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby'];
1148
-        $orderby                    = $this->_req_data['orderby'];
1149
-        
1150
-        $order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1151
-            ? $this->_req_data['order']
1152
-            : 'ASC';
1153
-        
1154
-        $current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1155
-            ? $this->_req_data['paged']
1156
-            : 1;
1157
-        $per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1158
-            ? $this->_req_data['perpage']
1159
-            : $perpage;
1160
-        
1161
-        $offset = ($current_page - 1) * $per_page;
1162
-        $limit  = $all ? null : array($offset, $per_page);
1163
-        
1164
-        
1165
-        //options will match what is in the _views array property
1166
-        switch ($type) {
1167
-            case 'in_use':
1168
-                $templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true);
1169
-                break;
1170
-            default:
1171
-                $templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global);
1172
-        }
1173
-        
1174
-        return $templates;
1175
-    }
1121
+	/**
1122
+	 * get_message_templates
1123
+	 * This gets all the message templates for listing on the overview list.
1124
+	 *
1125
+	 * @access public
1126
+	 * @param int    $perpage the amount of templates groups to show per page
1127
+	 * @param string $type    the current _view we're getting templates for
1128
+	 * @param bool   $count   return count?
1129
+	 * @param bool   $all     disregard any paging info (get all data);
1130
+	 * @param bool   $global  whether to return just global (true) or custom templates (false)
1131
+	 * @return array
1132
+	 * @throws EE_Error
1133
+	 * @throws InvalidArgumentException
1134
+	 * @throws InvalidDataTypeException
1135
+	 * @throws InvalidInterfaceException
1136
+	 */
1137
+	public function get_message_templates(
1138
+		$perpage = 10,
1139
+		$type = 'in_use',
1140
+		$count = false,
1141
+		$all = false,
1142
+		$global = true)
1143
+	{
1144
+        
1145
+		$MTP = EEM_Message_Template_Group::instance();
1146
+        
1147
+		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby'];
1148
+		$orderby                    = $this->_req_data['orderby'];
1149
+        
1150
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order']))
1151
+			? $this->_req_data['order']
1152
+			: 'ASC';
1153
+        
1154
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged'])
1155
+			? $this->_req_data['paged']
1156
+			: 1;
1157
+		$per_page     = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage'])
1158
+			? $this->_req_data['perpage']
1159
+			: $perpage;
1160
+        
1161
+		$offset = ($current_page - 1) * $per_page;
1162
+		$limit  = $all ? null : array($offset, $per_page);
1163
+        
1164
+        
1165
+		//options will match what is in the _views array property
1166
+		switch ($type) {
1167
+			case 'in_use':
1168
+				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true);
1169
+				break;
1170
+			default:
1171
+				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global);
1172
+		}
1173
+        
1174
+		return $templates;
1175
+	}
1176 1176
     
1177 1177
     
1178
-    /**
1179
-     * filters etc might need a list of installed message_types
1180
-     * @return array an array of message type objects
1181
-     */
1182
-    public function get_installed_message_types()
1183
-    {
1184
-        $installed_message_types = $this->_message_resource_manager->installed_message_types();
1185
-        $installed               = array();
1186
-        
1187
-        foreach ($installed_message_types as $message_type) {
1188
-            $installed[$message_type->name] = $message_type;
1189
-        }
1190
-        
1191
-        return $installed;
1192
-    }
1178
+	/**
1179
+	 * filters etc might need a list of installed message_types
1180
+	 * @return array an array of message type objects
1181
+	 */
1182
+	public function get_installed_message_types()
1183
+	{
1184
+		$installed_message_types = $this->_message_resource_manager->installed_message_types();
1185
+		$installed               = array();
1186
+        
1187
+		foreach ($installed_message_types as $message_type) {
1188
+			$installed[$message_type->name] = $message_type;
1189
+		}
1190
+        
1191
+		return $installed;
1192
+	}
1193 1193
     
1194 1194
     
1195
-    /**
1196
-     * _add_message_template
1197
-     *
1198
-     * This is used when creating a custom template. All Custom Templates start based off another template.
1199
-     *
1200
-     * @param string $message_type
1201
-     * @param string $messenger
1202
-     * @param string $GRP_ID
1203
-     *
1204
-     * @throws EE_error
1205
-     */
1206
-    protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '')
1207
-    {
1208
-        //set values override any request data
1209
-        $message_type = ! empty($message_type) ? $message_type : '';
1210
-        $message_type = empty($message_type) && ! empty($this->_req_data['message_type'])
1211
-            ? $this->_req_data['message_type']
1212
-            : $message_type;
1213
-        
1214
-        $messenger = ! empty($messenger) ? $messenger : '';
1215
-        $messenger = empty($messenger) && ! empty($this->_req_data['messenger'])
1216
-            ? $this->_req_data['messenger']
1217
-            : $messenger;
1218
-        
1219
-        $GRP_ID = ! empty($GRP_ID) ? $GRP_ID : '';
1220
-        $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID;
1221
-        
1222
-        //we need messenger and message type.  They should be coming from the event editor. If not here then return error
1223
-        if (empty($message_type) || empty($messenger)) {
1224
-            throw new EE_Error(
1225
-                esc_html__(
1226
-                    'Sorry, but we can\'t create new templates because we\'re missing the messenger or message type',
1227
-                    'event_espresso'
1228
-                )
1229
-            );
1230
-        }
1231
-        
1232
-        //we need the GRP_ID for the template being used as the base for the new template
1233
-        if (empty($GRP_ID)) {
1234
-            throw new EE_Error(
1235
-                esc_html__(
1236
-                    'In order to create a custom message template the GRP_ID of the template being used as a base is needed',
1237
-                    'event_espresso'
1238
-                )
1239
-            );
1240
-        }
1241
-        
1242
-        //let's just make sure the template gets generated!
1243
-        
1244
-        //we need to reassign some variables for what the insert is expecting
1245
-        $this->_req_data['MTP_messenger']    = $messenger;
1246
-        $this->_req_data['MTP_message_type'] = $message_type;
1247
-        $this->_req_data['GRP_ID']           = $GRP_ID;
1248
-        $this->_insert_or_update_message_template(true);
1249
-    }
1195
+	/**
1196
+	 * _add_message_template
1197
+	 *
1198
+	 * This is used when creating a custom template. All Custom Templates start based off another template.
1199
+	 *
1200
+	 * @param string $message_type
1201
+	 * @param string $messenger
1202
+	 * @param string $GRP_ID
1203
+	 *
1204
+	 * @throws EE_error
1205
+	 */
1206
+	protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '')
1207
+	{
1208
+		//set values override any request data
1209
+		$message_type = ! empty($message_type) ? $message_type : '';
1210
+		$message_type = empty($message_type) && ! empty($this->_req_data['message_type'])
1211
+			? $this->_req_data['message_type']
1212
+			: $message_type;
1213
+        
1214
+		$messenger = ! empty($messenger) ? $messenger : '';
1215
+		$messenger = empty($messenger) && ! empty($this->_req_data['messenger'])
1216
+			? $this->_req_data['messenger']
1217
+			: $messenger;
1218
+        
1219
+		$GRP_ID = ! empty($GRP_ID) ? $GRP_ID : '';
1220
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID;
1221
+        
1222
+		//we need messenger and message type.  They should be coming from the event editor. If not here then return error
1223
+		if (empty($message_type) || empty($messenger)) {
1224
+			throw new EE_Error(
1225
+				esc_html__(
1226
+					'Sorry, but we can\'t create new templates because we\'re missing the messenger or message type',
1227
+					'event_espresso'
1228
+				)
1229
+			);
1230
+		}
1231
+        
1232
+		//we need the GRP_ID for the template being used as the base for the new template
1233
+		if (empty($GRP_ID)) {
1234
+			throw new EE_Error(
1235
+				esc_html__(
1236
+					'In order to create a custom message template the GRP_ID of the template being used as a base is needed',
1237
+					'event_espresso'
1238
+				)
1239
+			);
1240
+		}
1241
+        
1242
+		//let's just make sure the template gets generated!
1243
+        
1244
+		//we need to reassign some variables for what the insert is expecting
1245
+		$this->_req_data['MTP_messenger']    = $messenger;
1246
+		$this->_req_data['MTP_message_type'] = $message_type;
1247
+		$this->_req_data['GRP_ID']           = $GRP_ID;
1248
+		$this->_insert_or_update_message_template(true);
1249
+	}
1250 1250
 
1251 1251
 
1252
-    /**
1253
-     * public wrapper for the _add_message_template method
1254
-     *
1255
-     * @param string $message_type     message type slug
1256
-     * @param string $messenger        messenger slug
1257
-     * @param int    $GRP_ID           GRP_ID for the related message template group this new template will be based
1258
-     *                                 off of.
1259
-     * @throws EE_error
1260
-     */
1261
-    public function add_message_template($message_type, $messenger, $GRP_ID)
1262
-    {
1263
-        $this->_add_message_template($message_type, $messenger, $GRP_ID);
1264
-    }
1252
+	/**
1253
+	 * public wrapper for the _add_message_template method
1254
+	 *
1255
+	 * @param string $message_type     message type slug
1256
+	 * @param string $messenger        messenger slug
1257
+	 * @param int    $GRP_ID           GRP_ID for the related message template group this new template will be based
1258
+	 *                                 off of.
1259
+	 * @throws EE_error
1260
+	 */
1261
+	public function add_message_template($message_type, $messenger, $GRP_ID)
1262
+	{
1263
+		$this->_add_message_template($message_type, $messenger, $GRP_ID);
1264
+	}
1265 1265
 
1266 1266
 
1267
-    /**
1268
-     * _edit_message_template
1269
-     *
1270
-     * @access protected
1271
-     * @return void
1272
-     * @throws InvalidIdentifierException
1273
-     * @throws DomainException
1274
-     * @throws EE_Error
1275
-     * @throws InvalidArgumentException
1276
-     * @throws ReflectionException
1277
-     * @throws InvalidDataTypeException
1278
-     * @throws InvalidInterfaceException
1279
-     */
1280
-    protected function _edit_message_template()
1281
-    {
1282
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1283
-        $template_fields = '';
1284
-        $sidebar_fields  = '';
1285
-        //we filter the tinyMCE settings to remove the validation since message templates by their nature will not have
1286
-        // valid html in the templates.
1287
-        add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2);
1288
-        
1289
-        $GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id'])
1290
-            ? absint($this->_req_data['id'])
1291
-            : false;
1292
-        
1293
-        $this->_set_shortcodes(); //this also sets the _message_template property.
1294
-        $message_template_group = $this->_message_template_group;
1295
-        $c_label                = $message_template_group->context_label();
1296
-        $c_config               = $message_template_group->contexts_config();
1297
-        
1298
-        reset($c_config);
1299
-        $context = isset($this->_req_data['context']) && ! empty($this->_req_data['context'])
1300
-            ? strtolower($this->_req_data['context'])
1301
-            : key($c_config);
1302
-        
1303
-        
1304
-        if (empty($GRP_ID)) {
1305
-            $action = 'insert_message_template';
1306
-            $edit_message_template_form_url = add_query_arg(
1307
-                array('action' => $action, 'noheader' => true),
1308
-                EE_MSG_ADMIN_URL
1309
-            );
1310
-        } else {
1311
-            $action = 'update_message_template';
1312
-            $edit_message_template_form_url = add_query_arg(
1313
-                array('action' => $action, 'noheader' => true),
1314
-                EE_MSG_ADMIN_URL
1315
-            );
1316
-        }
1317
-        
1318
-        //set active messenger for this view
1319
-        $this->_active_messenger         = $this->_message_resource_manager->get_active_messenger(
1320
-            $message_template_group->messenger()
1321
-        );
1322
-        $this->_active_message_type_name = $message_template_group->message_type();
1323
-        
1324
-        
1325
-        //Do we have any validation errors?
1326
-        $validators = $this->_get_transient();
1327
-        $v_fields   = ! empty($validators) ? array_keys($validators) : array();
1328
-        
1329
-        
1330
-        //we need to assemble the title from Various details
1331
-        $context_label = sprintf(
1332
-            esc_html__('(%s %s)', 'event_espresso'),
1333
-            $c_config[$context]['label'],
1334
-            ucwords($c_label['label'])
1335
-        );
1336
-        
1337
-        $title = sprintf(
1338
-            esc_html__(' %s %s Template %s', 'event_espresso'),
1339
-            ucwords($message_template_group->messenger_obj()->label['singular']),
1340
-            ucwords($message_template_group->message_type_obj()->label['singular']),
1341
-            $context_label
1342
-        );
1343
-        
1344
-        $this->_template_args['GRP_ID']           = $GRP_ID;
1345
-        $this->_template_args['message_template'] = $message_template_group;
1346
-        $this->_template_args['is_extra_fields']  = false;
1347
-        
1348
-        
1349
-        //let's get EEH_MSG_Template so we can get template form fields
1350
-        $template_field_structure = EEH_MSG_Template::get_fields(
1351
-            $message_template_group->messenger(),
1352
-            $message_template_group->message_type()
1353
-        );
1354
-        
1355
-        if ( ! $template_field_structure) {
1356
-            $template_field_structure = false;
1357
-            $template_fields          = esc_html__(
1358
-                'There was an error in assembling the fields for this display (you should see an error message)',
1359
-                'event_espresso'
1360
-            );
1361
-        }
1362
-        
1363
-        
1364
-        $message_templates = $message_template_group->context_templates();
1365
-        
1366
-        
1367
-        //if we have the extra key.. then we need to remove the content index from the template_field_structure as it
1368
-        // will get handled in the "extra" array.
1369
-        if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) {
1370
-            foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) {
1371
-                unset($template_field_structure[$context][$reference_field]);
1372
-            }
1373
-        }
1374
-        
1375
-        //let's loop through the template_field_structure and actually assemble the input fields!
1376
-        if ( ! empty($template_field_structure)) {
1377
-            foreach ($template_field_structure[$context] as $template_field => $field_setup_array) {
1378
-                //if this is an 'extra' template field then we need to remove any existing fields that are keyed up in
1379
-                // the extra array and reset them.
1380
-                if ($template_field === 'extra') {
1381
-                    $this->_template_args['is_extra_fields'] = true;
1382
-                    foreach ($field_setup_array as $reference_field => $new_fields_array) {
1383
-                        $message_template = $message_templates[$context][$reference_field];
1384
-                        $content          = $message_template instanceof EE_Message_Template
1385
-                            ? $message_template->get('MTP_content')
1386
-                            : '';
1387
-                        foreach ($new_fields_array as $extra_field => $extra_array) {
1388
-                            //let's verify if we need this extra field via the shortcodes parameter.
1389
-                            $continue = false;
1390
-                            if (isset($extra_array['shortcodes_required'])) {
1391
-                                foreach ((array)$extra_array['shortcodes_required'] as $shortcode) {
1392
-                                    if ( ! array_key_exists($shortcode, $this->_shortcodes)) {
1393
-                                        $continue = true;
1394
-                                    }
1395
-                                }
1396
-                                if ($continue) {
1397
-                                    continue;
1398
-                                }
1399
-                            }
1267
+	/**
1268
+	 * _edit_message_template
1269
+	 *
1270
+	 * @access protected
1271
+	 * @return void
1272
+	 * @throws InvalidIdentifierException
1273
+	 * @throws DomainException
1274
+	 * @throws EE_Error
1275
+	 * @throws InvalidArgumentException
1276
+	 * @throws ReflectionException
1277
+	 * @throws InvalidDataTypeException
1278
+	 * @throws InvalidInterfaceException
1279
+	 */
1280
+	protected function _edit_message_template()
1281
+	{
1282
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1283
+		$template_fields = '';
1284
+		$sidebar_fields  = '';
1285
+		//we filter the tinyMCE settings to remove the validation since message templates by their nature will not have
1286
+		// valid html in the templates.
1287
+		add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2);
1288
+        
1289
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id'])
1290
+			? absint($this->_req_data['id'])
1291
+			: false;
1292
+        
1293
+		$this->_set_shortcodes(); //this also sets the _message_template property.
1294
+		$message_template_group = $this->_message_template_group;
1295
+		$c_label                = $message_template_group->context_label();
1296
+		$c_config               = $message_template_group->contexts_config();
1297
+        
1298
+		reset($c_config);
1299
+		$context = isset($this->_req_data['context']) && ! empty($this->_req_data['context'])
1300
+			? strtolower($this->_req_data['context'])
1301
+			: key($c_config);
1302
+        
1303
+        
1304
+		if (empty($GRP_ID)) {
1305
+			$action = 'insert_message_template';
1306
+			$edit_message_template_form_url = add_query_arg(
1307
+				array('action' => $action, 'noheader' => true),
1308
+				EE_MSG_ADMIN_URL
1309
+			);
1310
+		} else {
1311
+			$action = 'update_message_template';
1312
+			$edit_message_template_form_url = add_query_arg(
1313
+				array('action' => $action, 'noheader' => true),
1314
+				EE_MSG_ADMIN_URL
1315
+			);
1316
+		}
1317
+        
1318
+		//set active messenger for this view
1319
+		$this->_active_messenger         = $this->_message_resource_manager->get_active_messenger(
1320
+			$message_template_group->messenger()
1321
+		);
1322
+		$this->_active_message_type_name = $message_template_group->message_type();
1323
+        
1324
+        
1325
+		//Do we have any validation errors?
1326
+		$validators = $this->_get_transient();
1327
+		$v_fields   = ! empty($validators) ? array_keys($validators) : array();
1328
+        
1329
+        
1330
+		//we need to assemble the title from Various details
1331
+		$context_label = sprintf(
1332
+			esc_html__('(%s %s)', 'event_espresso'),
1333
+			$c_config[$context]['label'],
1334
+			ucwords($c_label['label'])
1335
+		);
1336
+        
1337
+		$title = sprintf(
1338
+			esc_html__(' %s %s Template %s', 'event_espresso'),
1339
+			ucwords($message_template_group->messenger_obj()->label['singular']),
1340
+			ucwords($message_template_group->message_type_obj()->label['singular']),
1341
+			$context_label
1342
+		);
1343
+        
1344
+		$this->_template_args['GRP_ID']           = $GRP_ID;
1345
+		$this->_template_args['message_template'] = $message_template_group;
1346
+		$this->_template_args['is_extra_fields']  = false;
1347
+        
1348
+        
1349
+		//let's get EEH_MSG_Template so we can get template form fields
1350
+		$template_field_structure = EEH_MSG_Template::get_fields(
1351
+			$message_template_group->messenger(),
1352
+			$message_template_group->message_type()
1353
+		);
1354
+        
1355
+		if ( ! $template_field_structure) {
1356
+			$template_field_structure = false;
1357
+			$template_fields          = esc_html__(
1358
+				'There was an error in assembling the fields for this display (you should see an error message)',
1359
+				'event_espresso'
1360
+			);
1361
+		}
1362
+        
1363
+        
1364
+		$message_templates = $message_template_group->context_templates();
1365
+        
1366
+        
1367
+		//if we have the extra key.. then we need to remove the content index from the template_field_structure as it
1368
+		// will get handled in the "extra" array.
1369
+		if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) {
1370
+			foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) {
1371
+				unset($template_field_structure[$context][$reference_field]);
1372
+			}
1373
+		}
1374
+        
1375
+		//let's loop through the template_field_structure and actually assemble the input fields!
1376
+		if ( ! empty($template_field_structure)) {
1377
+			foreach ($template_field_structure[$context] as $template_field => $field_setup_array) {
1378
+				//if this is an 'extra' template field then we need to remove any existing fields that are keyed up in
1379
+				// the extra array and reset them.
1380
+				if ($template_field === 'extra') {
1381
+					$this->_template_args['is_extra_fields'] = true;
1382
+					foreach ($field_setup_array as $reference_field => $new_fields_array) {
1383
+						$message_template = $message_templates[$context][$reference_field];
1384
+						$content          = $message_template instanceof EE_Message_Template
1385
+							? $message_template->get('MTP_content')
1386
+							: '';
1387
+						foreach ($new_fields_array as $extra_field => $extra_array) {
1388
+							//let's verify if we need this extra field via the shortcodes parameter.
1389
+							$continue = false;
1390
+							if (isset($extra_array['shortcodes_required'])) {
1391
+								foreach ((array)$extra_array['shortcodes_required'] as $shortcode) {
1392
+									if ( ! array_key_exists($shortcode, $this->_shortcodes)) {
1393
+										$continue = true;
1394
+									}
1395
+								}
1396
+								if ($continue) {
1397
+									continue;
1398
+								}
1399
+							}
1400 1400
                             
1401
-                            $field_id                                = $reference_field
1402
-                                                                       . '-'
1403
-                                                                       . $extra_field
1404
-                                                                       . '-content';
1405
-                            $template_form_fields[$field_id]         = $extra_array;
1406
-                            $template_form_fields[$field_id]['name'] = 'MTP_template_fields['
1407
-                                                                       . $reference_field
1408
-                                                                       . '][content]['
1409
-                                                                       . $extra_field . ']';
1410
-                            $css_class                               = isset($extra_array['css_class'])
1411
-                                ? $extra_array['css_class']
1412
-                                : '';
1401
+							$field_id                                = $reference_field
1402
+																	   . '-'
1403
+																	   . $extra_field
1404
+																	   . '-content';
1405
+							$template_form_fields[$field_id]         = $extra_array;
1406
+							$template_form_fields[$field_id]['name'] = 'MTP_template_fields['
1407
+																	   . $reference_field
1408
+																	   . '][content]['
1409
+																	   . $extra_field . ']';
1410
+							$css_class                               = isset($extra_array['css_class'])
1411
+								? $extra_array['css_class']
1412
+								: '';
1413 1413
                             
1414
-                            $template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1415
-                                && in_array($extra_field, $v_fields, true)
1416
-                                &&
1417
-                                (
1418
-                                    is_array($validators[$extra_field])
1419
-                                    && isset($validators[$extra_field]['msg'])
1420
-                                )
1421
-                                ? 'validate-error ' . $css_class
1422
-                                : $css_class;
1414
+							$template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1415
+								&& in_array($extra_field, $v_fields, true)
1416
+								&&
1417
+								(
1418
+									is_array($validators[$extra_field])
1419
+									&& isset($validators[$extra_field]['msg'])
1420
+								)
1421
+								? 'validate-error ' . $css_class
1422
+								: $css_class;
1423 1423
                             
1424
-                            $template_form_fields[$field_id]['value'] = ! empty($message_templates)
1425
-                                                                        && isset($content[$extra_field])
1426
-                                ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8"))
1427
-                                : '';
1424
+							$template_form_fields[$field_id]['value'] = ! empty($message_templates)
1425
+																		&& isset($content[$extra_field])
1426
+								? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8"))
1427
+								: '';
1428 1428
                             
1429
-                            //do we have a validation error?  if we do then let's use that value instead
1430
-                            $template_form_fields[$field_id]['value'] = isset($validators[$extra_field])
1431
-                                ? $validators[$extra_field]['value']
1432
-                                : $template_form_fields[$field_id]['value'];
1429
+							//do we have a validation error?  if we do then let's use that value instead
1430
+							$template_form_fields[$field_id]['value'] = isset($validators[$extra_field])
1431
+								? $validators[$extra_field]['value']
1432
+								: $template_form_fields[$field_id]['value'];
1433 1433
                             
1434 1434
                             
1435
-                            $template_form_fields[$field_id]['db-col'] = 'MTP_content';
1435
+							$template_form_fields[$field_id]['db-col'] = 'MTP_content';
1436 1436
                             
1437
-                            //shortcode selector
1438
-                            $field_name_to_use                                 = $extra_field === 'main'
1439
-                                ? 'content'
1440
-                                : $extra_field;
1441
-                            $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector(
1442
-                                $field_name_to_use,
1443
-                                $field_id
1444
-                            );
1437
+							//shortcode selector
1438
+							$field_name_to_use                                 = $extra_field === 'main'
1439
+								? 'content'
1440
+								: $extra_field;
1441
+							$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector(
1442
+								$field_name_to_use,
1443
+								$field_id
1444
+							);
1445 1445
                             
1446
-                            if (isset($extra_array['input']) && $extra_array['input'] === 'wp_editor') {
1447
-                                //we want to decode the entities
1448
-                                $template_form_fields[$field_id]['value'] = stripslashes(
1449
-                                    html_entity_decode(
1450
-                                        $template_form_fields[$field_id]['value'],
1451
-                                        ENT_QUOTES,
1452
-                                        "UTF-8")
1453
-                                );
1446
+							if (isset($extra_array['input']) && $extra_array['input'] === 'wp_editor') {
1447
+								//we want to decode the entities
1448
+								$template_form_fields[$field_id]['value'] = stripslashes(
1449
+									html_entity_decode(
1450
+										$template_form_fields[$field_id]['value'],
1451
+										ENT_QUOTES,
1452
+										"UTF-8")
1453
+								);
1454 1454
                                 
1455
-                            }/**/
1456
-                        }
1457
-                        $templatefield_MTP_id          = $reference_field . '-MTP_ID';
1458
-                        $templatefield_templatename_id = $reference_field . '-name';
1455
+							}/**/
1456
+						}
1457
+						$templatefield_MTP_id          = $reference_field . '-MTP_ID';
1458
+						$templatefield_templatename_id = $reference_field . '-name';
1459 1459
                         
1460
-                        $template_form_fields[$templatefield_MTP_id] = array(
1461
-                            'name'       => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1462
-                            'label'      => null,
1463
-                            'input'      => 'hidden',
1464
-                            'type'       => 'int',
1465
-                            'required'   => false,
1466
-                            'validation' => false,
1467
-                            'value'      => ! empty($message_templates) ? $message_template->ID() : '',
1468
-                            'css_class'  => '',
1469
-                            'format'     => '%d',
1470
-                            'db-col'     => 'MTP_ID'
1471
-                        );
1460
+						$template_form_fields[$templatefield_MTP_id] = array(
1461
+							'name'       => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1462
+							'label'      => null,
1463
+							'input'      => 'hidden',
1464
+							'type'       => 'int',
1465
+							'required'   => false,
1466
+							'validation' => false,
1467
+							'value'      => ! empty($message_templates) ? $message_template->ID() : '',
1468
+							'css_class'  => '',
1469
+							'format'     => '%d',
1470
+							'db-col'     => 'MTP_ID'
1471
+						);
1472 1472
                         
1473
-                        $template_form_fields[$templatefield_templatename_id] = array(
1474
-                            'name'       => 'MTP_template_fields[' . $reference_field . '][name]',
1475
-                            'label'      => null,
1476
-                            'input'      => 'hidden',
1477
-                            'type'       => 'string',
1478
-                            'required'   => false,
1479
-                            'validation' => true,
1480
-                            'value'      => $reference_field,
1481
-                            'css_class'  => '',
1482
-                            'format'     => '%s',
1483
-                            'db-col'     => 'MTP_template_field'
1484
-                        );
1485
-                    }
1486
-                    continue; //skip the next stuff, we got the necessary fields here for this dataset.
1487
-                } else {
1488
-                    $field_id                                 = $template_field . '-content';
1489
-                    $template_form_fields[$field_id]          = $field_setup_array;
1490
-                    $template_form_fields[$field_id]['name']  = 'MTP_template_fields[' . $template_field . '][content]';
1491
-                    $message_template                         = isset($message_templates[$context][$template_field])
1492
-                        ? $message_templates[$context][$template_field]
1493
-                        : null;
1494
-                    $template_form_fields[$field_id]['value'] = ! empty($message_templates)
1495
-                                                                && is_array($message_templates[$context])
1496
-                                                                && $message_template instanceof EE_Message_Template
1497
-                        ? $message_template->get('MTP_content')
1498
-                        : '';
1473
+						$template_form_fields[$templatefield_templatename_id] = array(
1474
+							'name'       => 'MTP_template_fields[' . $reference_field . '][name]',
1475
+							'label'      => null,
1476
+							'input'      => 'hidden',
1477
+							'type'       => 'string',
1478
+							'required'   => false,
1479
+							'validation' => true,
1480
+							'value'      => $reference_field,
1481
+							'css_class'  => '',
1482
+							'format'     => '%s',
1483
+							'db-col'     => 'MTP_template_field'
1484
+						);
1485
+					}
1486
+					continue; //skip the next stuff, we got the necessary fields here for this dataset.
1487
+				} else {
1488
+					$field_id                                 = $template_field . '-content';
1489
+					$template_form_fields[$field_id]          = $field_setup_array;
1490
+					$template_form_fields[$field_id]['name']  = 'MTP_template_fields[' . $template_field . '][content]';
1491
+					$message_template                         = isset($message_templates[$context][$template_field])
1492
+						? $message_templates[$context][$template_field]
1493
+						: null;
1494
+					$template_form_fields[$field_id]['value'] = ! empty($message_templates)
1495
+																&& is_array($message_templates[$context])
1496
+																&& $message_template instanceof EE_Message_Template
1497
+						? $message_template->get('MTP_content')
1498
+						: '';
1499 1499
                     
1500
-                    //do we have a validator error for this field?  if we do then we'll use that value instead
1501
-                    $template_form_fields[$field_id]['value'] = isset($validators[$template_field])
1502
-                        ? $validators[$template_field]['value']
1503
-                        : $template_form_fields[$field_id]['value'];
1500
+					//do we have a validator error for this field?  if we do then we'll use that value instead
1501
+					$template_form_fields[$field_id]['value'] = isset($validators[$template_field])
1502
+						? $validators[$template_field]['value']
1503
+						: $template_form_fields[$field_id]['value'];
1504 1504
                     
1505 1505
                     
1506
-                    $template_form_fields[$field_id]['db-col']    = 'MTP_content';
1507
-                    $css_class                                    = isset($field_setup_array['css_class'])
1508
-                        ? $field_setup_array['css_class']
1509
-                        : '';
1510
-                    $template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1511
-                                                                    && in_array($template_field, $v_fields, true)
1512
-                                                                    && isset($validators[$template_field]['msg'])
1513
-                        ? 'validate-error ' . $css_class
1514
-                        : $css_class;
1506
+					$template_form_fields[$field_id]['db-col']    = 'MTP_content';
1507
+					$css_class                                    = isset($field_setup_array['css_class'])
1508
+						? $field_setup_array['css_class']
1509
+						: '';
1510
+					$template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1511
+																	&& in_array($template_field, $v_fields, true)
1512
+																	&& isset($validators[$template_field]['msg'])
1513
+						? 'validate-error ' . $css_class
1514
+						: $css_class;
1515 1515
                     
1516
-                    //shortcode selector
1517
-                    $template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector(
1518
-                        $template_field, $field_id
1519
-                    );
1520
-                }
1516
+					//shortcode selector
1517
+					$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector(
1518
+						$template_field, $field_id
1519
+					);
1520
+				}
1521 1521
                 
1522
-                //k took care of content field(s) now let's take care of others.
1522
+				//k took care of content field(s) now let's take care of others.
1523 1523
                 
1524
-                $templatefield_MTP_id                = $template_field . '-MTP_ID';
1525
-                $templatefield_field_templatename_id = $template_field . '-name';
1524
+				$templatefield_MTP_id                = $template_field . '-MTP_ID';
1525
+				$templatefield_field_templatename_id = $template_field . '-name';
1526 1526
                 
1527
-                //foreach template field there are actually two form fields created
1528
-                $template_form_fields[$templatefield_MTP_id] = array(
1529
-                    'name'       => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1530
-                    'label'      => null,
1531
-                    'input'      => 'hidden',
1532
-                    'type'       => 'int',
1533
-                    'required'   => false,
1534
-                    'validation' => true,
1535
-                    'value'      => $message_template instanceof EE_Message_Template ? $message_template->ID() : '',
1536
-                    'css_class'  => '',
1537
-                    'format'     => '%d',
1538
-                    'db-col'     => 'MTP_ID'
1539
-                );
1527
+				//foreach template field there are actually two form fields created
1528
+				$template_form_fields[$templatefield_MTP_id] = array(
1529
+					'name'       => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1530
+					'label'      => null,
1531
+					'input'      => 'hidden',
1532
+					'type'       => 'int',
1533
+					'required'   => false,
1534
+					'validation' => true,
1535
+					'value'      => $message_template instanceof EE_Message_Template ? $message_template->ID() : '',
1536
+					'css_class'  => '',
1537
+					'format'     => '%d',
1538
+					'db-col'     => 'MTP_ID'
1539
+				);
1540 1540
                 
1541
-                $template_form_fields[$templatefield_field_templatename_id] = array(
1542
-                    'name'       => 'MTP_template_fields[' . $template_field . '][name]',
1543
-                    'label'      => null,
1544
-                    'input'      => 'hidden',
1545
-                    'type'       => 'string',
1546
-                    'required'   => false,
1547
-                    'validation' => true,
1548
-                    'value'      => $template_field,
1549
-                    'css_class'  => '',
1550
-                    'format'     => '%s',
1551
-                    'db-col'     => 'MTP_template_field'
1552
-                );
1541
+				$template_form_fields[$templatefield_field_templatename_id] = array(
1542
+					'name'       => 'MTP_template_fields[' . $template_field . '][name]',
1543
+					'label'      => null,
1544
+					'input'      => 'hidden',
1545
+					'type'       => 'string',
1546
+					'required'   => false,
1547
+					'validation' => true,
1548
+					'value'      => $template_field,
1549
+					'css_class'  => '',
1550
+					'format'     => '%s',
1551
+					'db-col'     => 'MTP_template_field'
1552
+				);
1553 1553
                 
1554
-            }
1554
+			}
1555 1555
             
1556
-            //add other fields
1557
-            $template_form_fields['ee-msg-current-context'] = array(
1558
-                'name'       => 'MTP_context',
1559
-                'label'      => null,
1560
-                'input'      => 'hidden',
1561
-                'type'       => 'string',
1562
-                'required'   => false,
1563
-                'validation' => true,
1564
-                'value'      => $context,
1565
-                'css_class'  => '',
1566
-                'format'     => '%s',
1567
-                'db-col'     => 'MTP_context'
1568
-            );
1556
+			//add other fields
1557
+			$template_form_fields['ee-msg-current-context'] = array(
1558
+				'name'       => 'MTP_context',
1559
+				'label'      => null,
1560
+				'input'      => 'hidden',
1561
+				'type'       => 'string',
1562
+				'required'   => false,
1563
+				'validation' => true,
1564
+				'value'      => $context,
1565
+				'css_class'  => '',
1566
+				'format'     => '%s',
1567
+				'db-col'     => 'MTP_context'
1568
+			);
1569 1569
             
1570
-            $template_form_fields['ee-msg-grp-id'] = array(
1571
-                'name'       => 'GRP_ID',
1572
-                'label'      => null,
1573
-                'input'      => 'hidden',
1574
-                'type'       => 'int',
1575
-                'required'   => false,
1576
-                'validation' => true,
1577
-                'value'      => $GRP_ID,
1578
-                'css_class'  => '',
1579
-                'format'     => '%d',
1580
-                'db-col'     => 'GRP_ID'
1581
-            );
1570
+			$template_form_fields['ee-msg-grp-id'] = array(
1571
+				'name'       => 'GRP_ID',
1572
+				'label'      => null,
1573
+				'input'      => 'hidden',
1574
+				'type'       => 'int',
1575
+				'required'   => false,
1576
+				'validation' => true,
1577
+				'value'      => $GRP_ID,
1578
+				'css_class'  => '',
1579
+				'format'     => '%d',
1580
+				'db-col'     => 'GRP_ID'
1581
+			);
1582 1582
             
1583
-            $template_form_fields['ee-msg-messenger'] = array(
1584
-                'name'       => 'MTP_messenger',
1585
-                'label'      => null,
1586
-                'input'      => 'hidden',
1587
-                'type'       => 'string',
1588
-                'required'   => false,
1589
-                'validation' => true,
1590
-                'value'      => $message_template_group->messenger(),
1591
-                'css_class'  => '',
1592
-                'format'     => '%s',
1593
-                'db-col'     => 'MTP_messenger'
1594
-            );
1583
+			$template_form_fields['ee-msg-messenger'] = array(
1584
+				'name'       => 'MTP_messenger',
1585
+				'label'      => null,
1586
+				'input'      => 'hidden',
1587
+				'type'       => 'string',
1588
+				'required'   => false,
1589
+				'validation' => true,
1590
+				'value'      => $message_template_group->messenger(),
1591
+				'css_class'  => '',
1592
+				'format'     => '%s',
1593
+				'db-col'     => 'MTP_messenger'
1594
+			);
1595 1595
             
1596
-            $template_form_fields['ee-msg-message-type'] = array(
1597
-                'name'       => 'MTP_message_type',
1598
-                'label'      => null,
1599
-                'input'      => 'hidden',
1600
-                'type'       => 'string',
1601
-                'required'   => false,
1602
-                'validation' => true,
1603
-                'value'      => $message_template_group->message_type(),
1604
-                'css_class'  => '',
1605
-                'format'     => '%s',
1606
-                'db-col'     => 'MTP_message_type'
1607
-            );
1596
+			$template_form_fields['ee-msg-message-type'] = array(
1597
+				'name'       => 'MTP_message_type',
1598
+				'label'      => null,
1599
+				'input'      => 'hidden',
1600
+				'type'       => 'string',
1601
+				'required'   => false,
1602
+				'validation' => true,
1603
+				'value'      => $message_template_group->message_type(),
1604
+				'css_class'  => '',
1605
+				'format'     => '%s',
1606
+				'db-col'     => 'MTP_message_type'
1607
+			);
1608 1608
             
1609
-            $sidebar_form_fields['ee-msg-is-global'] = array(
1610
-                'name'       => 'MTP_is_global',
1611
-                'label'      => esc_html__('Global Template', 'event_espresso'),
1612
-                'input'      => 'hidden',
1613
-                'type'       => 'int',
1614
-                'required'   => false,
1615
-                'validation' => true,
1616
-                'value'      => $message_template_group->get('MTP_is_global'),
1617
-                'css_class'  => '',
1618
-                'format'     => '%d',
1619
-                'db-col'     => 'MTP_is_global'
1620
-            );
1609
+			$sidebar_form_fields['ee-msg-is-global'] = array(
1610
+				'name'       => 'MTP_is_global',
1611
+				'label'      => esc_html__('Global Template', 'event_espresso'),
1612
+				'input'      => 'hidden',
1613
+				'type'       => 'int',
1614
+				'required'   => false,
1615
+				'validation' => true,
1616
+				'value'      => $message_template_group->get('MTP_is_global'),
1617
+				'css_class'  => '',
1618
+				'format'     => '%d',
1619
+				'db-col'     => 'MTP_is_global'
1620
+			);
1621 1621
             
1622
-            $sidebar_form_fields['ee-msg-is-override'] = array(
1623
-                'name'       => 'MTP_is_override',
1624
-                'label'      => esc_html__('Override all custom', 'event_espresso'),
1625
-                'input'      => $message_template_group->is_global() ? 'checkbox' : 'hidden',
1626
-                'type'       => 'int',
1627
-                'required'   => false,
1628
-                'validation' => true,
1629
-                'value'      => $message_template_group->get('MTP_is_override'),
1630
-                'css_class'  => '',
1631
-                'format'     => '%d',
1632
-                'db-col'     => 'MTP_is_override'
1633
-            );
1622
+			$sidebar_form_fields['ee-msg-is-override'] = array(
1623
+				'name'       => 'MTP_is_override',
1624
+				'label'      => esc_html__('Override all custom', 'event_espresso'),
1625
+				'input'      => $message_template_group->is_global() ? 'checkbox' : 'hidden',
1626
+				'type'       => 'int',
1627
+				'required'   => false,
1628
+				'validation' => true,
1629
+				'value'      => $message_template_group->get('MTP_is_override'),
1630
+				'css_class'  => '',
1631
+				'format'     => '%d',
1632
+				'db-col'     => 'MTP_is_override'
1633
+			);
1634 1634
             
1635
-            $sidebar_form_fields['ee-msg-is-active'] = array(
1636
-                'name'       => 'MTP_is_active',
1637
-                'label'      => esc_html__('Active Template', 'event_espresso'),
1638
-                'input'      => 'hidden',
1639
-                'type'       => 'int',
1640
-                'required'   => false,
1641
-                'validation' => true,
1642
-                'value'      => $message_template_group->is_active(),
1643
-                'css_class'  => '',
1644
-                'format'     => '%d',
1645
-                'db-col'     => 'MTP_is_active'
1646
-            );
1635
+			$sidebar_form_fields['ee-msg-is-active'] = array(
1636
+				'name'       => 'MTP_is_active',
1637
+				'label'      => esc_html__('Active Template', 'event_espresso'),
1638
+				'input'      => 'hidden',
1639
+				'type'       => 'int',
1640
+				'required'   => false,
1641
+				'validation' => true,
1642
+				'value'      => $message_template_group->is_active(),
1643
+				'css_class'  => '',
1644
+				'format'     => '%d',
1645
+				'db-col'     => 'MTP_is_active'
1646
+			);
1647 1647
             
1648
-            $sidebar_form_fields['ee-msg-deleted'] = array(
1649
-                'name'       => 'MTP_deleted',
1650
-                'label'      => null,
1651
-                'input'      => 'hidden',
1652
-                'type'       => 'int',
1653
-                'required'   => false,
1654
-                'validation' => true,
1655
-                'value'      => $message_template_group->get('MTP_deleted'),
1656
-                'css_class'  => '',
1657
-                'format'     => '%d',
1658
-                'db-col'     => 'MTP_deleted'
1659
-            );
1660
-            $sidebar_form_fields['ee-msg-author']  = array(
1661
-                'name'       => 'MTP_user_id',
1662
-                'label'      => esc_html__('Author', 'event_espresso'),
1663
-                'input'      => 'hidden',
1664
-                'type'       => 'int',
1665
-                'required'   => false,
1666
-                'validation' => false,
1667
-                'value'      => $message_template_group->user(),
1668
-                'format'     => '%d',
1669
-                'db-col'     => 'MTP_user_id'
1670
-            );
1648
+			$sidebar_form_fields['ee-msg-deleted'] = array(
1649
+				'name'       => 'MTP_deleted',
1650
+				'label'      => null,
1651
+				'input'      => 'hidden',
1652
+				'type'       => 'int',
1653
+				'required'   => false,
1654
+				'validation' => true,
1655
+				'value'      => $message_template_group->get('MTP_deleted'),
1656
+				'css_class'  => '',
1657
+				'format'     => '%d',
1658
+				'db-col'     => 'MTP_deleted'
1659
+			);
1660
+			$sidebar_form_fields['ee-msg-author']  = array(
1661
+				'name'       => 'MTP_user_id',
1662
+				'label'      => esc_html__('Author', 'event_espresso'),
1663
+				'input'      => 'hidden',
1664
+				'type'       => 'int',
1665
+				'required'   => false,
1666
+				'validation' => false,
1667
+				'value'      => $message_template_group->user(),
1668
+				'format'     => '%d',
1669
+				'db-col'     => 'MTP_user_id'
1670
+			);
1671 1671
             
1672
-            $sidebar_form_fields['ee-msg-route'] = array(
1673
-                'name'  => 'action',
1674
-                'input' => 'hidden',
1675
-                'type'  => 'string',
1676
-                'value' => $action
1677
-            );
1672
+			$sidebar_form_fields['ee-msg-route'] = array(
1673
+				'name'  => 'action',
1674
+				'input' => 'hidden',
1675
+				'type'  => 'string',
1676
+				'value' => $action
1677
+			);
1678 1678
             
1679
-            $sidebar_form_fields['ee-msg-id']        = array(
1680
-                'name'  => 'id',
1681
-                'input' => 'hidden',
1682
-                'type'  => 'int',
1683
-                'value' => $GRP_ID
1684
-            );
1685
-            $sidebar_form_fields['ee-msg-evt-nonce'] = array(
1686
-                'name'  => $action . '_nonce',
1687
-                'input' => 'hidden',
1688
-                'type'  => 'string',
1689
-                'value' => wp_create_nonce($action . '_nonce')
1690
-            );
1679
+			$sidebar_form_fields['ee-msg-id']        = array(
1680
+				'name'  => 'id',
1681
+				'input' => 'hidden',
1682
+				'type'  => 'int',
1683
+				'value' => $GRP_ID
1684
+			);
1685
+			$sidebar_form_fields['ee-msg-evt-nonce'] = array(
1686
+				'name'  => $action . '_nonce',
1687
+				'input' => 'hidden',
1688
+				'type'  => 'string',
1689
+				'value' => wp_create_nonce($action . '_nonce')
1690
+			);
1691 1691
             
1692
-            if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
1693
-                $sidebar_form_fields['ee-msg-template-switch'] = array(
1694
-                    'name'  => 'template_switch',
1695
-                    'input' => 'hidden',
1696
-                    'type'  => 'int',
1697
-                    'value' => 1
1698
-                );
1699
-            }
1692
+			if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
1693
+				$sidebar_form_fields['ee-msg-template-switch'] = array(
1694
+					'name'  => 'template_switch',
1695
+					'input' => 'hidden',
1696
+					'type'  => 'int',
1697
+					'value' => 1
1698
+				);
1699
+			}
1700 1700
             
1701 1701
             
1702
-            $template_fields = $this->_generate_admin_form_fields($template_form_fields);
1703
-            $sidebar_fields  = $this->_generate_admin_form_fields($sidebar_form_fields);
1702
+			$template_fields = $this->_generate_admin_form_fields($template_form_fields);
1703
+			$sidebar_fields  = $this->_generate_admin_form_fields($sidebar_form_fields);
1704 1704
             
1705 1705
             
1706
-        } //end if ( !empty($template_field_structure) )
1707
-        
1708
-        //set extra content for publish box
1709
-        $this->_template_args['publish_box_extra_content'] = $sidebar_fields;
1710
-        $this->_set_publish_post_box_vars(
1711
-            'id',
1712
-            $GRP_ID,
1713
-            false,
1714
-            add_query_arg(
1715
-                array('action' => 'global_mtps'),
1716
-                $this->_admin_base_url
1717
-            )
1718
-        );
1719
-        
1720
-        //add preview button
1721
-        $preview_url    = parent::add_query_args_and_nonce(
1722
-            array(
1723
-                'message_type' => $message_template_group->message_type(),
1724
-                'messenger'    => $message_template_group->messenger(),
1725
-                'context'      => $context,
1726
-                'GRP_ID'       => $GRP_ID,
1727
-                'action'       => 'preview_message'
1728
-            ),
1729
-            $this->_admin_base_url
1730
-        );
1731
-        $preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">'
1732
-                          . esc_html__('Preview', 'event_espresso')
1733
-                          . '</a>';
1734
-        
1735
-        
1736
-        //setup context switcher
1737
-        $context_switcher_args = array(
1738
-            'page'    => 'espresso_messages',
1739
-            'action'  => 'edit_message_template',
1740
-            'id'      => $GRP_ID,
1741
-            'context' => $context,
1742
-            'extra'   => $preview_button
1743
-        );
1744
-        $this->_set_context_switcher($message_template_group, $context_switcher_args);
1745
-        
1746
-        
1747
-        //main box
1748
-        $this->_template_args['template_fields']                         = $template_fields;
1749
-        $this->_template_args['sidebar_box_id']                          = 'details';
1750
-        $this->_template_args['action']                                  = $action;
1751
-        $this->_template_args['context']                                 = $context;
1752
-        $this->_template_args['edit_message_template_form_url']          = $edit_message_template_form_url;
1753
-        $this->_template_args['learn_more_about_message_templates_link'] =
1754
-            $this->_learn_more_about_message_templates_link();
1755
-        
1756
-        
1757
-        $this->_template_args['before_admin_page_content'] = $this->add_context_switcher();
1758
-        $this->_template_args['before_admin_page_content'] .= $this->add_active_context_element(
1759
-            $message_template_group,
1760
-            $context,
1761
-            $context_label
1762
-        );
1763
-        $this->_template_args['before_admin_page_content'] .= $this->_add_form_element_before();
1764
-        $this->_template_args['after_admin_page_content'] = $this->_add_form_element_after();
1765
-        
1766
-        $this->_template_path = $this->_template_args['GRP_ID']
1767
-            ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1768
-            : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1769
-        
1770
-        //send along EE_Message_Template_Group object for further template use.
1771
-        $this->_template_args['MTP'] = $message_template_group;
1772
-        
1773
-        $this->_template_args['admin_page_content'] = EEH_Template::display_template(
1774
-            $this->_template_path,
1775
-            $this->_template_args,
1776
-            true
1777
-        );
1778
-        
1779
-        
1780
-        //finally, let's set the admin_page title
1781
-        $this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title);
1782
-        
1783
-        
1784
-        //we need to take care of setting the shortcodes property for use elsewhere.
1785
-        $this->_set_shortcodes();
1786
-        
1787
-        
1788
-        //final template wrapper
1789
-        $this->display_admin_page_with_sidebar();
1790
-    }
1706
+		} //end if ( !empty($template_field_structure) )
1707
+        
1708
+		//set extra content for publish box
1709
+		$this->_template_args['publish_box_extra_content'] = $sidebar_fields;
1710
+		$this->_set_publish_post_box_vars(
1711
+			'id',
1712
+			$GRP_ID,
1713
+			false,
1714
+			add_query_arg(
1715
+				array('action' => 'global_mtps'),
1716
+				$this->_admin_base_url
1717
+			)
1718
+		);
1719
+        
1720
+		//add preview button
1721
+		$preview_url    = parent::add_query_args_and_nonce(
1722
+			array(
1723
+				'message_type' => $message_template_group->message_type(),
1724
+				'messenger'    => $message_template_group->messenger(),
1725
+				'context'      => $context,
1726
+				'GRP_ID'       => $GRP_ID,
1727
+				'action'       => 'preview_message'
1728
+			),
1729
+			$this->_admin_base_url
1730
+		);
1731
+		$preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">'
1732
+						  . esc_html__('Preview', 'event_espresso')
1733
+						  . '</a>';
1734
+        
1735
+        
1736
+		//setup context switcher
1737
+		$context_switcher_args = array(
1738
+			'page'    => 'espresso_messages',
1739
+			'action'  => 'edit_message_template',
1740
+			'id'      => $GRP_ID,
1741
+			'context' => $context,
1742
+			'extra'   => $preview_button
1743
+		);
1744
+		$this->_set_context_switcher($message_template_group, $context_switcher_args);
1745
+        
1746
+        
1747
+		//main box
1748
+		$this->_template_args['template_fields']                         = $template_fields;
1749
+		$this->_template_args['sidebar_box_id']                          = 'details';
1750
+		$this->_template_args['action']                                  = $action;
1751
+		$this->_template_args['context']                                 = $context;
1752
+		$this->_template_args['edit_message_template_form_url']          = $edit_message_template_form_url;
1753
+		$this->_template_args['learn_more_about_message_templates_link'] =
1754
+			$this->_learn_more_about_message_templates_link();
1755
+        
1756
+        
1757
+		$this->_template_args['before_admin_page_content'] = $this->add_context_switcher();
1758
+		$this->_template_args['before_admin_page_content'] .= $this->add_active_context_element(
1759
+			$message_template_group,
1760
+			$context,
1761
+			$context_label
1762
+		);
1763
+		$this->_template_args['before_admin_page_content'] .= $this->_add_form_element_before();
1764
+		$this->_template_args['after_admin_page_content'] = $this->_add_form_element_after();
1765
+        
1766
+		$this->_template_path = $this->_template_args['GRP_ID']
1767
+			? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1768
+			: EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1769
+        
1770
+		//send along EE_Message_Template_Group object for further template use.
1771
+		$this->_template_args['MTP'] = $message_template_group;
1772
+        
1773
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
1774
+			$this->_template_path,
1775
+			$this->_template_args,
1776
+			true
1777
+		);
1778
+        
1779
+        
1780
+		//finally, let's set the admin_page title
1781
+		$this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title);
1782
+        
1783
+        
1784
+		//we need to take care of setting the shortcodes property for use elsewhere.
1785
+		$this->_set_shortcodes();
1786
+        
1787
+        
1788
+		//final template wrapper
1789
+		$this->display_admin_page_with_sidebar();
1790
+	}
1791 1791
     
1792 1792
     
1793
-    public function filter_tinymce_init($mceInit, $editor_id)
1794
-    {
1795
-        return $mceInit;
1796
-    }
1793
+	public function filter_tinymce_init($mceInit, $editor_id)
1794
+	{
1795
+		return $mceInit;
1796
+	}
1797 1797
     
1798 1798
     
1799
-    public function add_context_switcher()
1800
-    {
1801
-        return $this->_context_switcher;
1802
-    }
1799
+	public function add_context_switcher()
1800
+	{
1801
+		return $this->_context_switcher;
1802
+	}
1803 1803
 
1804 1804
 
1805
-    /**
1806
-     * Adds the activation/deactivation toggle for the message template context.
1807
-     *
1808
-     * @param EE_Message_Template_Group $message_template_group
1809
-     * @param string                    $context
1810
-     * @param string                    $context_label
1811
-     * @return string
1812
-     * @throws DomainException
1813
-     * @throws EE_Error
1814
-     * @throws InvalidIdentifierException
1815
-     */
1816
-    protected function add_active_context_element(
1817
-        EE_Message_Template_Group $message_template_group,
1818
-        $context,
1819
-        $context_label
1820
-    ) {
1821
-        $template_args = array(
1822
-            'context' => $context,
1823
-            'nonce' => wp_create_nonce('activate_' . $context . '_toggle_nonce'),
1824
-            'is_active' => $message_template_group->is_context_active($context),
1825
-            'on_off_action' => $message_template_group->is_context_active($context)
1826
-                ? 'context-off'
1827
-                : 'context-on',
1828
-            'context_label' => str_replace(array('(', ')'), '', $context_label),
1829
-            'message_template_group_id' => $message_template_group->ID()
1830
-        );
1831
-        return EEH_Template::display_template(
1832
-          EE_MSG_TEMPLATE_PATH . 'ee_msg_editor_active_context_element.template.php',
1833
-          $template_args,
1834
-          true
1835
-        );
1836
-    }
1805
+	/**
1806
+	 * Adds the activation/deactivation toggle for the message template context.
1807
+	 *
1808
+	 * @param EE_Message_Template_Group $message_template_group
1809
+	 * @param string                    $context
1810
+	 * @param string                    $context_label
1811
+	 * @return string
1812
+	 * @throws DomainException
1813
+	 * @throws EE_Error
1814
+	 * @throws InvalidIdentifierException
1815
+	 */
1816
+	protected function add_active_context_element(
1817
+		EE_Message_Template_Group $message_template_group,
1818
+		$context,
1819
+		$context_label
1820
+	) {
1821
+		$template_args = array(
1822
+			'context' => $context,
1823
+			'nonce' => wp_create_nonce('activate_' . $context . '_toggle_nonce'),
1824
+			'is_active' => $message_template_group->is_context_active($context),
1825
+			'on_off_action' => $message_template_group->is_context_active($context)
1826
+				? 'context-off'
1827
+				: 'context-on',
1828
+			'context_label' => str_replace(array('(', ')'), '', $context_label),
1829
+			'message_template_group_id' => $message_template_group->ID()
1830
+		);
1831
+		return EEH_Template::display_template(
1832
+		  EE_MSG_TEMPLATE_PATH . 'ee_msg_editor_active_context_element.template.php',
1833
+		  $template_args,
1834
+		  true
1835
+		);
1836
+	}
1837 1837
 
1838 1838
 
1839
-    /**
1840
-     * Ajax callback for `toggle_context_template` ajax action.
1841
-     * Handles toggling the message context on or off.
1842
-     * @throws EE_Error
1843
-     * @throws InvalidArgumentException
1844
-     * @throws InvalidDataTypeException
1845
-     * @throws InvalidIdentifierException
1846
-     * @throws InvalidInterfaceException
1847
-     */
1848
-    public function toggle_context_template()
1849
-    {
1850
-        $success = true;
1851
-        //check for required data
1852
-        if (!isset(
1853
-            $this->_req_data['message_template_group_id'],
1854
-            $this->_req_data['context'],
1855
-            $this->_req_data['status']
1856
-        )) {
1857
-            EE_Error::add_error(
1858
-                esc_html__('Required data for doing this action is not available.', 'event_espresso'),
1859
-                __FILE__,
1860
-                __FUNCTION__,
1861
-                __LINE__
1862
-            );
1863
-            $success = false;
1864
-        }
1839
+	/**
1840
+	 * Ajax callback for `toggle_context_template` ajax action.
1841
+	 * Handles toggling the message context on or off.
1842
+	 * @throws EE_Error
1843
+	 * @throws InvalidArgumentException
1844
+	 * @throws InvalidDataTypeException
1845
+	 * @throws InvalidIdentifierException
1846
+	 * @throws InvalidInterfaceException
1847
+	 */
1848
+	public function toggle_context_template()
1849
+	{
1850
+		$success = true;
1851
+		//check for required data
1852
+		if (!isset(
1853
+			$this->_req_data['message_template_group_id'],
1854
+			$this->_req_data['context'],
1855
+			$this->_req_data['status']
1856
+		)) {
1857
+			EE_Error::add_error(
1858
+				esc_html__('Required data for doing this action is not available.', 'event_espresso'),
1859
+				__FILE__,
1860
+				__FUNCTION__,
1861
+				__LINE__
1862
+			);
1863
+			$success = false;
1864
+		}
1865 1865
 
1866
-        $nonce = isset($this->_req_data['toggle_context_nonce'])
1867
-            ? sanitize_text_field($this->_req_data['toggle_context_nonce'])
1868
-            : '';
1869
-        $nonce_ref = 'activate_' . $this->_req_data['context'] . '_toggle_nonce';
1870
-        $this->_verify_nonce($nonce, $nonce_ref);
1871
-        $status = $this->_req_data['status'];
1872
-        if ($status !== 'off' && $status !=='on') {
1873
-            EE_Error::add_error(
1874
-                sprintf(
1875
-                    esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
1876
-                    $this->_req_data['status']
1877
-                ),
1878
-                __FILE__,
1879
-                __FUNCTION__,
1880
-                __LINE__
1881
-            );
1882
-            $success = false;
1883
-        }
1884
-        $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID(
1885
-            $this->_req_data['message_template_group_id']
1886
-        );
1887
-        if (! $message_template_group instanceof EE_Message_Template_Group) {
1888
-            EE_Error::add_error(
1889
-                sprintf(
1890
-                    esc_html__(
1891
-                        'Unable to change the active state because the given id "%1$d" does not match a valid "%2$s"',
1892
-                        'event_espresso'
1893
-                    ),
1894
-                    $this->_req_data['message_template_group_id'],
1895
-                    'EE_Message_Template_Group'
1896
-                ),
1897
-                __FILE__,
1898
-                __FUNCTION__,
1899
-                __LINE__
1900
-            );
1901
-            $success = false;
1902
-        }
1903
-        if ($success) {
1904
-            $success = $status === 'off'
1905
-                ? $message_template_group->deactivate_context($this->_req_data['context'])
1906
-                : $message_template_group->activate_context($this->_req_data['context']);
1907
-        }
1908
-        $this->_template_args['success'] = $success;
1909
-        $this->_return_json();
1910
-    }
1866
+		$nonce = isset($this->_req_data['toggle_context_nonce'])
1867
+			? sanitize_text_field($this->_req_data['toggle_context_nonce'])
1868
+			: '';
1869
+		$nonce_ref = 'activate_' . $this->_req_data['context'] . '_toggle_nonce';
1870
+		$this->_verify_nonce($nonce, $nonce_ref);
1871
+		$status = $this->_req_data['status'];
1872
+		if ($status !== 'off' && $status !=='on') {
1873
+			EE_Error::add_error(
1874
+				sprintf(
1875
+					esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
1876
+					$this->_req_data['status']
1877
+				),
1878
+				__FILE__,
1879
+				__FUNCTION__,
1880
+				__LINE__
1881
+			);
1882
+			$success = false;
1883
+		}
1884
+		$message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID(
1885
+			$this->_req_data['message_template_group_id']
1886
+		);
1887
+		if (! $message_template_group instanceof EE_Message_Template_Group) {
1888
+			EE_Error::add_error(
1889
+				sprintf(
1890
+					esc_html__(
1891
+						'Unable to change the active state because the given id "%1$d" does not match a valid "%2$s"',
1892
+						'event_espresso'
1893
+					),
1894
+					$this->_req_data['message_template_group_id'],
1895
+					'EE_Message_Template_Group'
1896
+				),
1897
+				__FILE__,
1898
+				__FUNCTION__,
1899
+				__LINE__
1900
+			);
1901
+			$success = false;
1902
+		}
1903
+		if ($success) {
1904
+			$success = $status === 'off'
1905
+				? $message_template_group->deactivate_context($this->_req_data['context'])
1906
+				: $message_template_group->activate_context($this->_req_data['context']);
1907
+		}
1908
+		$this->_template_args['success'] = $success;
1909
+		$this->_return_json();
1910
+	}
1911 1911
 
1912 1912
 
1913 1913
     
1914
-    public function _add_form_element_before()
1915
-    {
1916
-        return '<form method="post" action="'
1917
-               . $this->_template_args["edit_message_template_form_url"]
1918
-               . '" id="ee-msg-edit-frm">';
1919
-    }
1914
+	public function _add_form_element_before()
1915
+	{
1916
+		return '<form method="post" action="'
1917
+			   . $this->_template_args["edit_message_template_form_url"]
1918
+			   . '" id="ee-msg-edit-frm">';
1919
+	}
1920 1920
     
1921
-    public function _add_form_element_after()
1922
-    {
1923
-        return '</form>';
1924
-    }
1921
+	public function _add_form_element_after()
1922
+	{
1923
+		return '</form>';
1924
+	}
1925 1925
 
1926 1926
 
1927
-    /**
1928
-     * This executes switching the template pack for a message template.
1929
-     *
1930
-     * @since 4.5.0
1931
-     * @throws EE_Error
1932
-     * @throws InvalidDataTypeException
1933
-     * @throws InvalidInterfaceException
1934
-     * @throws InvalidArgumentException
1935
-     * @throws ReflectionException
1936
-     */
1937
-    public function switch_template_pack()
1938
-    {
1939
-        $GRP_ID        = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1940
-        $template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : '';
1941
-        
1942
-        //verify we have needed values.
1943
-        if (empty($GRP_ID) || empty($template_pack)) {
1944
-            $this->_template_args['error'] = true;
1945
-            EE_Error::add_error(
1946
-                esc_html__('The required date for switching templates is not available.', 'event_espresso'),
1947
-                __FILE__,
1948
-                __FUNCTION__,
1949
-                __LINE__
1950
-            );
1951
-        } else {
1952
-            //get template, set the new template_pack and then reset to default
1953
-            /** @type EE_Message_Template_Group $message_template_group */
1954
-            $message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1927
+	/**
1928
+	 * This executes switching the template pack for a message template.
1929
+	 *
1930
+	 * @since 4.5.0
1931
+	 * @throws EE_Error
1932
+	 * @throws InvalidDataTypeException
1933
+	 * @throws InvalidInterfaceException
1934
+	 * @throws InvalidArgumentException
1935
+	 * @throws ReflectionException
1936
+	 */
1937
+	public function switch_template_pack()
1938
+	{
1939
+		$GRP_ID        = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1940
+		$template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : '';
1941
+        
1942
+		//verify we have needed values.
1943
+		if (empty($GRP_ID) || empty($template_pack)) {
1944
+			$this->_template_args['error'] = true;
1945
+			EE_Error::add_error(
1946
+				esc_html__('The required date for switching templates is not available.', 'event_espresso'),
1947
+				__FILE__,
1948
+				__FUNCTION__,
1949
+				__LINE__
1950
+			);
1951
+		} else {
1952
+			//get template, set the new template_pack and then reset to default
1953
+			/** @type EE_Message_Template_Group $message_template_group */
1954
+			$message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1955 1955
             
1956
-            $message_template_group->set_template_pack_name($template_pack);
1957
-            $this->_req_data['msgr'] = $message_template_group->messenger();
1958
-            $this->_req_data['mt']   = $message_template_group->message_type();
1956
+			$message_template_group->set_template_pack_name($template_pack);
1957
+			$this->_req_data['msgr'] = $message_template_group->messenger();
1958
+			$this->_req_data['mt']   = $message_template_group->message_type();
1959 1959
             
1960
-            $query_args = $this->_reset_to_default_template();
1960
+			$query_args = $this->_reset_to_default_template();
1961 1961
             
1962
-            if (empty($query_args['id'])) {
1963
-                EE_Error::add_error(
1964
-                    esc_html__(
1965
-                        'Something went wrong with switching the template pack. Please try again or contact EE support',
1966
-                        'event_espresso'
1967
-                    ),
1968
-                    __FILE__,
1969
-                    __FUNCTION__,
1970
-                    __LINE__
1971
-                );
1972
-                $this->_template_args['error'] = true;
1973
-            } else {
1974
-                $template_label       = $message_template_group->get_template_pack()->label;
1975
-                $template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels();
1976
-                EE_Error::add_success(
1977
-                    sprintf(
1978
-                        esc_html__(
1979
-                            'This message template has been successfully switched to use the %1$s %2$s.  Please wait while the page reloads with your new template.',
1980
-                            'event_espresso'
1981
-                        ),
1982
-                        $template_label,
1983
-                        $template_pack_labels->template_pack
1984
-                    )
1985
-                );
1986
-                //generate the redirect url for js.
1987
-                $url                                          = self::add_query_args_and_nonce($query_args,
1988
-                    $this->_admin_base_url);
1989
-                $this->_template_args['data']['redirect_url'] = $url;
1990
-                $this->_template_args['success']              = true;
1991
-            }
1962
+			if (empty($query_args['id'])) {
1963
+				EE_Error::add_error(
1964
+					esc_html__(
1965
+						'Something went wrong with switching the template pack. Please try again or contact EE support',
1966
+						'event_espresso'
1967
+					),
1968
+					__FILE__,
1969
+					__FUNCTION__,
1970
+					__LINE__
1971
+				);
1972
+				$this->_template_args['error'] = true;
1973
+			} else {
1974
+				$template_label       = $message_template_group->get_template_pack()->label;
1975
+				$template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels();
1976
+				EE_Error::add_success(
1977
+					sprintf(
1978
+						esc_html__(
1979
+							'This message template has been successfully switched to use the %1$s %2$s.  Please wait while the page reloads with your new template.',
1980
+							'event_espresso'
1981
+						),
1982
+						$template_label,
1983
+						$template_pack_labels->template_pack
1984
+					)
1985
+				);
1986
+				//generate the redirect url for js.
1987
+				$url                                          = self::add_query_args_and_nonce($query_args,
1988
+					$this->_admin_base_url);
1989
+				$this->_template_args['data']['redirect_url'] = $url;
1990
+				$this->_template_args['success']              = true;
1991
+			}
1992 1992
             
1993
-            $this->_return_json();
1993
+			$this->_return_json();
1994 1994
             
1995
-        }
1996
-    }
1995
+		}
1996
+	}
1997 1997
 
1998 1998
 
1999
-    /**
2000
-     * This handles resetting the template for the given messenger/message_type so that users can start from scratch if
2001
-     * they want.
2002
-     *
2003
-     * @access protected
2004
-     * @return array|null
2005
-     * @throws EE_Error
2006
-     * @throws InvalidArgumentException
2007
-     * @throws InvalidDataTypeException
2008
-     * @throws InvalidInterfaceException
2009
-     */
2010
-    protected function _reset_to_default_template()
2011
-    {
2012
-        
2013
-        $templates = array();
2014
-        $GRP_ID    = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
2015
-        //we need to make sure we've got the info we need.
2016
-        if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) {
2017
-            EE_Error::add_error(
2018
-                esc_html__(
2019
-                    '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.',
2020
-                    'event_espresso'
2021
-                ),
2022
-                __FILE__, __FUNCTION__, __LINE__
2023
-            );
2024
-        }
2025
-        
2026
-        // all templates will be reset to whatever the defaults are
2027
-        // for the global template matching the messenger and message type.
2028
-        $success = ! empty($GRP_ID) ? true : false;
2029
-        
2030
-        if ($success) {
1999
+	/**
2000
+	 * This handles resetting the template for the given messenger/message_type so that users can start from scratch if
2001
+	 * they want.
2002
+	 *
2003
+	 * @access protected
2004
+	 * @return array|null
2005
+	 * @throws EE_Error
2006
+	 * @throws InvalidArgumentException
2007
+	 * @throws InvalidDataTypeException
2008
+	 * @throws InvalidInterfaceException
2009
+	 */
2010
+	protected function _reset_to_default_template()
2011
+	{
2012
+        
2013
+		$templates = array();
2014
+		$GRP_ID    = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
2015
+		//we need to make sure we've got the info we need.
2016
+		if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) {
2017
+			EE_Error::add_error(
2018
+				esc_html__(
2019
+					'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.',
2020
+					'event_espresso'
2021
+				),
2022
+				__FILE__, __FUNCTION__, __LINE__
2023
+			);
2024
+		}
2025
+        
2026
+		// all templates will be reset to whatever the defaults are
2027
+		// for the global template matching the messenger and message type.
2028
+		$success = ! empty($GRP_ID) ? true : false;
2029
+        
2030
+		if ($success) {
2031 2031
             
2032
-            //let's first determine if the incoming template is a global template,
2033
-            // if it isn't then we need to get the global template matching messenger and message type.
2034
-            //$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
2032
+			//let's first determine if the incoming template is a global template,
2033
+			// if it isn't then we need to get the global template matching messenger and message type.
2034
+			//$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
2035 2035
             
2036 2036
             
2037
-            //note this is ONLY deleting the template fields (Message Template rows) NOT the message template group.
2038
-            $success = $this->_delete_mtp_permanently($GRP_ID, false);
2037
+			//note this is ONLY deleting the template fields (Message Template rows) NOT the message template group.
2038
+			$success = $this->_delete_mtp_permanently($GRP_ID, false);
2039 2039
             
2040
-            if ($success) {
2041
-                // if successfully deleted, lets generate the new ones.
2042
-                // Note. We set GLOBAL to true, because resets on ANY template
2043
-                // will use the related global template defaults for regeneration.
2044
-                // This means that if a custom template is reset it resets to whatever the related global template is.
2045
-                // HOWEVER, we DO keep the template pack and template variation set
2046
-                // for the current custom template when resetting.
2047
-                $templates = $this->_generate_new_templates(
2048
-                    $this->_req_data['msgr'],
2049
-                    $this->_req_data['mt'],
2050
-                    $GRP_ID,
2051
-                    true
2052
-                );
2053
-            }
2040
+			if ($success) {
2041
+				// if successfully deleted, lets generate the new ones.
2042
+				// Note. We set GLOBAL to true, because resets on ANY template
2043
+				// will use the related global template defaults for regeneration.
2044
+				// This means that if a custom template is reset it resets to whatever the related global template is.
2045
+				// HOWEVER, we DO keep the template pack and template variation set
2046
+				// for the current custom template when resetting.
2047
+				$templates = $this->_generate_new_templates(
2048
+					$this->_req_data['msgr'],
2049
+					$this->_req_data['mt'],
2050
+					$GRP_ID,
2051
+					true
2052
+				);
2053
+			}
2054 2054
             
2055
-        }
2056
-        
2057
-        //any error messages?
2058
-        if ( ! $success) {
2059
-            EE_Error::add_error(
2060
-                esc_html__('Something went wrong with deleting existing templates. Unable to reset to default',
2061
-                    'event_espresso'),
2062
-                __FILE__, __FUNCTION__, __LINE__
2063
-            );
2064
-        }
2065
-        
2066
-        //all good, let's add a success message!
2067
-        if ($success && ! empty($templates)) {
2068
-            //the info for the template we generated is the first element in the returned array
2069
-            // $templates = $templates[0];
2070
-            EE_Error::overwrite_success();
2071
-            EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso'));
2072
-        }
2073
-        
2074
-        
2075
-        $query_args = array(
2076
-            'id'      => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null,
2077
-            'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null,
2078
-            'action'  => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps'
2079
-        );
2080
-        
2081
-        //if called via ajax then we return query args otherwise redirect
2082
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2083
-            return $query_args;
2084
-        } else {
2085
-            $this->_redirect_after_action(false, '', '', $query_args, true);
2055
+		}
2056
+        
2057
+		//any error messages?
2058
+		if ( ! $success) {
2059
+			EE_Error::add_error(
2060
+				esc_html__('Something went wrong with deleting existing templates. Unable to reset to default',
2061
+					'event_espresso'),
2062
+				__FILE__, __FUNCTION__, __LINE__
2063
+			);
2064
+		}
2065
+        
2066
+		//all good, let's add a success message!
2067
+		if ($success && ! empty($templates)) {
2068
+			//the info for the template we generated is the first element in the returned array
2069
+			// $templates = $templates[0];
2070
+			EE_Error::overwrite_success();
2071
+			EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso'));
2072
+		}
2073
+        
2074
+        
2075
+		$query_args = array(
2076
+			'id'      => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null,
2077
+			'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null,
2078
+			'action'  => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps'
2079
+		);
2080
+        
2081
+		//if called via ajax then we return query args otherwise redirect
2082
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2083
+			return $query_args;
2084
+		} else {
2085
+			$this->_redirect_after_action(false, '', '', $query_args, true);
2086 2086
 
2087
-            return null;
2088
-        }
2089
-    }
2087
+			return null;
2088
+		}
2089
+	}
2090 2090
 
2091 2091
 
2092
-    /**
2093
-     * Retrieve and set the message preview for display.
2094
-     *
2095
-     * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
2096
-     * @return string
2097
-     * @throws EE_Error
2098
-     * @throws InvalidArgumentException
2099
-     * @throws InvalidDataTypeException
2100
-     * @throws InvalidInterfaceException
2101
-     */
2102
-    public function _preview_message($send = false)
2103
-    {
2104
-        //first make sure we've got the necessary parameters
2105
-        if (
2106
-        ! isset(
2107
-            $this->_req_data['message_type'],
2108
-            $this->_req_data['messenger'],
2109
-            $this->_req_data['messenger'],
2110
-            $this->_req_data['GRP_ID']
2111
-        )
2112
-        ) {
2113
-            EE_Error::add_error(
2114
-                esc_html__('Missing necessary parameters for displaying preview', 'event_espresso'),
2115
-                __FILE__, __FUNCTION__, __LINE__
2116
-            );
2117
-        }
2118
-        
2119
-        EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']);
2120
-        
2121
-        
2122
-        //get the preview!
2123
-        $preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'],
2124
-            $this->_req_data['messenger'], $send);
2125
-        
2126
-        if ($send) {
2127
-            return $preview;
2128
-        }
2129
-        
2130
-        //let's add a button to go back to the edit view
2131
-        $query_args             = array(
2132
-            'id'      => $this->_req_data['GRP_ID'],
2133
-            'context' => $this->_req_data['context'],
2134
-            'action'  => 'edit_message_template'
2135
-        );
2136
-        $go_back_url            = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2137
-        $preview_button         = '<a href="'
2138
-                                  . $go_back_url
2139
-                                  . '" class="button-secondary messages-preview-go-back-button">'
2140
-                                  . esc_html__('Go Back to Edit', 'event_espresso')
2141
-                                  . '</a>';
2142
-        $message_types          = $this->get_installed_message_types();
2143
-        $active_messenger       = $this->_message_resource_manager->get_active_messenger(
2144
-                $this->_req_data['messenger']
2145
-        );
2146
-        $active_messenger_label = $active_messenger instanceof EE_messenger
2147
-            ? ucwords($active_messenger->label['singular'])
2148
-            : esc_html__('Unknown Messenger', 'event_espresso');
2149
-        //let's provide a helpful title for context
2150
-        $preview_title = sprintf(
2151
-            esc_html__('Viewing Preview for %s %s Message Template', 'event_espresso'),
2152
-            $active_messenger_label,
2153
-            ucwords($message_types[$this->_req_data['message_type']]->label['singular'])
2154
-        );
2155
-        //setup display of preview.
2156
-        $this->_admin_page_title                    = $preview_title;
2157
-        $this->_template_args['admin_page_content'] = $preview_button . '<br />' . stripslashes($preview);
2158
-        $this->_template_args['data']['force_json'] = true;
2159
-        
2160
-        return '';
2161
-    }
2092
+	/**
2093
+	 * Retrieve and set the message preview for display.
2094
+	 *
2095
+	 * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
2096
+	 * @return string
2097
+	 * @throws EE_Error
2098
+	 * @throws InvalidArgumentException
2099
+	 * @throws InvalidDataTypeException
2100
+	 * @throws InvalidInterfaceException
2101
+	 */
2102
+	public function _preview_message($send = false)
2103
+	{
2104
+		//first make sure we've got the necessary parameters
2105
+		if (
2106
+		! isset(
2107
+			$this->_req_data['message_type'],
2108
+			$this->_req_data['messenger'],
2109
+			$this->_req_data['messenger'],
2110
+			$this->_req_data['GRP_ID']
2111
+		)
2112
+		) {
2113
+			EE_Error::add_error(
2114
+				esc_html__('Missing necessary parameters for displaying preview', 'event_espresso'),
2115
+				__FILE__, __FUNCTION__, __LINE__
2116
+			);
2117
+		}
2118
+        
2119
+		EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']);
2120
+        
2121
+        
2122
+		//get the preview!
2123
+		$preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'],
2124
+			$this->_req_data['messenger'], $send);
2125
+        
2126
+		if ($send) {
2127
+			return $preview;
2128
+		}
2129
+        
2130
+		//let's add a button to go back to the edit view
2131
+		$query_args             = array(
2132
+			'id'      => $this->_req_data['GRP_ID'],
2133
+			'context' => $this->_req_data['context'],
2134
+			'action'  => 'edit_message_template'
2135
+		);
2136
+		$go_back_url            = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
2137
+		$preview_button         = '<a href="'
2138
+								  . $go_back_url
2139
+								  . '" class="button-secondary messages-preview-go-back-button">'
2140
+								  . esc_html__('Go Back to Edit', 'event_espresso')
2141
+								  . '</a>';
2142
+		$message_types          = $this->get_installed_message_types();
2143
+		$active_messenger       = $this->_message_resource_manager->get_active_messenger(
2144
+				$this->_req_data['messenger']
2145
+		);
2146
+		$active_messenger_label = $active_messenger instanceof EE_messenger
2147
+			? ucwords($active_messenger->label['singular'])
2148
+			: esc_html__('Unknown Messenger', 'event_espresso');
2149
+		//let's provide a helpful title for context
2150
+		$preview_title = sprintf(
2151
+			esc_html__('Viewing Preview for %s %s Message Template', 'event_espresso'),
2152
+			$active_messenger_label,
2153
+			ucwords($message_types[$this->_req_data['message_type']]->label['singular'])
2154
+		);
2155
+		//setup display of preview.
2156
+		$this->_admin_page_title                    = $preview_title;
2157
+		$this->_template_args['admin_page_content'] = $preview_button . '<br />' . stripslashes($preview);
2158
+		$this->_template_args['data']['force_json'] = true;
2159
+        
2160
+		return '';
2161
+	}
2162 2162
     
2163 2163
     
2164
-    /**
2165
-     * The initial _preview_message is on a no headers route.  It will optionally call this if necessary otherwise it
2166
-     * gets called automatically.
2167
-     *
2168
-     * @since 4.5.0
2169
-     *
2170
-     * @return string
2171
-     */
2172
-    protected function _display_preview_message()
2173
-    {
2174
-        $this->display_admin_page_with_no_sidebar();
2175
-    }
2164
+	/**
2165
+	 * The initial _preview_message is on a no headers route.  It will optionally call this if necessary otherwise it
2166
+	 * gets called automatically.
2167
+	 *
2168
+	 * @since 4.5.0
2169
+	 *
2170
+	 * @return string
2171
+	 */
2172
+	protected function _display_preview_message()
2173
+	{
2174
+		$this->display_admin_page_with_no_sidebar();
2175
+	}
2176 2176
     
2177 2177
     
2178
-    /**
2179
-     * registers metaboxes that should show up on the "edit_message_template" page
2180
-     *
2181
-     * @access protected
2182
-     * @return void
2183
-     */
2184
-    protected function _register_edit_meta_boxes()
2185
-    {
2186
-        add_meta_box(
2187
-            'mtp_valid_shortcodes',
2188
-            esc_html__('Valid Shortcodes', 'event_espresso'),
2189
-            array($this, 'shortcode_meta_box'),
2190
-            $this->_current_screen->id,
2191
-            'side',
2192
-            'default');
2193
-        add_meta_box(
2194
-            'mtp_extra_actions',
2195
-            esc_html__('Extra Actions', 'event_espresso'),
2196
-            array($this, 'extra_actions_meta_box'),
2197
-            $this->_current_screen->id,
2198
-            'side',
2199
-            'high'
2200
-        );
2201
-        add_meta_box(
2202
-            'mtp_templates',
2203
-            esc_html__('Template Styles', 'event_espresso'),
2204
-            array($this, 'template_pack_meta_box'),
2205
-            $this->_current_screen->id,
2206
-            'side',
2207
-            'high'
2208
-        );
2209
-    }
2178
+	/**
2179
+	 * registers metaboxes that should show up on the "edit_message_template" page
2180
+	 *
2181
+	 * @access protected
2182
+	 * @return void
2183
+	 */
2184
+	protected function _register_edit_meta_boxes()
2185
+	{
2186
+		add_meta_box(
2187
+			'mtp_valid_shortcodes',
2188
+			esc_html__('Valid Shortcodes', 'event_espresso'),
2189
+			array($this, 'shortcode_meta_box'),
2190
+			$this->_current_screen->id,
2191
+			'side',
2192
+			'default');
2193
+		add_meta_box(
2194
+			'mtp_extra_actions',
2195
+			esc_html__('Extra Actions', 'event_espresso'),
2196
+			array($this, 'extra_actions_meta_box'),
2197
+			$this->_current_screen->id,
2198
+			'side',
2199
+			'high'
2200
+		);
2201
+		add_meta_box(
2202
+			'mtp_templates',
2203
+			esc_html__('Template Styles', 'event_espresso'),
2204
+			array($this, 'template_pack_meta_box'),
2205
+			$this->_current_screen->id,
2206
+			'side',
2207
+			'high'
2208
+		);
2209
+	}
2210 2210
 
2211 2211
 
2212
-    /**
2213
-     * metabox content for all template pack and variation selection.
2214
-     *
2215
-     * @since 4.5.0
2216
-     * @return string
2217
-     * @throws DomainException
2218
-     * @throws EE_Error
2219
-     * @throws InvalidArgumentException
2220
-     * @throws ReflectionException
2221
-     * @throws InvalidDataTypeException
2222
-     * @throws InvalidInterfaceException
2223
-     */
2224
-    public function template_pack_meta_box()
2225
-    {
2226
-        $this->_set_message_template_group();
2227
-        
2228
-        $tp_collection = EEH_MSG_Template::get_template_pack_collection();
2229
-        
2230
-        $tp_select_values = array();
2231
-        
2232
-        foreach ($tp_collection as $tp) {
2233
-            //only include template packs that support this messenger and message type!
2234
-            $supports = $tp->get_supports();
2235
-            if (
2236
-                ! isset($supports[$this->_message_template_group->messenger()])
2237
-                || ! in_array(
2238
-                    $this->_message_template_group->message_type(),
2239
-                    $supports[$this->_message_template_group->messenger()],
2240
-                    true
2241
-                )
2242
-            ) {
2243
-                //not supported
2244
-                continue;
2245
-            }
2212
+	/**
2213
+	 * metabox content for all template pack and variation selection.
2214
+	 *
2215
+	 * @since 4.5.0
2216
+	 * @return string
2217
+	 * @throws DomainException
2218
+	 * @throws EE_Error
2219
+	 * @throws InvalidArgumentException
2220
+	 * @throws ReflectionException
2221
+	 * @throws InvalidDataTypeException
2222
+	 * @throws InvalidInterfaceException
2223
+	 */
2224
+	public function template_pack_meta_box()
2225
+	{
2226
+		$this->_set_message_template_group();
2227
+        
2228
+		$tp_collection = EEH_MSG_Template::get_template_pack_collection();
2229
+        
2230
+		$tp_select_values = array();
2231
+        
2232
+		foreach ($tp_collection as $tp) {
2233
+			//only include template packs that support this messenger and message type!
2234
+			$supports = $tp->get_supports();
2235
+			if (
2236
+				! isset($supports[$this->_message_template_group->messenger()])
2237
+				|| ! in_array(
2238
+					$this->_message_template_group->message_type(),
2239
+					$supports[$this->_message_template_group->messenger()],
2240
+					true
2241
+				)
2242
+			) {
2243
+				//not supported
2244
+				continue;
2245
+			}
2246 2246
             
2247
-            $tp_select_values[] = array(
2248
-                'text' => $tp->label,
2249
-                'id'   => $tp->dbref
2250
-            );
2251
-        }
2252
-        
2253
-        //if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by
2254
-        // the default template pack.  This still allows for the odd template pack to override.
2255
-        if (empty($tp_select_values)) {
2256
-            $tp_select_values[] = array(
2257
-                'text' => esc_html__('Default', 'event_espresso'),
2258
-                'id'   => 'default'
2259
-            );
2260
-        }
2261
-        
2262
-        //setup variation select values for the currently selected template.
2263
-        $variations               = $this->_message_template_group->get_template_pack()->get_variations(
2264
-            $this->_message_template_group->messenger(),
2265
-            $this->_message_template_group->message_type()
2266
-        );
2267
-        $variations_select_values = array();
2268
-        foreach ($variations as $variation => $label) {
2269
-            $variations_select_values[] = array(
2270
-                'text' => $label,
2271
-                'id'   => $variation
2272
-            );
2273
-        }
2274
-        
2275
-        $template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
2276
-        
2277
-        $template_args['template_packs_selector']        = EEH_Form_Fields::select_input(
2278
-            'MTP_template_pack',
2279
-            $tp_select_values,
2280
-            $this->_message_template_group->get_template_pack_name()
2281
-        );
2282
-        $template_args['variations_selector']            = EEH_Form_Fields::select_input(
2283
-            'MTP_template_variation',
2284
-            $variations_select_values,
2285
-            $this->_message_template_group->get_template_pack_variation()
2286
-        );
2287
-        $template_args['template_pack_label']            = $template_pack_labels->template_pack;
2288
-        $template_args['template_variation_label']       = $template_pack_labels->template_variation;
2289
-        $template_args['template_pack_description']      = $template_pack_labels->template_pack_description;
2290
-        $template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
2291
-        
2292
-        $template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
2293
-        
2294
-        EEH_Template::display_template($template, $template_args);
2295
-    }
2247
+			$tp_select_values[] = array(
2248
+				'text' => $tp->label,
2249
+				'id'   => $tp->dbref
2250
+			);
2251
+		}
2252
+        
2253
+		//if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by
2254
+		// the default template pack.  This still allows for the odd template pack to override.
2255
+		if (empty($tp_select_values)) {
2256
+			$tp_select_values[] = array(
2257
+				'text' => esc_html__('Default', 'event_espresso'),
2258
+				'id'   => 'default'
2259
+			);
2260
+		}
2261
+        
2262
+		//setup variation select values for the currently selected template.
2263
+		$variations               = $this->_message_template_group->get_template_pack()->get_variations(
2264
+			$this->_message_template_group->messenger(),
2265
+			$this->_message_template_group->message_type()
2266
+		);
2267
+		$variations_select_values = array();
2268
+		foreach ($variations as $variation => $label) {
2269
+			$variations_select_values[] = array(
2270
+				'text' => $label,
2271
+				'id'   => $variation
2272
+			);
2273
+		}
2274
+        
2275
+		$template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
2276
+        
2277
+		$template_args['template_packs_selector']        = EEH_Form_Fields::select_input(
2278
+			'MTP_template_pack',
2279
+			$tp_select_values,
2280
+			$this->_message_template_group->get_template_pack_name()
2281
+		);
2282
+		$template_args['variations_selector']            = EEH_Form_Fields::select_input(
2283
+			'MTP_template_variation',
2284
+			$variations_select_values,
2285
+			$this->_message_template_group->get_template_pack_variation()
2286
+		);
2287
+		$template_args['template_pack_label']            = $template_pack_labels->template_pack;
2288
+		$template_args['template_variation_label']       = $template_pack_labels->template_variation;
2289
+		$template_args['template_pack_description']      = $template_pack_labels->template_pack_description;
2290
+		$template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
2291
+        
2292
+		$template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
2293
+        
2294
+		EEH_Template::display_template($template, $template_args);
2295
+	}
2296 2296
     
2297 2297
     
2298
-    /**
2299
-     * This meta box holds any extra actions related to Message Templates
2300
-     * For now, this includes Resetting templates to defaults and sending a test email.
2301
-     *
2302
-     * @access  public
2303
-     * @return void
2304
-     * @throws EE_Error
2305
-     */
2306
-    public function extra_actions_meta_box()
2307
-    {
2308
-        $template_form_fields = array();
2309
-        
2310
-        $extra_args = array(
2311
-            'msgr'   => $this->_message_template_group->messenger(),
2312
-            'mt'     => $this->_message_template_group->message_type(),
2313
-            'GRP_ID' => $this->_message_template_group->GRP_ID()
2314
-        );
2315
-        //first we need to see if there are any fields
2316
-        $fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
2317
-        
2318
-        if ( ! empty($fields)) {
2319
-            //yup there be fields
2320
-            foreach ($fields as $field => $config) {
2321
-                $field_id = $this->_message_template_group->messenger() . '_' . $field;
2322
-                $existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
2323
-                $default  = isset($config['default']) ? $config['default'] : '';
2324
-                $default  = isset($config['value']) ? $config['value'] : $default;
2298
+	/**
2299
+	 * This meta box holds any extra actions related to Message Templates
2300
+	 * For now, this includes Resetting templates to defaults and sending a test email.
2301
+	 *
2302
+	 * @access  public
2303
+	 * @return void
2304
+	 * @throws EE_Error
2305
+	 */
2306
+	public function extra_actions_meta_box()
2307
+	{
2308
+		$template_form_fields = array();
2309
+        
2310
+		$extra_args = array(
2311
+			'msgr'   => $this->_message_template_group->messenger(),
2312
+			'mt'     => $this->_message_template_group->message_type(),
2313
+			'GRP_ID' => $this->_message_template_group->GRP_ID()
2314
+		);
2315
+		//first we need to see if there are any fields
2316
+		$fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
2317
+        
2318
+		if ( ! empty($fields)) {
2319
+			//yup there be fields
2320
+			foreach ($fields as $field => $config) {
2321
+				$field_id = $this->_message_template_group->messenger() . '_' . $field;
2322
+				$existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
2323
+				$default  = isset($config['default']) ? $config['default'] : '';
2324
+				$default  = isset($config['value']) ? $config['value'] : $default;
2325 2325
                 
2326
-                // if type is hidden and the value is empty
2327
-                // something may have gone wrong so let's correct with the defaults
2328
-                $fix              = $config['input'] === 'hidden'
2329
-                                    && isset($existing[$field])
2330
-                                    && empty($existing[$field])
2331
-                    ? $default
2332
-                    : '';
2333
-                $existing[$field] = isset($existing[$field]) && empty($fix)
2334
-                    ? $existing[$field]
2335
-                    : $fix;
2326
+				// if type is hidden and the value is empty
2327
+				// something may have gone wrong so let's correct with the defaults
2328
+				$fix              = $config['input'] === 'hidden'
2329
+									&& isset($existing[$field])
2330
+									&& empty($existing[$field])
2331
+					? $default
2332
+					: '';
2333
+				$existing[$field] = isset($existing[$field]) && empty($fix)
2334
+					? $existing[$field]
2335
+					: $fix;
2336 2336
                 
2337
-                $template_form_fields[$field_id] = array(
2338
-                    'name'       => 'test_settings_fld[' . $field . ']',
2339
-                    'label'      => $config['label'],
2340
-                    'input'      => $config['input'],
2341
-                    'type'       => $config['type'],
2342
-                    'required'   => $config['required'],
2343
-                    'validation' => $config['validation'],
2344
-                    'value'      => isset($existing[$field]) ? $existing[$field] : $default,
2345
-                    'css_class'  => $config['css_class'],
2346
-                    'options'    => isset($config['options']) ? $config['options'] : array(),
2347
-                    'default'    => $default,
2348
-                    'format'     => $config['format']
2349
-                );
2350
-            }
2351
-        }
2352
-        
2353
-        $test_settings_fields = ! empty($template_form_fields)
2354
-            ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds')
2355
-            : '';
2356
-        
2357
-        $test_settings_html = '';
2358
-        //print out $test_settings_fields
2359
-        if ( ! empty($test_settings_fields)) {
2360
-            echo $test_settings_fields;
2361
-            $test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" ';
2362
-            $test_settings_html .= 'name="test_button" value="';
2363
-            $test_settings_html .= esc_html__('Test Send', 'event_espresso');
2364
-            $test_settings_html .= '" /><div style="clear:both"></div>';
2365
-        }
2366
-        
2367
-        //and button
2368
-        $test_settings_html .= '<p>'
2369
-                               . esc_html__('Need to reset this message type and start over?', 'event_espresso')
2370
-                               . '</p>';
2371
-        $test_settings_html .= '<div class="publishing-action alignright resetbutton">';
2372
-        $test_settings_html .= $this->get_action_link_or_button(
2373
-            'reset_to_default',
2374
-            'reset',
2375
-            $extra_args,
2376
-            'button-primary reset-default-button'
2377
-        );
2378
-        $test_settings_html .= '</div><div style="clear:both"></div>';
2379
-        echo $test_settings_html;
2380
-    }
2337
+				$template_form_fields[$field_id] = array(
2338
+					'name'       => 'test_settings_fld[' . $field . ']',
2339
+					'label'      => $config['label'],
2340
+					'input'      => $config['input'],
2341
+					'type'       => $config['type'],
2342
+					'required'   => $config['required'],
2343
+					'validation' => $config['validation'],
2344
+					'value'      => isset($existing[$field]) ? $existing[$field] : $default,
2345
+					'css_class'  => $config['css_class'],
2346
+					'options'    => isset($config['options']) ? $config['options'] : array(),
2347
+					'default'    => $default,
2348
+					'format'     => $config['format']
2349
+				);
2350
+			}
2351
+		}
2352
+        
2353
+		$test_settings_fields = ! empty($template_form_fields)
2354
+			? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds')
2355
+			: '';
2356
+        
2357
+		$test_settings_html = '';
2358
+		//print out $test_settings_fields
2359
+		if ( ! empty($test_settings_fields)) {
2360
+			echo $test_settings_fields;
2361
+			$test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" ';
2362
+			$test_settings_html .= 'name="test_button" value="';
2363
+			$test_settings_html .= esc_html__('Test Send', 'event_espresso');
2364
+			$test_settings_html .= '" /><div style="clear:both"></div>';
2365
+		}
2366
+        
2367
+		//and button
2368
+		$test_settings_html .= '<p>'
2369
+							   . esc_html__('Need to reset this message type and start over?', 'event_espresso')
2370
+							   . '</p>';
2371
+		$test_settings_html .= '<div class="publishing-action alignright resetbutton">';
2372
+		$test_settings_html .= $this->get_action_link_or_button(
2373
+			'reset_to_default',
2374
+			'reset',
2375
+			$extra_args,
2376
+			'button-primary reset-default-button'
2377
+		);
2378
+		$test_settings_html .= '</div><div style="clear:both"></div>';
2379
+		echo $test_settings_html;
2380
+	}
2381 2381
 
2382 2382
 
2383
-    /**
2384
-     * This returns the shortcode selector skeleton for a given context and field.
2385
-     *
2386
-     * @since 4.9.rc.000
2387
-     * @param string $field           The name of the field retrieving shortcodes for.
2388
-     * @param string $linked_input_id The css id of the input that the shortcodes get added to.
2389
-     * @return string
2390
-     * @throws DomainException
2391
-     * @throws EE_Error
2392
-     * @throws InvalidArgumentException
2393
-     * @throws ReflectionException
2394
-     * @throws InvalidDataTypeException
2395
-     * @throws InvalidInterfaceException
2396
-     */
2397
-    protected function _get_shortcode_selector($field, $linked_input_id)
2398
-    {
2399
-        $template_args = array(
2400
-            'shortcodes'      => $this->_get_shortcodes(array($field), true),
2401
-            'fieldname'       => $field,
2402
-            'linked_input_id' => $linked_input_id
2403
-        );
2404
-        
2405
-        return EEH_Template::display_template(
2406
-            EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php',
2407
-            $template_args,
2408
-            true
2409
-        );
2410
-    }
2383
+	/**
2384
+	 * This returns the shortcode selector skeleton for a given context and field.
2385
+	 *
2386
+	 * @since 4.9.rc.000
2387
+	 * @param string $field           The name of the field retrieving shortcodes for.
2388
+	 * @param string $linked_input_id The css id of the input that the shortcodes get added to.
2389
+	 * @return string
2390
+	 * @throws DomainException
2391
+	 * @throws EE_Error
2392
+	 * @throws InvalidArgumentException
2393
+	 * @throws ReflectionException
2394
+	 * @throws InvalidDataTypeException
2395
+	 * @throws InvalidInterfaceException
2396
+	 */
2397
+	protected function _get_shortcode_selector($field, $linked_input_id)
2398
+	{
2399
+		$template_args = array(
2400
+			'shortcodes'      => $this->_get_shortcodes(array($field), true),
2401
+			'fieldname'       => $field,
2402
+			'linked_input_id' => $linked_input_id
2403
+		);
2404
+        
2405
+		return EEH_Template::display_template(
2406
+			EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php',
2407
+			$template_args,
2408
+			true
2409
+		);
2410
+	}
2411 2411
 
2412 2412
 
2413
-    /**
2414
-     * This just takes care of returning the meta box content for shortcodes (only used on the edit message template
2415
-     * page)
2416
-     *
2417
-     * @access public
2418
-     * @return void
2419
-     * @throws EE_Error
2420
-     * @throws InvalidArgumentException
2421
-     * @throws ReflectionException
2422
-     * @throws InvalidDataTypeException
2423
-     * @throws InvalidInterfaceException
2424
-     */
2425
-    public function shortcode_meta_box()
2426
-    {
2427
-        $shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set
2428
-        //$messenger = $this->_message_template_group->messenger_obj();
2429
-        //now let's set the content depending on the status of the shortcodes array
2430
-        if (empty($shortcodes)) {
2431
-            $content = '<p>' . esc_html__('There are no valid shortcodes available', 'event_espresso') . '</p>';
2432
-            echo $content;
2433
-        } else {
2434
-            //$alt = 0;
2435
-            ?>
2413
+	/**
2414
+	 * This just takes care of returning the meta box content for shortcodes (only used on the edit message template
2415
+	 * page)
2416
+	 *
2417
+	 * @access public
2418
+	 * @return void
2419
+	 * @throws EE_Error
2420
+	 * @throws InvalidArgumentException
2421
+	 * @throws ReflectionException
2422
+	 * @throws InvalidDataTypeException
2423
+	 * @throws InvalidInterfaceException
2424
+	 */
2425
+	public function shortcode_meta_box()
2426
+	{
2427
+		$shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set
2428
+		//$messenger = $this->_message_template_group->messenger_obj();
2429
+		//now let's set the content depending on the status of the shortcodes array
2430
+		if (empty($shortcodes)) {
2431
+			$content = '<p>' . esc_html__('There are no valid shortcodes available', 'event_espresso') . '</p>';
2432
+			echo $content;
2433
+		} else {
2434
+			//$alt = 0;
2435
+			?>
2436 2436
             <div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div>
2437 2437
             <p class="small-text"><?php printf(
2438
-                    esc_html__(
2439
-                        'You can view the shortcodes usable in your template by clicking the %s icon next to each field.',
2440
-                        'event_espresso'
2441
-                    ),
2442
-                    '<span class="dashicons dashicons-menu"></span>'
2443
-                ); ?></p>
2438
+					esc_html__(
2439
+						'You can view the shortcodes usable in your template by clicking the %s icon next to each field.',
2440
+						'event_espresso'
2441
+					),
2442
+					'<span class="dashicons dashicons-menu"></span>'
2443
+				); ?></p>
2444 2444
             <?php
2445
-        }
2445
+		}
2446 2446
         
2447 2447
         
2448
-    }
2448
+	}
2449 2449
 
2450 2450
 
2451
-    /**
2452
-     * used to set the $_shortcodes property for when its needed elsewhere.
2453
-     *
2454
-     * @access protected
2455
-     * @return void
2456
-     * @throws EE_Error
2457
-     * @throws InvalidArgumentException
2458
-     * @throws ReflectionException
2459
-     * @throws InvalidDataTypeException
2460
-     * @throws InvalidInterfaceException
2461
-     */
2462
-    protected function _set_shortcodes()
2463
-    {
2464
-        
2465
-        //no need to run this if the property is already set
2466
-        if ( ! empty($this->_shortcodes)) {
2467
-            return;
2468
-        }
2469
-        
2470
-        $this->_shortcodes = $this->_get_shortcodes();
2471
-    }
2451
+	/**
2452
+	 * used to set the $_shortcodes property for when its needed elsewhere.
2453
+	 *
2454
+	 * @access protected
2455
+	 * @return void
2456
+	 * @throws EE_Error
2457
+	 * @throws InvalidArgumentException
2458
+	 * @throws ReflectionException
2459
+	 * @throws InvalidDataTypeException
2460
+	 * @throws InvalidInterfaceException
2461
+	 */
2462
+	protected function _set_shortcodes()
2463
+	{
2464
+        
2465
+		//no need to run this if the property is already set
2466
+		if ( ! empty($this->_shortcodes)) {
2467
+			return;
2468
+		}
2469
+        
2470
+		$this->_shortcodes = $this->_get_shortcodes();
2471
+	}
2472 2472
 
2473 2473
 
2474
-    /**
2475
-     * get's all shortcodes for a given template group. (typically used by _set_shortcodes to set the $_shortcodes
2476
-     * property)
2477
-     *
2478
-     * @access  protected
2479
-     * @param  array   $fields include an array of specific field names that you want to be used to get the shortcodes
2480
-     *                         for. Defaults to all (for the given context)
2481
-     * @param  boolean $merged Whether to merge all the shortcodes into one list of unique shortcodes
2482
-     * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is
2483
-     *                         true just an array of shortcode/label pairs.
2484
-     * @throws EE_Error
2485
-     * @throws InvalidArgumentException
2486
-     * @throws ReflectionException
2487
-     * @throws InvalidDataTypeException
2488
-     * @throws InvalidInterfaceException
2489
-     */
2490
-    protected function _get_shortcodes($fields = array(), $merged = true)
2491
-    {
2492
-        $this->_set_message_template_group();
2493
-        
2494
-        //we need the messenger and message template to retrieve the valid shortcodes array.
2495
-        $GRP_ID  = isset($this->_req_data['id']) && ! empty($this->_req_data['id'])
2496
-            ? absint($this->_req_data['id'])
2497
-            : false;
2498
-        $context = isset($this->_req_data['context'])
2499
-            ? $this->_req_data['context']
2500
-            : key($this->_message_template_group->contexts_config());
2501
-        
2502
-        return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array();
2503
-    }
2474
+	/**
2475
+	 * get's all shortcodes for a given template group. (typically used by _set_shortcodes to set the $_shortcodes
2476
+	 * property)
2477
+	 *
2478
+	 * @access  protected
2479
+	 * @param  array   $fields include an array of specific field names that you want to be used to get the shortcodes
2480
+	 *                         for. Defaults to all (for the given context)
2481
+	 * @param  boolean $merged Whether to merge all the shortcodes into one list of unique shortcodes
2482
+	 * @return array Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is
2483
+	 *                         true just an array of shortcode/label pairs.
2484
+	 * @throws EE_Error
2485
+	 * @throws InvalidArgumentException
2486
+	 * @throws ReflectionException
2487
+	 * @throws InvalidDataTypeException
2488
+	 * @throws InvalidInterfaceException
2489
+	 */
2490
+	protected function _get_shortcodes($fields = array(), $merged = true)
2491
+	{
2492
+		$this->_set_message_template_group();
2493
+        
2494
+		//we need the messenger and message template to retrieve the valid shortcodes array.
2495
+		$GRP_ID  = isset($this->_req_data['id']) && ! empty($this->_req_data['id'])
2496
+			? absint($this->_req_data['id'])
2497
+			: false;
2498
+		$context = isset($this->_req_data['context'])
2499
+			? $this->_req_data['context']
2500
+			: key($this->_message_template_group->contexts_config());
2501
+        
2502
+		return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array();
2503
+	}
2504 2504
 
2505 2505
 
2506
-    /**
2507
-     * This sets the _message_template property (containing the called message_template object)
2508
-     *
2509
-     * @access protected
2510
-     * @return void
2511
-     * @throws EE_Error
2512
-     * @throws InvalidArgumentException
2513
-     * @throws ReflectionException
2514
-     * @throws InvalidDataTypeException
2515
-     * @throws InvalidInterfaceException
2516
-     */
2517
-    protected function _set_message_template_group()
2518
-    {
2519
-        
2520
-        if ( ! empty($this->_message_template_group)) {
2521
-            return;
2522
-        } //get out if this is already set.
2523
-        
2524
-        $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false;
2525
-        $GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID;
2526
-        
2527
-        //let's get the message templates
2528
-        $MTP = EEM_Message_Template_Group::instance();
2529
-        
2530
-        if (empty($GRP_ID)) {
2531
-            $this->_message_template_group = $MTP->create_default_object();
2532
-        } else {
2533
-            $this->_message_template_group = $MTP->get_one_by_ID($GRP_ID);
2534
-        }
2535
-        
2536
-        $this->_template_pack = $this->_message_template_group->get_template_pack();
2537
-        $this->_variation     = $this->_message_template_group->get_template_pack_variation();
2538
-        
2539
-    }
2506
+	/**
2507
+	 * This sets the _message_template property (containing the called message_template object)
2508
+	 *
2509
+	 * @access protected
2510
+	 * @return void
2511
+	 * @throws EE_Error
2512
+	 * @throws InvalidArgumentException
2513
+	 * @throws ReflectionException
2514
+	 * @throws InvalidDataTypeException
2515
+	 * @throws InvalidInterfaceException
2516
+	 */
2517
+	protected function _set_message_template_group()
2518
+	{
2519
+        
2520
+		if ( ! empty($this->_message_template_group)) {
2521
+			return;
2522
+		} //get out if this is already set.
2523
+        
2524
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false;
2525
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID;
2526
+        
2527
+		//let's get the message templates
2528
+		$MTP = EEM_Message_Template_Group::instance();
2529
+        
2530
+		if (empty($GRP_ID)) {
2531
+			$this->_message_template_group = $MTP->create_default_object();
2532
+		} else {
2533
+			$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID);
2534
+		}
2535
+        
2536
+		$this->_template_pack = $this->_message_template_group->get_template_pack();
2537
+		$this->_variation     = $this->_message_template_group->get_template_pack_variation();
2538
+        
2539
+	}
2540 2540
 
2541 2541
 
2542
-    /**
2543
-     * sets up a context switcher for edit forms
2544
-     *
2545
-     * @access  protected
2546
-     * @param  EE_Message_Template_Group $template_group_object the template group object being displayed on the form
2547
-     * @param array                      $args                  various things the context switcher needs.
2548
-     * @throws EE_Error
2549
-     */
2550
-    protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args)
2551
-    {
2552
-        $context_details = $template_group_object->contexts_config();
2553
-        $context_label   = $template_group_object->context_label();
2554
-        ob_start();
2555
-        ?>
2542
+	/**
2543
+	 * sets up a context switcher for edit forms
2544
+	 *
2545
+	 * @access  protected
2546
+	 * @param  EE_Message_Template_Group $template_group_object the template group object being displayed on the form
2547
+	 * @param array                      $args                  various things the context switcher needs.
2548
+	 * @throws EE_Error
2549
+	 */
2550
+	protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args)
2551
+	{
2552
+		$context_details = $template_group_object->contexts_config();
2553
+		$context_label   = $template_group_object->context_label();
2554
+		ob_start();
2555
+		?>
2556 2556
         <div class="ee-msg-switcher-container">
2557 2557
             <form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm">
2558 2558
                 <?php
2559
-                foreach ($args as $name => $value) {
2560
-                    if ($name === 'context' || empty($value) || $name === 'extra') {
2561
-                        continue;
2562
-                    }
2563
-                    ?>
2559
+				foreach ($args as $name => $value) {
2560
+					if ($name === 'context' || empty($value) || $name === 'extra') {
2561
+						continue;
2562
+					}
2563
+					?>
2564 2564
                     <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>"/>
2565 2565
                     <?php
2566
-                }
2567
-                //setup nonce_url
2568
-                wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
2569
-                ?>
2566
+				}
2567
+				//setup nonce_url
2568
+				wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
2569
+				?>
2570 2570
                 <select name="context">
2571 2571
                     <?php
2572
-                    $context_templates = $template_group_object->context_templates();
2573
-                    if (is_array($context_templates)) :
2574
-                        foreach ($context_templates as $context => $template_fields) :
2575
-                            $checked = ($context === $args['context']) ? 'selected="selected"' : '';
2576
-                            ?>
2572
+					$context_templates = $template_group_object->context_templates();
2573
+					if (is_array($context_templates)) :
2574
+						foreach ($context_templates as $context => $template_fields) :
2575
+							$checked = ($context === $args['context']) ? 'selected="selected"' : '';
2576
+							?>
2577 2577
                             <option value="<?php echo $context; ?>" <?php echo $checked; ?>>
2578 2578
                                 <?php echo $context_details[$context]['label']; ?>
2579 2579
                             </option>
@@ -2586,1823 +2586,1823 @@  discard block
 block discarded – undo
2586 2586
             <?php echo $args['extra']; ?>
2587 2587
         </div> <!-- end .ee-msg-switcher-container -->
2588 2588
         <?php
2589
-        $output = ob_get_contents();
2590
-        ob_clean();
2591
-        $this->_context_switcher = $output;
2592
-    }
2589
+		$output = ob_get_contents();
2590
+		ob_clean();
2591
+		$this->_context_switcher = $output;
2592
+	}
2593 2593
     
2594 2594
     
2595
-    /**
2596
-     * utility for sanitizing new values coming in.
2597
-     * Note: this is only used when updating a context.
2598
-     *
2599
-     * @access protected
2600
-     *
2601
-     * @param int $index This helps us know which template field to select from the request array.
2602
-     *
2603
-     * @return array
2604
-     */
2605
-    protected function _set_message_template_column_values($index)
2606
-    {
2607
-        if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) {
2608
-            foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) {
2609
-                $this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value;
2610
-            }
2611
-        }
2612
-        
2613
-        
2614
-        $set_column_values = array(
2615
-            'MTP_ID'             => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']),
2616
-            'GRP_ID'             => absint($this->_req_data['GRP_ID']),
2617
-            'MTP_user_id'        => absint($this->_req_data['MTP_user_id']),
2618
-            'MTP_messenger'      => strtolower($this->_req_data['MTP_messenger']),
2619
-            'MTP_message_type'   => strtolower($this->_req_data['MTP_message_type']),
2620
-            'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']),
2621
-            'MTP_context'        => strtolower($this->_req_data['MTP_context']),
2622
-            'MTP_content'        => $this->_req_data['MTP_template_fields'][$index]['content'],
2623
-            'MTP_is_global'      => isset($this->_req_data['MTP_is_global'])
2624
-                ? absint($this->_req_data['MTP_is_global'])
2625
-                : 0,
2626
-            'MTP_is_override'    => isset($this->_req_data['MTP_is_override'])
2627
-                ? absint($this->_req_data['MTP_is_override'])
2628
-                : 0,
2629
-            'MTP_deleted'        => absint($this->_req_data['MTP_deleted']),
2630
-            'MTP_is_active'      => absint($this->_req_data['MTP_is_active'])
2631
-        );
2632
-        
2633
-        
2634
-        return $set_column_values;
2635
-    }
2595
+	/**
2596
+	 * utility for sanitizing new values coming in.
2597
+	 * Note: this is only used when updating a context.
2598
+	 *
2599
+	 * @access protected
2600
+	 *
2601
+	 * @param int $index This helps us know which template field to select from the request array.
2602
+	 *
2603
+	 * @return array
2604
+	 */
2605
+	protected function _set_message_template_column_values($index)
2606
+	{
2607
+		if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) {
2608
+			foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) {
2609
+				$this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value;
2610
+			}
2611
+		}
2612
+        
2613
+        
2614
+		$set_column_values = array(
2615
+			'MTP_ID'             => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']),
2616
+			'GRP_ID'             => absint($this->_req_data['GRP_ID']),
2617
+			'MTP_user_id'        => absint($this->_req_data['MTP_user_id']),
2618
+			'MTP_messenger'      => strtolower($this->_req_data['MTP_messenger']),
2619
+			'MTP_message_type'   => strtolower($this->_req_data['MTP_message_type']),
2620
+			'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']),
2621
+			'MTP_context'        => strtolower($this->_req_data['MTP_context']),
2622
+			'MTP_content'        => $this->_req_data['MTP_template_fields'][$index]['content'],
2623
+			'MTP_is_global'      => isset($this->_req_data['MTP_is_global'])
2624
+				? absint($this->_req_data['MTP_is_global'])
2625
+				: 0,
2626
+			'MTP_is_override'    => isset($this->_req_data['MTP_is_override'])
2627
+				? absint($this->_req_data['MTP_is_override'])
2628
+				: 0,
2629
+			'MTP_deleted'        => absint($this->_req_data['MTP_deleted']),
2630
+			'MTP_is_active'      => absint($this->_req_data['MTP_is_active'])
2631
+		);
2632
+        
2633
+        
2634
+		return $set_column_values;
2635
+	}
2636 2636
     
2637 2637
     
2638
-    protected function _insert_or_update_message_template($new = false)
2639
-    {
2640
-        
2641
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2642
-        $success  = 0;
2643
-        $override = false;
2644
-        
2645
-        //setup notices description
2646
-        $messenger_slug = ! empty($this->_req_data['MTP_messenger']) ? $this->_req_data['MTP_messenger'] : '';
2647
-        
2648
-        //need the message type and messenger objects to be able to use the labels for the notices
2649
-        $messenger_object = $this->_message_resource_manager->get_messenger($messenger_slug);
2650
-        $messenger_label  = $messenger_object instanceof EE_messenger
2651
-            ? ucwords($messenger_object->label['singular'])
2652
-            : '';
2653
-        
2654
-        $message_type_slug   = ! empty($this->_req_data['MTP_message_type'])
2655
-            ? $this->_req_data['MTP_message_type']
2656
-            : '';
2657
-        $message_type_object = $this->_message_resource_manager->get_message_type($message_type_slug);
2658
-        
2659
-        $message_type_label = $message_type_object instanceof EE_message_type
2660
-            ? ucwords($message_type_object->label['singular'])
2661
-            : '';
2662
-        
2663
-        $context_slug = ! empty($this->_req_data['MTP_context'])
2664
-            ? $this->_req_data['MTP_context']
2665
-            : '';
2666
-        $context      = ucwords(str_replace('_', ' ', $context_slug));
2667
-        
2668
-        $item_desc = $messenger_label && $message_type_label
2669
-            ? $messenger_label . ' ' . $message_type_label . ' ' . $context . ' '
2670
-            : '';
2671
-        $item_desc .= 'Message Template';
2672
-        $query_args  = array();
2673
-        $edit_array  = array();
2674
-        $action_desc = '';
2675
-        
2676
-        //if this is "new" then we need to generate the default contexts for the selected messenger/message_type for
2677
-        // user to edit.
2678
-        if ($new) {
2679
-            $GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
2680
-            if ($edit_array = $this->_generate_new_templates($messenger_slug, $message_type_slug, $GRP_ID)) {
2681
-                if (empty($edit_array)) {
2682
-                    $success = 0;
2683
-                } else {
2684
-                    $success    = 1;
2685
-                    $edit_array = $edit_array[0];
2686
-                    $query_args = array(
2687
-                        'id'      => $edit_array['GRP_ID'],
2688
-                        'context' => $edit_array['MTP_context'],
2689
-                        'action'  => 'edit_message_template'
2690
-                    );
2691
-                }
2692
-            }
2693
-            $action_desc = 'created';
2694
-        } else {
2695
-            $MTPG = EEM_Message_Template_Group::instance();
2696
-            $MTP  = EEM_Message_Template::instance();
2638
+	protected function _insert_or_update_message_template($new = false)
2639
+	{
2640
+        
2641
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2642
+		$success  = 0;
2643
+		$override = false;
2644
+        
2645
+		//setup notices description
2646
+		$messenger_slug = ! empty($this->_req_data['MTP_messenger']) ? $this->_req_data['MTP_messenger'] : '';
2647
+        
2648
+		//need the message type and messenger objects to be able to use the labels for the notices
2649
+		$messenger_object = $this->_message_resource_manager->get_messenger($messenger_slug);
2650
+		$messenger_label  = $messenger_object instanceof EE_messenger
2651
+			? ucwords($messenger_object->label['singular'])
2652
+			: '';
2653
+        
2654
+		$message_type_slug   = ! empty($this->_req_data['MTP_message_type'])
2655
+			? $this->_req_data['MTP_message_type']
2656
+			: '';
2657
+		$message_type_object = $this->_message_resource_manager->get_message_type($message_type_slug);
2658
+        
2659
+		$message_type_label = $message_type_object instanceof EE_message_type
2660
+			? ucwords($message_type_object->label['singular'])
2661
+			: '';
2662
+        
2663
+		$context_slug = ! empty($this->_req_data['MTP_context'])
2664
+			? $this->_req_data['MTP_context']
2665
+			: '';
2666
+		$context      = ucwords(str_replace('_', ' ', $context_slug));
2667
+        
2668
+		$item_desc = $messenger_label && $message_type_label
2669
+			? $messenger_label . ' ' . $message_type_label . ' ' . $context . ' '
2670
+			: '';
2671
+		$item_desc .= 'Message Template';
2672
+		$query_args  = array();
2673
+		$edit_array  = array();
2674
+		$action_desc = '';
2675
+        
2676
+		//if this is "new" then we need to generate the default contexts for the selected messenger/message_type for
2677
+		// user to edit.
2678
+		if ($new) {
2679
+			$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
2680
+			if ($edit_array = $this->_generate_new_templates($messenger_slug, $message_type_slug, $GRP_ID)) {
2681
+				if (empty($edit_array)) {
2682
+					$success = 0;
2683
+				} else {
2684
+					$success    = 1;
2685
+					$edit_array = $edit_array[0];
2686
+					$query_args = array(
2687
+						'id'      => $edit_array['GRP_ID'],
2688
+						'context' => $edit_array['MTP_context'],
2689
+						'action'  => 'edit_message_template'
2690
+					);
2691
+				}
2692
+			}
2693
+			$action_desc = 'created';
2694
+		} else {
2695
+			$MTPG = EEM_Message_Template_Group::instance();
2696
+			$MTP  = EEM_Message_Template::instance();
2697 2697
             
2698 2698
             
2699
-            //run update for each template field in displayed context
2700
-            if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) {
2701
-                EE_Error::add_error(
2702
-                    esc_html__(
2703
-                        'There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.',
2704
-                        'event_espresso'
2705
-                    ),
2706
-                    __FILE__,
2707
-                    __FUNCTION__,
2708
-                    __LINE__
2709
-                );
2710
-                $success = 0;
2699
+			//run update for each template field in displayed context
2700
+			if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) {
2701
+				EE_Error::add_error(
2702
+					esc_html__(
2703
+						'There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.',
2704
+						'event_espresso'
2705
+					),
2706
+					__FILE__,
2707
+					__FUNCTION__,
2708
+					__LINE__
2709
+				);
2710
+				$success = 0;
2711 2711
                 
2712
-            } else {
2713
-                //first validate all fields!
2714
-                $validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $context_slug, $messenger_slug,
2715
-                    $message_type_slug);
2712
+			} else {
2713
+				//first validate all fields!
2714
+				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $context_slug, $messenger_slug,
2715
+					$message_type_slug);
2716 2716
                 
2717
-                //if $validate returned error messages (i.e. is_array()) then we need to process them and setup an
2718
-                // appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array.
2719
-                //  WE need to make sure there is no actual error messages in validates.
2720
-                if (is_array($validates) && ! empty($validates)) {
2721
-                    //add the transient so when the form loads we know which fields to highlight
2722
-                    $this->_add_transient('edit_message_template', $validates);
2717
+				//if $validate returned error messages (i.e. is_array()) then we need to process them and setup an
2718
+				// appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array.
2719
+				//  WE need to make sure there is no actual error messages in validates.
2720
+				if (is_array($validates) && ! empty($validates)) {
2721
+					//add the transient so when the form loads we know which fields to highlight
2722
+					$this->_add_transient('edit_message_template', $validates);
2723 2723
                     
2724
-                    $success = 0;
2724
+					$success = 0;
2725 2725
                     
2726
-                    //setup notices
2727
-                    foreach ($validates as $field => $error) {
2728
-                        if (isset($error['msg'])) {
2729
-                            EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
2730
-                        }
2731
-                    }
2726
+					//setup notices
2727
+					foreach ($validates as $field => $error) {
2728
+						if (isset($error['msg'])) {
2729
+							EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
2730
+						}
2731
+					}
2732 2732
                     
2733
-                } else {
2734
-                    $set_column_values = array();
2735
-                    foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) {
2736
-                        $set_column_values = $this->_set_message_template_column_values($template_field);
2733
+				} else {
2734
+					$set_column_values = array();
2735
+					foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) {
2736
+						$set_column_values = $this->_set_message_template_column_values($template_field);
2737 2737
                         
2738
-                        $where_cols_n_values = array(
2739
-                            'MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']
2740
-                        );
2738
+						$where_cols_n_values = array(
2739
+							'MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']
2740
+						);
2741 2741
                         
2742
-                        $message_template_fields = array(
2743
-                            'GRP_ID'             => $set_column_values['GRP_ID'],
2744
-                            'MTP_template_field' => $set_column_values['MTP_template_field'],
2745
-                            'MTP_context'        => $set_column_values['MTP_context'],
2746
-                            'MTP_content'        => $set_column_values['MTP_content']
2747
-                        );
2748
-                        if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) {
2749
-                            if ($updated === false) {
2750
-                                EE_Error::add_error(
2751
-                                    sprintf(
2752
-                                        esc_html__('%s field was NOT updated for some reason', 'event_espresso'),
2753
-                                        $template_field
2754
-                                    ),
2755
-                                    __FILE__,
2756
-                                    __FUNCTION__,
2757
-                                    __LINE__
2758
-                                );
2759
-                            } else {
2760
-                                $success = 1;
2761
-                            }
2762
-                        } else {
2763
-                            //only do this logic if we don't have a MTP_ID for this field
2764
-                            if (empty($this->_req_data['MTP_template_fields'][$template_field]['MTP_ID'])) {
2765
-                                //this has already been through the template field validator and sanitized, so it will be
2766
-                                //safe to insert this field.  Why insert?  This typically happens when we introduce a new
2767
-                                //message template field in a messenger/message type and existing users don't have the
2768
-                                //default setup for it.
2769
-                                //@link https://events.codebasehq.com/projects/event-espresso/tickets/9465
2770
-                                $updated = $MTP->insert($message_template_fields);
2771
-                                if (! $updated || is_wp_error($updated)) {
2772
-                                    EE_Error::add_error(
2773
-                                        sprintf(
2774
-                                            esc_html__('%s field could not be updated.', 'event_espresso'),
2775
-                                            $template_field
2776
-                                        ),
2777
-                                        __FILE__,
2778
-                                        __FUNCTION__,
2779
-                                        __LINE__
2780
-                                    );
2781
-                                    $success = 0;
2782
-                                } else {
2783
-                                    $success = 1;
2784
-                                }
2785
-                            }
2786
-                        }
2787
-                        $action_desc = 'updated';
2788
-                    }
2742
+						$message_template_fields = array(
2743
+							'GRP_ID'             => $set_column_values['GRP_ID'],
2744
+							'MTP_template_field' => $set_column_values['MTP_template_field'],
2745
+							'MTP_context'        => $set_column_values['MTP_context'],
2746
+							'MTP_content'        => $set_column_values['MTP_content']
2747
+						);
2748
+						if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) {
2749
+							if ($updated === false) {
2750
+								EE_Error::add_error(
2751
+									sprintf(
2752
+										esc_html__('%s field was NOT updated for some reason', 'event_espresso'),
2753
+										$template_field
2754
+									),
2755
+									__FILE__,
2756
+									__FUNCTION__,
2757
+									__LINE__
2758
+								);
2759
+							} else {
2760
+								$success = 1;
2761
+							}
2762
+						} else {
2763
+							//only do this logic if we don't have a MTP_ID for this field
2764
+							if (empty($this->_req_data['MTP_template_fields'][$template_field]['MTP_ID'])) {
2765
+								//this has already been through the template field validator and sanitized, so it will be
2766
+								//safe to insert this field.  Why insert?  This typically happens when we introduce a new
2767
+								//message template field in a messenger/message type and existing users don't have the
2768
+								//default setup for it.
2769
+								//@link https://events.codebasehq.com/projects/event-espresso/tickets/9465
2770
+								$updated = $MTP->insert($message_template_fields);
2771
+								if (! $updated || is_wp_error($updated)) {
2772
+									EE_Error::add_error(
2773
+										sprintf(
2774
+											esc_html__('%s field could not be updated.', 'event_espresso'),
2775
+											$template_field
2776
+										),
2777
+										__FILE__,
2778
+										__FUNCTION__,
2779
+										__LINE__
2780
+									);
2781
+									$success = 0;
2782
+								} else {
2783
+									$success = 1;
2784
+								}
2785
+							}
2786
+						}
2787
+						$action_desc = 'updated';
2788
+					}
2789 2789
                     
2790
-                    //we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs)
2791
-                    $mtpg_fields = array(
2792
-                        'MTP_user_id'      => $set_column_values['MTP_user_id'],
2793
-                        'MTP_messenger'    => $set_column_values['MTP_messenger'],
2794
-                        'MTP_message_type' => $set_column_values['MTP_message_type'],
2795
-                        'MTP_is_global'    => $set_column_values['MTP_is_global'],
2796
-                        'MTP_is_override'  => $set_column_values['MTP_is_override'],
2797
-                        'MTP_deleted'      => $set_column_values['MTP_deleted'],
2798
-                        'MTP_is_active'    => $set_column_values['MTP_is_active'],
2799
-                        'MTP_name'         => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name'])
2800
-                            ? $this->_req_data['ee_msg_non_global_fields']['MTP_name']
2801
-                            : '',
2802
-                        'MTP_description'  => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description'])
2803
-                            ? $this->_req_data['ee_msg_non_global_fields']['MTP_description']
2804
-                            : ''
2805
-                    );
2790
+					//we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs)
2791
+					$mtpg_fields = array(
2792
+						'MTP_user_id'      => $set_column_values['MTP_user_id'],
2793
+						'MTP_messenger'    => $set_column_values['MTP_messenger'],
2794
+						'MTP_message_type' => $set_column_values['MTP_message_type'],
2795
+						'MTP_is_global'    => $set_column_values['MTP_is_global'],
2796
+						'MTP_is_override'  => $set_column_values['MTP_is_override'],
2797
+						'MTP_deleted'      => $set_column_values['MTP_deleted'],
2798
+						'MTP_is_active'    => $set_column_values['MTP_is_active'],
2799
+						'MTP_name'         => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name'])
2800
+							? $this->_req_data['ee_msg_non_global_fields']['MTP_name']
2801
+							: '',
2802
+						'MTP_description'  => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description'])
2803
+							? $this->_req_data['ee_msg_non_global_fields']['MTP_description']
2804
+							: ''
2805
+					);
2806 2806
                     
2807
-                    $mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']);
2808
-                    $updated    = $MTPG->update($mtpg_fields, array($mtpg_where));
2807
+					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']);
2808
+					$updated    = $MTPG->update($mtpg_fields, array($mtpg_where));
2809 2809
                     
2810
-                    if ($updated === false) {
2811
-                        EE_Error::add_error(
2812
-                            sprintf(
2813
-                                esc_html__(
2814
-                                    'The Message Template Group (%d) was NOT updated for some reason',
2815
-                                    'event_espresso'
2816
-                                ),
2817
-                                $set_column_values['GRP_ID']
2818
-                            ),
2819
-                            __FILE__,
2820
-                            __FUNCTION__,
2821
-                            __LINE__
2822
-                        );
2823
-                    } else {
2824
-                        //k now we need to ensure the template_pack and template_variation fields are set.
2825
-                        $template_pack = ! empty($this->_req_data['MTP_template_pack'])
2826
-                            ? $this->_req_data['MTP_template_pack']
2827
-                            : 'default';
2810
+					if ($updated === false) {
2811
+						EE_Error::add_error(
2812
+							sprintf(
2813
+								esc_html__(
2814
+									'The Message Template Group (%d) was NOT updated for some reason',
2815
+									'event_espresso'
2816
+								),
2817
+								$set_column_values['GRP_ID']
2818
+							),
2819
+							__FILE__,
2820
+							__FUNCTION__,
2821
+							__LINE__
2822
+						);
2823
+					} else {
2824
+						//k now we need to ensure the template_pack and template_variation fields are set.
2825
+						$template_pack = ! empty($this->_req_data['MTP_template_pack'])
2826
+							? $this->_req_data['MTP_template_pack']
2827
+							: 'default';
2828 2828
                         
2829
-                        $template_variation = ! empty($this->_req_data['MTP_template_variation'])
2830
-                            ? $this->_req_data['MTP_template_variation']
2831
-                            : 'default';
2829
+						$template_variation = ! empty($this->_req_data['MTP_template_variation'])
2830
+							? $this->_req_data['MTP_template_variation']
2831
+							: 'default';
2832 2832
                         
2833
-                        $mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']);
2834
-                        if ($mtpg_obj instanceof EE_Message_Template_Group) {
2835
-                            $mtpg_obj->set_template_pack_name($template_pack);
2836
-                            $mtpg_obj->set_template_pack_variation($template_variation);
2837
-                        }
2838
-                        $success = 1;
2839
-                    }
2840
-                }
2841
-            }
2833
+						$mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']);
2834
+						if ($mtpg_obj instanceof EE_Message_Template_Group) {
2835
+							$mtpg_obj->set_template_pack_name($template_pack);
2836
+							$mtpg_obj->set_template_pack_variation($template_variation);
2837
+						}
2838
+						$success = 1;
2839
+					}
2840
+				}
2841
+			}
2842 2842
             
2843
-        }
2844
-        
2845
-        //we return things differently if doing ajax
2846
-        if (defined('DOING_AJAX') && DOING_AJAX) {
2847
-            $this->_template_args['success'] = $success;
2848
-            $this->_template_args['error']   = ! $success ? true : false;
2849
-            $this->_template_args['content'] = '';
2850
-            $this->_template_args['data']    = array(
2851
-                'grpID'        => $edit_array['GRP_ID'],
2852
-                'templateName' => $edit_array['template_name']
2853
-            );
2854
-            if ($success) {
2855
-                EE_Error::overwrite_success();
2856
-                EE_Error::add_success(
2857
-                    esc_html__(
2858
-                        '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.',
2859
-                        'event_espresso'
2860
-                    )
2861
-                );
2862
-            }
2843
+		}
2844
+        
2845
+		//we return things differently if doing ajax
2846
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2847
+			$this->_template_args['success'] = $success;
2848
+			$this->_template_args['error']   = ! $success ? true : false;
2849
+			$this->_template_args['content'] = '';
2850
+			$this->_template_args['data']    = array(
2851
+				'grpID'        => $edit_array['GRP_ID'],
2852
+				'templateName' => $edit_array['template_name']
2853
+			);
2854
+			if ($success) {
2855
+				EE_Error::overwrite_success();
2856
+				EE_Error::add_success(
2857
+					esc_html__(
2858
+						'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.',
2859
+						'event_espresso'
2860
+					)
2861
+				);
2862
+			}
2863 2863
             
2864
-            $this->_return_json();
2865
-        }
2866
-        
2867
-        
2868
-        //was a test send triggered?
2869
-        if (isset($this->_req_data['test_button'])) {
2870
-            EE_Error::overwrite_success();
2871
-            $this->_do_test_send($context_slug, $messenger_slug, $message_type_slug);
2872
-            $override = true;
2873
-        }
2874
-        
2875
-        if (empty($query_args)) {
2876
-            $query_args = array(
2877
-                'id'      => $this->_req_data['GRP_ID'],
2878
-                'context' => $context_slug,
2879
-                'action'  => 'edit_message_template'
2880
-            );
2881
-        }
2882
-        
2883
-        $this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
2884
-    }
2864
+			$this->_return_json();
2865
+		}
2866
+        
2867
+        
2868
+		//was a test send triggered?
2869
+		if (isset($this->_req_data['test_button'])) {
2870
+			EE_Error::overwrite_success();
2871
+			$this->_do_test_send($context_slug, $messenger_slug, $message_type_slug);
2872
+			$override = true;
2873
+		}
2874
+        
2875
+		if (empty($query_args)) {
2876
+			$query_args = array(
2877
+				'id'      => $this->_req_data['GRP_ID'],
2878
+				'context' => $context_slug,
2879
+				'action'  => 'edit_message_template'
2880
+			);
2881
+		}
2882
+        
2883
+		$this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
2884
+	}
2885 2885
 
2886 2886
 
2887
-    /**
2888
-     * processes a test send request to do an actual messenger delivery test for the given message template being tested
2889
-     *
2890
-     * @param  string $context      what context being tested
2891
-     * @param  string $messenger    messenger being tested
2892
-     * @param  string $message_type message type being tested
2893
-     * @throws EE_Error
2894
-     * @throws InvalidArgumentException
2895
-     * @throws InvalidDataTypeException
2896
-     * @throws InvalidInterfaceException
2897
-     */
2898
-    protected function _do_test_send($context, $messenger, $message_type)
2899
-    {
2900
-        //set things up for preview
2901
-        $this->_req_data['messenger']    = $messenger;
2902
-        $this->_req_data['message_type'] = $message_type;
2903
-        $this->_req_data['context']      = $context;
2904
-        $this->_req_data['GRP_ID']       = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : '';
2905
-        $active_messenger                = $this->_message_resource_manager->get_active_messenger($messenger);
2906
-        
2907
-        //let's save any existing fields that might be required by the messenger
2908
-        if (
2909
-            isset($this->_req_data['test_settings_fld'])
2910
-            && $active_messenger instanceof EE_messenger
2911
-            && apply_filters(
2912
-                'FHEE__Messages_Admin_Page__do_test_send__set_existing_test_settings',
2913
-                true,
2914
-                $this->_req_data['test_settings_fld'],
2915
-                $active_messenger
2916
-            )
2917
-        ) {
2918
-            $active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']);
2919
-        }
2920
-        
2921
-        $success = $this->_preview_message(true);
2922
-        
2923
-        if ($success) {
2924
-            EE_Error::add_success(__('Test message sent', 'event_espresso'));
2925
-        } else {
2926
-            EE_Error::add_error(
2927
-                esc_html__('The test message was not sent', 'event_espresso'),
2928
-                __FILE__,
2929
-                __FUNCTION__,
2930
-                __LINE__
2931
-            );
2932
-        }
2933
-    }
2887
+	/**
2888
+	 * processes a test send request to do an actual messenger delivery test for the given message template being tested
2889
+	 *
2890
+	 * @param  string $context      what context being tested
2891
+	 * @param  string $messenger    messenger being tested
2892
+	 * @param  string $message_type message type being tested
2893
+	 * @throws EE_Error
2894
+	 * @throws InvalidArgumentException
2895
+	 * @throws InvalidDataTypeException
2896
+	 * @throws InvalidInterfaceException
2897
+	 */
2898
+	protected function _do_test_send($context, $messenger, $message_type)
2899
+	{
2900
+		//set things up for preview
2901
+		$this->_req_data['messenger']    = $messenger;
2902
+		$this->_req_data['message_type'] = $message_type;
2903
+		$this->_req_data['context']      = $context;
2904
+		$this->_req_data['GRP_ID']       = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : '';
2905
+		$active_messenger                = $this->_message_resource_manager->get_active_messenger($messenger);
2906
+        
2907
+		//let's save any existing fields that might be required by the messenger
2908
+		if (
2909
+			isset($this->_req_data['test_settings_fld'])
2910
+			&& $active_messenger instanceof EE_messenger
2911
+			&& apply_filters(
2912
+				'FHEE__Messages_Admin_Page__do_test_send__set_existing_test_settings',
2913
+				true,
2914
+				$this->_req_data['test_settings_fld'],
2915
+				$active_messenger
2916
+			)
2917
+		) {
2918
+			$active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']);
2919
+		}
2920
+        
2921
+		$success = $this->_preview_message(true);
2922
+        
2923
+		if ($success) {
2924
+			EE_Error::add_success(__('Test message sent', 'event_espresso'));
2925
+		} else {
2926
+			EE_Error::add_error(
2927
+				esc_html__('The test message was not sent', 'event_espresso'),
2928
+				__FILE__,
2929
+				__FUNCTION__,
2930
+				__LINE__
2931
+			);
2932
+		}
2933
+	}
2934 2934
     
2935 2935
     
2936
-    /**
2937
-     * _generate_new_templates
2938
-     * This will handle the messenger, message_type selection when "adding a new custom template" for an event and will
2939
-     * automatically create the defaults for the event.  The user would then be redirected to edit the default context
2940
-     * for the event.
2941
-     *
2942
-     *
2943
-     * @param  string $messenger     the messenger we are generating templates for
2944
-     * @param array   $message_types array of message types that the templates are generated for.
2945
-     * @param int     $GRP_ID        If this is a custom template being generated then a GRP_ID needs to be included to
2946
-     *                               indicate the message_template_group being used as the base.
2947
-     *
2948
-     * @param bool    $global
2949
-     *
2950
-     * @return array|bool array of data required for the redirect to the correct edit page or bool if
2951
-     *                               encountering problems.
2952
-     * @throws EE_Error
2953
-     */
2954
-    protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false)
2955
-    {
2956
-        
2957
-        //if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we
2958
-        // just don't generate any templates.
2959
-        if (empty($message_types)) {
2960
-            return true;
2961
-        }
2962
-        
2963
-        return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
2964
-    }
2936
+	/**
2937
+	 * _generate_new_templates
2938
+	 * This will handle the messenger, message_type selection when "adding a new custom template" for an event and will
2939
+	 * automatically create the defaults for the event.  The user would then be redirected to edit the default context
2940
+	 * for the event.
2941
+	 *
2942
+	 *
2943
+	 * @param  string $messenger     the messenger we are generating templates for
2944
+	 * @param array   $message_types array of message types that the templates are generated for.
2945
+	 * @param int     $GRP_ID        If this is a custom template being generated then a GRP_ID needs to be included to
2946
+	 *                               indicate the message_template_group being used as the base.
2947
+	 *
2948
+	 * @param bool    $global
2949
+	 *
2950
+	 * @return array|bool array of data required for the redirect to the correct edit page or bool if
2951
+	 *                               encountering problems.
2952
+	 * @throws EE_Error
2953
+	 */
2954
+	protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false)
2955
+	{
2956
+        
2957
+		//if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we
2958
+		// just don't generate any templates.
2959
+		if (empty($message_types)) {
2960
+			return true;
2961
+		}
2962
+        
2963
+		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
2964
+	}
2965 2965
 
2966 2966
 
2967
-    /**
2968
-     * [_trash_or_restore_message_template]
2969
-     *
2970
-     * @param  boolean $trash whether to move an item to trash/restore (TRUE) or restore it (FALSE)
2971
-     * @param boolean  $all   whether this is going to trash/restore all contexts within a template group (TRUE) OR just
2972
-     *                        an individual context (FALSE).
2973
-     * @return void
2974
-     * @throws EE_Error
2975
-     * @throws InvalidArgumentException
2976
-     * @throws InvalidDataTypeException
2977
-     * @throws InvalidInterfaceException
2978
-     */
2979
-    protected function _trash_or_restore_message_template($trash = true, $all = false)
2980
-    {
2981
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2982
-        $MTP = EEM_Message_Template_Group::instance();
2983
-        
2984
-        $success = 1;
2985
-        
2986
-        //incoming GRP_IDs
2987
-        if ($all) {
2988
-            //Checkboxes
2989
-            if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2990
-                //if array has more than one element then success message should be plural.
2991
-                //todo: what about nonce?
2992
-                $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2967
+	/**
2968
+	 * [_trash_or_restore_message_template]
2969
+	 *
2970
+	 * @param  boolean $trash whether to move an item to trash/restore (TRUE) or restore it (FALSE)
2971
+	 * @param boolean  $all   whether this is going to trash/restore all contexts within a template group (TRUE) OR just
2972
+	 *                        an individual context (FALSE).
2973
+	 * @return void
2974
+	 * @throws EE_Error
2975
+	 * @throws InvalidArgumentException
2976
+	 * @throws InvalidDataTypeException
2977
+	 * @throws InvalidInterfaceException
2978
+	 */
2979
+	protected function _trash_or_restore_message_template($trash = true, $all = false)
2980
+	{
2981
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2982
+		$MTP = EEM_Message_Template_Group::instance();
2983
+        
2984
+		$success = 1;
2985
+        
2986
+		//incoming GRP_IDs
2987
+		if ($all) {
2988
+			//Checkboxes
2989
+			if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2990
+				//if array has more than one element then success message should be plural.
2991
+				//todo: what about nonce?
2992
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2993 2993
                 
2994
-                //cycle through checkboxes
2995
-                while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2996
-                    $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2997
-                    if ( ! $trashed_or_restored) {
2998
-                        $success = 0;
2999
-                    }
3000
-                }
3001
-            } else {
3002
-                //grab single GRP_ID and handle
3003
-                $GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
3004
-                if ( ! empty($GRP_ID)) {
3005
-                    $trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
3006
-                    if ( ! $trashed_or_restored) {
3007
-                        $success = 0;
3008
-                    }
3009
-                } else {
3010
-                    $success = 0;
3011
-                }
3012
-            }
2994
+				//cycle through checkboxes
2995
+				while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2996
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2997
+					if ( ! $trashed_or_restored) {
2998
+						$success = 0;
2999
+					}
3000
+				}
3001
+			} else {
3002
+				//grab single GRP_ID and handle
3003
+				$GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
3004
+				if ( ! empty($GRP_ID)) {
3005
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
3006
+					if ( ! $trashed_or_restored) {
3007
+						$success = 0;
3008
+					}
3009
+				} else {
3010
+					$success = 0;
3011
+				}
3012
+			}
3013 3013
             
3014
-        }
3014
+		}
3015 3015
         
3016
-        $action_desc = $trash
3017
-            ? esc_html__('moved to the trash', 'event_espresso')
3018
-            : esc_html__('restored', 'event_espresso');
3016
+		$action_desc = $trash
3017
+			? esc_html__('moved to the trash', 'event_espresso')
3018
+			: esc_html__('restored', 'event_espresso');
3019 3019
         
3020
-        $action_desc = ! empty($this->_req_data['template_switch']) ? esc_html__('switched') : $action_desc;
3020
+		$action_desc = ! empty($this->_req_data['template_switch']) ? esc_html__('switched') : $action_desc;
3021 3021
         
3022
-        $item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success,
3023
-            'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
3022
+		$item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success,
3023
+			'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
3024 3024
         
3025
-        $item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success,
3026
-            'event_espresso') : $item_desc;
3025
+		$item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success,
3026
+			'event_espresso') : $item_desc;
3027 3027
         
3028
-        $this->_redirect_after_action($success, $item_desc, $action_desc, array());
3028
+		$this->_redirect_after_action($success, $item_desc, $action_desc, array());
3029 3029
         
3030
-    }
3030
+	}
3031 3031
 
3032 3032
 
3033
-    /**
3034
-     * [_delete_message_template]
3035
-     * NOTE: this handles not only the deletion of the groups but also all the templates belonging to that group.
3036
-     *
3037
-     * @return void
3038
-     * @throws EE_Error
3039
-     * @throws InvalidArgumentException
3040
-     * @throws InvalidDataTypeException
3041
-     * @throws InvalidInterfaceException
3042
-     */
3043
-    protected function _delete_message_template()
3044
-    {
3045
-        do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3046
-        
3047
-        //checkboxes
3048
-        if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3049
-            //if array has more than one element then success message should be plural
3050
-            $success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3033
+	/**
3034
+	 * [_delete_message_template]
3035
+	 * NOTE: this handles not only the deletion of the groups but also all the templates belonging to that group.
3036
+	 *
3037
+	 * @return void
3038
+	 * @throws EE_Error
3039
+	 * @throws InvalidArgumentException
3040
+	 * @throws InvalidDataTypeException
3041
+	 * @throws InvalidInterfaceException
3042
+	 */
3043
+	protected function _delete_message_template()
3044
+	{
3045
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
3046
+        
3047
+		//checkboxes
3048
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
3049
+			//if array has more than one element then success message should be plural
3050
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
3051 3051
             
3052
-            //cycle through bulk action checkboxes
3053
-            while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
3054
-                $success = $this->_delete_mtp_permanently($GRP_ID);
3055
-            }
3056
-        } else {
3057
-            //grab single grp_id and delete
3058
-            $GRP_ID  = absint($this->_req_data['id']);
3059
-            $success = $this->_delete_mtp_permanently($GRP_ID);
3060
-        }
3061
-        
3062
-        $this->_redirect_after_action($success, 'Message Templates', 'deleted', array());
3063
-        
3064
-    }
3052
+			//cycle through bulk action checkboxes
3053
+			while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
3054
+				$success = $this->_delete_mtp_permanently($GRP_ID);
3055
+			}
3056
+		} else {
3057
+			//grab single grp_id and delete
3058
+			$GRP_ID  = absint($this->_req_data['id']);
3059
+			$success = $this->_delete_mtp_permanently($GRP_ID);
3060
+		}
3061
+        
3062
+		$this->_redirect_after_action($success, 'Message Templates', 'deleted', array());
3063
+        
3064
+	}
3065 3065
 
3066 3066
 
3067
-    /**
3068
-     * helper for permanently deleting a mtP group and all related message_templates
3069
-     *
3070
-     * @param  int  $GRP_ID        The group being deleted
3071
-     * @param  bool $include_group whether to delete the Message Template Group as well.
3072
-     * @return bool boolean to indicate the success of the deletes or not.
3073
-     * @throws EE_Error
3074
-     * @throws InvalidArgumentException
3075
-     * @throws InvalidDataTypeException
3076
-     * @throws InvalidInterfaceException
3077
-     */
3078
-    private function _delete_mtp_permanently($GRP_ID, $include_group = true)
3079
-    {
3080
-        $success = 1;
3081
-        $MTPG    = EEM_Message_Template_Group::instance();
3082
-        //first let's GET this group
3083
-        $MTG = $MTPG->get_one_by_ID($GRP_ID);
3084
-        //then delete permanently all the related Message Templates
3085
-        $deleted = $MTG->delete_related_permanently('Message_Template');
3086
-        
3087
-        if ($deleted === 0) {
3088
-            $success = 0;
3089
-        }
3090
-        
3091
-        //now delete permanently this particular group
3092
-        
3093
-        if ($include_group && ! $MTG->delete_permanently()) {
3094
-            $success = 0;
3095
-        }
3096
-        
3097
-        return $success;
3098
-    }
3067
+	/**
3068
+	 * helper for permanently deleting a mtP group and all related message_templates
3069
+	 *
3070
+	 * @param  int  $GRP_ID        The group being deleted
3071
+	 * @param  bool $include_group whether to delete the Message Template Group as well.
3072
+	 * @return bool boolean to indicate the success of the deletes or not.
3073
+	 * @throws EE_Error
3074
+	 * @throws InvalidArgumentException
3075
+	 * @throws InvalidDataTypeException
3076
+	 * @throws InvalidInterfaceException
3077
+	 */
3078
+	private function _delete_mtp_permanently($GRP_ID, $include_group = true)
3079
+	{
3080
+		$success = 1;
3081
+		$MTPG    = EEM_Message_Template_Group::instance();
3082
+		//first let's GET this group
3083
+		$MTG = $MTPG->get_one_by_ID($GRP_ID);
3084
+		//then delete permanently all the related Message Templates
3085
+		$deleted = $MTG->delete_related_permanently('Message_Template');
3086
+        
3087
+		if ($deleted === 0) {
3088
+			$success = 0;
3089
+		}
3090
+        
3091
+		//now delete permanently this particular group
3092
+        
3093
+		if ($include_group && ! $MTG->delete_permanently()) {
3094
+			$success = 0;
3095
+		}
3096
+        
3097
+		return $success;
3098
+	}
3099 3099
     
3100 3100
     
3101
-    /**
3102
-     *    _learn_more_about_message_templates_link
3103
-     * @access protected
3104
-     * @return string
3105
-     */
3106
-    protected function _learn_more_about_message_templates_link()
3107
-    {
3108
-        return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'
3109
-               . esc_html__('learn more about how message templates works', 'event_espresso')
3110
-               . '</a>';
3111
-    }
3101
+	/**
3102
+	 *    _learn_more_about_message_templates_link
3103
+	 * @access protected
3104
+	 * @return string
3105
+	 */
3106
+	protected function _learn_more_about_message_templates_link()
3107
+	{
3108
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'
3109
+			   . esc_html__('learn more about how message templates works', 'event_espresso')
3110
+			   . '</a>';
3111
+	}
3112 3112
 
3113 3113
 
3114
-    /**
3115
-     * Used for setting up messenger/message type activation.  This loads up the initial view.  The rest is handled by
3116
-     * ajax and other routes.
3117
-     *
3118
-     * @return void
3119
-     * @throws DomainException
3120
-     */
3121
-    protected function _settings()
3122
-    {
3123
-        
3124
-        
3125
-        $this->_set_m_mt_settings();
3126
-        
3127
-        $selected_messenger = isset($this->_req_data['selected_messenger'])
3128
-            ? $this->_req_data['selected_messenger']
3129
-            : 'email';
3130
-        
3131
-        //let's setup the messenger tabs
3132
-        $this->_template_args['admin_page_header']         = EEH_Tabbed_Content::tab_text_links(
3133
-            $this->_m_mt_settings['messenger_tabs'],
3134
-            'messenger_links',
3135
-            '|',
3136
-            $selected_messenger
3137
-        );
3138
-        $this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
3139
-        $this->_template_args['after_admin_page_content']  = '</div><!-- end .ui-widget -->';
3140
-        
3141
-        $this->display_admin_page_with_sidebar();
3142
-        
3143
-    }
3114
+	/**
3115
+	 * Used for setting up messenger/message type activation.  This loads up the initial view.  The rest is handled by
3116
+	 * ajax and other routes.
3117
+	 *
3118
+	 * @return void
3119
+	 * @throws DomainException
3120
+	 */
3121
+	protected function _settings()
3122
+	{
3123
+        
3124
+        
3125
+		$this->_set_m_mt_settings();
3126
+        
3127
+		$selected_messenger = isset($this->_req_data['selected_messenger'])
3128
+			? $this->_req_data['selected_messenger']
3129
+			: 'email';
3130
+        
3131
+		//let's setup the messenger tabs
3132
+		$this->_template_args['admin_page_header']         = EEH_Tabbed_Content::tab_text_links(
3133
+			$this->_m_mt_settings['messenger_tabs'],
3134
+			'messenger_links',
3135
+			'|',
3136
+			$selected_messenger
3137
+		);
3138
+		$this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
3139
+		$this->_template_args['after_admin_page_content']  = '</div><!-- end .ui-widget -->';
3140
+        
3141
+		$this->display_admin_page_with_sidebar();
3142
+        
3143
+	}
3144 3144
 
3145 3145
 
3146
-    /**
3147
-     * This sets the $_m_mt_settings property for when needed (used on the Messages settings page)
3148
-     *
3149
-     * @access protected
3150
-     * @return void
3151
-     * @throws DomainException
3152
-     */
3153
-    protected function _set_m_mt_settings()
3154
-    {
3155
-        //first if this is already set then lets get out no need to regenerate data.
3156
-        if ( ! empty($this->_m_mt_settings)) {
3157
-            return;
3158
-        }
3159
-        
3160
-        //get all installed messengers and message_types
3161
-        /** @type EE_messenger[] $messengers */
3162
-        $messengers = $this->_message_resource_manager->installed_messengers();
3163
-        /** @type EE_message_type[] $message_types */
3164
-        $message_types = $this->_message_resource_manager->installed_message_types();
3165
-        
3166
-        
3167
-        //assemble the array for the _tab_text_links helper
3168
-        
3169
-        foreach ($messengers as $messenger) {
3170
-            $this->_m_mt_settings['messenger_tabs'][$messenger->name] = array(
3171
-                'label' => ucwords($messenger->label['singular']),
3172
-                'class' => $this->_message_resource_manager->is_messenger_active($messenger->name)
3173
-                    ? 'messenger-active'
3174
-                    : '',
3175
-                'href'  => $messenger->name,
3176
-                'title' => esc_html__('Modify this Messenger', 'event_espresso'),
3177
-                'slug'  => $messenger->name,
3178
-                'obj'   => $messenger
3179
-            );
3146
+	/**
3147
+	 * This sets the $_m_mt_settings property for when needed (used on the Messages settings page)
3148
+	 *
3149
+	 * @access protected
3150
+	 * @return void
3151
+	 * @throws DomainException
3152
+	 */
3153
+	protected function _set_m_mt_settings()
3154
+	{
3155
+		//first if this is already set then lets get out no need to regenerate data.
3156
+		if ( ! empty($this->_m_mt_settings)) {
3157
+			return;
3158
+		}
3159
+        
3160
+		//get all installed messengers and message_types
3161
+		/** @type EE_messenger[] $messengers */
3162
+		$messengers = $this->_message_resource_manager->installed_messengers();
3163
+		/** @type EE_message_type[] $message_types */
3164
+		$message_types = $this->_message_resource_manager->installed_message_types();
3165
+        
3166
+        
3167
+		//assemble the array for the _tab_text_links helper
3168
+        
3169
+		foreach ($messengers as $messenger) {
3170
+			$this->_m_mt_settings['messenger_tabs'][$messenger->name] = array(
3171
+				'label' => ucwords($messenger->label['singular']),
3172
+				'class' => $this->_message_resource_manager->is_messenger_active($messenger->name)
3173
+					? 'messenger-active'
3174
+					: '',
3175
+				'href'  => $messenger->name,
3176
+				'title' => esc_html__('Modify this Messenger', 'event_espresso'),
3177
+				'slug'  => $messenger->name,
3178
+				'obj'   => $messenger
3179
+			);
3180 3180
             
3181 3181
             
3182
-            $message_types_for_messenger = $messenger->get_valid_message_types();
3182
+			$message_types_for_messenger = $messenger->get_valid_message_types();
3183 3183
             
3184
-            foreach ($message_types as $message_type) {
3185
-                //first we need to verify that this message type is valid with this messenger. Cause if it isn't then
3186
-                // it shouldn't show in either the inactive OR active metabox.
3187
-                if ( ! in_array($message_type->name, $message_types_for_messenger, true)) {
3188
-                    continue;
3189
-                }
3184
+			foreach ($message_types as $message_type) {
3185
+				//first we need to verify that this message type is valid with this messenger. Cause if it isn't then
3186
+				// it shouldn't show in either the inactive OR active metabox.
3187
+				if ( ! in_array($message_type->name, $message_types_for_messenger, true)) {
3188
+					continue;
3189
+				}
3190 3190
                 
3191
-                $a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger(
3192
-                    $messenger->name,
3193
-                    $message_type->name
3194
-                )
3195
-                    ? 'active'
3196
-                    : 'inactive';
3191
+				$a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger(
3192
+					$messenger->name,
3193
+					$message_type->name
3194
+				)
3195
+					? 'active'
3196
+					: 'inactive';
3197 3197
                 
3198
-                $this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
3199
-                    'label'    => ucwords($message_type->label['singular']),
3200
-                    'class'    => 'message-type-' . $a_or_i,
3201
-                    'slug_id'  => $message_type->name . '-messagetype-' . $messenger->name,
3202
-                    'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'),
3203
-                    'href'     => 'espresso_' . $message_type->name . '_message_type_settings',
3204
-                    'title'    => $a_or_i === 'active'
3205
-                        ? esc_html__('Drag this message type to the Inactive window to deactivate', 'event_espresso')
3206
-                        : esc_html__('Drag this message type to the messenger to activate', 'event_espresso'),
3207
-                    'content'  => $a_or_i === 'active'
3208
-                        ? $this->_message_type_settings_content($message_type, $messenger, true)
3209
-                        : $this->_message_type_settings_content($message_type, $messenger),
3210
-                    'slug'     => $message_type->name,
3211
-                    'active'   => $a_or_i === 'active',
3212
-                    'obj'      => $message_type
3213
-                );
3214
-            }
3215
-        }
3216
-    }
3198
+				$this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
3199
+					'label'    => ucwords($message_type->label['singular']),
3200
+					'class'    => 'message-type-' . $a_or_i,
3201
+					'slug_id'  => $message_type->name . '-messagetype-' . $messenger->name,
3202
+					'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'),
3203
+					'href'     => 'espresso_' . $message_type->name . '_message_type_settings',
3204
+					'title'    => $a_or_i === 'active'
3205
+						? esc_html__('Drag this message type to the Inactive window to deactivate', 'event_espresso')
3206
+						: esc_html__('Drag this message type to the messenger to activate', 'event_espresso'),
3207
+					'content'  => $a_or_i === 'active'
3208
+						? $this->_message_type_settings_content($message_type, $messenger, true)
3209
+						: $this->_message_type_settings_content($message_type, $messenger),
3210
+					'slug'     => $message_type->name,
3211
+					'active'   => $a_or_i === 'active',
3212
+					'obj'      => $message_type
3213
+				);
3214
+			}
3215
+		}
3216
+	}
3217 3217
 
3218 3218
 
3219
-    /**
3220
-     * This just prepares the content for the message type settings
3221
-     *
3222
-     * @param  EE_message_type  $message_type The message type object
3223
-     * @param  EE_messenger  $messenger    The messenger object
3224
-     * @param  boolean $active       Whether the message type is active or not
3225
-     * @return string html output for the content
3226
-     * @throws DomainException
3227
-     */
3228
-    protected function _message_type_settings_content($message_type, $messenger, $active = false)
3229
-    {
3230
-        //get message type fields
3231
-        $fields                                         = $message_type->get_admin_settings_fields();
3232
-        $settings_template_args['template_form_fields'] = '';
3233
-        
3234
-        if ( ! empty($fields) && $active) {
3219
+	/**
3220
+	 * This just prepares the content for the message type settings
3221
+	 *
3222
+	 * @param  EE_message_type  $message_type The message type object
3223
+	 * @param  EE_messenger  $messenger    The messenger object
3224
+	 * @param  boolean $active       Whether the message type is active or not
3225
+	 * @return string html output for the content
3226
+	 * @throws DomainException
3227
+	 */
3228
+	protected function _message_type_settings_content($message_type, $messenger, $active = false)
3229
+	{
3230
+		//get message type fields
3231
+		$fields                                         = $message_type->get_admin_settings_fields();
3232
+		$settings_template_args['template_form_fields'] = '';
3233
+        
3234
+		if ( ! empty($fields) && $active) {
3235 3235
             
3236
-            $existing_settings = $message_type->get_existing_admin_settings($messenger->name);
3236
+			$existing_settings = $message_type->get_existing_admin_settings($messenger->name);
3237 3237
             
3238
-            foreach ($fields as $fldname => $fldprops) {
3239
-                $field_id                       = $messenger->name . '-' . $message_type->name . '-' . $fldname;
3240
-                $template_form_field[$field_id] = array(
3241
-                    'name'       => 'message_type_settings[' . $fldname . ']',
3242
-                    'label'      => $fldprops['label'],
3243
-                    'input'      => $fldprops['field_type'],
3244
-                    'type'       => $fldprops['value_type'],
3245
-                    'required'   => $fldprops['required'],
3246
-                    'validation' => $fldprops['validation'],
3247
-                    'value'      => isset($existing_settings[$fldname])
3248
-                        ? $existing_settings[$fldname]
3249
-                        : $fldprops['default'],
3250
-                    'options'    => isset($fldprops['options'])
3251
-                        ? $fldprops['options']
3252
-                        : array(),
3253
-                    'default'    => isset($existing_settings[$fldname])
3254
-                        ? $existing_settings[$fldname]
3255
-                        : $fldprops['default'],
3256
-                    'css_class'  => 'no-drag',
3257
-                    'format'     => $fldprops['format']
3258
-                );
3259
-            }
3238
+			foreach ($fields as $fldname => $fldprops) {
3239
+				$field_id                       = $messenger->name . '-' . $message_type->name . '-' . $fldname;
3240
+				$template_form_field[$field_id] = array(
3241
+					'name'       => 'message_type_settings[' . $fldname . ']',
3242
+					'label'      => $fldprops['label'],
3243
+					'input'      => $fldprops['field_type'],
3244
+					'type'       => $fldprops['value_type'],
3245
+					'required'   => $fldprops['required'],
3246
+					'validation' => $fldprops['validation'],
3247
+					'value'      => isset($existing_settings[$fldname])
3248
+						? $existing_settings[$fldname]
3249
+						: $fldprops['default'],
3250
+					'options'    => isset($fldprops['options'])
3251
+						? $fldprops['options']
3252
+						: array(),
3253
+					'default'    => isset($existing_settings[$fldname])
3254
+						? $existing_settings[$fldname]
3255
+						: $fldprops['default'],
3256
+					'css_class'  => 'no-drag',
3257
+					'format'     => $fldprops['format']
3258
+				);
3259
+			}
3260 3260
             
3261 3261
             
3262
-            $settings_template_args['template_form_fields'] = ! empty($template_form_field)
3263
-                ? $this->_generate_admin_form_fields(
3264
-                    $template_form_field,
3265
-                    'string',
3266
-                    'ee_mt_activate_form'
3267
-                )
3268
-                : '';
3269
-        }
3270
-        
3271
-        $settings_template_args['description'] = $message_type->description;
3272
-        //we also need some hidden fields
3273
-        $settings_template_args['hidden_fields'] = array(
3274
-            'message_type_settings[messenger]'    => array(
3275
-                'type'  => 'hidden',
3276
-                'value' => $messenger->name
3277
-            ),
3278
-            'message_type_settings[message_type]' => array(
3279
-                'type'  => 'hidden',
3280
-                'value' => $message_type->name
3281
-            ),
3282
-            'type'                                => array(
3283
-                'type'  => 'hidden',
3284
-                'value' => 'message_type'
3285
-            )
3286
-        );
3287
-        
3288
-        $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3289
-            $settings_template_args['hidden_fields'],
3290
-            'array'
3291
-        );
3292
-        $settings_template_args['show_form']     = empty($settings_template_args['template_form_fields'])
3293
-            ? ' hidden'
3294
-            : '';
3295
-        
3296
-        
3297
-        $template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
3298
-        $content  = EEH_Template::display_template($template, $settings_template_args, true);
3299
-        
3300
-        return $content;
3301
-    }
3262
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field)
3263
+				? $this->_generate_admin_form_fields(
3264
+					$template_form_field,
3265
+					'string',
3266
+					'ee_mt_activate_form'
3267
+				)
3268
+				: '';
3269
+		}
3270
+        
3271
+		$settings_template_args['description'] = $message_type->description;
3272
+		//we also need some hidden fields
3273
+		$settings_template_args['hidden_fields'] = array(
3274
+			'message_type_settings[messenger]'    => array(
3275
+				'type'  => 'hidden',
3276
+				'value' => $messenger->name
3277
+			),
3278
+			'message_type_settings[message_type]' => array(
3279
+				'type'  => 'hidden',
3280
+				'value' => $message_type->name
3281
+			),
3282
+			'type'                                => array(
3283
+				'type'  => 'hidden',
3284
+				'value' => 'message_type'
3285
+			)
3286
+		);
3287
+        
3288
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3289
+			$settings_template_args['hidden_fields'],
3290
+			'array'
3291
+		);
3292
+		$settings_template_args['show_form']     = empty($settings_template_args['template_form_fields'])
3293
+			? ' hidden'
3294
+			: '';
3295
+        
3296
+        
3297
+		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
3298
+		$content  = EEH_Template::display_template($template, $settings_template_args, true);
3299
+        
3300
+		return $content;
3301
+	}
3302 3302
 
3303 3303
 
3304
-    /**
3305
-     * Generate all the metaboxes for the message types and register them for the messages settings page.
3306
-     *
3307
-     * @access protected
3308
-     * @return void
3309
-     * @throws DomainException
3310
-     */
3311
-    protected function _messages_settings_metaboxes()
3312
-    {
3313
-        $this->_set_m_mt_settings();
3314
-        $m_boxes         = $mt_boxes = array();
3315
-        $m_template_args = $mt_template_args = array();
3316
-        
3317
-        $selected_messenger = isset($this->_req_data['selected_messenger'])
3318
-            ? $this->_req_data['selected_messenger']
3319
-            : 'email';
3320
-        
3321
-        if (isset($this->_m_mt_settings['messenger_tabs'])) {
3322
-            foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
3323
-                $hide_on_message  = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden';
3324
-                $hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : '';
3325
-                //messenger meta boxes
3326
-                $active                                 = $selected_messenger === $messenger;
3327
-                $active_mt_tabs                         = isset(
3328
-                    $this->_m_mt_settings['message_type_tabs'][$messenger]['active']
3329
-                )
3330
-                    ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active']
3331
-                    : '';
3332
-                $m_boxes[$messenger . '_a_box']         = sprintf(
3333
-                    esc_html__('%s Settings', 'event_espresso'),
3334
-                    $tab_array['label']
3335
-                );
3336
-                $m_template_args[$messenger . '_a_box'] = array(
3337
-                    'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3338
-                    'inactive_message_types' => isset(
3339
-                        $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']
3340
-                    )
3341
-                        ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
3342
-                        : '',
3343
-                    'content'                => $this->_get_messenger_box_content($tab_array['obj']),
3344
-                    'hidden'                 => $active ? '' : ' hidden',
3345
-                    'hide_on_message'        => $hide_on_message,
3346
-                    'messenger'              => $messenger,
3347
-                    'active'                 => $active
3348
-                );
3349
-                // message type meta boxes
3350
-                // (which is really just the inactive container for each messenger
3351
-                // showing inactive message types for that messenger)
3352
-                $mt_boxes[$messenger . '_i_box']         = esc_html__('Inactive Message Types', 'event_espresso');
3353
-                $mt_template_args[$messenger . '_i_box'] = array(
3354
-                    'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3355
-                    'inactive_message_types' => isset(
3356
-                        $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']
3357
-                    )
3358
-                        ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
3359
-                        : '',
3360
-                    'hidden'                 => $active ? '' : ' hidden',
3361
-                    'hide_on_message'        => $hide_on_message,
3362
-                    'hide_off_message'       => $hide_off_message,
3363
-                    'messenger'              => $messenger,
3364
-                    'active'                 => $active
3365
-                );
3366
-            }
3367
-        }
3368
-        
3369
-        
3370
-        //register messenger metaboxes
3371
-        $m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
3372
-        foreach ($m_boxes as $box => $label) {
3373
-            $callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
3374
-            $msgr          = str_replace('_a_box', '', $box);
3375
-            add_meta_box(
3376
-                'espresso_' . $msgr . '_settings',
3377
-                $label,
3378
-                function ($post, $metabox) {
3379
-                    echo EEH_Template::display_template(
3380
-                            $metabox["args"]["template_path"],
3381
-                            $metabox["args"]["template_args"],
3382
-                            true
3383
-                    );
3384
-                },
3385
-                $this->_current_screen->id,
3386
-                'normal',
3387
-                'high',
3388
-                $callback_args
3389
-            );
3390
-        }
3391
-        
3392
-        //register message type metaboxes
3393
-        $mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
3394
-        foreach ($mt_boxes as $box => $label) {
3395
-            $callback_args = array(
3396
-                'template_path' => $mt_template_path,
3397
-                'template_args' => $mt_template_args[$box]
3398
-            );
3399
-            $mt            = str_replace('_i_box', '', $box);
3400
-            add_meta_box(
3401
-                'espresso_' . $mt . '_inactive_mts',
3402
-                $label,
3403
-                function ($post, $metabox) {
3404
-                    echo EEH_Template::display_template(
3405
-                            $metabox["args"]["template_path"],
3406
-                            $metabox["args"]["template_args"],
3407
-                            true
3408
-                    );
3409
-                },
3410
-                $this->_current_screen->id,
3411
-                'side',
3412
-                'high',
3413
-                $callback_args
3414
-            );
3415
-        }
3416
-        
3417
-        //register metabox for global messages settings but only when on the main site.  On single site installs this
3418
-        // will always result in the metabox showing, on multisite installs the metabox will only show on the main site.
3419
-        if (is_main_site()) {
3420
-            add_meta_box(
3421
-                'espresso_global_message_settings',
3422
-                esc_html__('Global Message Settings', 'event_espresso'),
3423
-                array($this, 'global_messages_settings_metabox_content'),
3424
-                $this->_current_screen->id,
3425
-                'normal',
3426
-                'low',
3427
-                array()
3428
-            );
3429
-        }
3430
-        
3431
-    }
3304
+	/**
3305
+	 * Generate all the metaboxes for the message types and register them for the messages settings page.
3306
+	 *
3307
+	 * @access protected
3308
+	 * @return void
3309
+	 * @throws DomainException
3310
+	 */
3311
+	protected function _messages_settings_metaboxes()
3312
+	{
3313
+		$this->_set_m_mt_settings();
3314
+		$m_boxes         = $mt_boxes = array();
3315
+		$m_template_args = $mt_template_args = array();
3316
+        
3317
+		$selected_messenger = isset($this->_req_data['selected_messenger'])
3318
+			? $this->_req_data['selected_messenger']
3319
+			: 'email';
3320
+        
3321
+		if (isset($this->_m_mt_settings['messenger_tabs'])) {
3322
+			foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
3323
+				$hide_on_message  = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden';
3324
+				$hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : '';
3325
+				//messenger meta boxes
3326
+				$active                                 = $selected_messenger === $messenger;
3327
+				$active_mt_tabs                         = isset(
3328
+					$this->_m_mt_settings['message_type_tabs'][$messenger]['active']
3329
+				)
3330
+					? $this->_m_mt_settings['message_type_tabs'][$messenger]['active']
3331
+					: '';
3332
+				$m_boxes[$messenger . '_a_box']         = sprintf(
3333
+					esc_html__('%s Settings', 'event_espresso'),
3334
+					$tab_array['label']
3335
+				);
3336
+				$m_template_args[$messenger . '_a_box'] = array(
3337
+					'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3338
+					'inactive_message_types' => isset(
3339
+						$this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']
3340
+					)
3341
+						? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
3342
+						: '',
3343
+					'content'                => $this->_get_messenger_box_content($tab_array['obj']),
3344
+					'hidden'                 => $active ? '' : ' hidden',
3345
+					'hide_on_message'        => $hide_on_message,
3346
+					'messenger'              => $messenger,
3347
+					'active'                 => $active
3348
+				);
3349
+				// message type meta boxes
3350
+				// (which is really just the inactive container for each messenger
3351
+				// showing inactive message types for that messenger)
3352
+				$mt_boxes[$messenger . '_i_box']         = esc_html__('Inactive Message Types', 'event_espresso');
3353
+				$mt_template_args[$messenger . '_i_box'] = array(
3354
+					'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
3355
+					'inactive_message_types' => isset(
3356
+						$this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']
3357
+					)
3358
+						? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
3359
+						: '',
3360
+					'hidden'                 => $active ? '' : ' hidden',
3361
+					'hide_on_message'        => $hide_on_message,
3362
+					'hide_off_message'       => $hide_off_message,
3363
+					'messenger'              => $messenger,
3364
+					'active'                 => $active
3365
+				);
3366
+			}
3367
+		}
3368
+        
3369
+        
3370
+		//register messenger metaboxes
3371
+		$m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
3372
+		foreach ($m_boxes as $box => $label) {
3373
+			$callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
3374
+			$msgr          = str_replace('_a_box', '', $box);
3375
+			add_meta_box(
3376
+				'espresso_' . $msgr . '_settings',
3377
+				$label,
3378
+				function ($post, $metabox) {
3379
+					echo EEH_Template::display_template(
3380
+							$metabox["args"]["template_path"],
3381
+							$metabox["args"]["template_args"],
3382
+							true
3383
+					);
3384
+				},
3385
+				$this->_current_screen->id,
3386
+				'normal',
3387
+				'high',
3388
+				$callback_args
3389
+			);
3390
+		}
3391
+        
3392
+		//register message type metaboxes
3393
+		$mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
3394
+		foreach ($mt_boxes as $box => $label) {
3395
+			$callback_args = array(
3396
+				'template_path' => $mt_template_path,
3397
+				'template_args' => $mt_template_args[$box]
3398
+			);
3399
+			$mt            = str_replace('_i_box', '', $box);
3400
+			add_meta_box(
3401
+				'espresso_' . $mt . '_inactive_mts',
3402
+				$label,
3403
+				function ($post, $metabox) {
3404
+					echo EEH_Template::display_template(
3405
+							$metabox["args"]["template_path"],
3406
+							$metabox["args"]["template_args"],
3407
+							true
3408
+					);
3409
+				},
3410
+				$this->_current_screen->id,
3411
+				'side',
3412
+				'high',
3413
+				$callback_args
3414
+			);
3415
+		}
3416
+        
3417
+		//register metabox for global messages settings but only when on the main site.  On single site installs this
3418
+		// will always result in the metabox showing, on multisite installs the metabox will only show on the main site.
3419
+		if (is_main_site()) {
3420
+			add_meta_box(
3421
+				'espresso_global_message_settings',
3422
+				esc_html__('Global Message Settings', 'event_espresso'),
3423
+				array($this, 'global_messages_settings_metabox_content'),
3424
+				$this->_current_screen->id,
3425
+				'normal',
3426
+				'low',
3427
+				array()
3428
+			);
3429
+		}
3430
+        
3431
+	}
3432 3432
 
3433 3433
 
3434
-    /**
3435
-     *  This generates the content for the global messages settings metabox.
3436
-     *
3437
-     * @return string
3438
-     * @throws EE_Error
3439
-     * @throws InvalidArgumentException
3440
-     * @throws ReflectionException
3441
-     * @throws InvalidDataTypeException
3442
-     * @throws InvalidInterfaceException
3443
-     */
3444
-    public function global_messages_settings_metabox_content()
3445
-    {
3446
-        $form = $this->_generate_global_settings_form();
3447
-        echo $form->form_open(
3448
-                $this->add_query_args_and_nonce(array('action' => 'update_global_settings'), EE_MSG_ADMIN_URL),
3449
-                'POST'
3450
-            )
3451
-             . $form->get_html()
3452
-             . $form->form_close();
3453
-    }
3434
+	/**
3435
+	 *  This generates the content for the global messages settings metabox.
3436
+	 *
3437
+	 * @return string
3438
+	 * @throws EE_Error
3439
+	 * @throws InvalidArgumentException
3440
+	 * @throws ReflectionException
3441
+	 * @throws InvalidDataTypeException
3442
+	 * @throws InvalidInterfaceException
3443
+	 */
3444
+	public function global_messages_settings_metabox_content()
3445
+	{
3446
+		$form = $this->_generate_global_settings_form();
3447
+		echo $form->form_open(
3448
+				$this->add_query_args_and_nonce(array('action' => 'update_global_settings'), EE_MSG_ADMIN_URL),
3449
+				'POST'
3450
+			)
3451
+			 . $form->get_html()
3452
+			 . $form->form_close();
3453
+	}
3454 3454
 
3455 3455
 
3456
-    /**
3457
-     * This generates and returns the form object for the global messages settings.
3458
-     *
3459
-     * @return EE_Form_Section_Proper
3460
-     * @throws EE_Error
3461
-     * @throws InvalidArgumentException
3462
-     * @throws ReflectionException
3463
-     * @throws InvalidDataTypeException
3464
-     * @throws InvalidInterfaceException
3465
-     */
3466
-    protected function _generate_global_settings_form()
3467
-    {
3468
-        EE_Registry::instance()->load_helper('HTML');
3469
-        /** @var EE_Network_Core_Config $network_config */
3470
-        $network_config = EE_Registry::instance()->NET_CFG->core;
3471
-        
3472
-        return new EE_Form_Section_Proper(
3473
-            array(
3474
-                'name'            => 'global_messages_settings',
3475
-                'html_id'         => 'global_messages_settings',
3476
-                'html_class'      => 'form-table',
3477
-                'layout_strategy' => new EE_Admin_Two_Column_Layout(),
3478
-                'subsections'     => apply_filters(
3479
-                    'FHEE__Messages_Admin_Page__global_messages_settings_metabox_content__form_subsections',
3480
-                    array(
3481
-                        'do_messages_on_same_request' => new EE_Select_Input(
3482
-                            array(
3483
-                                true  => esc_html__("On the same request", "event_espresso"),
3484
-                                false => esc_html__("On a separate request", "event_espresso")
3485
-                            ),
3486
-                            array(
3487
-                                'default'         => $network_config->do_messages_on_same_request,
3488
-                                'html_label_text' => esc_html__(
3489
-                                    'Generate and send all messages:',
3490
-                                    'event_espresso'
3491
-                                ),
3492
-                                'html_help_text'  => esc_html__(
3493
-                                    'By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system.  This makes things execute faster for people registering for your events.  However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.',
3494
-                                    'event_espresso'
3495
-                                ),
3496
-                            )
3497
-                        ),
3498
-                        'delete_threshold' => new EE_Select_Input(
3499
-                            array(
3500
-                                0 => esc_html__('Forever', 'event_espresso'),
3501
-                                3 => esc_html__('3 Months', 'event_espresso'),
3502
-                                6 => esc_html__('6 Months', 'event_espresso'),
3503
-                                9 => esc_html__('9 Months', 'event_espresso'),
3504
-                                12 => esc_html__('12 Months', 'event_espresso'),
3505
-                                24 => esc_html__('24 Months', 'event_espresso'),
3506
-                                36 => esc_html__('36 Months', 'event_espresso')
3507
-                            ),
3508
-                            array(
3509
-                                'default' => EE_Registry::instance()->CFG->messages->delete_threshold,
3510
-                                'html_label_text' => esc_html__('Cleanup of old messages:', 'event_espresso'),
3511
-                                'html_help_text' => esc_html__(
3512
-                                    'You can control how long a record of processed messages is kept via this option.',
3513
-                                    'event_espresso'
3514
-                                ),
3515
-                            )
3516
-                        ),
3517
-                        'update_settings'             => new EE_Submit_Input(
3518
-                            array(
3519
-                                'default'         => esc_html__('Update', 'event_espresso'),
3520
-                                'html_label_text' => '&nbsp'
3521
-                            )
3522
-                        )
3523
-                    )
3524
-                )
3525
-            )
3526
-        );
3527
-    }
3456
+	/**
3457
+	 * This generates and returns the form object for the global messages settings.
3458
+	 *
3459
+	 * @return EE_Form_Section_Proper
3460
+	 * @throws EE_Error
3461
+	 * @throws InvalidArgumentException
3462
+	 * @throws ReflectionException
3463
+	 * @throws InvalidDataTypeException
3464
+	 * @throws InvalidInterfaceException
3465
+	 */
3466
+	protected function _generate_global_settings_form()
3467
+	{
3468
+		EE_Registry::instance()->load_helper('HTML');
3469
+		/** @var EE_Network_Core_Config $network_config */
3470
+		$network_config = EE_Registry::instance()->NET_CFG->core;
3471
+        
3472
+		return new EE_Form_Section_Proper(
3473
+			array(
3474
+				'name'            => 'global_messages_settings',
3475
+				'html_id'         => 'global_messages_settings',
3476
+				'html_class'      => 'form-table',
3477
+				'layout_strategy' => new EE_Admin_Two_Column_Layout(),
3478
+				'subsections'     => apply_filters(
3479
+					'FHEE__Messages_Admin_Page__global_messages_settings_metabox_content__form_subsections',
3480
+					array(
3481
+						'do_messages_on_same_request' => new EE_Select_Input(
3482
+							array(
3483
+								true  => esc_html__("On the same request", "event_espresso"),
3484
+								false => esc_html__("On a separate request", "event_espresso")
3485
+							),
3486
+							array(
3487
+								'default'         => $network_config->do_messages_on_same_request,
3488
+								'html_label_text' => esc_html__(
3489
+									'Generate and send all messages:',
3490
+									'event_espresso'
3491
+								),
3492
+								'html_help_text'  => esc_html__(
3493
+									'By default the messages system uses a more efficient means of processing messages on separate requests and utilizes the wp-cron scheduling system.  This makes things execute faster for people registering for your events.  However, if the wp-cron system is disabled on your site and there is no alternative in place, then you can change this so messages are always executed on the same request.',
3494
+									'event_espresso'
3495
+								),
3496
+							)
3497
+						),
3498
+						'delete_threshold' => new EE_Select_Input(
3499
+							array(
3500
+								0 => esc_html__('Forever', 'event_espresso'),
3501
+								3 => esc_html__('3 Months', 'event_espresso'),
3502
+								6 => esc_html__('6 Months', 'event_espresso'),
3503
+								9 => esc_html__('9 Months', 'event_espresso'),
3504
+								12 => esc_html__('12 Months', 'event_espresso'),
3505
+								24 => esc_html__('24 Months', 'event_espresso'),
3506
+								36 => esc_html__('36 Months', 'event_espresso')
3507
+							),
3508
+							array(
3509
+								'default' => EE_Registry::instance()->CFG->messages->delete_threshold,
3510
+								'html_label_text' => esc_html__('Cleanup of old messages:', 'event_espresso'),
3511
+								'html_help_text' => esc_html__(
3512
+									'You can control how long a record of processed messages is kept via this option.',
3513
+									'event_espresso'
3514
+								),
3515
+							)
3516
+						),
3517
+						'update_settings'             => new EE_Submit_Input(
3518
+							array(
3519
+								'default'         => esc_html__('Update', 'event_espresso'),
3520
+								'html_label_text' => '&nbsp'
3521
+							)
3522
+						)
3523
+					)
3524
+				)
3525
+			)
3526
+		);
3527
+	}
3528 3528
 
3529 3529
 
3530
-    /**
3531
-     * This handles updating the global settings set on the admin page.
3532
-     *
3533
-     * @throws EE_Error
3534
-     * @throws InvalidDataTypeException
3535
-     * @throws InvalidInterfaceException
3536
-     * @throws InvalidArgumentException
3537
-     * @throws ReflectionException
3538
-     */
3539
-    protected function _update_global_settings()
3540
-    {
3541
-        /** @var EE_Network_Core_Config $network_config */
3542
-        $network_config = EE_Registry::instance()->NET_CFG->core;
3543
-        $messages_config = EE_Registry::instance()->CFG->messages;
3544
-        $form           = $this->_generate_global_settings_form();
3545
-        if ($form->was_submitted()) {
3546
-            $form->receive_form_submission();
3547
-            if ($form->is_valid()) {
3548
-                $valid_data = $form->valid_data();
3549
-                foreach ($valid_data as $property => $value) {
3550
-                    $setter = 'set_' . $property;
3551
-                    if (method_exists($network_config, $setter)) {
3552
-                        $network_config->{$setter}($value);
3553
-                    } else if (
3554
-                        property_exists($network_config, $property)
3555
-                        && $network_config->{$property} !== $value
3556
-                    ) {
3557
-                        $network_config->{$property} = $value;
3558
-                    } else if (
3559
-                        property_exists($messages_config, $property)
3560
-                        && $messages_config->{$property} !== $value
3561
-                    ) {
3562
-                        $messages_config->{$property} = $value;
3563
-                    }
3564
-                }
3565
-                //only update if the form submission was valid!
3566
-                EE_Registry::instance()->NET_CFG->update_config(true, false);
3567
-                EE_Registry::instance()->CFG->update_espresso_config();
3568
-                EE_Error::overwrite_success();
3569
-                EE_Error::add_success(__('Global message settings were updated', 'event_espresso'));
3570
-            }
3571
-        }
3572
-        $this->_redirect_after_action(0, '', '', array('action' => 'settings'), true);
3573
-    }
3530
+	/**
3531
+	 * This handles updating the global settings set on the admin page.
3532
+	 *
3533
+	 * @throws EE_Error
3534
+	 * @throws InvalidDataTypeException
3535
+	 * @throws InvalidInterfaceException
3536
+	 * @throws InvalidArgumentException
3537
+	 * @throws ReflectionException
3538
+	 */
3539
+	protected function _update_global_settings()
3540
+	{
3541
+		/** @var EE_Network_Core_Config $network_config */
3542
+		$network_config = EE_Registry::instance()->NET_CFG->core;
3543
+		$messages_config = EE_Registry::instance()->CFG->messages;
3544
+		$form           = $this->_generate_global_settings_form();
3545
+		if ($form->was_submitted()) {
3546
+			$form->receive_form_submission();
3547
+			if ($form->is_valid()) {
3548
+				$valid_data = $form->valid_data();
3549
+				foreach ($valid_data as $property => $value) {
3550
+					$setter = 'set_' . $property;
3551
+					if (method_exists($network_config, $setter)) {
3552
+						$network_config->{$setter}($value);
3553
+					} else if (
3554
+						property_exists($network_config, $property)
3555
+						&& $network_config->{$property} !== $value
3556
+					) {
3557
+						$network_config->{$property} = $value;
3558
+					} else if (
3559
+						property_exists($messages_config, $property)
3560
+						&& $messages_config->{$property} !== $value
3561
+					) {
3562
+						$messages_config->{$property} = $value;
3563
+					}
3564
+				}
3565
+				//only update if the form submission was valid!
3566
+				EE_Registry::instance()->NET_CFG->update_config(true, false);
3567
+				EE_Registry::instance()->CFG->update_espresso_config();
3568
+				EE_Error::overwrite_success();
3569
+				EE_Error::add_success(__('Global message settings were updated', 'event_espresso'));
3570
+			}
3571
+		}
3572
+		$this->_redirect_after_action(0, '', '', array('action' => 'settings'), true);
3573
+	}
3574 3574
 
3575 3575
 
3576
-    /**
3577
-     * this prepares the messenger tabs that can be dragged in and out of messenger boxes to activate/deactivate
3578
-     *
3579
-     * @param  array $tab_array This is an array of message type tab details used to generate the tabs
3580
-     * @return string html formatted tabs
3581
-     * @throws DomainException
3582
-     */
3583
-    protected function _get_mt_tabs($tab_array)
3584
-    {
3585
-        $tab_array = (array)$tab_array;
3586
-        $template  = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
3587
-        $tabs      = '';
3588
-        
3589
-        foreach ($tab_array as $tab) {
3590
-            $tabs .= EEH_Template::display_template($template, $tab, true);
3591
-        }
3592
-        
3593
-        return $tabs;
3594
-    }
3576
+	/**
3577
+	 * this prepares the messenger tabs that can be dragged in and out of messenger boxes to activate/deactivate
3578
+	 *
3579
+	 * @param  array $tab_array This is an array of message type tab details used to generate the tabs
3580
+	 * @return string html formatted tabs
3581
+	 * @throws DomainException
3582
+	 */
3583
+	protected function _get_mt_tabs($tab_array)
3584
+	{
3585
+		$tab_array = (array)$tab_array;
3586
+		$template  = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
3587
+		$tabs      = '';
3588
+        
3589
+		foreach ($tab_array as $tab) {
3590
+			$tabs .= EEH_Template::display_template($template, $tab, true);
3591
+		}
3592
+        
3593
+		return $tabs;
3594
+	}
3595 3595
 
3596 3596
 
3597
-    /**
3598
-     * This prepares the content of the messenger meta box admin settings
3599
-     *
3600
-     * @param  EE_messenger $messenger The messenger we're setting up content for
3601
-     * @return string html formatted content
3602
-     * @throws DomainException
3603
-     */
3604
-    protected function _get_messenger_box_content(EE_messenger $messenger)
3605
-    {
3597
+	/**
3598
+	 * This prepares the content of the messenger meta box admin settings
3599
+	 *
3600
+	 * @param  EE_messenger $messenger The messenger we're setting up content for
3601
+	 * @return string html formatted content
3602
+	 * @throws DomainException
3603
+	 */
3604
+	protected function _get_messenger_box_content(EE_messenger $messenger)
3605
+	{
3606 3606
         
3607
-        $fields                                         = $messenger->get_admin_settings_fields();
3608
-        $settings_template_args['template_form_fields'] = '';
3607
+		$fields                                         = $messenger->get_admin_settings_fields();
3608
+		$settings_template_args['template_form_fields'] = '';
3609 3609
         
3610
-        //is $messenger active?
3611
-        $settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name);
3610
+		//is $messenger active?
3611
+		$settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name);
3612 3612
         
3613 3613
         
3614
-        if ( ! empty($fields)) {
3614
+		if ( ! empty($fields)) {
3615 3615
             
3616
-            $existing_settings = $messenger->get_existing_admin_settings();
3616
+			$existing_settings = $messenger->get_existing_admin_settings();
3617 3617
             
3618
-            foreach ($fields as $fldname => $fldprops) {
3619
-                $field_id                       = $messenger->name . '-' . $fldname;
3620
-                $template_form_field[$field_id] = array(
3621
-                    'name'       => 'messenger_settings[' . $field_id . ']',
3622
-                    'label'      => $fldprops['label'],
3623
-                    'input'      => $fldprops['field_type'],
3624
-                    'type'       => $fldprops['value_type'],
3625
-                    'required'   => $fldprops['required'],
3626
-                    'validation' => $fldprops['validation'],
3627
-                    'value'      => isset($existing_settings[$field_id])
3628
-                        ? $existing_settings[$field_id]
3629
-                        : $fldprops['default'],
3630
-                    'css_class'  => '',
3631
-                    'format'     => $fldprops['format']
3632
-                );
3633
-            }
3618
+			foreach ($fields as $fldname => $fldprops) {
3619
+				$field_id                       = $messenger->name . '-' . $fldname;
3620
+				$template_form_field[$field_id] = array(
3621
+					'name'       => 'messenger_settings[' . $field_id . ']',
3622
+					'label'      => $fldprops['label'],
3623
+					'input'      => $fldprops['field_type'],
3624
+					'type'       => $fldprops['value_type'],
3625
+					'required'   => $fldprops['required'],
3626
+					'validation' => $fldprops['validation'],
3627
+					'value'      => isset($existing_settings[$field_id])
3628
+						? $existing_settings[$field_id]
3629
+						: $fldprops['default'],
3630
+					'css_class'  => '',
3631
+					'format'     => $fldprops['format']
3632
+				);
3633
+			}
3634 3634
             
3635 3635
             
3636
-            $settings_template_args['template_form_fields'] = ! empty($template_form_field)
3637
-                ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form')
3638
-                : '';
3639
-        }
3640
-        
3641
-        //we also need some hidden fields
3642
-        $settings_template_args['hidden_fields'] = array(
3643
-            'messenger_settings[messenger]' => array(
3644
-                'type'  => 'hidden',
3645
-                'value' => $messenger->name
3646
-            ),
3647
-            'type'                          => array(
3648
-                'type'  => 'hidden',
3649
-                'value' => 'messenger'
3650
-            )
3651
-        );
3652
-        
3653
-        //make sure any active message types that are existing are included in the hidden fields
3654
-        if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
3655
-            foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
3656
-                $settings_template_args['hidden_fields']['messenger_settings[message_types][' . $mt . ']'] = array(
3657
-                    'type'  => 'hidden',
3658
-                    'value' => $mt
3659
-                );
3660
-            }
3661
-        }
3662
-        $settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3663
-            $settings_template_args['hidden_fields'],
3664
-            'array'
3665
-        );
3666
-        $active = $this->_message_resource_manager->is_messenger_active($messenger->name);
3667
-        
3668
-        $settings_template_args['messenger']           = $messenger->name;
3669
-        $settings_template_args['description']         = $messenger->description;
3670
-        $settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
3671
-        
3672
-        
3673
-        $settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active(
3674
-            $messenger->name
3675
-        )
3676
-            ? $settings_template_args['show_hide_edit_form']
3677
-            : ' hidden';
3678
-        
3679
-        $settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields'])
3680
-            ? ' hidden'
3681
-            : $settings_template_args['show_hide_edit_form'];
3682
-        
3683
-        
3684
-        $settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
3685
-        $settings_template_args['nonce']         = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
3686
-        $settings_template_args['on_off_status'] = $active ? true : false;
3687
-        $template                                = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
3688
-        $content                                 = EEH_Template::display_template(
3689
-            $template,
3690
-            $settings_template_args,
3691
-            true
3692
-        );
3693
-        
3694
-        return $content;
3695
-    }
3636
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field)
3637
+				? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form')
3638
+				: '';
3639
+		}
3640
+        
3641
+		//we also need some hidden fields
3642
+		$settings_template_args['hidden_fields'] = array(
3643
+			'messenger_settings[messenger]' => array(
3644
+				'type'  => 'hidden',
3645
+				'value' => $messenger->name
3646
+			),
3647
+			'type'                          => array(
3648
+				'type'  => 'hidden',
3649
+				'value' => 'messenger'
3650
+			)
3651
+		);
3652
+        
3653
+		//make sure any active message types that are existing are included in the hidden fields
3654
+		if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
3655
+			foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
3656
+				$settings_template_args['hidden_fields']['messenger_settings[message_types][' . $mt . ']'] = array(
3657
+					'type'  => 'hidden',
3658
+					'value' => $mt
3659
+				);
3660
+			}
3661
+		}
3662
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
3663
+			$settings_template_args['hidden_fields'],
3664
+			'array'
3665
+		);
3666
+		$active = $this->_message_resource_manager->is_messenger_active($messenger->name);
3667
+        
3668
+		$settings_template_args['messenger']           = $messenger->name;
3669
+		$settings_template_args['description']         = $messenger->description;
3670
+		$settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
3671
+        
3672
+        
3673
+		$settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active(
3674
+			$messenger->name
3675
+		)
3676
+			? $settings_template_args['show_hide_edit_form']
3677
+			: ' hidden';
3678
+        
3679
+		$settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields'])
3680
+			? ' hidden'
3681
+			: $settings_template_args['show_hide_edit_form'];
3682
+        
3683
+        
3684
+		$settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
3685
+		$settings_template_args['nonce']         = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
3686
+		$settings_template_args['on_off_status'] = $active ? true : false;
3687
+		$template                                = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
3688
+		$content                                 = EEH_Template::display_template(
3689
+			$template,
3690
+			$settings_template_args,
3691
+			true
3692
+		);
3693
+        
3694
+		return $content;
3695
+	}
3696 3696
 
3697 3697
 
3698
-    /**
3699
-     * used by ajax on the messages settings page to activate|deactivate the messenger
3700
-     *
3701
-     * @throws DomainException
3702
-     * @throws EE_Error
3703
-     * @throws InvalidDataTypeException
3704
-     * @throws InvalidInterfaceException
3705
-     * @throws InvalidArgumentException
3706
-     * @throws ReflectionException
3707
-     */
3708
-    public function activate_messenger_toggle()
3709
-    {
3710
-        $success = true;
3711
-        $this->_prep_default_response_for_messenger_or_message_type_toggle();
3712
-        //let's check that we have required data
3713
-        if ( ! isset($this->_req_data['messenger'])) {
3714
-            EE_Error::add_error(
3715
-                esc_html__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3716
-                __FILE__,
3717
-                __FUNCTION__,
3718
-                __LINE__
3719
-            );
3720
-            $success = false;
3721
-        }
3722
-        
3723
-        //do a nonce check here since we're not arriving via a normal route
3724
-        $nonce     = isset($this->_req_data['activate_nonce'])
3725
-            ? sanitize_text_field($this->_req_data['activate_nonce'])
3726
-            : '';
3727
-        $nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
3728
-        
3729
-        $this->_verify_nonce($nonce, $nonce_ref);
3730
-        
3731
-        
3732
-        if ( ! isset($this->_req_data['status'])) {
3733
-            EE_Error::add_error(
3734
-                esc_html__(
3735
-                    'Messenger status needed to know whether activation or deactivation is happening. No status is given',
3736
-                    'event_espresso'
3737
-                ),
3738
-                __FILE__,
3739
-                __FUNCTION__,
3740
-                __LINE__
3741
-            );
3742
-            $success = false;
3743
-        }
3744
-        
3745
-        //do check to verify we have a valid status.
3746
-        $status = $this->_req_data['status'];
3747
-        
3748
-        if ($status !== 'off' && $status !== 'on') {
3749
-            EE_Error::add_error(
3750
-                sprintf(
3751
-                    esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
3752
-                    $this->_req_data['status']
3753
-                ),
3754
-                __FILE__,
3755
-                __FUNCTION__,
3756
-                __LINE__
3757
-            );
3758
-            $success = false;
3759
-        }
3760
-        
3761
-        if ($success) {
3762
-            //made it here?  Stop dawdling then!!
3763
-            $success = $status === 'off'
3764
-                ? $this->_deactivate_messenger($this->_req_data['messenger'])
3765
-                : $this->_activate_messenger($this->_req_data['messenger']);
3766
-        }
3767
-        
3768
-        $this->_template_args['success'] = $success;
3769
-        
3770
-        //no special instructions so let's just do the json return (which should automatically do all the special stuff).
3771
-        $this->_return_json();
3772
-        
3773
-    }
3698
+	/**
3699
+	 * used by ajax on the messages settings page to activate|deactivate the messenger
3700
+	 *
3701
+	 * @throws DomainException
3702
+	 * @throws EE_Error
3703
+	 * @throws InvalidDataTypeException
3704
+	 * @throws InvalidInterfaceException
3705
+	 * @throws InvalidArgumentException
3706
+	 * @throws ReflectionException
3707
+	 */
3708
+	public function activate_messenger_toggle()
3709
+	{
3710
+		$success = true;
3711
+		$this->_prep_default_response_for_messenger_or_message_type_toggle();
3712
+		//let's check that we have required data
3713
+		if ( ! isset($this->_req_data['messenger'])) {
3714
+			EE_Error::add_error(
3715
+				esc_html__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3716
+				__FILE__,
3717
+				__FUNCTION__,
3718
+				__LINE__
3719
+			);
3720
+			$success = false;
3721
+		}
3722
+        
3723
+		//do a nonce check here since we're not arriving via a normal route
3724
+		$nonce     = isset($this->_req_data['activate_nonce'])
3725
+			? sanitize_text_field($this->_req_data['activate_nonce'])
3726
+			: '';
3727
+		$nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
3728
+        
3729
+		$this->_verify_nonce($nonce, $nonce_ref);
3730
+        
3731
+        
3732
+		if ( ! isset($this->_req_data['status'])) {
3733
+			EE_Error::add_error(
3734
+				esc_html__(
3735
+					'Messenger status needed to know whether activation or deactivation is happening. No status is given',
3736
+					'event_espresso'
3737
+				),
3738
+				__FILE__,
3739
+				__FUNCTION__,
3740
+				__LINE__
3741
+			);
3742
+			$success = false;
3743
+		}
3744
+        
3745
+		//do check to verify we have a valid status.
3746
+		$status = $this->_req_data['status'];
3747
+        
3748
+		if ($status !== 'off' && $status !== 'on') {
3749
+			EE_Error::add_error(
3750
+				sprintf(
3751
+					esc_html__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
3752
+					$this->_req_data['status']
3753
+				),
3754
+				__FILE__,
3755
+				__FUNCTION__,
3756
+				__LINE__
3757
+			);
3758
+			$success = false;
3759
+		}
3760
+        
3761
+		if ($success) {
3762
+			//made it here?  Stop dawdling then!!
3763
+			$success = $status === 'off'
3764
+				? $this->_deactivate_messenger($this->_req_data['messenger'])
3765
+				: $this->_activate_messenger($this->_req_data['messenger']);
3766
+		}
3767
+        
3768
+		$this->_template_args['success'] = $success;
3769
+        
3770
+		//no special instructions so let's just do the json return (which should automatically do all the special stuff).
3771
+		$this->_return_json();
3772
+        
3773
+	}
3774 3774
 
3775 3775
 
3776
-    /**
3777
-     * used by ajax from the messages settings page to activate|deactivate a message type
3778
-     *
3779
-     * @throws DomainException
3780
-     * @throws EE_Error
3781
-     * @throws ReflectionException
3782
-     * @throws InvalidDataTypeException
3783
-     * @throws InvalidInterfaceException
3784
-     * @throws InvalidArgumentException
3785
-     */
3786
-    public function activate_mt_toggle()
3787
-    {
3788
-        $success = true;
3789
-        $this->_prep_default_response_for_messenger_or_message_type_toggle();
3790
-        
3791
-        //let's make sure we have the necessary data
3792
-        if ( ! isset($this->_req_data['message_type'])) {
3793
-            EE_Error::add_error(
3794
-                esc_html__('Message Type name needed to toggle activation. None given', 'event_espresso'),
3795
-                __FILE__,
3796
-                __FUNCTION__,
3797
-                __LINE__
3798
-            );
3799
-            $success = false;
3800
-        }
3801
-        
3802
-        if ( ! isset($this->_req_data['messenger'])) {
3803
-            EE_Error::add_error(
3804
-                esc_html__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3805
-                __FILE__,
3806
-                __FUNCTION__,
3807
-                __LINE__
3808
-            );
3809
-            $success = false;
3810
-        }
3811
-        
3812
-        if ( ! isset($this->_req_data['status'])) {
3813
-            EE_Error::add_error(
3814
-                esc_html__('Messenger status needed to know whether activation or deactivation is happening. No status is given',
3815
-                    'event_espresso'),
3816
-                __FILE__,
3817
-                __FUNCTION__,
3818
-                __LINE__
3819
-            );
3820
-            $success = false;
3821
-        }
3822
-        
3823
-        
3824
-        //do check to verify we have a valid status.
3825
-        $status = $this->_req_data['status'];
3826
-        
3827
-        if ($status !== 'activate' && $status !== 'deactivate') {
3828
-            EE_Error::add_error(
3829
-                sprintf(
3830
-                    esc_html__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'),
3831
-                    $this->_req_data['status']
3832
-                ),
3833
-                __FILE__,
3834
-                __FUNCTION__,
3835
-                __LINE__
3836
-            );
3837
-            $success = false;
3838
-        }
3839
-        
3840
-        
3841
-        //do a nonce check here since we're not arriving via a normal route
3842
-        $nonce     = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
3843
-        $nonce_ref = $this->_req_data['message_type'] . '_nonce';
3844
-        
3845
-        $this->_verify_nonce($nonce, $nonce_ref);
3846
-        
3847
-        if ($success) {
3848
-            //made it here? um, what are you waiting for then?
3849
-            $success = $status === 'deactivate'
3850
-                ? $this->_deactivate_message_type_for_messenger(
3851
-                    $this->_req_data['messenger'],
3852
-                    $this->_req_data['message_type']
3853
-                )
3854
-                : $this->_activate_message_type_for_messenger(
3855
-                    $this->_req_data['messenger'],
3856
-                    $this->_req_data['message_type']
3857
-                );
3858
-        }
3859
-        
3860
-        $this->_template_args['success'] = $success;
3861
-        $this->_return_json();
3862
-    }
3776
+	/**
3777
+	 * used by ajax from the messages settings page to activate|deactivate a message type
3778
+	 *
3779
+	 * @throws DomainException
3780
+	 * @throws EE_Error
3781
+	 * @throws ReflectionException
3782
+	 * @throws InvalidDataTypeException
3783
+	 * @throws InvalidInterfaceException
3784
+	 * @throws InvalidArgumentException
3785
+	 */
3786
+	public function activate_mt_toggle()
3787
+	{
3788
+		$success = true;
3789
+		$this->_prep_default_response_for_messenger_or_message_type_toggle();
3790
+        
3791
+		//let's make sure we have the necessary data
3792
+		if ( ! isset($this->_req_data['message_type'])) {
3793
+			EE_Error::add_error(
3794
+				esc_html__('Message Type name needed to toggle activation. None given', 'event_espresso'),
3795
+				__FILE__,
3796
+				__FUNCTION__,
3797
+				__LINE__
3798
+			);
3799
+			$success = false;
3800
+		}
3801
+        
3802
+		if ( ! isset($this->_req_data['messenger'])) {
3803
+			EE_Error::add_error(
3804
+				esc_html__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3805
+				__FILE__,
3806
+				__FUNCTION__,
3807
+				__LINE__
3808
+			);
3809
+			$success = false;
3810
+		}
3811
+        
3812
+		if ( ! isset($this->_req_data['status'])) {
3813
+			EE_Error::add_error(
3814
+				esc_html__('Messenger status needed to know whether activation or deactivation is happening. No status is given',
3815
+					'event_espresso'),
3816
+				__FILE__,
3817
+				__FUNCTION__,
3818
+				__LINE__
3819
+			);
3820
+			$success = false;
3821
+		}
3822
+        
3823
+        
3824
+		//do check to verify we have a valid status.
3825
+		$status = $this->_req_data['status'];
3826
+        
3827
+		if ($status !== 'activate' && $status !== 'deactivate') {
3828
+			EE_Error::add_error(
3829
+				sprintf(
3830
+					esc_html__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'),
3831
+					$this->_req_data['status']
3832
+				),
3833
+				__FILE__,
3834
+				__FUNCTION__,
3835
+				__LINE__
3836
+			);
3837
+			$success = false;
3838
+		}
3839
+        
3840
+        
3841
+		//do a nonce check here since we're not arriving via a normal route
3842
+		$nonce     = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
3843
+		$nonce_ref = $this->_req_data['message_type'] . '_nonce';
3844
+        
3845
+		$this->_verify_nonce($nonce, $nonce_ref);
3846
+        
3847
+		if ($success) {
3848
+			//made it here? um, what are you waiting for then?
3849
+			$success = $status === 'deactivate'
3850
+				? $this->_deactivate_message_type_for_messenger(
3851
+					$this->_req_data['messenger'],
3852
+					$this->_req_data['message_type']
3853
+				)
3854
+				: $this->_activate_message_type_for_messenger(
3855
+					$this->_req_data['messenger'],
3856
+					$this->_req_data['message_type']
3857
+				);
3858
+		}
3859
+        
3860
+		$this->_template_args['success'] = $success;
3861
+		$this->_return_json();
3862
+	}
3863 3863
 
3864 3864
 
3865
-    /**
3866
-     * Takes care of processing activating a messenger and preparing the appropriate response.
3867
-     *
3868
-     * @param string $messenger_name The name of the messenger being activated
3869
-     * @return bool
3870
-     * @throws DomainException
3871
-     * @throws EE_Error
3872
-     * @throws InvalidArgumentException
3873
-     * @throws ReflectionException
3874
-     * @throws InvalidDataTypeException
3875
-     * @throws InvalidInterfaceException
3876
-     */
3877
-    protected function _activate_messenger($messenger_name)
3878
-    {
3879
-        /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't */
3880
-        $active_messenger          = $this->_message_resource_manager->get_messenger($messenger_name);
3881
-        $message_types_to_activate = $active_messenger instanceof EE_Messenger
3882
-            ? $active_messenger->get_default_message_types()
3883
-            : array();
3884
-        
3885
-        //ensure is active
3886
-        $this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate);
3887
-        
3888
-        //set response_data for reload
3889
-        foreach ($message_types_to_activate as $message_type_name) {
3890
-            /** @var EE_message_type $message_type */
3891
-            $message_type = $this->_message_resource_manager->get_message_type($message_type_name);
3892
-            if ($this->_message_resource_manager->is_message_type_active_for_messenger(
3893
-                    $messenger_name,
3894
-                    $message_type_name
3895
-                )
3896
-                && $message_type instanceof EE_message_type
3897
-            ) {
3898
-                $this->_template_args['data']['active_mts'][] = $message_type_name;
3899
-                if ($message_type->get_admin_settings_fields()) {
3900
-                    $this->_template_args['data']['mt_reload'][] = $message_type_name;
3901
-                }
3902
-            }
3903
-        }
3904
-        
3905
-        //add success message for activating messenger
3906
-        return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger);
3907
-        
3908
-    }
3865
+	/**
3866
+	 * Takes care of processing activating a messenger and preparing the appropriate response.
3867
+	 *
3868
+	 * @param string $messenger_name The name of the messenger being activated
3869
+	 * @return bool
3870
+	 * @throws DomainException
3871
+	 * @throws EE_Error
3872
+	 * @throws InvalidArgumentException
3873
+	 * @throws ReflectionException
3874
+	 * @throws InvalidDataTypeException
3875
+	 * @throws InvalidInterfaceException
3876
+	 */
3877
+	protected function _activate_messenger($messenger_name)
3878
+	{
3879
+		/** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't */
3880
+		$active_messenger          = $this->_message_resource_manager->get_messenger($messenger_name);
3881
+		$message_types_to_activate = $active_messenger instanceof EE_Messenger
3882
+			? $active_messenger->get_default_message_types()
3883
+			: array();
3884
+        
3885
+		//ensure is active
3886
+		$this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate);
3887
+        
3888
+		//set response_data for reload
3889
+		foreach ($message_types_to_activate as $message_type_name) {
3890
+			/** @var EE_message_type $message_type */
3891
+			$message_type = $this->_message_resource_manager->get_message_type($message_type_name);
3892
+			if ($this->_message_resource_manager->is_message_type_active_for_messenger(
3893
+					$messenger_name,
3894
+					$message_type_name
3895
+				)
3896
+				&& $message_type instanceof EE_message_type
3897
+			) {
3898
+				$this->_template_args['data']['active_mts'][] = $message_type_name;
3899
+				if ($message_type->get_admin_settings_fields()) {
3900
+					$this->_template_args['data']['mt_reload'][] = $message_type_name;
3901
+				}
3902
+			}
3903
+		}
3904
+        
3905
+		//add success message for activating messenger
3906
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger);
3907
+        
3908
+	}
3909 3909
 
3910 3910
 
3911
-    /**
3912
-     * Takes care of processing deactivating a messenger and preparing the appropriate response.
3913
-     *
3914
-     * @param string $messenger_name The name of the messenger being activated
3915
-     * @return bool
3916
-     * @throws DomainException
3917
-     * @throws EE_Error
3918
-     * @throws InvalidArgumentException
3919
-     * @throws ReflectionException
3920
-     * @throws InvalidDataTypeException
3921
-     * @throws InvalidInterfaceException
3922
-     */
3923
-    protected function _deactivate_messenger($messenger_name)
3924
-    {
3925
-        /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't */
3926
-        $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3927
-        $this->_message_resource_manager->deactivate_messenger($messenger_name);
3928
-        
3929
-        return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger);
3930
-    }
3911
+	/**
3912
+	 * Takes care of processing deactivating a messenger and preparing the appropriate response.
3913
+	 *
3914
+	 * @param string $messenger_name The name of the messenger being activated
3915
+	 * @return bool
3916
+	 * @throws DomainException
3917
+	 * @throws EE_Error
3918
+	 * @throws InvalidArgumentException
3919
+	 * @throws ReflectionException
3920
+	 * @throws InvalidDataTypeException
3921
+	 * @throws InvalidInterfaceException
3922
+	 */
3923
+	protected function _deactivate_messenger($messenger_name)
3924
+	{
3925
+		/** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't */
3926
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3927
+		$this->_message_resource_manager->deactivate_messenger($messenger_name);
3928
+        
3929
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger);
3930
+	}
3931 3931
 
3932 3932
 
3933
-    /**
3934
-     * Takes care of processing activating a message type for a messenger and preparing the appropriate response.
3935
-     *
3936
-     * @param string $messenger_name    The name of the messenger the message type is being activated for.
3937
-     * @param string $message_type_name The name of the message type being activated for the messenger
3938
-     * @return bool
3939
-     * @throws DomainException
3940
-     * @throws EE_Error
3941
-     * @throws InvalidArgumentException
3942
-     * @throws ReflectionException
3943
-     * @throws InvalidDataTypeException
3944
-     * @throws InvalidInterfaceException
3945
-     */
3946
-    protected function _activate_message_type_for_messenger($messenger_name, $message_type_name)
3947
-    {
3948
-        /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't */
3949
-        $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3950
-        /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't */
3951
-        $message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name);
3952
-        
3953
-        //ensure is active
3954
-        $this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name);
3955
-        
3956
-        //set response for load
3957
-        if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name,
3958
-            $message_type_name)
3959
-        ) {
3960
-            $this->_template_args['data']['active_mts'][] = $message_type_name;
3961
-            if ($message_type_to_activate->get_admin_settings_fields()) {
3962
-                $this->_template_args['data']['mt_reload'][] = $message_type_name;
3963
-            }
3964
-        }
3965
-        
3966
-        return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger,
3967
-            $message_type_to_activate);
3968
-    }
3933
+	/**
3934
+	 * Takes care of processing activating a message type for a messenger and preparing the appropriate response.
3935
+	 *
3936
+	 * @param string $messenger_name    The name of the messenger the message type is being activated for.
3937
+	 * @param string $message_type_name The name of the message type being activated for the messenger
3938
+	 * @return bool
3939
+	 * @throws DomainException
3940
+	 * @throws EE_Error
3941
+	 * @throws InvalidArgumentException
3942
+	 * @throws ReflectionException
3943
+	 * @throws InvalidDataTypeException
3944
+	 * @throws InvalidInterfaceException
3945
+	 */
3946
+	protected function _activate_message_type_for_messenger($messenger_name, $message_type_name)
3947
+	{
3948
+		/** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't */
3949
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3950
+		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't */
3951
+		$message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name);
3952
+        
3953
+		//ensure is active
3954
+		$this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name);
3955
+        
3956
+		//set response for load
3957
+		if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name,
3958
+			$message_type_name)
3959
+		) {
3960
+			$this->_template_args['data']['active_mts'][] = $message_type_name;
3961
+			if ($message_type_to_activate->get_admin_settings_fields()) {
3962
+				$this->_template_args['data']['mt_reload'][] = $message_type_name;
3963
+			}
3964
+		}
3965
+        
3966
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger,
3967
+			$message_type_to_activate);
3968
+	}
3969 3969
 
3970 3970
 
3971
-    /**
3972
-     * Takes care of processing deactivating a message type for a messenger and preparing the appropriate response.
3973
-     *
3974
-     * @param string $messenger_name    The name of the messenger the message type is being deactivated for.
3975
-     * @param string $message_type_name The name of the message type being deactivated for the messenger
3976
-     * @return bool
3977
-     * @throws DomainException
3978
-     * @throws EE_Error
3979
-     * @throws InvalidArgumentException
3980
-     * @throws ReflectionException
3981
-     * @throws InvalidDataTypeException
3982
-     * @throws InvalidInterfaceException
3983
-     */
3984
-    protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name)
3985
-    {
3986
-        /** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't */
3987
-        $active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3988
-        /** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't */
3989
-        $message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name);
3990
-        $this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name);
3991
-        
3992
-        return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger,
3993
-            $message_type_to_deactivate);
3994
-    }
3971
+	/**
3972
+	 * Takes care of processing deactivating a message type for a messenger and preparing the appropriate response.
3973
+	 *
3974
+	 * @param string $messenger_name    The name of the messenger the message type is being deactivated for.
3975
+	 * @param string $message_type_name The name of the message type being deactivated for the messenger
3976
+	 * @return bool
3977
+	 * @throws DomainException
3978
+	 * @throws EE_Error
3979
+	 * @throws InvalidArgumentException
3980
+	 * @throws ReflectionException
3981
+	 * @throws InvalidDataTypeException
3982
+	 * @throws InvalidInterfaceException
3983
+	 */
3984
+	protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name)
3985
+	{
3986
+		/** @var EE_messenger $active_messenger This will be present because it can't be toggled if it isn't */
3987
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3988
+		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't */
3989
+		$message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name);
3990
+		$this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name);
3991
+        
3992
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger,
3993
+			$message_type_to_deactivate);
3994
+	}
3995 3995
     
3996 3996
     
3997
-    /**
3998
-     * This just initializes the defaults for activating messenger and message type responses.
3999
-     */
4000
-    protected function _prep_default_response_for_messenger_or_message_type_toggle()
4001
-    {
4002
-        $this->_template_args['data']['active_mts'] = array();
4003
-        $this->_template_args['data']['mt_reload']  = array();
4004
-    }
3997
+	/**
3998
+	 * This just initializes the defaults for activating messenger and message type responses.
3999
+	 */
4000
+	protected function _prep_default_response_for_messenger_or_message_type_toggle()
4001
+	{
4002
+		$this->_template_args['data']['active_mts'] = array();
4003
+		$this->_template_args['data']['mt_reload']  = array();
4004
+	}
4005 4005
 
4006 4006
 
4007
-    /**
4008
-     * Setup appropriate response for activating a messenger and/or message types
4009
-     *
4010
-     * @param EE_messenger         $messenger
4011
-     * @param EE_message_type|null $message_type
4012
-     * @return bool
4013
-     * @throws DomainException
4014
-     * @throws EE_Error
4015
-     * @throws InvalidArgumentException
4016
-     * @throws ReflectionException
4017
-     * @throws InvalidDataTypeException
4018
-     * @throws InvalidInterfaceException
4019
-     */
4020
-    protected function _setup_response_message_for_activating_messenger_with_message_types(
4021
-        $messenger,
4022
-        EE_Message_Type $message_type = null
4023
-    ) {
4024
-        //if $messenger isn't a valid messenger object then get out.
4025
-        if ( ! $messenger instanceof EE_Messenger) {
4026
-            EE_Error::add_error(
4027
-                esc_html__('The messenger being activated is not a valid messenger', 'event_espresso'),
4028
-                __FILE__,
4029
-                __FUNCTION__,
4030
-                __LINE__
4031
-            );
4007
+	/**
4008
+	 * Setup appropriate response for activating a messenger and/or message types
4009
+	 *
4010
+	 * @param EE_messenger         $messenger
4011
+	 * @param EE_message_type|null $message_type
4012
+	 * @return bool
4013
+	 * @throws DomainException
4014
+	 * @throws EE_Error
4015
+	 * @throws InvalidArgumentException
4016
+	 * @throws ReflectionException
4017
+	 * @throws InvalidDataTypeException
4018
+	 * @throws InvalidInterfaceException
4019
+	 */
4020
+	protected function _setup_response_message_for_activating_messenger_with_message_types(
4021
+		$messenger,
4022
+		EE_Message_Type $message_type = null
4023
+	) {
4024
+		//if $messenger isn't a valid messenger object then get out.
4025
+		if ( ! $messenger instanceof EE_Messenger) {
4026
+			EE_Error::add_error(
4027
+				esc_html__('The messenger being activated is not a valid messenger', 'event_espresso'),
4028
+				__FILE__,
4029
+				__FUNCTION__,
4030
+				__LINE__
4031
+			);
4032 4032
             
4033
-            return false;
4034
-        }
4035
-        //activated
4036
-        if ($this->_template_args['data']['active_mts']) {
4037
-            EE_Error::overwrite_success();
4038
-            //activated a message type with the messenger
4039
-            if ($message_type instanceof EE_message_type) {
4040
-                EE_Error::add_success(
4041
-                    sprintf(
4042
-                        esc_html__('%s message type has been successfully activated with the %s messenger', 'event_espresso'),
4043
-                        ucwords($message_type->label['singular']),
4044
-                        ucwords($messenger->label['singular'])
4045
-                    )
4046
-                );
4033
+			return false;
4034
+		}
4035
+		//activated
4036
+		if ($this->_template_args['data']['active_mts']) {
4037
+			EE_Error::overwrite_success();
4038
+			//activated a message type with the messenger
4039
+			if ($message_type instanceof EE_message_type) {
4040
+				EE_Error::add_success(
4041
+					sprintf(
4042
+						esc_html__('%s message type has been successfully activated with the %s messenger', 'event_espresso'),
4043
+						ucwords($message_type->label['singular']),
4044
+						ucwords($messenger->label['singular'])
4045
+					)
4046
+				);
4047 4047
                 
4048
-                //if message type was invoice then let's make sure we activate the invoice payment method.
4049
-                if ($message_type->name === 'invoice') {
4050
-                    EE_Registry::instance()->load_lib('Payment_Method_Manager');
4051
-                    $pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
4052
-                    if ($pm instanceof EE_Payment_Method) {
4053
-                        EE_Error::add_attention(
4054
-                            esc_html__(
4055
-                                '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.',
4056
-                                'event_espresso'
4057
-                            )
4058
-                        );
4059
-                    }
4060
-                }
4061
-                //just toggles the entire messenger
4062
-            } else {
4063
-                EE_Error::add_success(
4064
-                    sprintf(
4065
-                        esc_html__('%s messenger has been successfully activated', 'event_espresso'),
4066
-                        ucwords($messenger->label['singular'])
4067
-                    )
4068
-                );
4069
-            }
4048
+				//if message type was invoice then let's make sure we activate the invoice payment method.
4049
+				if ($message_type->name === 'invoice') {
4050
+					EE_Registry::instance()->load_lib('Payment_Method_Manager');
4051
+					$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
4052
+					if ($pm instanceof EE_Payment_Method) {
4053
+						EE_Error::add_attention(
4054
+							esc_html__(
4055
+								'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.',
4056
+								'event_espresso'
4057
+							)
4058
+						);
4059
+					}
4060
+				}
4061
+				//just toggles the entire messenger
4062
+			} else {
4063
+				EE_Error::add_success(
4064
+					sprintf(
4065
+						esc_html__('%s messenger has been successfully activated', 'event_espresso'),
4066
+						ucwords($messenger->label['singular'])
4067
+					)
4068
+				);
4069
+			}
4070 4070
             
4071
-            return true;
4071
+			return true;
4072 4072
             
4073
-            //possible error condition. This will happen when our active_mts data is empty because it is validated for actual active
4074
-            //message types after the activation process.  However its possible some messengers don't HAVE any default_message_types
4075
-            //in which case we just give a success message for the messenger being successfully activated.
4076
-        } else {
4077
-            if ( ! $messenger->get_default_message_types()) {
4078
-                //messenger doesn't have any default message types so still a success.
4079
-                EE_Error::add_success(
4080
-                    sprintf(
4081
-                        esc_html__('%s messenger was successfully activated.', 'event_espresso'),
4082
-                        ucwords($messenger->label['singular'])
4083
-                    )
4084
-                );
4073
+			//possible error condition. This will happen when our active_mts data is empty because it is validated for actual active
4074
+			//message types after the activation process.  However its possible some messengers don't HAVE any default_message_types
4075
+			//in which case we just give a success message for the messenger being successfully activated.
4076
+		} else {
4077
+			if ( ! $messenger->get_default_message_types()) {
4078
+				//messenger doesn't have any default message types so still a success.
4079
+				EE_Error::add_success(
4080
+					sprintf(
4081
+						esc_html__('%s messenger was successfully activated.', 'event_espresso'),
4082
+						ucwords($messenger->label['singular'])
4083
+					)
4084
+				);
4085 4085
                 
4086
-                return true;
4087
-            } else {
4088
-                EE_Error::add_error(
4089
-                    $message_type instanceof EE_message_type
4090
-                        ? sprintf(
4091
-                        esc_html__('%s message type was not successfully activated with the %s messenger', 'event_espresso'),
4092
-                        ucwords($message_type->label['singular']),
4093
-                        ucwords($messenger->label['singular'])
4094
-                    )
4095
-                        : sprintf(
4096
-                        esc_html__('%s messenger was not successfully activated', 'event_espresso'),
4097
-                        ucwords($messenger->label['singular'])
4098
-                    ),
4099
-                    __FILE__,
4100
-                    __FUNCTION__,
4101
-                    __LINE__
4102
-                );
4086
+				return true;
4087
+			} else {
4088
+				EE_Error::add_error(
4089
+					$message_type instanceof EE_message_type
4090
+						? sprintf(
4091
+						esc_html__('%s message type was not successfully activated with the %s messenger', 'event_espresso'),
4092
+						ucwords($message_type->label['singular']),
4093
+						ucwords($messenger->label['singular'])
4094
+					)
4095
+						: sprintf(
4096
+						esc_html__('%s messenger was not successfully activated', 'event_espresso'),
4097
+						ucwords($messenger->label['singular'])
4098
+					),
4099
+					__FILE__,
4100
+					__FUNCTION__,
4101
+					__LINE__
4102
+				);
4103 4103
                 
4104
-                return false;
4105
-            }
4106
-        }
4107
-    }
4104
+				return false;
4105
+			}
4106
+		}
4107
+	}
4108 4108
 
4109 4109
 
4110
-    /**
4111
-     * This sets up the appropriate response for deactivating a messenger and/or message type.
4112
-     *
4113
-     * @param EE_messenger         $messenger
4114
-     * @param EE_message_type|null $message_type
4115
-     * @return bool
4116
-     * @throws DomainException
4117
-     * @throws EE_Error
4118
-     * @throws InvalidArgumentException
4119
-     * @throws ReflectionException
4120
-     * @throws InvalidDataTypeException
4121
-     * @throws InvalidInterfaceException
4122
-     */
4123
-    protected function _setup_response_message_for_deactivating_messenger_with_message_types(
4124
-        $messenger,
4125
-        EE_message_type $message_type = null
4126
-    ) {
4127
-        EE_Error::overwrite_success();
4128
-        
4129
-        //if $messenger isn't a valid messenger object then get out.
4130
-        if ( ! $messenger instanceof EE_Messenger) {
4131
-            EE_Error::add_error(
4132
-                esc_html__('The messenger being deactivated is not a valid messenger', 'event_espresso'),
4133
-                __FILE__,
4134
-                __FUNCTION__,
4135
-                __LINE__
4136
-            );
4110
+	/**
4111
+	 * This sets up the appropriate response for deactivating a messenger and/or message type.
4112
+	 *
4113
+	 * @param EE_messenger         $messenger
4114
+	 * @param EE_message_type|null $message_type
4115
+	 * @return bool
4116
+	 * @throws DomainException
4117
+	 * @throws EE_Error
4118
+	 * @throws InvalidArgumentException
4119
+	 * @throws ReflectionException
4120
+	 * @throws InvalidDataTypeException
4121
+	 * @throws InvalidInterfaceException
4122
+	 */
4123
+	protected function _setup_response_message_for_deactivating_messenger_with_message_types(
4124
+		$messenger,
4125
+		EE_message_type $message_type = null
4126
+	) {
4127
+		EE_Error::overwrite_success();
4128
+        
4129
+		//if $messenger isn't a valid messenger object then get out.
4130
+		if ( ! $messenger instanceof EE_Messenger) {
4131
+			EE_Error::add_error(
4132
+				esc_html__('The messenger being deactivated is not a valid messenger', 'event_espresso'),
4133
+				__FILE__,
4134
+				__FUNCTION__,
4135
+				__LINE__
4136
+			);
4137 4137
             
4138
-            return false;
4139
-        }
4140
-        
4141
-        if ($message_type instanceof EE_message_type) {
4142
-            $message_type_name = $message_type->name;
4143
-            EE_Error::add_success(
4144
-                sprintf(
4145
-                    esc_html__('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'),
4146
-                    ucwords($message_type->label['singular']),
4147
-                    ucwords($messenger->label['singular'])
4148
-                )
4149
-            );
4150
-        } else {
4151
-            $message_type_name = '';
4152
-            EE_Error::add_success(
4153
-                sprintf(
4154
-                    esc_html__('%s messenger has been successfully deactivated.', 'event_espresso'),
4155
-                    ucwords($messenger->label['singular'])
4156
-                )
4157
-            );
4158
-        }
4159
-        
4160
-        //if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
4161
-        if ($messenger->name === 'html' || $message_type_name === 'invoice') {
4162
-            EE_Registry::instance()->load_lib('Payment_Method_Manager');
4163
-            $count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
4164
-            if ($count_updated > 0) {
4165
-                $msg = $message_type_name === 'invoice'
4166
-                    ? esc_html__(
4167
-                        'Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.',
4168
-                        'event_espresso'
4169
-                    )
4170
-                    : esc_html__(
4171
-                        '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.',
4172
-                        'event_espresso'
4173
-                    );
4174
-                EE_Error::add_attention($msg);
4175
-            }
4176
-        }
4177
-        
4178
-        return true;
4179
-    }
4138
+			return false;
4139
+		}
4140
+        
4141
+		if ($message_type instanceof EE_message_type) {
4142
+			$message_type_name = $message_type->name;
4143
+			EE_Error::add_success(
4144
+				sprintf(
4145
+					esc_html__('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'),
4146
+					ucwords($message_type->label['singular']),
4147
+					ucwords($messenger->label['singular'])
4148
+				)
4149
+			);
4150
+		} else {
4151
+			$message_type_name = '';
4152
+			EE_Error::add_success(
4153
+				sprintf(
4154
+					esc_html__('%s messenger has been successfully deactivated.', 'event_espresso'),
4155
+					ucwords($messenger->label['singular'])
4156
+				)
4157
+			);
4158
+		}
4159
+        
4160
+		//if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
4161
+		if ($messenger->name === 'html' || $message_type_name === 'invoice') {
4162
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
4163
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
4164
+			if ($count_updated > 0) {
4165
+				$msg = $message_type_name === 'invoice'
4166
+					? esc_html__(
4167
+						'Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.',
4168
+						'event_espresso'
4169
+					)
4170
+					: esc_html__(
4171
+						'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.',
4172
+						'event_espresso'
4173
+					);
4174
+				EE_Error::add_attention($msg);
4175
+			}
4176
+		}
4177
+        
4178
+		return true;
4179
+	}
4180 4180
 
4181 4181
 
4182
-    /**
4183
-     * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax)
4184
-     *
4185
-     * @throws DomainException
4186
-     */
4187
-    public function update_mt_form()
4188
-    {
4189
-        if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) {
4190
-            EE_Error::add_error(
4191
-                esc_html__('Require message type or messenger to send an updated form', 'event_espresso'),
4192
-                __FILE__,
4193
-                __FUNCTION__,
4194
-                __LINE__
4195
-            );
4196
-            $this->_return_json();
4197
-        }
4198
-        
4199
-        $message_types = $this->get_installed_message_types();
4200
-        
4201
-        $message_type = $message_types[$this->_req_data['message_type']];
4202
-        $messenger    = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
4203
-        
4204
-        $content                         = $this->_message_type_settings_content(
4205
-            $message_type,
4206
-            $messenger,
4207
-            true
4208
-        );
4209
-        $this->_template_args['success'] = true;
4210
-        $this->_template_args['content'] = $content;
4211
-        $this->_return_json();
4212
-    }
4182
+	/**
4183
+	 * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax)
4184
+	 *
4185
+	 * @throws DomainException
4186
+	 */
4187
+	public function update_mt_form()
4188
+	{
4189
+		if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) {
4190
+			EE_Error::add_error(
4191
+				esc_html__('Require message type or messenger to send an updated form', 'event_espresso'),
4192
+				__FILE__,
4193
+				__FUNCTION__,
4194
+				__LINE__
4195
+			);
4196
+			$this->_return_json();
4197
+		}
4198
+        
4199
+		$message_types = $this->get_installed_message_types();
4200
+        
4201
+		$message_type = $message_types[$this->_req_data['message_type']];
4202
+		$messenger    = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
4203
+        
4204
+		$content                         = $this->_message_type_settings_content(
4205
+			$message_type,
4206
+			$messenger,
4207
+			true
4208
+		);
4209
+		$this->_template_args['success'] = true;
4210
+		$this->_template_args['content'] = $content;
4211
+		$this->_return_json();
4212
+	}
4213 4213
     
4214 4214
     
4215
-    /**
4216
-     * this handles saving the settings for a messenger or message type
4217
-     *
4218
-     */
4219
-    public function save_settings()
4220
-    {
4221
-        if ( ! isset($this->_req_data['type'])) {
4222
-            EE_Error::add_error(
4223
-                esc_html__(
4224
-                    'Cannot save settings because type is unknown (messenger settings or messsage type settings?)',
4225
-                    'event_espresso'
4226
-                ),
4227
-                __FILE__,
4228
-                __FUNCTION__,
4229
-                __LINE__
4230
-            );
4231
-            $this->_template_args['error'] = true;
4232
-            $this->_return_json();
4233
-        }
4234
-        
4235
-        
4236
-        if ($this->_req_data['type'] === 'messenger') {
4237
-            //this should be an array.
4238
-            $settings  = $this->_req_data['messenger_settings'];
4239
-            $messenger = $settings['messenger'];
4240
-            //let's setup the settings data
4241
-            foreach ($settings as $key => $value) {
4242
-                switch ($key) {
4243
-                    case 'messenger' :
4244
-                        unset($settings['messenger']);
4245
-                        break;
4246
-                    case 'message_types' :
4247
-                        unset($settings['message_types']);
4248
-                        break;
4249
-                    default :
4250
-                        $settings[$key] = $value;
4251
-                        break;
4252
-                }
4253
-            }
4254
-            $this->_message_resource_manager->add_settings_for_messenger($messenger, $settings);
4255
-        } elseif ($this->_req_data['type'] === 'message_type') {
4256
-            $settings     = $this->_req_data['message_type_settings'];
4257
-            $messenger    = $settings['messenger'];
4258
-            $message_type = $settings['message_type'];
4215
+	/**
4216
+	 * this handles saving the settings for a messenger or message type
4217
+	 *
4218
+	 */
4219
+	public function save_settings()
4220
+	{
4221
+		if ( ! isset($this->_req_data['type'])) {
4222
+			EE_Error::add_error(
4223
+				esc_html__(
4224
+					'Cannot save settings because type is unknown (messenger settings or messsage type settings?)',
4225
+					'event_espresso'
4226
+				),
4227
+				__FILE__,
4228
+				__FUNCTION__,
4229
+				__LINE__
4230
+			);
4231
+			$this->_template_args['error'] = true;
4232
+			$this->_return_json();
4233
+		}
4234
+        
4235
+        
4236
+		if ($this->_req_data['type'] === 'messenger') {
4237
+			//this should be an array.
4238
+			$settings  = $this->_req_data['messenger_settings'];
4239
+			$messenger = $settings['messenger'];
4240
+			//let's setup the settings data
4241
+			foreach ($settings as $key => $value) {
4242
+				switch ($key) {
4243
+					case 'messenger' :
4244
+						unset($settings['messenger']);
4245
+						break;
4246
+					case 'message_types' :
4247
+						unset($settings['message_types']);
4248
+						break;
4249
+					default :
4250
+						$settings[$key] = $value;
4251
+						break;
4252
+				}
4253
+			}
4254
+			$this->_message_resource_manager->add_settings_for_messenger($messenger, $settings);
4255
+		} elseif ($this->_req_data['type'] === 'message_type') {
4256
+			$settings     = $this->_req_data['message_type_settings'];
4257
+			$messenger    = $settings['messenger'];
4258
+			$message_type = $settings['message_type'];
4259 4259
             
4260
-            foreach ($settings as $key => $value) {
4261
-                switch ($key) {
4262
-                    case 'messenger' :
4263
-                        unset($settings['messenger']);
4264
-                        break;
4265
-                    case 'message_type' :
4266
-                        unset($settings['message_type']);
4267
-                        break;
4268
-                    default :
4269
-                        $settings[$key] = $value;
4270
-                        break;
4271
-                }
4272
-            }
4260
+			foreach ($settings as $key => $value) {
4261
+				switch ($key) {
4262
+					case 'messenger' :
4263
+						unset($settings['messenger']);
4264
+						break;
4265
+					case 'message_type' :
4266
+						unset($settings['message_type']);
4267
+						break;
4268
+					default :
4269
+						$settings[$key] = $value;
4270
+						break;
4271
+				}
4272
+			}
4273 4273
             
4274
-            $this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings);
4275
-        }
4276
-        
4277
-        //okay we should have the data all setup.  Now we just update!
4278
-        $success = $this->_message_resource_manager->update_active_messengers_option();
4279
-        
4280
-        if ($success) {
4281
-            EE_Error::add_success(__('Settings updated', 'event_espresso'));
4282
-        } else {
4283
-            EE_Error::add_error(
4284
-                esc_html__(
4285
-                    'Settings did not get updated',
4286
-                    'event_espresso'
4287
-                ),
4288
-                __FILE__,
4289
-                __FUNCTION__,
4290
-                __LINE__
4291
-            );
4292
-        }
4293
-        
4294
-        $this->_template_args['success'] = $success;
4295
-        $this->_return_json();
4296
-    }
4274
+			$this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings);
4275
+		}
4276
+        
4277
+		//okay we should have the data all setup.  Now we just update!
4278
+		$success = $this->_message_resource_manager->update_active_messengers_option();
4279
+        
4280
+		if ($success) {
4281
+			EE_Error::add_success(__('Settings updated', 'event_espresso'));
4282
+		} else {
4283
+			EE_Error::add_error(
4284
+				esc_html__(
4285
+					'Settings did not get updated',
4286
+					'event_espresso'
4287
+				),
4288
+				__FILE__,
4289
+				__FUNCTION__,
4290
+				__LINE__
4291
+			);
4292
+		}
4293
+        
4294
+		$this->_template_args['success'] = $success;
4295
+		$this->_return_json();
4296
+	}
4297 4297
     
4298 4298
     
4299 4299
     
4300 4300
     
4301
-    /**  EE MESSAGE PROCESSING ACTIONS **/
4301
+	/**  EE MESSAGE PROCESSING ACTIONS **/
4302 4302
     
4303 4303
     
4304
-    /**
4305
-     * This immediately generates any EE_Message ID's that are selected that are EEM_Message::status_incomplete
4306
-     * However, this does not send immediately, it just queues for sending.
4307
-     *
4308
-     * @since 4.9.0
4309
-     */
4310
-    protected function _generate_now()
4311
-    {
4312
-        $msg_ids = $this->_get_msg_ids_from_request();
4313
-        EED_Messages::generate_now($msg_ids);
4314
-        $this->_redirect_after_action(false, '', '', array(), true);
4315
-    }
4304
+	/**
4305
+	 * This immediately generates any EE_Message ID's that are selected that are EEM_Message::status_incomplete
4306
+	 * However, this does not send immediately, it just queues for sending.
4307
+	 *
4308
+	 * @since 4.9.0
4309
+	 */
4310
+	protected function _generate_now()
4311
+	{
4312
+		$msg_ids = $this->_get_msg_ids_from_request();
4313
+		EED_Messages::generate_now($msg_ids);
4314
+		$this->_redirect_after_action(false, '', '', array(), true);
4315
+	}
4316 4316
     
4317 4317
     
4318
-    /**
4319
-     * This immediately generates AND sends any EE_Message's selected that are EEM_Message::status_incomplete or that
4320
-     * are EEM_Message::status_resend or EEM_Message::status_idle
4321
-     *
4322
-     * @since 4.9.0
4323
-     *
4324
-     */
4325
-    protected function _generate_and_send_now()
4326
-    {
4327
-        $this->_generate_now();
4328
-        $this->_send_now();
4329
-        $this->_redirect_after_action(false, '', '', array(), true);
4330
-    }
4318
+	/**
4319
+	 * This immediately generates AND sends any EE_Message's selected that are EEM_Message::status_incomplete or that
4320
+	 * are EEM_Message::status_resend or EEM_Message::status_idle
4321
+	 *
4322
+	 * @since 4.9.0
4323
+	 *
4324
+	 */
4325
+	protected function _generate_and_send_now()
4326
+	{
4327
+		$this->_generate_now();
4328
+		$this->_send_now();
4329
+		$this->_redirect_after_action(false, '', '', array(), true);
4330
+	}
4331 4331
     
4332 4332
     
4333
-    /**
4334
-     * This queues any EEM_Message::status_sent EE_Message ids in the request for resending.
4335
-     *
4336
-     * @since 4.9.0
4337
-     */
4338
-    protected function _queue_for_resending()
4339
-    {
4340
-        $msg_ids = $this->_get_msg_ids_from_request();
4341
-        EED_Messages::queue_for_resending($msg_ids);
4342
-        $this->_redirect_after_action(false, '', '', array(), true);
4343
-    }
4333
+	/**
4334
+	 * This queues any EEM_Message::status_sent EE_Message ids in the request for resending.
4335
+	 *
4336
+	 * @since 4.9.0
4337
+	 */
4338
+	protected function _queue_for_resending()
4339
+	{
4340
+		$msg_ids = $this->_get_msg_ids_from_request();
4341
+		EED_Messages::queue_for_resending($msg_ids);
4342
+		$this->_redirect_after_action(false, '', '', array(), true);
4343
+	}
4344 4344
     
4345 4345
     
4346
-    /**
4347
-     *  This sends immediately any EEM_Message::status_idle or EEM_Message::status_resend messages in the queue
4348
-     *
4349
-     * @since 4.9.0
4350
-     */
4351
-    protected function _send_now()
4352
-    {
4353
-        $msg_ids = $this->_get_msg_ids_from_request();
4354
-        EED_Messages::send_now($msg_ids);
4355
-        $this->_redirect_after_action(false, '', '', array(), true);
4356
-    }
4346
+	/**
4347
+	 *  This sends immediately any EEM_Message::status_idle or EEM_Message::status_resend messages in the queue
4348
+	 *
4349
+	 * @since 4.9.0
4350
+	 */
4351
+	protected function _send_now()
4352
+	{
4353
+		$msg_ids = $this->_get_msg_ids_from_request();
4354
+		EED_Messages::send_now($msg_ids);
4355
+		$this->_redirect_after_action(false, '', '', array(), true);
4356
+	}
4357 4357
 
4358 4358
 
4359
-    /**
4360
-     * Deletes EE_messages for IDs in the request.
4361
-     *
4362
-     * @since 4.9.0
4363
-     * @throws EE_Error
4364
-     * @throws InvalidDataTypeException
4365
-     * @throws InvalidInterfaceException
4366
-     * @throws InvalidArgumentException
4367
-     */
4368
-    protected function _delete_ee_messages()
4369
-    {
4370
-        $msg_ids       = $this->_get_msg_ids_from_request();
4371
-        $deleted_count = 0;
4372
-        foreach ($msg_ids as $msg_id) {
4373
-            if (EEM_Message::instance()->delete_by_ID($msg_id)) {
4374
-                $deleted_count++;
4375
-            }
4376
-        }
4377
-        if ($deleted_count) {
4378
-            $this->_redirect_after_action(
4379
-                true,
4380
-                _n('message', 'messages', $deleted_count, 'event_espresso'),
4381
-                esc_html__('deleted', 'event_espresso')
4382
-            );
4383
-        } else {
4384
-            EE_Error::add_error(
4385
-                _n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'),
4386
-                __FILE__, __FUNCTION__, __LINE__
4387
-            );
4388
-            $this->_redirect_after_action(false, '', '', array(), true);
4389
-        }
4390
-    }
4359
+	/**
4360
+	 * Deletes EE_messages for IDs in the request.
4361
+	 *
4362
+	 * @since 4.9.0
4363
+	 * @throws EE_Error
4364
+	 * @throws InvalidDataTypeException
4365
+	 * @throws InvalidInterfaceException
4366
+	 * @throws InvalidArgumentException
4367
+	 */
4368
+	protected function _delete_ee_messages()
4369
+	{
4370
+		$msg_ids       = $this->_get_msg_ids_from_request();
4371
+		$deleted_count = 0;
4372
+		foreach ($msg_ids as $msg_id) {
4373
+			if (EEM_Message::instance()->delete_by_ID($msg_id)) {
4374
+				$deleted_count++;
4375
+			}
4376
+		}
4377
+		if ($deleted_count) {
4378
+			$this->_redirect_after_action(
4379
+				true,
4380
+				_n('message', 'messages', $deleted_count, 'event_espresso'),
4381
+				esc_html__('deleted', 'event_espresso')
4382
+			);
4383
+		} else {
4384
+			EE_Error::add_error(
4385
+				_n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'),
4386
+				__FILE__, __FUNCTION__, __LINE__
4387
+			);
4388
+			$this->_redirect_after_action(false, '', '', array(), true);
4389
+		}
4390
+	}
4391 4391
     
4392 4392
     
4393
-    /**
4394
-     *  This looks for 'MSG_ID' key in the request and returns an array of MSG_ID's if present.
4395
-     * @since 4.9.0
4396
-     * @return array
4397
-     */
4398
-    protected function _get_msg_ids_from_request()
4399
-    {
4400
-        if ( ! isset($this->_req_data['MSG_ID'])) {
4401
-            return array();
4402
-        }
4403
-        
4404
-        return is_array($this->_req_data['MSG_ID'])
4405
-            ? array_keys($this->_req_data['MSG_ID'])
4406
-            : array($this->_req_data['MSG_ID']);
4407
-    }
4393
+	/**
4394
+	 *  This looks for 'MSG_ID' key in the request and returns an array of MSG_ID's if present.
4395
+	 * @since 4.9.0
4396
+	 * @return array
4397
+	 */
4398
+	protected function _get_msg_ids_from_request()
4399
+	{
4400
+		if ( ! isset($this->_req_data['MSG_ID'])) {
4401
+			return array();
4402
+		}
4403
+        
4404
+		return is_array($this->_req_data['MSG_ID'])
4405
+			? array_keys($this->_req_data['MSG_ID'])
4406
+			: array($this->_req_data['MSG_ID']);
4407
+	}
4408 4408
 }
Please login to merge, or discard this patch.
core/db_classes/EE_Message_Template_Group.class.php 2 patches
Indentation   +482 added lines, -482 removed lines patch added patch discarded remove patch
@@ -15,486 +15,486 @@
 block discarded – undo
15 15
 class EE_Message_Template_Group extends EE_Soft_Delete_Base_Class
16 16
 {
17 17
 
18
-    /**
19
-     * Extra Meta key prefix for whether a given context for this message tmeplate group is active or not.
20
-     */
21
-    const ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX = 'active_context_';
22
-
23
-    /**
24
-     * @param array  $props_n_values
25
-     * @param string $timezone
26
-     * @return EE_Message_Template_Group|mixed
27
-     * @throws EE_Error
28
-     */
29
-    public static function new_instance($props_n_values = array(), $timezone = '')
30
-    {
31
-        $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
32
-        return $has_object ? $has_object : new self($props_n_values, false, $timezone);
33
-    }
34
-
35
-
36
-    /**
37
-     * @param array  $props_n_values
38
-     * @param string $timezone
39
-     * @return EE_Message_Template_Group
40
-     */
41
-    public static function new_instance_from_db($props_n_values = array(), $timezone = '')
42
-    {
43
-        return new self($props_n_values, true, $timezone);
44
-    }
45
-
46
-
47
-    /**
48
-     * @param bool $message_type
49
-     * @throws EE_Error
50
-     */
51
-    public function set_message_type($message_type = false)
52
-    {
53
-        if (! $message_type) {
54
-            throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
55
-        }
56
-        $this->set('MTP_message_type', $message_type);
57
-    }
58
-
59
-
60
-    /**
61
-     * @param bool $messenger
62
-     * @throws EE_Error
63
-     */
64
-    public function set_messenger($messenger = false)
65
-    {
66
-        if (! $messenger) {
67
-            throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
68
-        }
69
-        $this->set('MTP_messenger', $messenger);
70
-    }
71
-
72
-
73
-    /**
74
-     * @param bool $GRP_ID
75
-     * @throws EE_Error
76
-     */
77
-    public function set_group_template_id($GRP_ID = false)
78
-    {
79
-        if (! $GRP_ID) {
80
-            throw new EE_Error(
81
-                esc_html__(
82
-                    'Missing required value for the message template group id',
83
-                    'event_espresso'
84
-                )
85
-            );
86
-        }
87
-        $this->set('GRP_ID', $GRP_ID);
88
-    }
89
-
90
-
91
-    /**
92
-     * get Group ID
93
-     *
94
-     * @access public
95
-     * @return int
96
-     * @throws EE_Error
97
-     */
98
-    public function GRP_ID()
99
-    {
100
-        return $this->get('GRP_ID');
101
-    }
102
-
103
-
104
-    /**
105
-     * get User ID
106
-     *
107
-     * @access public
108
-     * @return int
109
-     * @throws EE_Error
110
-     */
111
-    public function user()
112
-    {
113
-        $user_id = $this->get('MTP_user_id');
114
-        return empty($user_id) ? get_current_user_id() : $user_id;
115
-    }
116
-
117
-
118
-    /**
119
-     * Wrapper for the user function() (preserve backward compat)
120
-     *
121
-     * @since  4.5.0
122
-     * @return int
123
-     * @throws EE_Error
124
-     */
125
-    public function wp_user()
126
-    {
127
-        return $this->user();
128
-    }
129
-
130
-
131
-    /**
132
-     * This simply returns a count of all related events to this message template group
133
-     *
134
-     * @return int
135
-     */
136
-    public function count_events()
137
-    {
138
-        return $this->count_related('Event');
139
-    }
140
-
141
-
142
-    /**
143
-     * returns the name saved in the db for this template
144
-     *
145
-     * @return string
146
-     * @throws EE_Error
147
-     */
148
-    public function name()
149
-    {
150
-        return $this->get('MTP_name');
151
-    }
152
-
153
-
154
-    /**
155
-     * Returns the description saved in the db for this template group
156
-     *
157
-     * @return string
158
-     * @throws EE_Error
159
-     */
160
-    public function description()
161
-    {
162
-        return $this->get('MTP_description');
163
-    }
164
-
165
-
166
-    /**
167
-     * returns all related EE_Message_Template objects
168
-     *
169
-     * @param  array $query_params like EEM_Base::get_all()
170
-     * @return EE_Message_Template[]
171
-     * @throws EE_Error
172
-     */
173
-    public function message_templates($query_params = array())
174
-    {
175
-        return $this->get_many_related('Message_Template', $query_params);
176
-    }
177
-
178
-
179
-    /**
180
-     * get Message Messenger
181
-     *
182
-     * @access public
183
-     * @return string
184
-     * @throws EE_Error
185
-     */
186
-    public function messenger()
187
-    {
188
-        return $this->get('MTP_messenger');
189
-    }
190
-
191
-
192
-    /**
193
-     * get Message Messenger OBJECT
194
-     * If an attempt to get the corresponding messenger object fails, then we set this message
195
-     * template group to inactive, and save to db.  Then return null so client code can handle
196
-     * appropriately.
197
-     *
198
-     * @return EE_messenger
199
-     * @throws EE_Error
200
-     */
201
-    public function messenger_obj()
202
-    {
203
-        $messenger = $this->messenger();
204
-        try {
205
-            $messenger = EEH_MSG_Template::messenger_obj($messenger);
206
-        } catch (EE_Error $e) {
207
-            //if an exception was thrown then let's deactivate this message template group because it means there is no
208
-            // class for this messenger in this group.
209
-            $this->set('MTP_is_active', false);
210
-            $this->save();
211
-            return null;
212
-        }
213
-        return $messenger;
214
-    }
215
-
216
-
217
-    /**
218
-     * get Message Type
219
-     *
220
-     * @access public
221
-     * @return string
222
-     * @throws EE_Error
223
-     */
224
-    public function message_type()
225
-    {
226
-        return $this->get('MTP_message_type');
227
-    }
228
-
229
-
230
-    /**
231
-     * get Message type OBJECT
232
-     * If an attempt to get the corresponding message type object fails, then we set this message
233
-     * template group to inactive, and save to db.  Then return null so client code can handle
234
-     * appropriately.
235
-     *
236
-     * @throws EE_Error
237
-     * @return EE_message_type|false if exception thrown.
238
-     */
239
-    public function message_type_obj()
240
-    {
241
-        $message_type = $this->message_type();
242
-        try {
243
-            $message_type = EEH_MSG_Template::message_type_obj($message_type);
244
-        } catch (EE_Error $e) {
245
-            //if an exception was thrown then let's deactivate this message template group because it means there is no
246
-            // class for the message type in this group.
247
-            $this->set('MTP_is_active', false);
248
-            $this->save();
249
-            return null;
250
-        }
251
-        return $message_type;
252
-    }
253
-
254
-
255
-    /**
256
-     * @return array
257
-     * @throws EE_Error
258
-     */
259
-    public function contexts_config()
260
-    {
261
-        return $this->message_type_obj()->get_contexts();
262
-    }
263
-
264
-
265
-    /**
266
-     * This returns the context_label for contexts as set in the message type object
267
-     * Note this is an array with singular and plural keys
268
-     *
269
-     * @access public
270
-     * @return array labels for "context"
271
-     * @throws EE_Error
272
-     */
273
-    public function context_label()
274
-    {
275
-        $obj = $this->message_type_obj();
276
-        return $obj->get_context_label();
277
-    }
278
-
279
-
280
-    /**
281
-     * This returns an array of EE_Message_Template objects indexed by context and field.
282
-     *
283
-     * @return array ()
284
-     * @throws EE_Error
285
-     */
286
-    public function context_templates()
287
-    {
288
-        $mtps_arr = array();
289
-        $mtps     = $this->get_many_related('Message_Template');
290
-        if (empty($mtps)) {
291
-            return array();
292
-        }
293
-        //note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
294
-        foreach ($mtps as $mtp) {
295
-            $mtps_arr[$mtp->get('MTP_context')][$mtp->get('MTP_template_field')] = $mtp;
296
-        }
297
-        return $mtps_arr;
298
-    }
299
-
300
-
301
-    /**
302
-     * this returns if the template group this template belongs to is global
303
-     *
304
-     * @return bool true if it is, false if it isn't
305
-     * @throws EE_Error
306
-     */
307
-    public function is_global()
308
-    {
309
-        return $this->get('MTP_is_global');
310
-    }
311
-
312
-
313
-    /**
314
-     * this returns if the template group this template belongs to is active (i.e. turned "on" or not)
315
-     *
316
-     * @return bool true if it is, false if it isn't
317
-     * @throws EE_Error
318
-     */
319
-    public function is_active()
320
-    {
321
-        return $this->get('MTP_is_active');
322
-    }
323
-
324
-
325
-    /**
326
-     * This will return an array of shortcodes => labels from the messenger and message_type objects associated with
327
-     * this template.
328
-     *
329
-     * @since 4.3.0
330
-     * @uses  EEH_MSG_Template::get_shortcodes()
331
-     * @param string $context what context we're going to return shortcodes for
332
-     * @param array  $fields  what fields we're returning valid shortcodes for.  If empty then we assume all fields are
333
-     *                        to be returned.
334
-     * @param bool   $merged  If TRUE then we don't return shortcodes indexed by field but instead an array of the
335
-     *                        unique shortcodes for all the given (or all) fields.
336
-     * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no
337
-     *                        shortcodes found.
338
-     * @throws EE_Error
339
-     */
340
-    public function get_shortcodes($context, $fields = array(), $merged = false)
341
-    {
342
-        $messenger    = $this->messenger();
343
-        $message_type = $this->message_type();
344
-        return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged);
345
-    }
346
-
347
-
348
-    /**
349
-     * This just gets the template pack name assigned to this message template group.  If it's not set, then we just
350
-     * use the default template pack.
351
-     *
352
-     * @since 4.5.0
353
-     * @return string
354
-     * @throws EE_Error
355
-     */
356
-    public function get_template_pack_name()
357
-    {
358
-        return $this->get_extra_meta('MTP_template_pack', true, 'default');
359
-    }
360
-
361
-
362
-    /**
363
-     * This returns the specific template pack object referenced by the template pack name attached to this message
364
-     * template group.  If no template pack is assigned then the default template pack is retrieved.
365
-     *
366
-     * @since 4.5.0
367
-     * @return EE_Messages_Template_Pack
368
-     * @throws EE_Error
369
-     * @throws InvalidArgumentException
370
-     * @throws ReflectionException
371
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
372
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
373
-     */
374
-    public function get_template_pack()
375
-    {
376
-        $pack_name = $this->get_template_pack_name();
377
-        EE_Registry::instance()->load_helper('MSG_Template');
378
-        return EEH_MSG_Template::get_template_pack($pack_name);
379
-    }
380
-
381
-
382
-    /**
383
-     * This retrieves the template variation assigned to this message template group.  If it's not set, then we just
384
-     * use the default template variation.
385
-     *
386
-     * @since 4.5.0
387
-     * @return string
388
-     * @throws EE_Error
389
-     */
390
-    public function get_template_pack_variation()
391
-    {
392
-        return $this->get_extra_meta('MTP_variation', true, 'default');
393
-    }
394
-
395
-
396
-    /**
397
-     * This just sets the template pack name attached to this message template group.
398
-     *
399
-     * @since 4.5.0
400
-     * @param string $template_pack_name What message template pack is assigned.
401
-     * @return int
402
-     * @throws EE_Error
403
-     */
404
-    public function set_template_pack_name($template_pack_name)
405
-    {
406
-        return $this->update_extra_meta('MTP_template_pack', $template_pack_name);
407
-    }
408
-
409
-
410
-    /**
411
-     * This just sets the template pack variation attached to this message template group.
412
-     *
413
-     * @since 4.5.0
414
-     * @param string $variation What variation is being set on the message template group.
415
-     * @return int
416
-     * @throws EE_Error
417
-     */
418
-    public function set_template_pack_variation($variation)
419
-    {
420
-        return $this->update_extra_meta('MTP_variation', $variation);
421
-    }
422
-
423
-
424
-    /**
425
-     * Deactivates the given context.
426
-     *
427
-     * @param $context
428
-     * @return bool|int
429
-     * @throws EE_Error
430
-     * @throws InvalidIdentifierException
431
-     */
432
-    public function deactivate_context($context)
433
-    {
434
-        $this->validate_context($context);
435
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
436
-    }
437
-
438
-
439
-    /**
440
-     * Activates the given context.
441
-     *
442
-     * @param $context
443
-     * @return bool|int
444
-     * @throws EE_Error
445
-     * @throws InvalidIdentifierException
446
-     */
447
-    public function activate_context($context)
448
-    {
449
-        $this->validate_context($context);
450
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
451
-    }
452
-
453
-
454
-    /**
455
-     * Returns whether the context is active or not.
456
-     * Note, this will default to true if the extra meta record doesn't exist.
457
-     * Also, this does NOT account for whether the "To" field is empty or not. Some messengers may allow the "To" field
458
-     * to be empty (@see EE_Messenger::allow_empty_to_field()) so an empty "To" field is not always an indicator of
459
-     * whether a context is "active" or not.
460
-     *
461
-     * @param $context
462
-     * @return bool
463
-     * @throws EE_Error
464
-     * @throws InvalidIdentifierException
465
-     */
466
-    public function is_context_active($context)
467
-    {
468
-        $this->validate_context($context);
469
-        return filter_var(
470
-            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
471
-            FILTER_VALIDATE_BOOLEAN
472
-        );
473
-    }
474
-
475
-
476
-    /**
477
-     * Validates the incoming context to verify it matches a registered context for the related message type.
478
-     * @param string $context
479
-     * @throws EE_Error
480
-     * @throws InvalidIdentifierException
481
-     */
482
-    public function validate_context($context)
483
-    {
484
-        $contexts = $this->contexts_config();
485
-        if (! isset($contexts[$context])) {
486
-            throw new InvalidIdentifierException(
487
-                '',
488
-                '',
489
-                sprintf(
490
-                    esc_html__(
491
-                        'An invalid string identifying a context was provided.  "%1$s" was received, and one of "%2$s" was expected.',
492
-                        'event_espresso'
493
-                    ),
494
-                    $context,
495
-                    implode(',', array_keys($contexts))
496
-                )
497
-            );
498
-        }
499
-    }
18
+	/**
19
+	 * Extra Meta key prefix for whether a given context for this message tmeplate group is active or not.
20
+	 */
21
+	const ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX = 'active_context_';
22
+
23
+	/**
24
+	 * @param array  $props_n_values
25
+	 * @param string $timezone
26
+	 * @return EE_Message_Template_Group|mixed
27
+	 * @throws EE_Error
28
+	 */
29
+	public static function new_instance($props_n_values = array(), $timezone = '')
30
+	{
31
+		$has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone);
32
+		return $has_object ? $has_object : new self($props_n_values, false, $timezone);
33
+	}
34
+
35
+
36
+	/**
37
+	 * @param array  $props_n_values
38
+	 * @param string $timezone
39
+	 * @return EE_Message_Template_Group
40
+	 */
41
+	public static function new_instance_from_db($props_n_values = array(), $timezone = '')
42
+	{
43
+		return new self($props_n_values, true, $timezone);
44
+	}
45
+
46
+
47
+	/**
48
+	 * @param bool $message_type
49
+	 * @throws EE_Error
50
+	 */
51
+	public function set_message_type($message_type = false)
52
+	{
53
+		if (! $message_type) {
54
+			throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
55
+		}
56
+		$this->set('MTP_message_type', $message_type);
57
+	}
58
+
59
+
60
+	/**
61
+	 * @param bool $messenger
62
+	 * @throws EE_Error
63
+	 */
64
+	public function set_messenger($messenger = false)
65
+	{
66
+		if (! $messenger) {
67
+			throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
68
+		}
69
+		$this->set('MTP_messenger', $messenger);
70
+	}
71
+
72
+
73
+	/**
74
+	 * @param bool $GRP_ID
75
+	 * @throws EE_Error
76
+	 */
77
+	public function set_group_template_id($GRP_ID = false)
78
+	{
79
+		if (! $GRP_ID) {
80
+			throw new EE_Error(
81
+				esc_html__(
82
+					'Missing required value for the message template group id',
83
+					'event_espresso'
84
+				)
85
+			);
86
+		}
87
+		$this->set('GRP_ID', $GRP_ID);
88
+	}
89
+
90
+
91
+	/**
92
+	 * get Group ID
93
+	 *
94
+	 * @access public
95
+	 * @return int
96
+	 * @throws EE_Error
97
+	 */
98
+	public function GRP_ID()
99
+	{
100
+		return $this->get('GRP_ID');
101
+	}
102
+
103
+
104
+	/**
105
+	 * get User ID
106
+	 *
107
+	 * @access public
108
+	 * @return int
109
+	 * @throws EE_Error
110
+	 */
111
+	public function user()
112
+	{
113
+		$user_id = $this->get('MTP_user_id');
114
+		return empty($user_id) ? get_current_user_id() : $user_id;
115
+	}
116
+
117
+
118
+	/**
119
+	 * Wrapper for the user function() (preserve backward compat)
120
+	 *
121
+	 * @since  4.5.0
122
+	 * @return int
123
+	 * @throws EE_Error
124
+	 */
125
+	public function wp_user()
126
+	{
127
+		return $this->user();
128
+	}
129
+
130
+
131
+	/**
132
+	 * This simply returns a count of all related events to this message template group
133
+	 *
134
+	 * @return int
135
+	 */
136
+	public function count_events()
137
+	{
138
+		return $this->count_related('Event');
139
+	}
140
+
141
+
142
+	/**
143
+	 * returns the name saved in the db for this template
144
+	 *
145
+	 * @return string
146
+	 * @throws EE_Error
147
+	 */
148
+	public function name()
149
+	{
150
+		return $this->get('MTP_name');
151
+	}
152
+
153
+
154
+	/**
155
+	 * Returns the description saved in the db for this template group
156
+	 *
157
+	 * @return string
158
+	 * @throws EE_Error
159
+	 */
160
+	public function description()
161
+	{
162
+		return $this->get('MTP_description');
163
+	}
164
+
165
+
166
+	/**
167
+	 * returns all related EE_Message_Template objects
168
+	 *
169
+	 * @param  array $query_params like EEM_Base::get_all()
170
+	 * @return EE_Message_Template[]
171
+	 * @throws EE_Error
172
+	 */
173
+	public function message_templates($query_params = array())
174
+	{
175
+		return $this->get_many_related('Message_Template', $query_params);
176
+	}
177
+
178
+
179
+	/**
180
+	 * get Message Messenger
181
+	 *
182
+	 * @access public
183
+	 * @return string
184
+	 * @throws EE_Error
185
+	 */
186
+	public function messenger()
187
+	{
188
+		return $this->get('MTP_messenger');
189
+	}
190
+
191
+
192
+	/**
193
+	 * get Message Messenger OBJECT
194
+	 * If an attempt to get the corresponding messenger object fails, then we set this message
195
+	 * template group to inactive, and save to db.  Then return null so client code can handle
196
+	 * appropriately.
197
+	 *
198
+	 * @return EE_messenger
199
+	 * @throws EE_Error
200
+	 */
201
+	public function messenger_obj()
202
+	{
203
+		$messenger = $this->messenger();
204
+		try {
205
+			$messenger = EEH_MSG_Template::messenger_obj($messenger);
206
+		} catch (EE_Error $e) {
207
+			//if an exception was thrown then let's deactivate this message template group because it means there is no
208
+			// class for this messenger in this group.
209
+			$this->set('MTP_is_active', false);
210
+			$this->save();
211
+			return null;
212
+		}
213
+		return $messenger;
214
+	}
215
+
216
+
217
+	/**
218
+	 * get Message Type
219
+	 *
220
+	 * @access public
221
+	 * @return string
222
+	 * @throws EE_Error
223
+	 */
224
+	public function message_type()
225
+	{
226
+		return $this->get('MTP_message_type');
227
+	}
228
+
229
+
230
+	/**
231
+	 * get Message type OBJECT
232
+	 * If an attempt to get the corresponding message type object fails, then we set this message
233
+	 * template group to inactive, and save to db.  Then return null so client code can handle
234
+	 * appropriately.
235
+	 *
236
+	 * @throws EE_Error
237
+	 * @return EE_message_type|false if exception thrown.
238
+	 */
239
+	public function message_type_obj()
240
+	{
241
+		$message_type = $this->message_type();
242
+		try {
243
+			$message_type = EEH_MSG_Template::message_type_obj($message_type);
244
+		} catch (EE_Error $e) {
245
+			//if an exception was thrown then let's deactivate this message template group because it means there is no
246
+			// class for the message type in this group.
247
+			$this->set('MTP_is_active', false);
248
+			$this->save();
249
+			return null;
250
+		}
251
+		return $message_type;
252
+	}
253
+
254
+
255
+	/**
256
+	 * @return array
257
+	 * @throws EE_Error
258
+	 */
259
+	public function contexts_config()
260
+	{
261
+		return $this->message_type_obj()->get_contexts();
262
+	}
263
+
264
+
265
+	/**
266
+	 * This returns the context_label for contexts as set in the message type object
267
+	 * Note this is an array with singular and plural keys
268
+	 *
269
+	 * @access public
270
+	 * @return array labels for "context"
271
+	 * @throws EE_Error
272
+	 */
273
+	public function context_label()
274
+	{
275
+		$obj = $this->message_type_obj();
276
+		return $obj->get_context_label();
277
+	}
278
+
279
+
280
+	/**
281
+	 * This returns an array of EE_Message_Template objects indexed by context and field.
282
+	 *
283
+	 * @return array ()
284
+	 * @throws EE_Error
285
+	 */
286
+	public function context_templates()
287
+	{
288
+		$mtps_arr = array();
289
+		$mtps     = $this->get_many_related('Message_Template');
290
+		if (empty($mtps)) {
291
+			return array();
292
+		}
293
+		//note contexts could have CHECKBOX fields per context. So we return the objects indexed by context AND field.
294
+		foreach ($mtps as $mtp) {
295
+			$mtps_arr[$mtp->get('MTP_context')][$mtp->get('MTP_template_field')] = $mtp;
296
+		}
297
+		return $mtps_arr;
298
+	}
299
+
300
+
301
+	/**
302
+	 * this returns if the template group this template belongs to is global
303
+	 *
304
+	 * @return bool true if it is, false if it isn't
305
+	 * @throws EE_Error
306
+	 */
307
+	public function is_global()
308
+	{
309
+		return $this->get('MTP_is_global');
310
+	}
311
+
312
+
313
+	/**
314
+	 * this returns if the template group this template belongs to is active (i.e. turned "on" or not)
315
+	 *
316
+	 * @return bool true if it is, false if it isn't
317
+	 * @throws EE_Error
318
+	 */
319
+	public function is_active()
320
+	{
321
+		return $this->get('MTP_is_active');
322
+	}
323
+
324
+
325
+	/**
326
+	 * This will return an array of shortcodes => labels from the messenger and message_type objects associated with
327
+	 * this template.
328
+	 *
329
+	 * @since 4.3.0
330
+	 * @uses  EEH_MSG_Template::get_shortcodes()
331
+	 * @param string $context what context we're going to return shortcodes for
332
+	 * @param array  $fields  what fields we're returning valid shortcodes for.  If empty then we assume all fields are
333
+	 *                        to be returned.
334
+	 * @param bool   $merged  If TRUE then we don't return shortcodes indexed by field but instead an array of the
335
+	 *                        unique shortcodes for all the given (or all) fields.
336
+	 * @return mixed (array|bool) an array of shortcodes in the format array( '[shortcode] => 'label') OR FALSE if no
337
+	 *                        shortcodes found.
338
+	 * @throws EE_Error
339
+	 */
340
+	public function get_shortcodes($context, $fields = array(), $merged = false)
341
+	{
342
+		$messenger    = $this->messenger();
343
+		$message_type = $this->message_type();
344
+		return EEH_MSG_Template::get_shortcodes($message_type, $messenger, $fields, $context, $merged);
345
+	}
346
+
347
+
348
+	/**
349
+	 * This just gets the template pack name assigned to this message template group.  If it's not set, then we just
350
+	 * use the default template pack.
351
+	 *
352
+	 * @since 4.5.0
353
+	 * @return string
354
+	 * @throws EE_Error
355
+	 */
356
+	public function get_template_pack_name()
357
+	{
358
+		return $this->get_extra_meta('MTP_template_pack', true, 'default');
359
+	}
360
+
361
+
362
+	/**
363
+	 * This returns the specific template pack object referenced by the template pack name attached to this message
364
+	 * template group.  If no template pack is assigned then the default template pack is retrieved.
365
+	 *
366
+	 * @since 4.5.0
367
+	 * @return EE_Messages_Template_Pack
368
+	 * @throws EE_Error
369
+	 * @throws InvalidArgumentException
370
+	 * @throws ReflectionException
371
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
372
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
373
+	 */
374
+	public function get_template_pack()
375
+	{
376
+		$pack_name = $this->get_template_pack_name();
377
+		EE_Registry::instance()->load_helper('MSG_Template');
378
+		return EEH_MSG_Template::get_template_pack($pack_name);
379
+	}
380
+
381
+
382
+	/**
383
+	 * This retrieves the template variation assigned to this message template group.  If it's not set, then we just
384
+	 * use the default template variation.
385
+	 *
386
+	 * @since 4.5.0
387
+	 * @return string
388
+	 * @throws EE_Error
389
+	 */
390
+	public function get_template_pack_variation()
391
+	{
392
+		return $this->get_extra_meta('MTP_variation', true, 'default');
393
+	}
394
+
395
+
396
+	/**
397
+	 * This just sets the template pack name attached to this message template group.
398
+	 *
399
+	 * @since 4.5.0
400
+	 * @param string $template_pack_name What message template pack is assigned.
401
+	 * @return int
402
+	 * @throws EE_Error
403
+	 */
404
+	public function set_template_pack_name($template_pack_name)
405
+	{
406
+		return $this->update_extra_meta('MTP_template_pack', $template_pack_name);
407
+	}
408
+
409
+
410
+	/**
411
+	 * This just sets the template pack variation attached to this message template group.
412
+	 *
413
+	 * @since 4.5.0
414
+	 * @param string $variation What variation is being set on the message template group.
415
+	 * @return int
416
+	 * @throws EE_Error
417
+	 */
418
+	public function set_template_pack_variation($variation)
419
+	{
420
+		return $this->update_extra_meta('MTP_variation', $variation);
421
+	}
422
+
423
+
424
+	/**
425
+	 * Deactivates the given context.
426
+	 *
427
+	 * @param $context
428
+	 * @return bool|int
429
+	 * @throws EE_Error
430
+	 * @throws InvalidIdentifierException
431
+	 */
432
+	public function deactivate_context($context)
433
+	{
434
+		$this->validate_context($context);
435
+		return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
436
+	}
437
+
438
+
439
+	/**
440
+	 * Activates the given context.
441
+	 *
442
+	 * @param $context
443
+	 * @return bool|int
444
+	 * @throws EE_Error
445
+	 * @throws InvalidIdentifierException
446
+	 */
447
+	public function activate_context($context)
448
+	{
449
+		$this->validate_context($context);
450
+		return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
451
+	}
452
+
453
+
454
+	/**
455
+	 * Returns whether the context is active or not.
456
+	 * Note, this will default to true if the extra meta record doesn't exist.
457
+	 * Also, this does NOT account for whether the "To" field is empty or not. Some messengers may allow the "To" field
458
+	 * to be empty (@see EE_Messenger::allow_empty_to_field()) so an empty "To" field is not always an indicator of
459
+	 * whether a context is "active" or not.
460
+	 *
461
+	 * @param $context
462
+	 * @return bool
463
+	 * @throws EE_Error
464
+	 * @throws InvalidIdentifierException
465
+	 */
466
+	public function is_context_active($context)
467
+	{
468
+		$this->validate_context($context);
469
+		return filter_var(
470
+			$this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
471
+			FILTER_VALIDATE_BOOLEAN
472
+		);
473
+	}
474
+
475
+
476
+	/**
477
+	 * Validates the incoming context to verify it matches a registered context for the related message type.
478
+	 * @param string $context
479
+	 * @throws EE_Error
480
+	 * @throws InvalidIdentifierException
481
+	 */
482
+	public function validate_context($context)
483
+	{
484
+		$contexts = $this->contexts_config();
485
+		if (! isset($contexts[$context])) {
486
+			throw new InvalidIdentifierException(
487
+				'',
488
+				'',
489
+				sprintf(
490
+					esc_html__(
491
+						'An invalid string identifying a context was provided.  "%1$s" was received, and one of "%2$s" was expected.',
492
+						'event_espresso'
493
+					),
494
+					$context,
495
+					implode(',', array_keys($contexts))
496
+				)
497
+			);
498
+		}
499
+	}
500 500
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
      */
51 51
     public function set_message_type($message_type = false)
52 52
     {
53
-        if (! $message_type) {
53
+        if ( ! $message_type) {
54 54
             throw new EE_Error(esc_html__('Missing required value for the message_type parameter', 'event_espresso'));
55 55
         }
56 56
         $this->set('MTP_message_type', $message_type);
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
      */
64 64
     public function set_messenger($messenger = false)
65 65
     {
66
-        if (! $messenger) {
66
+        if ( ! $messenger) {
67 67
             throw new EE_Error(esc_html__('Missing required value for the messenger parameter', 'event_espresso'));
68 68
         }
69 69
         $this->set('MTP_messenger', $messenger);
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     public function set_group_template_id($GRP_ID = false)
78 78
     {
79
-        if (! $GRP_ID) {
79
+        if ( ! $GRP_ID) {
80 80
             throw new EE_Error(
81 81
                 esc_html__(
82 82
                     'Missing required value for the message template group id',
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
     public function deactivate_context($context)
433 433
     {
434 434
         $this->validate_context($context);
435
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, false);
435
+        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, false);
436 436
     }
437 437
 
438 438
 
@@ -447,7 +447,7 @@  discard block
 block discarded – undo
447 447
     public function activate_context($context)
448 448
     {
449 449
         $this->validate_context($context);
450
-        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true);
450
+        return $this->update_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, true);
451 451
     }
452 452
 
453 453
 
@@ -467,7 +467,7 @@  discard block
 block discarded – undo
467 467
     {
468 468
         $this->validate_context($context);
469 469
         return filter_var(
470
-            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX . $context, true, true),
470
+            $this->get_extra_meta(self::ACTIVE_CONTEXT_RECORD_META_KEY_PREFIX.$context, true, true),
471 471
             FILTER_VALIDATE_BOOLEAN
472 472
         );
473 473
     }
@@ -482,7 +482,7 @@  discard block
 block discarded – undo
482 482
     public function validate_context($context)
483 483
     {
484 484
         $contexts = $this->contexts_config();
485
-        if (! isset($contexts[$context])) {
485
+        if ( ! isset($contexts[$context])) {
486 486
             throw new InvalidIdentifierException(
487 487
                 '',
488 488
                 '',
Please login to merge, or discard this patch.
admin_pages/messages/help_tabs/messages_settings_messengers.help_tab.php 2 patches
Indentation   +50 added lines, -50 removed lines patch added patch discarded remove patch
@@ -3,79 +3,79 @@
 block discarded – undo
3 3
 </p>
4 4
 <p>
5 5
     <?php esc_html_e(
6
-        'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab.  When you click one of those tabs it will display that messenger.',
7
-        'event_espresso'
8
-    ); ?>
6
+		'You can select Messengers via the tabs across the top of the settings page. The available messengers you see depends on what version of Event Espresso you have and what addons are installed. Every install include an "Email" messenger tab.  When you click one of those tabs it will display that messenger.',
7
+		'event_espresso'
8
+	); ?>
9 9
 </p>
10 10
 <p>
11 11
     <?php esc_html_e(
12
-        'There are two ways to determine whether a messenger is active or not.  The first way is via the messenger tab itself.',
13
-        'event_espresso'
14
-    ); ?>
12
+		'There are two ways to determine whether a messenger is active or not.  The first way is via the messenger tab itself.',
13
+		'event_espresso'
14
+	); ?>
15 15
 </p>
16 16
 <p>
17 17
     <?php printf(
18
-        esc_html__(
19
-            'The green colored gear %s indicates that this messenger is currently active.',
20
-            'event_espresso'
21
-        ),
22
-        '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"'
23
-        . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'
24
-    );
25
-    printf(
26
-        esc_html__(
27
-            ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.',
28
-            'event_espresso'
29
-        ),
30
-        '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
31
-        . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'
32
-    ); ?>
18
+		esc_html__(
19
+			'The green colored gear %s indicates that this messenger is currently active.',
20
+			'event_espresso'
21
+		),
22
+		'<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"'
23
+		. ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'
24
+	);
25
+	printf(
26
+		esc_html__(
27
+			' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.',
28
+			'event_espresso'
29
+		),
30
+		'<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
31
+		. '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'
32
+	); ?>
33 33
 </p>
34 34
 <p>
35 35
     <?php esc_html_e(
36
-        'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:',
37
-        'event_espresso'
38
-    ); ?>
36
+		'The second way to determine whether a messenger is active or not is via the "on/off" button in the top right corner of the active messenger displayed content:',
37
+		'event_espresso'
38
+	); ?>
39 39
 </p>
40 40
 <p>
41 41
     <?php printf(
42
-        esc_html__(
43
-            '%1$s means of course that the messenger is active and %2$s means the messenger is inactive.',
44
-            'event_espresso'
45
-        ),
46
-        '<div class="switch">'
47
-            . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked" disabled>'
48
-            . '<label for="ee-on-off-toggle-on"></label>'
49
-        . '</div>',
50
-        '<div class="switch">'
51
-            . '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" disabled>'
52
-            . '<label for="ee-on-off-toggle-on"></label>'
53
-        . '</div>'
54
-    ); ?>
42
+		esc_html__(
43
+			'%1$s means of course that the messenger is active and %2$s means the messenger is inactive.',
44
+			'event_espresso'
45
+		),
46
+		'<div class="switch">'
47
+			. '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked" disabled>'
48
+			. '<label for="ee-on-off-toggle-on"></label>'
49
+		. '</div>',
50
+		'<div class="switch">'
51
+			. '<input class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" disabled>'
52
+			. '<label for="ee-on-off-toggle-on"></label>'
53
+		. '</div>'
54
+	); ?>
55 55
 </p>
56 56
 <p>
57 57
     <?php
58
-        esc_html_e(
59
-            'The on/off toggle is also what you use to activate or deactivate a messenger.',
60
-            'event_espresso'
61
-        ); ?>
58
+		esc_html_e(
59
+			'The on/off toggle is also what you use to activate or deactivate a messenger.',
60
+			'event_espresso'
61
+		); ?>
62 62
 </p>
63 63
 <p>
64 64
     <?php esc_html_e(
65
-        'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger.  Then, if there are any default settings for either the messenger or message types those settings are saved.  Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated).  Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.',
66
-        'event_espresso'
67
-    ); ?>
65
+		'What happens when you click the toggle to activate is the messenger is activated and the system determines what default message types are activated with the messenger.  Then, if there are any default settings for either the messenger or message types those settings are saved.  Next, the system will generate any default templates (if none have been generated before, if there are previously generated templates then they are reactivated).  Finally, you will see the display change to reflect that the messenger is active. If the messenger has settings you can modify them then. Any message types that have settings will also automatically expand so you can see the default settings and make any changes as necessary to fit your needs. Usually the defaults are sufficient however.',
66
+		'event_espresso'
67
+	); ?>
68 68
 </p>
69 69
 <p>
70 70
     <?php esc_html_e(
71
-        'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate.  If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.',
72
-        'event_espresso'
73
-    ); ?>
71
+		'When you deactivate a messenger, the system will first check if there are any custom event templates for that messenger. If there are you will be unable to deactivate the messenger. This is a fail safe to make sure you know that no messages will go out for those specific events so you don\'t accidentally deactivate.  If this check passes, then the system will deactivate any global templates for that messenger (note the templates are not erased, they just become inactive, so if you decide to reactivate the messenger later all your customizations are preserved). Then the display will change to reflect the deactivation.',
72
+		'event_espresso'
73
+	); ?>
74 74
 </p>
75 75
 <p>
76 76
     <strong><?php esc_html_e('Important', 'event_espresso'); ?></strong><br/>
77 77
     <?php esc_html_e(
78
-        'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation.  Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.',
79
-        'event_espresso'
80
-    ); ?>
78
+		'Although customizations made to global templates are preserved when a messenger is deactivated, any settings for that messenger (or the message types that were attached to it) are lost on deactivation.  Also, once you deactivate a messenger, no more messages will be delivered using that messenger for any of your events.',
79
+		'event_espresso'
80
+	); ?>
81 81
 </p>
Please login to merge, or discard this patch.
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -19,16 +19,16 @@
 block discarded – undo
19 19
             'The green colored gear %s indicates that this messenger is currently active.',
20 20
             'event_espresso'
21 21
         ),
22
-        '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '"'
23
-        . ' alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />'
22
+        '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'"'
23
+        . ' alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />'
24 24
     );
25 25
     printf(
26 26
         esc_html__(
27 27
             ' The white colored gear %s indicates the messenger is inactive. This is very helpful for seeing at a glance all the messengers that are active when you first view the page.',
28 28
             'event_espresso'
29 29
         ),
30
-        '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png'
31
-        . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />'
30
+        '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'
31
+        . '" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />'
32 32
     ); ?>
33 33
 </p>
34 34
 <p>
Please login to merge, or discard this patch.
core/libraries/rest_api/calculations/Event.php 2 patches
Indentation   +401 added lines, -401 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @since                 $VID:$
20 20
  */
21 21
 if (! defined('EVENT_ESPRESSO_VERSION')) {
22
-    exit('No direct script access allowed');
22
+	exit('No direct script access allowed');
23 23
 }
24 24
 
25 25
 
@@ -27,404 +27,404 @@  discard block
 block discarded – undo
27 27
 class Event extends Calculations_Base
28 28
 {
29 29
 
30
-    /**
31
-     * Calculates the total spaces on the event (not subtracting sales, but taking
32
-     * sales into account; so this is the optimum sales that CAN still be achieved)
33
-     * See EE_Event::total_available_spaces( true );
34
-     *
35
-     * @param array            $wpdb_row
36
-     * @param \WP_REST_Request $request
37
-     * @param Base             $controller
38
-     * @return int
39
-     * @throws EE_Error
40
-     */
41
-    public static function optimumSalesAtStart($wpdb_row, $request, $controller)
42
-    {
43
-        $event_obj = null;
44
-        if (Event::wpdbRowHasEventId($wpdb_row)) {
45
-            $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']);
46
-        }
47
-        if ($event_obj instanceof EE_Event) {
48
-            return $event_obj->total_available_spaces();
49
-        }
50
-        throw new EE_Error(
51
-            sprintf(
52
-                __(
53
-                    // @codingStandardsIgnoreStart
54
-                    'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found',
55
-                    // @codingStandardsIgnoreEnd
56
-                    'event_espresso'
57
-                ),
58
-                $wpdb_row['Event_CPT.ID'],
59
-                print_r($wpdb_row, true)
60
-            )
61
-        );
62
-    }
63
-
64
-
65
-
66
-    /**
67
-     * Calculates the total spaces on the event (ignoring all sales; so this is the optimum
68
-     * sales that COULD have been achieved)
69
-     * See EE_Event::total_available_spaces( true );
70
-     *
71
-     * @param array            $wpdb_row
72
-     * @param \WP_REST_Request $request
73
-     * @param Base             $controller
74
-     * @return int
75
-     * @throws EE_Error
76
-     */
77
-    public static function optimumSalesNow($wpdb_row, $request, $controller)
78
-    {
79
-        $event_obj = null;
80
-        if (Event::wpdbRowHasEventId($wpdb_row)) {
81
-            $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']);
82
-        }
83
-        if ($event_obj instanceof EE_Event) {
84
-            return $event_obj->total_available_spaces(true);
85
-        }
86
-        throw new EE_Error(
87
-            sprintf(
88
-                __(
89
-                    // @codingStandardsIgnoreStart
90
-                    'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found',
91
-                    // @codingStandardsIgnoreEnd
92
-                    'event_espresso'
93
-                ),
94
-                $wpdb_row['Event_CPT.ID'],
95
-                print_r($wpdb_row, true)
96
-            )
97
-        );
98
-    }
99
-
100
-
101
-
102
-    /**
103
-     * Like optimum_sales_now, but minus total sales so far.
104
-     * See EE_Event::spaces_remaining_for_sale( true );
105
-     *
106
-     * @param array            $wpdb_row
107
-     * @param \WP_REST_Request $request
108
-     * @param Base             $controller
109
-     * @return int
110
-     * @throws EE_Error
111
-     */
112
-    public static function spacesRemaining($wpdb_row, $request, $controller)
113
-    {
114
-        $event_obj = null;
115
-        if (Event::wpdbRowHasEventId($wpdb_row)) {
116
-            $event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']);
117
-        }
118
-        if ($event_obj instanceof EE_Event) {
119
-            return $event_obj->spaces_remaining_for_sale();
120
-        }
121
-        throw new EE_Error(
122
-            sprintf(
123
-                __(
124
-                    // @codingStandardsIgnoreStart
125
-                    'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found',
126
-                    // @codingStandardsIgnoreEnd
127
-                    'event_espresso'
128
-                ),
129
-                $wpdb_row['Event_CPT.ID'],
130
-                print_r($wpdb_row, true)
131
-            )
132
-        );
133
-    }
134
-
135
-
136
-
137
-    /**
138
-     * Counts the number of approved registrations for this event (regardless
139
-     * of how many datetimes each registrations' ticket purchase is for)
140
-     *
141
-     * @param array            $wpdb_row
142
-     * @param \WP_REST_Request $request
143
-     * @param Base             $controller
144
-     * @return int
145
-     * @throws EE_Error
146
-     */
147
-    public static function spotsTaken($wpdb_row, $request, $controller)
148
-    {
149
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
150
-            throw new EE_Error(
151
-                sprintf(
152
-                    __(
153
-                        // @codingStandardsIgnoreStart
154
-                        'Cannot calculate spots_taken because the database row %1$s does not have a valid entry for "Event_CPT.ID"',
155
-                        // @codingStandardsIgnoreEnd
156
-                        'event_espresso'
157
-                    ),
158
-                    print_r($wpdb_row, true)
159
-                )
160
-            );
161
-        }
162
-        return EEM_Registration::instance()->count(
163
-            array(
164
-                array(
165
-                    'EVT_ID' => $wpdb_row['Event_CPT.ID'],
166
-                    'STS_ID' => EEM_Registration::status_id_approved,
167
-                ),
168
-            ),
169
-            'REG_ID',
170
-            true
171
-        );
172
-    }
173
-
174
-
175
-
176
-    /**
177
-     * Counts the number of pending-payment registrations for this event (regardless
178
-     * of how many datetimes each registrations' ticket purchase is for)
179
-     *
180
-     * @param array            $wpdb_row
181
-     * @param \WP_REST_Request $request
182
-     * @param Base             $controller
183
-     * @return int
184
-     * @throws EE_Error
185
-     * @throws RestException
186
-     */
187
-    public static function spotsTakenPendingPayment($wpdb_row, $request, $controller)
188
-    {
189
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
190
-            throw new EE_Error(
191
-                sprintf(
192
-                    __(
193
-                        // @codingStandardsIgnoreStart
194
-                        'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"',
195
-                        // @codingStandardsIgnoreEnd
196
-                        'event_espresso'
197
-                    ),
198
-                    print_r($wpdb_row, true)
199
-                )
200
-            );
201
-        }
202
-        self::verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment');
203
-        return EEM_Registration::instance()->count(
204
-            array(
205
-                array(
206
-                    'EVT_ID' => $wpdb_row['Event_CPT.ID'],
207
-                    'STS_ID' => EEM_Registration::status_id_pending_payment,
208
-                ),
209
-            ),
210
-            'REG_ID',
211
-            true
212
-        );
213
-    }
214
-
215
-
216
-
217
-    /**
218
-     * Counts all the registrations who have checked into one of this events' datetimes
219
-     * See EE_Event::total_available_spaces( false );
220
-     *
221
-     * @param array            $wpdb_row
222
-     * @param \WP_REST_Request $request
223
-     * @param Base             $controller
224
-     * @return int|null if permission denied
225
-     * @throws EE_Error
226
-     * @throws RestException
227
-     */
228
-    public static function registrationsCheckedInCount($wpdb_row, $request, $controller)
229
-    {
230
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
231
-            throw new EE_Error(
232
-                sprintf(
233
-                    __(
234
-                        // @codingStandardsIgnoreStart
235
-                        'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"',
236
-                        // @codingStandardsIgnoreEnd
237
-                        'event_espresso'
238
-                    ),
239
-                    print_r($wpdb_row, true)
240
-                )
241
-            );
242
-        }
243
-        self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count');
244
-        return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true);
245
-    }
246
-
247
-
248
-
249
-    /**
250
-     * Counts all the registrations who have checked out of one of this events' datetimes
251
-     * See EE_Event::total_available_spaces( false );
252
-     *
253
-     * @param array            $wpdb_row
254
-     * @param \WP_REST_Request $request
255
-     * @param Base             $controller
256
-     * @return int
257
-     * @throws EE_Error
258
-     * @throws RestException
259
-     */
260
-    public static function registrationsCheckedOutCount($wpdb_row, $request, $controller)
261
-    {
262
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
263
-            throw new EE_Error(
264
-                sprintf(
265
-                    __(
266
-                        // @codingStandardsIgnoreStart
267
-                        'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"',
268
-                        // @codingStandardsIgnoreEnd
269
-                        'event_espresso'
270
-                    ),
271
-                    print_r($wpdb_row, true)
272
-                )
273
-            );
274
-        }
275
-        self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count');
276
-        return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false);
277
-    }
278
-
279
-
280
-
281
-    /**
282
-     * Gets the thumbnail image
283
-     *
284
-     * @param array            $wpdb_row
285
-     * @param \WP_REST_Request $request
286
-     * @param Base             $controller
287
-     * @return array
288
-     * @throws EE_Error
289
-     */
290
-    public static function imageThumbnail($wpdb_row, $request, $controller)
291
-    {
292
-        return self::calculateImageData($wpdb_row, 'thumbnail');
293
-    }
294
-
295
-
296
-
297
-    /**
298
-     * Gets the medium image
299
-     *
300
-     * @param array            $wpdb_row
301
-     * @param \WP_REST_Request $request
302
-     * @param Base             $controller
303
-     * @return array
304
-     * @throws EE_Error
305
-     */
306
-    public static function imageMedium($wpdb_row, $request, $controller)
307
-    {
308
-        return self::calculateImageData($wpdb_row, 'medium');
309
-    }
310
-
311
-
312
-
313
-    /**
314
-     * Gets the medium-large image
315
-     *
316
-     * @param array            $wpdb_row
317
-     * @param \WP_REST_Request $request
318
-     * @param Base             $controller
319
-     * @return array
320
-     * @throws EE_Error
321
-     */
322
-    public static function imageMediumLarge($wpdb_row, $request, $controller)
323
-    {
324
-        return self::calculateImageData($wpdb_row, 'medium_large');
325
-    }
326
-
327
-
328
-
329
-    /**
330
-     * Gets the large image
331
-     *
332
-     * @param array            $wpdb_row
333
-     * @param \WP_REST_Request $request
334
-     * @param Base             $controller
335
-     * @return array
336
-     * @throws EE_Error
337
-     */
338
-    public static function imageLarge($wpdb_row, $request, $controller)
339
-    {
340
-        return self::calculateImageData($wpdb_row, 'large');
341
-    }
342
-
343
-
344
-
345
-    /**
346
-     * Gets the post-thumbnail image
347
-     *
348
-     * @param array            $wpdb_row
349
-     * @param \WP_REST_Request $request
350
-     * @param Base             $controller
351
-     * @return array
352
-     * @throws EE_Error
353
-     */
354
-    public static function imagePostThumbnail($wpdb_row, $request, $controller)
355
-    {
356
-        return self::calculateImageData($wpdb_row, 'post-thumbnail');
357
-    }
358
-
359
-
360
-
361
-    /**
362
-     * Gets the full size image
363
-     *
364
-     * @param array            $wpdb_row
365
-     * @param \WP_REST_Request $request
366
-     * @param Base             $controller
367
-     * @return array
368
-     * @throws EE_Error
369
-     */
370
-    public static function imageFull($wpdb_row, $request, $controller)
371
-    {
372
-        return self::calculateImageData($wpdb_row, 'full');
373
-    }
374
-
375
-
376
-
377
-    /**
378
-     * Gets image specs and formats them for the display in the API,
379
-     * according to the image size requested
380
-     *
381
-     * @param array    $wpdb_row
382
-     * @param string $image_size one of these: thumbnail, medium, medium_large, large, post-thumbnail, full
383
-     * @return array|false if no such image exists. If array it will have keys 'url', 'width', 'height' and 'original'
384
-     * @throws EE_Error
385
-     */
386
-    protected static function calculateImageData($wpdb_row, $image_size)
387
-    {
388
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
389
-            throw new EE_Error(
390
-                sprintf(
391
-                    __(
392
-                    // @codingStandardsIgnoreStart
393
-                        'Cannot calculate image because the database row %1$s does not have an entry for "Event_CPT.ID"',
394
-                        // @codingStandardsIgnoreEnd
395
-                        'event_espresso'
396
-                    ),
397
-                    print_r($wpdb_row, true)
398
-                )
399
-            );
400
-        }
401
-        $EVT_ID = $wpdb_row['Event_CPT.ID'];
402
-        $attachment_id = get_post_thumbnail_id($EVT_ID);
403
-        $data = wp_get_attachment_image_src($attachment_id, $image_size);
404
-        if (! $data) {
405
-            return null;
406
-        }
407
-        $generated = true;
408
-        if (isset($data[3])) {
409
-            $generated = $data[3];
410
-        }
411
-        return array(
412
-            'url'       => $data[0],
413
-            'width'     => $data[1],
414
-            'height'    => $data[2],
415
-            'generated' => $generated,
416
-        );
417
-    }
418
-
419
-
420
-
421
-    /**
422
-     * Returns true if the array of data contains 'Event_CPT.ID'. False otherwise
423
-     * @param array $wpdb_row
424
-     * @return bool
425
-     */
426
-    protected static function wpdbRowHasEventId($wpdb_row)
427
-    {
428
-        return (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID']));
429
-    }
30
+	/**
31
+	 * Calculates the total spaces on the event (not subtracting sales, but taking
32
+	 * sales into account; so this is the optimum sales that CAN still be achieved)
33
+	 * See EE_Event::total_available_spaces( true );
34
+	 *
35
+	 * @param array            $wpdb_row
36
+	 * @param \WP_REST_Request $request
37
+	 * @param Base             $controller
38
+	 * @return int
39
+	 * @throws EE_Error
40
+	 */
41
+	public static function optimumSalesAtStart($wpdb_row, $request, $controller)
42
+	{
43
+		$event_obj = null;
44
+		if (Event::wpdbRowHasEventId($wpdb_row)) {
45
+			$event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']);
46
+		}
47
+		if ($event_obj instanceof EE_Event) {
48
+			return $event_obj->total_available_spaces();
49
+		}
50
+		throw new EE_Error(
51
+			sprintf(
52
+				__(
53
+					// @codingStandardsIgnoreStart
54
+					'Cannot calculate optimum_sales_at_start because the event with ID %1$s (from database row %2$s) was not found',
55
+					// @codingStandardsIgnoreEnd
56
+					'event_espresso'
57
+				),
58
+				$wpdb_row['Event_CPT.ID'],
59
+				print_r($wpdb_row, true)
60
+			)
61
+		);
62
+	}
63
+
64
+
65
+
66
+	/**
67
+	 * Calculates the total spaces on the event (ignoring all sales; so this is the optimum
68
+	 * sales that COULD have been achieved)
69
+	 * See EE_Event::total_available_spaces( true );
70
+	 *
71
+	 * @param array            $wpdb_row
72
+	 * @param \WP_REST_Request $request
73
+	 * @param Base             $controller
74
+	 * @return int
75
+	 * @throws EE_Error
76
+	 */
77
+	public static function optimumSalesNow($wpdb_row, $request, $controller)
78
+	{
79
+		$event_obj = null;
80
+		if (Event::wpdbRowHasEventId($wpdb_row)) {
81
+			$event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']);
82
+		}
83
+		if ($event_obj instanceof EE_Event) {
84
+			return $event_obj->total_available_spaces(true);
85
+		}
86
+		throw new EE_Error(
87
+			sprintf(
88
+				__(
89
+					// @codingStandardsIgnoreStart
90
+					'Cannot calculate optimum_sales_now because the event with ID %1$s (from database row %2$s) was not found',
91
+					// @codingStandardsIgnoreEnd
92
+					'event_espresso'
93
+				),
94
+				$wpdb_row['Event_CPT.ID'],
95
+				print_r($wpdb_row, true)
96
+			)
97
+		);
98
+	}
99
+
100
+
101
+
102
+	/**
103
+	 * Like optimum_sales_now, but minus total sales so far.
104
+	 * See EE_Event::spaces_remaining_for_sale( true );
105
+	 *
106
+	 * @param array            $wpdb_row
107
+	 * @param \WP_REST_Request $request
108
+	 * @param Base             $controller
109
+	 * @return int
110
+	 * @throws EE_Error
111
+	 */
112
+	public static function spacesRemaining($wpdb_row, $request, $controller)
113
+	{
114
+		$event_obj = null;
115
+		if (Event::wpdbRowHasEventId($wpdb_row)) {
116
+			$event_obj = EEM_Event::instance()->get_one_by_ID($wpdb_row['Event_CPT.ID']);
117
+		}
118
+		if ($event_obj instanceof EE_Event) {
119
+			return $event_obj->spaces_remaining_for_sale();
120
+		}
121
+		throw new EE_Error(
122
+			sprintf(
123
+				__(
124
+					// @codingStandardsIgnoreStart
125
+					'Cannot calculate spaces_remaining because the event with ID %1$s (from database row %2$s) was not found',
126
+					// @codingStandardsIgnoreEnd
127
+					'event_espresso'
128
+				),
129
+				$wpdb_row['Event_CPT.ID'],
130
+				print_r($wpdb_row, true)
131
+			)
132
+		);
133
+	}
134
+
135
+
136
+
137
+	/**
138
+	 * Counts the number of approved registrations for this event (regardless
139
+	 * of how many datetimes each registrations' ticket purchase is for)
140
+	 *
141
+	 * @param array            $wpdb_row
142
+	 * @param \WP_REST_Request $request
143
+	 * @param Base             $controller
144
+	 * @return int
145
+	 * @throws EE_Error
146
+	 */
147
+	public static function spotsTaken($wpdb_row, $request, $controller)
148
+	{
149
+		if (! Event::wpdbRowHasEventId($wpdb_row)) {
150
+			throw new EE_Error(
151
+				sprintf(
152
+					__(
153
+						// @codingStandardsIgnoreStart
154
+						'Cannot calculate spots_taken because the database row %1$s does not have a valid entry for "Event_CPT.ID"',
155
+						// @codingStandardsIgnoreEnd
156
+						'event_espresso'
157
+					),
158
+					print_r($wpdb_row, true)
159
+				)
160
+			);
161
+		}
162
+		return EEM_Registration::instance()->count(
163
+			array(
164
+				array(
165
+					'EVT_ID' => $wpdb_row['Event_CPT.ID'],
166
+					'STS_ID' => EEM_Registration::status_id_approved,
167
+				),
168
+			),
169
+			'REG_ID',
170
+			true
171
+		);
172
+	}
173
+
174
+
175
+
176
+	/**
177
+	 * Counts the number of pending-payment registrations for this event (regardless
178
+	 * of how many datetimes each registrations' ticket purchase is for)
179
+	 *
180
+	 * @param array            $wpdb_row
181
+	 * @param \WP_REST_Request $request
182
+	 * @param Base             $controller
183
+	 * @return int
184
+	 * @throws EE_Error
185
+	 * @throws RestException
186
+	 */
187
+	public static function spotsTakenPendingPayment($wpdb_row, $request, $controller)
188
+	{
189
+		if (! Event::wpdbRowHasEventId($wpdb_row)) {
190
+			throw new EE_Error(
191
+				sprintf(
192
+					__(
193
+						// @codingStandardsIgnoreStart
194
+						'Cannot calculate spots_taken_pending_payment because the database row %1$s does not have an entry for "Event_CPT.ID"',
195
+						// @codingStandardsIgnoreEnd
196
+						'event_espresso'
197
+					),
198
+					print_r($wpdb_row, true)
199
+				)
200
+			);
201
+		}
202
+		self::verifyCurrentUserCan('ee_read_registrations', 'spots_taken_pending_payment');
203
+		return EEM_Registration::instance()->count(
204
+			array(
205
+				array(
206
+					'EVT_ID' => $wpdb_row['Event_CPT.ID'],
207
+					'STS_ID' => EEM_Registration::status_id_pending_payment,
208
+				),
209
+			),
210
+			'REG_ID',
211
+			true
212
+		);
213
+	}
214
+
215
+
216
+
217
+	/**
218
+	 * Counts all the registrations who have checked into one of this events' datetimes
219
+	 * See EE_Event::total_available_spaces( false );
220
+	 *
221
+	 * @param array            $wpdb_row
222
+	 * @param \WP_REST_Request $request
223
+	 * @param Base             $controller
224
+	 * @return int|null if permission denied
225
+	 * @throws EE_Error
226
+	 * @throws RestException
227
+	 */
228
+	public static function registrationsCheckedInCount($wpdb_row, $request, $controller)
229
+	{
230
+		if (! Event::wpdbRowHasEventId($wpdb_row)) {
231
+			throw new EE_Error(
232
+				sprintf(
233
+					__(
234
+						// @codingStandardsIgnoreStart
235
+						'Cannot calculate registrations_checked_in_count because the database row %1$s does not have an entry for "Event_CPT.ID"',
236
+						// @codingStandardsIgnoreEnd
237
+						'event_espresso'
238
+					),
239
+					print_r($wpdb_row, true)
240
+				)
241
+			);
242
+		}
243
+		self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_in_count');
244
+		return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], true);
245
+	}
246
+
247
+
248
+
249
+	/**
250
+	 * Counts all the registrations who have checked out of one of this events' datetimes
251
+	 * See EE_Event::total_available_spaces( false );
252
+	 *
253
+	 * @param array            $wpdb_row
254
+	 * @param \WP_REST_Request $request
255
+	 * @param Base             $controller
256
+	 * @return int
257
+	 * @throws EE_Error
258
+	 * @throws RestException
259
+	 */
260
+	public static function registrationsCheckedOutCount($wpdb_row, $request, $controller)
261
+	{
262
+		if (! Event::wpdbRowHasEventId($wpdb_row)) {
263
+			throw new EE_Error(
264
+				sprintf(
265
+					__(
266
+						// @codingStandardsIgnoreStart
267
+						'Cannot calculate registrations_checked_out_count because the database row %1$s does not have an entry for "Event_CPT.ID"',
268
+						// @codingStandardsIgnoreEnd
269
+						'event_espresso'
270
+					),
271
+					print_r($wpdb_row, true)
272
+				)
273
+			);
274
+		}
275
+		self::verifyCurrentUserCan('ee_read_checkins', 'registrations_checked_out_count');
276
+		return EEM_Registration::instance()->count_registrations_checked_into_event($wpdb_row['Event_CPT.ID'], false);
277
+	}
278
+
279
+
280
+
281
+	/**
282
+	 * Gets the thumbnail image
283
+	 *
284
+	 * @param array            $wpdb_row
285
+	 * @param \WP_REST_Request $request
286
+	 * @param Base             $controller
287
+	 * @return array
288
+	 * @throws EE_Error
289
+	 */
290
+	public static function imageThumbnail($wpdb_row, $request, $controller)
291
+	{
292
+		return self::calculateImageData($wpdb_row, 'thumbnail');
293
+	}
294
+
295
+
296
+
297
+	/**
298
+	 * Gets the medium image
299
+	 *
300
+	 * @param array            $wpdb_row
301
+	 * @param \WP_REST_Request $request
302
+	 * @param Base             $controller
303
+	 * @return array
304
+	 * @throws EE_Error
305
+	 */
306
+	public static function imageMedium($wpdb_row, $request, $controller)
307
+	{
308
+		return self::calculateImageData($wpdb_row, 'medium');
309
+	}
310
+
311
+
312
+
313
+	/**
314
+	 * Gets the medium-large image
315
+	 *
316
+	 * @param array            $wpdb_row
317
+	 * @param \WP_REST_Request $request
318
+	 * @param Base             $controller
319
+	 * @return array
320
+	 * @throws EE_Error
321
+	 */
322
+	public static function imageMediumLarge($wpdb_row, $request, $controller)
323
+	{
324
+		return self::calculateImageData($wpdb_row, 'medium_large');
325
+	}
326
+
327
+
328
+
329
+	/**
330
+	 * Gets the large image
331
+	 *
332
+	 * @param array            $wpdb_row
333
+	 * @param \WP_REST_Request $request
334
+	 * @param Base             $controller
335
+	 * @return array
336
+	 * @throws EE_Error
337
+	 */
338
+	public static function imageLarge($wpdb_row, $request, $controller)
339
+	{
340
+		return self::calculateImageData($wpdb_row, 'large');
341
+	}
342
+
343
+
344
+
345
+	/**
346
+	 * Gets the post-thumbnail image
347
+	 *
348
+	 * @param array            $wpdb_row
349
+	 * @param \WP_REST_Request $request
350
+	 * @param Base             $controller
351
+	 * @return array
352
+	 * @throws EE_Error
353
+	 */
354
+	public static function imagePostThumbnail($wpdb_row, $request, $controller)
355
+	{
356
+		return self::calculateImageData($wpdb_row, 'post-thumbnail');
357
+	}
358
+
359
+
360
+
361
+	/**
362
+	 * Gets the full size image
363
+	 *
364
+	 * @param array            $wpdb_row
365
+	 * @param \WP_REST_Request $request
366
+	 * @param Base             $controller
367
+	 * @return array
368
+	 * @throws EE_Error
369
+	 */
370
+	public static function imageFull($wpdb_row, $request, $controller)
371
+	{
372
+		return self::calculateImageData($wpdb_row, 'full');
373
+	}
374
+
375
+
376
+
377
+	/**
378
+	 * Gets image specs and formats them for the display in the API,
379
+	 * according to the image size requested
380
+	 *
381
+	 * @param array    $wpdb_row
382
+	 * @param string $image_size one of these: thumbnail, medium, medium_large, large, post-thumbnail, full
383
+	 * @return array|false if no such image exists. If array it will have keys 'url', 'width', 'height' and 'original'
384
+	 * @throws EE_Error
385
+	 */
386
+	protected static function calculateImageData($wpdb_row, $image_size)
387
+	{
388
+		if (! Event::wpdbRowHasEventId($wpdb_row)) {
389
+			throw new EE_Error(
390
+				sprintf(
391
+					__(
392
+					// @codingStandardsIgnoreStart
393
+						'Cannot calculate image because the database row %1$s does not have an entry for "Event_CPT.ID"',
394
+						// @codingStandardsIgnoreEnd
395
+						'event_espresso'
396
+					),
397
+					print_r($wpdb_row, true)
398
+				)
399
+			);
400
+		}
401
+		$EVT_ID = $wpdb_row['Event_CPT.ID'];
402
+		$attachment_id = get_post_thumbnail_id($EVT_ID);
403
+		$data = wp_get_attachment_image_src($attachment_id, $image_size);
404
+		if (! $data) {
405
+			return null;
406
+		}
407
+		$generated = true;
408
+		if (isset($data[3])) {
409
+			$generated = $data[3];
410
+		}
411
+		return array(
412
+			'url'       => $data[0],
413
+			'width'     => $data[1],
414
+			'height'    => $data[2],
415
+			'generated' => $generated,
416
+		);
417
+	}
418
+
419
+
420
+
421
+	/**
422
+	 * Returns true if the array of data contains 'Event_CPT.ID'. False otherwise
423
+	 * @param array $wpdb_row
424
+	 * @return bool
425
+	 */
426
+	protected static function wpdbRowHasEventId($wpdb_row)
427
+	{
428
+		return (is_array($wpdb_row) && isset($wpdb_row['Event_CPT.ID']) && absint($wpdb_row['Event_CPT.ID']));
429
+	}
430 430
 }
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
  * @author                Mike Nelson
19 19
  * @since                 $VID:$
20 20
  */
21
-if (! defined('EVENT_ESPRESSO_VERSION')) {
21
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
22 22
     exit('No direct script access allowed');
23 23
 }
24 24
 
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
      */
147 147
     public static function spotsTaken($wpdb_row, $request, $controller)
148 148
     {
149
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
149
+        if ( ! Event::wpdbRowHasEventId($wpdb_row)) {
150 150
             throw new EE_Error(
151 151
                 sprintf(
152 152
                     __(
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     public static function spotsTakenPendingPayment($wpdb_row, $request, $controller)
188 188
     {
189
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
189
+        if ( ! Event::wpdbRowHasEventId($wpdb_row)) {
190 190
             throw new EE_Error(
191 191
                 sprintf(
192 192
                     __(
@@ -227,7 +227,7 @@  discard block
 block discarded – undo
227 227
      */
228 228
     public static function registrationsCheckedInCount($wpdb_row, $request, $controller)
229 229
     {
230
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
230
+        if ( ! Event::wpdbRowHasEventId($wpdb_row)) {
231 231
             throw new EE_Error(
232 232
                 sprintf(
233 233
                     __(
@@ -259,7 +259,7 @@  discard block
 block discarded – undo
259 259
      */
260 260
     public static function registrationsCheckedOutCount($wpdb_row, $request, $controller)
261 261
     {
262
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
262
+        if ( ! Event::wpdbRowHasEventId($wpdb_row)) {
263 263
             throw new EE_Error(
264 264
                 sprintf(
265 265
                     __(
@@ -385,7 +385,7 @@  discard block
 block discarded – undo
385 385
      */
386 386
     protected static function calculateImageData($wpdb_row, $image_size)
387 387
     {
388
-        if (! Event::wpdbRowHasEventId($wpdb_row)) {
388
+        if ( ! Event::wpdbRowHasEventId($wpdb_row)) {
389 389
             throw new EE_Error(
390 390
                 sprintf(
391 391
                     __(
@@ -401,7 +401,7 @@  discard block
 block discarded – undo
401 401
         $EVT_ID = $wpdb_row['Event_CPT.ID'];
402 402
         $attachment_id = get_post_thumbnail_id($EVT_ID);
403 403
         $data = wp_get_attachment_image_src($attachment_id, $image_size);
404
-        if (! $data) {
404
+        if ( ! $data) {
405 405
             return null;
406 406
         }
407 407
         $generated = true;
Please login to merge, or discard this patch.
modules/single_page_checkout/inc/EE_Checkout.class.php 2 patches
Indentation   +28 added lines, -28 removed lines patch added patch discarded remove patch
@@ -1,16 +1,16 @@  discard block
 block discarded – undo
1 1
 <?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { exit('No direct script access allowed'); }
2 2
  /**
3
- *
4
- * Class EE_Checkout
5
- *
6
- * Description
7
- *
8
- * @package 			Event Espresso
9
- * @subpackage    core
10
- * @author				Brent Christensen
11
- * @since 				4.5.0
12
- *
13
- */
3
+  *
4
+  * Class EE_Checkout
5
+  *
6
+  * Description
7
+  *
8
+  * @package 			Event Espresso
9
+  * @subpackage    core
10
+  * @author				Brent Christensen
11
+  * @since 				4.5.0
12
+  *
13
+  */
14 14
 class EE_Checkout {
15 15
 
16 16
 	/**
@@ -250,9 +250,9 @@  discard block
 block discarded – undo
250 250
 		$this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE );
251 251
 		$this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax;
252 252
 		$this->reg_cache_where_params = array(
253
-		    0 => array( 'REG_deleted' => false ),
254
-		    'order_by' => array( 'REG_count' => 'ASC' )
255
-        );
253
+			0 => array( 'REG_deleted' => false ),
254
+			'order_by' => array( 'REG_count' => 'ASC' )
255
+		);
256 256
 	}
257 257
 
258 258
 
@@ -807,10 +807,10 @@  discard block
 block discarded – undo
807 807
 	 */
808 808
 	public function visit_allows_processing_of_this_registration( EE_Registration $registration ) {
809 809
 		return ! $this->revisit
810
-		       || $this->primary_revisit
811
-		       || (
812
-			       $this->revisit && $this->reg_url_link === $registration->reg_url_link()
813
-		       )
810
+			   || $this->primary_revisit
811
+			   || (
812
+				   $this->revisit && $this->reg_url_link === $registration->reg_url_link()
813
+			   )
814 814
 			? true
815 815
 			: false;
816 816
 	}
@@ -1202,16 +1202,16 @@  discard block
 block discarded – undo
1202 1202
 	 * @return array
1203 1203
 	 * @throws \EE_Error
1204 1204
 	 */
1205
-    public function __sleep()
1206
-    {
1207
-	    if ( $this->primary_attendee_obj instanceof EE_Attendee && $this->primary_attendee_obj->ID() ) {
1208
-		    $this->primary_attendee_obj = $this->primary_attendee_obj->ID();
1209
-	    }        // remove the reg form and the checkout
1210
-	    if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
1211
-		    $this->transaction = $this->transaction->ID();
1212
-	    }        // remove the reg form and the checkout
1213
-        return array_diff( array_keys( get_object_vars( $this ) ), array( 'billing_form', 'registration_form' ) );
1214
-    }
1205
+	public function __sleep()
1206
+	{
1207
+		if ( $this->primary_attendee_obj instanceof EE_Attendee && $this->primary_attendee_obj->ID() ) {
1208
+			$this->primary_attendee_obj = $this->primary_attendee_obj->ID();
1209
+		}        // remove the reg form and the checkout
1210
+		if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
1211
+			$this->transaction = $this->transaction->ID();
1212
+		}        // remove the reg form and the checkout
1213
+		return array_diff( array_keys( get_object_vars( $this ) ), array( 'billing_form', 'registration_form' ) );
1214
+	}
1215 1215
 
1216 1216
 
1217 1217
 	/**
Please login to merge, or discard this patch.
Spacing   +207 added lines, -207 removed lines patch added patch discarded remove patch
@@ -247,11 +247,11 @@  discard block
 block discarded – undo
247 247
 		$this->reg_page_base_url = EE_Registry::instance()->CFG->core->reg_page_url();
248 248
 		$this->thank_you_page_url = EE_Registry::instance()->CFG->core->thank_you_page_url();
249 249
 		$this->cancel_page_url = EE_Registry::instance()->CFG->core->cancel_page_url();
250
-		$this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', TRUE );
250
+		$this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', TRUE);
251 251
 		$this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->ajax;
252 252
 		$this->reg_cache_where_params = array(
253
-		    0 => array( 'REG_deleted' => false ),
254
-		    'order_by' => array( 'REG_count' => 'ASC' )
253
+		    0 => array('REG_deleted' => false),
254
+		    'order_by' => array('REG_count' => 'ASC')
255 255
         );
256 256
 	}
257 257
 
@@ -263,8 +263,8 @@  discard block
 block discarded – undo
263 263
 	 * @return boolean
264 264
 	 */
265 265
 	public function any_reg_status_updated() {
266
-		foreach ( $this->reg_status_updated as $reg_status ) {
267
-			if ( $reg_status ) {
266
+		foreach ($this->reg_status_updated as $reg_status) {
267
+			if ($reg_status) {
268 268
 				return true;
269 269
 			}
270 270
 		}
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param $REG_ID
278 278
 	 * @return boolean
279 279
 	 */
280
-	public function reg_status_updated( $REG_ID ) {
281
-		return isset( $this->reg_status_updated[ $REG_ID ] ) ? $this->reg_status_updated[ $REG_ID ] : false;
280
+	public function reg_status_updated($REG_ID) {
281
+		return isset($this->reg_status_updated[$REG_ID]) ? $this->reg_status_updated[$REG_ID] : false;
282 282
 	}
283 283
 
284 284
 
@@ -287,8 +287,8 @@  discard block
 block discarded – undo
287 287
 	 * @param $REG_ID
288 288
 	 * @param $reg_status
289 289
 	 */
290
-	public function set_reg_status_updated( $REG_ID, $reg_status ) {
291
-		$this->reg_status_updated[ $REG_ID ] = filter_var( $reg_status, FILTER_VALIDATE_BOOLEAN );
290
+	public function set_reg_status_updated($REG_ID, $reg_status) {
291
+		$this->reg_status_updated[$REG_ID] = filter_var($reg_status, FILTER_VALIDATE_BOOLEAN);
292 292
 	}
293 293
 
294 294
 
@@ -309,7 +309,7 @@  discard block
 block discarded – undo
309 309
 	 * can ONLY be set by the  Finalize_Registration reg step
310 310
 	 */
311 311
 	public function set_exit_spco() {
312
-		if ( $this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration ) {
312
+		if ($this->current_step instanceof EE_SPCO_Reg_Step_Finalize_Registration) {
313 313
 			$this->exit_spco = true;
314 314
 		}
315 315
 	}
@@ -326,12 +326,12 @@  discard block
 block discarded – undo
326 326
 	 */
327 327
 	public function reset_for_current_request() {
328 328
 		$this->process_form_submission = FALSE;
329
-		$this->continue_reg = apply_filters( 'FHEE__EE_Checkout___construct___continue_reg', true );
329
+		$this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true);
330 330
 		$this->admin_request = is_admin() && ! EE_Registry::instance()->REQ->front_ajax;
331 331
 		$this->continue_reg = true;
332 332
 		$this->redirect = false;
333 333
 		// don't reset the cached redirect form if we're about to be asked to display it !!!
334
-		if ( EE_Registry::instance()->REQ->get( 'action', 'display_spco_reg_step' ) !== 'redirect_form' ) {
334
+		if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') {
335 335
 			$this->redirect_form = '';
336 336
 		}
337 337
 		$this->redirect_url = '';
@@ -348,8 +348,8 @@  discard block
 block discarded – undo
348 348
 	 * @param EE_SPCO_Reg_Step $reg_step_obj
349 349
 	 * @return    void
350 350
 	 */
351
-	public function add_reg_step( EE_SPCO_Reg_Step $reg_step_obj ) {
352
-		$this->reg_steps[ $reg_step_obj->slug()  ] = $reg_step_obj;
351
+	public function add_reg_step(EE_SPCO_Reg_Step $reg_step_obj) {
352
+		$this->reg_steps[$reg_step_obj->slug()] = $reg_step_obj;
353 353
 	}
354 354
 
355 355
 
@@ -365,22 +365,22 @@  discard block
 block discarded – undo
365 365
 	 * @return    void
366 366
 	 * @throws \EE_Error
367 367
 	 */
368
-	public function skip_reg_step( $reg_step_slug = '' ) {
369
-		$step_to_skip = $this->find_reg_step( $reg_step_slug );
370
-		if ( $step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step() ) {
371
-			$step_to_skip->set_is_current_step( false );
368
+	public function skip_reg_step($reg_step_slug = '') {
369
+		$step_to_skip = $this->find_reg_step($reg_step_slug);
370
+		if ($step_to_skip instanceof EE_SPCO_Reg_Step && $step_to_skip->is_current_step()) {
371
+			$step_to_skip->set_is_current_step(false);
372 372
 			$step_to_skip->set_completed();
373 373
 			// advance to the next step
374
-			$this->set_current_step( $this->next_step->slug() );
374
+			$this->set_current_step($this->next_step->slug());
375 375
 			// also reset the step param in the request in case any other code references that directly
376
-			EE_Registry::instance()->REQ->set( 'step', $this->current_step->slug() );
376
+			EE_Registry::instance()->REQ->set('step', $this->current_step->slug());
377 377
 			// since we are skipping a step and setting the current step to be what was previously the next step,
378 378
 			// we need to check that the next step is now correct, and not still set to the current step.
379
-			if ( $this->current_step->slug() === $this->next_step->slug() ) {
379
+			if ($this->current_step->slug() === $this->next_step->slug()) {
380 380
 				// correctly setup the next step
381 381
 				$this->set_next_step();
382 382
 			}
383
-			$this->set_reg_step_initiated( $this->current_step );
383
+			$this->set_reg_step_initiated($this->current_step);
384 384
 		}
385 385
 	}
386 386
 
@@ -394,14 +394,14 @@  discard block
 block discarded – undo
394 394
 	 * @param bool   $reset whether to reset reg steps after removal
395 395
 	 * @throws EE_Error
396 396
 	 */
397
-	public function remove_reg_step( $reg_step_slug = '', $reset = true ) {
398
-		unset( $this->reg_steps[ $reg_step_slug  ] );
399
-		if ( $this->transaction instanceof EE_Transaction ) {
397
+	public function remove_reg_step($reg_step_slug = '', $reset = true) {
398
+		unset($this->reg_steps[$reg_step_slug]);
399
+		if ($this->transaction instanceof EE_Transaction) {
400 400
 			// now remove reg step from TXN and save
401
-			$this->transaction->remove_reg_step( $reg_step_slug );
401
+			$this->transaction->remove_reg_step($reg_step_slug);
402 402
 			$this->transaction->save();
403 403
 		}
404
-		if ( $reset ) {
404
+		if ($reset) {
405 405
 			$this->reset_reg_steps();
406 406
 		}
407 407
 	}
@@ -416,9 +416,9 @@  discard block
 block discarded – undo
416 416
 	 * @param int    $order
417 417
 	 * @return    void
418 418
 	 */
419
-	public function set_reg_step_order( $reg_step_slug = '', $order = 100 ) {
420
-		if ( isset( $this->reg_steps[ $reg_step_slug  ] )) {
421
-			$this->reg_steps[ $reg_step_slug ]->set_order( $order );
419
+	public function set_reg_step_order($reg_step_slug = '', $order = 100) {
420
+		if (isset($this->reg_steps[$reg_step_slug])) {
421
+			$this->reg_steps[$reg_step_slug]->set_order($order);
422 422
 		}
423 423
 	}
424 424
 
@@ -431,25 +431,25 @@  discard block
 block discarded – undo
431 431
 	 * @param string $current_step
432 432
 	 * @return    void
433 433
 	 */
434
-	public function set_current_step( $current_step ) {
434
+	public function set_current_step($current_step) {
435 435
 		// grab what step we're on
436
-		$this->current_step = isset( $this->reg_steps[ $current_step ] ) ? $this->reg_steps[ $current_step ] : reset( $this->reg_steps );
436
+		$this->current_step = isset($this->reg_steps[$current_step]) ? $this->reg_steps[$current_step] : reset($this->reg_steps);
437 437
 		// verify instance
438
-		if ( $this->current_step instanceof EE_SPCO_Reg_Step ) {
438
+		if ($this->current_step instanceof EE_SPCO_Reg_Step) {
439 439
 			// we don't want to repeat completed steps if this is the first time through SPCO
440
-			if ( $this->continue_reg && ! $this->revisit && $this->current_step->completed() ) {
440
+			if ($this->continue_reg && ! $this->revisit && $this->current_step->completed()) {
441 441
 				// so advance to the next step
442 442
 				$this->set_next_step();
443
-				if ( $this->next_step instanceof EE_SPCO_Reg_Step ) {
443
+				if ($this->next_step instanceof EE_SPCO_Reg_Step) {
444 444
 					// and attempt to set it as the current step
445
-					$this->set_current_step( $this->next_step->slug() );
445
+					$this->set_current_step($this->next_step->slug());
446 446
 				}
447 447
 				return;
448 448
 			}
449
-			$this->current_step->set_is_current_step( TRUE );
449
+			$this->current_step->set_is_current_step(TRUE);
450 450
 		} else {
451 451
 			EE_Error::add_error(
452
-				__( 'The current step could not be set.', 'event_espresso' ),
452
+				__('The current step could not be set.', 'event_espresso'),
453 453
 				__FILE__, __FUNCTION__, __LINE__
454 454
 			);
455 455
 		}
@@ -466,20 +466,20 @@  discard block
 block discarded – undo
466 466
 	 */
467 467
 	public function set_next_step() {
468 468
 		// set pointer to start of array
469
-		reset( $this->reg_steps );
469
+		reset($this->reg_steps);
470 470
 		// if there is more than one step
471
-		if ( count( $this->reg_steps ) > 1 ) {
471
+		if (count($this->reg_steps) > 1) {
472 472
 			// advance to the current step and set pointer
473
-			while ( key( $this->reg_steps ) !== $this->current_step->slug() && key( $this->reg_steps ) !== '' ) {
474
-				next( $this->reg_steps );
473
+			while (key($this->reg_steps) !== $this->current_step->slug() && key($this->reg_steps) !== '') {
474
+				next($this->reg_steps);
475 475
 			}
476 476
 		}
477 477
 		// advance one more spot ( if it exists )
478
-		$this->next_step = next( $this->reg_steps );
478
+		$this->next_step = next($this->reg_steps);
479 479
 		// verify instance
480
-		$this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step  : NULL;
480
+		$this->next_step = $this->next_step instanceof EE_SPCO_Reg_Step ? $this->next_step : NULL;
481 481
 		// then back to current step to reset
482
-		prev( $this->reg_steps );
482
+		prev($this->reg_steps);
483 483
 	}
484 484
 
485 485
 
@@ -493,8 +493,8 @@  discard block
 block discarded – undo
493 493
 	 *  @return 	EE_SPCO_Reg_Step | null
494 494
 	 */
495 495
 	public function get_next_reg_step() {
496
-		$next = next( $this->reg_steps );
497
-		prev( $this->reg_steps );
496
+		$next = next($this->reg_steps);
497
+		prev($this->reg_steps);
498 498
 		return $next instanceof EE_SPCO_Reg_Step ? $next : null;
499 499
 	}
500 500
 
@@ -509,8 +509,8 @@  discard block
 block discarded – undo
509 509
 	 *  @return 	EE_SPCO_Reg_Step | null
510 510
 	 */
511 511
 	public function get_prev_reg_step() {
512
-		$prev = prev( $this->reg_steps );
513
-		next( $this->reg_steps );
512
+		$prev = prev($this->reg_steps);
513
+		next($this->reg_steps);
514 514
 		return $prev instanceof EE_SPCO_Reg_Step ? $prev : null;
515 515
 	}
516 516
 
@@ -523,8 +523,8 @@  discard block
 block discarded – undo
523 523
 	 * @return void
524 524
 	 */
525 525
 	public function sort_reg_steps() {
526
-		$reg_step_sorting_callback = apply_filters( 'FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback' );
527
-		uasort( $this->reg_steps, array( $this, $reg_step_sorting_callback ));
526
+		$reg_step_sorting_callback = apply_filters('FHEE__EE_Checkout__sort_reg_steps__reg_step_sorting_callback', 'reg_step_sorting_callback');
527
+		uasort($this->reg_steps, array($this, $reg_step_sorting_callback));
528 528
 	}
529 529
 
530 530
 
@@ -537,19 +537,19 @@  discard block
 block discarded – undo
537 537
 	 * @param string $reg_step_slug
538 538
 	 * @return EE_SPCO_Reg_Step|null
539 539
 	 */
540
-	public function find_reg_step( $reg_step_slug = '' ) {
541
-		if ( ! empty( $reg_step_slug ) ) {
540
+	public function find_reg_step($reg_step_slug = '') {
541
+		if ( ! empty($reg_step_slug)) {
542 542
 			// copy reg step array
543 543
 			$reg_steps = $this->reg_steps;
544 544
 			// set pointer to start of array
545
-			reset( $reg_steps );
545
+			reset($reg_steps);
546 546
 			// if there is more than one step
547
-			if ( count( $reg_steps ) > 1 ) {
547
+			if (count($reg_steps) > 1) {
548 548
 				// advance to the current step and set pointer
549
-				while ( key( $reg_steps ) !== $reg_step_slug && key( $reg_steps ) !== '' ) {
550
-					next( $reg_steps );
549
+				while (key($reg_steps) !== $reg_step_slug && key($reg_steps) !== '') {
550
+					next($reg_steps);
551 551
 				}
552
-				return current( $reg_steps );
552
+				return current($reg_steps);
553 553
 			}
554 554
 		}
555 555
 		return null;
@@ -565,17 +565,17 @@  discard block
 block discarded – undo
565 565
 	 * @param EE_SPCO_Reg_Step $reg_step_B
566 566
 	 * @return int
567 567
 	 */
568
-	public function reg_step_sorting_callback( EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B ) {
568
+	public function reg_step_sorting_callback(EE_SPCO_Reg_Step $reg_step_A, EE_SPCO_Reg_Step $reg_step_B) {
569 569
 		// send finalize_registration step to the end of the array
570
-		if ( $reg_step_A->slug() === 'finalize_registration' ) {
570
+		if ($reg_step_A->slug() === 'finalize_registration') {
571 571
 			return 1;
572
-		} else if ( $reg_step_B->slug() === 'finalize_registration' ) {
572
+		} else if ($reg_step_B->slug() === 'finalize_registration') {
573 573
 			return -1;
574 574
 		}
575
-		if ( $reg_step_A->order() === $reg_step_B->order() ) {
575
+		if ($reg_step_A->order() === $reg_step_B->order()) {
576 576
 			return 0;
577 577
 		}
578
-		return ( $reg_step_A->order() > $reg_step_B->order() ) ? 1 : -1;
578
+		return ($reg_step_A->order() > $reg_step_B->order()) ? 1 : -1;
579 579
 	}
580 580
 
581 581
 
@@ -587,7 +587,7 @@  discard block
 block discarded – undo
587 587
 	 * @param    EE_SPCO_Reg_Step $reg_step
588 588
 	 * @throws \EE_Error
589 589
 	 */
590
-	public function set_reg_step_initiated( EE_SPCO_Reg_Step $reg_step ) {
590
+	public function set_reg_step_initiated(EE_SPCO_Reg_Step $reg_step) {
591 591
 		// call set_reg_step_initiated ???
592 592
 		if (
593 593
 			// first time visiting SPCO ?
@@ -600,11 +600,11 @@  discard block
 block discarded – undo
600 600
 			)
601 601
 		) {
602 602
 			// set the start time for this reg step
603
-			if ( ! $this->transaction->set_reg_step_initiated( $reg_step->slug() ) ) {
604
-				if ( WP_DEBUG ) {
603
+			if ( ! $this->transaction->set_reg_step_initiated($reg_step->slug())) {
604
+				if (WP_DEBUG) {
605 605
 					EE_Error::add_error(
606 606
 						sprintf(
607
-							__( 'The "%1$s" registration step was not initialized properly.', 'event_espresso' ),
607
+							__('The "%1$s" registration step was not initialized properly.', 'event_espresso'),
608 608
 							$reg_step->name()
609 609
 						),
610 610
 						__FILE__, __FUNCTION__, __LINE__
@@ -623,10 +623,10 @@  discard block
 block discarded – undo
623 623
 	 * 	@return 	void
624 624
 	 */
625 625
 	public function set_reg_step_JSON_info() {
626
-		EE_Registry::$i18n_js_strings[ 'reg_steps' ] = array();
626
+		EE_Registry::$i18n_js_strings['reg_steps'] = array();
627 627
 		// pass basic reg step data to JS
628
-		foreach ( $this->reg_steps as $reg_step ) {
629
-			EE_Registry::$i18n_js_strings[ 'reg_steps' ][] = $reg_step->slug();
628
+		foreach ($this->reg_steps as $reg_step) {
629
+			EE_Registry::$i18n_js_strings['reg_steps'][] = $reg_step->slug();
630 630
 		}
631 631
 		// reset reg step html
632 632
 //		$this->json_response->set_reg_step_html( '' );
@@ -642,7 +642,7 @@  discard block
 block discarded – undo
642 642
 	 */
643 643
 	public function reset_reg_steps() {
644 644
 		$this->sort_reg_steps();
645
-		$this->set_current_step( EE_Registry::instance()->REQ->get( 'step' ));
645
+		$this->set_current_step(EE_Registry::instance()->REQ->get('step'));
646 646
 		$this->set_next_step();
647 647
 		// the text that appears on the reg step form submit button
648 648
 		$this->current_step->set_submit_button_text();
@@ -659,9 +659,9 @@  discard block
 block discarded – undo
659 659
 	 */
660 660
 	public function get_registration_time_limit() {
661 661
 
662
-		$registration_time_limit = (float)( EE_Registry::instance()	->SSN->expiration() - time() );
662
+		$registration_time_limit = (float) (EE_Registry::instance()	->SSN->expiration() - time());
663 663
 		$time_limit_format = $registration_time_limit > 60 * MINUTE_IN_SECONDS ? 'H:i:s' : 'i:s';
664
-		$registration_time_limit = date( $time_limit_format, $registration_time_limit );
664
+		$registration_time_limit = date($time_limit_format, $registration_time_limit);
665 665
 		return apply_filters(
666 666
 			'FHEE__EE_Checkout__get_registration_time_limit__registration_time_limit',
667 667
 			$registration_time_limit
@@ -681,7 +681,7 @@  discard block
 block discarded – undo
681 681
 		//		overpaid TXN
682 682
 		//		free TXN ( total = 0.00 )
683 683
 		// then payment required is TRUE
684
-		return ! ( $this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free() ) ? TRUE : FALSE;
684
+		return ! ($this->admin_request || $this->transaction->is_completed() || $this->transaction->is_overpaid() || $this->transaction->is_free()) ? TRUE : FALSE;
685 685
 	}
686 686
 
687 687
 
@@ -693,12 +693,12 @@  discard block
 block discarded – undo
693 693
 	 * @param EE_Transaction $transaction
694 694
 	 * @return EE_Cart
695 695
 	 */
696
-	public function get_cart_for_transaction( $transaction ) {
697
-		$session = EE_Registry::instance()->load_core( 'Session' );
698
-		$cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn( $transaction, $session ) : null;
696
+	public function get_cart_for_transaction($transaction) {
697
+		$session = EE_Registry::instance()->load_core('Session');
698
+		$cart = $transaction instanceof EE_Transaction ? EE_Cart::get_cart_from_txn($transaction, $session) : null;
699 699
 		// verify cart
700
-		if ( ! $cart instanceof EE_Cart ) {
701
-			$cart = EE_Registry::instance()->load_core( 'Cart' );
700
+		if ( ! $cart instanceof EE_Cart) {
701
+			$cart = EE_Registry::instance()->load_core('Cart');
702 702
 		}
703 703
 
704 704
 		return $cart;
@@ -714,8 +714,8 @@  discard block
 block discarded – undo
714 714
 	 */
715 715
 	public function initialize_txn_reg_steps_array() {
716 716
 		$txn_reg_steps_array = array();
717
-		foreach ( $this->reg_steps as $reg_step ) {
718
-			$txn_reg_steps_array[ $reg_step->slug() ] = FALSE;
717
+		foreach ($this->reg_steps as $reg_step) {
718
+			$txn_reg_steps_array[$reg_step->slug()] = FALSE;
719 719
 		}
720 720
 		return $txn_reg_steps_array;
721 721
 	}
@@ -731,14 +731,14 @@  discard block
 block discarded – undo
731 731
 	 */
732 732
 	public function update_txn_reg_steps_array() {
733 733
 		$updated = false;
734
-		foreach ( $this->reg_steps as $reg_step ) {
735
-			if ( $reg_step->completed() ) {
736
-				$updated = $this->transaction->set_reg_step_completed( $reg_step->slug() )
734
+		foreach ($this->reg_steps as $reg_step) {
735
+			if ($reg_step->completed()) {
736
+				$updated = $this->transaction->set_reg_step_completed($reg_step->slug())
737 737
 					? true
738 738
 					: $updated;
739 739
 			}
740 740
 		}
741
-		if ( $updated ) {
741
+		if ($updated) {
742 742
 			$this->transaction->save();
743 743
 		}
744 744
 		return $updated;
@@ -754,14 +754,14 @@  discard block
 block discarded – undo
754 754
 	 * @throws \EE_Error
755 755
 	 */
756 756
 	public function stash_transaction_and_checkout() {
757
-		if ( ! $this->revisit ) {
757
+		if ( ! $this->revisit) {
758 758
 			$this->update_txn_reg_steps_array();
759 759
 		}
760 760
 		$this->track_transaction_and_registration_status_updates();
761 761
 		// save all data to the db, but suppress errors
762 762
 		//$this->save_all_data( FALSE );
763 763
 		// cache the checkout in the session
764
-		EE_Registry::instance()->SSN->set_checkout( $this );
764
+		EE_Registry::instance()->SSN->set_checkout($this);
765 765
 	}
766 766
 
767 767
 
@@ -776,15 +776,15 @@  discard block
 block discarded – undo
776 776
 	 */
777 777
 	public function track_transaction_and_registration_status_updates() {
778 778
 		// verify the transaction
779
-		if ( $this->transaction instanceof EE_Transaction ) {
779
+		if ($this->transaction instanceof EE_Transaction) {
780 780
 			// has there been a TXN status change during this checkout?
781 781
 			$this->txn_status_updated = $this->transaction->txn_status_updated();
782 782
 			/** @type EE_Registration_Processor $registration_processor */
783
-			$registration_processor = EE_Registry::instance()->load_class( 'Registration_Processor' );
783
+			$registration_processor = EE_Registry::instance()->load_class('Registration_Processor');
784 784
 			// grab the saved registrations from the transaction
785
-			foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $registration ) {
786
-				if ( $registration_processor->reg_status_updated( $registration->ID() ) ) {
787
-					$this->set_reg_status_updated( $registration->ID(), true );
785
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as $registration) {
786
+				if ($registration_processor->reg_status_updated($registration->ID())) {
787
+					$this->set_reg_status_updated($registration->ID(), true);
788 788
 				}
789 789
 			}
790 790
 		}
@@ -805,7 +805,7 @@  discard block
 block discarded – undo
805 805
 	 * @return    bool
806 806
 	 * @throws \EE_Error
807 807
 	 */
808
-	public function visit_allows_processing_of_this_registration( EE_Registration $registration ) {
808
+	public function visit_allows_processing_of_this_registration(EE_Registration $registration) {
809 809
 		return ! $this->revisit
810 810
 		       || $this->primary_revisit
811 811
 		       || (
@@ -838,18 +838,18 @@  discard block
 block discarded – undo
838 838
 	 * @return bool
839 839
 	 * @throws \EE_Error
840 840
 	 */
841
-	public function save_all_data( $show_errors = TRUE ) {
841
+	public function save_all_data($show_errors = TRUE) {
842 842
 		// verify the transaction
843
-		if ( $this->transaction instanceof EE_Transaction ) {
843
+		if ($this->transaction instanceof EE_Transaction) {
844 844
 			// save to ensure that TXN has ID
845 845
 			$this->transaction->save();
846 846
 			// grab the saved registrations from the transaction
847
-			foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as  $registration ) {
848
-				$this->_save_registration( $registration, $show_errors );
847
+			foreach ($this->transaction->registrations($this->reg_cache_where_params) as  $registration) {
848
+				$this->_save_registration($registration, $show_errors);
849 849
 			}
850 850
 		} else {
851
-			if ( $show_errors ) {
852
-				EE_Error::add_error( __( 'A valid Transaction was not found when attempting to save your registration information.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
851
+			if ($show_errors) {
852
+				EE_Error::add_error(__('A valid Transaction was not found when attempting to save your registration information.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
853 853
 			}
854 854
 			return FALSE;
855 855
 		}
@@ -866,32 +866,32 @@  discard block
 block discarded – undo
866 866
 	 * @return void
867 867
 	 * @throws \EE_Error
868 868
 	 */
869
-	private function _save_registration( $registration, $show_errors = TRUE  ) {
869
+	private function _save_registration($registration, $show_errors = TRUE) {
870 870
 		// verify object
871
-		if ( $registration instanceof EE_Registration ) {
871
+		if ($registration instanceof EE_Registration) {
872 872
 			// should this registration be processed during this visit ?
873
-			if ( $this->visit_allows_processing_of_this_registration( $registration ) ) {
873
+			if ($this->visit_allows_processing_of_this_registration($registration)) {
874 874
 				//set TXN ID
875
-				if ( ! $registration->transaction_ID() ) {
876
-					$registration->set_transaction_id( $this->transaction->ID() );
875
+				if ( ! $registration->transaction_ID()) {
876
+					$registration->set_transaction_id($this->transaction->ID());
877 877
 				}
878 878
 				// verify and save the attendee
879
-				$this->_save_registration_attendee( $registration, $show_errors );
879
+				$this->_save_registration_attendee($registration, $show_errors);
880 880
 				// save answers to reg form questions
881
-				$this->_save_registration_answers( $registration, $show_errors );
881
+				$this->_save_registration_answers($registration, $show_errors);
882 882
 				// save changes
883 883
 				$registration->save();
884 884
 				// update txn cache
885
-				if ( ! $this->transaction->update_cache_after_object_save( 'Registration', $registration )) {
886
-					if ( $show_errors ) {
887
-						EE_Error::add_error( __( 'The newly saved Registration object could not be cached on the Transaction.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
885
+				if ( ! $this->transaction->update_cache_after_object_save('Registration', $registration)) {
886
+					if ($show_errors) {
887
+						EE_Error::add_error(__('The newly saved Registration object could not be cached on the Transaction.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
888 888
 					}
889 889
 				}
890 890
 			}
891 891
 		} else {
892
-			if ( $show_errors ) {
892
+			if ($show_errors) {
893 893
 				EE_Error::add_error(
894
-					__( 'An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso' ),
894
+					__('An invalid Registration object was discovered when attempting to save your registration information.', 'event_espresso'),
895 895
 					__FILE__, __FUNCTION__, __LINE__
896 896
 				);
897 897
 			}
@@ -908,25 +908,25 @@  discard block
 block discarded – undo
908 908
 	 * @return void
909 909
 	 * @throws \EE_Error
910 910
 	 */
911
-	private function _save_registration_attendee( $registration, $show_errors = TRUE ) {
912
-		if ( $registration->attendee() instanceof EE_Attendee ) {
911
+	private function _save_registration_attendee($registration, $show_errors = TRUE) {
912
+		if ($registration->attendee() instanceof EE_Attendee) {
913 913
 			// save so that ATT has ID
914 914
 			$registration->attendee()->save();
915
-			if ( ! $registration->update_cache_after_object_save( 'Attendee', $registration->attendee() ) ) {
916
-				if ( $show_errors ) {
915
+			if ( ! $registration->update_cache_after_object_save('Attendee', $registration->attendee())) {
916
+				if ($show_errors) {
917 917
 					EE_Error::add_error(
918
-						__( 'The newly saved Attendee object could not be cached on the registration.', 'event_espresso' ),
918
+						__('The newly saved Attendee object could not be cached on the registration.', 'event_espresso'),
919 919
 						__FILE__, __FUNCTION__, __LINE__
920 920
 					);
921 921
 				}
922 922
 			}
923 923
 		} else {
924
-			if ( $show_errors ) {
924
+			if ($show_errors) {
925 925
 				EE_Error::add_error(
926 926
 					sprintf(
927 927
 						'%1$s||%1$s $attendee = %2$s',
928
-						__( 'Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso' ),
929
-						var_export( $registration->attendee(), true )
928
+						__('Either no Attendee information was found, or an invalid Attendee object was discovered when attempting to save your registration information.', 'event_espresso'),
929
+						var_export($registration->attendee(), true)
930 930
 					),
931 931
 					__FILE__, __FUNCTION__, __LINE__
932 932
 				);
@@ -944,25 +944,25 @@  discard block
 block discarded – undo
944 944
 	 * @return void
945 945
 	 * @throws \EE_Error
946 946
 	 */
947
-	private function _save_registration_answers( $registration, $show_errors = TRUE ) {
947
+	private function _save_registration_answers($registration, $show_errors = TRUE) {
948 948
 		// now save the answers
949
-		foreach ( $registration->answers() as $cache_key => $answer ) {
949
+		foreach ($registration->answers() as $cache_key => $answer) {
950 950
 			// verify object
951
-			if ( $answer instanceof EE_Answer ) {
952
-				$answer->set_registration( $registration->ID() );
951
+			if ($answer instanceof EE_Answer) {
952
+				$answer->set_registration($registration->ID());
953 953
 				$answer->save();
954
-				if ( ! $registration->update_cache_after_object_save( 'Answer', $answer, $cache_key )) {
955
-					if ( $show_errors ) {
954
+				if ( ! $registration->update_cache_after_object_save('Answer', $answer, $cache_key)) {
955
+					if ($show_errors) {
956 956
 						EE_Error::add_error(
957
-							__( 'The newly saved Answer object could not be cached on the registration.', 'event_espresso' ),
957
+							__('The newly saved Answer object could not be cached on the registration.', 'event_espresso'),
958 958
 							__FILE__, __FUNCTION__, __LINE__
959 959
 						);
960 960
 					}
961 961
 				}
962 962
 			} else {
963
-				if ( $show_errors ) {
963
+				if ($show_errors) {
964 964
 					EE_Error::add_error(
965
-						__( 'An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso' ),
965
+						__('An invalid Answer object was discovered when attempting to save your registration information.', 'event_espresso'),
966 966
 						__FILE__, __FUNCTION__, __LINE__
967 967
 					);
968 968
 				}
@@ -981,7 +981,7 @@  discard block
 block discarded – undo
981 981
 	 * @return bool
982 982
 	 * @throws \EE_Error
983 983
 	 */
984
-	public function refresh_all_entities( $from_db = false ) {
984
+	public function refresh_all_entities($from_db = false) {
985 985
 		$from_db = $this->current_step->is_final_step() || $this->action === 'process_gateway_response'
986 986
 			? true
987 987
 			: $from_db;
@@ -1005,11 +1005,11 @@  discard block
 block discarded – undo
1005 1005
 	 */
1006 1006
 	protected function refresh_from_db() {
1007 1007
 		// verify the transaction
1008
-		if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
1008
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1009 1009
 			// pull fresh TXN data from the db
1010
-			$this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db( $this->transaction->ID() );
1010
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_from_db($this->transaction->ID());
1011 1011
 			// update EE_Checkout's cached primary_attendee object
1012
-			$this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db( $this->transaction );
1012
+			$this->primary_attendee_obj = $this->_refresh_primary_attendee_obj_from_db($this->transaction);
1013 1013
 			// update EE_Checkout's cached payment object
1014 1014
 			$payment = $this->transaction->last_payment();
1015 1015
 			$this->payment = $payment instanceof EE_Payment ? $payment : $this->payment;
@@ -1017,9 +1017,9 @@  discard block
 block discarded – undo
1017 1017
 			$payment_method = $this->payment instanceof EE_Payment ? $this->payment->payment_method() : null;
1018 1018
 			$this->payment_method = $payment_method instanceof EE_Payment_Method ? $payment_method : $this->payment_method;
1019 1019
 			//now refresh the cart, based on the TXN
1020
-			$this->cart = $this->get_cart_for_transaction( $this->transaction );
1020
+			$this->cart = $this->get_cart_for_transaction($this->transaction);
1021 1021
 		} else {
1022
-			EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
1022
+			EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1023 1023
 			return FALSE;
1024 1024
 		}
1025 1025
 		return TRUE;
@@ -1034,21 +1034,21 @@  discard block
 block discarded – undo
1034 1034
 	 * @return  EE_Attendee | null
1035 1035
 	 * @throws \EE_Error
1036 1036
 	 */
1037
-	protected function _refresh_primary_attendee_obj_from_db( EE_Transaction $transaction ) {
1037
+	protected function _refresh_primary_attendee_obj_from_db(EE_Transaction $transaction) {
1038 1038
 
1039 1039
 		$primary_attendee_obj = null;
1040 1040
 		// grab the saved registrations from the transaction
1041
-		foreach ( $transaction->registrations( $this->reg_cache_where_params, true ) as $registration ) {
1041
+		foreach ($transaction->registrations($this->reg_cache_where_params, true) as $registration) {
1042 1042
 			// verify object
1043
-			if ( $registration instanceof EE_Registration ) {
1043
+			if ($registration instanceof EE_Registration) {
1044 1044
 				$attendee = $registration->attendee();
1045 1045
 				// verify object && maybe cache primary_attendee_obj ?
1046
-				if ( $attendee instanceof EE_Attendee&& $registration->is_primary_registrant() ) {
1046
+				if ($attendee instanceof EE_Attendee && $registration->is_primary_registrant()) {
1047 1047
 					$primary_attendee_obj = $attendee;
1048 1048
 				}
1049 1049
 			} else {
1050 1050
 				EE_Error::add_error(
1051
-						__( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1051
+						__('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1052 1052
 						__FILE__, __FUNCTION__, __LINE__
1053 1053
 				);
1054 1054
 			}
@@ -1069,43 +1069,43 @@  discard block
 block discarded – undo
1069 1069
 	 */
1070 1070
 	protected function refresh_entity_map() {
1071 1071
 		// verify the transaction
1072
-		if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
1072
+		if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1073 1073
 			// never cache payment info
1074
-			$this->transaction->clear_cache( 'Payment' );
1074
+			$this->transaction->clear_cache('Payment');
1075 1075
 			// is the Payment Options Reg Step completed ?
1076
-			if ( $this->transaction->reg_step_completed( 'payment_options' ) ) {
1076
+			if ($this->transaction->reg_step_completed('payment_options')) {
1077 1077
 				// then check for payments and update TXN accordingly
1078 1078
 				/** @type EE_Transaction_Payments $transaction_payments */
1079
-				$transaction_payments = EE_Registry::instance()->load_class( 'Transaction_Payments' );
1080
-				$transaction_payments->calculate_total_payments_and_update_status( $this->transaction );
1079
+				$transaction_payments = EE_Registry::instance()->load_class('Transaction_Payments');
1080
+				$transaction_payments->calculate_total_payments_and_update_status($this->transaction);
1081 1081
 			}
1082 1082
 			// grab the saved registrations from the transaction
1083 1083
 			foreach (
1084
-				$this->transaction->registrations( $this->reg_cache_where_params ) as $reg_cache_ID => $registration
1084
+				$this->transaction->registrations($this->reg_cache_where_params) as $reg_cache_ID => $registration
1085 1085
 			) {
1086
-				$this->_refresh_registration( $reg_cache_ID, $registration );
1086
+				$this->_refresh_registration($reg_cache_ID, $registration);
1087 1087
 			}
1088 1088
 			// make sure our cached TXN is added to the model entity mapper
1089
-			$this->transaction = $this->transaction->get_model()->refresh_entity_map_with( $this->transaction->ID(), $this->transaction );
1089
+			$this->transaction = $this->transaction->get_model()->refresh_entity_map_with($this->transaction->ID(), $this->transaction);
1090 1090
 
1091 1091
 		} else {
1092
-			EE_Error::add_error( __( 'A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
1092
+			EE_Error::add_error(__('A valid Transaction was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1093 1093
 			return FALSE;
1094 1094
 		}
1095 1095
 		// verify and update the cart because inaccurate totals are not so much fun
1096
-		if ( $this->cart instanceof EE_Cart ) {
1096
+		if ($this->cart instanceof EE_Cart) {
1097 1097
 			$grand_total = $this->cart->get_grand_total();
1098
-			if ( $grand_total instanceof EE_Line_Item && $grand_total->ID() ) {
1098
+			if ($grand_total instanceof EE_Line_Item && $grand_total->ID()) {
1099 1099
 				$grand_total->recalculate_total_including_taxes();
1100 1100
 				$grand_total = $grand_total->get_model()->refresh_entity_map_with(
1101 1101
 					$this->cart->get_grand_total()->ID(),
1102 1102
 					$this->cart->get_grand_total()
1103 1103
 				);
1104 1104
 			}
1105
-			if ( $grand_total instanceof EE_Line_Item ) {
1106
-				$this->cart = EE_Cart::instance( $grand_total );
1105
+			if ($grand_total instanceof EE_Line_Item) {
1106
+				$this->cart = EE_Cart::instance($grand_total);
1107 1107
 			} else {
1108
-				EE_Error::add_error( __( 'A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1108
+				EE_Error::add_error(__('A valid Cart was not found when attempting to update the model entity mapper.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1109 1109
 				return false;
1110 1110
 			}
1111 1111
 		}
@@ -1122,19 +1122,19 @@  discard block
 block discarded – undo
1122 1122
 	 * @return void
1123 1123
 	 * @throws \EE_Error
1124 1124
 	 */
1125
-	protected function _refresh_registration( $reg_cache_ID, $registration ) {
1125
+	protected function _refresh_registration($reg_cache_ID, $registration) {
1126 1126
 
1127 1127
 		// verify object
1128
-		if ( $registration instanceof EE_Registration ) {
1128
+		if ($registration instanceof EE_Registration) {
1129 1129
 			// update the entity mapper attendee
1130
-			$this->_refresh_registration_attendee( $registration );
1130
+			$this->_refresh_registration_attendee($registration);
1131 1131
 			// update the entity mapper answers for reg form questions
1132
-			$this->_refresh_registration_answers( $registration );
1132
+			$this->_refresh_registration_answers($registration);
1133 1133
 			// make sure the cached registration is added to the model entity mapper
1134
-			$registration->get_model()->refresh_entity_map_with( $reg_cache_ID, $registration );
1134
+			$registration->get_model()->refresh_entity_map_with($reg_cache_ID, $registration);
1135 1135
 		} else {
1136 1136
 			EE_Error::add_error(
1137
-				__( 'An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1137
+				__('An invalid Registration object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1138 1138
 				__FILE__, __FUNCTION__, __LINE__
1139 1139
 			);
1140 1140
 		}
@@ -1149,15 +1149,15 @@  discard block
 block discarded – undo
1149 1149
 	 * @return void
1150 1150
 	 * @throws \EE_Error
1151 1151
 	 */
1152
-	protected function _refresh_registration_attendee( $registration ) {
1152
+	protected function _refresh_registration_attendee($registration) {
1153 1153
 
1154 1154
 		$attendee = $registration->attendee();
1155 1155
 		// verify object
1156
-		if ( $attendee instanceof EE_Attendee && $attendee->ID() ) {
1156
+		if ($attendee instanceof EE_Attendee && $attendee->ID()) {
1157 1157
 			// make sure the cached attendee is added to the model entity mapper
1158
-			$registration->attendee()->get_model()->refresh_entity_map_with( $attendee->ID(), $attendee );
1158
+			$registration->attendee()->get_model()->refresh_entity_map_with($attendee->ID(), $attendee);
1159 1159
 			// maybe cache primary_attendee_obj ?
1160
-			if ( $registration->is_primary_registrant() ) {
1160
+			if ($registration->is_primary_registrant()) {
1161 1161
 				$this->primary_attendee_obj = $attendee;
1162 1162
 			}
1163 1163
 		}
@@ -1172,19 +1172,19 @@  discard block
 block discarded – undo
1172 1172
 	 * @return void
1173 1173
 	 * @throws \EE_Error
1174 1174
 	 */
1175
-	protected function _refresh_registration_answers( $registration ) {
1175
+	protected function _refresh_registration_answers($registration) {
1176 1176
 
1177 1177
 		// now update the answers
1178
-		foreach ( $registration->answers() as $cache_key => $answer ) {
1178
+		foreach ($registration->answers() as $cache_key => $answer) {
1179 1179
 			// verify object
1180
-			if ( $answer instanceof EE_Answer ) {
1181
-				if ( $answer->ID() ) {
1180
+			if ($answer instanceof EE_Answer) {
1181
+				if ($answer->ID()) {
1182 1182
 					// make sure the cached answer is added to the model entity mapper
1183
-					$answer->get_model()->refresh_entity_map_with( $answer->ID(), $answer );
1183
+					$answer->get_model()->refresh_entity_map_with($answer->ID(), $answer);
1184 1184
 				}
1185 1185
 			} else {
1186 1186
 				EE_Error::add_error(
1187
-					__( 'An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso' ),
1187
+					__('An invalid Answer object was discovered when attempting to update the model entity mapper.', 'event_espresso'),
1188 1188
 					__FILE__, __FUNCTION__, __LINE__
1189 1189
 				);
1190 1190
 			}
@@ -1204,13 +1204,13 @@  discard block
 block discarded – undo
1204 1204
 	 */
1205 1205
     public function __sleep()
1206 1206
     {
1207
-	    if ( $this->primary_attendee_obj instanceof EE_Attendee && $this->primary_attendee_obj->ID() ) {
1207
+	    if ($this->primary_attendee_obj instanceof EE_Attendee && $this->primary_attendee_obj->ID()) {
1208 1208
 		    $this->primary_attendee_obj = $this->primary_attendee_obj->ID();
1209 1209
 	    }        // remove the reg form and the checkout
1210
-	    if ( $this->transaction instanceof EE_Transaction && $this->transaction->ID() ) {
1210
+	    if ($this->transaction instanceof EE_Transaction && $this->transaction->ID()) {
1211 1211
 		    $this->transaction = $this->transaction->ID();
1212 1212
 	    }        // remove the reg form and the checkout
1213
-        return array_diff( array_keys( get_object_vars( $this ) ), array( 'billing_form', 'registration_form' ) );
1213
+        return array_diff(array_keys(get_object_vars($this)), array('billing_form', 'registration_form'));
1214 1214
     }
1215 1215
 
1216 1216
 
@@ -1220,15 +1220,15 @@  discard block
 block discarded – undo
1220 1220
 	 * this will reinstate the EE_Checkout object on each EE_SPCO_Reg_Step object
1221 1221
 	 */
1222 1222
 	public function __wakeup() {
1223
-		if ( ! $this->primary_attendee_obj instanceof EE_Attendee && absint( $this->primary_attendee_obj ) !== 0 ) {
1223
+		if ( ! $this->primary_attendee_obj instanceof EE_Attendee && absint($this->primary_attendee_obj) !== 0) {
1224 1224
 			// $this->primary_attendee_obj is actually just an ID, so use it to get the object from the db
1225
-			$this->primary_attendee_obj = EEM_Attendee::instance()->get_one_by_ID( $this->primary_attendee_obj );
1225
+			$this->primary_attendee_obj = EEM_Attendee::instance()->get_one_by_ID($this->primary_attendee_obj);
1226 1226
 		}
1227
-		if ( ! $this->transaction instanceof EE_Transaction && absint( $this->transaction ) !== 0 ) {
1227
+		if ( ! $this->transaction instanceof EE_Transaction && absint($this->transaction) !== 0) {
1228 1228
 			// $this->transaction is actually just an ID, so use it to get the object from the db
1229
-			$this->transaction = EEM_Transaction::instance()->get_one_by_ID( $this->transaction );
1229
+			$this->transaction = EEM_Transaction::instance()->get_one_by_ID($this->transaction);
1230 1230
 		}
1231
-		foreach ( $this->reg_steps as $reg_step ) {
1231
+		foreach ($this->reg_steps as $reg_step) {
1232 1232
 			$reg_step->checkout = $this;
1233 1233
 		}
1234 1234
 	}
@@ -1245,12 +1245,12 @@  discard block
 block discarded – undo
1245 1245
 	 * @param bool   $display_request
1246 1246
 	 * @throws \EE_Error
1247 1247
 	 */
1248
-	public function log( $class = '', $func = '', $line = '', $info = array(), $display_request = false ) {
1248
+	public function log($class = '', $func = '', $line = '', $info = array(), $display_request = false) {
1249 1249
 		$disabled = true;
1250
-		if ( WP_DEBUG && ! $disabled ) {
1251
-			$debug_data = get_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), array() );
1250
+		if (WP_DEBUG && ! $disabled) {
1251
+			$debug_data = get_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), array());
1252 1252
 			$default_data = array(
1253
-				$class 		=> $func . '() : ' . $line,
1253
+				$class 		=> $func.'() : '.$line,
1254 1254
 				'request->step' 		=> $this->step,
1255 1255
 				'request->action' 	=> $this->action,
1256 1256
 				'current_step->slug' => $this->current_step instanceof EE_SPCO_Reg_Step ?
@@ -1262,24 +1262,24 @@  discard block
 block discarded – undo
1262 1262
 				'reg_url_link' => $this->reg_url_link,
1263 1263
 				'REQ' => $display_request ? $_REQUEST : '',
1264 1264
 			);
1265
-			if ( $this->transaction instanceof EE_Transaction ) {
1266
-				$default_data[ 'TXN_status' ] 		= $this->transaction->status_ID();
1267
-				$default_data[ 'TXN_reg_steps' ] 	= $this->transaction->reg_steps();
1268
-				foreach ( $this->transaction->registrations( $this->reg_cache_where_params ) as $REG_ID => $registration ) {
1269
-					$default_data[ 'registrations' ][ $REG_ID ] = $registration->status_ID();
1265
+			if ($this->transaction instanceof EE_Transaction) {
1266
+				$default_data['TXN_status'] = $this->transaction->status_ID();
1267
+				$default_data['TXN_reg_steps'] = $this->transaction->reg_steps();
1268
+				foreach ($this->transaction->registrations($this->reg_cache_where_params) as $REG_ID => $registration) {
1269
+					$default_data['registrations'][$REG_ID] = $registration->status_ID();
1270 1270
 				}
1271
-				if ( $this->transaction->ID() ) {
1272
-					$TXN_ID = 'EE_Transaction: ' . $this->transaction->ID();
1271
+				if ($this->transaction->ID()) {
1272
+					$TXN_ID = 'EE_Transaction: '.$this->transaction->ID();
1273 1273
 					// don't serialize objects
1274
-					$info = $this->_strip_objects( $info );
1275
-					if ( ! isset( $debug_data[ $TXN_ID ] ) ) {
1276
-						$debug_data[ $TXN_ID ] = array();
1274
+					$info = $this->_strip_objects($info);
1275
+					if ( ! isset($debug_data[$TXN_ID])) {
1276
+						$debug_data[$TXN_ID] = array();
1277 1277
 					}
1278
-					$debug_data[ $TXN_ID ][ microtime() ] = array_merge(
1278
+					$debug_data[$TXN_ID][microtime()] = array_merge(
1279 1279
 						$default_data,
1280 1280
 						$info
1281 1281
 					);
1282
-					update_option( 'EE_DEBUG_SPCO_' . EE_Session::instance()->id(), $debug_data );
1282
+					update_option('EE_DEBUG_SPCO_'.EE_Session::instance()->id(), $debug_data);
1283 1283
 				}
1284 1284
 			}
1285 1285
 		}
@@ -1292,23 +1292,23 @@  discard block
 block discarded – undo
1292 1292
 	 * @param array $info
1293 1293
 	 * @return array
1294 1294
 	 */
1295
-	public function _strip_objects( $info = array() ) {
1296
-		foreach ( (array)$info as $key => $value ) {
1297
-			if ( is_array( $value )) {
1298
-				$info[ $key ] = $this->_strip_objects( $value );
1299
-			} else if ( is_object( $value ) ) {
1300
-				$object_class = get_class( $value );
1301
-				$info[ $object_class ] = array();
1302
-				$info[ $object_class ][ 'ID' ] = method_exists( $value, 'ID' ) ? $value->ID() : 0;
1303
-				if ( method_exists( $value, 'status' ) ) {
1304
-					$info[ $object_class ][ 'status' ] = $value->status();
1305
-				} else if ( method_exists( $value, 'status_ID' ) ) {
1306
-					$info[ $object_class ][ 'status' ] = $value->status_ID();
1295
+	public function _strip_objects($info = array()) {
1296
+		foreach ((array) $info as $key => $value) {
1297
+			if (is_array($value)) {
1298
+				$info[$key] = $this->_strip_objects($value);
1299
+			} else if (is_object($value)) {
1300
+				$object_class = get_class($value);
1301
+				$info[$object_class] = array();
1302
+				$info[$object_class]['ID'] = method_exists($value, 'ID') ? $value->ID() : 0;
1303
+				if (method_exists($value, 'status')) {
1304
+					$info[$object_class]['status'] = $value->status();
1305
+				} else if (method_exists($value, 'status_ID')) {
1306
+					$info[$object_class]['status'] = $value->status_ID();
1307 1307
 				}
1308
-				unset( $info[ $key ] );
1308
+				unset($info[$key]);
1309 1309
 			}
1310 1310
 		}
1311
-		return (array)$info;
1311
+		return (array) $info;
1312 1312
 	}
1313 1313
 
1314 1314
 
Please login to merge, or discard this patch.