Completed
Branch BUG-9680-compress-dompdf-files... (43e183)
by
unknown
577:38 queued 559:24
created
core/helpers/EEH_Activation.helper.php 2 patches
Spacing   +346 added lines, -346 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * EEH_Activation Helper
4 4
  *
@@ -48,9 +48,9 @@  discard block
 block discarded – undo
48 48
 	 * @param $table_name
49 49
 	 * @return string
50 50
 	 */
51
-	public static function ensure_table_name_has_prefix( $table_name ) {
51
+	public static function ensure_table_name_has_prefix($table_name) {
52 52
 		global $wpdb;
53
-		return strpos( $table_name, $wpdb->base_prefix ) === 0 ? $table_name : $wpdb->prefix . $table_name;
53
+		return strpos($table_name, $wpdb->base_prefix) === 0 ? $table_name : $wpdb->prefix.$table_name;
54 54
 	}
55 55
 
56 56
 
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
 	 * @return boolean success, whether the database and folders are setup properly
79 79
 	 * @throws \EE_Error
80 80
 	 */
81
-	public static function initialize_db_and_folders(){
81
+	public static function initialize_db_and_folders() {
82 82
 		$good_filesystem = EEH_Activation::create_upload_directories();
83 83
 		$good_db = EEH_Activation::create_database_tables();
84 84
 		return $good_filesystem && $good_db;
@@ -94,9 +94,9 @@  discard block
 block discarded – undo
94 94
 	 *
95 95
 	 * @throws \EE_Error
96 96
 	 */
97
-	public static function initialize_db_content(){
97
+	public static function initialize_db_content() {
98 98
 		//let's avoid doing all this logic repeatedly, especially when addons are requesting it
99
-		if( EEH_Activation::$_initialized_db_content_already_in_this_request ) {
99
+		if (EEH_Activation::$_initialized_db_content_already_in_this_request) {
100 100
 			return;
101 101
 		}
102 102
 		EEH_Activation::$_initialized_db_content_already_in_this_request = true;
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 		EEH_Activation::remove_cron_tasks();
114 114
 		EEH_Activation::create_cron_tasks();
115 115
 		// remove all TXN locks since that is being done via extra meta now
116
-		delete_option( 'ee_locked_transactions' );
116
+		delete_option('ee_locked_transactions');
117 117
 		//also, check for CAF default db content
118
-		do_action( 'AHEE__EEH_Activation__initialize_db_content' );
118
+		do_action('AHEE__EEH_Activation__initialize_db_content');
119 119
 		//also: EEM_Gateways::load_all_gateways() outputs a lot of success messages
120 120
 		//which users really won't care about on initial activation
121 121
 		EE_Error::overwrite_success();
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 	 * @return array
136 136
 	 * @throws \EE_Error
137 137
 	 */
138
-	public static function get_cron_tasks( $which_to_include ) {
138
+	public static function get_cron_tasks($which_to_include) {
139 139
 		$cron_tasks = apply_filters(
140 140
 			'FHEE__EEH_Activation__get_cron_tasks',
141 141
 			array(
@@ -144,16 +144,16 @@  discard block
 block discarded – undo
144 144
 				'AHEE__EE_Cron_Tasks__update_transaction_with_payment' => EEH_Activation::cron_task_no_longer_in_use, //there may have been a bug which prevented from these cron tasks from getting unscheduled, so we might want to remove these for a few updates
145 145
 			)
146 146
 		);
147
-		if ( $which_to_include === 'old' ) {
147
+		if ($which_to_include === 'old') {
148 148
 			$cron_tasks = array_filter(
149 149
 				$cron_tasks,
150
-				function ( $value ) {
150
+				function($value) {
151 151
 					return $value === EEH_Activation::cron_task_no_longer_in_use;
152 152
 				}
153 153
 			);
154
-		} elseif ( $which_to_include === 'current' ) {
155
-			$cron_tasks = array_filter( $cron_tasks );
156
-		} elseif ( WP_DEBUG && $which_to_include !== 'all' ) {
154
+		} elseif ($which_to_include === 'current') {
155
+			$cron_tasks = array_filter($cron_tasks);
156
+		} elseif (WP_DEBUG && $which_to_include !== 'all') {
157 157
 			throw new EE_Error(
158 158
 				sprintf(
159 159
 					__(
@@ -176,9 +176,9 @@  discard block
 block discarded – undo
176 176
 	 */
177 177
 	public static function create_cron_tasks() {
178 178
 
179
-		foreach( EEH_Activation::get_cron_tasks( 'current' ) as $hook_name => $frequency ) {
180
-			if( ! wp_next_scheduled( $hook_name ) ) {
181
-				wp_schedule_event( time(), $frequency, $hook_name );
179
+		foreach (EEH_Activation::get_cron_tasks('current') as $hook_name => $frequency) {
180
+			if ( ! wp_next_scheduled($hook_name)) {
181
+				wp_schedule_event(time(), $frequency, $hook_name);
182 182
 			}
183 183
 		}
184 184
 
@@ -192,10 +192,10 @@  discard block
 block discarded – undo
192 192
 	 * @param boolean $remove_all whether to only remove the old ones, or remove absolutely ALL the EE ones
193 193
 	 * @throws \EE_Error
194 194
 	 */
195
-	public static function remove_cron_tasks( $remove_all = true ) {
195
+	public static function remove_cron_tasks($remove_all = true) {
196 196
 		$cron_tasks_to_remove = $remove_all ? 'all' : 'old';
197 197
 		$crons = _get_cron_array();
198
-		$crons = is_array( $crons ) ? $crons : array();
198
+		$crons = is_array($crons) ? $crons : array();
199 199
 		/* reminder of what $crons look like:
200 200
 		 * Top-level keys are timestamps, and their values are arrays.
201 201
 		 * The 2nd level arrays have keys with each of the cron task hook names to run at that time
@@ -213,23 +213,23 @@  discard block
 block discarded – undo
213 213
 		 *					...
214 214
 		 *      ...
215 215
 		 */
216
-		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks( $cron_tasks_to_remove );
217
-		foreach ( $crons as $timestamp => $hooks_to_fire_at_time ) {
218
-			if ( is_array( $hooks_to_fire_at_time ) ) {
219
-				foreach ( $hooks_to_fire_at_time as $hook_name => $hook_actions ) {
220
-					if ( isset( $ee_cron_tasks_to_remove[ $hook_name ] )
221
-					     && is_array( $ee_cron_tasks_to_remove[ $hook_name ] )
216
+		$ee_cron_tasks_to_remove = EEH_Activation::get_cron_tasks($cron_tasks_to_remove);
217
+		foreach ($crons as $timestamp => $hooks_to_fire_at_time) {
218
+			if (is_array($hooks_to_fire_at_time)) {
219
+				foreach ($hooks_to_fire_at_time as $hook_name => $hook_actions) {
220
+					if (isset($ee_cron_tasks_to_remove[$hook_name])
221
+					     && is_array($ee_cron_tasks_to_remove[$hook_name])
222 222
 					) {
223
-						unset( $crons[ $timestamp ][ $hook_name ] );
223
+						unset($crons[$timestamp][$hook_name]);
224 224
 					}
225 225
 				}
226 226
 				//also take care of any empty cron timestamps.
227
-				if ( empty( $hooks_to_fire_at_time ) ) {
228
-					unset( $crons[ $timestamp ] );
227
+				if (empty($hooks_to_fire_at_time)) {
228
+					unset($crons[$timestamp]);
229 229
 				}
230 230
 			}
231 231
 		}
232
-		_set_cron_array( $crons );
232
+		_set_cron_array($crons);
233 233
 	}
234 234
 
235 235
 
@@ -244,7 +244,7 @@  discard block
 block discarded – undo
244 244
 	 */
245 245
 	public static function CPT_initialization() {
246 246
 		// register Custom Post Types
247
-		EE_Registry::instance()->load_core( 'Register_CPTs' );
247
+		EE_Registry::instance()->load_core('Register_CPTs');
248 248
 		flush_rewrite_rules();
249 249
 	}
250 250
 
@@ -262,8 +262,8 @@  discard block
 block discarded – undo
262 262
 	 * 	@return void
263 263
 	 */
264 264
 	public static function reset_and_update_config() {
265
-		do_action( 'AHEE__EE_Config___load_core_config__start', array( 'EEH_Activation', 'load_calendar_config' ) );
266
-		add_filter( 'FHEE__EE_Config___load_core_config__config_settings', array( 'EEH_Activation', 'migrate_old_config_data' ), 10, 3 );
265
+		do_action('AHEE__EE_Config___load_core_config__start', array('EEH_Activation', 'load_calendar_config'));
266
+		add_filter('FHEE__EE_Config___load_core_config__config_settings', array('EEH_Activation', 'migrate_old_config_data'), 10, 3);
267 267
 		//EE_Config::reset();
268 268
 	}
269 269
 
@@ -276,28 +276,28 @@  discard block
 block discarded – undo
276 276
 	 */
277 277
 	public static function load_calendar_config() {
278 278
 		// grab array of all plugin folders and loop thru it
279
-		$plugins = glob( WP_PLUGIN_DIR . DS . '*', GLOB_ONLYDIR );
280
-		if ( empty( $plugins ) ) {
279
+		$plugins = glob(WP_PLUGIN_DIR.DS.'*', GLOB_ONLYDIR);
280
+		if (empty($plugins)) {
281 281
 			return;
282 282
 		}
283
-		foreach ( $plugins as $plugin_path ) {
283
+		foreach ($plugins as $plugin_path) {
284 284
 			// grab plugin folder name from path
285
-			$plugin = basename( $plugin_path );
285
+			$plugin = basename($plugin_path);
286 286
 			// drill down to Espresso plugins
287 287
 			// then to calendar related plugins
288 288
 			if (
289
-				strpos( $plugin, 'espresso' ) !== FALSE
290
-				|| strpos( $plugin, 'Espresso' ) !== FALSE
291
-				|| strpos( $plugin, 'ee4' ) !== FALSE
292
-				|| strpos( $plugin, 'EE4' ) !== FALSE
293
-				|| strpos( $plugin, 'calendar' ) !== false
289
+				strpos($plugin, 'espresso') !== FALSE
290
+				|| strpos($plugin, 'Espresso') !== FALSE
291
+				|| strpos($plugin, 'ee4') !== FALSE
292
+				|| strpos($plugin, 'EE4') !== FALSE
293
+				|| strpos($plugin, 'calendar') !== false
294 294
 			) {
295 295
 				// this is what we are looking for
296
-				$calendar_config = $plugin_path . DS . 'EE_Calendar_Config.php';
296
+				$calendar_config = $plugin_path.DS.'EE_Calendar_Config.php';
297 297
 				// does it exist in this folder ?
298
-				if ( is_readable( $calendar_config )) {
298
+				if (is_readable($calendar_config)) {
299 299
 					// YEAH! let's load it
300
-					require_once( $calendar_config );
300
+					require_once($calendar_config);
301 301
 				}
302 302
 			}
303 303
 		}
@@ -313,21 +313,21 @@  discard block
 block discarded – undo
313 313
 	 * @param \EE_Config     $EE_Config
314 314
 	 * @return \stdClass
315 315
 	 */
316
-	public static function migrate_old_config_data( $settings = array(), $config = '', EE_Config $EE_Config ) {
317
-		$convert_from_array = array( 'addons' );
316
+	public static function migrate_old_config_data($settings = array(), $config = '', EE_Config $EE_Config) {
317
+		$convert_from_array = array('addons');
318 318
 		// in case old settings were saved as an array
319
-		if ( is_array( $settings ) && in_array( $config, $convert_from_array )) {
319
+		if (is_array($settings) && in_array($config, $convert_from_array)) {
320 320
 			// convert existing settings to an object
321 321
 			$config_array = $settings;
322 322
 			$settings = new stdClass();
323
-			foreach ( $config_array as $key => $value ){
324
-				if ( $key === 'calendar' && class_exists( 'EE_Calendar_Config' )) {
325
-					$EE_Config->set_config( 'addons', 'EE_Calendar', 'EE_Calendar_Config', $value );
323
+			foreach ($config_array as $key => $value) {
324
+				if ($key === 'calendar' && class_exists('EE_Calendar_Config')) {
325
+					$EE_Config->set_config('addons', 'EE_Calendar', 'EE_Calendar_Config', $value);
326 326
 				} else {
327 327
 					$settings->{$key} = $value;
328 328
 				}
329 329
 			}
330
-			add_filter( 'FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true' );
330
+			add_filter('FHEE__EE_Config___load_core_config__update_espresso_config', '__return_true');
331 331
 		}
332 332
 		return $settings;
333 333
 	}
@@ -343,8 +343,8 @@  discard block
 block discarded – undo
343 343
 	 */
344 344
 	public static function deactivate_event_espresso() {
345 345
 		// check permissions
346
-		if ( current_user_can( 'activate_plugins' )) {
347
-			deactivate_plugins( EE_PLUGIN_BASENAME, TRUE );
346
+		if (current_user_can('activate_plugins')) {
347
+			deactivate_plugins(EE_PLUGIN_BASENAME, TRUE);
348 348
 		}
349 349
 	}
350 350
 
@@ -366,25 +366,25 @@  discard block
 block discarded – undo
366 366
 		$critical_pages = array(
367 367
 			array(
368 368
 				'id' =>'reg_page_id',
369
-				'name' => __( 'Registration Checkout', 'event_espresso' ),
369
+				'name' => __('Registration Checkout', 'event_espresso'),
370 370
 				'post' => NULL,
371 371
 				'code' => 'ESPRESSO_CHECKOUT'
372 372
 			),
373 373
 			array(
374 374
 				'id' => 'txn_page_id',
375
-				'name' => __( 'Transactions', 'event_espresso' ),
375
+				'name' => __('Transactions', 'event_espresso'),
376 376
 				'post' => NULL,
377 377
 				'code' => 'ESPRESSO_TXN_PAGE'
378 378
 			),
379 379
 			array(
380 380
 				'id' => 'thank_you_page_id',
381
-				'name' => __( 'Thank You', 'event_espresso' ),
381
+				'name' => __('Thank You', 'event_espresso'),
382 382
 				'post' => NULL,
383 383
 				'code' => 'ESPRESSO_THANK_YOU'
384 384
 			),
385 385
 			array(
386 386
 				'id' => 'cancel_page_id',
387
-				'name' => __( 'Registration Cancelled', 'event_espresso' ),
387
+				'name' => __('Registration Cancelled', 'event_espresso'),
388 388
 				'post' => NULL,
389 389
 				'code' => 'ESPRESSO_CANCELLED'
390 390
 			),
@@ -392,62 +392,62 @@  discard block
 block discarded – undo
392 392
 
393 393
 		$EE_Core_Config = EE_Registry::instance()->CFG->core;
394 394
 
395
-		foreach ( $critical_pages as $critical_page ) {
395
+		foreach ($critical_pages as $critical_page) {
396 396
 			// is critical page ID set in config ?
397
-			if ( $EE_Core_Config->{$critical_page[ 'id' ]} !== FALSE ) {
397
+			if ($EE_Core_Config->{$critical_page['id']} !== FALSE) {
398 398
 				// attempt to find post by ID
399
-				$critical_page['post'] = get_post( $EE_Core_Config->{$critical_page[ 'id' ]} );
399
+				$critical_page['post'] = get_post($EE_Core_Config->{$critical_page['id']} );
400 400
 			}
401 401
 			// no dice?
402
-			if ( $critical_page['post'] === null ) {
402
+			if ($critical_page['post'] === null) {
403 403
 				// attempt to find post by title
404
-				$critical_page['post'] = self::get_page_by_ee_shortcode( $critical_page['code'] );
404
+				$critical_page['post'] = self::get_page_by_ee_shortcode($critical_page['code']);
405 405
 				// still nothing?
406
-				if ( $critical_page['post'] === null ) {
407
-					$critical_page = EEH_Activation::create_critical_page( $critical_page );
406
+				if ($critical_page['post'] === null) {
407
+					$critical_page = EEH_Activation::create_critical_page($critical_page);
408 408
 					// REALLY? Still nothing ??!?!?
409
-					if ( $critical_page['post'] === null ) {
410
-						$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
411
-						EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
409
+					if ($critical_page['post'] === null) {
410
+						$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
411
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
412 412
 						break;
413 413
 					}
414 414
 				}
415 415
 			}
416 416
 			// track post_shortcodes
417
-			if ( $critical_page['post'] ) {
418
-				EEH_Activation::_track_critical_page_post_shortcodes( $critical_page );
417
+			if ($critical_page['post']) {
418
+				EEH_Activation::_track_critical_page_post_shortcodes($critical_page);
419 419
 			}
420 420
 			// check that Post ID matches critical page ID in config
421 421
 			if (
422
-				isset( $critical_page['post']->ID )
423
-				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page[ 'id' ]}
422
+				isset($critical_page['post']->ID)
423
+				&& $critical_page['post']->ID !== $EE_Core_Config->{$critical_page['id']}
424 424
 			) {
425 425
 				//update Config with post ID
426
-				$EE_Core_Config->{$critical_page[ 'id' ]} = $critical_page['post']->ID;
427
-				if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE ) ) {
428
-					$msg = __( 'The Event Espresso critical page configuration settings could not be updated.', 'event_espresso' );
429
-					EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
426
+				$EE_Core_Config->{$critical_page['id']} = $critical_page['post']->ID;
427
+				if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
428
+					$msg = __('The Event Espresso critical page configuration settings could not be updated.', 'event_espresso');
429
+					EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
430 430
 				}
431 431
 			}
432 432
 
433 433
 			$critical_page_problem =
434
-				! isset( $critical_page['post']->post_status )
434
+				! isset($critical_page['post']->post_status)
435 435
 				|| $critical_page['post']->post_status !== 'publish'
436
-				|| strpos( $critical_page['post']->post_content, $critical_page['code'] ) === FALSE
436
+				|| strpos($critical_page['post']->post_content, $critical_page['code']) === FALSE
437 437
 					? TRUE
438 438
 					: $critical_page_problem;
439 439
 
440 440
 		}
441 441
 
442
-		if ( $critical_page_problem ) {
442
+		if ($critical_page_problem) {
443 443
 			$msg = sprintf(
444
-				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso' ),
445
-				'<a href="' . admin_url('admin.php?page=espresso_general_settings&action=critical_pages') . '">' . __('Event Espresso Critical Pages Settings', 'event_espresso') . '</a>'
444
+				__('A potential issue has been detected with one or more of your Event Espresso pages. Go to %s to view your Event Espresso pages.', 'event_espresso'),
445
+				'<a href="'.admin_url('admin.php?page=espresso_general_settings&action=critical_pages').'">'.__('Event Espresso Critical Pages Settings', 'event_espresso').'</a>'
446 446
 			);
447
-			EE_Error::add_persistent_admin_notice( 'critical_page_problem', $msg );
447
+			EE_Error::add_persistent_admin_notice('critical_page_problem', $msg);
448 448
 		}
449
-		if ( EE_Error::has_notices() ) {
450
-			EE_Error::get_notices( FALSE, TRUE, TRUE );
449
+		if (EE_Error::has_notices()) {
450
+			EE_Error::get_notices(FALSE, TRUE, TRUE);
451 451
 		}
452 452
 	}
453 453
 
@@ -459,13 +459,13 @@  discard block
 block discarded – undo
459 459
 	 * parameter to the shortcode
460 460
 	 * @return WP_Post or NULl
461 461
 	 */
462
-	public static function get_page_by_ee_shortcode($ee_shortcode){
462
+	public static function get_page_by_ee_shortcode($ee_shortcode) {
463 463
 		global $wpdb;
464 464
 		$shortcode_and_opening_bracket = '['.$ee_shortcode;
465 465
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
466
-		if($post_id){
466
+		if ($post_id) {
467 467
 			return get_post($post_id);
468
-		}else{
468
+		} else {
469 469
 			return NULL;
470 470
 		}
471 471
 
@@ -482,32 +482,32 @@  discard block
 block discarded – undo
482 482
 	 * @param array $critical_page
483 483
 	 * @return array
484 484
 	 */
485
-	public static function create_critical_page( $critical_page ) {
485
+	public static function create_critical_page($critical_page) {
486 486
 
487 487
 		$post_args = array(
488 488
 			'post_title' => $critical_page['name'],
489 489
 			'post_status' => 'publish',
490 490
 			'post_type' => 'page',
491 491
 			'comment_status' => 'closed',
492
-			'post_content' => '[' . $critical_page['code'] . ']'
492
+			'post_content' => '['.$critical_page['code'].']'
493 493
 		);
494 494
 
495
-		$post_id = wp_insert_post( $post_args );
496
-		if ( ! $post_id ) {
495
+		$post_id = wp_insert_post($post_args);
496
+		if ( ! $post_id) {
497 497
 			$msg = sprintf(
498
-				__( 'The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso' ),
498
+				__('The Event Espresso  critical page entitled "%s" could not be created.', 'event_espresso'),
499 499
 				$critical_page['name']
500 500
 			);
501
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
501
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
502 502
 			return $critical_page;
503 503
 		}
504 504
 		// get newly created post's details
505
-		if ( ! $critical_page['post'] = get_post( $post_id )) {
505
+		if ( ! $critical_page['post'] = get_post($post_id)) {
506 506
 			$msg = sprintf(
507
-				__( 'The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso' ),
507
+				__('The Event Espresso critical page entitled "%s" could not be retrieved.', 'event_espresso'),
508 508
 				$critical_page['name']
509 509
 			);
510
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
510
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
511 511
 		}
512 512
 
513 513
 		return $critical_page;
@@ -526,35 +526,35 @@  discard block
 block discarded – undo
526 526
 	 * @param array $critical_page
527 527
 	 * @return void
528 528
 	 */
529
-	private static function _track_critical_page_post_shortcodes( $critical_page = array() ) {
529
+	private static function _track_critical_page_post_shortcodes($critical_page = array()) {
530 530
 		// check the goods
531
-		if ( ! $critical_page['post'] instanceof WP_Post ) {
531
+		if ( ! $critical_page['post'] instanceof WP_Post) {
532 532
 			$msg = sprintf(
533
-				__( 'The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso' ),
533
+				__('The Event Espresso critical page shortcode for the page %s can not be tracked because it is not a WP_Post object.', 'event_espresso'),
534 534
 				$critical_page['name']
535 535
 			);
536
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
536
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
537 537
 			return;
538 538
 		}
539 539
 		$EE_Core_Config = EE_Registry::instance()->CFG->core;
540 540
 		// map shortcode to post
541
-		$EE_Core_Config->post_shortcodes[ $critical_page['post']->post_name ][ $critical_page['code'] ] = $critical_page['post']->ID;
541
+		$EE_Core_Config->post_shortcodes[$critical_page['post']->post_name][$critical_page['code']] = $critical_page['post']->ID;
542 542
 		// and make sure it's NOT added to the WP "Posts Page"
543 543
 		// name of the WP Posts Page
544 544
 		$posts_page = EE_Config::get_page_for_posts();
545
-		if ( isset( $EE_Core_Config->post_shortcodes[ $posts_page ] )) {
546
-			unset( $EE_Core_Config->post_shortcodes[ $posts_page ][ $critical_page['code'] ] );
545
+		if (isset($EE_Core_Config->post_shortcodes[$posts_page])) {
546
+			unset($EE_Core_Config->post_shortcodes[$posts_page][$critical_page['code']]);
547 547
 		}
548
-		if ( $posts_page !== 'posts' && isset( $EE_Core_Config->post_shortcodes['posts'] )) {
549
-			unset( $EE_Core_Config->post_shortcodes['posts'][ $critical_page['code'] ] );
548
+		if ($posts_page !== 'posts' && isset($EE_Core_Config->post_shortcodes['posts'])) {
549
+			unset($EE_Core_Config->post_shortcodes['posts'][$critical_page['code']]);
550 550
 		}
551 551
 		// update post_shortcode CFG
552
-		if ( ! EE_Config::instance()->update_espresso_config( FALSE, FALSE )) {
552
+		if ( ! EE_Config::instance()->update_espresso_config(FALSE, FALSE)) {
553 553
 			$msg = sprintf(
554
-				__( 'The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso' ),
554
+				__('The Event Espresso critical page shortcode for the %s page could not be configured properly.', 'event_espresso'),
555 555
 				$critical_page['name']
556 556
 			);
557
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
557
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
558 558
 		}
559 559
 	}
560 560
 
@@ -572,24 +572,24 @@  discard block
 block discarded – undo
572 572
 	public static function get_default_creator_id() {
573 573
 		global $wpdb;
574 574
 
575
-		if ( ! empty( self::$_default_creator_id ) ) {
575
+		if ( ! empty(self::$_default_creator_id)) {
576 576
 			return self::$_default_creator_id;
577 577
 		}/**/
578 578
 
579
-		$role_to_check = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator' );
579
+		$role_to_check = apply_filters('FHEE__EEH_Activation__get_default_creator_id__role_to_check', 'administrator');
580 580
 
581 581
 		//let's allow pre_filtering for early exits by alternative methods for getting id.  We check for truthy result and if so then exit early.
582
-		$pre_filtered_id = apply_filters( 'FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check );
583
-		if ( $pre_filtered_id !== false ) {
582
+		$pre_filtered_id = apply_filters('FHEE__EEH_Activation__get_default_creator_id__pre_filtered_id', false, $role_to_check);
583
+		if ($pre_filtered_id !== false) {
584 584
 			return (int) $pre_filtered_id;
585 585
 		}
586 586
 
587
-		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix( 'capabilities' );
588
-		$query = $wpdb->prepare( "SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%' . $role_to_check . '%' );
589
-		$user_id = $wpdb->get_var( $query );
590
-		 $user_id = apply_filters( 'FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id );
591
-		 if ( $user_id && (int)$user_id ) {
592
-		 	self::$_default_creator_id = (int)$user_id;
587
+		$capabilities_key = EEH_Activation::ensure_table_name_has_prefix('capabilities');
588
+		$query = $wpdb->prepare("SELECT user_id FROM $wpdb->usermeta WHERE meta_key = '$capabilities_key' AND meta_value LIKE %s ORDER BY user_id ASC LIMIT 0,1", '%'.$role_to_check.'%');
589
+		$user_id = $wpdb->get_var($query);
590
+		 $user_id = apply_filters('FHEE__EEH_Activation_Helper__get_default_creator_id__user_id', $user_id);
591
+		 if ($user_id && (int) $user_id) {
592
+		 	self::$_default_creator_id = (int) $user_id;
593 593
 		 	return self::$_default_creator_id;
594 594
 		 } else {
595 595
 		 	return NULL;
@@ -616,29 +616,29 @@  discard block
 block discarded – undo
616 616
 	 * 	@return void
617 617
 	 * @throws EE_Error if there are database errors
618 618
 	 */
619
-	public static function create_table( $table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false ) {
620
-		if( apply_filters( 'FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql ) ){
619
+	public static function create_table($table_name, $sql, $engine = 'ENGINE=MyISAM ', $drop_pre_existing_table = false) {
620
+		if (apply_filters('FHEE__EEH_Activation__create_table__short_circuit', FALSE, $table_name, $sql)) {
621 621
 			return;
622 622
 		}
623
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
624
-		if ( ! function_exists( 'dbDelta' )) {
625
-			require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
623
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
624
+		if ( ! function_exists('dbDelta')) {
625
+			require_once(ABSPATH.'wp-admin/includes/upgrade.php');
626 626
 		}
627 627
 		/** @var WPDB $wpdb */
628 628
 		global $wpdb;
629
-		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
629
+		$wp_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
630 630
 		// do we need to first delete an existing version of this table ?
631
-		if ( $drop_pre_existing_table && EEH_Activation::table_exists( $wp_table_name ) ){
631
+		if ($drop_pre_existing_table && EEH_Activation::table_exists($wp_table_name)) {
632 632
 			// ok, delete the table... but ONLY if it's empty
633
-			$deleted_safely = EEH_Activation::delete_db_table_if_empty( $wp_table_name );
633
+			$deleted_safely = EEH_Activation::delete_db_table_if_empty($wp_table_name);
634 634
 			// table is NOT empty, are you SURE you want to delete this table ???
635
-			if ( ! $deleted_safely && defined( 'EE_DROP_BAD_TABLES' ) && EE_DROP_BAD_TABLES ){
636
-				EEH_Activation::delete_unused_db_table( $wp_table_name );
637
-			} else if ( ! $deleted_safely ) {
635
+			if ( ! $deleted_safely && defined('EE_DROP_BAD_TABLES') && EE_DROP_BAD_TABLES) {
636
+				EEH_Activation::delete_unused_db_table($wp_table_name);
637
+			} else if ( ! $deleted_safely) {
638 638
 				// so we should be more cautious rather than just dropping tables so easily
639 639
 				EE_Error::add_persistent_admin_notice(
640
-						'bad_table_' . $wp_table_name . '_detected',
641
-						sprintf( __( 'Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso' ),
640
+						'bad_table_'.$wp_table_name.'_detected',
641
+						sprintf(__('Database table %1$s exists when it shouldn\'t, and may contain erroneous data. If you have previously restored your database from a backup that didn\'t remove the old tables, then we recommend adding %2$s to your %3$s file then restore to that backup again. This will clear out the invalid data from %1$s. Afterwards you should undo that change from your %3$s file. %4$sIf you cannot edit %3$s, you should remove the data from %1$s manually then restore to the backup again.', 'event_espresso'),
642 642
 								$wp_table_name,
643 643
 								"<pre>define( 'EE_DROP_BAD_TABLES', TRUE );</pre>",
644 644
 								'<b>wp-config.php</b>',
@@ -647,25 +647,25 @@  discard block
 block discarded – undo
647 647
 			}
648 648
 		}
649 649
 		// does $sql contain valid column information? ( LPT: https://regex101.com/ is great for working out regex patterns )
650
-		if ( preg_match( '((((.*?))(,\s))+)', $sql, $valid_column_data ) ) {
650
+		if (preg_match('((((.*?))(,\s))+)', $sql, $valid_column_data)) {
651 651
 			$SQL = "CREATE TABLE $wp_table_name ( $sql ) $engine DEFAULT CHARSET=utf8 COLLATE=utf8_general_ci;";
652 652
 			//get $wpdb to echo errors, but buffer them. This way at least WE know an error
653 653
 			//happened. And then we can choose to tell the end user
654
-			$old_show_errors_policy = $wpdb->show_errors( TRUE );
655
-			$old_error_suppression_policy = $wpdb->suppress_errors( FALSE );
654
+			$old_show_errors_policy = $wpdb->show_errors(TRUE);
655
+			$old_error_suppression_policy = $wpdb->suppress_errors(FALSE);
656 656
 			ob_start();
657
-			dbDelta( $SQL );
657
+			dbDelta($SQL);
658 658
 			$output = ob_get_contents();
659 659
 			ob_end_clean();
660
-			$wpdb->show_errors( $old_show_errors_policy );
661
-			$wpdb->suppress_errors( $old_error_suppression_policy );
662
-			if( ! empty( $output ) ){
663
-				throw new EE_Error( $output	);
660
+			$wpdb->show_errors($old_show_errors_policy);
661
+			$wpdb->suppress_errors($old_error_suppression_policy);
662
+			if ( ! empty($output)) {
663
+				throw new EE_Error($output);
664 664
 			}
665 665
 		} else {
666 666
 			throw new EE_Error(
667 667
 				sprintf(
668
-					__( 'The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso' ),
668
+					__('The following table creation SQL does not contain valid information about the table columns: %1$s %2$s', 'event_espresso'),
669 669
 					'<br />',
670 670
 					$sql
671 671
 				)
@@ -688,15 +688,15 @@  discard block
 block discarded – undo
688 688
 	 *                            'VARCHAR(10)'
689 689
 	 * @return bool|int
690 690
 	 */
691
-	public static function add_column_if_it_doesnt_exist($table_name,$column_name,$column_info='INT UNSIGNED NOT NULL'){
692
-		if( apply_filters( 'FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE ) ){
691
+	public static function add_column_if_it_doesnt_exist($table_name, $column_name, $column_info = 'INT UNSIGNED NOT NULL') {
692
+		if (apply_filters('FHEE__EEH_Activation__add_column_if_it_doesnt_exist__short_circuit', FALSE)) {
693 693
 			return FALSE;
694 694
 		}
695 695
 		global $wpdb;
696
-		$full_table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
696
+		$full_table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
697 697
 		$fields = self::get_fields_on_table($table_name);
698
-		if (!in_array($column_name, $fields)){
699
-			$alter_query="ALTER TABLE $full_table_name ADD $column_name $column_info";
698
+		if ( ! in_array($column_name, $fields)) {
699
+			$alter_query = "ALTER TABLE $full_table_name ADD $column_name $column_info";
700 700
 			//echo "alter query:$alter_query";
701 701
 			return $wpdb->query($alter_query);
702 702
 		}
@@ -715,14 +715,14 @@  discard block
 block discarded – undo
715 715
 	 * 	@param string $table_name, without prefixed $wpdb->prefix
716 716
 	 * 	@return array of database column names
717 717
 	 */
718
-	public static function get_fields_on_table( $table_name = NULL ) {
718
+	public static function get_fields_on_table($table_name = NULL) {
719 719
 		global $wpdb;
720
-		$table_name= EEH_Activation::ensure_table_name_has_prefix( $table_name );
721
-		if ( ! empty( $table_name )) {
720
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
721
+		if ( ! empty($table_name)) {
722 722
 			$columns = $wpdb->get_results("SHOW COLUMNS FROM $table_name ");
723 723
 			if ($columns !== FALSE) {
724 724
 				$field_array = array();
725
-				foreach($columns as $column ){
725
+				foreach ($columns as $column) {
726 726
 					$field_array[] = $column->Field;
727 727
 				}
728 728
 				return $field_array;
@@ -741,12 +741,12 @@  discard block
 block discarded – undo
741 741
 	 * @param string $table_name
742 742
 	 * @return bool
743 743
 	 */
744
-	public static function db_table_is_empty( $table_name ) {
744
+	public static function db_table_is_empty($table_name) {
745 745
 		global $wpdb;
746
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
747
-		if ( EEH_Activation::table_exists( $table_name ) ) {
748
-			$count = $wpdb->get_var( "SELECT COUNT(*) FROM $table_name" );
749
-			return absint( $count ) === 0 ? true : false;
746
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
747
+		if (EEH_Activation::table_exists($table_name)) {
748
+			$count = $wpdb->get_var("SELECT COUNT(*) FROM $table_name");
749
+			return absint($count) === 0 ? true : false;
750 750
 		}
751 751
 		return false;
752 752
 	}
@@ -761,9 +761,9 @@  discard block
 block discarded – undo
761 761
 	 * @param string $table_name
762 762
 	 * @return bool | int
763 763
 	 */
764
-	public static function delete_db_table_if_empty( $table_name ) {
765
-		if ( EEH_Activation::db_table_is_empty( $table_name ) ) {
766
-			return EEH_Activation::delete_unused_db_table( $table_name );
764
+	public static function delete_db_table_if_empty($table_name) {
765
+		if (EEH_Activation::db_table_is_empty($table_name)) {
766
+			return EEH_Activation::delete_unused_db_table($table_name);
767 767
 		}
768 768
 		return false;
769 769
 	}
@@ -778,11 +778,11 @@  discard block
 block discarded – undo
778 778
 	 * @param string $table_name
779 779
 	 * @return bool | int
780 780
 	 */
781
-	public static function delete_unused_db_table( $table_name ) {
781
+	public static function delete_unused_db_table($table_name) {
782 782
 		global $wpdb;
783
-		if ( EEH_Activation::table_exists( $table_name ) ) {
784
-			$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
785
-			return $wpdb->query( "DROP TABLE IF EXISTS $table_name" );
783
+		if (EEH_Activation::table_exists($table_name)) {
784
+			$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
785
+			return $wpdb->query("DROP TABLE IF EXISTS $table_name");
786 786
 		}
787 787
 		return false;
788 788
 	}
@@ -798,18 +798,18 @@  discard block
 block discarded – undo
798 798
 	 * @param string $index_name
799 799
 	 * @return bool | int
800 800
 	 */
801
-	public static function drop_index( $table_name, $index_name ) {
802
-		if( apply_filters( 'FHEE__EEH_Activation__drop_index__short_circuit', FALSE ) ){
801
+	public static function drop_index($table_name, $index_name) {
802
+		if (apply_filters('FHEE__EEH_Activation__drop_index__short_circuit', FALSE)) {
803 803
 			return FALSE;
804 804
 		}
805 805
 		global $wpdb;
806
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
806
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
807 807
 		$index_exists_query = "SHOW INDEX FROM $table_name WHERE Key_name = '$index_name'";
808 808
 		if (
809
-			EEH_Activation::table_exists(  $table_name )
810
-			&& $wpdb->get_var( $index_exists_query ) === $table_name //using get_var with the $index_exists_query returns the table's name
809
+			EEH_Activation::table_exists($table_name)
810
+			&& $wpdb->get_var($index_exists_query) === $table_name //using get_var with the $index_exists_query returns the table's name
811 811
 		) {
812
-			return $wpdb->query( "ALTER TABLE $table_name DROP INDEX $index_name" );
812
+			return $wpdb->query("ALTER TABLE $table_name DROP INDEX $index_name");
813 813
 		}
814 814
 		return TRUE;
815 815
 	}
@@ -825,27 +825,27 @@  discard block
 block discarded – undo
825 825
 	 * @return boolean success (whether database is setup properly or not)
826 826
 	 */
827 827
 	public static function create_database_tables() {
828
-		EE_Registry::instance()->load_core( 'Data_Migration_Manager' );
828
+		EE_Registry::instance()->load_core('Data_Migration_Manager');
829 829
 		//find the migration script that sets the database to be compatible with the code
830 830
 		$dms_name = EE_Data_Migration_Manager::instance()->get_most_up_to_date_dms();
831
-		if( $dms_name ){
832
-			$current_data_migration_script = EE_Registry::instance()->load_dms( $dms_name );
833
-			$current_data_migration_script->set_migrating( false );
831
+		if ($dms_name) {
832
+			$current_data_migration_script = EE_Registry::instance()->load_dms($dms_name);
833
+			$current_data_migration_script->set_migrating(false);
834 834
 			$current_data_migration_script->schema_changes_before_migration();
835 835
 			$current_data_migration_script->schema_changes_after_migration();
836
-			if( $current_data_migration_script->get_errors() ){
837
-				if( WP_DEBUG ){
838
-					foreach( $current_data_migration_script->get_errors() as $error ){
839
-						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
836
+			if ($current_data_migration_script->get_errors()) {
837
+				if (WP_DEBUG) {
838
+					foreach ($current_data_migration_script->get_errors() as $error) {
839
+						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__);
840 840
 					}
841
-				}else{
842
-					EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) );
841
+				} else {
842
+					EE_Error::add_error(__('There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso'));
843 843
 				}
844 844
 				return false;
845 845
 			}
846 846
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
847
-		}else{
848
-			EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
847
+		} else {
848
+			EE_Error::add_error(__('Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
849 849
 			return false;
850 850
 		}
851 851
 		return true;
@@ -865,27 +865,27 @@  discard block
 block discarded – undo
865 865
 	public static function initialize_system_questions() {
866 866
 		// QUESTION GROUPS
867 867
 		global $wpdb;
868
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group' );
868
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question_group');
869 869
 		$SQL = "SELECT QSG_system FROM $table_name WHERE QSG_system != 0";
870 870
 		// what we have
871
-		$question_groups = $wpdb->get_col( $SQL );
871
+		$question_groups = $wpdb->get_col($SQL);
872 872
 		// check the response
873
-		$question_groups = is_array( $question_groups ) ? $question_groups : array();
873
+		$question_groups = is_array($question_groups) ? $question_groups : array();
874 874
 		// what we should have
875
-		$QSG_systems = array( 1, 2 );
875
+		$QSG_systems = array(1, 2);
876 876
 		// loop thru what we should have and compare to what we have
877
-		foreach ( $QSG_systems as $QSG_system ) {
877
+		foreach ($QSG_systems as $QSG_system) {
878 878
 			// reset values array
879 879
 			$QSG_values = array();
880 880
 			// if we don't have what we should have (but use $QST_system as as string because that's what we got from the db)
881
-			if ( ! in_array( "$QSG_system", $question_groups )) {
881
+			if ( ! in_array("$QSG_system", $question_groups)) {
882 882
 				// add it
883
-				switch ( $QSG_system ) {
883
+				switch ($QSG_system) {
884 884
 
885 885
 					case 1:
886 886
 							$QSG_values = array(
887
-									'QSG_name' => __( 'Personal Information', 'event_espresso' ),
888
-									'QSG_identifier' => 'personal-information-' . time(),
887
+									'QSG_name' => __('Personal Information', 'event_espresso'),
888
+									'QSG_identifier' => 'personal-information-'.time(),
889 889
 									'QSG_desc' => '',
890 890
 									'QSG_order' => 1,
891 891
 									'QSG_show_group_name' => 1,
@@ -897,8 +897,8 @@  discard block
 block discarded – undo
897 897
 
898 898
 					case 2:
899 899
 							$QSG_values = array(
900
-									'QSG_name' => __( 'Address Information','event_espresso' ),
901
-									'QSG_identifier' => 'address-information-' . time(),
900
+									'QSG_name' => __('Address Information', 'event_espresso'),
901
+									'QSG_identifier' => 'address-information-'.time(),
902 902
 									'QSG_desc' => '',
903 903
 									'QSG_order' => 2,
904 904
 									'QSG_show_group_name' => 1,
@@ -910,14 +910,14 @@  discard block
 block discarded – undo
910 910
 
911 911
 				}
912 912
 				// make sure we have some values before inserting them
913
-				if ( ! empty( $QSG_values )) {
913
+				if ( ! empty($QSG_values)) {
914 914
 					// insert system question
915 915
 					$wpdb->insert(
916 916
 						$table_name,
917 917
 						$QSG_values,
918
-						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d' )
918
+						array('%s', '%s', '%s', '%d', '%d', '%d', '%d', '%d')
919 919
 					);
920
-					$QSG_IDs[ $QSG_system ] = $wpdb->insert_id;
920
+					$QSG_IDs[$QSG_system] = $wpdb->insert_id;
921 921
 				}
922 922
 			}
923 923
 		}
@@ -926,10 +926,10 @@  discard block
 block discarded – undo
926 926
 
927 927
 		// QUESTIONS
928 928
 		global $wpdb;
929
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( 'esp_question' );
929
+		$table_name = EEH_Activation::ensure_table_name_has_prefix('esp_question');
930 930
 		$SQL = "SELECT QST_system FROM $table_name WHERE QST_system != ''";
931 931
 		// what we have
932
-		$questions = $wpdb->get_col( $SQL );
932
+		$questions = $wpdb->get_col($SQL);
933 933
 		// what we should have
934 934
 		$QST_systems = array(
935 935
 			'fname',
@@ -946,25 +946,25 @@  discard block
 block discarded – undo
946 946
 		$order_for_group_1 = 1;
947 947
 		$order_for_group_2 = 1;
948 948
 		// loop thru what we should have and compare to what we have
949
-		foreach ( $QST_systems as $QST_system ) {
949
+		foreach ($QST_systems as $QST_system) {
950 950
 			// reset values array
951 951
 			$QST_values = array();
952 952
 			// if we don't have what we should have
953
-			if ( ! in_array( $QST_system, $questions )) {
953
+			if ( ! in_array($QST_system, $questions)) {
954 954
 				// add it
955
-				switch ( $QST_system ) {
955
+				switch ($QST_system) {
956 956
 
957 957
 					case 'fname':
958 958
 							$QST_values = array(
959
-									'QST_display_text' => __( 'First Name', 'event_espresso' ),
960
-									'QST_admin_label' => __( 'First Name - System Question', 'event_espresso' ),
959
+									'QST_display_text' => __('First Name', 'event_espresso'),
960
+									'QST_admin_label' => __('First Name - System Question', 'event_espresso'),
961 961
 									'QST_system' => 'fname',
962 962
 									'QST_type' => 'TEXT',
963 963
 									'QST_required' => 1,
964
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
964
+									'QST_required_text' => __('This field is required', 'event_espresso'),
965 965
 									'QST_order' => 1,
966 966
 									'QST_admin_only' => 0,
967
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
967
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
968 968
 									'QST_wp_user' => self::get_default_creator_id(),
969 969
 									'QST_deleted' => 0
970 970
 								);
@@ -972,15 +972,15 @@  discard block
 block discarded – undo
972 972
 
973 973
 					case 'lname':
974 974
 							$QST_values = array(
975
-									'QST_display_text' => __( 'Last Name', 'event_espresso' ),
976
-									'QST_admin_label' => __( 'Last Name - System Question', 'event_espresso' ),
975
+									'QST_display_text' => __('Last Name', 'event_espresso'),
976
+									'QST_admin_label' => __('Last Name - System Question', 'event_espresso'),
977 977
 									'QST_system' => 'lname',
978 978
 									'QST_type' => 'TEXT',
979 979
 									'QST_required' => 1,
980
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
980
+									'QST_required_text' => __('This field is required', 'event_espresso'),
981 981
 									'QST_order' => 2,
982 982
 									'QST_admin_only' => 0,
983
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
983
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
984 984
 									'QST_wp_user' => self::get_default_creator_id(),
985 985
 									'QST_deleted' => 0
986 986
 								);
@@ -988,15 +988,15 @@  discard block
 block discarded – undo
988 988
 
989 989
 					case 'email':
990 990
 							$QST_values = array(
991
-									'QST_display_text' => __( 'Email Address', 'event_espresso' ),
992
-									'QST_admin_label' => __( 'Email Address - System Question', 'event_espresso' ),
991
+									'QST_display_text' => __('Email Address', 'event_espresso'),
992
+									'QST_admin_label' => __('Email Address - System Question', 'event_espresso'),
993 993
 									'QST_system' => 'email',
994 994
 									'QST_type' => 'EMAIL',
995 995
 									'QST_required' => 1,
996
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
996
+									'QST_required_text' => __('This field is required', 'event_espresso'),
997 997
 									'QST_order' => 3,
998 998
 									'QST_admin_only' => 0,
999
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
999
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1000 1000
 									'QST_wp_user' => self::get_default_creator_id(),
1001 1001
 									'QST_deleted' => 0
1002 1002
 								);
@@ -1004,15 +1004,15 @@  discard block
 block discarded – undo
1004 1004
 
1005 1005
 					case 'address':
1006 1006
 							$QST_values = array(
1007
-									'QST_display_text' => __( 'Address', 'event_espresso' ),
1008
-									'QST_admin_label' => __( 'Address - System Question', 'event_espresso' ),
1007
+									'QST_display_text' => __('Address', 'event_espresso'),
1008
+									'QST_admin_label' => __('Address - System Question', 'event_espresso'),
1009 1009
 									'QST_system' => 'address',
1010 1010
 									'QST_type' => 'TEXT',
1011 1011
 									'QST_required' => 0,
1012
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1012
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1013 1013
 									'QST_order' => 4,
1014 1014
 									'QST_admin_only' => 0,
1015
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1015
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1016 1016
 									'QST_wp_user' => self::get_default_creator_id(),
1017 1017
 									'QST_deleted' => 0
1018 1018
 								);
@@ -1020,15 +1020,15 @@  discard block
 block discarded – undo
1020 1020
 
1021 1021
 					case 'address2':
1022 1022
 							$QST_values = array(
1023
-									'QST_display_text' => __( 'Address2', 'event_espresso' ),
1024
-									'QST_admin_label' => __( 'Address2 - System Question', 'event_espresso' ),
1023
+									'QST_display_text' => __('Address2', 'event_espresso'),
1024
+									'QST_admin_label' => __('Address2 - System Question', 'event_espresso'),
1025 1025
 									'QST_system' => 'address2',
1026 1026
 									'QST_type' => 'TEXT',
1027 1027
 									'QST_required' => 0,
1028
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1028
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1029 1029
 									'QST_order' => 5,
1030 1030
 									'QST_admin_only' => 0,
1031
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1031
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1032 1032
 									'QST_wp_user' => self::get_default_creator_id(),
1033 1033
 									'QST_deleted' => 0
1034 1034
 								);
@@ -1036,15 +1036,15 @@  discard block
 block discarded – undo
1036 1036
 
1037 1037
 					case 'city':
1038 1038
 							$QST_values = array(
1039
-									'QST_display_text' => __( 'City', 'event_espresso' ),
1040
-									'QST_admin_label' => __( 'City - System Question', 'event_espresso' ),
1039
+									'QST_display_text' => __('City', 'event_espresso'),
1040
+									'QST_admin_label' => __('City - System Question', 'event_espresso'),
1041 1041
 									'QST_system' => 'city',
1042 1042
 									'QST_type' => 'TEXT',
1043 1043
 									'QST_required' => 0,
1044
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1044
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1045 1045
 									'QST_order' => 6,
1046 1046
 									'QST_admin_only' => 0,
1047
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1047
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1048 1048
 									'QST_wp_user' => self::get_default_creator_id(),
1049 1049
 									'QST_deleted' => 0
1050 1050
 								);
@@ -1052,12 +1052,12 @@  discard block
 block discarded – undo
1052 1052
 
1053 1053
 					case 'state':
1054 1054
 							$QST_values = array(
1055
-									'QST_display_text' => __( 'State/Province', 'event_espresso' ),
1056
-									'QST_admin_label' => __( 'State/Province - System Question', 'event_espresso' ),
1055
+									'QST_display_text' => __('State/Province', 'event_espresso'),
1056
+									'QST_admin_label' => __('State/Province - System Question', 'event_espresso'),
1057 1057
 									'QST_system' => 'state',
1058 1058
 									'QST_type' => 'STATE',
1059 1059
 									'QST_required' => 0,
1060
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1060
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1061 1061
 									'QST_order' => 7,
1062 1062
 									'QST_admin_only' => 0,
1063 1063
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1067,12 +1067,12 @@  discard block
 block discarded – undo
1067 1067
 
1068 1068
 					case 'country' :
1069 1069
 							$QST_values = array(
1070
-									'QST_display_text' => __( 'Country', 'event_espresso' ),
1071
-									'QST_admin_label' => __( 'Country - System Question', 'event_espresso' ),
1070
+									'QST_display_text' => __('Country', 'event_espresso'),
1071
+									'QST_admin_label' => __('Country - System Question', 'event_espresso'),
1072 1072
 									'QST_system' => 'country',
1073 1073
 									'QST_type' => 'COUNTRY',
1074 1074
 									'QST_required' => 0,
1075
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1075
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1076 1076
 									'QST_order' => 8,
1077 1077
 									'QST_admin_only' => 0,
1078 1078
 									'QST_wp_user' => self::get_default_creator_id(),
@@ -1082,15 +1082,15 @@  discard block
 block discarded – undo
1082 1082
 
1083 1083
 					case 'zip':
1084 1084
 							$QST_values = array(
1085
-									'QST_display_text' => __( 'Zip/Postal Code', 'event_espresso' ),
1086
-									'QST_admin_label' => __( 'Zip/Postal Code - System Question', 'event_espresso' ),
1085
+									'QST_display_text' => __('Zip/Postal Code', 'event_espresso'),
1086
+									'QST_admin_label' => __('Zip/Postal Code - System Question', 'event_espresso'),
1087 1087
 									'QST_system' => 'zip',
1088 1088
 									'QST_type' => 'TEXT',
1089 1089
 									'QST_required' => 0,
1090
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1090
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1091 1091
 									'QST_order' => 9,
1092 1092
 									'QST_admin_only' => 0,
1093
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1093
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1094 1094
 									'QST_wp_user' => self::get_default_creator_id(),
1095 1095
 									'QST_deleted' => 0
1096 1096
 								);
@@ -1098,49 +1098,49 @@  discard block
 block discarded – undo
1098 1098
 
1099 1099
 					case 'phone':
1100 1100
 							$QST_values = array(
1101
-									'QST_display_text' => __( 'Phone Number', 'event_espresso' ),
1102
-									'QST_admin_label' => __( 'Phone Number - System Question', 'event_espresso' ),
1101
+									'QST_display_text' => __('Phone Number', 'event_espresso'),
1102
+									'QST_admin_label' => __('Phone Number - System Question', 'event_espresso'),
1103 1103
 									'QST_system' => 'phone',
1104 1104
 									'QST_type' => 'TEXT',
1105 1105
 									'QST_required' => 0,
1106
-									'QST_required_text' => __( 'This field is required', 'event_espresso' ),
1106
+									'QST_required_text' => __('This field is required', 'event_espresso'),
1107 1107
 									'QST_order' => 10,
1108 1108
 									'QST_admin_only' => 0,
1109
-									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question( $QST_system ),
1109
+									'QST_max' => EEM_Question::instance()->absolute_max_for_system_question($QST_system),
1110 1110
 									'QST_wp_user' => self::get_default_creator_id(),
1111 1111
 									'QST_deleted' => 0
1112 1112
 								);
1113 1113
 						break;
1114 1114
 
1115 1115
 				}
1116
-				if ( ! empty( $QST_values )) {
1116
+				if ( ! empty($QST_values)) {
1117 1117
 					// insert system question
1118 1118
 					$wpdb->insert(
1119 1119
 						$table_name,
1120 1120
 						$QST_values,
1121
-						array( '%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d' )
1121
+						array('%s', '%s', '%s', '%s', '%d', '%s', '%d', '%d', '%d', '%d')
1122 1122
 					);
1123 1123
 					$QST_ID = $wpdb->insert_id;
1124 1124
 
1125 1125
 					// QUESTION GROUP QUESTIONS
1126
-					if(  in_array( $QST_system, array( 'fname', 'lname', 'email' ) ) ) {
1126
+					if (in_array($QST_system, array('fname', 'lname', 'email'))) {
1127 1127
 						$system_question_we_want = EEM_Question_Group::system_personal;
1128 1128
 					} else {
1129 1129
 						$system_question_we_want = EEM_Question_Group::system_address;
1130 1130
 					}
1131
-					if( isset( $QSG_IDs[ $system_question_we_want ] ) ) {
1132
-						$QSG_ID = $QSG_IDs[ $system_question_we_want ];
1131
+					if (isset($QSG_IDs[$system_question_we_want])) {
1132
+						$QSG_ID = $QSG_IDs[$system_question_we_want];
1133 1133
 					} else {
1134
-						$id_col = EEM_Question_Group::instance()->get_col( array( array( 'QSG_system' => $system_question_we_want ) ) );
1135
-						if( is_array( $id_col ) ) {
1136
-							$QSG_ID = reset( $id_col );
1134
+						$id_col = EEM_Question_Group::instance()->get_col(array(array('QSG_system' => $system_question_we_want)));
1135
+						if (is_array($id_col)) {
1136
+							$QSG_ID = reset($id_col);
1137 1137
 						} else {
1138 1138
 							//ok so we didn't find it in the db either?? that's weird because we should have inserted it at the start of this method
1139 1139
                                                         EE_Log::instance()->log(
1140 1140
                                                                 __FILE__,
1141 1141
                                                                 __FUNCTION__,
1142 1142
                                                                 sprintf(
1143
-                                                                        __( 'Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'),
1143
+                                                                        __('Could not associate question %1$s to a question group because no system question group existed', 'event_espresso'),
1144 1144
                                                                         $QST_ID ),
1145 1145
                                                                 'error' );
1146 1146
                                                         continue;
@@ -1149,12 +1149,12 @@  discard block
 block discarded – undo
1149 1149
 
1150 1150
 					// add system questions to groups
1151 1151
 					$wpdb->insert(
1152
-						EEH_Activation::ensure_table_name_has_prefix( 'esp_question_group_question' ),
1153
-						array( 'QSG_ID'    => $QSG_ID,
1152
+						EEH_Activation::ensure_table_name_has_prefix('esp_question_group_question'),
1153
+						array('QSG_ID'    => $QSG_ID,
1154 1154
 						       'QST_ID'    => $QST_ID,
1155
-						       'QGQ_order' => ( $QSG_ID === 1 ) ? $order_for_group_1++ : $order_for_group_2++
1155
+						       'QGQ_order' => ($QSG_ID === 1) ? $order_for_group_1++ : $order_for_group_2++
1156 1156
 						),
1157
-						array( '%d', '%d', '%d' )
1157
+						array('%d', '%d', '%d')
1158 1158
 					);
1159 1159
 				}
1160 1160
 			}
@@ -1170,11 +1170,11 @@  discard block
 block discarded – undo
1170 1170
 	 *
1171 1171
 	 * @throws \EE_Error
1172 1172
 	 */
1173
-	public static function insert_default_payment_methods(){
1174
-		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1175
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1176
-			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1177
-		}else{
1173
+	public static function insert_default_payment_methods() {
1174
+		if ( ! EEM_Payment_Method::instance()->count_active(EEM_Payment_Method::scope_cart)) {
1175
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
1176
+			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
1177
+		} else {
1178 1178
 			EEM_Payment_Method::instance()->verify_button_urls();
1179 1179
 		}
1180 1180
 	}
@@ -1190,7 +1190,7 @@  discard block
 block discarded – undo
1190 1190
 
1191 1191
 		global $wpdb;
1192 1192
 
1193
-		if ( EEH_Activation::table_exists( EEM_Status::instance()->table() ) ) {
1193
+		if (EEH_Activation::table_exists(EEM_Status::instance()->table())) {
1194 1194
 
1195 1195
 			$table_name = EEM_Status::instance()->table();
1196 1196
 
@@ -1265,33 +1265,33 @@  discard block
 block discarded – undo
1265 1265
 		$folders = array(
1266 1266
 				EVENT_ESPRESSO_TEMPLATE_DIR,
1267 1267
 				EVENT_ESPRESSO_GATEWAY_DIR,
1268
-				EVENT_ESPRESSO_UPLOAD_DIR . 'logs/',
1269
-				EVENT_ESPRESSO_UPLOAD_DIR . 'css/',
1270
-				EVENT_ESPRESSO_UPLOAD_DIR . 'tickets/'
1268
+				EVENT_ESPRESSO_UPLOAD_DIR.'logs/',
1269
+				EVENT_ESPRESSO_UPLOAD_DIR.'css/',
1270
+				EVENT_ESPRESSO_UPLOAD_DIR.'tickets/'
1271 1271
 		);
1272
-		foreach ( $folders as $folder ) {
1272
+		foreach ($folders as $folder) {
1273 1273
 			try {
1274
-				EEH_File::ensure_folder_exists_and_is_writable( $folder );
1275
-				@ chmod( $folder, 0755 );
1276
-			} catch( EE_Error $e ){
1274
+				EEH_File::ensure_folder_exists_and_is_writable($folder);
1275
+				@ chmod($folder, 0755);
1276
+			} catch (EE_Error $e) {
1277 1277
 				EE_Error::add_error(
1278 1278
 					sprintf(
1279
-						__(  'Could not create the folder at "%1$s" because: %2$s', 'event_espresso' ),
1279
+						__('Could not create the folder at "%1$s" because: %2$s', 'event_espresso'),
1280 1280
 						$folder,
1281
-						'<br />' . $e->getMessage()
1281
+						'<br />'.$e->getMessage()
1282 1282
 					),
1283 1283
 					__FILE__, __FUNCTION__, __LINE__
1284 1284
 				);
1285 1285
 				//indicate we'll need to fix this later
1286
-				update_option( EEH_Activation::upload_directories_incomplete_option_name, true );
1286
+				update_option(EEH_Activation::upload_directories_incomplete_option_name, true);
1287 1287
 				return FALSE;
1288 1288
 			}
1289 1289
 		}
1290 1290
 		//just add the .htaccess file to the logs directory to begin with. Even if logging
1291 1291
 		//is disabled, there might be activation errors recorded in there
1292
-		EEH_File::add_htaccess_deny_from_all( EVENT_ESPRESSO_UPLOAD_DIR . 'logs/' );
1292
+		EEH_File::add_htaccess_deny_from_all(EVENT_ESPRESSO_UPLOAD_DIR.'logs/');
1293 1293
 		//remember EE's folders are all good
1294
-		delete_option( EEH_Activation::upload_directories_incomplete_option_name );
1294
+		delete_option(EEH_Activation::upload_directories_incomplete_option_name);
1295 1295
 		return TRUE;
1296 1296
 	}
1297 1297
 
@@ -1304,7 +1304,7 @@  discard block
 block discarded – undo
1304 1304
 	 * @return boolean
1305 1305
 	 */
1306 1306
 	public static function upload_directories_incomplete() {
1307
-		return get_option( EEH_Activation::upload_directories_incomplete_option_name, false );
1307
+		return get_option(EEH_Activation::upload_directories_incomplete_option_name, false);
1308 1308
 	}
1309 1309
 
1310 1310
 
@@ -1321,7 +1321,7 @@  discard block
 block discarded – undo
1321 1321
 	 */
1322 1322
 	public static function generate_default_message_templates() {
1323 1323
 		/** @type EE_Message_Resource_Manager $message_resource_manager */
1324
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
1324
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1325 1325
 		/*
1326 1326
 		 * This first method is taking care of ensuring any default messengers
1327 1327
 		 * that should be made active and have templates generated are done.
@@ -1357,22 +1357,22 @@  discard block
 block discarded – undo
1357 1357
 		$active_messengers = $message_resource_manager->active_messengers();
1358 1358
 		$installed_message_types = $message_resource_manager->installed_message_types();
1359 1359
 		$templates_created = false;
1360
-		foreach ( $active_messengers as $active_messenger ) {
1360
+		foreach ($active_messengers as $active_messenger) {
1361 1361
 			$default_message_type_names_for_messenger = $active_messenger->get_default_message_types();
1362 1362
 			$default_message_type_names_to_activate = array();
1363 1363
 			// looping through each default message type reported by the messenger
1364 1364
 			// and setup the actual message types to activate.
1365
-			foreach ( $default_message_type_names_for_messenger as $default_message_type_name_for_messenger ) {
1365
+			foreach ($default_message_type_names_for_messenger as $default_message_type_name_for_messenger) {
1366 1366
 				// if already active or has already been activated before we skip
1367 1367
 				// (otherwise we might reactivate something user's intentionally deactivated.)
1368 1368
 				// we also skip if the message type is not installed.
1369 1369
 				if (
1370
-					$message_resource_manager->has_message_type_been_activated_for_messenger( $default_message_type_name_for_messenger, $active_messenger->name )
1370
+					$message_resource_manager->has_message_type_been_activated_for_messenger($default_message_type_name_for_messenger, $active_messenger->name)
1371 1371
 					|| $message_resource_manager->is_message_type_active_for_messenger(
1372 1372
 						$active_messenger->name,
1373 1373
 						$default_message_type_name_for_messenger
1374 1374
 					)
1375
-					|| ! isset( $installed_message_types[ $default_message_type_name_for_messenger ] )
1375
+					|| ! isset($installed_message_types[$default_message_type_name_for_messenger])
1376 1376
 				) {
1377 1377
 					continue;
1378 1378
 				}
@@ -1385,7 +1385,7 @@  discard block
 block discarded – undo
1385 1385
 				false
1386 1386
 			);
1387 1387
 			//activate the templates for these message types
1388
-			if ( ! empty( $default_message_type_names_to_activate ) ) {
1388
+			if ( ! empty($default_message_type_names_to_activate)) {
1389 1389
 				$templates_created = EEH_MSG_Template::generate_new_templates(
1390 1390
 					$active_messenger->name,
1391 1391
 					$default_message_type_names_for_messenger,
@@ -1412,18 +1412,18 @@  discard block
 block discarded – undo
1412 1412
 		EE_Message_Resource_Manager $message_resource_manager
1413 1413
 	) {
1414 1414
 		/** @type EE_messenger[] $messengers_to_generate */
1415
-		$messengers_to_generate = self::_get_default_messengers_to_generate_on_activation( $message_resource_manager );
1415
+		$messengers_to_generate = self::_get_default_messengers_to_generate_on_activation($message_resource_manager);
1416 1416
 		$installed_message_types = $message_resource_manager->installed_message_types();
1417 1417
 		$templates_generated = false;
1418
-		foreach ( $messengers_to_generate as $messenger_to_generate ) {
1418
+		foreach ($messengers_to_generate as $messenger_to_generate) {
1419 1419
 			$default_message_type_names_for_messenger = $messenger_to_generate->get_default_message_types();
1420 1420
 			//verify the default message types match an installed message type.
1421
-			foreach ( $default_message_type_names_for_messenger as $key => $name ) {
1421
+			foreach ($default_message_type_names_for_messenger as $key => $name) {
1422 1422
 				if (
1423
-					! isset( $installed_message_types[ $name ] )
1424
-					|| $message_resource_manager->has_message_type_been_activated_for_messenger( $name, $messenger_to_generate->name )
1423
+					! isset($installed_message_types[$name])
1424
+					|| $message_resource_manager->has_message_type_been_activated_for_messenger($name, $messenger_to_generate->name)
1425 1425
 				) {
1426
-					unset( $default_message_type_names_for_messenger[ $key ] );
1426
+					unset($default_message_type_names_for_messenger[$key]);
1427 1427
 				}
1428 1428
 			}
1429 1429
 			// in previous iterations, the active_messengers option in the db
@@ -1437,7 +1437,7 @@  discard block
 block discarded – undo
1437 1437
 				false
1438 1438
 			);
1439 1439
 			//create any templates needing created (or will reactivate templates already generated as necessary).
1440
-			if ( ! empty( $default_message_type_names_for_messenger ) ) {
1440
+			if ( ! empty($default_message_type_names_for_messenger)) {
1441 1441
 				$templates_generated = EEH_MSG_Template::generate_new_templates(
1442 1442
 					$messenger_to_generate->name,
1443 1443
 					$default_message_type_names_for_messenger,
@@ -1469,18 +1469,18 @@  discard block
 block discarded – undo
1469 1469
 		$has_activated = $message_resource_manager->get_has_activated_messengers_option();
1470 1470
 
1471 1471
 		$messengers_to_generate = array();
1472
-		foreach ( $installed_messengers as $installed_messenger ) {
1472
+		foreach ($installed_messengers as $installed_messenger) {
1473 1473
 			//if installed messenger is a messenger that should be activated on install
1474 1474
 			//and is not already active
1475 1475
 			//and has never been activated
1476 1476
 			if (
1477 1477
 				! $installed_messenger->activate_on_install
1478
-				|| isset( $active_messengers[ $installed_messenger->name ] )
1479
-				|| isset( $has_activated[ $installed_messenger->name ] )
1478
+				|| isset($active_messengers[$installed_messenger->name])
1479
+				|| isset($has_activated[$installed_messenger->name])
1480 1480
 			) {
1481 1481
 				continue;
1482 1482
 			}
1483
-			$messengers_to_generate[ $installed_messenger->name ] = $installed_messenger;
1483
+			$messengers_to_generate[$installed_messenger->name] = $installed_messenger;
1484 1484
 		}
1485 1485
 		return $messengers_to_generate;
1486 1486
 	}
@@ -1505,9 +1505,9 @@  discard block
 block discarded – undo
1505 1505
 	 */
1506 1506
 	public static function validate_messages_system() {
1507 1507
 		/** @type EE_Message_Resource_Manager $message_resource_manager */
1508
-		$message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
1508
+		$message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
1509 1509
 		$message_resource_manager->validate_active_message_types_are_installed();
1510
-		do_action( 'AHEE__EEH_Activation__validate_messages_system' );
1510
+		do_action('AHEE__EEH_Activation__validate_messages_system');
1511 1511
 	}
1512 1512
 
1513 1513
 
@@ -1520,12 +1520,12 @@  discard block
 block discarded – undo
1520 1520
 	 * 	@static
1521 1521
 	 * 	@return void
1522 1522
 	 */
1523
-	public static function create_no_ticket_prices_array(){
1523
+	public static function create_no_ticket_prices_array() {
1524 1524
 		// this creates an array for tracking events that have no active ticket prices created
1525 1525
 		// this allows us to warn admins of the situation so that it can be corrected
1526
-		$espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', FALSE );
1527
-		if ( ! $espresso_no_ticket_prices ) {
1528
-			add_option( 'ee_no_ticket_prices', array(), '', FALSE );
1526
+		$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', FALSE);
1527
+		if ( ! $espresso_no_ticket_prices) {
1528
+			add_option('ee_no_ticket_prices', array(), '', FALSE);
1529 1529
 		}
1530 1530
 	}
1531 1531
 
@@ -1550,24 +1550,24 @@  discard block
 block discarded – undo
1550 1550
 	 * @global wpdb $wpdb
1551 1551
 	 * @throws \EE_Error
1552 1552
 	 */
1553
-	public static function delete_all_espresso_cpt_data(){
1553
+	public static function delete_all_espresso_cpt_data() {
1554 1554
 		global $wpdb;
1555 1555
 		//get all the CPT post_types
1556 1556
 		$ee_post_types = array();
1557
-		foreach(EE_Registry::instance()->non_abstract_db_models as $model_name){
1558
-			if ( method_exists( $model_name, 'instance' )) {
1559
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1560
-				if ( $model_obj instanceof EEM_CPT_Base ) {
1561
-					$ee_post_types[] = $wpdb->prepare("%s",$model_obj->post_type());
1557
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1558
+			if (method_exists($model_name, 'instance')) {
1559
+				$model_obj = call_user_func(array($model_name, 'instance'));
1560
+				if ($model_obj instanceof EEM_CPT_Base) {
1561
+					$ee_post_types[] = $wpdb->prepare("%s", $model_obj->post_type());
1562 1562
 				}
1563 1563
 			}
1564 1564
 		}
1565 1565
 		//get all our CPTs
1566
-		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",",$ee_post_types).")";
1566
+		$query = "SELECT ID FROM {$wpdb->posts} WHERE post_type IN (".implode(",", $ee_post_types).")";
1567 1567
 		$cpt_ids = $wpdb->get_col($query);
1568 1568
 		//delete each post meta and term relations too
1569
-		foreach($cpt_ids as $post_id){
1570
-			wp_delete_post($post_id,true);
1569
+		foreach ($cpt_ids as $post_id) {
1570
+			wp_delete_post($post_id, true);
1571 1571
 		}
1572 1572
 	}
1573 1573
 
@@ -1581,18 +1581,18 @@  discard block
 block discarded – undo
1581 1581
 	 * @param bool $remove_all
1582 1582
 	 * @return void
1583 1583
 	 */
1584
-	public static function delete_all_espresso_tables_and_data( $remove_all = true ) {
1584
+	public static function delete_all_espresso_tables_and_data($remove_all = true) {
1585 1585
 		global $wpdb;
1586 1586
 		$undeleted_tables = array();
1587 1587
 
1588 1588
 		// load registry
1589
-		foreach( EE_Registry::instance()->non_abstract_db_models as $model_name ){
1590
-			if ( method_exists( $model_name, 'instance' )) {
1591
-				$model_obj = call_user_func( array( $model_name, 'instance' ));
1592
-				if ( $model_obj instanceof EEM_Base ) {
1593
-					foreach ( $model_obj->get_tables() as $table ) {
1594
-						if ( strpos( $table->get_table_name(), 'esp_' )) {
1595
-							switch ( EEH_Activation::delete_unused_db_table( $table->get_table_name() )) {
1589
+		foreach (EE_Registry::instance()->non_abstract_db_models as $model_name) {
1590
+			if (method_exists($model_name, 'instance')) {
1591
+				$model_obj = call_user_func(array($model_name, 'instance'));
1592
+				if ($model_obj instanceof EEM_Base) {
1593
+					foreach ($model_obj->get_tables() as $table) {
1594
+						if (strpos($table->get_table_name(), 'esp_')) {
1595
+							switch (EEH_Activation::delete_unused_db_table($table->get_table_name())) {
1596 1596
 								case false :
1597 1597
 									$undeleted_tables[] = $table->get_table_name();
1598 1598
 								break;
@@ -1617,8 +1617,8 @@  discard block
 block discarded – undo
1617 1617
 			'esp_promotion_rule',
1618 1618
 			'esp_rule'
1619 1619
 		);
1620
-		foreach( $tables_without_models as $table ){
1621
-			EEH_Activation::delete_db_table_if_empty( $table );
1620
+		foreach ($tables_without_models as $table) {
1621
+			EEH_Activation::delete_db_table_if_empty($table);
1622 1622
 		}
1623 1623
 
1624 1624
 
@@ -1656,58 +1656,58 @@  discard block
 block discarded – undo
1656 1656
 			'ee_job_parameters_' => false,
1657 1657
 			'ee_upload_directories_incomplete' => true,
1658 1658
 		);
1659
-		if( is_main_site() ) {
1660
-			$wp_options_to_delete[ 'ee_network_config' ] = true;
1659
+		if (is_main_site()) {
1660
+			$wp_options_to_delete['ee_network_config'] = true;
1661 1661
 		}
1662 1662
 
1663 1663
 		$undeleted_options = array();
1664
-		foreach ( $wp_options_to_delete as $option_name => $no_wildcard ) {
1664
+		foreach ($wp_options_to_delete as $option_name => $no_wildcard) {
1665 1665
 
1666
-			if( $no_wildcard ){
1667
-				if( ! delete_option( $option_name ) ){
1666
+			if ($no_wildcard) {
1667
+				if ( ! delete_option($option_name)) {
1668 1668
 					$undeleted_options[] = $option_name;
1669 1669
 				}
1670
-			}else{
1671
-				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1672
-				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1673
-					if( ! delete_option( $option_name_from_wildcard ) ){
1670
+			} else {
1671
+				$option_names_to_delete_from_wildcard = $wpdb->get_col("SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'");
1672
+				foreach ($option_names_to_delete_from_wildcard as $option_name_from_wildcard) {
1673
+					if ( ! delete_option($option_name_from_wildcard)) {
1674 1674
 						$undeleted_options[] = $option_name_from_wildcard;
1675 1675
 					}
1676 1676
 				}
1677 1677
 			}
1678 1678
 		}
1679 1679
                 //also, let's make sure the "ee_config_option_names" wp option stays out by removing the action that adds it
1680
-                remove_action( 'shutdown', array( EE_Config::instance(), 'shutdown' ), 10 );
1680
+                remove_action('shutdown', array(EE_Config::instance(), 'shutdown'), 10);
1681 1681
 
1682
-		if ( $remove_all && $espresso_db_update = get_option( 'espresso_db_update' )) {
1682
+		if ($remove_all && $espresso_db_update = get_option('espresso_db_update')) {
1683 1683
 			$db_update_sans_ee4 = array();
1684
-			foreach($espresso_db_update as $version => $times_activated){
1685
-				if( (string)$version[0] === '3'){//if its NON EE4
1684
+			foreach ($espresso_db_update as $version => $times_activated) {
1685
+				if ((string) $version[0] === '3') {//if its NON EE4
1686 1686
 					$db_update_sans_ee4[$version] = $times_activated;
1687 1687
 				}
1688 1688
 			}
1689
-			update_option( 'espresso_db_update', $db_update_sans_ee4 );
1689
+			update_option('espresso_db_update', $db_update_sans_ee4);
1690 1690
 		}
1691 1691
 
1692 1692
 		$errors = '';
1693
-		if ( ! empty( $undeleted_tables )) {
1693
+		if ( ! empty($undeleted_tables)) {
1694 1694
 			$errors .= sprintf(
1695
-				__( 'The following tables could not be deleted: %s%s', 'event_espresso' ),
1695
+				__('The following tables could not be deleted: %s%s', 'event_espresso'),
1696 1696
 				'<br/>',
1697
-				implode( ',<br/>', $undeleted_tables )
1697
+				implode(',<br/>', $undeleted_tables)
1698 1698
 			);
1699 1699
 		}
1700
-		if ( ! empty( $undeleted_options )) {
1701
-			$errors .= ! empty( $undeleted_tables ) ? '<br/>' : '';
1700
+		if ( ! empty($undeleted_options)) {
1701
+			$errors .= ! empty($undeleted_tables) ? '<br/>' : '';
1702 1702
 			$errors .= sprintf(
1703
-				__( 'The following wp-options could not be deleted: %s%s', 'event_espresso' ),
1703
+				__('The following wp-options could not be deleted: %s%s', 'event_espresso'),
1704 1704
 				'<br/>',
1705
-				implode( ',<br/>', $undeleted_options )
1705
+				implode(',<br/>', $undeleted_options)
1706 1706
 			);
1707 1707
 
1708 1708
 		}
1709
-		if ( ! empty( $errors ) ) {
1710
-			EE_Error::add_attention( $errors, __FILE__, __FUNCTION__, __LINE__ );
1709
+		if ( ! empty($errors)) {
1710
+			EE_Error::add_attention($errors, __FILE__, __FUNCTION__, __LINE__);
1711 1711
 		}
1712 1712
 	}
1713 1713
 	
@@ -1717,10 +1717,10 @@  discard block
 block discarded – undo
1717 1717
 	 */
1718 1718
 	public static function last_wpdb_error_code() {
1719 1719
 		global $wpdb;
1720
-		if( $wpdb->use_mysqli ) {
1721
-			return mysqli_errno( $wpdb->dbh );
1720
+		if ($wpdb->use_mysqli) {
1721
+			return mysqli_errno($wpdb->dbh);
1722 1722
 		} else {
1723
-			return mysql_errno( $wpdb->dbh );
1723
+			return mysql_errno($wpdb->dbh);
1724 1724
 		}
1725 1725
 	}
1726 1726
 
@@ -1730,23 +1730,23 @@  discard block
 block discarded – undo
1730 1730
 	 * @param string $table_name with or without $wpdb->prefix
1731 1731
 	 * @return boolean
1732 1732
 	 */
1733
-	public static function table_exists( $table_name ){
1733
+	public static function table_exists($table_name) {
1734 1734
 		global $wpdb, $EZSQL_ERROR;
1735
-		$table_name = EEH_Activation::ensure_table_name_has_prefix( $table_name );
1735
+		$table_name = EEH_Activation::ensure_table_name_has_prefix($table_name);
1736 1736
 		//ignore if this causes an sql error
1737 1737
 		$old_error = $wpdb->last_error;
1738 1738
 		$old_suppress_errors = $wpdb->suppress_errors();
1739
-		$old_show_errors_value = $wpdb->show_errors( FALSE );
1739
+		$old_show_errors_value = $wpdb->show_errors(FALSE);
1740 1740
 		$ezsql_error_cache = $EZSQL_ERROR;
1741
-		$wpdb->get_results( "SELECT * from $table_name LIMIT 1");
1742
-		$wpdb->show_errors( $old_show_errors_value );
1743
-		$wpdb->suppress_errors( $old_suppress_errors );
1741
+		$wpdb->get_results("SELECT * from $table_name LIMIT 1");
1742
+		$wpdb->show_errors($old_show_errors_value);
1743
+		$wpdb->suppress_errors($old_suppress_errors);
1744 1744
 		$new_error = $wpdb->last_error;
1745 1745
 		$wpdb->last_error = $old_error;
1746 1746
 		$EZSQL_ERROR = $ezsql_error_cache;
1747 1747
 		//if there was a table doesn't exist error
1748
-		if( ! empty( $new_error ) ) {
1749
-			if(
1748
+		if ( ! empty($new_error)) {
1749
+			if (
1750 1750
 				in_array(
1751 1751
 					EEH_Activation::last_wpdb_error_code(),
1752 1752
 					array(
@@ -1756,14 +1756,14 @@  discard block
 block discarded – undo
1756 1756
 					)
1757 1757
 				)
1758 1758
 				|| 
1759
-				preg_match( '~^Table .* doesn\'t exist~', $new_error ) //in case not using mysql and error codes aren't reliable, just check for this error string
1759
+				preg_match('~^Table .* doesn\'t exist~', $new_error) //in case not using mysql and error codes aren't reliable, just check for this error string
1760 1760
 			) {
1761 1761
 				return false;
1762 1762
 			} else {
1763 1763
 				//log this because that's weird. Just use the normal PHP error log
1764 1764
 				error_log( 
1765 1765
 					sprintf(
1766
-						__( 'Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso' ),
1766
+						__('Event Espresso error detected when checking if table existed: %1$s (it wasn\'t just that the table didn\'t exist either)', 'event_espresso'),
1767 1767
 					$new_error
1768 1768
 					)
1769 1769
 				);
@@ -1775,7 +1775,7 @@  discard block
 block discarded – undo
1775 1775
 	/**
1776 1776
 	 * Resets the cache on EEH_Activation
1777 1777
 	 */
1778
-	public static function reset(){
1778
+	public static function reset() {
1779 1779
 		self::$_default_creator_id = NULL;
1780 1780
 		self::$_initialized_db_content_already_in_this_request = false;
1781 1781
 	}
Please login to merge, or discard this patch.
Braces   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -465,7 +465,7 @@  discard block
 block discarded – undo
465 465
 		$post_id = $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE post_content LIKE '%$shortcode_and_opening_bracket%' LIMIT 1");
466 466
 		if($post_id){
467 467
 			return get_post($post_id);
468
-		}else{
468
+		} else{
469 469
 			return NULL;
470 470
 		}
471 471
 
@@ -838,13 +838,13 @@  discard block
 block discarded – undo
838 838
 					foreach( $current_data_migration_script->get_errors() as $error ){
839 839
 						EE_Error::add_error($error, __FILE__, __FUNCTION__, __LINE__ );
840 840
 					}
841
-				}else{
841
+				} else{
842 842
 					EE_Error::add_error( __( 'There were errors creating the Event Espresso database tables and Event Espresso has been deactivated. To view the errors, please enable WP_DEBUG in your wp-config.php file.', 'event_espresso' ) );
843 843
 				}
844 844
 				return false;
845 845
 			}
846 846
 			EE_Data_Migration_Manager::instance()->update_current_database_state_to();
847
-		}else{
847
+		} else{
848 848
 			EE_Error::add_error( __( 'Could not determine most up-to-date data migration script from which to pull database schema structure. So database is probably not setup properly', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__);
849 849
 			return false;
850 850
 		}
@@ -1174,7 +1174,7 @@  discard block
 block discarded – undo
1174 1174
 		if( ! EEM_Payment_Method::instance()->count_active( EEM_Payment_Method::scope_cart ) ){
1175 1175
 			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
1176 1176
 			EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
1177
-		}else{
1177
+		} else{
1178 1178
 			EEM_Payment_Method::instance()->verify_button_urls();
1179 1179
 		}
1180 1180
 	}
@@ -1667,7 +1667,7 @@  discard block
 block discarded – undo
1667 1667
 				if( ! delete_option( $option_name ) ){
1668 1668
 					$undeleted_options[] = $option_name;
1669 1669
 				}
1670
-			}else{
1670
+			} else{
1671 1671
 				$option_names_to_delete_from_wildcard = $wpdb->get_col( "SELECT option_name FROM $wpdb->options WHERE option_name LIKE '%$option_name%'" );
1672 1672
 				foreach($option_names_to_delete_from_wildcard as $option_name_from_wildcard ){
1673 1673
 					if( ! delete_option( $option_name_from_wildcard ) ){
Please login to merge, or discard this patch.
core/db_models/EEM_Message.model.php 1 patch
Spacing   +81 added lines, -81 removed lines patch added patch discarded remove patch
@@ -105,42 +105,42 @@  discard block
 block discarded – undo
105 105
 	 *
106 106
 	 * @return EEM_Message
107 107
 	 */
108
-	protected function __construct( $timezone = null ) {
109
-		$this->singular_item = __('Message','event_espresso');
110
-		$this->plural_item = __('Messages','event_espresso');
108
+	protected function __construct($timezone = null) {
109
+		$this->singular_item = __('Message', 'event_espresso');
110
+		$this->plural_item = __('Messages', 'event_espresso');
111 111
 
112 112
 		//used for token generator
113
-		EE_Registry::instance()->load_helper( 'URL' );
113
+		EE_Registry::instance()->load_helper('URL');
114 114
 
115 115
 		$this->_tables = array(
116
-			'Message'=>new EE_Primary_Table('esp_message','MSG_ID')
116
+			'Message'=>new EE_Primary_Table('esp_message', 'MSG_ID')
117 117
 		);
118 118
 
119 119
 		$allowed_priority = array(
120
-			self::priority_high => __( 'high', 'event_espresso' ),
121
-			self::priority_medium => __( 'medium', 'event_espresso' ),
122
-			self::priority_low => __( 'low', 'event_espresso' )
120
+			self::priority_high => __('high', 'event_espresso'),
121
+			self::priority_medium => __('medium', 'event_espresso'),
122
+			self::priority_low => __('low', 'event_espresso')
123 123
 		);
124 124
 
125 125
 		$this->_fields = array(
126 126
 			'Message'=>array(
127
-				'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID','event_espresso')),
128
-				'MSG_token' => new EE_Plain_Text_Field( 'MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso' ), false, EEH_URL::generate_unique_token() ),
129
-				'GRP_ID'=>new EE_Foreign_Key_Int_Field( 'GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso' ), true, 0, 'Message_Template_Group' ),
130
-				'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( 'Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message', 'event_espresso' ), true, 0, 'Transaction' ),
131
-				'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __( 'Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso' ), false, 'email' ),
132
-				'MSG_message_type' => new EE_Plain_Text_Field( 'MSG_message_type', __( 'Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso' ), false, 'receipt' ),
133
-				'MSG_context' => new EE_Plain_Text_Field( 'MSG_context', __( 'Context', 'event_espresso' ), false ),
134
-				'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field( 'MSG_recipient_ID', __( 'Recipient ID', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ),
135
-				'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field( 'MSG_recipient_type', __( 'Recipient Type', 'event_espresso' ), true, null, array( 'Registration', 'Attendee', 'WP_User' ) ),
136
-				'MSG_content' => new EE_Maybe_Serialized_Text_Field( 'MSG_content', __( 'Content', 'event_espresso' ), true, '' ),
137
-				'MSG_to' => new EE_Maybe_Serialized_Text_Field( 'MSG_to', __( 'Address To', 'event_espresso' ), true ),
138
-				'MSG_from' => new EE_Maybe_Serialized_Text_Field( 'MSG_from', __( 'Address From', 'event_espresso' ), true ),
139
-				'MSG_subject' => new EE_Maybe_Serialized_Text_Field( 'MSG_subject', __( 'Subject', 'event_espresso' ), true, '' ),
140
-				'MSG_priority' => new EE_Enum_Integer_Field( 'MSG_priority', __( 'Priority', 'event_espresso' ), false, self::priority_low, $allowed_priority ),
141
-				'STS_ID' => new EE_Foreign_Key_String_Field( 'STS_ID', __( 'Status', 'event_espresso' ), false, self::status_incomplete, 'Status' ),
142
-				'MSG_created' => new EE_Datetime_Field( 'MSG_created', __( 'Created', 'event_espresso' ), false, time() ),
143
-				'MSG_modified' => new EE_Datetime_Field( 'MSG_modified', __( 'Modified', 'event_espresso' ), true, time() )
127
+				'MSG_ID'=>new EE_Primary_Key_Int_Field('MSG_ID', __('Message ID', 'event_espresso')),
128
+				'MSG_token' => new EE_Plain_Text_Field('MSG_token', __('Unique Token used to represent this row in publicly viewable contexts (eg. a url).', 'event_espresso'), false, EEH_URL::generate_unique_token()),
129
+				'GRP_ID'=>new EE_Foreign_Key_Int_Field('GRP_ID', __('Foreign key to the EEM_Message_Template_Group table.', 'event_espresso'), true, 0, 'Message_Template_Group'),
130
+				'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __('Foreign key to the related EE_Transaction.  This is required to give context for regenerating the specific message', 'event_espresso'), true, 0, 'Transaction'),
131
+				'MSG_messenger' => new EE_Plain_Text_Field('MSG_messenger', __('Corresponds to the EE_messenger::name used to send this message. This will also be used to attempt any resending of the message.', 'event_espresso'), false, 'email'),
132
+				'MSG_message_type' => new EE_Plain_Text_Field('MSG_message_type', __('Corresponds to the EE_message_type::name used to generate this message.', 'event_espresso'), false, 'receipt'),
133
+				'MSG_context' => new EE_Plain_Text_Field('MSG_context', __('Context', 'event_espresso'), false),
134
+				'MSG_recipient_ID' => new EE_Foreign_Key_Int_Field('MSG_recipient_ID', __('Recipient ID', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')),
135
+				'MSG_recipient_type' => new EE_Any_Foreign_Model_Name_Field('MSG_recipient_type', __('Recipient Type', 'event_espresso'), true, null, array('Registration', 'Attendee', 'WP_User')),
136
+				'MSG_content' => new EE_Maybe_Serialized_Text_Field('MSG_content', __('Content', 'event_espresso'), true, ''),
137
+				'MSG_to' => new EE_Maybe_Serialized_Text_Field('MSG_to', __('Address To', 'event_espresso'), true),
138
+				'MSG_from' => new EE_Maybe_Serialized_Text_Field('MSG_from', __('Address From', 'event_espresso'), true),
139
+				'MSG_subject' => new EE_Maybe_Serialized_Text_Field('MSG_subject', __('Subject', 'event_espresso'), true, ''),
140
+				'MSG_priority' => new EE_Enum_Integer_Field('MSG_priority', __('Priority', 'event_espresso'), false, self::priority_low, $allowed_priority),
141
+				'STS_ID' => new EE_Foreign_Key_String_Field('STS_ID', __('Status', 'event_espresso'), false, self::status_incomplete, 'Status'),
142
+				'MSG_created' => new EE_Datetime_Field('MSG_created', __('Created', 'event_espresso'), false, time()),
143
+				'MSG_modified' => new EE_Datetime_Field('MSG_modified', __('Modified', 'event_espresso'), true, time())
144 144
 			)
145 145
 		);
146 146
 		$this->_model_relations = array(
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 			'Message_Template_Group' => new EE_Belongs_To_Relation(),
151 151
 			'Transaction' => new EE_Belongs_To_Relation()
152 152
 		);
153
-		parent::__construct( $timezone );
153
+		parent::__construct($timezone);
154 154
 	}
155 155
 
156 156
 
@@ -161,8 +161,8 @@  discard block
 block discarded – undo
161 161
 	public function create_default_object() {
162 162
 		/** @type EE_Message $message */
163 163
 		$message = parent::create_default_object();
164
-		if ( $message instanceof EE_Message ) {
165
-			return EE_Message_Factory::set_messenger_and_message_type( $message );
164
+		if ($message instanceof EE_Message) {
165
+			return EE_Message_Factory::set_messenger_and_message_type($message);
166 166
 		}
167 167
 		return null;
168 168
 	}
@@ -173,11 +173,11 @@  discard block
 block discarded – undo
173 173
 	 * @param mixed $cols_n_values
174 174
 	 * @return \EE_Message
175 175
 	 */
176
-	public function instantiate_class_from_array_or_object( $cols_n_values ) {
176
+	public function instantiate_class_from_array_or_object($cols_n_values) {
177 177
 		/** @type EE_Message $message */
178
-		$message = parent::instantiate_class_from_array_or_object( $cols_n_values );
179
-		if ( $message instanceof EE_Message ) {
180
-			return EE_Message_Factory::set_messenger_and_message_type( $message );
178
+		$message = parent::instantiate_class_from_array_or_object($cols_n_values);
179
+		if ($message instanceof EE_Message) {
180
+			return EE_Message_Factory::set_messenger_and_message_type($message);
181 181
 		}
182 182
 		return null;
183 183
 	}
@@ -190,13 +190,13 @@  discard block
 block discarded – undo
190 190
 	 * @param string $message_type the message type slug
191 191
 	 * @return boolean
192 192
 	 */
193
-	public function message_sent_for_attendee( $attendee, $message_type ) {
194
-		$attendee_ID = EEM_Attendee::instance()->ensure_is_ID( $attendee );
195
-		return $this->exists( array( array(
193
+	public function message_sent_for_attendee($attendee, $message_type) {
194
+		$attendee_ID = EEM_Attendee::instance()->ensure_is_ID($attendee);
195
+		return $this->exists(array(array(
196 196
 			'Attendee.ATT_ID' => $attendee_ID,
197 197
 			'MSG_message_type' => $message_type,
198
-			'STS_ID' => array( 'IN', $this->stati_indicating_sent() )
199
-		) ) );
198
+			'STS_ID' => array('IN', $this->stati_indicating_sent())
199
+		)));
200 200
 	}
201 201
 
202 202
 
@@ -208,13 +208,13 @@  discard block
 block discarded – undo
208 208
 	 * @param string $message_type the message type slug
209 209
 	 * @return boolean
210 210
 	 */
211
-	public function message_sent_for_registration( $registration, $message_type ) {
212
-		$registrationID = EEM_Registration::instance()->ensure_is_ID( $registration );
213
-		return $this->exists( array( array(
211
+	public function message_sent_for_registration($registration, $message_type) {
212
+		$registrationID = EEM_Registration::instance()->ensure_is_ID($registration);
213
+		return $this->exists(array(array(
214 214
 			'Registration.REG_ID' => $registrationID,
215 215
 			'MSG_message_type' => $message_type,
216
-			'STS_ID' => array( 'IN', $this->stati_indicating_sent() )
217
-		) ) );
216
+			'STS_ID' => array('IN', $this->stati_indicating_sent())
217
+		)));
218 218
 	}
219 219
 
220 220
 
@@ -225,10 +225,10 @@  discard block
 block discarded – undo
225 225
 	 * @param string $token
226 226
 	 * @return EE_Message
227 227
 	 */
228
-	public function get_one_by_token( $token ) {
229
-		return $this->get_one( array( array(
228
+	public function get_one_by_token($token) {
229
+		return $this->get_one(array(array(
230 230
 			'MSG_token' => $token
231
-		) ) );
231
+		)));
232 232
 	}
233 233
 
234 234
 
@@ -236,8 +236,8 @@  discard block
 block discarded – undo
236 236
 	 * Returns stati that indicate the message HAS been sent
237 237
 	 * @return array of strings for possible stati
238 238
 	 */
239
-	public function stati_indicating_sent(){
240
-		return apply_filters( 'FHEE__EEM_Message__stati_indicating_sent', array( self::status_sent ) );
239
+	public function stati_indicating_sent() {
240
+		return apply_filters('FHEE__EEM_Message__stati_indicating_sent', array(self::status_sent));
241 241
 	}
242 242
 
243 243
 
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
 	 * @return array of strings for possible stati.
249 249
 	 */
250 250
 	public function stati_indicating_to_send() {
251
-		return apply_filters( 'FHEE__EEM_Message__stati_indicating_to_send', array( self::status_idle, self::status_resend ) );
251
+		return apply_filters('FHEE__EEM_Message__stati_indicating_to_send', array(self::status_idle, self::status_resend));
252 252
 	}
253 253
 
254 254
 
@@ -262,10 +262,10 @@  discard block
 block discarded – undo
262 262
 			self::status_retry,
263 263
 		);
264 264
 		//if WP_DEBUG is set, then let's include debug_only fails
265
-		if ( WP_DEBUG ) {
265
+		if (WP_DEBUG) {
266 266
 			$failed_stati[] = self::status_debug_only;
267 267
 		}
268
-		return apply_filters( 'FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati );
268
+		return apply_filters('FHEE__EEM_Message__stati_indicating_failed_sending', $failed_stati);
269 269
 	}
270 270
 
271 271
 
@@ -300,11 +300,11 @@  discard block
 block discarded – undo
300 300
 		// the value, matches the corresponding EEM_Base child reference.
301 301
 		$expected_vars = $this->_expected_vars_for_query_inject();
302 302
 		$query_params[0] = array();
303
-		foreach ( $expected_vars as $request_key => $model_name ) {
304
-			$request_value = EE_Registry::instance()->REQ->get( $request_key );
305
-			if ( $request_value ) {
303
+		foreach ($expected_vars as $request_key => $model_name) {
304
+			$request_value = EE_Registry::instance()->REQ->get($request_key);
305
+			if ($request_value) {
306 306
 				//special case
307
-				switch ( $request_key ) {
307
+				switch ($request_key) {
308 308
 					case '_REG_ID' :
309 309
 						$query_params[0]['AND**filter_by']['OR**filter_by_REG_ID'] = array(
310 310
 							'Transaction.Registration.REG_ID' => $request_value,
@@ -316,7 +316,7 @@  discard block
 block discarded – undo
316 316
 						);
317 317
 						break;
318 318
 					default :
319
-						$query_params[0]['AND**filter_by'][ 'OR**filter_by_' . $request_key ][ $model_name . '.' . $request_key ] = $request_value;
319
+						$query_params[0]['AND**filter_by']['OR**filter_by_'.$request_key][$model_name.'.'.$request_key] = $request_value;
320 320
 						break;
321 321
 				}
322 322
 			}
@@ -333,53 +333,53 @@  discard block
 block discarded – undo
333 333
 		$expected_vars = $this->_expected_vars_for_query_inject();
334 334
 		$pretty_label = '';
335 335
 		$label_parts = array();
336
-		foreach ( $expected_vars as $request_key => $model_name ) {
337
-			$model = EE_Registry::instance()->load_model( $model_name );
338
-			if ( $model_field_value = EE_Registry::instance()->REQ->get( $request_key ) ) {
339
-				switch ( $request_key ) {
336
+		foreach ($expected_vars as $request_key => $model_name) {
337
+			$model = EE_Registry::instance()->load_model($model_name);
338
+			if ($model_field_value = EE_Registry::instance()->REQ->get($request_key)) {
339
+				switch ($request_key) {
340 340
 					case '_REG_ID' :
341 341
 						$label_parts[] = sprintf(
342
-							esc_html__( 'Registration with the ID: %s', 'event_espresso' ),
342
+							esc_html__('Registration with the ID: %s', 'event_espresso'),
343 343
 							$model_field_value
344 344
 						);
345 345
 						break;
346 346
 					case 'ATT_ID' :
347 347
 						/** @var EE_Attendee $attendee */
348
-						$attendee = $model->get_one_by_ID( $model_field_value );
348
+						$attendee = $model->get_one_by_ID($model_field_value);
349 349
 						$label_parts[] = $attendee instanceof EE_Attendee
350
-							? sprintf( esc_html__( 'Attendee %s', 'event_espresso' ), $attendee->full_name() )
351
-							: sprintf( esc_html__( 'Attendee ID: %s', 'event_espresso' ), $model_field_value );
350
+							? sprintf(esc_html__('Attendee %s', 'event_espresso'), $attendee->full_name())
351
+							: sprintf(esc_html__('Attendee ID: %s', 'event_espresso'), $model_field_value);
352 352
 						break;
353 353
 					case 'ID' :
354 354
 						/** @var EE_WP_User $wpUser */
355
-						$wpUser = $model->get_one_by_ID( $model_field_value );
355
+						$wpUser = $model->get_one_by_ID($model_field_value);
356 356
 						$label_parts[] = $wpUser instanceof EE_WP_User
357
-							? sprintf( esc_html__( 'WP User: %s', 'event_espresso' ), $wpUser->name() )
358
-							: sprintf( esc_html__( 'WP User ID: %s', 'event_espresso' ), $model_field_value );
357
+							? sprintf(esc_html__('WP User: %s', 'event_espresso'), $wpUser->name())
358
+							: sprintf(esc_html__('WP User ID: %s', 'event_espresso'), $model_field_value);
359 359
 						break;
360 360
 					case 'TXN_ID' :
361 361
 						$label_parts[] = sprintf(
362
-							esc_html__( 'Transaction with the ID: %s', 'event_espresso' ),
362
+							esc_html__('Transaction with the ID: %s', 'event_espresso'),
363 363
 							$model_field_value
364 364
 						);
365 365
 						break;
366 366
 					case 'EVT_ID' :
367 367
 						/** @var EE_Event $Event */
368
-						$Event = $model->get_one_by_ID( $model_field_value );
368
+						$Event = $model->get_one_by_ID($model_field_value);
369 369
 						$label_parts[] = $Event instanceof EE_Event
370
-							? sprintf( esc_html__( 'for the Event: %s', 'event_espresso' ), $Event->name() )
371
-							: sprintf( esc_html__( 'for the Event with ID: %s', 'event_espresso' ), $model_field_value );
370
+							? sprintf(esc_html__('for the Event: %s', 'event_espresso'), $Event->name())
371
+							: sprintf(esc_html__('for the Event with ID: %s', 'event_espresso'), $model_field_value);
372 372
 						break;
373 373
 				}
374 374
 			}
375 375
 		}
376 376
 
377
-		if ( $label_parts ) {
377
+		if ($label_parts) {
378 378
 
379 379
 			//prepend to the last element of $label_parts an "and".
380
-			if ( count( $label_parts ) > 1 ) {
381
-				$label_parts_index_to_prepend                 = count( $label_parts ) - 1;
382
-				$label_parts[ $label_parts_index_to_prepend ] = 'and' . $label_parts[ $label_parts_index_to_prepend ];
380
+			if (count($label_parts) > 1) {
381
+				$label_parts_index_to_prepend                 = count($label_parts) - 1;
382
+				$label_parts[$label_parts_index_to_prepend] = 'and'.$label_parts[$label_parts_index_to_prepend];
383 383
 			}
384 384
 
385 385
 			$pretty_label .= sprintf(
@@ -388,7 +388,7 @@  discard block
 block discarded – undo
388 388
 					'A label for the messages returned in a query that are filtered by items in the query. This could be Transaction, Event, Attendee, Registration, or WP_User.',
389 389
 					'event_espresso'
390 390
 				),
391
-				implode( ', ', $label_parts )
391
+				implode(', ', $label_parts)
392 392
 			);
393 393
 		}
394 394
 		return $pretty_label;
@@ -438,20 +438,20 @@  discard block
 block discarded – undo
438 438
 	 *
439 439
 	 * @return bool         true means Messages is in debug mode.  false means messages system is not in debug mode.
440 440
 	 */
441
-	public static function debug( $set_debug = null ) {
441
+	public static function debug($set_debug = null) {
442 442
 		static $is_debugging = null;
443 443
 
444 444
 		//initialize (use constant if set).
445
-		if ( is_null( $set_debug ) && is_null( $is_debugging ) ) {
446
-			$is_debugging = defined( 'EE_DEBUG_MESSAGES' ) && EE_DEBUG_MESSAGES;
445
+		if (is_null($set_debug) && is_null($is_debugging)) {
446
+			$is_debugging = defined('EE_DEBUG_MESSAGES') && EE_DEBUG_MESSAGES;
447 447
 		}
448 448
 
449
-		if ( ! is_null( $set_debug ) ) {
450
-			$is_debugging = filter_var( $set_debug, FILTER_VALIDATE_BOOLEAN );
449
+		if ( ! is_null($set_debug)) {
450
+			$is_debugging = filter_var($set_debug, FILTER_VALIDATE_BOOLEAN);
451 451
 		}
452 452
 
453 453
 		//return filtered value
454
-		return apply_filters( 'FHEE__EEM_Message__debug', $is_debugging );
454
+		return apply_filters('FHEE__EEM_Message__debug', $is_debugging);
455 455
 	}
456 456
 
457 457
 
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page.core.php 1 patch
Spacing   +627 added lines, -627 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION') )
2
-	{exit('NO direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION'))
2
+	{exit('NO direct script access allowed'); }
3 3
 
4 4
 /**
5 5
  *
@@ -72,10 +72,10 @@  discard block
 block discarded – undo
72 72
 	/**
73 73
 	 * @param bool $routing
74 74
 	 */
75
-	public function __construct( $routing = true ) {
75
+	public function __construct($routing = true) {
76 76
 		//make sure messages autoloader is running
77 77
 		EED_Messages::set_autoloaders();
78
-		parent::__construct( $routing );
78
+		parent::__construct($routing);
79 79
 	}
80 80
 
81 81
 
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
 
90 90
 		$this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array();
91 91
 
92
-		$this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : null;
92
+		$this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : null;
93 93
 		$this->_load_message_resource_manager();
94 94
 	}
95 95
 
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
 	 * @throws EE_Error
104 104
 	*/
105 105
 	protected function _load_message_resource_manager() {
106
-		$this->_message_resource_manager = EE_Registry::instance()->load_lib( 'Message_Resource_Manager' );
106
+		$this->_message_resource_manager = EE_Registry::instance()->load_lib('Message_Resource_Manager');
107 107
 	}
108 108
 
109 109
 
@@ -116,13 +116,13 @@  discard block
 block discarded – undo
116 116
 	 */
117 117
 	public function get_messengers_for_list_table() {
118 118
 		$m_values = array();
119
-		$active_messengers = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_messenger' ) );
119
+		$active_messengers = EEM_Message::instance()->get_all(array('group_by' => 'MSG_messenger'));
120 120
 		//setup messengers for selects
121 121
 		$i = 1;
122
-		foreach ( $active_messengers as $active_messenger ) {
123
-			if ( $active_messenger instanceof EE_Message ) {
124
-				$m_values[ $i ]['id'] = $active_messenger->messenger();
125
-				$m_values[ $i ]['text'] = ucwords( $active_messenger->messenger_label() );
122
+		foreach ($active_messengers as $active_messenger) {
123
+			if ($active_messenger instanceof EE_Message) {
124
+				$m_values[$i]['id'] = $active_messenger->messenger();
125
+				$m_values[$i]['text'] = ucwords($active_messenger->messenger_label());
126 126
 				$i++;
127 127
 			}
128 128
 		}
@@ -139,12 +139,12 @@  discard block
 block discarded – undo
139 139
 	 */
140 140
 	public function get_message_types_for_list_table() {
141 141
 		$mt_values = array();
142
-		$active_messages = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_message_type' ) );
142
+		$active_messages = EEM_Message::instance()->get_all(array('group_by' => 'MSG_message_type'));
143 143
 		$i = 1;
144
-		foreach ( $active_messages as $active_message ) {
145
-			if ( $active_message instanceof EE_Message ) {
146
-				$mt_values[ $i ]['id'] = $active_message->message_type();
147
-				$mt_values[ $i ]['text'] = ucwords( $active_message->message_type_label() );
144
+		foreach ($active_messages as $active_message) {
145
+			if ($active_message instanceof EE_Message) {
146
+				$mt_values[$i]['id'] = $active_message->message_type();
147
+				$mt_values[$i]['text'] = ucwords($active_message->message_type_label());
148 148
 				$i++;
149 149
 			}
150 150
 		}
@@ -161,14 +161,14 @@  discard block
 block discarded – undo
161 161
 	 */
162 162
 	public function get_contexts_for_message_types_for_list_table() {
163 163
 		$contexts = array();
164
-		$active_message_contexts = EEM_Message::instance()->get_all( array( 'group_by' => 'MSG_context' ) );
165
-		foreach ( $active_message_contexts as $active_message ) {
166
-			if ( $active_message instanceof EE_Message ) {
164
+		$active_message_contexts = EEM_Message::instance()->get_all(array('group_by' => 'MSG_context'));
165
+		foreach ($active_message_contexts as $active_message) {
166
+			if ($active_message instanceof EE_Message) {
167 167
 				$message_type = $active_message->message_type_object();
168
-				if ( $message_type instanceof EE_message_type ) {
168
+				if ($message_type instanceof EE_message_type) {
169 169
 					$message_type_contexts = $message_type->get_contexts();
170
-					foreach ( $message_type_contexts as $context => $context_details ) {
171
-						$contexts[ $context ] = $context_details['label'];
170
+					foreach ($message_type_contexts as $context => $context_details) {
171
+						$contexts[$context] = $context_details['label'];
172 172
 					}
173 173
 				}
174 174
 			}
@@ -179,11 +179,11 @@  discard block
 block discarded – undo
179 179
 
180 180
 
181 181
 	protected function _ajax_hooks() {
182
-		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) );
183
-		add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') );
184
-		add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') );
185
-		add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) );
186
-		add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) );
182
+		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle'));
183
+		add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle'));
184
+		add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings'));
185
+		add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form'));
186
+		add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack'));
187 187
 	}
188 188
 
189 189
 
@@ -215,13 +215,13 @@  discard block
 block discarded – undo
215 215
 	*		@return void
216 216
 	*/
217 217
 	protected function _set_page_routes() {
218
-		$grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] )
218
+		$grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID'])
219 219
 			? $this->_req_data['GRP_ID']
220 220
 			: 0;
221
-		$grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] )
221
+		$grp_id = empty($grp_id) && ! empty($this->_req_data['id'])
222 222
 			? $this->_req_data['id']
223 223
 			: $grp_id;
224
-		$msg_id = ! empty( $this->_req_data['MSG_ID'] ) && ! is_array( $this->_req_data['MSG_ID'] )
224
+		$msg_id = ! empty($this->_req_data['MSG_ID']) && ! is_array($this->_req_data['MSG_ID'])
225 225
 			? $this->_req_data['MSG_ID']
226 226
 			: 0;
227 227
 
@@ -263,35 +263,35 @@  discard block
 block discarded – undo
263 263
 			'insert_message_template' => array(
264 264
 				'func' => '_insert_or_update_message_template',
265 265
 				'capability' => 'ee_edit_messages',
266
-				'args' => array( 'new_template' => true ),
266
+				'args' => array('new_template' => true),
267 267
 				'noheader' => true
268 268
 			 ),
269 269
 			'update_message_template' => array(
270 270
 				'func' => '_insert_or_update_message_template',
271 271
 				'capability' => 'ee_edit_message',
272 272
 				'obj_id' => $grp_id,
273
-				'args' => array( 'new_template' => false ),
273
+				'args' => array('new_template' => false),
274 274
 				'noheader' => true
275 275
 			),
276 276
 			'trash_message_template' => array(
277 277
 				'func' => '_trash_or_restore_message_template',
278 278
 				'capability' => 'ee_delete_message',
279 279
 				'obj_id' => $grp_id,
280
-				'args' => array( 'trash' => true, 'all' => true ),
280
+				'args' => array('trash' => true, 'all' => true),
281 281
 				'noheader' => true
282 282
 			),
283 283
 			'trash_message_template_context' => array(
284 284
 				'func' => '_trash_or_restore_message_template',
285 285
 				'capability' => 'ee_delete_message',
286 286
 				'obj_id' => $grp_id,
287
-				'args' => array( 'trash' => true ),
287
+				'args' => array('trash' => true),
288 288
 				'noheader' => true
289 289
 			),
290 290
 			'restore_message_template' => array(
291 291
 				'func' => '_trash_or_restore_message_template',
292 292
 				'capability' => 'ee_delete_message',
293 293
 				'obj_id' => $grp_id,
294
-				'args' => array( 'trash' => false, 'all' => true ),
294
+				'args' => array('trash' => false, 'all' => true),
295 295
 				'noheader' => true
296 296
 			),
297 297
 			'restore_message_template_context' => array(
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 						'filename' => 'messages_overview_other',
411 411
 					),
412 412
 				),
413
-				'help_tour' => array( 'Messages_Overview_Help_Tour' ),
413
+				'help_tour' => array('Messages_Overview_Help_Tour'),
414 414
 				'require_nonce' => false
415 415
 			),
416 416
 			'custom_mtps' => array(
@@ -445,7 +445,7 @@  discard block
 block discarded – undo
445 445
 				),
446 446
 				'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'),
447 447
 				'has_metaboxes' => true,
448
-				'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ),
448
+				'help_tour' => array('Message_Templates_Edit_Help_Tour'),
449 449
 				'help_tabs' => array(
450 450
 					'edit_message_template' => array(
451 451
 						'title' => __('Message Template Editor', 'event_espresso'),
@@ -501,7 +501,7 @@  discard block
 block discarded – undo
501 501
 						'filename' => 'messages_settings_messengers'
502 502
 					),
503 503
 				),
504
-				'help_tour' => array( 'Messages_Settings_Help_Tour' ),
504
+				'help_tour' => array('Messages_Settings_Help_Tour'),
505 505
 				'require_nonce' => false
506 506
 			)
507 507
 		);
@@ -534,7 +534,7 @@  discard block
 block discarded – undo
534 534
 
535 535
 
536 536
 	protected function _add_screen_options_default() {
537
-		$this->_admin_page_title = __( 'Message Activity', 'event_espresso' );
537
+		$this->_admin_page_title = __('Message Activity', 'event_espresso');
538 538
 		$this->_per_page_screen_option();
539 539
 	}
540 540
 
@@ -556,37 +556,37 @@  discard block
 block discarded – undo
556 556
 
557 557
 
558 558
 	public function messages_help_tab() {
559
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php' );
559
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php');
560 560
 	}
561 561
 
562 562
 
563 563
 	public function messengers_help_tab() {
564
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php' );
564
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php');
565 565
 	}
566 566
 
567 567
 
568 568
 	public function message_types_help_tab() {
569
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php' );
569
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php');
570 570
 	}
571 571
 
572 572
 
573 573
 	public function messages_overview_help_tab() {
574
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php' );
574
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php');
575 575
 	}
576 576
 
577 577
 
578 578
 	public function message_templates_help_tab() {
579
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php' );
579
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php');
580 580
 	}
581 581
 
582 582
 
583 583
 	public function edit_message_template_help_tab() {
584
-		$args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />';
585
-		$args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />';
586
-		$args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />';
587
-		$args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />';
588
-		$args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />';
589
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php', $args);
584
+		$args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />';
585
+		$args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />';
586
+		$args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />';
587
+		$args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />';
588
+		$args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />';
589
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php', $args);
590 590
 	}
591 591
 
592 592
 
@@ -594,22 +594,22 @@  discard block
 block discarded – undo
594 594
 	public function message_template_shortcodes_help_tab() {
595 595
 		$this->_set_shortcodes();
596 596
 		$args['shortcodes'] = $this->_shortcodes;
597
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php', $args );
597
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php', $args);
598 598
 	}
599 599
 
600 600
 
601 601
 
602 602
 	public function preview_message_help_tab() {
603
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php' );
603
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php');
604 604
 	}
605 605
 
606 606
 
607 607
 	public function settings_help_tab() {
608
-		$args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
609
-		$args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
608
+		$args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />';
609
+		$args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />';
610 610
 		$args['img3'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox" checked="checked"><label for="ee-on-off-toggle-on"></label>';
611 611
 		$args['img4'] = '<div class="switch"><input id="ee-on-off-toggle-on" class="ee-on-off-toggle ee-toggle-round-flat" type="checkbox"><label for="ee-on-off-toggle-on"></label>';
612
-		EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php', $args);
612
+		EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php', $args);
613 613
 	}
614 614
 
615 615
 
@@ -617,31 +617,31 @@  discard block
 block discarded – undo
617 617
 
618 618
 
619 619
 	public function load_scripts_styles() {
620
-		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION );
620
+		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
621 621
 		wp_enqueue_style('espresso_ee_msg');
622 622
 
623
-		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL . 'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true );
624
-		wp_register_script( 'ee-msg-list-table-js', EE_MSG_ASSETS_URL. 'ee_message_admin_list_table.js', array( 'ee-dialog' ), EVENT_ESPRESSO_VERSION );
623
+		wp_register_script('ee-messages-settings', EE_MSG_ASSETS_URL.'ee-messages-settings.js', array('jquery-ui-droppable', 'ee-serialize-full-array'), EVENT_ESPRESSO_VERSION, true);
624
+		wp_register_script('ee-msg-list-table-js', EE_MSG_ASSETS_URL.'ee_message_admin_list_table.js', array('ee-dialog'), EVENT_ESPRESSO_VERSION);
625 625
 	}
626 626
 
627 627
 
628 628
 
629 629
 	public function load_scripts_styles_default() {
630
-		wp_enqueue_script( 'ee-msg-list-table-js' );
630
+		wp_enqueue_script('ee-msg-list-table-js');
631 631
 	}
632 632
 
633 633
 
634 634
 
635 635
 
636 636
 
637
-	public function wp_editor_css( $mce_css ) {
637
+	public function wp_editor_css($mce_css) {
638 638
 		//if we're on the edit_message_template route
639
-		if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger  ) {
639
+		if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
640 640
 			$message_type_name = $this->_active_message_type_name;
641 641
 
642 642
 			//we're going to REPLACE the existing mce css
643 643
 			//we need to get the css file location from the active messenger
644
-			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation );
644
+			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'wpeditor', $this->_variation);
645 645
 		}
646 646
 
647 647
 		return $mce_css;
@@ -659,15 +659,15 @@  discard block
 block discarded – undo
659 659
 			$this->_message_template_group->messenger_obj()->label['singular'],
660 660
 			$this->_message_template_group->message_type_obj()->label['singular']
661 661
 		);
662
-		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso' );
662
+		EE_Registry::$i18n_js_strings['confirm_switch_template_pack'] = __('Switching the template pack for a messages template will reset the content for the template so the new layout is loaded.  Any custom content in the existing template will be lost. Are you sure you wish to do this?', 'event_espresso');
663 663
 
664
-		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION );
664
+		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION);
665 665
 
666 666
 		wp_enqueue_script('ee_admin_js');
667 667
 		wp_enqueue_script('ee_msgs_edit_js');
668 668
 
669 669
 		//add in special css for tiny_mce
670
-		add_filter( 'mce_css', array( $this, 'wp_editor_css' ) );
670
+		add_filter('mce_css', array($this, 'wp_editor_css'));
671 671
 	}
672 672
 
673 673
 
@@ -676,22 +676,22 @@  discard block
 block discarded – undo
676 676
 
677 677
 		$this->_set_message_template_group();
678 678
 
679
-		if ( isset( $this->_req_data['messenger'] ) ) {
680
-			$this->_active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
679
+		if (isset($this->_req_data['messenger'])) {
680
+			$this->_active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
681 681
 		}
682 682
 
683
-		$message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : '';
683
+		$message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : '';
684 684
 
685 685
 
686
-		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, true, 'preview', $this->_variation ) );
686
+		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, true, 'preview', $this->_variation));
687 687
 	}
688 688
 
689 689
 
690 690
 
691 691
 	public function load_scripts_styles_settings() {
692
-		wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION );
693
-		wp_enqueue_style( 'ee-text-links' );
694
-		wp_enqueue_style( 'ee-message-settings' );
692
+		wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION);
693
+		wp_enqueue_style('ee-text-links');
694
+		wp_enqueue_style('ee-message-settings');
695 695
 
696 696
 		wp_enqueue_script('ee-messages-settings');
697 697
 	}
@@ -721,40 +721,40 @@  discard block
 block discarded – undo
721 721
 	 * set views array for message queue list table
722 722
 	 */
723 723
 	public function _set_list_table_views_default() {
724
-		EE_Registry::instance()->load_helper( 'Template' );
724
+		EE_Registry::instance()->load_helper('Template');
725 725
 
726
-		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can( 'ee_send_message', 'message_list_table_bulk_actions' )
726
+		$common_bulk_actions = EE_Registry::instance()->CAP->current_user_can('ee_send_message', 'message_list_table_bulk_actions')
727 727
 			? array(
728
-				'generate_now' => __( 'Generate Now', 'event_espresso' ),
729
-		        'generate_and_send_now' => __( 'Generate and Send Now', 'event_espresso' ),
730
-		        'queue_for_resending' => __( 'Queue for Resending', 'event_espresso' ),
731
-		        'send_now' => __( 'Send Now', 'event_espresso' )
728
+				'generate_now' => __('Generate Now', 'event_espresso'),
729
+		        'generate_and_send_now' => __('Generate and Send Now', 'event_espresso'),
730
+		        'queue_for_resending' => __('Queue for Resending', 'event_espresso'),
731
+		        'send_now' => __('Send Now', 'event_espresso')
732 732
 				)
733 733
 			: array();
734 734
 
735
-		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can( 'ee_delete_messages', 'message_list_table_bulk_actions' )
736
-			? array( 'delete_ee_messages' => __( 'Delete Messages', 'event_espresso' ) )
735
+		$delete_bulk_action = EE_Registry::instance()->CAP->current_user_can('ee_delete_messages', 'message_list_table_bulk_actions')
736
+			? array('delete_ee_messages' => __('Delete Messages', 'event_espresso'))
737 737
 			: array();
738 738
 
739 739
 
740 740
 		$this->_views = array(
741 741
 			 'all' => array(
742 742
 			    'slug' => 'all',
743
-			    'label' => __( 'All', 'event_espresso' ),
743
+			    'label' => __('All', 'event_espresso'),
744 744
 			    'count' => 0,
745
-			    'bulk_action' => array_merge( $common_bulk_actions, $delete_bulk_action )
745
+			    'bulk_action' => array_merge($common_bulk_actions, $delete_bulk_action)
746 746
 			 )
747 747
 		);
748 748
 
749 749
 
750
-		foreach ( EEM_Message::instance()->all_statuses() as $status ) {
751
-			if ( $status === EEM_Message::status_debug_only && ! EEM_Message::debug() ) {
750
+		foreach (EEM_Message::instance()->all_statuses() as $status) {
751
+			if ($status === EEM_Message::status_debug_only && ! EEM_Message::debug()) {
752 752
 				continue;
753 753
 			}
754 754
 			$status_bulk_actions = $common_bulk_actions;
755 755
 			//unset bulk actions not applying to status
756
-			if ( ! empty( $status_bulk_actions ) ) {
757
-				switch ( $status ) {
756
+			if ( ! empty($status_bulk_actions)) {
757
+				switch ($status) {
758 758
 					case EEM_Message::status_idle :
759 759
 					case EEM_Message::status_resend :
760 760
 						$status_bulk_actions['send_now'] = $common_bulk_actions['send_now'];
@@ -766,21 +766,21 @@  discard block
 block discarded – undo
766 766
 						break;
767 767
 
768 768
 					case EEM_Message::status_incomplete :
769
-						unset( $status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now'] );
769
+						unset($status_bulk_actions['queue_for_resending'], $status_bulk_actions['send_now']);
770 770
 						break;
771 771
 
772 772
 					case EEM_Message::status_retry :
773 773
 					case EEM_Message::status_sent :
774
-						unset( $status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now'] );
774
+						unset($status_bulk_actions['generate_now'], $status_bulk_actions['generate_and_send_now']);
775 775
 						break;
776 776
 				}
777 777
 			}
778 778
 
779
-			$this->_views[ strtolower( $status ) ] = array(
780
-				'slug' => strtolower( $status ),
781
-				'label' => EEH_Template::pretty_status( $status, false, 'sentence' ),
779
+			$this->_views[strtolower($status)] = array(
780
+				'slug' => strtolower($status),
781
+				'label' => EEH_Template::pretty_status($status, false, 'sentence'),
782 782
 				'count' => 0,
783
-				'bulk_action' => array_merge( $status_bulk_actions, $delete_bulk_action )
783
+				'bulk_action' => array_merge($status_bulk_actions, $delete_bulk_action)
784 784
 			);
785 785
 		}
786 786
 	}
@@ -799,8 +799,8 @@  discard block
 block discarded – undo
799 799
 	protected function _message_queue_list_table() {
800 800
 		$this->_search_btn_label = __('Message Activity', 'event_espresso');
801 801
 		$this->_template_args['per_column'] = 6;
802
-		$this->_template_args['after_list_table'] = $this->_display_legend( $this->_message_legend_items() );
803
-		$this->_template_args['before_list_table'] = '<h3>' . EEM_Message::instance()->get_pretty_label_for_results() . '</h3>';
802
+		$this->_template_args['after_list_table'] = $this->_display_legend($this->_message_legend_items());
803
+		$this->_template_args['before_list_table'] = '<h3>'.EEM_Message::instance()->get_pretty_label_for_results().'</h3>';
804 804
 		$this->display_admin_list_table_page_with_no_sidebar();
805 805
 	}
806 806
 
@@ -813,8 +813,8 @@  discard block
 block discarded – undo
813 813
 		$action_css_classes = EEH_MSG_Template::get_message_action_icons();
814 814
 		$action_items = array();
815 815
 
816
-		foreach( $action_css_classes as $action_item => $action_details ) {
817
-			if ( $action_item === 'see_notifications_for' ) {
816
+		foreach ($action_css_classes as $action_item => $action_details) {
817
+			if ($action_item === 'see_notifications_for') {
818 818
 				continue;
819 819
 			}
820 820
 			$action_items[$action_item] = array(
@@ -826,37 +826,37 @@  discard block
 block discarded – undo
826 826
 		/** @type array $status_items status legend setup*/
827 827
 		$status_items = array(
828 828
 			'sent_status' => array(
829
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_sent,
830
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_sent, false, 'sentence' )
829
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_sent,
830
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_sent, false, 'sentence')
831 831
 				),
832 832
 			'idle_status' => array(
833
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_idle,
834
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_idle, false, 'sentence' )
833
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_idle,
834
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_idle, false, 'sentence')
835 835
 				),
836 836
 			'failed_status' => array(
837
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_failed,
838
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_failed, false, 'sentence' )
837
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_failed,
838
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_failed, false, 'sentence')
839 839
 			),
840 840
 			'resend_status' => array(
841
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_resend,
842
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_resend, false, 'sentence' )
841
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_resend,
842
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_resend, false, 'sentence')
843 843
 				),
844 844
 			'incomplete_status' => array(
845
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_incomplete,
846
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_incomplete, false, 'sentence' )
845
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_incomplete,
846
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_incomplete, false, 'sentence')
847 847
 				),
848 848
 			'retry_status' => array(
849
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_retry,
850
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_retry, false, 'sentence' )
849
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_retry,
850
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_retry, false, 'sentence')
851 851
 				)
852 852
 		);
853
-		if ( EEM_Message::debug() ) {
853
+		if (EEM_Message::debug()) {
854 854
 			$status_items['debug_only_status'] = array(
855
-				'class' => 'ee-status-legend ee-status-legend-' . EEM_Message::status_debug_only,
856
-				'desc' => EEH_Template::pretty_status( EEM_Message::status_debug_only, false, 'sentence' )
855
+				'class' => 'ee-status-legend ee-status-legend-'.EEM_Message::status_debug_only,
856
+				'desc' => EEH_Template::pretty_status(EEM_Message::status_debug_only, false, 'sentence')
857 857
 			);
858 858
 		}
859
-		return array_merge( $action_items, $status_items );
859
+		return array_merge($action_items, $status_items);
860 860
 	}
861 861
 
862 862
 
@@ -866,9 +866,9 @@  discard block
 block discarded – undo
866 866
 
867 867
 	protected function _custom_mtps_preview() {
868 868
 		$this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso');
869
-		$this->_template_args['preview_img'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/custom_mtps_preview.png" alt="' . esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso' ) . '" />';
869
+		$this->_template_args['preview_img'] = '<img src="'.EE_MSG_ASSETS_URL.'images/custom_mtps_preview.png" alt="'.esc_attr__('Preview Custom Message Templates screenshot', 'event_espresso').'" />';
870 870
 		$this->_template_args['preview_text'] = '<strong>'.__('Custom Message Templates is a feature that is only available in the caffeinated version of Event Espresso.  With the Custom Message Templates feature, you are able to create custom templates and set them per event.', 'event_espresso').'</strong>';
871
-		$this->display_admin_caf_preview_page( 'custom_message_types', false );
871
+		$this->display_admin_caf_preview_page('custom_message_types', false);
872 872
 	}
873 873
 
874 874
 
@@ -892,31 +892,31 @@  discard block
 block discarded – undo
892 892
 	 *
893 893
 	 * @return array
894 894
 	 */
895
-	public function get_message_templates( $perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true ) {
895
+	public function get_message_templates($perpage = 10, $type = 'in_use', $count = false, $all = false, $global = true) {
896 896
 
897 897
 		$MTP = EEM_Message_Template_Group::instance();
898 898
 
899 899
 		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby'];
900 900
 		$orderby = $this->_req_data['orderby'];
901 901
 
902
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC';
902
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
903 903
 
904
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
905
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage;
904
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
905
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage;
906 906
 
907
-		$offset = ($current_page-1)*$per_page;
908
-		$limit = $all ? null : array( $offset, $per_page );
907
+		$offset = ($current_page - 1) * $per_page;
908
+		$limit = $all ? null : array($offset, $per_page);
909 909
 
910 910
 
911 911
 		//options will match what is in the _views array property
912
-		switch( $type ) {
912
+		switch ($type) {
913 913
 
914 914
 			case 'in_use':
915
-				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true );
915
+				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, true);
916 916
 				break;
917 917
 
918 918
 			default:
919
-				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global );
919
+				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global);
920 920
 
921 921
 		}
922 922
 
@@ -935,8 +935,8 @@  discard block
 block discarded – undo
935 935
 		$installed_message_types = $this->_message_resource_manager->installed_message_types();
936 936
 		$installed = array();
937 937
 
938
-		foreach ( $installed_message_types as $message_type ) {
939
-			$installed[ $message_type->name ] = $message_type;
938
+		foreach ($installed_message_types as $message_type) {
939
+			$installed[$message_type->name] = $message_type;
940 940
 		}
941 941
 
942 942
 		return $installed;
@@ -955,24 +955,24 @@  discard block
 block discarded – undo
955 955
 	 *
956 956
 	 * @throws EE_error
957 957
 	 */
958
-	protected function _add_message_template(  $message_type = '', $messenger='', $GRP_ID = '' ) {
958
+	protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') {
959 959
 		//set values override any request data
960
-		$message_type = !empty( $message_type ) ? $message_type : '';
961
-		$message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type;
960
+		$message_type = ! empty($message_type) ? $message_type : '';
961
+		$message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type;
962 962
 
963
-		$messenger = !empty( $messenger ) ? $messenger : '';
964
-		$messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger;
963
+		$messenger = ! empty($messenger) ? $messenger : '';
964
+		$messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger;
965 965
 
966
-		$GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : '';
967
-		$GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID;
966
+		$GRP_ID = ! empty($GRP_ID) ? $GRP_ID : '';
967
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID;
968 968
 
969 969
 		//we need messenger and message type.  They should be coming from the event editor. If not here then return error
970
-		if ( empty( $message_type ) || empty( $messenger )  )
971
-			{throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));}
970
+		if (empty($message_type) || empty($messenger))
971
+			{throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso')); }
972 972
 
973 973
 		//we need the GRP_ID for the template being used as the base for the new template
974
-		if ( empty( $GRP_ID ) )
975
-			{throw new EE_Error( __('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso' ) );}
974
+		if (empty($GRP_ID))
975
+			{throw new EE_Error(__('In order to create a custom message template the GRP_ID of the template being used as a base is needed', 'event_espresso')); }
976 976
 
977 977
 		//let's just make sure the template gets generated!
978 978
 
@@ -993,8 +993,8 @@  discard block
 block discarded – undo
993 993
 	 * @param int      $GRP_ID         GRP_ID for the related message template group this new template will be based
994 994
 	 *                                 off of.
995 995
 	 */
996
-	public function add_message_template( $message_type, $messenger, $GRP_ID ) {
997
-		$this->_add_message_template( $message_type, $messenger, $GRP_ID );
996
+	public function add_message_template($message_type, $messenger, $GRP_ID) {
997
+		$this->_add_message_template($message_type, $messenger, $GRP_ID);
998 998
 	}
999 999
 
1000 1000
 
@@ -1005,14 +1005,14 @@  discard block
 block discarded – undo
1005 1005
 	 * @return void
1006 1006
 	 */
1007 1007
 	protected function _edit_message_template() {
1008
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '');
1008
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1009 1009
 		$template_fields = '';
1010 1010
 		$sidebar_fields = '';
1011 1011
 		//we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates.
1012
-		add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 );
1012
+		add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2);
1013 1013
 
1014
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] )
1015
-			? absint( $this->_req_data['id'] )
1014
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id'])
1015
+			? absint($this->_req_data['id'])
1016 1016
 			: false;
1017 1017
 
1018 1018
 		$this->_set_shortcodes(); //this also sets the _message_template property.
@@ -1020,20 +1020,20 @@  discard block
 block discarded – undo
1020 1020
 		$c_label = $message_template_group->context_label();
1021 1021
 		$c_config = $message_template_group->contexts_config();
1022 1022
 
1023
-		reset( $c_config );
1024
-		$context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] )
1023
+		reset($c_config);
1024
+		$context = isset($this->_req_data['context']) && ! empty($this->_req_data['context'])
1025 1025
 			? strtolower($this->_req_data['context'])
1026 1026
 			: key($c_config);
1027 1027
 
1028 1028
 
1029
-		if ( empty($GRP_ID) ) {
1029
+		if (empty($GRP_ID)) {
1030 1030
 			$action = 'insert_message_template';
1031 1031
 			//$button_both = false;
1032 1032
 			//$button_text = array( __( 'Save','event_espresso') );
1033 1033
 			//$button_actions = array('something_different');
1034 1034
 			//$referrer = false;
1035 1035
 			$edit_message_template_form_url = add_query_arg(
1036
-				array( 'action' => $action, 'noheader' => true ),
1036
+				array('action' => $action, 'noheader' => true),
1037 1037
 				EE_MSG_ADMIN_URL
1038 1038
 			);
1039 1039
 		} else {
@@ -1043,7 +1043,7 @@  discard block
 block discarded – undo
1043 1043
 			//$button_actions = array();
1044 1044
 			//$referrer = $this->_admin_base_url;
1045 1045
 			$edit_message_template_form_url = add_query_arg(
1046
-				array( 'action' => $action, 'noheader' => true ),
1046
+				array('action' => $action, 'noheader' => true),
1047 1047
 				EE_MSG_ADMIN_URL
1048 1048
 			);
1049 1049
 		}
@@ -1057,14 +1057,14 @@  discard block
 block discarded – undo
1057 1057
 
1058 1058
 		//Do we have any validation errors?
1059 1059
 		$validators = $this->_get_transient();
1060
-		$v_fields = !empty($validators) ? array_keys($validators) : array();
1060
+		$v_fields = ! empty($validators) ? array_keys($validators) : array();
1061 1061
 
1062 1062
 
1063 1063
 		//we need to assemble the title from Various details
1064 1064
 		$context_label = sprintf(
1065 1065
 			__('(%s %s)', 'event_espresso'),
1066 1066
 			$c_config[$context]['label'],
1067
-			ucwords($c_label['label'] )
1067
+			ucwords($c_label['label'])
1068 1068
 		);
1069 1069
 
1070 1070
 		$title = sprintf(
@@ -1085,7 +1085,7 @@  discard block
 block discarded – undo
1085 1085
 			$message_template_group->message_type()
1086 1086
 		);
1087 1087
 
1088
-		if ( !$template_field_structure ) {
1088
+		if ( ! $template_field_structure) {
1089 1089
 			$template_field_structure = false;
1090 1090
 			$template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso');
1091 1091
 		}
@@ -1095,51 +1095,51 @@  discard block
 block discarded – undo
1095 1095
 
1096 1096
 
1097 1097
 		//if we have the extra key.. then we need to remove the content index from the template_field_structure as it will get handled in the "extra" array.
1098
-		if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) {
1099
-			foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) {
1100
-				unset( $template_field_structure[$context][$reference_field] );
1098
+		if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) {
1099
+			foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) {
1100
+				unset($template_field_structure[$context][$reference_field]);
1101 1101
 			}
1102 1102
 		}
1103 1103
 
1104 1104
 		//let's loop through the template_field_structure and actually assemble the input fields!
1105
-		if ( !empty($template_field_structure) ) {
1106
-			foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) {
1105
+		if ( ! empty($template_field_structure)) {
1106
+			foreach ($template_field_structure[$context] as $template_field => $field_setup_array) {
1107 1107
 				//if this is an 'extra' template field then we need to remove any existing fields that are keyed up in the extra array and reset them.
1108
-				if ( $template_field == 'extra' ) {
1108
+				if ($template_field == 'extra') {
1109 1109
 					$this->_template_args['is_extra_fields'] = true;
1110
-					foreach ( $field_setup_array as $reference_field => $new_fields_array ) {
1111
-						$message_template = $message_templates[ $context ][ $reference_field ];
1110
+					foreach ($field_setup_array as $reference_field => $new_fields_array) {
1111
+						$message_template = $message_templates[$context][$reference_field];
1112 1112
 						$content = $message_template instanceof EE_Message_Template
1113
-							? $message_template->get( 'MTP_content' )
1113
+							? $message_template->get('MTP_content')
1114 1114
 							: '';
1115
-						foreach ( $new_fields_array as $extra_field =>  $extra_array ) {
1115
+						foreach ($new_fields_array as $extra_field =>  $extra_array) {
1116 1116
 							//let's verify if we need this extra field via the shortcodes parameter.
1117 1117
 							$continue = false;
1118
-							if ( isset( $extra_array['shortcodes_required'] ) ) {
1119
-								foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) {
1120
-									if ( !array_key_exists( $shortcode, $this->_shortcodes ) )
1121
-										{$continue = true;}
1118
+							if (isset($extra_array['shortcodes_required'])) {
1119
+								foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
1120
+									if ( ! array_key_exists($shortcode, $this->_shortcodes))
1121
+										{$continue = true; }
1122 1122
 								}
1123
-								if ( $continue ) {continue;}
1123
+								if ($continue) {continue; }
1124 1124
 							}
1125 1125
 
1126
-							$field_id = $reference_field . '-' . $extra_field . '-content';
1126
+							$field_id = $reference_field.'-'.$extra_field.'-content';
1127 1127
 							$template_form_fields[$field_id] = $extra_array;
1128
-							$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']';
1129
-							$css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : '';
1128
+							$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']';
1129
+							$css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : '';
1130 1130
 
1131
-							$template_form_fields[$field_id]['css_class'] = ! empty( $v_fields )
1131
+							$template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1132 1132
 																			&& in_array($extra_field, $v_fields)
1133 1133
 																			&&
1134 1134
 																			(
1135
-								                                                is_array($validators[$extra_field] )
1136
-																				&& isset( $validators[$extra_field]['msg'] )
1135
+								                                                is_array($validators[$extra_field])
1136
+																				&& isset($validators[$extra_field]['msg'])
1137 1137
 							                                                )
1138
-								? 'validate-error ' . $css_class
1138
+								? 'validate-error '.$css_class
1139 1139
 								: $css_class;
1140 1140
 
1141
-							$template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field])
1142
-								? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") )
1141
+							$template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field])
1142
+								? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8"))
1143 1143
 								: '';
1144 1144
 
1145 1145
 							//do we have a validation error?  if we do then let's use that value instead
@@ -1155,32 +1155,32 @@  discard block
 block discarded – undo
1155 1155
 								$field_id
1156 1156
 							);
1157 1157
 
1158
-							if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) {
1158
+							if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') {
1159 1159
 								//we want to decode the entities
1160 1160
 								$template_form_fields[$field_id]['value'] = stripslashes(
1161
-									html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")
1161
+									html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8")
1162 1162
 								);
1163 1163
 
1164 1164
 							}/**/
1165 1165
 						}
1166
-						$templatefield_MTP_id = $reference_field . '-MTP_ID';
1167
-						$templatefield_templatename_id = $reference_field . '-name';
1166
+						$templatefield_MTP_id = $reference_field.'-MTP_ID';
1167
+						$templatefield_templatename_id = $reference_field.'-name';
1168 1168
 
1169 1169
 						$template_form_fields[$templatefield_MTP_id] = array(
1170
-							'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
1170
+							'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]',
1171 1171
 							'label' => null,
1172 1172
 							'input' => 'hidden',
1173 1173
 							'type' => 'int',
1174 1174
 							'required' => false,
1175 1175
 							'validation' => false,
1176
-							'value' => !empty($message_templates) ? $message_template->ID() : '',
1176
+							'value' => ! empty($message_templates) ? $message_template->ID() : '',
1177 1177
 							'css_class' => '',
1178 1178
 							'format' => '%d',
1179 1179
 							'db-col' => 'MTP_ID'
1180 1180
 						);
1181 1181
 
1182 1182
 						$template_form_fields[$templatefield_templatename_id] = array(
1183
-							'name' => 'MTP_template_fields[' . $reference_field . '][name]',
1183
+							'name' => 'MTP_template_fields['.$reference_field.'][name]',
1184 1184
 							'label' => null,
1185 1185
 							'input' => 'hidden',
1186 1186
 							'type' => 'string',
@@ -1194,14 +1194,14 @@  discard block
 block discarded – undo
1194 1194
 					}
1195 1195
 					continue; //skip the next stuff, we got the necessary fields here for this dataset.
1196 1196
 				} else {
1197
-					$field_id = $template_field . '-content';
1197
+					$field_id = $template_field.'-content';
1198 1198
 					$template_form_fields[$field_id] = $field_setup_array;
1199
-					$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]';
1200
-					$message_template = isset( $message_templates[ $context ][ $template_field ] )
1201
-						? $message_templates[ $context ][ $template_field ]
1199
+					$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]';
1200
+					$message_template = isset($message_templates[$context][$template_field])
1201
+						? $message_templates[$context][$template_field]
1202 1202
 						: null;
1203
-					$template_form_fields[$field_id]['value'] = ! empty( $message_templates )
1204
-																&& is_array( $message_templates[$context] )
1203
+					$template_form_fields[$field_id]['value'] = ! empty($message_templates)
1204
+																&& is_array($message_templates[$context])
1205 1205
 																&& $message_template instanceof EE_Message_Template
1206 1206
 						? $message_template->get('MTP_content')
1207 1207
 						: '';
@@ -1214,10 +1214,10 @@  discard block
 block discarded – undo
1214 1214
 
1215 1215
 					$template_form_fields[$field_id]['db-col'] = 'MTP_content';
1216 1216
 					$css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : '';
1217
-					$template_form_fields[$field_id]['css_class'] =  ! empty( $v_fields )
1218
-																	 && in_array( $template_field, $v_fields )
1219
-																	 && isset( $validators[$template_field]['msg'] )
1220
-						? 'validate-error ' . $css_class
1217
+					$template_form_fields[$field_id]['css_class'] = ! empty($v_fields)
1218
+																	 && in_array($template_field, $v_fields)
1219
+																	 && isset($validators[$template_field]['msg'])
1220
+						? 'validate-error '.$css_class
1221 1221
 						: $css_class;
1222 1222
 
1223 1223
 					//shortcode selector
@@ -1228,12 +1228,12 @@  discard block
 block discarded – undo
1228 1228
 
1229 1229
 				//k took care of content field(s) now let's take care of others.
1230 1230
 
1231
-				$templatefield_MTP_id = $template_field . '-MTP_ID';
1232
-				$templatefield_field_templatename_id = $template_field . '-name';
1231
+				$templatefield_MTP_id = $template_field.'-MTP_ID';
1232
+				$templatefield_field_templatename_id = $template_field.'-name';
1233 1233
 
1234 1234
 				//foreach template field there are actually two form fields created
1235 1235
 				$template_form_fields[$templatefield_MTP_id] = array(
1236
-					'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
1236
+					'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]',
1237 1237
 					'label' => null,
1238 1238
 					'input' => 'hidden',
1239 1239
 					'type' => 'int',
@@ -1246,7 +1246,7 @@  discard block
 block discarded – undo
1246 1246
 				);
1247 1247
 
1248 1248
 				$template_form_fields[$templatefield_field_templatename_id] = array(
1249
-					'name' => 'MTP_template_fields[' . $template_field . '][name]',
1249
+					'name' => 'MTP_template_fields['.$template_field.'][name]',
1250 1250
 					'label' => null,
1251 1251
 					'input' => 'hidden',
1252 1252
 					'type' => 'string',
@@ -1390,13 +1390,13 @@  discard block
 block discarded – undo
1390 1390
 				'value' => $GRP_ID
1391 1391
 				);
1392 1392
 			$sidebar_form_fields['ee-msg-evt-nonce'] = array(
1393
-				'name' => $action . '_nonce',
1393
+				'name' => $action.'_nonce',
1394 1394
 				'input' => 'hidden',
1395 1395
 				'type' => 'string',
1396
-				'value' => wp_create_nonce( $action . '_nonce')
1396
+				'value' => wp_create_nonce($action.'_nonce')
1397 1397
 				);
1398 1398
 
1399
-			if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) {
1399
+			if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
1400 1400
 				$sidebar_form_fields['ee-msg-template-switch'] = array(
1401 1401
 					'name' => 'template_switch',
1402 1402
 					'input' => 'hidden',
@@ -1406,8 +1406,8 @@  discard block
 block discarded – undo
1406 1406
 			}
1407 1407
 
1408 1408
 
1409
-			$template_fields = $this->_generate_admin_form_fields( $template_form_fields );
1410
-			$sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields );
1409
+			$template_fields = $this->_generate_admin_form_fields($template_form_fields);
1410
+			$sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields);
1411 1411
 
1412 1412
 
1413 1413
 		} //end if ( !empty($template_field_structure) )
@@ -1419,7 +1419,7 @@  discard block
 block discarded – undo
1419 1419
 			 $GRP_ID,
1420 1420
 			 false,
1421 1421
 			 add_query_arg(
1422
-			    array( 'action' => 'global_mtps' ),
1422
+			    array('action' => 'global_mtps'),
1423 1423
 			    $this->_admin_base_url
1424 1424
 			 )
1425 1425
 		);
@@ -1435,7 +1435,7 @@  discard block
 block discarded – undo
1435 1435
 			),
1436 1436
 			$this->_admin_base_url
1437 1437
 		);
1438
-		$preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>';
1438
+		$preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>';
1439 1439
 
1440 1440
 
1441 1441
 		//setup context switcher
@@ -1463,17 +1463,17 @@  discard block
 block discarded – undo
1463 1463
 		$this->_template_args['after_admin_page_content'] = $this->_add_form_element_after();
1464 1464
 
1465 1465
 		$this->_template_path = $this->_template_args['GRP_ID']
1466
-			? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php'
1467
-			: EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1466
+			? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php'
1467
+			: EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php';
1468 1468
 
1469 1469
 		//send along EE_Message_Template_Group object for further template use.
1470 1470
 		$this->_template_args['MTP'] = $message_template_group;
1471 1471
 
1472
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, true );
1472
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, true);
1473 1473
 
1474 1474
 
1475 1475
 		//finally, let's set the admin_page title
1476
-		$this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title );
1476
+		$this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title);
1477 1477
 
1478 1478
 
1479 1479
 		//we need to take care of setting the shortcodes property for use elsewhere.
@@ -1486,7 +1486,7 @@  discard block
 block discarded – undo
1486 1486
 	}
1487 1487
 
1488 1488
 
1489
-	public function filter_tinymce_init( $mceInit, $editor_id ) {
1489
+	public function filter_tinymce_init($mceInit, $editor_id) {
1490 1490
 		return $mceInit;
1491 1491
 	}
1492 1492
 
@@ -1497,7 +1497,7 @@  discard block
 block discarded – undo
1497 1497
 	}
1498 1498
 
1499 1499
 	public function _add_form_element_before() {
1500
-		return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">';
1500
+		return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">';
1501 1501
 	}
1502 1502
 
1503 1503
 	public function _add_form_element_after() {
@@ -1514,25 +1514,25 @@  discard block
 block discarded – undo
1514 1514
 	 *
1515 1515
 	 */
1516 1516
 	public function switch_template_pack() {
1517
-		$GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1518
-		$template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : '';
1517
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1518
+		$template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : '';
1519 1519
 
1520 1520
 		//verify we have needed values.
1521
-		if ( empty( $GRP_ID ) || empty( $template_pack ) ) {
1521
+		if (empty($GRP_ID) || empty($template_pack)) {
1522 1522
 			$this->_template_args['error'] = true;
1523
-			EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__  );
1523
+			EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1524 1524
 		} else {
1525 1525
 			//get template, set the new template_pack and then reset to default
1526 1526
 			/** @type EE_Message_Template_Group $message_template_group */
1527
-			$message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1527
+			$message_template_group = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1528 1528
 
1529
-			$message_template_group->set_template_pack_name( $template_pack );
1529
+			$message_template_group->set_template_pack_name($template_pack);
1530 1530
 			$this->_req_data['msgr'] = $message_template_group->messenger();
1531 1531
 			$this->_req_data['mt'] = $message_template_group->message_type();
1532 1532
 
1533 1533
 			$query_args = $this->_reset_to_default_template();
1534 1534
 
1535
-			if ( empty( $query_args['id'] ) ) {
1535
+			if (empty($query_args['id'])) {
1536 1536
 				EE_Error::add_error(
1537 1537
 					__(
1538 1538
 						'Something went wrong with switching the template pack. Please try again or contact EE support',
@@ -1542,7 +1542,7 @@  discard block
 block discarded – undo
1542 1542
 				);
1543 1543
 				$this->_template_args['error'] = true;
1544 1544
 			} else {
1545
-				$template_label =$message_template_group->get_template_pack()->label;
1545
+				$template_label = $message_template_group->get_template_pack()->label;
1546 1546
 				$template_pack_labels = $message_template_group->messenger_obj()->get_supports_labels();
1547 1547
 				EE_Error::add_success(
1548 1548
 					sprintf(
@@ -1555,7 +1555,7 @@  discard block
 block discarded – undo
1555 1555
 					)
1556 1556
 				);
1557 1557
 				//generate the redirect url for js.
1558
-				$url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1558
+				$url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1559 1559
 				$this->_template_args['data']['redirect_url'] = $url;
1560 1560
 				$this->_template_args['success'] = true;
1561 1561
 			}
@@ -1577,9 +1577,9 @@  discard block
 block discarded – undo
1577 1577
 	protected function _reset_to_default_template() {
1578 1578
 
1579 1579
 		$templates = array();
1580
-		$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1580
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1581 1581
 		//we need to make sure we've got the info we need.
1582
-		if ( ! isset( $this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'] ) ) {
1582
+		if ( ! isset($this->_req_data['msgr'], $this->_req_data['mt'], $this->_req_data['GRP_ID'])) {
1583 1583
 			EE_Error::add_error(
1584 1584
 				__(
1585 1585
 					'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.',
@@ -1591,9 +1591,9 @@  discard block
 block discarded – undo
1591 1591
 
1592 1592
 		// all templates will be reset to whatever the defaults are
1593 1593
 		// for the global template matching the messenger and message type.
1594
-		$success = !empty( $GRP_ID ) ? true : false;
1594
+		$success = ! empty($GRP_ID) ? true : false;
1595 1595
 
1596
-		if ( $success ) {
1596
+		if ($success) {
1597 1597
 
1598 1598
 			//let's first determine if the incoming template is a global template,
1599 1599
 			// if it isn't then we need to get the global template matching messenger and message type.
@@ -1601,9 +1601,9 @@  discard block
 block discarded – undo
1601 1601
 
1602 1602
 
1603 1603
 			//note this is ONLY deleting the template fields (Message Template rows) NOT the message template group.
1604
-			$success = $this->_delete_mtp_permanently( $GRP_ID, false );
1604
+			$success = $this->_delete_mtp_permanently($GRP_ID, false);
1605 1605
 
1606
-			if ( $success ) {
1606
+			if ($success) {
1607 1607
 				// if successfully deleted, lets generate the new ones.
1608 1608
 				// Note. We set GLOBAL to true, because resets on ANY template
1609 1609
 				// will use the related global template defaults for regeneration.
@@ -1621,32 +1621,32 @@  discard block
 block discarded – undo
1621 1621
 		}
1622 1622
 
1623 1623
 		//any error messages?
1624
-		if ( !$success ) {
1624
+		if ( ! $success) {
1625 1625
 			EE_Error::add_error(
1626
-				__( 'Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso' ),
1626
+				__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'),
1627 1627
 				__FILE__, __FUNCTION__, __LINE__
1628 1628
 			);
1629 1629
 		}
1630 1630
 
1631 1631
 		//all good, let's add a success message!
1632
-		if ( $success && ! empty( $templates ) ) {
1632
+		if ($success && ! empty($templates)) {
1633 1633
 			$templates = $templates[0]; //the info for the template we generated is the first element in the returned array.
1634 1634
 			EE_Error::overwrite_success();
1635
-			EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') );
1635
+			EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso'));
1636 1636
 		}
1637 1637
 
1638 1638
 
1639 1639
 		$query_args = array(
1640
-			'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : null,
1641
-			'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : null,
1642
-			'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'global_mtps'
1640
+			'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : null,
1641
+			'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : null,
1642
+			'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'global_mtps'
1643 1643
 			);
1644 1644
 
1645 1645
 		//if called via ajax then we return query args otherwise redirect
1646
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
1646
+		if (defined('DOING_AJAX') && DOING_AJAX) {
1647 1647
 			return $query_args;
1648 1648
 		} else {
1649
-			$this->_redirect_after_action( false, '', '', $query_args, true );
1649
+			$this->_redirect_after_action(false, '', '', $query_args, true);
1650 1650
 			return null;
1651 1651
 		}
1652 1652
 	}
@@ -1659,7 +1659,7 @@  discard block
 block discarded – undo
1659 1659
 	 * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
1660 1660
 	 * @return string
1661 1661
 	 */
1662
-	public function _preview_message( $send = false ) {
1662
+	public function _preview_message($send = false) {
1663 1663
 		//first make sure we've got the necessary parameters
1664 1664
 		if (
1665 1665
 			! isset(
@@ -1675,13 +1675,13 @@  discard block
 block discarded – undo
1675 1675
 			);
1676 1676
 		}
1677 1677
 
1678
-		EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] );
1678
+		EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']);
1679 1679
 
1680 1680
 
1681 1681
 		//get the preview!
1682
-		$preview = EED_Messages::preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send );
1682
+		$preview = EED_Messages::preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send);
1683 1683
 
1684
-		if ( $send ) {
1684
+		if ($send) {
1685 1685
 			return $preview;
1686 1686
 		}
1687 1687
 
@@ -1691,22 +1691,22 @@  discard block
 block discarded – undo
1691 1691
 			'context' => $this->_req_data['context'],
1692 1692
 			'action' => 'edit_message_template'
1693 1693
 			);
1694
-		$go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1695
-		$preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>';
1694
+		$go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1695
+		$preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>';
1696 1696
 		$message_types = $this->get_installed_message_types();
1697
-		$active_messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
1697
+		$active_messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
1698 1698
 		$active_messenger_label = $active_messenger instanceof EE_messenger
1699
-			? ucwords( $active_messenger->label['singular'] )
1700
-			: esc_html__( 'Unknown Messenger', 'event_espresso' );
1699
+			? ucwords($active_messenger->label['singular'])
1700
+			: esc_html__('Unknown Messenger', 'event_espresso');
1701 1701
 		//let's provide a helpful title for context
1702 1702
 		$preview_title = sprintf(
1703
-			__( 'Viewing Preview for %s %s Message Template', 'event_espresso' ),
1703
+			__('Viewing Preview for %s %s Message Template', 'event_espresso'),
1704 1704
 			$active_messenger_label,
1705
-			ucwords( $message_types[ $this->_req_data[ 'message_type' ] ]->label[ 'singular' ] )
1705
+			ucwords($message_types[$this->_req_data['message_type']]->label['singular'])
1706 1706
 		);
1707 1707
 		//setup display of preview.
1708 1708
 		$this->_admin_page_title = $preview_title;
1709
-		$this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview);
1709
+		$this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview);
1710 1710
 		$this->_template_args['data']['force_json'] = true;
1711 1711
 		return '';
1712 1712
 	}
@@ -1736,9 +1736,9 @@  discard block
 block discarded – undo
1736 1736
 	 * @return void
1737 1737
 	 */
1738 1738
 	protected function _register_edit_meta_boxes() {
1739
-		add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' );
1740
-		add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1741
-		add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1739
+		add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default');
1740
+		add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high');
1741
+		add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high');
1742 1742
 	}
1743 1743
 
1744 1744
 
@@ -1757,14 +1757,14 @@  discard block
 block discarded – undo
1757 1757
 
1758 1758
 		$tp_select_values = array();
1759 1759
 
1760
-		foreach ( $tp_collection as $tp ) {
1760
+		foreach ($tp_collection as $tp) {
1761 1761
 			//only include template packs that support this messenger and message type!
1762 1762
 			$supports = $tp->get_supports();
1763 1763
 			if (
1764
-				! isset( $supports[ $this->_message_template_group->messenger() ] )
1764
+				! isset($supports[$this->_message_template_group->messenger()])
1765 1765
 				|| ! in_array(
1766 1766
 					$this->_message_template_group->message_type(),
1767
-					$supports[ $this->_message_template_group->messenger() ]
1767
+					$supports[$this->_message_template_group->messenger()]
1768 1768
 				)
1769 1769
 			) {
1770 1770
 				//not supported
@@ -1778,7 +1778,7 @@  discard block
 block discarded – undo
1778 1778
 		}
1779 1779
 
1780 1780
 		//if empty $tp_select_values then we make sure default is set because EVERY message type should be supported by the default template pack.  This still allows for the odd template pack to override.
1781
-		if ( empty( $tp_select_values ) ) {
1781
+		if (empty($tp_select_values)) {
1782 1782
 			$tp_select_values[] = array(
1783 1783
 				'text' => __('Default', 'event_espresso'),
1784 1784
 				'id' => 'default'
@@ -1791,14 +1791,14 @@  discard block
 block discarded – undo
1791 1791
 			$this->_message_template_group->message_type()
1792 1792
 		);
1793 1793
 		$variations_select_values = array();
1794
-		foreach ( $variations as $variation => $label ) {
1794
+		foreach ($variations as $variation => $label) {
1795 1795
 			$variations_select_values[] = array(
1796 1796
 				'text' => $label,
1797 1797
 				'id' => $variation
1798 1798
 			);
1799 1799
 		}
1800 1800
 
1801
-		$template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels();
1801
+		$template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
1802 1802
 
1803 1803
 		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input(
1804 1804
 			'MTP_template_pack',
@@ -1815,9 +1815,9 @@  discard block
 block discarded – undo
1815 1815
 		$template_args['template_pack_description'] = $template_pack_labels->template_pack_description;
1816 1816
 		$template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
1817 1817
 
1818
-		$template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
1818
+		$template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php';
1819 1819
 
1820
-		EEH_Template::display_template( $template, $template_args );
1820
+		EEH_Template::display_template($template, $template_args);
1821 1821
 	}
1822 1822
 
1823 1823
 
@@ -1848,47 +1848,47 @@  discard block
 block discarded – undo
1848 1848
 		//first we need to see if there are any fields
1849 1849
 		$fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
1850 1850
 
1851
-		if ( !empty( $fields ) ) {
1851
+		if ( ! empty($fields)) {
1852 1852
 			//yup there be fields
1853
-			foreach ( $fields as $field => $config ) {
1854
-				$field_id = $this->_message_template_group->messenger() . '_' . $field;
1853
+			foreach ($fields as $field => $config) {
1854
+				$field_id = $this->_message_template_group->messenger().'_'.$field;
1855 1855
 				$existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
1856
-				$default = isset( $config['default'] ) ? $config['default'] : '';
1857
-				$default = isset( $config['value'] ) ? $config['value'] : $default;
1856
+				$default = isset($config['default']) ? $config['default'] : '';
1857
+				$default = isset($config['value']) ? $config['value'] : $default;
1858 1858
 
1859 1859
 				//if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults
1860 1860
 				$fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : '';
1861
-				$existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix;
1861
+				$existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix;
1862 1862
 
1863 1863
 				$template_form_fields[$field_id] = array(
1864
-					'name' => 'test_settings_fld[' . $field . ']',
1864
+					'name' => 'test_settings_fld['.$field.']',
1865 1865
 					'label' => $config['label'],
1866 1866
 					'input' => $config['input'],
1867 1867
 					'type' => $config['type'],
1868 1868
 					'required' => $config['required'],
1869 1869
 					'validation' => $config['validation'],
1870
-					'value' => isset( $existing[$field] ) ? $existing[$field] : $default,
1870
+					'value' => isset($existing[$field]) ? $existing[$field] : $default,
1871 1871
 					'css_class' => $config['css_class'],
1872
-					'options' => isset( $config['options'] ) ? $config['options'] : array(),
1872
+					'options' => isset($config['options']) ? $config['options'] : array(),
1873 1873
 					'default' => $default,
1874 1874
 					'format' => $config['format']
1875 1875
 					);
1876 1876
 			}
1877 1877
 		}
1878 1878
 
1879
-		$test_settings_fields = !empty( $template_form_fields)
1880
-			? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' )
1879
+		$test_settings_fields = ! empty($template_form_fields)
1880
+			? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds')
1881 1881
 			: '';
1882 1882
 
1883 1883
 		$test_settings_html = '';
1884 1884
 		//print out $test_settings_fields
1885
-		if ( !empty( $test_settings_fields ) ) {
1885
+		if ( ! empty($test_settings_fields)) {
1886 1886
 			echo $test_settings_fields;
1887
-			$test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="' . __('Test Send', 'event_espresso') . '" /><div style="clear:both"></div>';
1887
+			$test_settings_html = '<input type="submit" class="button-primary mtp-test-button alignright" name="test_button" value="'.__('Test Send', 'event_espresso').'" /><div style="clear:both"></div>';
1888 1888
 		}
1889 1889
 
1890 1890
 		//and button
1891
-		echo $test_settings_html . '<p>' . __('Need to reset this message type and start over?', 'event_espresso') . '</p>' . '<div class="publishing-action alignright resetbutton">' . $button . '</div><div style="clear:both"></div>';
1891
+		echo $test_settings_html.'<p>'.__('Need to reset this message type and start over?', 'event_espresso').'</p>'.'<div class="publishing-action alignright resetbutton">'.$button.'</div><div style="clear:both"></div>';
1892 1892
 	}
1893 1893
 
1894 1894
 
@@ -1903,13 +1903,13 @@  discard block
 block discarded – undo
1903 1903
      * @param string $linked_input_id The css id of the input that the shortcodes get added to.
1904 1904
      * @return string
1905 1905
     */
1906
-	protected function _get_shortcode_selector( $field, $linked_input_id ) {
1906
+	protected function _get_shortcode_selector($field, $linked_input_id) {
1907 1907
 		$template_args = array(
1908
-			'shortcodes' => $this->_get_shortcodes( array( $field ), true ),
1908
+			'shortcodes' => $this->_get_shortcodes(array($field), true),
1909 1909
 			'fieldname' => $field,
1910 1910
 			'linked_input_id' => $linked_input_id
1911 1911
 		);
1912
-		return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true );
1912
+		return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true);
1913 1913
 	}
1914 1914
 
1915 1915
 
@@ -1924,13 +1924,13 @@  discard block
 block discarded – undo
1924 1924
 		$shortcodes = $this->_get_shortcodes(array(), false); //just make sure shortcodes property is set
1925 1925
 		//$messenger = $this->_message_template_group->messenger_obj();
1926 1926
 		//now let's set the content depending on the status of the shortcodes array
1927
-		if ( empty( $shortcodes ) ) {
1928
-			$content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>';
1927
+		if (empty($shortcodes)) {
1928
+			$content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>';
1929 1929
 			echo $content;
1930 1930
 		} else {
1931 1931
 			//$alt = 0;
1932 1932
 			?>
1933
-			<div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf( __('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso' ), '<span class="dashicons dashicons-menu"></span>' ); ?></p>
1933
+			<div style="float:right; margin-top:10px"><?php echo $this->_get_help_tab_link('message_template_shortcodes'); ?></div><p class="small-text"><?php printf(__('You can view the shortcodes usable in your template by clicking the %s icon next to each field.', 'event_espresso'), '<span class="dashicons dashicons-menu"></span>'); ?></p>
1934 1934
 			<?php
1935 1935
 		}
1936 1936
 
@@ -1947,7 +1947,7 @@  discard block
 block discarded – undo
1947 1947
 	protected function _set_shortcodes() {
1948 1948
 
1949 1949
 		//no need to run this if the property is already set
1950
-		if ( !empty($this->_shortcodes ) ) {return;}
1950
+		if ( ! empty($this->_shortcodes)) {return; }
1951 1951
 
1952 1952
 		$this->_shortcodes = $this->_get_shortcodes();
1953 1953
 	}
@@ -1969,14 +1969,14 @@  discard block
 block discarded – undo
1969 1969
 	 * @return array          Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true
1970 1970
 	 *                       just an array of shortcode/label pairs.
1971 1971
 	 */
1972
-	protected function _get_shortcodes( $fields = array(), $merged = true ) {
1972
+	protected function _get_shortcodes($fields = array(), $merged = true) {
1973 1973
 		$this->_set_message_template_group();
1974 1974
 
1975 1975
 		//we need the messenger and message template to retrieve the valid shortcodes array.
1976
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : false;
1977
-		$context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() );
1976
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : false;
1977
+		$context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config());
1978 1978
 
1979
-		return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array();
1979
+		return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array();
1980 1980
 	}
1981 1981
 
1982 1982
 
@@ -1989,19 +1989,19 @@  discard block
 block discarded – undo
1989 1989
 	 */
1990 1990
 	protected function _set_message_template_group() {
1991 1991
 
1992
-		if ( !empty( $this->_message_template_group ) )
1993
-			{return;} //get out if this is already set.
1992
+		if ( ! empty($this->_message_template_group))
1993
+			{return; } //get out if this is already set.
1994 1994
 
1995
-		$GRP_ID =  ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : false;
1996
-		$GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID;
1995
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : false;
1996
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID;
1997 1997
 
1998 1998
 		//let's get the message templates
1999 1999
 		$MTP = EEM_Message_Template_Group::instance();
2000 2000
 
2001
-		if ( empty($GRP_ID) )
2002
-			{$this->_message_template_group = $MTP->create_default_object();}
2001
+		if (empty($GRP_ID))
2002
+			{$this->_message_template_group = $MTP->create_default_object(); }
2003 2003
 		else
2004
-			{$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );}
2004
+			{$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID); }
2005 2005
 
2006 2006
 		$this->_template_pack = $this->_message_template_group->get_template_pack();
2007 2007
 		$this->_variation = $this->_message_template_group->get_template_pack_variation();
@@ -2020,7 +2020,7 @@  discard block
 block discarded – undo
2020 2020
 	 * @param array $args various things the context switcher needs.
2021 2021
 	 *
2022 2022
 	 */
2023
-	protected function _set_context_switcher( EE_Message_Template_Group $template_group_object, $args) {
2023
+	protected function _set_context_switcher(EE_Message_Template_Group $template_group_object, $args) {
2024 2024
 		$context_details = $template_group_object->contexts_config();
2025 2025
 		$context_label = $template_group_object->context_label();
2026 2026
 		ob_start();
@@ -2028,20 +2028,20 @@  discard block
 block discarded – undo
2028 2028
 		<div class="ee-msg-switcher-container">
2029 2029
 			<form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm">
2030 2030
 				<?php
2031
-					foreach ( $args as $name => $value ) {
2032
-						if ( $name == 'context' || empty($value) || $name == 'extra' ) {continue;}
2031
+					foreach ($args as $name => $value) {
2032
+						if ($name == 'context' || empty($value) || $name == 'extra') {continue; }
2033 2033
 						?>
2034 2034
 						<input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" />
2035 2035
 						<?php
2036 2036
 					}
2037 2037
 					//setup nonce_url
2038
-					wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
2038
+					wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false);
2039 2039
 				?>
2040 2040
 				<select name="context">
2041 2041
 					<?php
2042 2042
 					$context_templates = $template_group_object->context_templates();
2043
-					if ( is_array($context_templates) ) :
2044
-							foreach ( $context_templates as $context => $template_fields ) :
2043
+					if (is_array($context_templates)) :
2044
+							foreach ($context_templates as $context => $template_fields) :
2045 2045
 								$checked = ($context == $args['context']) ? 'selected="selected"' : '';
2046 2046
 					?>
2047 2047
 					<option value="<?php echo $context; ?>" <?php echo $checked; ?>>
@@ -2049,7 +2049,7 @@  discard block
 block discarded – undo
2049 2049
 					</option>
2050 2050
 					<?php endforeach; endif; ?>
2051 2051
 				</select>
2052
-				<?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?>
2052
+				<?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?>
2053 2053
 				<input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>">
2054 2054
 			</form>
2055 2055
 			<?php echo $args['extra']; ?>
@@ -2076,8 +2076,8 @@  discard block
 block discarded – undo
2076 2076
 	 * @return array
2077 2077
 	 */
2078 2078
 	protected function _set_message_template_column_values($index) {
2079
-		if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) {
2080
-			foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) {
2079
+		if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) {
2080
+			foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) {
2081 2081
 				$this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value;
2082 2082
 			}
2083 2083
 		} /*else {
@@ -2086,22 +2086,22 @@  discard block
 block discarded – undo
2086 2086
 
2087 2087
 
2088 2088
 		$set_column_values = array(
2089
-			'MTP_ID'             => absint( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'MTP_ID' ] ),
2090
-			'GRP_ID'             => absint( $this->_req_data[ 'GRP_ID' ] ),
2091
-			'MTP_user_id'        => absint( $this->_req_data[ 'MTP_user_id' ] ),
2092
-			'MTP_messenger'      => strtolower( $this->_req_data[ 'MTP_messenger' ] ),
2093
-			'MTP_message_type'   => strtolower( $this->_req_data[ 'MTP_message_type' ] ),
2094
-			'MTP_template_field' => strtolower( $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'name' ] ),
2095
-			'MTP_context'        => strtolower( $this->_req_data[ 'MTP_context' ] ),
2096
-			'MTP_content'        => $this->_req_data[ 'MTP_template_fields' ][ $index ][ 'content' ],
2097
-			'MTP_is_global'      => isset( $this->_req_data[ 'MTP_is_global' ] )
2098
-				? absint( $this->_req_data[ 'MTP_is_global' ] )
2089
+			'MTP_ID'             => absint($this->_req_data['MTP_template_fields'][$index]['MTP_ID']),
2090
+			'GRP_ID'             => absint($this->_req_data['GRP_ID']),
2091
+			'MTP_user_id'        => absint($this->_req_data['MTP_user_id']),
2092
+			'MTP_messenger'      => strtolower($this->_req_data['MTP_messenger']),
2093
+			'MTP_message_type'   => strtolower($this->_req_data['MTP_message_type']),
2094
+			'MTP_template_field' => strtolower($this->_req_data['MTP_template_fields'][$index]['name']),
2095
+			'MTP_context'        => strtolower($this->_req_data['MTP_context']),
2096
+			'MTP_content'        => $this->_req_data['MTP_template_fields'][$index]['content'],
2097
+			'MTP_is_global'      => isset($this->_req_data['MTP_is_global'])
2098
+				? absint($this->_req_data['MTP_is_global'])
2099 2099
 				: 0,
2100
-			'MTP_is_override'    => isset( $this->_req_data[ 'MTP_is_override' ] )
2101
-				? absint( $this->_req_data[ 'MTP_is_override' ] )
2100
+			'MTP_is_override'    => isset($this->_req_data['MTP_is_override'])
2101
+				? absint($this->_req_data['MTP_is_override'])
2102 2102
 				: 0,
2103
-			'MTP_deleted'        => absint( $this->_req_data[ 'MTP_deleted' ] ),
2104
-			'MTP_is_active'      => absint( $this->_req_data[ 'MTP_is_active' ] )
2103
+			'MTP_deleted'        => absint($this->_req_data['MTP_deleted']),
2104
+			'MTP_is_active'      => absint($this->_req_data['MTP_is_active'])
2105 2105
 		);
2106 2106
 
2107 2107
 
@@ -2113,36 +2113,36 @@  discard block
 block discarded – undo
2113 2113
 
2114 2114
 
2115 2115
 
2116
-	protected function _insert_or_update_message_template($new = false ) {
2116
+	protected function _insert_or_update_message_template($new = false) {
2117 2117
 
2118
-		do_action ( 'AHEE_log', __FILE__, __FUNCTION__, '');
2118
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2119 2119
 		$success = 0;
2120 2120
 		$override = false;
2121 2121
 
2122 2122
 		//setup notices description
2123
-		$messenger = ! empty( $this->_req_data['MTP_messenger'] )
2124
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_messenger'] ) )
2123
+		$messenger = ! empty($this->_req_data['MTP_messenger'])
2124
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger']))
2125 2125
 			: false;
2126 2126
 
2127
-		$message_type = ! empty( $this->_req_data['MTP_message_type'] )
2128
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_message_type'] ) )
2127
+		$message_type = ! empty($this->_req_data['MTP_message_type'])
2128
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type']))
2129 2129
 			: false;
2130 2130
 
2131
-		$context = ! empty( $this->_req_data['MTP_context'] )
2132
-			? ucwords( str_replace( '_', ' ', $this->_req_data['MTP_context'] ) )
2131
+		$context = ! empty($this->_req_data['MTP_context'])
2132
+			? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context']))
2133 2133
 			: false;
2134 2134
 
2135
-		$item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : '';
2135
+		$item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : '';
2136 2136
 		$item_desc .= 'Message Template';
2137 2137
 		$query_args = array();
2138 2138
 		$edit_array = array();
2139 2139
 		$action_desc = '';
2140 2140
 
2141 2141
 		//if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit.
2142
-		if ( $new ) {
2143
-			$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
2144
-			if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) {
2145
-				if ( empty($edit_array) ) {
2142
+		if ($new) {
2143
+			$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
2144
+			if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) {
2145
+				if (empty($edit_array)) {
2146 2146
 					$success = 0;
2147 2147
 				} else {
2148 2148
 					$success = 1;
@@ -2161,7 +2161,7 @@  discard block
 block discarded – undo
2161 2161
 
2162 2162
 
2163 2163
 			//run update for each template field in displayed context
2164
-			if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) {
2164
+			if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) {
2165 2165
 				EE_Error::add_error(
2166 2166
 					__('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'),
2167 2167
 					__FILE__, __FUNCTION__, __LINE__
@@ -2170,25 +2170,25 @@  discard block
 block discarded – undo
2170 2170
 
2171 2171
 			} else {
2172 2172
 				//first validate all fields!
2173
-				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2173
+				$validates = $MTPG->validate($this->_req_data['MTP_template_fields'], $this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2174 2174
 
2175 2175
 				//if $validate returned error messages (i.e. is_array()) then we need to process them and setup an appropriate response. HMM, dang this isn't correct, $validates will ALWAYS be an array.  WE need to make sure there is no actual error messages in validates.
2176
-				if ( is_array($validates) && !empty($validates) ) {
2176
+				if (is_array($validates) && ! empty($validates)) {
2177 2177
 					//add the transient so when the form loads we know which fields to highlight
2178
-					$this->_add_transient( 'edit_message_template', $validates );
2178
+					$this->_add_transient('edit_message_template', $validates);
2179 2179
 
2180 2180
 					$success = 0;
2181 2181
 
2182 2182
 					//setup notices
2183
-					foreach ( $validates as $field => $error ) {
2184
-						if ( isset($error['msg'] ) ) {
2185
-							EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );
2183
+					foreach ($validates as $field => $error) {
2184
+						if (isset($error['msg'])) {
2185
+							EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
2186 2186
 						}
2187 2187
 					}
2188 2188
 
2189 2189
 				} else {
2190 2190
 					$set_column_values = array();
2191
-					foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) {
2191
+					foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) {
2192 2192
 						$set_column_values = $this->_set_message_template_column_values($template_field);
2193 2193
 
2194 2194
 						$where_cols_n_values = array(
@@ -2201,11 +2201,11 @@  discard block
 block discarded – undo
2201 2201
 							'MTP_context' => $set_column_values['MTP_context'],
2202 2202
 							'MTP_content' => $set_column_values['MTP_content']
2203 2203
 						);
2204
-						if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) {
2205
-							if ( $updated === false ) {
2204
+						if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) {
2205
+							if ($updated === false) {
2206 2206
 								EE_Error::add_error(
2207 2207
 									sprintf(
2208
-										__( '%s field was NOT updated for some reason', 'event_espresso' ),
2208
+										__('%s field was NOT updated for some reason', 'event_espresso'),
2209 2209
 										$template_field
2210 2210
 									),
2211 2211
 									__FILE__, __FUNCTION__, __LINE__
@@ -2219,46 +2219,46 @@  discard block
 block discarded – undo
2219 2219
 
2220 2220
 					//we can use the last set_column_values for the MTPG update (because its the same for all of these specific MTPs)
2221 2221
 					$mtpg_fields = array(
2222
-						'MTP_user_id'      => $set_column_values[ 'MTP_user_id' ],
2223
-						'MTP_messenger'    => $set_column_values[ 'MTP_messenger' ],
2224
-						'MTP_message_type' => $set_column_values[ 'MTP_message_type' ],
2225
-						'MTP_is_global'    => $set_column_values[ 'MTP_is_global' ],
2226
-						'MTP_is_override'  => $set_column_values[ 'MTP_is_override' ],
2227
-						'MTP_deleted'      => $set_column_values[ 'MTP_deleted' ],
2228
-						'MTP_is_active'    => $set_column_values[ 'MTP_is_active' ],
2229
-						'MTP_name'         => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ] )
2230
-							? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_name' ]
2222
+						'MTP_user_id'      => $set_column_values['MTP_user_id'],
2223
+						'MTP_messenger'    => $set_column_values['MTP_messenger'],
2224
+						'MTP_message_type' => $set_column_values['MTP_message_type'],
2225
+						'MTP_is_global'    => $set_column_values['MTP_is_global'],
2226
+						'MTP_is_override'  => $set_column_values['MTP_is_override'],
2227
+						'MTP_deleted'      => $set_column_values['MTP_deleted'],
2228
+						'MTP_is_active'    => $set_column_values['MTP_is_active'],
2229
+						'MTP_name'         => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name'])
2230
+							? $this->_req_data['ee_msg_non_global_fields']['MTP_name']
2231 2231
 							: '',
2232
-						'MTP_description'  => ! empty( $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ] )
2233
-							? $this->_req_data[ 'ee_msg_non_global_fields' ][ 'MTP_description' ]
2232
+						'MTP_description'  => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description'])
2233
+							? $this->_req_data['ee_msg_non_global_fields']['MTP_description']
2234 2234
 							: ''
2235 2235
 					);
2236 2236
 
2237
-					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] );
2238
-					$updated = $MTPG->update( $mtpg_fields, array($mtpg_where) );
2237
+					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']);
2238
+					$updated = $MTPG->update($mtpg_fields, array($mtpg_where));
2239 2239
 
2240
-					if ( $updated === false ) {
2240
+					if ($updated === false) {
2241 2241
 						EE_Error::add_error(
2242 2242
 							sprintf(
2243
-								__( 'The Message Template Group (%d) was NOT updated for some reason', 'event_espresso' ),
2244
-								$set_column_values[ 'GRP_ID' ]
2243
+								__('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'),
2244
+								$set_column_values['GRP_ID']
2245 2245
 							),
2246 2246
 							__FILE__, __FUNCTION__, __LINE__
2247 2247
 						);
2248 2248
 					} else {
2249 2249
 						//k now we need to ensure the template_pack and template_variation fields are set.
2250
-						$template_pack = ! empty( $this->_req_data['MTP_template_pack' ] )
2250
+						$template_pack = ! empty($this->_req_data['MTP_template_pack'])
2251 2251
 							? $this->_req_data['MTP_template_pack']
2252 2252
 							: 'default';
2253 2253
 
2254
-						$template_variation = ! empty( $this->_req_data['MTP_template_variation'] )
2254
+						$template_variation = ! empty($this->_req_data['MTP_template_variation'])
2255 2255
 							? $this->_req_data['MTP_template_variation']
2256 2256
 							: 'default';
2257 2257
 
2258
-						$mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] );
2259
-						if ( $mtpg_obj instanceof EE_Message_Template_Group ) {
2260
-							$mtpg_obj->set_template_pack_name( $template_pack );
2261
-							$mtpg_obj->set_template_pack_variation( $template_variation );
2258
+						$mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']);
2259
+						if ($mtpg_obj instanceof EE_Message_Template_Group) {
2260
+							$mtpg_obj->set_template_pack_name($template_pack);
2261
+							$mtpg_obj->set_template_pack_variation($template_variation);
2262 2262
 						}
2263 2263
 						$success = 1;
2264 2264
 					}
@@ -2268,7 +2268,7 @@  discard block
 block discarded – undo
2268 2268
 		}
2269 2269
 
2270 2270
 		//we return things differently if doing ajax
2271
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
2271
+		if (defined('DOING_AJAX') && DOING_AJAX) {
2272 2272
 			$this->_template_args['success'] = $success;
2273 2273
 			$this->_template_args['error'] = ! $success ? true : false;
2274 2274
 			$this->_template_args['content'] = '';
@@ -2276,9 +2276,9 @@  discard block
 block discarded – undo
2276 2276
 				'grpID' => $edit_array['GRP_ID'],
2277 2277
 				'templateName' => $edit_array['template_name']
2278 2278
 				);
2279
-			if ( $success ) {
2279
+			if ($success) {
2280 2280
 				EE_Error::overwrite_success();
2281
-				EE_Error::add_success( __('The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.', 'event_espresso') );
2281
+				EE_Error::add_success(__('The new template has been created and automatically selected for this event.  You can edit the new template by clicking the edit button.  Note before this template is assigned to this event, the event must be saved.', 'event_espresso'));
2282 2282
 			}
2283 2283
 
2284 2284
 			$this->_return_json();
@@ -2286,13 +2286,13 @@  discard block
 block discarded – undo
2286 2286
 
2287 2287
 
2288 2288
 		//was a test send triggered?
2289
-		if ( isset( $this->_req_data['test_button'] ) ) {
2289
+		if (isset($this->_req_data['test_button'])) {
2290 2290
 			EE_Error::overwrite_success();
2291
-			$this->_do_test_send( $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] );
2291
+			$this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
2292 2292
 			$override = true;
2293 2293
 		}
2294 2294
 
2295
-		if ( empty( $query_args ) ) {
2295
+		if (empty($query_args)) {
2296 2296
 			$query_args = array(
2297 2297
 				'id' => $this->_req_data['GRP_ID'],
2298 2298
 				'context' => $this->_req_data['MTP_context'],
@@ -2300,7 +2300,7 @@  discard block
 block discarded – undo
2300 2300
 				);
2301 2301
 		}
2302 2302
 
2303
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override );
2303
+		$this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
2304 2304
 	}
2305 2305
 
2306 2306
 
@@ -2314,28 +2314,28 @@  discard block
 block discarded – undo
2314 2314
 	 * @param  string $message_type message type being tested
2315 2315
 	 *
2316 2316
 	 */
2317
-	protected function _do_test_send( $context, $messenger, $message_type ) {
2317
+	protected function _do_test_send($context, $messenger, $message_type) {
2318 2318
 		//set things up for preview
2319 2319
 		$this->_req_data['messenger'] = $messenger;
2320 2320
 		$this->_req_data['message_type'] = $message_type;
2321 2321
 		$this->_req_data['context'] = $context;
2322
-		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : '';
2323
-		$active_messenger = $this->_message_resource_manager->get_active_messenger( $messenger );
2322
+		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : '';
2323
+		$active_messenger = $this->_message_resource_manager->get_active_messenger($messenger);
2324 2324
 
2325 2325
 		//let's save any existing fields that might be required by the messenger
2326 2326
 		if (
2327
-			isset( $this->_req_data['test_settings_fld'] )
2327
+			isset($this->_req_data['test_settings_fld'])
2328 2328
 			&& $active_messenger instanceof EE_messenger
2329 2329
 		) {
2330
-			$active_messenger->set_existing_test_settings( $this->_req_data['test_settings_fld'] );
2330
+			$active_messenger->set_existing_test_settings($this->_req_data['test_settings_fld']);
2331 2331
 		}
2332 2332
 
2333 2333
 		$success = $this->_preview_message(true);
2334 2334
 
2335
-		if ( $success ) {
2336
-			EE_Error::add_success( __('Test message sent', 'event_espresso') );
2335
+		if ($success) {
2336
+			EE_Error::add_success(__('Test message sent', 'event_espresso'));
2337 2337
 		} else {
2338
-			EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
2338
+			EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2339 2339
 		}
2340 2340
 	}
2341 2341
 
@@ -2361,11 +2361,11 @@  discard block
 block discarded – undo
2361 2361
 	protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = false) {
2362 2362
 
2363 2363
 		//if no $message_types are given then that's okay... this may be a messenger that just adds shortcodes, so we just don't generate any templates.
2364
-		if ( empty( $message_types ) ) {
2364
+		if (empty($message_types)) {
2365 2365
 			return true;
2366 2366
 		}
2367 2367
 
2368
-		return EEH_MSG_Template::generate_new_templates( $messenger, $message_types, $GRP_ID, $global );
2368
+		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
2369 2369
 	}
2370 2370
 
2371 2371
 
@@ -2381,33 +2381,33 @@  discard block
 block discarded – undo
2381 2381
 	 *
2382 2382
 	 * @return void
2383 2383
 	 */
2384
-	protected function _trash_or_restore_message_template($trash = true, $all = false ) {
2385
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2384
+	protected function _trash_or_restore_message_template($trash = true, $all = false) {
2385
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2386 2386
 		$MTP = EEM_Message_Template_Group::instance();
2387 2387
 
2388 2388
 		$success = 1;
2389 2389
 
2390 2390
 		//incoming GRP_IDs
2391
-		if ( $all ) {
2391
+		if ($all) {
2392 2392
 			//Checkboxes
2393
-			if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) {
2393
+			if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2394 2394
 				//if array has more than one element then success message should be plural.
2395 2395
 				//todo: what about nonce?
2396
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2396
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2397 2397
 
2398 2398
 				//cycle through checkboxes
2399
-				while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) {
2400
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2401
-					if ( ! $trashed_or_restored ) {
2399
+				while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2400
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2401
+					if ( ! $trashed_or_restored) {
2402 2402
 						$success = 0;
2403 2403
 					}
2404 2404
 				}
2405 2405
 			} else {
2406 2406
 				//grab single GRP_ID and handle
2407
-				$GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0;
2408
-				if ( ! empty( $GRP_ID ) ) {
2409
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2410
-					if ( ! $trashed_or_restored ) {
2407
+				$GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
2408
+				if ( ! empty($GRP_ID)) {
2409
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2410
+					if ( ! $trashed_or_restored) {
2411 2411
 						$success = 0;
2412 2412
 					}
2413 2413
 				} else {
@@ -2419,13 +2419,13 @@  discard block
 block discarded – undo
2419 2419
 
2420 2420
 		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2421 2421
 
2422
-		$action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc;
2422
+		$action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc;
2423 2423
 
2424 2424
 		$item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
2425 2425
 
2426
-		$item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2426
+		$item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2427 2427
 
2428
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, array() );
2428
+		$this->_redirect_after_action($success, $item_desc, $action_desc, array());
2429 2429
 
2430 2430
 	}
2431 2431
 
@@ -2441,24 +2441,24 @@  discard block
 block discarded – undo
2441 2441
 	 * @return void
2442 2442
 	 */
2443 2443
 	protected function _delete_message_template() {
2444
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2444
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2445 2445
 
2446 2446
 		//checkboxes
2447
-		if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) {
2447
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2448 2448
 			//if array has more than one element then success message should be plural
2449
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2449
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2450 2450
 
2451 2451
 			//cycle through bulk action checkboxes
2452
-			while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) {
2453
-				$success = $this->_delete_mtp_permanently( $GRP_ID );
2452
+			while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2453
+				$success = $this->_delete_mtp_permanently($GRP_ID);
2454 2454
 			}
2455 2455
 		} else {
2456 2456
 			//grab single grp_id and delete
2457
-			$GRP_ID = absint($this->_req_data['id'] );
2458
-			$success = $this->_delete_mtp_permanently( $GRP_ID );
2457
+			$GRP_ID = absint($this->_req_data['id']);
2458
+			$success = $this->_delete_mtp_permanently($GRP_ID);
2459 2459
 		}
2460 2460
 
2461
-		$this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() );
2461
+		$this->_redirect_after_action($success, 'Message Templates', 'deleted', array());
2462 2462
 
2463 2463
 	}
2464 2464
 
@@ -2473,20 +2473,20 @@  discard block
 block discarded – undo
2473 2473
 	 *
2474 2474
 	 * @return bool        boolean to indicate the success of the deletes or not.
2475 2475
 	 */
2476
-	private function _delete_mtp_permanently( $GRP_ID, $include_group = true ) {
2476
+	private function _delete_mtp_permanently($GRP_ID, $include_group = true) {
2477 2477
 		$success = 1;
2478 2478
 		$MTPG = EEM_Message_Template_Group::instance();
2479 2479
 		//first let's GET this group
2480
-		$MTG = $MTPG->get_one_by_ID( $GRP_ID );
2480
+		$MTG = $MTPG->get_one_by_ID($GRP_ID);
2481 2481
 		//then delete permanently all the related Message Templates
2482
-		$deleted = $MTG->delete_related_permanently( 'Message_Template' );
2482
+		$deleted = $MTG->delete_related_permanently('Message_Template');
2483 2483
 
2484
-		if ( $deleted === 0 )
2485
-			{$success = 0;}
2484
+		if ($deleted === 0)
2485
+			{$success = 0; }
2486 2486
 
2487 2487
 		//now delete permanently this particular group
2488 2488
 
2489
-		if ( $include_group && ! $MTG->delete_permanently() ) {
2489
+		if ($include_group && ! $MTG->delete_permanently()) {
2490 2490
 			$success = 0;
2491 2491
 		}
2492 2492
 		return $success;
@@ -2504,7 +2504,7 @@  discard block
 block discarded – undo
2504 2504
 	*	@return string
2505 2505
 	*/
2506 2506
 	protected function _learn_more_about_message_templates_link() {
2507
-		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>';
2507
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>';
2508 2508
 	}
2509 2509
 
2510 2510
 
@@ -2522,10 +2522,10 @@  discard block
 block discarded – undo
2522 2522
 
2523 2523
 		$this->_set_m_mt_settings();
2524 2524
 
2525
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2525
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2526 2526
 
2527 2527
 		//let's setup the messenger tabs
2528
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger );
2528
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger);
2529 2529
 		$this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
2530 2530
 		$this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->';
2531 2531
 
@@ -2544,7 +2544,7 @@  discard block
 block discarded – undo
2544 2544
 	 */
2545 2545
 	protected function _set_m_mt_settings() {
2546 2546
 		//first if this is already set then lets get out no need to regenerate data.
2547
-		if ( !empty($this->_m_mt_settings) ) {
2547
+		if ( ! empty($this->_m_mt_settings)) {
2548 2548
 			return;
2549 2549
 		}
2550 2550
 
@@ -2559,10 +2559,10 @@  discard block
 block discarded – undo
2559 2559
 
2560 2560
 		//assemble the array for the _tab_text_links helper
2561 2561
 
2562
-		foreach ( $messengers as $messenger ) {
2562
+		foreach ($messengers as $messenger) {
2563 2563
 			$this->_m_mt_settings['messenger_tabs'][$messenger->name] = array(
2564 2564
 				'label' => ucwords($messenger->label['singular']),
2565
-				'class' => $this->_message_resource_manager->is_messenger_active( $messenger->name ) ? 'messenger-active' : '',
2565
+				'class' => $this->_message_resource_manager->is_messenger_active($messenger->name) ? 'messenger-active' : '',
2566 2566
 				'href' => $messenger->name,
2567 2567
 				'title' => __('Modify this Messenger', 'event_espresso'),
2568 2568
 				'slug' => $messenger->name,
@@ -2572,26 +2572,26 @@  discard block
 block discarded – undo
2572 2572
 
2573 2573
 			$message_types_for_messenger = $messenger->get_valid_message_types();
2574 2574
 
2575
-			foreach ( $message_types as $message_type ) {
2575
+			foreach ($message_types as $message_type) {
2576 2576
 				//first we need to verify that this message type is valid with this messenger. Cause if it isn't then it shouldn't show in either the inactive OR active metabox.
2577
-				if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) {
2577
+				if ( ! in_array($message_type->name, $message_types_for_messenger)) {
2578 2578
 					continue;
2579 2579
 				}
2580 2580
 
2581
-				$a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger->name, $message_type->name ) ? 'active' : 'inactive';
2581
+				$a_or_i = $this->_message_resource_manager->is_message_type_active_for_messenger($messenger->name, $message_type->name) ? 'active' : 'inactive';
2582 2582
 
2583 2583
 				$this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
2584
-					'label'    => ucwords( $message_type->label[ 'singular' ] ),
2585
-					'class'    => 'message-type-' . $a_or_i,
2586
-					'slug_id'  => $message_type->name . '-messagetype-' . $messenger->name,
2587
-					'mt_nonce' => wp_create_nonce( $message_type->name . '_nonce' ),
2588
-					'href'     => 'espresso_' . $message_type->name . '_message_type_settings',
2584
+					'label'    => ucwords($message_type->label['singular']),
2585
+					'class'    => 'message-type-'.$a_or_i,
2586
+					'slug_id'  => $message_type->name.'-messagetype-'.$messenger->name,
2587
+					'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'),
2588
+					'href'     => 'espresso_'.$message_type->name.'_message_type_settings',
2589 2589
 					'title'    => $a_or_i == 'active'
2590
-						? __( 'Drag this message type to the Inactive window to deactivate', 'event_espresso' )
2591
-						: __( 'Drag this message type to the messenger to activate', 'event_espresso' ),
2590
+						? __('Drag this message type to the Inactive window to deactivate', 'event_espresso')
2591
+						: __('Drag this message type to the messenger to activate', 'event_espresso'),
2592 2592
 					'content'  => $a_or_i == 'active'
2593
-						? $this->_message_type_settings_content( $message_type, $messenger, true )
2594
-						: $this->_message_type_settings_content( $message_type, $messenger ),
2593
+						? $this->_message_type_settings_content($message_type, $messenger, true)
2594
+						: $this->_message_type_settings_content($message_type, $messenger),
2595 2595
 					'slug'     => $message_type->name,
2596 2596
 					'active'   => $a_or_i == 'active' ? true : false,
2597 2597
 					'obj'      => $message_type
@@ -2610,34 +2610,34 @@  discard block
 block discarded – undo
2610 2610
 	 *
2611 2611
 	 * @return string                html output for the content
2612 2612
 	 */
2613
-	protected function _message_type_settings_content( $message_type, $messenger, $active = false ) {
2613
+	protected function _message_type_settings_content($message_type, $messenger, $active = false) {
2614 2614
 		//get message type fields
2615 2615
 		$fields = $message_type->get_admin_settings_fields();
2616
-		$settings_template_args['template_form_fields']= '';
2616
+		$settings_template_args['template_form_fields'] = '';
2617 2617
 
2618
-		if ( !empty( $fields ) && $active ) {
2618
+		if ( ! empty($fields) && $active) {
2619 2619
 
2620
-			$existing_settings = $message_type->get_existing_admin_settings( $messenger->name );
2620
+			$existing_settings = $message_type->get_existing_admin_settings($messenger->name);
2621 2621
 
2622
-			foreach( $fields as $fldname => $fldprops ) {
2623
-				$field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname;
2622
+			foreach ($fields as $fldname => $fldprops) {
2623
+				$field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname;
2624 2624
 				$template_form_field[$field_id] = array(
2625
-					'name' => 'message_type_settings[' . $fldname . ']',
2625
+					'name' => 'message_type_settings['.$fldname.']',
2626 2626
 					'label' => $fldprops['label'],
2627 2627
 					'input' => $fldprops['field_type'],
2628 2628
 					'type' => $fldprops['value_type'],
2629 2629
 					'required' => $fldprops['required'],
2630 2630
 					'validation' => $fldprops['validation'],
2631
-					'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2632
-					'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(),
2633
-					'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'],
2631
+					'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2632
+					'options' => isset($fldprops['options']) ? $fldprops['options'] : array(),
2633
+					'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2634 2634
 					'css_class' => 'no-drag',
2635 2635
 					'format' => $fldprops['format']
2636 2636
 				);
2637 2637
 			}
2638 2638
 
2639 2639
 
2640
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : '';
2640
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : '';
2641 2641
 		}
2642 2642
 
2643 2643
 		$settings_template_args['description'] = $message_type->description;
@@ -2657,13 +2657,13 @@  discard block
 block discarded – undo
2657 2657
 					)
2658 2658
 				);
2659 2659
 
2660
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2661
-		$settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : '';
2660
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2661
+		$settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : '';
2662 2662
 
2663 2663
 
2664 2664
 
2665
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
2666
-		$content = EEH_Template::display_template( $template, $settings_template_args, true );
2665
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php';
2666
+		$content = EEH_Template::display_template($template, $settings_template_args, true);
2667 2667
 		return $content;
2668 2668
 	}
2669 2669
 
@@ -2680,27 +2680,27 @@  discard block
 block discarded – undo
2680 2680
 		$m_boxes = $mt_boxes = array();
2681 2681
 		$m_template_args = $mt_template_args = array();
2682 2682
 
2683
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2683
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2684 2684
 
2685
-		if ( isset( $this->_m_mt_settings[ 'messenger_tabs' ] ) ) {
2686
-			foreach ( $this->_m_mt_settings[ 'messenger_tabs' ] as $messenger => $tab_array ) {
2687
-				$hide_on_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? '' : 'hidden';
2688
-				$hide_off_message = $this->_message_resource_manager->is_messenger_active( $messenger ) ? 'hidden' : '';
2685
+		if (isset($this->_m_mt_settings['messenger_tabs'])) {
2686
+			foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
2687
+				$hide_on_message = $this->_message_resource_manager->is_messenger_active($messenger) ? '' : 'hidden';
2688
+				$hide_off_message = $this->_message_resource_manager->is_messenger_active($messenger) ? 'hidden' : '';
2689 2689
 				//messenger meta boxes
2690 2690
 				$active = $selected_messenger == $messenger ? true : false;
2691
-				$active_mt_tabs = isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ] )
2692
-				? $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'active' ]
2691
+				$active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active'])
2692
+				? $this->_m_mt_settings['message_type_tabs'][$messenger]['active']
2693 2693
 				: '';
2694
-				$m_boxes[ $messenger . '_a_box' ] = sprintf(
2695
-				__( '%s Settings', 'event_espresso' ),
2696
-				$tab_array[ 'label' ]
2694
+				$m_boxes[$messenger.'_a_box'] = sprintf(
2695
+				__('%s Settings', 'event_espresso'),
2696
+				$tab_array['label']
2697 2697
 				);
2698
-				$m_template_args[ $messenger . '_a_box' ] = array(
2699
-				'active_message_types'   => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2700
-				'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2701
-				? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2698
+				$m_template_args[$messenger.'_a_box'] = array(
2699
+				'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2700
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2701
+				? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2702 2702
 				: '',
2703
-				'content'                => $this->_get_messenger_box_content( $tab_array[ 'obj' ] ),
2703
+				'content'                => $this->_get_messenger_box_content($tab_array['obj']),
2704 2704
 				'hidden'                 => $active ? '' : ' hidden',
2705 2705
 				'hide_on_message'        => $hide_on_message,
2706 2706
 				'messenger'              => $messenger,
@@ -2709,11 +2709,11 @@  discard block
 block discarded – undo
2709 2709
 				// message type meta boxes
2710 2710
 				// (which is really just the inactive container for each messenger
2711 2711
 				// showing inactive message types for that messenger)
2712
-				$mt_boxes[ $messenger . '_i_box' ] = __( 'Inactive Message Types', 'event_espresso' );
2713
-				$mt_template_args[ $messenger . '_i_box' ] = array(
2714
-				'active_message_types'   => ! empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2715
-				'inactive_message_types' => isset( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2716
-				? $this->_get_mt_tabs( $this->_m_mt_settings[ 'message_type_tabs' ][ $messenger ][ 'inactive' ] )
2712
+				$mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso');
2713
+				$mt_template_args[$messenger.'_i_box'] = array(
2714
+				'active_message_types'   => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2715
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2716
+				? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'])
2717 2717
 				: '',
2718 2718
 				'hidden'                 => $active ? '' : ' hidden',
2719 2719
 				'hide_on_message'        => $hide_on_message,
@@ -2726,15 +2726,15 @@  discard block
 block discarded – undo
2726 2726
 
2727 2727
 
2728 2728
 		//register messenger metaboxes
2729
-		$m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
2730
-		foreach ( $m_boxes as $box => $label ) {
2731
-			$callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] );
2732
-			$msgr = str_replace( '_a_box', '', $box );
2729
+		$m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php';
2730
+		foreach ($m_boxes as $box => $label) {
2731
+			$callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
2732
+			$msgr = str_replace('_a_box', '', $box);
2733 2733
 			add_meta_box(
2734
-				'espresso_' . $msgr . '_settings',
2734
+				'espresso_'.$msgr.'_settings',
2735 2735
 				$label,
2736
-				function( $post, $metabox ) {
2737
-					echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );
2736
+				function($post, $metabox) {
2737
+					echo EEH_Template::display_template($metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE);
2738 2738
 				},
2739 2739
 				$this->_current_screen->id,
2740 2740
 				'normal',
@@ -2744,17 +2744,17 @@  discard block
 block discarded – undo
2744 2744
 		}
2745 2745
 
2746 2746
 		//register message type metaboxes
2747
-		$mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
2748
-		foreach ( $mt_boxes as $box => $label ) {
2747
+		$mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php';
2748
+		foreach ($mt_boxes as $box => $label) {
2749 2749
 			$callback_args = array(
2750
-				'template_path' => $mt_template_path, 'template_args' => $mt_template_args[ $box ]
2750
+				'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]
2751 2751
 			);
2752
-			$mt = str_replace( '_i_box', '', $box );
2752
+			$mt = str_replace('_i_box', '', $box);
2753 2753
 			add_meta_box(
2754
-				'espresso_' . $mt . '_inactive_mts',
2754
+				'espresso_'.$mt.'_inactive_mts',
2755 2755
 				$label,
2756
-				function( $post, $metabox ) {
2757
-					echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );
2756
+				function($post, $metabox) {
2757
+					echo EEH_Template::display_template($metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE);
2758 2758
 				},
2759 2759
 				$this->_current_screen->id,
2760 2760
 				'side',
@@ -2765,11 +2765,11 @@  discard block
 block discarded – undo
2765 2765
 
2766 2766
 		//register metabox for global messages settings but only when on the main site.  On single site installs this will
2767 2767
 		//always result in the metabox showing, on multisite installs the metabox will only show on the main site.
2768
-		if ( is_main_site() ) {
2768
+		if (is_main_site()) {
2769 2769
 			add_meta_box(
2770 2770
 				'espresso_global_message_settings',
2771
-				__( 'Global Message Settings', 'event_espresso' ),
2772
-				array( $this, 'global_messages_settings_metabox_content' ),
2771
+				__('Global Message Settings', 'event_espresso'),
2772
+				array($this, 'global_messages_settings_metabox_content'),
2773 2773
 				$this->_current_screen->id,
2774 2774
 				'normal',
2775 2775
 				'low',
@@ -2789,7 +2789,7 @@  discard block
 block discarded – undo
2789 2789
 	public function global_messages_settings_metabox_content() {
2790 2790
 		$form = $this->_generate_global_settings_form();
2791 2791
 		echo $form->form_open(
2792
-			$this->add_query_args_and_nonce( array( 'action' => 'update_global_settings' ), EE_MSG_ADMIN_URL ),
2792
+			$this->add_query_args_and_nonce(array('action' => 'update_global_settings'), EE_MSG_ADMIN_URL),
2793 2793
 			'POST'
2794 2794
 		)
2795 2795
 		. $form->get_html()
@@ -2802,7 +2802,7 @@  discard block
 block discarded – undo
2802 2802
 	 * @return EE_Form_Section_Proper
2803 2803
 	 */
2804 2804
 	protected function _generate_global_settings_form() {
2805
-		EE_Registry::instance()->load_helper( 'HTML' );
2805
+		EE_Registry::instance()->load_helper('HTML');
2806 2806
 		/** @var EE_Network_Core_Config $network_config */
2807 2807
 		$network_config = EE_Registry::instance()->NET_CFG->core;
2808 2808
 		return new EE_Form_Section_Proper(
@@ -2821,13 +2821,13 @@  discard block
 block discarded – undo
2821 2821
 							),
2822 2822
 							array(
2823 2823
 								'default' => $network_config->do_messages_on_same_request,
2824
-								'html_label_text' => __( 'Generate and send all messages:', 'event_espresso' ),
2825
-								'html_help_text' => __( '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.', 'event_espresso' ),
2824
+								'html_label_text' => __('Generate and send all messages:', 'event_espresso'),
2825
+								'html_help_text' => __('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.', 'event_espresso'),
2826 2826
 							)
2827 2827
 						),
2828 2828
 						'update_settings' => new EE_Submit_Input(
2829 2829
 							array(
2830
-								'default' => __( 'Update', 'event_espresso' ),
2830
+								'default' => __('Update', 'event_espresso'),
2831 2831
 								'html_label_text' => '&nbsp'
2832 2832
 							)
2833 2833
 						)
@@ -2846,28 +2846,28 @@  discard block
 block discarded – undo
2846 2846
 		/** @var EE_Network_Core_Config $network_config */
2847 2847
 		$network_config = EE_Registry::instance()->NET_CFG->core;
2848 2848
 		$form = $this->_generate_global_settings_form();
2849
-		if ( $form->was_submitted() ) {
2849
+		if ($form->was_submitted()) {
2850 2850
 			$form->receive_form_submission();
2851
-			if ( $form->is_valid() ) {
2851
+			if ($form->is_valid()) {
2852 2852
 				$valid_data = $form->valid_data();
2853
-				foreach( $valid_data as $property => $value ) {
2854
-					$setter = 'set_' . $property;
2855
-					if ( method_exists( $network_config, $setter ) ) {
2856
-						$network_config->{$setter}( $value );
2853
+				foreach ($valid_data as $property => $value) {
2854
+					$setter = 'set_'.$property;
2855
+					if (method_exists($network_config, $setter)) {
2856
+						$network_config->{$setter}($value);
2857 2857
 					} else if (
2858
-						property_exists( $network_config, $property )
2858
+						property_exists($network_config, $property)
2859 2859
 						&& $network_config->{$property} !== $value
2860 2860
 					) {
2861 2861
 						$network_config->{$property} = $value;
2862 2862
 					}
2863 2863
 				}
2864 2864
 				//only update if the form submission was valid!
2865
-				EE_Registry::instance()->NET_CFG->update_config( true, false );
2865
+				EE_Registry::instance()->NET_CFG->update_config(true, false);
2866 2866
 				EE_Error::overwrite_success();
2867
-				EE_Error::add_success( __( 'Global message settings were updated', 'event_espresso' ) );
2867
+				EE_Error::add_success(__('Global message settings were updated', 'event_espresso'));
2868 2868
 			}
2869 2869
 		}
2870
-		$this->_redirect_after_action( 0, '', '', array( 'action' => 'settings' ), true );
2870
+		$this->_redirect_after_action(0, '', '', array('action' => 'settings'), true);
2871 2871
 	}
2872 2872
 
2873 2873
 
@@ -2878,13 +2878,13 @@  discard block
 block discarded – undo
2878 2878
 	 *
2879 2879
 	 * @return string            html formatted tabs
2880 2880
 	 */
2881
-	protected function _get_mt_tabs( $tab_array ) {
2881
+	protected function _get_mt_tabs($tab_array) {
2882 2882
 		$tab_array = (array) $tab_array;
2883
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
2883
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php';
2884 2884
 		$tabs = '';
2885 2885
 
2886
-		foreach ( $tab_array as $tab ) {
2887
-			$tabs .=  EEH_Template::display_template( $template, $tab, true );
2886
+		foreach ($tab_array as $tab) {
2887
+			$tabs .= EEH_Template::display_template($template, $tab, true);
2888 2888
 		}
2889 2889
 
2890 2890
 		return $tabs;
@@ -2900,29 +2900,29 @@  discard block
 block discarded – undo
2900 2900
 	 *
2901 2901
 	 * @return string            html formatted content
2902 2902
 	 */
2903
-	protected function _get_messenger_box_content( EE_messenger $messenger ) {
2903
+	protected function _get_messenger_box_content(EE_messenger $messenger) {
2904 2904
 
2905 2905
 		$fields = $messenger->get_admin_settings_fields();
2906 2906
 		$settings_template_args['template_form_fields'] = '';
2907 2907
 
2908 2908
 		//is $messenger active?
2909
-		$settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active( $messenger->name );
2909
+		$settings_template_args['active'] = $this->_message_resource_manager->is_messenger_active($messenger->name);
2910 2910
 
2911 2911
 
2912
-		if ( ! empty( $fields ) ) {
2912
+		if ( ! empty($fields)) {
2913 2913
 
2914 2914
 			$existing_settings = $messenger->get_existing_admin_settings();
2915 2915
 
2916
-			foreach( $fields as $fldname => $fldprops ) {
2917
-				$field_id = $messenger->name . '-' . $fldname;
2916
+			foreach ($fields as $fldname => $fldprops) {
2917
+				$field_id = $messenger->name.'-'.$fldname;
2918 2918
 				$template_form_field[$field_id] = array(
2919
-					'name' => 'messenger_settings[' . $field_id . ']',
2919
+					'name' => 'messenger_settings['.$field_id.']',
2920 2920
 					'label' => $fldprops['label'],
2921 2921
 					'input' => $fldprops['field_type'],
2922 2922
 					'type' => $fldprops['value_type'],
2923 2923
 					'required' => $fldprops['required'],
2924 2924
 					'validation' => $fldprops['validation'],
2925
-					'value' => isset( $existing_settings[$field_id])
2925
+					'value' => isset($existing_settings[$field_id])
2926 2926
 						? $existing_settings[$field_id]
2927 2927
 						: $fldprops['default'],
2928 2928
 					'css_class' => '',
@@ -2931,8 +2931,8 @@  discard block
 block discarded – undo
2931 2931
 			}
2932 2932
 
2933 2933
 
2934
-			$settings_template_args['template_form_fields'] = !empty($template_form_field)
2935
-				? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' )
2934
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field)
2935
+				? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form')
2936 2936
 				: '';
2937 2937
 		}
2938 2938
 
@@ -2949,39 +2949,39 @@  discard block
 block discarded – undo
2949 2949
 			);
2950 2950
 
2951 2951
 		//make sure any active message types that are existing are included in the hidden fields
2952
-		if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) {
2953
-			foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) {
2952
+		if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
2953
+			foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
2954 2954
 				$settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array(
2955 2955
 						'type' => 'hidden',
2956 2956
 						'value' => $mt
2957 2957
 					);
2958 2958
 			}
2959 2959
 		}
2960
-		$settings_template_args[ 'hidden_fields' ] = $this->_generate_admin_form_fields(
2961
-			$settings_template_args[ 'hidden_fields' ],
2960
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields(
2961
+			$settings_template_args['hidden_fields'],
2962 2962
 			'array'
2963 2963
 		);
2964
-		$active = $this->_message_resource_manager->is_messenger_active( $messenger->name );
2964
+		$active = $this->_message_resource_manager->is_messenger_active($messenger->name);
2965 2965
 
2966 2966
 		$settings_template_args['messenger'] = $messenger->name;
2967 2967
 		$settings_template_args['description'] = $messenger->description;
2968 2968
 		$settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
2969 2969
 
2970 2970
 
2971
-		$settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active( $messenger->name )
2971
+		$settings_template_args['show_hide_edit_form'] = $this->_message_resource_manager->is_messenger_active($messenger->name)
2972 2972
 			? $settings_template_args['show_hide_edit_form']
2973 2973
 			: ' hidden';
2974 2974
 
2975
-		$settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] )
2975
+		$settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields'])
2976 2976
 			? ' hidden'
2977 2977
 			: $settings_template_args['show_hide_edit_form'];
2978 2978
 
2979 2979
 
2980 2980
 		$settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
2981
-		$settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
2981
+		$settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce');
2982 2982
 		$settings_template_args['on_off_status'] = $active ? true : false;
2983
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
2984
-		$content = EEH_Template::display_template( $template, $settings_template_args, true);
2983
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php';
2984
+		$content = EEH_Template::display_template($template, $settings_template_args, true);
2985 2985
 		return $content;
2986 2986
 	}
2987 2987
 
@@ -2995,9 +2995,9 @@  discard block
 block discarded – undo
2995 2995
 		$success = true;
2996 2996
 		$this->_prep_default_response_for_messenger_or_message_type_toggle();
2997 2997
 		//let's check that we have required data
2998
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
2998
+		if ( ! isset($this->_req_data['messenger'])) {
2999 2999
 			EE_Error::add_error(
3000
-				__( 'Messenger name needed to toggle activation. None given', 'event_espresso' ),
3000
+				__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3001 3001
 				__FILE__,
3002 3002
 				__FUNCTION__,
3003 3003
 				__LINE__
@@ -3006,14 +3006,14 @@  discard block
 block discarded – undo
3006 3006
 		}
3007 3007
 
3008 3008
 		//do a nonce check here since we're not arriving via a normal route
3009
-		$nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : '';
3010
-		$nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
3009
+		$nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : '';
3010
+		$nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce';
3011 3011
 
3012
-		$this->_verify_nonce( $nonce, $nonce_ref );
3012
+		$this->_verify_nonce($nonce, $nonce_ref);
3013 3013
 
3014 3014
 
3015 3015
 
3016
-		if ( !isset( $this->_req_data[ 'status' ])) {
3016
+		if ( ! isset($this->_req_data['status'])) {
3017 3017
 			EE_Error::add_error(
3018 3018
 				__(
3019 3019
 					'Messenger status needed to know whether activation or deactivation is happening. No status is given',
@@ -3029,11 +3029,11 @@  discard block
 block discarded – undo
3029 3029
 		//do check to verify we have a valid status.
3030 3030
 		$status = $this->_req_data['status'];
3031 3031
 
3032
-		if ( $status != 'off' && $status != 'on' ) {
3032
+		if ($status != 'off' && $status != 'on') {
3033 3033
 			EE_Error::add_error(
3034 3034
 				sprintf(
3035
-					__( 'The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso' ),
3036
-					$this->_req_data[ 'status' ]
3035
+					__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'),
3036
+					$this->_req_data['status']
3037 3037
 				),
3038 3038
 				__FILE__,
3039 3039
 				__FUNCTION__,
@@ -3042,11 +3042,11 @@  discard block
 block discarded – undo
3042 3042
 			$success = false;
3043 3043
 		}
3044 3044
 
3045
-		if ( $success ) {
3045
+		if ($success) {
3046 3046
 			//made it here?  Stop dawdling then!!
3047 3047
 			$success = $status == 'off'
3048
-				? $this->_deactivate_messenger( $this->_req_data['messenger'] )
3049
-				: $this->_activate_messenger( $this->_req_data['messenger'] );
3048
+				? $this->_deactivate_messenger($this->_req_data['messenger'])
3049
+				: $this->_activate_messenger($this->_req_data['messenger']);
3050 3050
 		}
3051 3051
 
3052 3052
 		$this->_template_args['success'] = $success;
@@ -3069,7 +3069,7 @@  discard block
 block discarded – undo
3069 3069
 		$this->_prep_default_response_for_messenger_or_message_type_toggle();
3070 3070
 
3071 3071
 		//let's make sure we have the necessary data
3072
-		if ( ! isset( $this->_req_data[ 'message_type' ] ) ) {
3072
+		if ( ! isset($this->_req_data['message_type'])) {
3073 3073
 			EE_Error::add_error(
3074 3074
 				__('Message Type name needed to toggle activation. None given', 'event_espresso'),
3075 3075
 				__FILE__, __FUNCTION__, __LINE__
@@ -3077,7 +3077,7 @@  discard block
 block discarded – undo
3077 3077
 			$success = false;
3078 3078
 		}
3079 3079
 
3080
-		if ( ! isset( $this->_req_data[ 'messenger' ] ) ) {
3080
+		if ( ! isset($this->_req_data['messenger'])) {
3081 3081
 			EE_Error::add_error(
3082 3082
 				__('Messenger name needed to toggle activation. None given', 'event_espresso'),
3083 3083
 				__FILE__, __FUNCTION__, __LINE__
@@ -3085,7 +3085,7 @@  discard block
 block discarded – undo
3085 3085
 			$success = false;
3086 3086
 		}
3087 3087
 
3088
-		if ( ! isset( $this->_req_data[ 'status' ])) {
3088
+		if ( ! isset($this->_req_data['status'])) {
3089 3089
 			EE_Error::add_error(
3090 3090
 				__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'),
3091 3091
 				__FILE__, __FUNCTION__, __LINE__
@@ -3097,7 +3097,7 @@  discard block
 block discarded – undo
3097 3097
 		//do check to verify we have a valid status.
3098 3098
 		$status = $this->_req_data['status'];
3099 3099
 
3100
-		if ( $status != 'activate' && $status != 'deactivate' ) {
3100
+		if ($status != 'activate' && $status != 'deactivate') {
3101 3101
 			EE_Error::add_error(
3102 3102
 				sprintf(
3103 3103
 					__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'),
@@ -3110,16 +3110,16 @@  discard block
 block discarded – undo
3110 3110
 
3111 3111
 
3112 3112
 		//do a nonce check here since we're not arriving via a normal route
3113
-		$nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : '';
3114
-		$nonce_ref = $this->_req_data['message_type'] . '_nonce';
3113
+		$nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
3114
+		$nonce_ref = $this->_req_data['message_type'].'_nonce';
3115 3115
 
3116
-		$this->_verify_nonce( $nonce, $nonce_ref );
3116
+		$this->_verify_nonce($nonce, $nonce_ref);
3117 3117
 
3118
-		if ( $success ) {
3118
+		if ($success) {
3119 3119
 			//made it here? um, what are you waiting for then?
3120 3120
 			$success = $status == 'deactivate'
3121
-				? $this->_deactivate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] )
3122
-				: $this->_activate_message_type_for_messenger( $this->_req_data['messenger'], $this->_req_data['message_type'] );
3121
+				? $this->_deactivate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type'])
3122
+				: $this->_activate_message_type_for_messenger($this->_req_data['messenger'], $this->_req_data['message_type']);
3123 3123
 		}
3124 3124
 
3125 3125
 		$this->_template_args['success'] = $success;
@@ -3133,30 +3133,30 @@  discard block
 block discarded – undo
3133 3133
 	 * @param string $messenger_name The name of the messenger being activated
3134 3134
 	 * @return bool
3135 3135
 	 */
3136
-	protected function _activate_messenger( $messenger_name ) {
3136
+	protected function _activate_messenger($messenger_name) {
3137 3137
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3138
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3138
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3139 3139
 		$message_types_to_activate = $active_messenger instanceof EE_Messenger ? $active_messenger->get_default_message_types() : array();
3140 3140
 
3141 3141
 		//ensure is active
3142
-		$this->_message_resource_manager->activate_messenger( $messenger_name, $message_types_to_activate );
3142
+		$this->_message_resource_manager->activate_messenger($messenger_name, $message_types_to_activate);
3143 3143
 
3144 3144
 		//set response_data for reload
3145
-		foreach( $message_types_to_activate as $message_type_name ) {
3145
+		foreach ($message_types_to_activate as $message_type_name) {
3146 3146
 			/** @var EE_message_type $message_type */
3147
-			$message_type = $this->_message_resource_manager->get_message_type( $message_type_name );
3148
-			if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name )
3147
+			$message_type = $this->_message_resource_manager->get_message_type($message_type_name);
3148
+			if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)
3149 3149
 			     && $message_type instanceof EE_message_type
3150 3150
 			) {
3151 3151
 				$this->_template_args['data']['active_mts'][] = $message_type_name;
3152
-				if ( $message_type->get_admin_settings_fields() ) {
3152
+				if ($message_type->get_admin_settings_fields()) {
3153 3153
 					$this->_template_args['data']['mt_reload'][] = $message_type_name;
3154 3154
 				}
3155 3155
 			}
3156 3156
 		}
3157 3157
 
3158 3158
 		//add success message for activating messenger
3159
-		return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger );
3159
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger);
3160 3160
 
3161 3161
 	}
3162 3162
 
@@ -3167,11 +3167,11 @@  discard block
 block discarded – undo
3167 3167
 	 * @param string $messenger_name The name of the messenger being activated
3168 3168
 	 * @return bool
3169 3169
 	 */
3170
-	protected function _deactivate_messenger( $messenger_name ) {
3170
+	protected function _deactivate_messenger($messenger_name) {
3171 3171
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3172
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3173
-		$this->_message_resource_manager->deactivate_messenger( $messenger_name );
3174
-		return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger );
3172
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3173
+		$this->_message_resource_manager->deactivate_messenger($messenger_name);
3174
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger);
3175 3175
 	}
3176 3176
 
3177 3177
 
@@ -3182,23 +3182,23 @@  discard block
 block discarded – undo
3182 3182
 	 * @param string $message_type_name  The name of the message type being activated for the messenger
3183 3183
 	 * @return bool
3184 3184
 	 */
3185
-	protected function _activate_message_type_for_messenger( $messenger_name, $message_type_name ) {
3185
+	protected function _activate_message_type_for_messenger($messenger_name, $message_type_name) {
3186 3186
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3187
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3187
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3188 3188
 		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/
3189
-		$message_type_to_activate = $this->_message_resource_manager->get_message_type( $message_type_name );
3189
+		$message_type_to_activate = $this->_message_resource_manager->get_message_type($message_type_name);
3190 3190
 
3191 3191
 		//ensure is active
3192
-		$this->_message_resource_manager->activate_messenger( $messenger_name, $message_type_name );
3192
+		$this->_message_resource_manager->activate_messenger($messenger_name, $message_type_name);
3193 3193
 
3194 3194
 		//set response for load
3195
-		if ( $this->_message_resource_manager->is_message_type_active_for_messenger( $messenger_name, $message_type_name ) ) {
3195
+		if ($this->_message_resource_manager->is_message_type_active_for_messenger($messenger_name, $message_type_name)) {
3196 3196
 			$this->_template_args['data']['active_mts'][] = $message_type_name;
3197
-			if ( $message_type_to_activate->get_admin_settings_fields() ) {
3197
+			if ($message_type_to_activate->get_admin_settings_fields()) {
3198 3198
 				$this->_template_args['data']['mt_reload'][] = $message_type_name;
3199 3199
 			}
3200 3200
 		}
3201
-		return $this->_setup_response_message_for_activating_messenger_with_message_types( $active_messenger, $message_type_to_activate );
3201
+		return $this->_setup_response_message_for_activating_messenger_with_message_types($active_messenger, $message_type_to_activate);
3202 3202
 	}
3203 3203
 
3204 3204
 
@@ -3210,13 +3210,13 @@  discard block
 block discarded – undo
3210 3210
 	 * @param string $message_type_name  The name of the message type being deactivated for the messenger
3211 3211
 	 * @return bool
3212 3212
 	 */
3213
-	protected function _deactivate_message_type_for_messenger( $messenger_name, $message_type_name ) {
3213
+	protected function _deactivate_message_type_for_messenger($messenger_name, $message_type_name) {
3214 3214
 		/** @var EE_messenger $active_messenger  This will be present because it can't be toggled if it isn't*/
3215
-		$active_messenger = $this->_message_resource_manager->get_messenger( $messenger_name );
3215
+		$active_messenger = $this->_message_resource_manager->get_messenger($messenger_name);
3216 3216
 		/** @var EE_message_type $message_type_to_activate This will be present because it can't be toggled if it isn't*/
3217
-		$message_type_to_deactivate = $this->_message_resource_manager->get_message_type( $message_type_name );
3218
-		$this->_message_resource_manager->deactivate_message_type_for_messenger( $message_type_name, $messenger_name );
3219
-		return $this->_setup_response_message_for_deactivating_messenger_with_message_types( $active_messenger, $message_type_to_deactivate );
3217
+		$message_type_to_deactivate = $this->_message_resource_manager->get_message_type($message_type_name);
3218
+		$this->_message_resource_manager->deactivate_message_type_for_messenger($message_type_name, $messenger_name);
3219
+		return $this->_setup_response_message_for_deactivating_messenger_with_message_types($active_messenger, $message_type_to_deactivate);
3220 3220
 	}
3221 3221
 
3222 3222
 
@@ -3247,9 +3247,9 @@  discard block
 block discarded – undo
3247 3247
 		EE_Message_Type $message_type = null
3248 3248
 	) {
3249 3249
 		//if $messenger isn't a valid messenger object then get out.
3250
-		if ( ! $messenger instanceof EE_Messenger ) {
3250
+		if ( ! $messenger instanceof EE_Messenger) {
3251 3251
 			EE_Error::add_error(
3252
-				__( 'The messenger being activated is not a valid messenger', 'event_espresso' ),
3252
+				__('The messenger being activated is not a valid messenger', 'event_espresso'),
3253 3253
 				__FILE__,
3254 3254
 				__FUNCTION__,
3255 3255
 				__LINE__
@@ -3257,32 +3257,32 @@  discard block
 block discarded – undo
3257 3257
 			return false;
3258 3258
 		}
3259 3259
 		//activated
3260
-		if ( $this->_template_args['data']['active_mts'] ) {
3260
+		if ($this->_template_args['data']['active_mts']) {
3261 3261
 			EE_Error::overwrite_success();
3262 3262
 			//activated a message type with the messenger
3263
-			if ( $message_type instanceof EE_message_type ) {
3263
+			if ($message_type instanceof EE_message_type) {
3264 3264
 				EE_Error::add_success(
3265 3265
 					sprintf(
3266 3266
 						__('%s message type has been successfully activated with the %s messenger', 'event_espresso'),
3267
-						ucwords( $message_type->label['singular'] ),
3268
-						ucwords( $messenger->label['singular'] )
3267
+						ucwords($message_type->label['singular']),
3268
+						ucwords($messenger->label['singular'])
3269 3269
 					)
3270 3270
 				);
3271 3271
 
3272 3272
 				//if message type was invoice then let's make sure we activate the invoice payment method.
3273
-				if ( $message_type->name == 'invoice' ) {
3274
-					EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
3275
-					$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
3276
-					if ( $pm instanceof EE_Payment_Method ) {
3277
-						EE_Error::add_attention( __('Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso' ) );
3273
+				if ($message_type->name == 'invoice') {
3274
+					EE_Registry::instance()->load_lib('Payment_Method_Manager');
3275
+					$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
3276
+					if ($pm instanceof EE_Payment_Method) {
3277
+						EE_Error::add_attention(__('Activating the invoice message type also automatically activates the invoice payment method.  If you do not wish the invoice payment method to be active, or to change its settings, visit the payment method admin page.', 'event_espresso'));
3278 3278
 					}
3279 3279
 				}
3280 3280
 			//just toggles the entire messenger
3281 3281
 			} else {
3282 3282
 				EE_Error::add_success(
3283 3283
 					sprintf(
3284
-						__( '%s messenger has been successfully activated', 'event_espresso' ),
3285
-						ucwords( $messenger->label[ 'singular' ] )
3284
+						__('%s messenger has been successfully activated', 'event_espresso'),
3285
+						ucwords($messenger->label['singular'])
3286 3286
 					)
3287 3287
 				);
3288 3288
 			}
@@ -3292,12 +3292,12 @@  discard block
 block discarded – undo
3292 3292
 		//message types after the activation process.  However its possible some messengers don't HAVE any default_message_types
3293 3293
 		//in which case we just give a success message for the messenger being successfully activated.
3294 3294
 		} else {
3295
-			if ( ! $messenger->get_default_message_types() ) {
3295
+			if ( ! $messenger->get_default_message_types()) {
3296 3296
 				//messenger doesn't have any default message types so still a success.
3297 3297
 				EE_Error::add_success(
3298 3298
 					sprintf(
3299
-						__('%s messenger was successfully activated.', 'event_espresso' ),
3300
-						ucwords( $messenger->label['singular'] )
3299
+						__('%s messenger was successfully activated.', 'event_espresso'),
3300
+						ucwords($messenger->label['singular'])
3301 3301
 						)
3302 3302
 				);
3303 3303
 				return true;
@@ -3305,13 +3305,13 @@  discard block
 block discarded – undo
3305 3305
 				EE_Error::add_error(
3306 3306
 					$message_type instanceof EE_message_type
3307 3307
 						? sprintf(
3308
-						__( '%s message type was not successfully activated with the %s messenger', 'event_espresso' ),
3309
-						ucwords( $message_type->label['singular'] ),
3310
-						ucwords( $messenger->label['singular'] )
3308
+						__('%s message type was not successfully activated with the %s messenger', 'event_espresso'),
3309
+						ucwords($message_type->label['singular']),
3310
+						ucwords($messenger->label['singular'])
3311 3311
 					)
3312 3312
 						: sprintf(
3313
-						__( '%s messenger was not successfully activated', 'event_espresso' ),
3314
-						ucwords( $messenger->label['singular'] )
3313
+						__('%s messenger was not successfully activated', 'event_espresso'),
3314
+						ucwords($messenger->label['singular'])
3315 3315
 					),
3316 3316
 					__FILE__,
3317 3317
 					__FUNCTION__,
@@ -3339,9 +3339,9 @@  discard block
 block discarded – undo
3339 3339
 		EE_Error::overwrite_success();
3340 3340
 
3341 3341
 		//if $messenger isn't a valid messenger object then get out.
3342
-		if ( ! $messenger instanceof EE_Messenger ) {
3342
+		if ( ! $messenger instanceof EE_Messenger) {
3343 3343
 			EE_Error::add_error(
3344
-				__( 'The messenger being deactivated is not a valid messenger', 'event_espresso' ),
3344
+				__('The messenger being deactivated is not a valid messenger', 'event_espresso'),
3345 3345
 				__FILE__,
3346 3346
 				__FUNCTION__,
3347 3347
 				__LINE__
@@ -3349,13 +3349,13 @@  discard block
 block discarded – undo
3349 3349
 			return false;
3350 3350
 		}
3351 3351
 
3352
-		if ( $message_type instanceof EE_message_type ) {
3352
+		if ($message_type instanceof EE_message_type) {
3353 3353
 			$message_type_name = $message_type->name;
3354 3354
 			EE_Error::add_success(
3355 3355
 				sprintf(
3356 3356
 					__('%s message type has been successfully deactivated for the %s messenger.', 'event_espresso'),
3357
-					ucwords( $message_type->label['singular'] ),
3358
-					ucwords ( $messenger->label['singular'] )
3357
+					ucwords($message_type->label['singular']),
3358
+					ucwords($messenger->label['singular'])
3359 3359
 				)
3360 3360
 			);
3361 3361
 		} else {
@@ -3363,20 +3363,20 @@  discard block
 block discarded – undo
3363 3363
 			EE_Error::add_success(
3364 3364
 				sprintf(
3365 3365
 					__('%s messenger has been successfully deactivated.', 'event_espresso'),
3366
-					ucwords( $messenger->label['singular'] )
3366
+					ucwords($messenger->label['singular'])
3367 3367
 				)
3368 3368
 			);
3369 3369
 		}
3370 3370
 
3371 3371
 		//if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
3372
-		if ( $messenger->name == 'html'  || $message_type_name == 'invoice') {
3373
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
3374
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' );
3375
-			if ( $count_updated > 0 ) {
3372
+		if ($messenger->name == 'html' || $message_type_name == 'invoice') {
3373
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
3374
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
3375
+			if ($count_updated > 0) {
3376 3376
 				$msg = $message_type_name == 'invoice'
3377
-					? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' )
3378
-					: __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' );
3379
-				EE_Error::add_attention( $msg );
3377
+					? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso')
3378
+					: __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso');
3379
+				EE_Error::add_attention($msg);
3380 3380
 			}
3381 3381
 		}
3382 3382
 		return true;
@@ -3387,17 +3387,17 @@  discard block
 block discarded – undo
3387 3387
 	 * handles updating a message type form on messenger activation IF the message type has settings fields. (via ajax)
3388 3388
 	 */
3389 3389
 	public function update_mt_form() {
3390
-		if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) {
3391
-			EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ );
3390
+		if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) {
3391
+			EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__);
3392 3392
 			$this->_return_json();
3393 3393
 		}
3394 3394
 
3395 3395
 		$message_types = $this->get_installed_message_types();
3396 3396
 
3397
-		$message_type = $message_types[ $this->_req_data['message_type'] ];
3398
-		$messenger = $this->_message_resource_manager->get_active_messenger( $this->_req_data['messenger'] );
3397
+		$message_type = $message_types[$this->_req_data['message_type']];
3398
+		$messenger = $this->_message_resource_manager->get_active_messenger($this->_req_data['messenger']);
3399 3399
 
3400
-		$content = $this->_message_type_settings_content ( $message_type, $messenger, true );
3400
+		$content = $this->_message_type_settings_content($message_type, $messenger, true);
3401 3401
 		$this->_template_args['success'] = true;
3402 3402
 		$this->_template_args['content'] = $content;
3403 3403
 		$this->_return_json();
@@ -3411,45 +3411,45 @@  discard block
 block discarded – undo
3411 3411
 	 *
3412 3412
 	 */
3413 3413
 	public function save_settings() {
3414
-		if ( !isset( $this->_req_data['type'] ) ) {
3415
-			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
3414
+		if ( ! isset($this->_req_data['type'])) {
3415
+			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
3416 3416
 			$this->_template_args['error'] = true;
3417 3417
 			$this->_return_json();
3418 3418
 		}
3419 3419
 
3420 3420
 
3421
-		if ( $this->_req_data['type'] == 'messenger' ) {
3421
+		if ($this->_req_data['type'] == 'messenger') {
3422 3422
 			$settings = $this->_req_data['messenger_settings']; //this should be an array.
3423 3423
 			$messenger = $settings['messenger'];
3424 3424
 			//let's setup the settings data
3425
-			foreach ( $settings as $key => $value ) {
3426
-				switch ( $key ) {
3425
+			foreach ($settings as $key => $value) {
3426
+				switch ($key) {
3427 3427
 					case 'messenger' :
3428
-						unset( $settings['messenger'] );
3428
+						unset($settings['messenger']);
3429 3429
 						break;
3430 3430
 					case 'message_types' :
3431
-						unset( $settings['message_types'] );
3431
+						unset($settings['message_types']);
3432 3432
 						break;
3433 3433
 					default :
3434 3434
 						$settings[$key] = $value;
3435 3435
 						break;
3436 3436
 				}
3437 3437
 			}
3438
-			$this->_message_resource_manager->add_settings_for_messenger( $messenger, $settings );
3438
+			$this->_message_resource_manager->add_settings_for_messenger($messenger, $settings);
3439 3439
 		}
3440 3440
 
3441
-		else if ( $this->_req_data['type'] == 'message_type' ) {
3441
+		else if ($this->_req_data['type'] == 'message_type') {
3442 3442
 			$settings = $this->_req_data['message_type_settings'];
3443 3443
 			$messenger = $settings['messenger'];
3444 3444
 			$message_type = $settings['message_type'];
3445 3445
 
3446
-			foreach ( $settings as $key => $value ) {
3447
-				switch ( $key ) {
3446
+			foreach ($settings as $key => $value) {
3447
+				switch ($key) {
3448 3448
 					case 'messenger' :
3449
-						unset( $settings['messenger'] );
3449
+						unset($settings['messenger']);
3450 3450
 						break;
3451 3451
 					case 'message_type' :
3452
-						unset( $settings['message_type'] );
3452
+						unset($settings['message_type']);
3453 3453
 						break;
3454 3454
 					default :
3455 3455
 						$settings[$key] = $value;
@@ -3457,16 +3457,16 @@  discard block
 block discarded – undo
3457 3457
 				}
3458 3458
 			}
3459 3459
 
3460
-			$this->_message_resource_manager->add_settings_for_message_type( $messenger, $message_type, $settings );
3460
+			$this->_message_resource_manager->add_settings_for_message_type($messenger, $message_type, $settings);
3461 3461
 		}
3462 3462
 
3463 3463
 		//okay we should have the data all setup.  Now we just update!
3464 3464
 		$success = $this->_message_resource_manager->update_active_messengers_option();
3465 3465
 
3466
-		if ( $success ) {
3467
-			EE_Error::add_success( __('Settings updated', 'event_espresso') );
3466
+		if ($success) {
3467
+			EE_Error::add_success(__('Settings updated', 'event_espresso'));
3468 3468
 		} else {
3469
-			EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
3469
+			EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
3470 3470
 		}
3471 3471
 
3472 3472
 		$this->_template_args['success'] = $success;
@@ -3488,8 +3488,8 @@  discard block
 block discarded – undo
3488 3488
      */
3489 3489
 	protected function _generate_now() {
3490 3490
 		$msg_ids = $this->_get_msg_ids_from_request();
3491
-		EED_Messages::generate_now( $msg_ids );
3492
-		$this->_redirect_after_action( false, '', '', array(), true );
3491
+		EED_Messages::generate_now($msg_ids);
3492
+		$this->_redirect_after_action(false, '', '', array(), true);
3493 3493
 	}
3494 3494
 
3495 3495
 
@@ -3504,7 +3504,7 @@  discard block
 block discarded – undo
3504 3504
 	protected function _generate_and_send_now() {
3505 3505
 		$this->_generate_now();
3506 3506
 		$this->_send_now();
3507
-		$this->_redirect_after_action( false, '', '', array(), true );
3507
+		$this->_redirect_after_action(false, '', '', array(), true);
3508 3508
 	}
3509 3509
 
3510 3510
 
@@ -3518,8 +3518,8 @@  discard block
 block discarded – undo
3518 3518
      */
3519 3519
 	protected function _queue_for_resending() {
3520 3520
 		$msg_ids = $this->_get_msg_ids_from_request();
3521
-		EED_Messages::queue_for_resending( $msg_ids );
3522
-		$this->_redirect_after_action( false, '', '', array(), true );
3521
+		EED_Messages::queue_for_resending($msg_ids);
3522
+		$this->_redirect_after_action(false, '', '', array(), true);
3523 3523
 	}
3524 3524
 
3525 3525
 
@@ -3532,8 +3532,8 @@  discard block
 block discarded – undo
3532 3532
      */
3533 3533
 	protected function _send_now() {
3534 3534
 		$msg_ids = $this->_get_msg_ids_from_request();
3535
-		EED_Messages::send_now( $msg_ids );
3536
-		$this->_redirect_after_action( false, '', '', array(), true );
3535
+		EED_Messages::send_now($msg_ids);
3536
+		$this->_redirect_after_action(false, '', '', array(), true);
3537 3537
 	}
3538 3538
 
3539 3539
 
@@ -3547,23 +3547,23 @@  discard block
 block discarded – undo
3547 3547
 	protected function _delete_ee_messages() {
3548 3548
 		$msg_ids = $this->_get_msg_ids_from_request();
3549 3549
 		$deleted_count = 0;
3550
-		foreach ( $msg_ids as $msg_id ) {
3551
-			if ( EEM_Message::instance()->delete_by_ID( $msg_id ) ) {
3550
+		foreach ($msg_ids as $msg_id) {
3551
+			if (EEM_Message::instance()->delete_by_ID($msg_id)) {
3552 3552
 				$deleted_count++;
3553 3553
 			}
3554 3554
 		}
3555
-		if ( $deleted_count ) {
3555
+		if ($deleted_count) {
3556 3556
 			$this->_redirect_after_action(
3557 3557
 				true,
3558
-				_n( 'message', 'messages', $deleted_count, 'event_espresso' ),
3558
+				_n('message', 'messages', $deleted_count, 'event_espresso'),
3559 3559
 				__('deleted', 'event_espresso')
3560 3560
 			);
3561 3561
 		} else {
3562 3562
 			EE_Error::add_error(
3563
-				_n( 'The message was not deleted.', 'The messages were not deleted', count( $msg_ids ), 'event_espresso' ),
3563
+				_n('The message was not deleted.', 'The messages were not deleted', count($msg_ids), 'event_espresso'),
3564 3564
 				__FILE__, __FUNCTION__, __LINE__
3565 3565
 			);
3566
-			$this->_redirect_after_action( false, '', '', array(), true );
3566
+			$this->_redirect_after_action(false, '', '', array(), true);
3567 3567
 		}
3568 3568
 	}
3569 3569
 
@@ -3576,10 +3576,10 @@  discard block
 block discarded – undo
3576 3576
      *  @return array
3577 3577
      */
3578 3578
 	protected function _get_msg_ids_from_request() {
3579
-		if ( ! isset( $this->_req_data['MSG_ID'] ) ) {
3579
+		if ( ! isset($this->_req_data['MSG_ID'])) {
3580 3580
 			return array();
3581 3581
 		}
3582
-		return is_array( $this->_req_data['MSG_ID'] ) ? array_keys( $this->_req_data['MSG_ID'] ) : array( $this->_req_data['MSG_ID'] );
3582
+		return is_array($this->_req_data['MSG_ID']) ? array_keys($this->_req_data['MSG_ID']) : array($this->_req_data['MSG_ID']);
3583 3583
 	}
3584 3584
 
3585 3585
 
Please login to merge, or discard this patch.
admin_pages/support/Support_Admin_Page.core.php 1 patch
Spacing   +19 added lines, -19 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
 /**
@@ -30,8 +30,8 @@  discard block
 block discarded – undo
30 30
 class Support_Admin_Page extends EE_Admin_Page {
31 31
 
32 32
 
33
-	public function __construct( $routing = TRUE ) {
34
-		parent::__construct( $routing );
33
+	public function __construct($routing = TRUE) {
34
+		parent::__construct($routing);
35 35
 	}
36 36
 
37 37
 
@@ -84,14 +84,14 @@  discard block
 block discarded – undo
84 84
 				'nav' => array(
85 85
 					'label' => __('Shortcodes', 'event_espresso'),
86 86
 					'order' => 30),
87
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array('_shortcodes_boxes' ) ),
87
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_shortcodes_boxes')),
88 88
 				'require_nonce' => FALSE
89 89
 				),
90 90
 			'contact_support' => array(
91 91
 				'nav' => array(
92 92
 					'label' => __('Support', 'event_espresso'),
93 93
 					'order' => 40),
94
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_support_boxes' ) ),
94
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_support_boxes')),
95 95
 				'require_nonce' => FALSE
96 96
 				),
97 97
 			'developers' => array(
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
 
120 120
 
121 121
 	protected function _installation() {
122
-		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_installation.template.php';
123
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE);
122
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_installation.template.php';
123
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE);
124 124
 		$this->display_admin_page_with_sidebar();
125 125
 	}
126 126
 
@@ -145,10 +145,10 @@  discard block
 block discarded – undo
145 145
 			'other_resources' => __('Other Resources', 'event_espresso')
146 146
 			);
147 147
 
148
-		foreach ( $boxes as $box => $label ) {
149
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
148
+		foreach ($boxes as $box => $label) {
149
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
150 150
 			$callback_args = array('template_path' => $template_path);
151
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
151
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
152 152
 		}
153 153
 	}
154 154
 
@@ -169,15 +169,15 @@  discard block
 block discarded – undo
169 169
 			'shortcodes_event_listings' => __('Event Listings', 'event_espresso'),
170 170
 			'shortcodes_ticket_selector' => __('Event Ticket Selector', 'event_espresso'),
171 171
 			'shortcodes_category' => __('Event Categories', 'event_espresso'),
172
-			'shortcodes_attendee' => __( 'Event Attendees', 'event_espresso' )
172
+			'shortcodes_attendee' => __('Event Attendees', 'event_espresso')
173 173
 			/*'shortcodes_single_events' => __('Single Events', 'event_espresso'),*/
174 174
 			/*'shortcodes_attendee_listings' => __('Attendee Listings', 'event_espresso'),*/
175 175
 			);
176 176
 
177
-		foreach ( $boxes as $box => $label ) {
178
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
177
+		foreach ($boxes as $box => $label) {
178
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
179 179
 			$callback_args = array('template_path' => $template_path);
180
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
180
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
181 181
 		}
182 182
 	}
183 183
 
@@ -196,17 +196,17 @@  discard block
 block discarded – undo
196 196
 			'important_information' => __('Important Information', 'event_espresso')
197 197
 			);
198 198
 
199
-		foreach ( $boxes as $box => $label ) {
200
-			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'support_admin_details_' . $box . '.template.php';
199
+		foreach ($boxes as $box => $label) {
200
+			$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'support_admin_details_'.$box.'.template.php';
201 201
 			$callback_args = array('template_path' => $template_path, 'template_args' => $this->_template_args);
202
-			add_meta_box( 'espresso_' . $box . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
202
+			add_meta_box('espresso_'.$box.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen->id, 'normal', 'high', $callback_args);
203 203
 		}
204 204
 	}
205 205
 
206 206
 
207 207
 	protected function _developers() {
208
-		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH . 'developers_admin_details.template.php';
209
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true );
208
+		$template_path = EE_SUPPORT_ADMIN_TEMPLATE_PATH.'developers_admin_details.template.php';
209
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, array(), true);
210 210
 		$this->display_admin_page_with_sidebar();
211 211
 	}
212 212
 } //end Support_Admin_Page class
Please login to merge, or discard this patch.
caffeinated/admin/extend/support/Extend_Support_Admin_Page.core.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 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
 /**
@@ -29,16 +29,16 @@  discard block
 block discarded – undo
29 29
  */
30 30
 class Extend_Support_Admin_Page extends Support_Admin_Page {
31 31
 
32
-	public function __construct( $routing = TRUE ) {
33
-		parent::__construct( $routing );
34
-		define( 'EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'support/templates/' );
32
+	public function __construct($routing = TRUE) {
33
+		parent::__construct($routing);
34
+		define('EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'support/templates/');
35 35
 	}
36 36
 
37 37
 
38 38
 
39 39
 
40 40
 	protected function _extend_page_config() {
41
-		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'support';
41
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'support';
42 42
 		//new routes and new configs (or overrides )
43 43
 		$new_page_routes = array(
44 44
 			'faq' => array(
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 				'capability' => 'ee_read_ee'
47 47
 				)
48 48
 			);
49
-		$this->_page_routes = array_merge( $this->_page_routes, $new_page_routes );
49
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
50 50
 
51 51
 		$new_page_config = array(
52 52
 			'faq' => array(
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
 				'require_nonce' => FALSE
58 58
 				)
59 59
 			);
60
-		$this->_page_config = array_merge( $this->_page_config, $new_page_config );
60
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
61 61
 
62 62
 		$this->_page_config['default']['metaboxes'][] = '_installation_boxes';
63 63
 	}
@@ -66,8 +66,8 @@  discard block
 block discarded – undo
66 66
 
67 67
 
68 68
 	protected function _faq() {
69
-		$template_path = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH . 'support_admin_details_faq.template.php';
70
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $template_path, '', TRUE);
69
+		$template_path = EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH.'support_admin_details_faq.template.php';
70
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($template_path, '', TRUE);
71 71
 		$this->display_admin_page_with_sidebar();
72 72
 
73 73
 	}
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 
76 76
 
77 77
 	protected function _installation_boxes() {
78
-		$callback_args = array('template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH . 'support_admin_details_additional_information.template.php');
79
-		add_meta_box( 'espresso_additional_information_support', __('Additional Information', 'event_espresso'), create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE);' ), $this->_current_screen->id, 'normal', 'high', $callback_args);
78
+		$callback_args = array('template_path' => EE_SUPPORT_CAF_ADMIN_TEMPLATE_PATH.'support_admin_details_additional_information.template.php');
79
+		add_meta_box('espresso_additional_information_support', __('Additional Information', 'event_espresso'), create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], "", TRUE);'), $this->_current_screen->id, 'normal', 'high', $callback_args);
80 80
 	}
81 81
 
82 82
 
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Processor.lib.php 1 patch
Spacing   +108 added lines, -108 removed lines patch added patch discarded remove patch
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 *
36 36
 	 * @param EE_Message_Resource_Manager $message_resource_manager
37 37
 	 */
38
-	public function __construct( EE_Message_Resource_Manager $message_resource_manager ) {
38
+	public function __construct(EE_Message_Resource_Manager $message_resource_manager) {
39 39
 		$this->_message_resource_manager = $message_resource_manager;
40 40
 		$this->_init_queue_and_generator();
41 41
 	}
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 	 * - $_generator = holds the messages generator
51 51
 	 */
52 52
 	protected function _init_queue_and_generator() {
53
-		$this->_generator = EE_Registry::factory( 'EE_Messages_Generator' );
53
+		$this->_generator = EE_Registry::factory('EE_Messages_Generator');
54 54
 		$this->_queue = $this->_generator->generation_queue();
55 55
 	}
56 56
 
@@ -75,31 +75,31 @@  discard block
 block discarded – undo
75 75
 	 * @param EE_Messages_Queue $queue_to_process
76 76
 	 * @return bool  true for success false for error.
77 77
 	 */
78
-	public function process_immediately_from_queue( EE_Messages_Queue $queue_to_process ) {
78
+	public function process_immediately_from_queue(EE_Messages_Queue $queue_to_process) {
79 79
 		$success = false;
80 80
 		$messages_to_send = array();
81 81
 		$messages_to_generate = array();
82 82
 		//loop through and setup the various messages from the queue so we know what is being processed
83 83
 		$queue_to_process->get_message_repository()->rewind();
84
-		foreach ( $queue_to_process->get_message_repository() as $message ) {
85
-			if ( $message->STS_ID() === EEM_Message::status_incomplete ) {
84
+		foreach ($queue_to_process->get_message_repository() as $message) {
85
+			if ($message->STS_ID() === EEM_Message::status_incomplete) {
86 86
 				$messages_to_generate[] = $message;
87 87
 				continue;
88 88
 			}
89 89
 
90
-			if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) {
90
+			if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) {
91 91
 				$messages_to_send[] = $message;
92 92
 				continue;
93 93
 			}
94 94
 		}
95 95
 
96 96
 		//do generation/sends
97
-		if ( $messages_to_generate ) {
98
-			$success = $this->batch_generate_from_queue( $messages_to_generate, true );
97
+		if ($messages_to_generate) {
98
+			$success = $this->batch_generate_from_queue($messages_to_generate, true);
99 99
 		}
100 100
 
101
-		if ( $messages_to_send ) {
102
-			$sent = $this->batch_send_from_queue( $messages_to_send, true );
101
+		if ($messages_to_send) {
102
+			$sent = $this->batch_send_from_queue($messages_to_send, true);
103 103
 			//if there was messages to generate and it failed, then we override any success value for the sending process
104 104
 			//otherwise we just use the return from batch send.  The intent is that there is a simple response for success/fail.
105 105
 			//Either everything was successful or we consider it a fail.  To be clear, this is a limitation of doing
@@ -119,13 +119,13 @@  discard block
 block discarded – undo
119 119
 	 * @return bool|EE_Messages_Queue return false if nothing generated.  This returns a new EE_Message_Queue with
120 120
 	 *                                   generated messages.
121 121
 	 */
122
-	public function batch_generate_from_queue( $messages = array(), $clear_queue = false ) {
123
-		if ( $this->_build_queue_for_generation( $messages, $clear_queue ) ) {
122
+	public function batch_generate_from_queue($messages = array(), $clear_queue = false) {
123
+		if ($this->_build_queue_for_generation($messages, $clear_queue)) {
124 124
 			$new_queue = $this->_generator->generate();
125
-			if ( $new_queue instanceof EE_Messages_Queue ) {
125
+			if ($new_queue instanceof EE_Messages_Queue) {
126 126
 				//unlock queue
127 127
 				$this->_queue->unlock_queue();
128
-				$new_queue->initiate_request_by_priority( 'send' );
128
+				$new_queue->initiate_request_by_priority('send');
129 129
 				return $new_queue;
130 130
 			}
131 131
 		}
@@ -146,24 +146,24 @@  discard block
 block discarded – undo
146 146
 	 *
147 147
 	 * @return bool true means queue prepped, false means there was a lock so no generation please.
148 148
 	 */
149
-	protected function _build_queue_for_generation( $messages = array(), $clear_queue = false ) {
149
+	protected function _build_queue_for_generation($messages = array(), $clear_queue = false) {
150 150
 
151
-		if ( $clear_queue ) {
151
+		if ($clear_queue) {
152 152
 			$this->_init_queue_and_generator();
153 153
 		}
154 154
 
155
-		if ( $messages ) {
155
+		if ($messages) {
156 156
 			//if generation is locked then get out now because that means processing is already happening.
157
-			if ( $this->_queue->is_locked() ) {
157
+			if ($this->_queue->is_locked()) {
158 158
 				return false;
159 159
 			}
160 160
 
161 161
 			$this->_queue->lock_queue();
162
-			$messages = is_array( $messages ) ? $messages : array( $messages );
163
-			foreach ( $messages as $message ) {
164
-				if ( $message instanceof EE_Message ) {
162
+			$messages = is_array($messages) ? $messages : array($messages);
163
+			foreach ($messages as $message) {
164
+				if ($message instanceof EE_Message) {
165 165
 					$data = $message->all_extra_meta_array();
166
-					$this->_queue->add( $message, $data );
166
+					$this->_queue->add($message, $data);
167 167
 				}
168 168
 			}
169 169
 			return true;
@@ -181,22 +181,22 @@  discard block
 block discarded – undo
181 181
 	 *
182 182
 	 * @return bool true means queue prepped, false means there was a lock so no queue prepped.
183 183
 	 */
184
-	protected function _build_queue_for_sending( $messages, $clear_queue = false ) {
184
+	protected function _build_queue_for_sending($messages, $clear_queue = false) {
185 185
 		//if sending is locked then get out now because that means processing is already happening.
186
-		if ( $this->_queue->is_locked( EE_Messages_Queue::action_sending ) ) {
186
+		if ($this->_queue->is_locked(EE_Messages_Queue::action_sending)) {
187 187
 			return false;
188 188
 		}
189 189
 
190
-		$this->_queue->lock_queue( EE_Messages_Queue::action_sending );
190
+		$this->_queue->lock_queue(EE_Messages_Queue::action_sending);
191 191
 
192
-		if ( $clear_queue ) {
192
+		if ($clear_queue) {
193 193
 			$this->_init_queue_and_generator();
194 194
 		}
195 195
 
196
-		$messages = is_array( $messages ) ? $messages : array( $messages );
196
+		$messages = is_array($messages) ? $messages : array($messages);
197 197
 
198
-		foreach ( $messages as $message ) {
199
-			$this->_queue->add( $message );
198
+		foreach ($messages as $message) {
199
+			$this->_queue->add($message);
200 200
 		}
201 201
 		return true;
202 202
 	}
@@ -212,11 +212,11 @@  discard block
 block discarded – undo
212 212
 	 *
213 213
 	 * @return EE_Messages_Queue
214 214
 	 */
215
-	public function batch_send_from_queue( $messages = array(), $clear_queue = false ) {
215
+	public function batch_send_from_queue($messages = array(), $clear_queue = false) {
216 216
 
217
-		if ( $messages && $this->_build_queue_for_sending( $messages, $clear_queue ) ) {
217
+		if ($messages && $this->_build_queue_for_sending($messages, $clear_queue)) {
218 218
 			$this->_queue->execute();
219
-			$this->_queue->unlock_queue( EE_Messages_Queue::action_sending );
219
+			$this->_queue->unlock_queue(EE_Messages_Queue::action_sending);
220 220
 		} else {
221 221
 			//get messages to send and execute.
222 222
 			$this->_queue->get_to_send_batch_and_send();
@@ -239,10 +239,10 @@  discard block
 block discarded – undo
239 239
 	 * @param EE_Message_To_Generate[] $messages_to_generate
240 240
 	 * @return EE_Messages_Queue
241 241
 	 */
242
-	public function generate_and_return(  $messages_to_generate ) {
242
+	public function generate_and_return($messages_to_generate) {
243 243
 		$this->_init_queue_and_generator();
244
-		$this->_queue_for_generation_loop( $messages_to_generate );
245
-		return $this->_generator->generate( false );
244
+		$this->_queue_for_generation_loop($messages_to_generate);
245
+		return $this->_generator->generate(false);
246 246
 	}
247 247
 
248 248
 
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	 * @param  bool     $persist    Indicate whether to instruct the generator to persist the generated queue (true) or not (false).
254 254
 	 * @return EE_Messages_Queue
255 255
 	 */
256
-	public function generate_queue( $persist = true ) {
257
-		return $this->_generator->generate( $persist );
256
+	public function generate_queue($persist = true) {
257
+		return $this->_generator->generate($persist);
258 258
 	}
259 259
 
260 260
 
@@ -267,9 +267,9 @@  discard block
 block discarded – undo
267 267
 	 * @param bool                   $test_send             Whether this item is for a test send or not.
268 268
 	 * @return  EE_Messages_Queue
269 269
 	 */
270
-	public function queue_for_generation( EE_Message_To_Generate $message_to_generate, $test_send = false ) {
271
-		if ( $message_to_generate->valid() ) {
272
-			$this->_generator->create_and_add_message_to_queue( $message_to_generate, $test_send );
270
+	public function queue_for_generation(EE_Message_To_Generate $message_to_generate, $test_send = false) {
271
+		if ($message_to_generate->valid()) {
272
+			$this->_generator->create_and_add_message_to_queue($message_to_generate, $test_send);
273 273
 		}
274 274
 	}
275 275
 
@@ -285,9 +285,9 @@  discard block
 block discarded – undo
285 285
 	 *
286 286
 	 * @param EE_Message_To_Generate[] $messages_to_generate
287 287
 	 */
288
-	public function batch_queue_for_generation_and_persist( $messages_to_generate ) {
288
+	public function batch_queue_for_generation_and_persist($messages_to_generate) {
289 289
 		$this->_init_queue_and_generator();
290
-		$this->_queue_for_generation_loop( $messages_to_generate );
290
+		$this->_queue_for_generation_loop($messages_to_generate);
291 291
 		$this->_queue->save();
292 292
 	}
293 293
 
@@ -303,9 +303,9 @@  discard block
 block discarded – undo
303 303
 	 *
304 304
 	 * @param EE_Message_To_Generate[]  $messages_to_generate
305 305
 	 */
306
-	public function batch_queue_for_generation_no_persist( $messages_to_generate ) {
306
+	public function batch_queue_for_generation_no_persist($messages_to_generate) {
307 307
 		$this->_init_queue_and_generator();
308
-		$this->_queue_for_generation_loop( $messages_to_generate );
308
+		$this->_queue_for_generation_loop($messages_to_generate);
309 309
 	}
310 310
 
311 311
 
@@ -317,15 +317,15 @@  discard block
 block discarded – undo
317 317
 	 *
318 318
 	 * @param EE_Message_To_Generate[] $messages_to_generate
319 319
 	 */
320
-	protected function _queue_for_generation_loop( $messages_to_generate ) {
320
+	protected function _queue_for_generation_loop($messages_to_generate) {
321 321
 		//make sure is in an array.
322
-		if ( ! is_array( $messages_to_generate ) ) {
323
-			$messages_to_generate = array( $messages_to_generate );
322
+		if ( ! is_array($messages_to_generate)) {
323
+			$messages_to_generate = array($messages_to_generate);
324 324
 		}
325 325
 
326
-		foreach ( $messages_to_generate as $message_to_generate ) {
327
-			if ( $message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid() ) {
328
-				$this->queue_for_generation( $message_to_generate );
326
+		foreach ($messages_to_generate as $message_to_generate) {
327
+			if ($message_to_generate instanceof EE_Message_To_Generate && $message_to_generate->valid()) {
328
+				$this->queue_for_generation($message_to_generate);
329 329
 			}
330 330
 		}
331 331
 	}
@@ -340,10 +340,10 @@  discard block
 block discarded – undo
340 340
 	 * @param  EE_Message_To_Generate[]
341 341
 	 * @return EE_Messages_Queue
342 342
 	 */
343
-	public function generate_and_queue_for_sending( $messages_to_generate ) {
343
+	public function generate_and_queue_for_sending($messages_to_generate) {
344 344
 		$this->_init_queue_and_generator();
345
-		$this->_queue_for_generation_loop( $messages_to_generate );
346
-		return $this->_generator->generate( true );
345
+		$this->_queue_for_generation_loop($messages_to_generate);
346
+		return $this->_generator->generate(true);
347 347
 	}
348 348
 
349 349
 
@@ -357,10 +357,10 @@  discard block
 block discarded – undo
357 357
 	 * @param   bool                   $test_send                Whether this is a test send or not.
358 358
 	 * @return  EE_Messages_Queue | bool   false if unable to generate otherwise the generated queue.
359 359
 	 */
360
-	public function generate_for_preview( EE_Message_To_Generate $message_to_generate, $test_send = false ) {
361
-		if ( ! $message_to_generate->valid() ) {
360
+	public function generate_for_preview(EE_Message_To_Generate $message_to_generate, $test_send = false) {
361
+		if ( ! $message_to_generate->valid()) {
362 362
 			EE_Error::add_error(
363
-				__( 'Unable to generate preview because of invalid data', 'event_espresso' ),
363
+				__('Unable to generate preview because of invalid data', 'event_espresso'),
364 364
 				__FILE__,
365 365
 				__FUNCTION__,
366 366
 				__LINE__
@@ -368,14 +368,14 @@  discard block
 block discarded – undo
368 368
 			return false;
369 369
 		}
370 370
 		//just make sure preview is set on the $message_to_generate (in case client forgot)
371
-		$message_to_generate->set_preview( true );
371
+		$message_to_generate->set_preview(true);
372 372
 		$this->_init_queue_and_generator();
373
-		$this->queue_for_generation( $message_to_generate, $test_send );
374
-		$generated_queue = $this->_generator->generate( false );
375
-		if ( $generated_queue->execute( false ) ) {
373
+		$this->queue_for_generation($message_to_generate, $test_send);
374
+		$generated_queue = $this->_generator->generate(false);
375
+		if ($generated_queue->execute(false)) {
376 376
 			//the first queue item should be the preview
377 377
 			$generated_queue->get_message_repository()->rewind();
378
-			if ( ! $generated_queue->get_message_repository()->valid() ) {
378
+			if ( ! $generated_queue->get_message_repository()->valid()) {
379 379
 				return $generated_queue;
380 380
 			}
381 381
 			return $generated_queue->get_message_repository()->is_test_send() ? true : $generated_queue;
@@ -392,15 +392,15 @@  discard block
 block discarded – undo
392 392
 	 * @param EE_Message_To_Generate $message_to_generate
393 393
 	 * @return bool true or false for success.
394 394
 	 */
395
-	public function queue_for_sending( EE_Message_To_Generate $message_to_generate ) {
396
-		if ( ! $message_to_generate->valid() ) {
395
+	public function queue_for_sending(EE_Message_To_Generate $message_to_generate) {
396
+		if ( ! $message_to_generate->valid()) {
397 397
 			return false;
398 398
 		}
399 399
 		$this->_init_queue_and_generator();
400 400
 		$message = $message_to_generate->get_EE_Message();
401
-		$this->_queue->add( $message );
402
-		if ( $message->send_now() ) {
403
-			$this->_queue->execute( false );
401
+		$this->_queue->add($message);
402
+		if ($message->send_now()) {
403
+			$this->_queue->execute(false);
404 404
 		} else {
405 405
 			$this->_queue->save();
406 406
 		}
@@ -413,12 +413,12 @@  discard block
 block discarded – undo
413 413
 	 * @param EE_Message_To_Generate $message_to_generate
414 414
 	 * @return EE_Messages_Queue | null
415 415
 	 */
416
-	public function generate_and_send_now( EE_Message_To_Generate $message_to_generate ) {
417
-		if ( ! $message_to_generate->valid() ) {
416
+	public function generate_and_send_now(EE_Message_To_Generate $message_to_generate) {
417
+		if ( ! $message_to_generate->valid()) {
418 418
 			return null;
419 419
 		}
420 420
 		// is there supposed to be a sending messenger for this message?
421
-		if ( $message_to_generate instanceof EEI_Has_Sending_Messenger ) {
421
+		if ($message_to_generate instanceof EEI_Has_Sending_Messenger) {
422 422
 			// make sure it's valid, but if it's not,
423 423
 			// then set the value of $sending_messenger to an EE_Error object
424 424
 			// so that downstream code can easily see that things went wrong.
@@ -434,14 +434,14 @@  discard block
 block discarded – undo
434 434
 			$sending_messenger = null;
435 435
 		}
436 436
 
437
-		if ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle ) {
437
+		if ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_idle) {
438 438
 			$this->_init_queue_and_generator();
439
-			$this->_queue->add( $message_to_generate->get_EE_Message() );
440
-			$this->_queue->execute( false, $sending_messenger );
439
+			$this->_queue->add($message_to_generate->get_EE_Message());
440
+			$this->_queue->execute(false, $sending_messenger);
441 441
 			return $this->_queue;
442
-		} elseif ( $message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete ) {
443
-			$generated_queue = $this->generate_and_return( array( $message_to_generate ) );
444
-			$generated_queue->execute( false, $sending_messenger );
442
+		} elseif ($message_to_generate->get_EE_Message()->STS_ID() === EEM_Message::status_incomplete) {
443
+			$generated_queue = $this->generate_and_return(array($message_to_generate));
444
+			$generated_queue->execute(false, $sending_messenger);
445 445
 			return $generated_queue;
446 446
 		}
447 447
 		return null;
@@ -458,13 +458,13 @@  discard block
 block discarded – undo
458 458
 	 * @param mixed  $data   The data being used for generation.
459 459
 	 * @param bool   $persist   Whether to persist the queued messages to the db or not.
460 460
 	 */
461
-	public function generate_for_all_active_messengers( $message_type, $data, $persist = true ) {
462
-		$messages_to_generate = $this->setup_mtgs_for_all_active_messengers( $message_type, $data );
463
-		if ( $persist ) {
464
-			$this->batch_queue_for_generation_and_persist( $messages_to_generate );
461
+	public function generate_for_all_active_messengers($message_type, $data, $persist = true) {
462
+		$messages_to_generate = $this->setup_mtgs_for_all_active_messengers($message_type, $data);
463
+		if ($persist) {
464
+			$this->batch_queue_for_generation_and_persist($messages_to_generate);
465 465
 			$this->_queue->initiate_request_by_priority();
466 466
 		} else {
467
-			$this->batch_queue_for_generation_no_persist( $messages_to_generate );
467
+			$this->batch_queue_for_generation_no_persist($messages_to_generate);
468 468
 		}
469 469
 	}
470 470
 
@@ -479,11 +479,11 @@  discard block
 block discarded – undo
479 479
 	 *
480 480
 	 * @return EE_Message_To_Generate[]
481 481
 	 */
482
-	public function setup_mtgs_for_all_active_messengers( $message_type, $data ) {
482
+	public function setup_mtgs_for_all_active_messengers($message_type, $data) {
483 483
 		$messages_to_generate = array();
484
-		foreach ( $this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object  ) {
485
-			$message_to_generate = new EE_Message_To_Generate( $messenger_slug, $message_type, $data );
486
-			if ( $message_to_generate->valid() ) {
484
+		foreach ($this->_message_resource_manager->active_messengers() as $messenger_slug => $messenger_object) {
485
+			$message_to_generate = new EE_Message_To_Generate($messenger_slug, $message_type, $data);
486
+			if ($message_to_generate->valid()) {
487 487
 				$messages_to_generate[] = $message_to_generate;
488 488
 			}
489 489
 		}
@@ -498,29 +498,29 @@  discard block
 block discarded – undo
498 498
 	 * and send.
499 499
 	 * @param array $message_ids
500 500
 	 */
501
-	public function setup_messages_from_ids_and_send( $message_ids ) {
501
+	public function setup_messages_from_ids_and_send($message_ids) {
502 502
 		$this->_init_queue_and_generator();
503
-		$messages = EEM_Message::instance()->get_all( array(
503
+		$messages = EEM_Message::instance()->get_all(array(
504 504
 			array(
505
-				'MSG_ID' => array( 'IN', $message_ids ),
505
+				'MSG_ID' => array('IN', $message_ids),
506 506
 				'STS_ID' => array(
507 507
 					'IN',
508 508
 					array_merge(
509 509
 						EEM_Message::instance()->stati_indicating_sent(),
510
-						array( EEM_Message::status_retry )
510
+						array(EEM_Message::status_retry)
511 511
 					),
512 512
 				),
513 513
 			),
514 514
 		));
515 515
 		//set the Messages to resend.
516
-		foreach ( $messages as $message ) {
517
-			if ( $message instanceof EE_Message ) {
518
-				$message->set_STS_ID( EEM_Message::status_resend );
519
-				$this->_queue->add( $message );
516
+		foreach ($messages as $message) {
517
+			if ($message instanceof EE_Message) {
518
+				$message->set_STS_ID(EEM_Message::status_resend);
519
+				$this->_queue->add($message);
520 520
 			}
521 521
 		}
522 522
 
523
-		$this->_queue->initiate_request_by_priority( 'send' );
523
+		$this->_queue->initiate_request_by_priority('send');
524 524
 	}
525 525
 
526 526
 
@@ -534,23 +534,23 @@  discard block
 block discarded – undo
534 534
 	 *
535 535
 	 * @return EE_Message_To_Generate[]
536 536
 	 */
537
-	public function setup_messages_to_generate_from_registration_ids_in_request( $registration_ids_key = '_REG_ID' ) {
538
-		EE_Registry::instance()->load_core( 'Request_Handler' );
539
-		EE_Registry::instance()->load_helper( 'MSG_Template' );
537
+	public function setup_messages_to_generate_from_registration_ids_in_request($registration_ids_key = '_REG_ID') {
538
+		EE_Registry::instance()->load_core('Request_Handler');
539
+		EE_Registry::instance()->load_helper('MSG_Template');
540 540
 		$regs_to_send = array();
541
-		$regIDs = EE_Registry::instance()->REQ->get( $registration_ids_key );
542
-		if ( empty( $regIDs ) ) {
543
-			EE_Error::add_error( __('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
541
+		$regIDs = EE_Registry::instance()->REQ->get($registration_ids_key);
542
+		if (empty($regIDs)) {
543
+			EE_Error::add_error(__('Something went wrong because we\'re missing the registration ID', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
544 544
 			return false;
545 545
 		}
546 546
 
547 547
 		//make sure is an array
548
-		$regIDs = is_array( $regIDs ) ? $regIDs : array( $regIDs );
548
+		$regIDs = is_array($regIDs) ? $regIDs : array($regIDs);
549 549
 
550
-		foreach( $regIDs as $regID ) {
551
-			$reg = EEM_Registration::instance()->get_one_by_ID( $regID );
552
-			if ( ! $reg instanceof EE_Registration ) {
553
-				EE_Error::add_error( sprintf( __('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID ) );
550
+		foreach ($regIDs as $regID) {
551
+			$reg = EEM_Registration::instance()->get_one_by_ID($regID);
552
+			if ( ! $reg instanceof EE_Registration) {
553
+				EE_Error::add_error(sprintf(__('Unable to retrieve a registration object for the given reg id (%s)', 'event_espresso'), $regID));
554 554
 				return false;
555 555
 			}
556 556
 			$regs_to_send[$reg->transaction_ID()][$reg->status_ID()][] = $reg;
@@ -558,13 +558,13 @@  discard block
 block discarded – undo
558 558
 
559 559
 		$messages_to_generate = array();
560 560
 
561
-		foreach ( $regs_to_send as $status_group ) {
562
-			foreach ( $status_group as $status_id => $registrations ) {
561
+		foreach ($regs_to_send as $status_group) {
562
+			foreach ($status_group as $status_id => $registrations) {
563 563
 				$messages_to_generate = array_merge(
564 564
 					$messages_to_generate,
565 565
 					$this->setup_mtgs_for_all_active_messengers(
566
-						EEH_MSG_Template::convert_reg_status_to_message_type( $status_id ),
567
-						array( $registrations, $status_id )
566
+						EEH_MSG_Template::convert_reg_status_to_message_type($status_id),
567
+						array($registrations, $status_id)
568 568
 					)
569 569
 				);
570 570
 			}
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Queue.lib.php 1 patch
Spacing   +97 added lines, -97 removed lines patch added patch discarded remove patch
@@ -71,8 +71,8 @@  discard block
 block discarded – undo
71 71
 	 *
72 72
 	 * @param \EE_Message_Repository       $message_repository
73 73
 	 */
74
-	public function __construct( EE_Message_Repository $message_repository ) {
75
-		$this->_batch_count        = apply_filters( 'FHEE__EE_Messages_Queue___batch_count', 50 );
74
+	public function __construct(EE_Message_Repository $message_repository) {
75
+		$this->_batch_count        = apply_filters('FHEE__EE_Messages_Queue___batch_count', 50);
76 76
 		$this->_rate_limit         = $this->get_rate_limit();
77 77
 		$this->_message_repository = $message_repository;
78 78
 	}
@@ -91,10 +91,10 @@  discard block
 block discarded – undo
91 91
 	 *                                 use the messenger send method but typically is based on preview data.
92 92
 	 * @return bool          Whether the message was successfully added to the repository or not.
93 93
 	 */
94
-	public function add( EE_Message $message, $data = array(), $preview = false, $test_send = false ) {
94
+	public function add(EE_Message $message, $data = array(), $preview = false, $test_send = false) {
95 95
 		$data['preview'] = $preview;
96 96
 		$data['test_send'] = $test_send;
97
-		return $this->_message_repository->add( $message, $data );
97
+		return $this->_message_repository->add($message, $data);
98 98
 	}
99 99
 
100 100
 
@@ -106,13 +106,13 @@  discard block
 block discarded – undo
106 106
 	 * @param bool          $persist    This flag indicates whether to attempt to delete the object from the db as well.
107 107
 	 * @return bool
108 108
 	 */
109
-	public function remove( EE_Message $message, $persist = false ) {
110
-		if ( $persist && $this->_message_repository->current() !== $message ) {
109
+	public function remove(EE_Message $message, $persist = false) {
110
+		if ($persist && $this->_message_repository->current() !== $message) {
111 111
 			//get pointer on right message
112
-			if ( $this->_message_repository->has( $message ) ) {
112
+			if ($this->_message_repository->has($message)) {
113 113
 				$this->_message_repository->rewind();
114
-				while( $this->_message_repository->valid() ) {
115
-					if ( $this->_message_repository->current() === $message ) {
114
+				while ($this->_message_repository->valid()) {
115
+					if ($this->_message_repository->current() === $message) {
116 116
 						break;
117 117
 					}
118 118
 					$this->_message_repository->next();
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 				return false;
122 122
 			}
123 123
 		}
124
-		return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove( $message );
124
+		return $persist ? $this->_message_repository->delete() : $this->_message_repository->remove($message);
125 125
 	}
126 126
 
127 127
 
@@ -161,29 +161,29 @@  discard block
 block discarded – undo
161 161
 	 * @return bool  true if successfully retrieved batch, false no batch ready.
162 162
 	 */
163 163
 	public function get_batch_to_generate() {
164
-		if ( $this->is_locked( EE_Messages_Queue::action_generating ) ) {
164
+		if ($this->is_locked(EE_Messages_Queue::action_generating)) {
165 165
 			return false;
166 166
 		}
167 167
 
168 168
 		//lock batch generation to prevent race conditions.
169
-		$this->lock_queue( EE_Messages_Queue::action_generating );
169
+		$this->lock_queue(EE_Messages_Queue::action_generating);
170 170
 
171 171
 		$query_args = array(
172 172
 			// key 0 = where conditions
173
-			0 => array( 'STS_ID' => EEM_Message::status_incomplete ),
173
+			0 => array('STS_ID' => EEM_Message::status_incomplete),
174 174
 			'order_by' => $this->_get_priority_orderby(),
175 175
 			'limit' => $this->_batch_count
176 176
 		);
177
-		$messages = EEM_Message::instance()->get_all( $query_args );
177
+		$messages = EEM_Message::instance()->get_all($query_args);
178 178
 
179
-		if ( ! $messages ) {
179
+		if ( ! $messages) {
180 180
 			return false; //nothing to generate
181 181
 		}
182 182
 
183
-		foreach ( $messages as $message ) {
184
-			if ( $message instanceof EE_Message ) {
183
+		foreach ($messages as $message) {
184
+			if ($message instanceof EE_Message) {
185 185
 				$data = $message->all_extra_meta_array();
186
-				$this->add( $message, $data );
186
+				$this->add($message, $data);
187 187
 			}
188 188
 		}
189 189
 		return true;
@@ -206,34 +206,34 @@  discard block
 block discarded – undo
206 206
 	 *               to assist with notifying user.
207 207
 	 */
208 208
 	public function get_to_send_batch_and_send() {
209
-		if ( $this->is_locked( EE_Messages_Queue::action_sending ) || $this->_rate_limit < 1 ) {
209
+		if ($this->is_locked(EE_Messages_Queue::action_sending) || $this->_rate_limit < 1) {
210 210
 			return false;
211 211
 		}
212 212
 
213
-		$this->lock_queue( EE_Messages_Queue::action_sending );
213
+		$this->lock_queue(EE_Messages_Queue::action_sending);
214 214
 
215 215
 		$batch = $this->_batch_count < $this->_rate_limit ? $this->_batch_count : $this->_rate_limit;
216 216
 
217 217
 		$query_args = array(
218 218
 			// key 0 = where conditions
219
-			0 => array( 'STS_ID' => array( 'IN', EEM_Message::instance()->stati_indicating_to_send() ) ),
219
+			0 => array('STS_ID' => array('IN', EEM_Message::instance()->stati_indicating_to_send())),
220 220
 			'order_by' => $this->_get_priority_orderby(),
221 221
 			'limit' => $batch
222 222
 		);
223 223
 
224
-		$messages_to_send = EEM_Message::instance()->get_all( $query_args );
224
+		$messages_to_send = EEM_Message::instance()->get_all($query_args);
225 225
 
226 226
 
227 227
 		//any to send?
228
-		if ( ! $messages_to_send ) {
229
-			$this->unlock_queue( EE_Messages_Queue::action_sending );
228
+		if ( ! $messages_to_send) {
229
+			$this->unlock_queue(EE_Messages_Queue::action_sending);
230 230
 			return false;
231 231
 		}
232 232
 
233 233
 		//add to queue.
234
-		foreach ( $messages_to_send as $message ) {
235
-			if ( $message instanceof EE_Message ) {
236
-				$this->add( $message );
234
+		foreach ($messages_to_send as $message) {
235
+			if ($message instanceof EE_Message) {
236
+				$this->add($message);
237 237
 			}
238 238
 		}
239 239
 
@@ -241,7 +241,7 @@  discard block
 block discarded – undo
241 241
 		$this->execute();
242 242
 
243 243
 		//release lock
244
-		$this->unlock_queue( EE_Messages_Queue::action_sending );
244
+		$this->unlock_queue(EE_Messages_Queue::action_sending);
245 245
 		return true;
246 246
 	}
247 247
 
@@ -253,8 +253,8 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @param   string  $type   The type of queue being locked.
255 255
 	 */
256
-	public function lock_queue( $type = EE_Messages_Queue::action_generating ) {
257
-		set_transient( $this->_get_lock_key( $type ), 1, $this->_get_lock_expiry( $type ) );
256
+	public function lock_queue($type = EE_Messages_Queue::action_generating) {
257
+		set_transient($this->_get_lock_key($type), 1, $this->_get_lock_expiry($type));
258 258
 	}
259 259
 
260 260
 
@@ -265,8 +265,8 @@  discard block
 block discarded – undo
265 265
 	 *
266 266
 	 * @param   string  $type   The type of queue being unlocked.
267 267
 	 */
268
-	public function unlock_queue( $type = EE_Messages_Queue::action_generating ) {
269
-		delete_transient( $this->_get_lock_key( $type ) );
268
+	public function unlock_queue($type = EE_Messages_Queue::action_generating) {
269
+		delete_transient($this->_get_lock_key($type));
270 270
 	}
271 271
 
272 272
 
@@ -277,8 +277,8 @@  discard block
 block discarded – undo
277 277
 	 * @param string $type  The type of lock.
278 278
 	 * @return string
279 279
 	 */
280
-	protected function _get_lock_key( $type = EE_Messages_Queue::action_generating ) {
281
-		return '_ee_lock_' . $type;
280
+	protected function _get_lock_key($type = EE_Messages_Queue::action_generating) {
281
+		return '_ee_lock_'.$type;
282 282
 	}
283 283
 
284 284
 
@@ -289,8 +289,8 @@  discard block
 block discarded – undo
289 289
 	 * @param string $type  The type of lock
290 290
 	 * @return int   time to expiry in seconds.
291 291
 	 */
292
-	protected function _get_lock_expiry( $type = EE_Messages_Queue::action_generating ) {
293
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type );
292
+	protected function _get_lock_expiry($type = EE_Messages_Queue::action_generating) {
293
+		return (int) apply_filters('FHEE__EE_Messages_Queue__lock_expiry', HOUR_IN_SECONDS, $type);
294 294
 	}
295 295
 
296 296
 
@@ -308,7 +308,7 @@  discard block
 block discarded – undo
308 308
 	 * @return int
309 309
 	 */
310 310
 	protected function _get_rate_limit_expiry() {
311
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS );
311
+		return (int) apply_filters('FHEE__EE_Messages_Queue__rate_limit_expiry', HOUR_IN_SECONDS);
312 312
 	}
313 313
 
314 314
 
@@ -319,7 +319,7 @@  discard block
 block discarded – undo
319 319
 	 * @return int
320 320
 	 */
321 321
 	protected function _default_rate_limit() {
322
-		return (int) apply_filters( 'FHEE__EE_Messages_Queue___rate_limit', 200 );
322
+		return (int) apply_filters('FHEE__EE_Messages_Queue___rate_limit', 200);
323 323
 	}
324 324
 
325 325
 
@@ -345,14 +345,14 @@  discard block
 block discarded – undo
345 345
 	 * @param  string $type The type of lock being checked for.
346 346
 	 * @return bool
347 347
 	 */
348
-	public function is_locked( $type = EE_Messages_Queue::action_generating ) {
348
+	public function is_locked($type = EE_Messages_Queue::action_generating) {
349 349
 		/**
350 350
 		 * This filters the default is_locked behaviour.
351 351
 		 */
352 352
 		$is_locked = filter_var(
353 353
 			apply_filters(
354 354
 				'FHEE__EE_Messages_Queue__is_locked',
355
-				get_transient( $this->_get_lock_key( $type ) ),
355
+				get_transient($this->_get_lock_key($type)),
356 356
 				$this
357 357
 			),
358 358
 			FILTER_VALIDATE_BOOLEAN
@@ -363,7 +363,7 @@  discard block
 block discarded – undo
363 363
 		 *            Also implemented here because messages processed on the same request should not have any locks applied.
364 364
 		 */
365 365
 		if (
366
-			apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false )
366
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
367 367
 			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
368 368
 		) {
369 369
 			$is_locked = false;
@@ -385,9 +385,9 @@  discard block
 block discarded – undo
385 385
 	 * @return int
386 386
 	 */
387 387
 	public function get_rate_limit() {
388
-		if ( ! $rate_limit = get_transient( $this->_get_rate_limit_key() ) ) {
388
+		if ( ! $rate_limit = get_transient($this->_get_rate_limit_key())) {
389 389
 			$rate_limit = $this->_default_rate_limit();
390
-			set_transient( $this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key() );
390
+			set_transient($this->_get_rate_limit_key(), $rate_limit, $this->_get_rate_limit_key());
391 391
 		}
392 392
 		return $rate_limit;
393 393
 	}
@@ -399,12 +399,12 @@  discard block
 block discarded – undo
399 399
 	 * This updates existing rate limit with the new limit which is the old minus the batch.
400 400
 	 * @param int $batch_completed  This sets the new rate limit based on the given batch that was completed.
401 401
 	 */
402
-	public function set_rate_limit( $batch_completed ) {
402
+	public function set_rate_limit($batch_completed) {
403 403
 		//first get the most up to date rate limit (in case its expired and reset)
404 404
 		$rate_limit = $this->get_rate_limit();
405 405
 		$new_limit = $rate_limit - $batch_completed;
406 406
 		//updating the transient option directly to avoid resetting the expiry.
407
-		update_option( '_transient_' . $this->_get_rate_limit_key(), $new_limit );
407
+		update_option('_transient_'.$this->_get_rate_limit_key(), $new_limit);
408 408
 	}
409 409
 
410 410
 
@@ -417,7 +417,7 @@  discard block
 block discarded – undo
417 417
 	 * @param string $task This indicates what type of request is going to be initiated.
418 418
 	 * @param int    $priority  This indicates the priority that triggers initiating the request.
419 419
 	 */
420
-	public function initiate_request_by_priority( $task = 'generate', $priority = EEM_Message::priority_high ) {
420
+	public function initiate_request_by_priority($task = 'generate', $priority = EEM_Message::priority_high) {
421 421
 		//determine what status is matched with the priority as part of the trigger conditions.
422 422
 		$status = $task == 'generate'
423 423
 			? EEM_Message::status_incomplete
@@ -437,19 +437,19 @@  discard block
 block discarded – undo
437 437
 		 *   the same request.
438 438
 		 */
439 439
 		if (
440
-			apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false )
440
+			apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
441 441
 			|| EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
442 442
 		) {
443
-			$messages_processor = EE_Registry::instance()->load_lib( 'Messages_Processor' );
444
-			if ( $messages_processor instanceof EE_Messages_Processor ) {
445
-				return $messages_processor->process_immediately_from_queue( $this );
443
+			$messages_processor = EE_Registry::instance()->load_lib('Messages_Processor');
444
+			if ($messages_processor instanceof EE_Messages_Processor) {
445
+				return $messages_processor->process_immediately_from_queue($this);
446 446
 			}
447 447
 			//if we get here then that means the messages processor couldn't be loaded so messages will just remain
448 448
 			//queued for manual triggering by end user.
449 449
 		}
450 450
 
451
-		if ( $this->_message_repository->count_by_priority_and_status( $priority, $status ) ) {
452
-			EE_Messages_Scheduler::initiate_scheduled_non_blocking_request( $task );
451
+		if ($this->_message_repository->count_by_priority_and_status($priority, $status)) {
452
+			EE_Messages_Scheduler::initiate_scheduled_non_blocking_request($task);
453 453
 		}
454 454
 	}
455 455
 
@@ -474,53 +474,53 @@  discard block
 block discarded – undo
474 474
 	 *                    Also, if the messenger is an request type messenger (or a preview),
475 475
 	 * 					  its entirely possible that the messenger will exit before
476 476
 	 */
477
-	public function execute( $save = true, $sending_messenger = null, $by_priority = false ) {
477
+	public function execute($save = true, $sending_messenger = null, $by_priority = false) {
478 478
 		$messages_sent = 0;
479 479
 		$this->_did_hook = array();
480 480
 		$this->_message_repository->rewind();
481 481
 
482
-		while ( $this->_message_repository->valid() ) {
482
+		while ($this->_message_repository->valid()) {
483 483
 			$error_messages = array();
484 484
 			/** @type EE_Message $message */
485 485
 			$message = $this->_message_repository->current();
486 486
 			//only process things that are queued for sending
487
-			if ( ! in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send() ) ) {
487
+			if ( ! in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_to_send())) {
488 488
 				$this->_message_repository->next();
489 489
 				continue;
490 490
 			}
491 491
 			//if $by_priority is set and does not match then continue;
492
-			if ( $by_priority && $by_priority != $message->priority() ) {
492
+			if ($by_priority && $by_priority != $message->priority()) {
493 493
 				$this->_message_repository->next();
494 494
 				continue;
495 495
 			}
496 496
 			//error checking
497
-			if ( ! $message->valid_messenger() ) {
497
+			if ( ! $message->valid_messenger()) {
498 498
 				$error_messages[] = sprintf(
499
-					__( 'The %s messenger is not active at time of sending.', 'event_espresso' ),
499
+					__('The %s messenger is not active at time of sending.', 'event_espresso'),
500 500
 					$message->messenger()
501 501
 				);
502 502
 			}
503
-			if ( ! $message->valid_message_type() ) {
503
+			if ( ! $message->valid_message_type()) {
504 504
 				$error_messages[] = sprintf(
505
-					__( 'The %s message type is not active at the time of sending.', 'event_espresso' ),
505
+					__('The %s message type is not active at the time of sending.', 'event_espresso'),
506 506
 					$message->message_type()
507 507
 				);
508 508
 			}
509 509
 			// if there was supposed to be a sending messenger for this message, but it was invalid/inactive,
510 510
 			// then it will instead be an EE_Error object, so let's check for that
511
-			if ( $sending_messenger instanceof EE_Error ) {
511
+			if ($sending_messenger instanceof EE_Error) {
512 512
 				$error_messages[] = $sending_messenger->getMessage();
513 513
 			}
514 514
 			// if there are no errors, then let's process the message
515
-			if ( empty( $error_messages ) && $this->_process_message( $message, $sending_messenger ) ) {
515
+			if (empty($error_messages) && $this->_process_message($message, $sending_messenger)) {
516 516
 				$messages_sent++;
517 517
 			}
518
-			$this->_set_error_message( $message, $error_messages );
518
+			$this->_set_error_message($message, $error_messages);
519 519
 			//add modified time
520
-			$message->set_modified( time() );
520
+			$message->set_modified(time());
521 521
 			$this->_message_repository->next();
522 522
 		}
523
-		if ( $save ) {
523
+		if ($save) {
524 524
 			$this->save();
525 525
 		}
526 526
 		return $messages_sent;
@@ -535,7 +535,7 @@  discard block
 block discarded – undo
535 535
 	 * @param mixed 	 $sending_messenger (optional)
536 536
 	 * @return bool
537 537
 	 */
538
-	protected function _process_message( EE_Message $message, $sending_messenger = null ) {
538
+	protected function _process_message(EE_Message $message, $sending_messenger = null) {
539 539
 		// these *should* have been validated in the execute() method above
540 540
 		$messenger = $message->messenger_object();
541 541
 		$message_type = $message->message_type_object();
@@ -545,20 +545,20 @@  discard block
 block discarded – undo
545 545
 			&& $messenger instanceof EE_messenger
546 546
 			&& $sending_messenger->name != $messenger->name
547 547
 		) {
548
-			$messenger->do_secondary_messenger_hooks( $sending_messenger->name );
548
+			$messenger->do_secondary_messenger_hooks($sending_messenger->name);
549 549
 			$messenger = $sending_messenger;
550 550
 		}
551 551
 		// send using messenger, but double check objects
552
-		if ( $messenger instanceof EE_messenger && $message_type instanceof EE_message_type ) {
552
+		if ($messenger instanceof EE_messenger && $message_type instanceof EE_message_type) {
553 553
 			//set hook for message type (but only if not using another messenger to send).
554
-			if ( ! isset( $this->_did_hook[ $message_type->name ] ) ) {
555
-				$message_type->do_messenger_hooks( $messenger );
556
-				$this->_did_hook[ $message_type->name ] = 1;
554
+			if ( ! isset($this->_did_hook[$message_type->name])) {
555
+				$message_type->do_messenger_hooks($messenger);
556
+				$this->_did_hook[$message_type->name] = 1;
557 557
 			}
558 558
 			//if preview then use preview method
559 559
 			return $this->_message_repository->is_preview()
560
-				? $this->_do_preview( $message, $messenger, $message_type, $this->_message_repository->is_test_send() )
561
-				: $this->_do_send( $message, $messenger, $message_type );
560
+				? $this->_do_preview($message, $messenger, $message_type, $this->_message_repository->is_test_send())
561
+				: $this->_do_send($message, $messenger, $message_type);
562 562
 		}
563 563
 		return false;
564 564
 	}
@@ -576,12 +576,12 @@  discard block
 block discarded – undo
576 576
 	 * @param array $status  Stati to check for in queue
577 577
 	 * @return int  Count of EE_Message's matching the given status.
578 578
 	 */
579
-	public function count_STS_in_queue( $status ) {
579
+	public function count_STS_in_queue($status) {
580 580
 		$count = 0;
581
-		$status = is_array( $status ) ? $status : array( $status );
581
+		$status = is_array($status) ? $status : array($status);
582 582
 		$this->_message_repository->rewind();
583
-		foreach( $this->_message_repository as $message ) {
584
-			if ( in_array( $message->STS_ID(), $status ) ) {
583
+		foreach ($this->_message_repository as $message) {
584
+			if (in_array($message->STS_ID(), $status)) {
585 585
 				$count++;
586 586
 			}
587 587
 		}
@@ -598,15 +598,15 @@  discard block
 block discarded – undo
598 598
 	 * @param $test_send
599 599
 	 * @return bool   true means all went well, false means, not so much.
600 600
 	 */
601
-	protected function _do_preview( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send ) {
602
-		if ( $preview = $messenger->get_preview( $message, $message_type, $test_send ) ) {
603
-			if ( ! $test_send ) {
604
-				$message->set_content( $preview );
601
+	protected function _do_preview(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type, $test_send) {
602
+		if ($preview = $messenger->get_preview($message, $message_type, $test_send)) {
603
+			if ( ! $test_send) {
604
+				$message->set_content($preview);
605 605
 			}
606
-			$message->set_STS_ID( EEM_Message::status_sent );
606
+			$message->set_STS_ID(EEM_Message::status_sent);
607 607
 			return true;
608 608
 		} else {
609
-			$message->set_STS_ID( EEM_Message::status_failed );
609
+			$message->set_STS_ID(EEM_Message::status_failed);
610 610
 			return false;
611 611
 		}
612 612
 	}
@@ -622,12 +622,12 @@  discard block
 block discarded – undo
622 622
 	 * @param EE_message_type $message_type
623 623
 	 * @return bool true means all went well, false means, not so much.
624 624
 	 */
625
-	protected function _do_send( EE_Message $message, EE_messenger $messenger, EE_message_type $message_type ) {
626
-		if ( $messenger->send_message( $message, $message_type ) ) {
627
-			$message->set_STS_ID( EEM_Message::status_sent );
625
+	protected function _do_send(EE_Message $message, EE_messenger $messenger, EE_message_type $message_type) {
626
+		if ($messenger->send_message($message, $message_type)) {
627
+			$message->set_STS_ID(EEM_Message::status_sent);
628 628
 			return true;
629 629
 		} else {
630
-			$message->set_STS_ID( EEM_Message::status_retry );
630
+			$message->set_STS_ID(EEM_Message::status_retry);
631 631
 			return false;
632 632
 		}
633 633
 	}
@@ -641,21 +641,21 @@  discard block
 block discarded – undo
641 641
 	 * @param EE_Message $message
642 642
 	 * @param array      $error_messages the response from the messenger.
643 643
 	 */
644
-	protected function _set_error_message( EE_Message $message, $error_messages ) {
644
+	protected function _set_error_message(EE_Message $message, $error_messages) {
645 645
 		$error_messages = (array) $error_messages;
646
-		if ( in_array( $message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending() ) ) {
646
+		if (in_array($message->STS_ID(), EEM_Message::instance()->stati_indicating_failed_sending())) {
647 647
 			$notices = EE_Error::has_notices();
648
-			$error_messages[] = __( 'Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso' );
649
-			if ( $notices === 1 ) {
648
+			$error_messages[] = __('Messenger and Message Type were valid and active, but the messenger send method failed.', 'event_espresso');
649
+			if ($notices === 1) {
650 650
 				$notices = EE_Error::get_vanilla_notices();
651
-				$notices['errors'] = isset( $notices['errors'] ) ? $notices['errors'] : array();
652
-				$error_messages[] = implode( "\n", $notices['errors'] );
651
+				$notices['errors'] = isset($notices['errors']) ? $notices['errors'] : array();
652
+				$error_messages[] = implode("\n", $notices['errors']);
653 653
 			}
654 654
 		}
655
-		if ( count( $error_messages ) > 0 ) {
656
-			$msg = __( 'Message was not executed successfully.', 'event_espresso' );
657
-			$msg = $msg . "\n" . implode( "\n", $error_messages );
658
-			$message->set_error_message( $msg );
655
+		if (count($error_messages) > 0) {
656
+			$msg = __('Message was not executed successfully.', 'event_espresso');
657
+			$msg = $msg."\n".implode("\n", $error_messages);
658
+			$message->set_error_message($msg);
659 659
 		}
660 660
 	}
661 661
 
Please login to merge, or discard this patch.
core/EE_Network_Config.core.php 1 patch
Spacing   +29 added lines, -29 removed lines patch added patch discarded remove patch
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 */
59 59
 	public static function instance() {
60 60
 		// check if class object is instantiated, and instantiated properly
61
-		if ( self::$_instance === NULL  or ! is_object( self::$_instance ) or ! ( self::$_instance instanceof EE_Network_Config )) {
61
+		if (self::$_instance === NULL or ! is_object(self::$_instance) or ! (self::$_instance instanceof EE_Network_Config)) {
62 62
 			self::$_instance = new self();
63 63
 		}
64 64
 		return self::$_instance;
@@ -73,15 +73,15 @@  discard block
 block discarded – undo
73 73
 	 *  @access 	private
74 74
 	 */
75 75
 	private function __construct() {
76
-		do_action( 'AHEE__EE_Network_Config__construct__begin',$this );
76
+		do_action('AHEE__EE_Network_Config__construct__begin', $this);
77 77
 		//set defaults
78
-		$this->core = apply_filters( 'FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config() );
78
+		$this->core = apply_filters('FHEE__EE_Network_Config___construct__core', new EE_Network_Core_Config());
79 79
 		$this->addons = array();
80 80
 
81 81
 		$this->_load_config();
82 82
 
83 83
 		// construct__end hook
84
-		do_action( 'AHEE__EE_Network_Config__construct__end',$this );
84
+		do_action('AHEE__EE_Network_Config__construct__end', $this);
85 85
 	}
86 86
 
87 87
 
@@ -94,25 +94,25 @@  discard block
 block discarded – undo
94 94
 	 */
95 95
 	private function _load_config() {
96 96
 		//load network config start hook
97
-		do_action( 'AHEE__EE_Network_Config___load_config__start', $this );
97
+		do_action('AHEE__EE_Network_Config___load_config__start', $this);
98 98
 		$config = $this->get_config();
99
-		foreach ( $config as $config_prop => $settings ) {
100
-			if ( is_object( $settings ) && property_exists( $this, $config_prop ) ) {
101
-				$this->{$config_prop} = apply_filters( 'FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this );
102
-				if ( method_exists( $settings, 'populate' ) ) {
99
+		foreach ($config as $config_prop => $settings) {
100
+			if (is_object($settings) && property_exists($this, $config_prop)) {
101
+				$this->{$config_prop} = apply_filters('FHEE__EE_Network_Config___load_config__config_settings', $settings, $config_prop, $this);
102
+				if (method_exists($settings, 'populate')) {
103 103
 					$this->{$config_prop}->populate();
104 104
 				}
105
-				if ( method_exists( $settings, 'do_hooks' ) ) {
105
+				if (method_exists($settings, 'do_hooks')) {
106 106
 					$this->{$config_prop}->do_hooks();
107 107
 				}
108 108
 			}
109 109
 		}
110
-		if ( apply_filters( 'FHEE__EE_Network_Config___load_config__update_network_config', false ) ) {
110
+		if (apply_filters('FHEE__EE_Network_Config___load_config__update_network_config', false)) {
111 111
 			$this->update_config();
112 112
 		}
113 113
 
114 114
 		//load network config end hook
115
-		do_action( 'AHEE__EE_Network_Config___load_config__end', $this );
115
+		do_action('AHEE__EE_Network_Config___load_config__end', $this);
116 116
 	}
117 117
 
118 118
 
@@ -126,8 +126,8 @@  discard block
 block discarded – undo
126 126
 	 */
127 127
 	public function get_config() {
128 128
 		// grab network configuration
129
-		$CFG = get_site_option( 'ee_network_config', array() );
130
-		$CFG = apply_filters( 'FHEE__EE_Network_Config__get_config__CFG', $CFG );
129
+		$CFG = get_site_option('ee_network_config', array());
130
+		$CFG = apply_filters('FHEE__EE_Network_Config__get_config__CFG', $CFG);
131 131
 		return $CFG;
132 132
 	}
133 133
 
@@ -141,32 +141,32 @@  discard block
 block discarded – undo
141 141
 	 * @param bool $add_error
142 142
 	 * @return bool success
143 143
 	 */
144
-	public function update_config( $add_success = FALSE, $add_error = TRUE ) {
145
-		do_action( 'AHEE__EE_Network_Config__update_config__begin',$this );
144
+	public function update_config($add_success = FALSE, $add_error = TRUE) {
145
+		do_action('AHEE__EE_Network_Config__update_config__begin', $this);
146 146
 
147 147
 		//we have to compare existing saved config with config in memory because if there is no difference that means
148 148
 		//that the method executed fine but there just was no update.  WordPress doesn't distinguish between false because
149 149
 		//there were 0 records updated because of no change vs false because some error produced problems with the update.
150
-		$original = get_site_option( 'ee_network_config' );
150
+		$original = get_site_option('ee_network_config');
151 151
 
152
-		if ( $original == $this ) {
152
+		if ($original == $this) {
153 153
 			return true;
154 154
 		}
155 155
 		// update
156
-		$saved = update_site_option( 'ee_network_config', $this );
156
+		$saved = update_site_option('ee_network_config', $this);
157 157
 		
158
-		do_action( 'AHEE__EE_Network_Config__update_config__end', $this, $saved );
158
+		do_action('AHEE__EE_Network_Config__update_config__end', $this, $saved);
159 159
 		// if config remains the same or was updated successfully
160
-		if ( $saved ) {
161
-			if ( $add_success ) {
162
-				$msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso' ) : __( 'Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso' );
163
-				EE_Error::add_success( $msg );
160
+		if ($saved) {
161
+			if ($add_success) {
162
+				$msg = is_multisite() ? __('The Event Espresso Network Configuration Settings have been successfully updated.', 'event_espresso') : __('Extra Event Espresso Configuration settings were successfully updated.', 'event_espresso');
163
+				EE_Error::add_success($msg);
164 164
 			}
165 165
 			return TRUE;
166 166
 		} else {
167
-			if ( $add_error ) {
168
-				$msg = is_multisite() ? __( 'The Event Espresso Network Configuration Settings were not updated.', 'event_espresso' ) : __( 'Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso' );
169
-				EE_Error::add_error( $msg , __FILE__, __FUNCTION__, __LINE__ );
167
+			if ($add_error) {
168
+				$msg = is_multisite() ? __('The Event Espresso Network Configuration Settings were not updated.', 'event_espresso') : __('Extra Event Espresso Network Configuration settings were not updated.', 'event_espresso');
169
+				EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
170 170
 			}
171 171
 			return FALSE;
172 172
 		}
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
 	 *  @return 	array
181 181
 	 */
182 182
 	public function __sleep() {
183
-		return apply_filters( 'FHEE__EE_Network_Config__sleep',array(
183
+		return apply_filters('FHEE__EE_Network_Config__sleep', array(
184 184
 			'core',
185
-		) );
185
+		));
186 186
 	}
187 187
 
188 188
 } //end EE_Network_Config.
Please login to merge, or discard this patch.
core/libraries/messages/EE_Messages_Scheduler.lib.php 1 patch
Spacing   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -23,18 +23,18 @@  discard block
 block discarded – undo
23 23
 	 */
24 24
 	public function __construct() {
25 25
 		//register tasks (and make sure only registered once).
26
-		if ( ! has_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ) ) ) {
27
-			add_action( 'FHEE__EEH_Activation__get_cron_tasks', array( $this, 'register_scheduled_tasks' ), 10 );
26
+		if ( ! has_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'))) {
27
+			add_action('FHEE__EEH_Activation__get_cron_tasks', array($this, 'register_scheduled_tasks'), 10);
28 28
 		}
29 29
 
30 30
 		//register callbacks for scheduled events (but make sure they are set only once).
31
-		if ( ! has_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation' ) ) ) {
32
-			add_action( 'AHEE__EE_Messages_Scheduler__generation', array( 'EE_Messages_Scheduler', 'batch_generation') );
33
-			add_action( 'AHEE__EE_Messages_Scheduler__sending', array( 'EE_Messages_Scheduler', 'batch_sending' ) );
31
+		if ( ! has_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'))) {
32
+			add_action('AHEE__EE_Messages_Scheduler__generation', array('EE_Messages_Scheduler', 'batch_generation'));
33
+			add_action('AHEE__EE_Messages_Scheduler__sending', array('EE_Messages_Scheduler', 'batch_sending'));
34 34
 		}
35 35
 
36 36
 		//add custom schedules
37
-		add_filter( 'cron_schedules', array( $this, 'custom_schedules' ) );
37
+		add_filter('cron_schedules', array($this, 'custom_schedules'));
38 38
 	}
39 39
 
40 40
 
@@ -44,10 +44,10 @@  discard block
 block discarded – undo
44 44
 	 * Add custom schedules for wp_cron
45 45
 	 * @param $schedules
46 46
 	 */
47
-	public function custom_schedules( $schedules ) {
47
+	public function custom_schedules($schedules) {
48 48
 		$schedules['ee_message_cron'] = array(
49 49
 			'interval' => self::message_cron_schedule,
50
-			'display' => __( 'This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', 'event_espresso' )
50
+			'display' => __('This is the cron time interval for EE Message schedules (defaults to once every 5 minutes)', 'event_espresso')
51 51
 		);
52 52
 		return $schedules;
53 53
 	}
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
 	 * @param array $tasks  already existing scheduled tasks
59 59
 	 * @return array
60 60
 	 */
61
-	public function register_scheduled_tasks( $tasks ) {
61
+	public function register_scheduled_tasks($tasks) {
62 62
 		$tasks['AHEE__EE_Messages_Scheduler__generation'] = 'ee_message_cron';
63 63
 		$tasks['AHEE__EE_Messages_Scheduler__sending'] = 'ee_message_cron';
64 64
 		return $tasks;
@@ -70,27 +70,27 @@  discard block
 block discarded – undo
70 70
 	 * Note: The EED_Messages module has the handlers for these requests.
71 71
 	 * @param string $task  The task the request is being generated for.
72 72
 	 */
73
-	public static function initiate_scheduled_non_blocking_request( $task ) {
74
-		if ( apply_filters( 'EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', true ) ) {
75
-			$request_url  = add_query_arg(
73
+	public static function initiate_scheduled_non_blocking_request($task) {
74
+		if (apply_filters('EE_Messages_Scheduler__initiate_scheduled_non_blocking_request__do_separate_request', true)) {
75
+			$request_url = add_query_arg(
76 76
 				array_merge(
77
-					array( 'ee' => 'msg_cron_trigger' ),
78
-					EE_Messages_Scheduler::get_request_params( $task )
77
+					array('ee' => 'msg_cron_trigger'),
78
+					EE_Messages_Scheduler::get_request_params($task)
79 79
 				),
80 80
 				site_url()
81 81
 			);
82 82
 			$request_args = array(
83 83
 				'timeout'     => 300,
84
-				'blocking'    => ( defined( 'DOING_CRON' ) && DOING_CRON ) || ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? true : false,
84
+				'blocking'    => (defined('DOING_CRON') && DOING_CRON) || (defined('DOING_AJAX') && DOING_AJAX) ? true : false,
85 85
 				'sslverify'   => false,
86 86
 				'redirection' => 10,
87 87
 			);
88
-			$response     = wp_remote_get( $request_url, $request_args );
89
-			if ( is_wp_error( $response ) ) {
90
-				trigger_error( $response->get_error_message() );
88
+			$response = wp_remote_get($request_url, $request_args);
89
+			if (is_wp_error($response)) {
90
+				trigger_error($response->get_error_message());
91 91
 			}
92 92
 		} else {
93
-			EE_Messages_Scheduler::initiate_immediate_request_on_cron( $task );
93
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron($task);
94 94
 		}
95 95
 	}
96 96
 
@@ -103,10 +103,10 @@  discard block
 block discarded – undo
103 103
 	 * @param string $task The task the request is for.
104 104
 	 * @return array
105 105
 	 */
106
-	public static function get_request_params( $task ) {
106
+	public static function get_request_params($task) {
107 107
 		//transient is used for flood control on msg_cron_trigger requests
108
-		$transient_key = 'ee_trans_' . uniqid( $task );
109
-		set_transient( $transient_key, 1, 5 * MINUTE_IN_SECONDS );
108
+		$transient_key = 'ee_trans_'.uniqid($task);
109
+		set_transient($transient_key, 1, 5 * MINUTE_IN_SECONDS);
110 110
 		return array(
111 111
 			'type' => $task,
112 112
 			'key' => $transient_key,
@@ -120,11 +120,11 @@  discard block
 block discarded – undo
120 120
 	 * This is used to execute an immediate call to the run_cron task performed by EED_Messages
121 121
 	 * @param string $task The task the request is being generated for.
122 122
 	 */
123
-	public static function initiate_immediate_request_on_cron( $task ) {
124
-		$request_args = EE_Messages_Scheduler::get_request_params( $task );
123
+	public static function initiate_immediate_request_on_cron($task) {
124
+		$request_args = EE_Messages_Scheduler::get_request_params($task);
125 125
 		//set those request args in the request so it gets picked up
126
-		foreach ( $request_args as $request_key => $request_value ) {
127
-			EE_Registry::instance()->REQ->set( $request_key, $request_value );
126
+		foreach ($request_args as $request_key => $request_value) {
127
+			EE_Registry::instance()->REQ->set($request_key, $request_value);
128 128
 		}
129 129
 		EED_Messages::instance()->run_cron();
130 130
 	}
@@ -141,10 +141,10 @@  discard block
 block discarded – undo
141 141
 		 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
142 142
 		 */
143 143
 		if (
144
-			! apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false )
144
+			! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
145 145
 			|| ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
146 146
 		) {
147
-			EE_Messages_Scheduler::initiate_immediate_request_on_cron( 'generate' );
147
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron('generate');
148 148
 		}
149 149
 	}
150 150
 
@@ -159,10 +159,10 @@  discard block
 block discarded – undo
159 159
 		 * @see filter usage in EE_Messages_Queue::initiate_request_by_priority()
160 160
 		 */
161 161
 		if (
162
-			! apply_filters( 'FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false )
162
+			! apply_filters('FHEE__EE_Messages_Processor__initiate_request_by_priority__do_immediate_processing', false)
163 163
 			|| ! EE_Registry::instance()->NET_CFG->core->do_messages_on_same_request
164 164
 		) {
165
-			EE_Messages_Scheduler::initiate_immediate_request_on_cron( 'send' );
165
+			EE_Messages_Scheduler::initiate_immediate_request_on_cron('send');
166 166
 		}
167 167
 	}
168 168
 
Please login to merge, or discard this patch.