Completed
Branch BUG-9548-transaction-completio... (b1c41e)
by
unknown
519:42 queued 503:28
created
modules/core_rest_api/EED_Core_Rest_Api.module.php 1 patch
Spacing   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 use EventEspresso\core\libraries\rest_api\Calculated_Model_Fields;
3 3
 
4
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
-	exit( 'No direct script access allowed' );
4
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
5
+	exit('No direct script access allowed');
6 6
 }
7 7
 
8 8
 /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 */
36 36
 	public static function instance() {
37 37
 		self::$_field_calculator = new Calculated_Model_Fields();
38
-		return parent::get_instance( __CLASS__ );
38
+		return parent::get_instance(__CLASS__);
39 39
 	}
40 40
 
41 41
 
@@ -65,10 +65,10 @@  discard block
 block discarded – undo
65 65
 
66 66
 
67 67
 	public static function set_hooks_both() {
68
-		add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'register_routes' ), 10 );
69
-		add_action( 'rest_api_init', array( 'EED_Core_Rest_Api', 'set_hooks_rest_api' ), 5 );
70
-		add_filter( 'rest_route_data', array( 'EED_Core_Rest_Api', 'hide_old_endpoints' ), 10, 2 );
71
-		add_filter( 'rest_index', array( 'EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index' ) );
68
+		add_action('rest_api_init', array('EED_Core_Rest_Api', 'register_routes'), 10);
69
+		add_action('rest_api_init', array('EED_Core_Rest_Api', 'set_hooks_rest_api'), 5);
70
+		add_filter('rest_route_data', array('EED_Core_Rest_Api', 'hide_old_endpoints'), 10, 2);
71
+		add_filter('rest_index', array('EventEspresso\core\libraries\rest_api\controllers\model\Meta', 'filter_ee_metadata_into_index'));
72 72
 		EED_Core_Rest_Api::invalidate_cached_route_data_on_version_change();
73 73
 	}
74 74
 
@@ -86,7 +86,7 @@  discard block
 block discarded – undo
86 86
 	 * Loads all the hooks which make requests to old versions of the API
87 87
 	 * appear the same as they always did
88 88
 	 */
89
-	public static function set_hooks_for_changes(){
89
+	public static function set_hooks_for_changes() {
90 90
 		self::_set_hooks_for_changes();
91 91
 	}
92 92
 	/**
@@ -94,16 +94,16 @@  discard block
 block discarded – undo
94 94
 	 * appear the same as they always did
95 95
 	 */
96 96
 	protected static function _set_hooks_for_changes() {
97
-		$folder_contents = EEH_File::get_contents_of_folders( array( EE_LIBRARIES . 'rest_api' . DS . 'changes' ), false );
98
-		foreach( $folder_contents as $classname_in_namespace => $filepath ) {
97
+		$folder_contents = EEH_File::get_contents_of_folders(array(EE_LIBRARIES.'rest_api'.DS.'changes'), false);
98
+		foreach ($folder_contents as $classname_in_namespace => $filepath) {
99 99
 			//ignore the base parent class
100
-			if( $classname_in_namespace === 'Changes_In_Base' ) {
100
+			if ($classname_in_namespace === 'Changes_In_Base') {
101 101
 				continue;
102 102
 			}
103
-			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\' . $classname_in_namespace;
104
-			if ( class_exists( $full_classname )) {
103
+			$full_classname = 'EventEspresso\core\libraries\rest_api\changes\\'.$classname_in_namespace;
104
+			if (class_exists($full_classname)) {
105 105
 				$instance_of_class = new $full_classname;
106
-				if ( $instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base ) {
106
+				if ($instance_of_class instanceof EventEspresso\core\libraries\rest_api\changes\Changes_In_Base) {
107 107
 					$instance_of_class->set_hooks();
108 108
 				}
109 109
 			}
@@ -116,16 +116,16 @@  discard block
 block discarded – undo
116 116
 	 * so we actually prefer to only do it when an EE plugin is activated or upgraded
117 117
 	 */
118 118
 	public static function register_routes() {
119
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
120
-			foreach( $relative_urls as $endpoint => $routes ) {
121
-				foreach( $routes as $route ) {
119
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
120
+			foreach ($relative_urls as $endpoint => $routes) {
121
+				foreach ($routes as $route) {
122 122
 					register_rest_route(
123 123
 						$namespace,
124 124
 						$endpoint,
125 125
 						array(
126
-							'callback' => $route[ 'callback' ],
127
-							'methods' => $route[ 'methods' ],
128
-							'args' => isset( $route[ 'args' ] ) ? $route[ 'args' ] : array(),
126
+							'callback' => $route['callback'],
127
+							'methods' => $route['methods'],
128
+							'args' => isset($route['args']) ? $route['args'] : array(),
129 129
 						)
130 130
 					);
131 131
 				}
@@ -139,11 +139,11 @@  discard block
 block discarded – undo
139 139
 	 * next time the WP API is used
140 140
 	 */
141 141
 	public static function invalidate_cached_route_data_on_version_change() {
142
-		if( EE_System::instance()->detect_req_type() != EE_System::req_type_normal ) {
142
+		if (EE_System::instance()->detect_req_type() != EE_System::req_type_normal) {
143 143
 			EED_Core_Rest_Api::invalidate_cached_route_data();
144 144
 		}
145
-		foreach( EE_Registry::instance()->addons as $addon ){
146
-			if( $addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal ) {
145
+		foreach (EE_Registry::instance()->addons as $addon) {
146
+			if ($addon instanceof EE_Addon && $addon->detect_req_type() != EE_System::req_type_normal) {
147 147
 				EED_Core_Rest_Api::invalidate_cached_route_data();
148 148
 			}
149 149
 		}
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
 	 */
155 155
 	public static function invalidate_cached_route_data() {
156 156
 		//delete the saved EE REST API routes
157
-		delete_option( EED_Core_Rest_Api::saved_routes_option_names );
157
+		delete_option(EED_Core_Rest_Api::saved_routes_option_names);
158 158
 	}
159 159
 
160 160
 	/**
@@ -166,10 +166,10 @@  discard block
 block discarded – undo
166 166
 	 * }
167 167
 	 */
168 168
 	public static function get_ee_route_data() {
169
-		$ee_routes = get_option( self::saved_routes_option_names, null );
170
-		if( ! $ee_routes || ( defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE )){
169
+		$ee_routes = get_option(self::saved_routes_option_names, null);
170
+		if ( ! $ee_routes || (defined('EE_REST_API_DEBUG_MODE') && EE_REST_API_DEBUG_MODE)) {
171 171
 			self::save_ee_routes();
172
-			$ee_routes = get_option( self::saved_routes_option_names, array() );
172
+			$ee_routes = get_option(self::saved_routes_option_names, array());
173 173
 		}
174 174
 		return $ee_routes;
175 175
 	}
@@ -180,7 +180,7 @@  discard block
 block discarded – undo
180 180
 	 * @return void
181 181
 	 */
182 182
 	public static function save_ee_routes() {
183
-		if( EE_Maintenance_Mode::instance()->models_can_query() ){
183
+		if (EE_Maintenance_Mode::instance()->models_can_query()) {
184 184
 			$instance = self::instance();
185 185
 			$routes = apply_filters(
186 186
 				'EED_Core_Rest_Api__save_ee_routes__routes',
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
 					$instance->_register_rpc_routes()
192 192
 				)
193 193
 			);
194
-			update_option( self::saved_routes_option_names, $routes, true );
194
+			update_option(self::saved_routes_option_names, $routes, true);
195 195
 		}
196 196
 	}
197 197
 
@@ -208,24 +208,24 @@  discard block
 block discarded – undo
208 208
 		unset($models_to_register['Extra_Meta']);
209 209
 		unset($models_to_register['Extra_Join']);
210 210
 		$model_routes = array( );
211
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
211
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
212 212
 
213
-			foreach ( $models_to_register as $model_name => $model_classname ) {
214
-				$model = \EE_Registry::instance()->load_model( $model_name );
213
+			foreach ($models_to_register as $model_name => $model_classname) {
214
+				$model = \EE_Registry::instance()->load_model($model_name);
215 215
 				//yes we could just register one route for ALL models, but then they wouldn't show up in the index
216
-				$ee_namespace = self::ee_api_namespace . $version;
217
-				$plural_model_route = EEH_Inflector::pluralize_and_lower( $model_name );
218
-				$singular_model_route = $plural_model_route . '/(?P<id>\d+)' ;
219
-				$model_routes[ $ee_namespace ][ $plural_model_route ] = array(
216
+				$ee_namespace = self::ee_api_namespace.$version;
217
+				$plural_model_route = EEH_Inflector::pluralize_and_lower($model_name);
218
+				$singular_model_route = $plural_model_route.'/(?P<id>\d+)';
219
+				$model_routes[$ee_namespace][$plural_model_route] = array(
220 220
 						array(
221 221
 							'callback' => array(
222 222
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
223 223
 								'handle_request_get_all' ),
224 224
 							'methods' => WP_REST_Server::READABLE,
225 225
 							'hidden_endpoint' => $hidden_endpoint,
226
-							'args' => $this->_get_read_query_params( $model, $version ),
226
+							'args' => $this->_get_read_query_params($model, $version),
227 227
 							'_links' => array(
228
-								'self' => rest_url( $ee_namespace . $singular_model_route ),
228
+								'self' => rest_url($ee_namespace.$singular_model_route),
229 229
 							)
230 230
 						),
231 231
 //						array(
@@ -236,14 +236,14 @@  discard block
 block discarded – undo
236 236
 //							'hidden_endpoint' => $hidden_endpoint
237 237
 //						)
238 238
 					);
239
-				$model_routes[ $ee_namespace ][ $singular_model_route ] = array(
239
+				$model_routes[$ee_namespace][$singular_model_route] = array(
240 240
 						array(
241 241
 							'callback' => array(
242 242
 								'EventEspresso\core\libraries\rest_api\controllers\model\Read',
243 243
 								'handle_request_get_one' ),
244 244
 							'methods' => WP_REST_Server::READABLE,
245 245
 							'hidden_endpoint' => $hidden_endpoint,
246
-							'args' => $this->_get_response_selection_query_params( $model, $version)
246
+							'args' => $this->_get_response_selection_query_params($model, $version)
247 247
 						),
248 248
 //						array(
249 249
 //							'callback' => array(
@@ -254,19 +254,19 @@  discard block
 block discarded – undo
254 254
 //							),
255 255
 				);
256 256
 				//@todo: also handle  DELETE for a single item
257
-				foreach ( $model->relation_settings() as $relation_name => $relation_obj ) {
257
+				foreach ($model->relation_settings() as $relation_name => $relation_obj) {
258 258
 					$related_model_name_endpoint_part = EventEspresso\core\libraries\rest_api\controllers\model\Read::get_related_entity_name(
259 259
 						$relation_name,
260 260
 						$relation_obj
261 261
 					);
262
-					$model_routes[ $ee_namespace ][ $singular_model_route . '/' . $related_model_name_endpoint_part ] = array(
262
+					$model_routes[$ee_namespace][$singular_model_route.'/'.$related_model_name_endpoint_part] = array(
263 263
 							array(
264 264
 								'callback' => array(
265 265
 									'EventEspresso\core\libraries\rest_api\controllers\model\Read',
266 266
 									'handle_request_get_related' ),
267 267
 								'methods' => WP_REST_Server::READABLE,
268 268
 								'hidden_endpoint' => $hidden_endpoint,
269
-								'args' => $this->_get_read_query_params( $relation_obj->get_other_model(), $version ),
269
+								'args' => $this->_get_read_query_params($relation_obj->get_other_model(), $version),
270 270
 							),
271 271
 //							array(
272 272
 //								'callback' => array(
@@ -290,11 +290,11 @@  discard block
 block discarded – undo
290 290
 	 */
291 291
 	protected function _register_rpc_routes() {
292 292
 		$routes = array();
293
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
294
-			$ee_namespace = self::ee_api_namespace . $version;
293
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
294
+			$ee_namespace = self::ee_api_namespace.$version;
295 295
 			$this_versions_routes = array();
296 296
 			//checkin endpoint
297
-			$this_versions_routes[ 'registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)' ] = array(
297
+			$this_versions_routes['registrations/(?P<REG_ID>\d+)/toggle_checkin_for_datetime/(?P<DTT_ID>\d+)'] = array(
298 298
 				array(
299 299
 					'callback' => array(
300 300
 						'EventEspresso\core\libraries\rest_api\controllers\rpc\Checkin',
@@ -305,12 +305,12 @@  discard block
 block discarded – undo
305 305
 						'force' => array(
306 306
 							'required' => false,
307 307
 							'default' => false,
308
-							'description' => __( 'Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso' )
308
+							'description' => __('Whether to force toggle checkin, or to verify the registration status and allowed ticket uses', 'event_espresso')
309 309
 						)
310 310
 					)
311 311
 				)
312 312
 			);
313
-			$routes[ $ee_namespace ] = apply_filters(
313
+			$routes[$ee_namespace] = apply_filters(
314 314
 				'FHEE__EED_Core_Rest_Api___register_rpc_routes__this_versions_routes',
315 315
 				$this_versions_routes,
316 316
 				$version,
@@ -326,19 +326,19 @@  discard block
 block discarded – undo
326 326
 	 * @param string $version
327 327
 	 * @return array
328 328
 	 */
329
-	protected function _get_response_selection_query_params( \EEM_Base $model, $version ) {
329
+	protected function _get_response_selection_query_params(\EEM_Base $model, $version) {
330 330
 		return apply_filters(
331 331
 			'FHEE__EED_Core_Rest_Api___get_response_selection_query_params',
332 332
 			array(
333 333
 				'include' => array(
334 334
 					'required' => false,
335 335
 					'default' => '*',
336
-					'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso' ),
336
+					'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#Including_Specific_Fields_and_Related_Entities_in_Results for documentation', 'event_espresso'),
337 337
 				),
338 338
 				'calculate' => array(
339 339
 					'required' => false,
340 340
 					'default' => '',
341
-					'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model( $model )
341
+					'enum' => self::$_field_calculator->retrieve_calculated_fields_for_model($model)
342 342
 				)
343 343
 			),
344 344
 			$model,
@@ -356,43 +356,43 @@  discard block
 block discarded – undo
356 356
 	 * @return array    describing the args acceptable when querying this model
357 357
 	 * @throws \EE_Error
358 358
 	 */
359
-	protected function _get_read_query_params( \EEM_Base $model, $version ) {
359
+	protected function _get_read_query_params(\EEM_Base $model, $version) {
360 360
 		$default_orderby = array();
361
-		foreach( $model->get_combined_primary_key_fields() as $key_field ) {
362
-			$default_orderby[ $key_field->get_name() ] = 'ASC';
361
+		foreach ($model->get_combined_primary_key_fields() as $key_field) {
362
+			$default_orderby[$key_field->get_name()] = 'ASC';
363 363
 		}
364 364
 		return array_merge(
365
-			$this->_get_response_selection_query_params( $model, $version ),
365
+			$this->_get_response_selection_query_params($model, $version),
366 366
 			array(
367 367
 				'where' => array(
368 368
 					'required' => false,
369 369
 					'default' => array(),
370
-					'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso' ),
370
+					'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#where for documentation', 'event_espresso'),
371 371
 					),
372 372
 				'limit' => array(
373 373
 					'required' => false,
374 374
 					'default' => EED_Core_Rest_Api::get_default_query_limit(),
375
-					'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso' )
375
+					'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#limit for documentation', 'event_espresso')
376 376
 				),
377 377
 				'order_by' => array(
378 378
 					'required' => false,
379 379
 					'default' => $default_orderby,
380
-					'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso' )
380
+					'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#order_by for documentation', 'event_espresso')
381 381
 				),
382 382
 				'group_by' => array(
383 383
 					'required' => false,
384 384
 					'default' => null,
385
-					'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso' )
385
+					'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#group_by for documentation', 'event_espresso')
386 386
 				),
387 387
 				'having' => array(
388 388
 					'required' => false,
389 389
 					'default' => null,
390
-					'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso' )
390
+					'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#having for documentation', 'event_espresso')
391 391
 				),
392 392
 				'caps' => array(
393 393
 					'required' => false,
394 394
 					'default' => EEM_Base::caps_read,
395
-					'description' => __( 'See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso' )
395
+					'description' => __('See http://developer.eventespresso.com/docs/ee4-rest-api-reading/#caps for documentation', 'event_espresso')
396 396
 				),
397 397
 			)
398 398
 		);
@@ -404,8 +404,8 @@  discard block
 block discarded – undo
404 404
 	 */
405 405
 	protected function _register_config_routes() {
406 406
 		$config_routes = array();
407
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
408
-			$config_routes[ self::ee_api_namespace . $version ][ 'config' ] = array(
407
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
408
+			$config_routes[self::ee_api_namespace.$version]['config'] = array(
409 409
 					array(
410 410
 						'callback' => array(
411 411
 							'EventEspresso\core\libraries\rest_api\controllers\config\Read',
@@ -424,8 +424,8 @@  discard block
 block discarded – undo
424 424
 	 */
425 425
 	protected function _register_meta_routes() {
426 426
 		$meta_routes = array();
427
-		foreach( self::versions_served() as $version => $hidden_endpoint ) {
428
-			$meta_routes[ self::ee_api_namespace . $version ][ '/resources' ] = array(
427
+		foreach (self::versions_served() as $version => $hidden_endpoint) {
428
+			$meta_routes[self::ee_api_namespace.$version]['/resources'] = array(
429 429
 				array(
430 430
 					'callback' => array(
431 431
 						'EventEspresso\core\libraries\rest_api\controllers\model\Meta',
@@ -446,13 +446,13 @@  discard block
 block discarded – undo
446 446
 	 * @param array $route_data
447 447
 	 * @return array
448 448
 	 */
449
-	public static function hide_old_endpoints( $route_data ) {
450
-		foreach( EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls ) {
451
-			foreach( $relative_urls as $endpoint => $routes ) {
452
-				foreach( $routes as $route ) {
453
-					if( $route[ 'hidden_endpoint' ] ) {
454
-						$full_route = '/' . ltrim( $namespace, '/' ) . '/' . ltrim( $endpoint, '/' );
455
-						unset( $route_data[ $full_route ] );
449
+	public static function hide_old_endpoints($route_data) {
450
+		foreach (EED_Core_Rest_Api::get_ee_route_data() as $namespace => $relative_urls) {
451
+			foreach ($relative_urls as $endpoint => $routes) {
452
+				foreach ($routes as $route) {
453
+					if ($route['hidden_endpoint']) {
454
+						$full_route = '/'.ltrim($namespace, '/').'/'.ltrim($endpoint, '/');
455
+						unset($route_data[$full_route]);
456 456
 					}
457 457
 				}
458 458
 			}
@@ -491,7 +491,7 @@  discard block
 block discarded – undo
491 491
 	 */
492 492
 	public static function latest_rest_api_version() {
493 493
 		$versions_served = \EED_Core_Rest_Api::versions_served();
494
-		return end( array_keys( $versions_served ) );
494
+		return end(array_keys($versions_served));
495 495
 	}
496 496
 
497 497
 	/**
@@ -505,32 +505,32 @@  discard block
 block discarded – undo
505 505
 	public static function versions_served() {
506 506
 		$versions_served = array();
507 507
 		$possibly_served_versions = EED_Core_Rest_Api::version_compatibilities();
508
-		$lowest_compatible_version = end( $possibly_served_versions);
509
-		reset( $possibly_served_versions );
510
-		$versions_served_historically = array_keys( $possibly_served_versions );
511
-		$latest_version = end( $versions_served_historically );
512
-		reset( $versions_served_historically );
508
+		$lowest_compatible_version = end($possibly_served_versions);
509
+		reset($possibly_served_versions);
510
+		$versions_served_historically = array_keys($possibly_served_versions);
511
+		$latest_version = end($versions_served_historically);
512
+		reset($versions_served_historically);
513 513
 		//for each version of core we have ever served:
514
-		foreach ( $versions_served_historically as $key_versioned_endpoint ) {
514
+		foreach ($versions_served_historically as $key_versioned_endpoint) {
515 515
 			//if it's not above the current core version, and it's compatible with the current version of core
516
-			if( $key_versioned_endpoint == $latest_version ) {
516
+			if ($key_versioned_endpoint == $latest_version) {
517 517
 				//don't hide the latest version in the index
518
-				$versions_served[ $key_versioned_endpoint ] = false;
519
-			} else if(
518
+				$versions_served[$key_versioned_endpoint] = false;
519
+			} else if (
520 520
 				$key_versioned_endpoint < EED_Core_Rest_Api::core_version()
521 521
 				&& $key_versioned_endpoint >= $lowest_compatible_version
522 522
 			) {
523 523
 				//include, but hide, previous versions which are still supported
524
-				$versions_served[ $key_versioned_endpoint ] = true;
525
-			} elseif(
524
+				$versions_served[$key_versioned_endpoint] = true;
525
+			} elseif (
526 526
 				apply_filters(
527 527
 					'FHEE__EED_Core_Rest_Api__versions_served__include_incompatible_versions',
528 528
 					false,
529 529
 					$possibly_served_versions
530 530
 				)
531
-			){
531
+			) {
532 532
 				//if a version is no longer supported, don't include it in index or list of versions served
533
-				$versions_served[ $key_versioned_endpoint ] = true;
533
+				$versions_served[$key_versioned_endpoint] = true;
534 534
 			}
535 535
 		}
536 536
 		return $versions_served;
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 	 * @return string
544 544
 	 */
545 545
 	public static function core_version() {
546
-		return apply_filters( 'FHEE__EED_Core_REST_API__core_version', implode('.', array_slice( explode( '.', espresso_version() ), 0, 3 ) ) );
546
+		return apply_filters('FHEE__EED_Core_REST_API__core_version', implode('.', array_slice(explode('.', espresso_version()), 0, 3)));
547 547
 	}
548 548
 
549 549
 	/**
@@ -568,7 +568,7 @@  discard block
 block discarded – undo
568 568
 	 * @param  WP $WP
569 569
 	 * @return    void
570 570
 	 */
571
-	public function run( $WP ) {
571
+	public function run($WP) {
572 572
 
573 573
 	}
574 574
 
Please login to merge, or discard this patch.
modules/bot_trap/EED_Bot_Trap.module.php 1 patch
Spacing   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@  discard block
 block discarded – undo
18 18
 	 * @return EED_Bot_Trap
19 19
 	 */
20 20
 	public static function instance() {
21
-		return parent::get_instance( __CLASS__ );
21
+		return parent::get_instance(__CLASS__);
22 22
 	}
23 23
 
24 24
 
@@ -31,22 +31,22 @@  discard block
 block discarded – undo
31 31
 	 */
32 32
 	public static function set_hooks() {
33 33
 		if (
34
-			apply_filters( 'FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true ) &&
34
+			apply_filters('FHEE__EED_Bot_Trap__set_hooks__use_bot_trap', true) &&
35 35
 			EE_Registry::instance()->CFG->registration->use_bot_trap
36 36
 		) {
37
-			define( 'EE_BOT_TRAP_BASE_URL', plugin_dir_url( __FILE__ ) . DS );
37
+			define('EE_BOT_TRAP_BASE_URL', plugin_dir_url(__FILE__).DS);
38 38
 			add_action(
39 39
 				'AHEE__ticket_selector_chart__template__after_ticket_selector',
40
-				array( 'EED_Bot_Trap', 'generate_bot_trap' ),
40
+				array('EED_Bot_Trap', 'generate_bot_trap'),
41 41
 				10, 2
42 42
 			);
43 43
 			add_action(
44 44
 				'EED_Ticket_Selector__process_ticket_selections__before',
45
-				array( 'EED_Bot_Trap', 'process_bot_trap' ),
45
+				array('EED_Bot_Trap', 'process_bot_trap'),
46 46
 				1, 2
47 47
 			);
48 48
 			// redirect bots to bogus success page
49
-			EE_Config::register_route( 'ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success' );
49
+			EE_Config::register_route('ticket_selection_received', 'EED_Bot_Trap', 'display_bot_trap_success');
50 50
 		}
51 51
 	}
52 52
 
@@ -61,12 +61,12 @@  discard block
 block discarded – undo
61 61
 	public static function set_hooks_admin() {
62 62
 		add_action(
63 63
 			'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template',
64
-			array( 'EED_Bot_Trap', 'bot_trap_settings_form' ),
64
+			array('EED_Bot_Trap', 'bot_trap_settings_form'),
65 65
 			10
66 66
 		);
67 67
 		add_filter(
68 68
 			'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration',
69
-			array( 'EED_Bot_Trap', 'update_bot_trap_settings_form' ),
69
+			array('EED_Bot_Trap', 'update_bot_trap_settings_form'),
70 70
 			10, 1
71 71
 		);
72 72
 	}
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 	 * @param    WP $WP
81 81
 	 * @return    void
82 82
 	 */
83
-	public function run( $WP ) {}
83
+	public function run($WP) {}
84 84
 
85 85
 
86 86
 
@@ -91,14 +91,14 @@  discard block
 block discarded – undo
91 91
 	 * @return    void
92 92
 	 */
93 93
 	public static function generate_bot_trap() {
94
-		$do_not_enter = __( 'please do not enter anything in this input', 'event_espresso' );
94
+		$do_not_enter = __('please do not enter anything in this input', 'event_espresso');
95 95
 		$html = '<div id="tkt-slctr-request-processor-dv" style="float:left; margin-left:-999em;">';
96
-		$html .= '<label for="tkt-slctr-request-processor-email">' . $do_not_enter  . '</label>';
96
+		$html .= '<label for="tkt-slctr-request-processor-email">'.$do_not_enter.'</label>';
97 97
 		$html .= '<input type="email" name="tkt-slctr-request-processor-email" value=""/>';
98 98
 		$html .= '<input type="hidden" name="tkt-slctr-request-processor-token" value="';
99
-		if ( EE_Registry::instance()->CFG->registration->use_encryption ) {
100
-			EE_Registry::instance()->load_core( 'EE_Encryption' );
101
-			$html .= EE_Encryption::instance()->encrypt( time() );
99
+		if (EE_Registry::instance()->CFG->registration->use_encryption) {
100
+			EE_Registry::instance()->load_core('EE_Encryption');
101
+			$html .= EE_Encryption::instance()->encrypt(time());
102 102
 		} else {
103 103
 			$html .= time();
104 104
 		}
@@ -117,35 +117,35 @@  discard block
 block discarded – undo
117 117
 	 */
118 118
 	public static function process_bot_trap() {
119 119
 		// what's your email address Mr. Bot ?
120
-		$empty_trap = isset( $_REQUEST[ 'tkt-slctr-request-processor-email' ] ) && $_REQUEST[ 'tkt-slctr-request-processor-email' ] == '' ? true : false;
120
+		$empty_trap = isset($_REQUEST['tkt-slctr-request-processor-email']) && $_REQUEST['tkt-slctr-request-processor-email'] == '' ? true : false;
121 121
 		// get encrypted timestamp for when the form was originally displayed
122
-		$bot_trap_timestamp = isset( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) ? sanitize_text_field( $_REQUEST[ 'tkt-slctr-request-processor-token' ] ) : '';
122
+		$bot_trap_timestamp = isset($_REQUEST['tkt-slctr-request-processor-token']) ? sanitize_text_field($_REQUEST['tkt-slctr-request-processor-token']) : '';
123 123
 		// decrypt and convert to absolute  integer
124
-		if ( EE_Registry::instance()->CFG->registration->use_encryption ) {
125
-			EE_Registry::instance()->load_core( 'EE_Encryption' );
126
-			$bot_trap_timestamp = absint( EE_Encryption::instance()->decrypt( $bot_trap_timestamp ) );
124
+		if (EE_Registry::instance()->CFG->registration->use_encryption) {
125
+			EE_Registry::instance()->load_core('EE_Encryption');
126
+			$bot_trap_timestamp = absint(EE_Encryption::instance()->decrypt($bot_trap_timestamp));
127 127
 		} else {
128
-			$bot_trap_timestamp = absint( $bot_trap_timestamp );
128
+			$bot_trap_timestamp = absint($bot_trap_timestamp);
129 129
 		}
130 130
 		// ticket form submitted too impossibly fast ( after now ) or more than an hour later ???
131
-		$suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < ( time() - HOUR_IN_SECONDS ) ? true : false;
131
+		$suspicious_timing = $bot_trap_timestamp > time() || $bot_trap_timestamp < (time() - HOUR_IN_SECONDS) ? true : false;
132 132
 		// are we human ?
133
-		if ( $empty_trap && ! $suspicious_timing ) {
133
+		if ($empty_trap && ! $suspicious_timing) {
134 134
 			return;
135 135
 		}
136 136
 		// UH OH...
137 137
 		$redirect_url = add_query_arg(
138
-			array( 'ee' => 'ticket_selection_received' ),
138
+			array('ee' => 'ticket_selection_received'),
139 139
 			EE_Registry::instance()->CFG->core->reg_page_url()
140 140
 		);
141
-		if ( $suspicious_timing ) {
141
+		if ($suspicious_timing) {
142 142
 			$redirect_url = add_query_arg(
143
-				array( 'ee-notice' => urlencode( __( 'We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso' ) ) ),
143
+				array('ee-notice' => urlencode(__('We\'re sorry, but your ticket selections could not be processed due to a server timing error. Please hit the back button on your browser and try again.', 'event_espresso'))),
144 144
 				$redirect_url
145 145
 			);
146 146
 		}
147 147
 		wp_safe_redirect(
148
-			apply_filters( 'FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url )
148
+			apply_filters('FHEE__EED_Bot_Trap__process_bot_trap__redirect_url', $redirect_url)
149 149
 		);
150 150
 		exit();
151 151
 	}
@@ -160,10 +160,10 @@  discard block
 block discarded – undo
160 160
 	 * @return    void
161 161
 	 */
162 162
 	public static function display_bot_trap_success() {
163
-		add_filter( 'FHEE__EED_Single_Page_Checkout__run', '__return_false' );
164
-		$bot_notice = __( 'Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso' );
165
-		$bot_notice = isset( $_REQUEST[ 'ee-notice' ] ) && $_REQUEST[ 'ee-notice' ] !== '' ? sanitize_text_field( stripslashes( $_REQUEST[ 'ee-notice' ] ) ) : $bot_notice;
166
-		EE_Registry::instance()->REQ->add_output( EEH_HTML::div( $bot_notice, '', 'ee-attention' ) );
163
+		add_filter('FHEE__EED_Single_Page_Checkout__run', '__return_false');
164
+		$bot_notice = __('Thank you so much. Your ticket selections have been received for consideration.', 'event_espresso');
165
+		$bot_notice = isset($_REQUEST['ee-notice']) && $_REQUEST['ee-notice'] !== '' ? sanitize_text_field(stripslashes($_REQUEST['ee-notice'])) : $bot_notice;
166
+		EE_Registry::instance()->REQ->add_output(EEH_HTML::div($bot_notice, '', 'ee-attention'));
167 167
 	}
168 168
 
169 169
 
@@ -197,20 +197,20 @@  discard block
 block discarded – undo
197 197
 				'html_id'         			=> 'bot_trap_settings',
198 198
 				'layout_strategy' 	=> new EE_Admin_Two_Column_Layout(),
199 199
 				'subsections'     		=> array(
200
-					'bot_trap_hdr' 		=> new EE_Form_Section_HTML( EEH_HTML::h2( __( 'Bot Trap Settings', 'event_espresso' ) ) ),
200
+					'bot_trap_hdr' 		=> new EE_Form_Section_HTML(EEH_HTML::h2(__('Bot Trap Settings', 'event_espresso'))),
201 201
 					'use_bot_trap' 		=> new EE_Yes_No_Input(
202 202
 						array(
203
-							'html_label_text' 	=> __( 'Enable Bot Trap', 'event_espresso' ),
204
-							'html_help_text' 		=>  __( 'The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso' ),
205
-							'default'        			=> isset( EE_Registry::instance()->CFG->registration->use_bot_trap ) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true,
203
+							'html_label_text' 	=> __('Enable Bot Trap', 'event_espresso'),
204
+							'html_help_text' 		=>  __('The Event Espresso Bot Trap will insert a fake input into your Ticket Selector forms that is hidden from regular site visitors, but visible to spam bots. Because the input asks for an email address, it is irresistible to spam bots who will of course enter text into it. Since regular site visitors can not see this input, any value detected during form submission means a bot has been detected, which will then be blocked from submitting the form.', 'event_espresso'),
205
+							'default'        			=> isset(EE_Registry::instance()->CFG->registration->use_bot_trap) ? EE_Registry::instance()->CFG->registration->use_bot_trap : true,
206 206
 							'required'        		=> false
207 207
 						)
208 208
 					),
209 209
 					'use_encryption' 		=> new EE_Yes_No_Input(
210 210
 						array(
211
-							'html_label_text' 	=> __( 'Encrypt Bot Trap Data', 'event_espresso' ),
212
-							'html_help_text' 		=>  __( 'One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso' ),
213
-							'default'        			=> isset( EE_Registry::instance()->CFG->registration->use_encryption ) ? EE_Registry::instance()->CFG->registration->use_encryption : true,
211
+							'html_label_text' 	=> __('Encrypt Bot Trap Data', 'event_espresso'),
212
+							'html_help_text' 		=>  __('One way to detect spam bots is by looking at how long it takes them to submit a form. They are often inhumanly fast, or will submit forms hours, days, or even weeks after the form was first scraped off the web. The Event Espresso Bot Trap will send a timestamp with the Ticket Selector form when it is submitted. By default, this timestamp is encrypted so that the spam bots can not change it, but encryption may cause issues on some servers due to configuration "conflicts". If you continuously get caught in the bot trap, then try setting this option to "No". This may increase the number of spam submissions you receive, but increases server compatibility.', 'event_espresso'),
213
+							'default'        			=> isset(EE_Registry::instance()->CFG->registration->use_encryption) ? EE_Registry::instance()->CFG->registration->use_encryption : true,
214 214
 							'required'        		=> false
215 215
 						)
216 216
 					),
@@ -228,30 +228,30 @@  discard block
 block discarded – undo
228 228
 	 * @param \EE_Registration_Config $EE_Registration_Config
229 229
 	 * @return \EE_Registration_Config
230 230
 	 */
231
-	public static function update_bot_trap_settings_form( EE_Registration_Config $EE_Registration_Config ) {
231
+	public static function update_bot_trap_settings_form(EE_Registration_Config $EE_Registration_Config) {
232 232
 		try {
233 233
 			$bot_trap_settings_form = EED_Bot_Trap::_bot_trap_settings_form();
234 234
 			// if not displaying a form, then check for form submission
235
-			if ( $bot_trap_settings_form->was_submitted() ) {
235
+			if ($bot_trap_settings_form->was_submitted()) {
236 236
 				// capture form data
237 237
 				$bot_trap_settings_form->receive_form_submission();
238 238
 				// validate form data
239
-				if ( $bot_trap_settings_form->is_valid() ) {
239
+				if ($bot_trap_settings_form->is_valid()) {
240 240
 					// grab validated data from form
241 241
 					$valid_data = $bot_trap_settings_form->valid_data();
242
-					if ( isset( $valid_data[ 'use_bot_trap' ], $valid_data[ 'use_encryption' ] ) ) {
243
-						$EE_Registration_Config->use_bot_trap = $valid_data[ 'use_bot_trap' ];
244
-						$EE_Registration_Config->use_encryption = $valid_data[ 'use_encryption' ];
242
+					if (isset($valid_data['use_bot_trap'], $valid_data['use_encryption'])) {
243
+						$EE_Registration_Config->use_bot_trap = $valid_data['use_bot_trap'];
244
+						$EE_Registration_Config->use_encryption = $valid_data['use_encryption'];
245 245
 					} else {
246
-						EE_Error::add_error( __( 'Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
246
+						EE_Error::add_error(__('Invalid or missing Bot Trap settings. Please refresh the form and try again.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
247 247
 					}
248 248
 				} else {
249
-					if ( $bot_trap_settings_form->submission_error_message() != '' ) {
250
-						EE_Error::add_error( $bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ );
249
+					if ($bot_trap_settings_form->submission_error_message() != '') {
250
+						EE_Error::add_error($bot_trap_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__);
251 251
 					}
252 252
 				}
253 253
 			}
254
-		} catch ( EE_Error $e ) {
254
+		} catch (EE_Error $e) {
255 255
 			$e->get_error();
256 256
 		}
257 257
 		return $EE_Registration_Config;
Please login to merge, or discard this patch.
admin_pages/maintenance/Maintenance_Admin_Page.core.php 1 patch
Spacing   +87 added lines, -87 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 Maintenance_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
 
@@ -46,8 +46,8 @@  discard block
 block discarded – undo
46 46
 
47 47
 
48 48
 	protected function _ajax_hooks() {
49
-		add_action('wp_ajax_migration_step',array($this,'migration_step'));
50
-		add_action('wp_ajax_add_error_to_migrations_ran',array($this,'add_error_to_migrations_ran'));
49
+		add_action('wp_ajax_migration_step', array($this, 'migration_step'));
50
+		add_action('wp_ajax_add_error_to_migrations_ran', array($this, 'add_error_to_migrations_ran'));
51 51
 	}
52 52
 
53 53
 
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
 		$this->_admin_page_title = EE_MAINTENANCE_LABEL;
57 57
 		$this->_labels = array(
58 58
 			'buttons' => array(
59
-				'reset_capabilities' => __( 'Reset Event Espresso Capabilities', 'event_espresso' )
59
+				'reset_capabilities' => __('Reset Event Espresso Capabilities', 'event_espresso')
60 60
 				)
61 61
 			);
62 62
 	}
@@ -155,23 +155,23 @@  discard block
 block discarded – undo
155 155
 	 * default maintenance page. If we're in maintenance mode level 2, then we need to show
156 156
 	 * the migration scripts and all that UI.
157 157
 	 */
158
-	public function _maintenance(){
158
+	public function _maintenance() {
159 159
 		//it all depends if we're in maintenance model level 1 (frontend-only) or
160 160
 		//level 2 (everything except maintenance page)
161
-		try{
161
+		try {
162 162
 			//get the current maintenance level and check if
163 163
 			//we are removed
164 164
 			$mm = EE_Maintenance_Mode::instance()->level();
165 165
 			$placed_in_mm = EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
166
-			if( $mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm){
166
+			if ($mm == EE_Maintenance_Mode::level_2_complete_maintenance && ! $placed_in_mm) {
167 167
 				//we just took the site out of maintenance mode, so notify the user.
168 168
 				//unfortunately this message appears to be echoed on the NEXT page load...
169 169
 				//oh well, we should really be checking for this on addon deactivation anyways
170
-				EE_Error::add_attention( __( 'Site taken out of maintenance mode because no data migration scripts are required', 'event_espresso' ) );
171
-				$this->_process_notices( array( 'page' => 'espresso_maintenance_settings'), false );
170
+				EE_Error::add_attention(__('Site taken out of maintenance mode because no data migration scripts are required', 'event_espresso'));
171
+				$this->_process_notices(array('page' => 'espresso_maintenance_settings'), false);
172 172
 			}
173 173
 			//in case an exception is thrown while trying to handle migrations
174
-			switch(EE_Maintenance_Mode::instance()->level()){
174
+			switch (EE_Maintenance_Mode::instance()->level()) {
175 175
 				case EE_Maintenance_Mode::level_0_not_in_maintenance:
176 176
 				case EE_Maintenance_Mode::level_1_frontend_only_maintenance:
177 177
 					$show_maintenance_switch = true;
@@ -183,18 +183,18 @@  discard block
 block discarded – undo
183 183
 				case EE_Maintenance_Mode::level_2_complete_maintenance:
184 184
 					$show_maintenance_switch = false;
185 185
 					$show_migration_progress = true;
186
-					if(isset($this->_req_data['continue_migration'])){
186
+					if (isset($this->_req_data['continue_migration'])) {
187 187
 						$show_backup_db_text = false;
188
-					}else{
188
+					} else {
189 189
 						$show_backup_db_text = true;
190 190
 					}
191 191
 					$scripts_needing_to_run = EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts();
192 192
 					$addons_should_be_upgraded_first = EE_Data_Migration_Manager::instance()->addons_need_updating();
193 193
 					$script_names = array();
194 194
 					$current_script = NULL;
195
-					foreach($scripts_needing_to_run as $script){
196
-						if($script instanceof EE_Data_Migration_Script_Base){
197
-							if( ! $current_script){
195
+					foreach ($scripts_needing_to_run as $script) {
196
+						if ($script instanceof EE_Data_Migration_Script_Base) {
197
+							if ( ! $current_script) {
198 198
 								$current_script = $script;
199 199
 								$current_script->migration_page_hooks();
200 200
 							}
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
 			}
206 206
 			$most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
207 207
 			$exception_thrown = false;
208
-		}catch(EE_Error $e){
208
+		} catch (EE_Error $e) {
209 209
 
210 210
 			EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
211 211
 			//now, just so we can display the page correctly, make a error migration script stage object
@@ -215,53 +215,53 @@  discard block
 block discarded – undo
215 215
 			$exception_thrown = true;
216 216
 		}
217 217
 		$current_db_state = EE_Data_Migration_Manager::instance()->ensure_current_database_state_is_set();
218
-		if($exception_thrown ||
219
-				(	$most_recent_migration &&
218
+		if ($exception_thrown ||
219
+				($most_recent_migration &&
220 220
 					$most_recent_migration instanceof EE_Data_Migration_Script_Base &&
221 221
 					$most_recent_migration->is_broken()
222
-				)){
223
-			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_was_borked_page.template.php';
224
-			$this->_template_args[ 'support_url' ] = 'http://eventespresso.com/support/forums/';
225
-			$this->_template_args[ 'next_url' ] = EEH_URL::add_query_args_and_nonce(array( 'action' => 'confirm_migration_crash_report_sent', 'success' => '0' ), EE_MAINTENANCE_ADMIN_URL );
226
-		}elseif($addons_should_be_upgraded_first){
227
-			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_upgrade_addons_before_migrating.template.php';
228
-		}else{
229
-			if($most_recent_migration &&
230
-					$most_recent_migration instanceof EE_Data_Migration_Script_Base  &&
231
-					$most_recent_migration->can_continue()){
222
+				)) {
223
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_was_borked_page.template.php';
224
+			$this->_template_args['support_url'] = 'http://eventespresso.com/support/forums/';
225
+			$this->_template_args['next_url'] = EEH_URL::add_query_args_and_nonce(array('action' => 'confirm_migration_crash_report_sent', 'success' => '0'), EE_MAINTENANCE_ADMIN_URL);
226
+		}elseif ($addons_should_be_upgraded_first) {
227
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_upgrade_addons_before_migrating.template.php';
228
+		} else {
229
+			if ($most_recent_migration &&
230
+					$most_recent_migration instanceof EE_Data_Migration_Script_Base &&
231
+					$most_recent_migration->can_continue()) {
232 232
 				$show_backup_db_text = false;
233 233
 				$show_continue_current_migration_script = true;
234 234
 				$show_most_recent_migration = true;
235
-			}elseif(isset($this->_req_data['continue_migration'])){
235
+			}elseif (isset($this->_req_data['continue_migration'])) {
236 236
 				$show_most_recent_migration = true;
237 237
 				$show_continue_current_migration_script = false;
238
-			}else{
238
+			} else {
239 239
 				$show_most_recent_migration = false;
240 240
 				$show_continue_current_migration_script = false;
241 241
 			}
242 242
 
243
-			if(isset($current_script)){
243
+			if (isset($current_script)) {
244 244
 				$migrates_to = $current_script->migrates_to_version();
245
-				$plugin_slug = $migrates_to[ 'slug' ];
246
-				$new_version = $migrates_to[ 'version' ];
247
-				$this->_template_args = array_merge($this->_template_args,array(
248
-					'current_db_state'=>  sprintf(__("EE%s (%s)", "event_espresso"), isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3,$plugin_slug),
249
-					'next_db_state'=>isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'),$new_version,$plugin_slug) : NULL));
245
+				$plugin_slug = $migrates_to['slug'];
246
+				$new_version = $migrates_to['version'];
247
+				$this->_template_args = array_merge($this->_template_args, array(
248
+					'current_db_state'=>  sprintf(__("EE%s (%s)", "event_espresso"), isset($current_db_state[$plugin_slug]) ? $current_db_state[$plugin_slug] : 3, $plugin_slug),
249
+					'next_db_state'=>isset($current_script) ? sprintf(__("EE%s (%s)", 'event_espresso'), $new_version, $plugin_slug) : NULL));
250 250
 			}
251 251
 
252
-			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_migration_page.template.php';
252
+			$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_migration_page.template.php';
253 253
 			$this->_template_args = array_merge(
254 254
 				$this->_template_args,
255 255
 				array(
256
-					'show_most_recent_migration' => $show_most_recent_migration,//flag for showing the most recent migration's status and/or errors
257
-					'show_migration_progress' => $show_migration_progress,//flag for showing the option to run migrations and see their progress
258
-					'show_backup_db_text' => $show_backup_db_text,//flag for showing text telling the user to backup their DB
259
-					'show_maintenance_switch'=> $show_maintenance_switch,//flag for showing the option to change maintenance mode between levels 0 and 1
260
-					'script_names'=>$script_names,//array of names of scripts that have run
261
-					'show_continue_current_migration_script'=>$show_continue_current_migration_script,//flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
256
+					'show_most_recent_migration' => $show_most_recent_migration, //flag for showing the most recent migration's status and/or errors
257
+					'show_migration_progress' => $show_migration_progress, //flag for showing the option to run migrations and see their progress
258
+					'show_backup_db_text' => $show_backup_db_text, //flag for showing text telling the user to backup their DB
259
+					'show_maintenance_switch'=> $show_maintenance_switch, //flag for showing the option to change maintenance mode between levels 0 and 1
260
+					'script_names'=>$script_names, //array of names of scripts that have run
261
+					'show_continue_current_migration_script'=>$show_continue_current_migration_script, //flag to change wording to indicating that we're only CONTINUING a migration script (somehow it got interrupted0
262 262
 					'reset_db_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action'=>'reset_db'), EE_MAINTENANCE_ADMIN_URL),
263
-					'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action'=>'change_maintenance_level'),EE_MAINTENANCE_ADMIN_URL),
264
-					'ultimate_db_state'=>  sprintf(__("EE%s", 'event_espresso'),espresso_version()),
263
+					'update_migration_script_page_link' => EE_Admin_Page::add_query_args_and_nonce(array('action'=>'change_maintenance_level'), EE_MAINTENANCE_ADMIN_URL),
264
+					'ultimate_db_state'=>  sprintf(__("EE%s", 'event_espresso'), espresso_version()),
265 265
 				)
266 266
 			);
267 267
 		//make sure we have the form fields helper available. It usually is, but sometimes it isn't
@@ -275,7 +275,7 @@  discard block
 block discarded – undo
275 275
 			'status_fatal_error'=>  EE_Data_Migration_Manager::status_fatal_error,
276 276
 			'status_completed'=>  EE_Data_Migration_Manager::status_completed));
277 277
 		}
278
-		$this->_template_args['most_recent_migration'] = $most_recent_migration;//the actual most recently ran migration
278
+		$this->_template_args['most_recent_migration'] = $most_recent_migration; //the actual most recently ran migration
279 279
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE);
280 280
 		$this->display_admin_page_with_sidebar();
281 281
 	}
@@ -285,7 +285,7 @@  discard block
 block discarded – undo
285 285
 	/**
286 286
 	 * returns JSON and executes another step of the currently-executing data migration (called via ajax)
287 287
 	 */
288
-	public function migration_step(){
288
+	public function migration_step() {
289 289
 		$this->_template_args['data'] = EE_Data_Migration_Manager::instance()->response_to_migration_ajax_request();
290 290
 		$this->_return_json();
291 291
 	}
@@ -296,7 +296,7 @@  discard block
 block discarded – undo
296 296
 	 * Can be used by js when it notices a response with HTML in it in order
297 297
 	 * to log the malformed response
298 298
 	 */
299
-	public function add_error_to_migrations_ran(){
299
+	public function add_error_to_migrations_ran() {
300 300
 		EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($this->_req_data['message']);
301 301
 		$this->_template_args['data'] = array('ok'=>true);
302 302
 		$this->_return_json();
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
 	/**
308 308
 	 * changes the maintenance level, provided there are still no migration scripts that shoudl run
309 309
 	 */
310
-	public function _change_maintenance_level(){
310
+	public function _change_maintenance_level() {
311 311
 		$new_level = intval($this->_req_data['maintenance_mode_level']);
312
-		if( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()){
312
+		if ( ! EE_Data_Migration_Manager::instance()->check_for_applicable_data_migration_scripts()) {
313 313
 			EE_Maintenance_Mode::instance()->set_maintenance_level($new_level);
314 314
 			$success = true;
315
-		}else{
315
+		} else {
316 316
 			EE_Maintenance_Mode::instance()->set_maintenance_mode_if_db_old();
317
-			$success= false;
317
+			$success = false;
318 318
 		}
319 319
 		$this->_redirect_after_action($success, 'Maintenance Mode', __("Updated", "event_espresso"));
320 320
 	}
@@ -324,9 +324,9 @@  discard block
 block discarded – undo
324 324
 	/**
325 325
 	 * a tab with options for reseting and/or deleting EE data
326 326
 	 */
327
-	public function _data_reset_and_delete(){
328
-		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_data_reset_and_delete.template.php';
329
-		$this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button( 'reset_capabilities', 'reset_capabilities', array(),  'button button-primary' );
327
+	public function _data_reset_and_delete() {
328
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_data_reset_and_delete.template.php';
329
+		$this->_template_args['reset_capabilities_button'] = $this->get_action_link_or_button('reset_capabilities', 'reset_capabilities', array(), 'button button-primary');
330 330
 		$this->_template_args['delete_db_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_db'), EE_MAINTENANCE_ADMIN_URL);
331 331
 		$this->_template_args['reset_db_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'reset_db'), EE_MAINTENANCE_ADMIN_URL);
332 332
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE);
@@ -336,9 +336,9 @@  discard block
 block discarded – undo
336 336
 
337 337
 
338 338
 	protected function _reset_capabilities() {
339
-		EE_Registry::instance()->CAP->init_caps( true );
340
-		EE_Error::add_success( __('Default Event Espresso capabilities have been restored for all current roles.', 'event_espresso' ) );
341
-		$this->_redirect_after_action( FALSE, '', '', array( 'action' => 'data_reset' ), TRUE );
339
+		EE_Registry::instance()->CAP->init_caps(true);
340
+		EE_Error::add_success(__('Default Event Espresso capabilities have been restored for all current roles.', 'event_espresso'));
341
+		$this->_redirect_after_action(FALSE, '', '', array('action' => 'data_reset'), TRUE);
342 342
 	}
343 343
 
344 344
 	/**
@@ -348,7 +348,7 @@  discard block
 block discarded – undo
348 348
 	 */
349 349
 	protected function _reattempt_migration() {
350 350
 		EE_Data_Migration_Manager::instance()->reattempt();
351
-		$this->_redirect_after_action( FALSE, '', '', array( 'action' => 'default' ), TRUE );
351
+		$this->_redirect_after_action(FALSE, '', '', array('action' => 'default'), TRUE);
352 352
 	}
353 353
 
354 354
 
@@ -357,8 +357,8 @@  discard block
 block discarded – undo
357 357
 	/**
358 358
 	 * shows the big ol' System Information page
359 359
 	 */
360
-	public function _system_status(){
361
-		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_system_stati_page.template.php';
360
+	public function _system_status() {
361
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_system_stati_page.template.php';
362 362
 		$this->_template_args['system_stati'] = EEM_System_Status::instance()->get_system_stati();
363 363
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE);
364 364
 		$this->display_admin_page_with_sidebar();
@@ -366,30 +366,30 @@  discard block
 block discarded – undo
366 366
 
367 367
 
368 368
 
369
-	public function _send_migration_crash_report(){
369
+	public function _send_migration_crash_report() {
370 370
 		$from = $this->_req_data['from'];
371 371
 		$from_name = $this->_req_data['from_name'];
372 372
 		$body = $this->_req_data['body'];
373
-		try{
373
+		try {
374 374
 		$success = wp_mail(EE_SUPPORT_EMAIL,
375 375
 				'Migration Crash Report',
376
-				$body."/r/n<br>".  print_r(EEM_System_Status::instance()->get_system_stati(),true),
376
+				$body."/r/n<br>".print_r(EEM_System_Status::instance()->get_system_stati(), true),
377 377
 				array(
378 378
 					"from:$from_name<$from>",
379 379
 //					'content-type:text/html charset=UTF-8'
380 380
 					));
381
-		}catch( Exception $e ){
381
+		} catch (Exception $e) {
382 382
 			$success = FALSE;
383 383
 		}
384
-		$this->_redirect_after_action($success, __("Migration Crash Report", "event_espresso"), __("sent", "event_espresso"),array('success'=>$success,'action'=>'confirm_migration_crash_report_sent'));
384
+		$this->_redirect_after_action($success, __("Migration Crash Report", "event_espresso"), __("sent", "event_espresso"), array('success'=>$success, 'action'=>'confirm_migration_crash_report_sent'));
385 385
 	}
386 386
 
387 387
 
388 388
 
389
-	public function _confirm_migration_crash_report_sent(){
390
-		try{
389
+	public function _confirm_migration_crash_report_sent() {
390
+		try {
391 391
 			$most_recent_migration = EE_Data_Migration_Manager::instance()->get_last_ran_script(true);
392
-		}catch(EE_Error $e){
392
+		} catch (EE_Error $e) {
393 393
 
394 394
 			EE_Data_Migration_Manager::instance()->add_error_to_migrations_ran($e->getMessage());
395 395
 			//now, just so we can display the page correctly, make a error migration script stage object
@@ -397,14 +397,14 @@  discard block
 block discarded – undo
397 397
 			$most_recent_migration = new EE_DMS_Unknown_1_0_0();
398 398
 			$most_recent_migration->add_error($e->getMessage());
399 399
 		}
400
-		$success = $this->_req_data['success']=='1' ? true : false;
400
+		$success = $this->_req_data['success'] == '1' ? true : false;
401 401
 		$this->_template_args['success'] = $success;
402
-		$this->_template_args[ 'most_recent_migration' ] = $most_recent_migration;
402
+		$this->_template_args['most_recent_migration'] = $most_recent_migration;
403 403
 		$this->_template_args['reset_db_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'reset_db'), EE_MAINTENANCE_ADMIN_URL);
404
-		$this->_template_args[ 'reset_db_page_url' ] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'data_reset'), EE_MAINTENANCE_ADMIN_URL);
405
-		$this->_template_args[ 'reattempt_action_url' ] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'reattempt_migration'), EE_MAINTENANCE_ADMIN_URL );
406
-		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH . 'ee_confirm_migration_crash_report_sent.template.php';
407
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path,$this->_template_args,TRUE);
404
+		$this->_template_args['reset_db_page_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'data_reset'), EE_MAINTENANCE_ADMIN_URL);
405
+		$this->_template_args['reattempt_action_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'reattempt_migration'), EE_MAINTENANCE_ADMIN_URL);
406
+		$this->_template_path = EE_MAINTENANCE_TEMPLATE_PATH.'ee_confirm_migration_crash_report_sent.template.php';
407
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE);
408 408
 		$this->display_admin_page_with_sidebar();
409 409
 	}
410 410
 
@@ -417,18 +417,18 @@  discard block
 block discarded – undo
417 417
 	 * @param boolean $nuke_old_ee4_data controls whether or not we
418 418
 	 * destroy the old ee4 data, or just try initializing ee4 default data
419 419
 	 */
420
-	public function _reset_db( $nuke_old_ee4_data = TRUE ){
420
+	public function _reset_db($nuke_old_ee4_data = TRUE) {
421 421
 		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
422 422
 
423
-		if( $nuke_old_ee4_data ){
423
+		if ($nuke_old_ee4_data) {
424 424
 			EEH_Activation::delete_all_espresso_cpt_data();
425
-			EEH_Activation::delete_all_espresso_tables_and_data( FALSE );
425
+			EEH_Activation::delete_all_espresso_tables_and_data(FALSE);
426 426
 			EEH_Activation::remove_cron_tasks();
427 427
 		}
428 428
 		//make sure when we reset the registry's config that it
429 429
 		//switches to using the new singleton
430
-		EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset( TRUE );
431
-		EE_System::instance()->initialize_db_if_no_migrations_required( TRUE );
430
+		EE_Registry::instance()->CFG = EE_Registry::instance()->CFG->reset(TRUE);
431
+		EE_System::instance()->initialize_db_if_no_migrations_required(TRUE);
432 432
 		EE_System::instance()->redirect_to_about_ee();
433 433
 	}
434 434
 
@@ -437,20 +437,20 @@  discard block
 block discarded – undo
437 437
 	/**
438 438
 	 * Deletes ALL EE tables, Records, and Options from the database.
439 439
 	 */
440
-	public function _delete_db(){
440
+	public function _delete_db() {
441 441
 		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
442 442
 		EEH_Activation::delete_all_espresso_cpt_data();
443 443
 		EEH_Activation::delete_all_espresso_tables_and_data();
444 444
 		EEH_Activation::remove_cron_tasks();
445 445
 		EEH_Activation::deactivate_event_espresso();
446
-		wp_safe_redirect( admin_url( 'plugins.php' ));
446
+		wp_safe_redirect(admin_url('plugins.php'));
447 447
 		exit;
448 448
 	}
449 449
 
450 450
 	/**
451 451
 	 * sets up EE4 to rerun the migrations from ee3 to ee4
452 452
 	 */
453
-	public function _rerun_migration_from_ee3(){
453
+	public function _rerun_migration_from_ee3() {
454 454
 		EE_Maintenance_Mode::instance()->set_maintenance_level(EE_Maintenance_Mode::level_0_not_in_maintenance);
455 455
 		EEH_Activation::delete_all_espresso_cpt_data();
456 456
 		EEH_Activation::delete_all_espresso_tables_and_data(false);
@@ -477,9 +477,9 @@  discard block
 block discarded – undo
477 477
 		wp_enqueue_script('ee_admin_js');
478 478
 //		wp_enqueue_media();
479 479
 //		wp_enqueue_script('media-upload');
480
-		wp_enqueue_script('ee-maintenance',EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js',array('jquery'),EVENT_ESPRESSO_VERSION,true);
480
+		wp_enqueue_script('ee-maintenance', EE_MAINTENANCE_ASSETS_URL.'/ee-maintenance.js', array('jquery'), EVENT_ESPRESSO_VERSION, true);
481 481
 
482
-		wp_register_style( 'espresso_maintenance', EE_MAINTENANCE_ASSETS_URL . 'ee-maintenance.css', array(), EVENT_ESPRESSO_VERSION );
482
+		wp_register_style('espresso_maintenance', EE_MAINTENANCE_ASSETS_URL.'ee-maintenance.css', array(), EVENT_ESPRESSO_VERSION);
483 483
 		wp_enqueue_style('espresso_maintenance');
484 484
 	}
485 485
 
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Admin_Page.core.php 1 patch
Spacing   +503 added lines, -503 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if (!defined('EVENT_ESPRESSO_VERSION') )
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION'))
2 2
 	exit('NO direct script access allowed');
3 3
 
4 4
 /**
@@ -73,7 +73,7 @@  discard block
 block discarded – undo
73 73
 	 * @access public
74 74
 	 * @return void
75 75
 	 */
76
-	public function __construct( $routing = TRUE ) {
76
+	public function __construct($routing = TRUE) {
77 77
 		//make sure MSG Template helper is loaded.
78 78
 		//make sure messages autoloader is running
79 79
 		EED_Messages::set_autoloaders();
@@ -93,13 +93,13 @@  discard block
 block discarded – undo
93 93
 
94 94
 		$this->_activate_state = isset($this->_req_data['activate_state']) ? (array) $this->_req_data['activate_state'] : array();
95 95
 
96
-		$this->_active_messenger = isset( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : NULL;
96
+		$this->_active_messenger = isset($this->_req_data['messenger']) ? $this->_req_data['messenger'] : NULL;
97 97
 
98
-		EE_Registry::instance()->load_lib( 'messages' );
98
+		EE_Registry::instance()->load_lib('messages');
99 99
 		//we're also going to set the active messengers and active message types in here.
100 100
 		$this->_active_messengers = EEH_MSG_Template::get_active_messengers_in_db();
101
-		$this->_active_messengers = !empty($this->_active_messengers) ?  $this->_active_messengers : array();
102
-		$this->_active_message_types = !empty($this->_active_messenger) && !empty($this->_active_messengers[$this->_active_messenger]) && ! empty(  $this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger . '-message_types'] ) ? array_keys($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger . '-message_types']) : array();
101
+		$this->_active_messengers = ! empty($this->_active_messengers) ? $this->_active_messengers : array();
102
+		$this->_active_message_types = ! empty($this->_active_messenger) && ! empty($this->_active_messengers[$this->_active_messenger]) && ! empty($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger.'-message_types']) ? array_keys($this->_active_messengers[$this->_active_messenger]['settings'][$this->_active_messenger.'-message_types']) : array();
103 103
 
104 104
 
105 105
 		//what about saving the objects in the active_messengers and active_message_types?
@@ -117,15 +117,15 @@  discard block
 block discarded – undo
117 117
 	 * @return void
118 118
 	 */
119 119
 	protected function _load_active_messenger_objects() {
120
-		foreach ( $this->_active_messengers as $messenger => $values ) {
121
-			$ref = ucwords( str_replace( '_' , ' ', $messenger) );
122
-			$ref = str_replace( ' ', '_', $ref );
123
-			$classname = 'EE_' . $ref . '_messenger';
124
-			require_once( EE_LIBRARIES . 'messages'. DS .'messenger' . DS . $classname . '.class.php' );
125
-			if ( !class_exists($classname) )
126
-				throw new EE_Error( sprintf( __('There is no messenger for the given classname (%s)', 'event_espresso'), $classname ) );
127
-
128
-			$a = new ReflectionClass( $classname );
120
+		foreach ($this->_active_messengers as $messenger => $values) {
121
+			$ref = ucwords(str_replace('_', ' ', $messenger));
122
+			$ref = str_replace(' ', '_', $ref);
123
+			$classname = 'EE_'.$ref.'_messenger';
124
+			require_once(EE_LIBRARIES.'messages'.DS.'messenger'.DS.$classname.'.class.php');
125
+			if ( ! class_exists($classname))
126
+				throw new EE_Error(sprintf(__('There is no messenger for the given classname (%s)', 'event_espresso'), $classname));
127
+
128
+			$a = new ReflectionClass($classname);
129 129
 			$this->_active_messengers[$messenger]['obj'] = $a->newInstance();
130 130
 		}
131 131
 	}
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
 	 * @return void
141 141
 	 */
142 142
 	protected function _load_active_message_type_objects() {
143
-		if ( empty($this->_active_message_types) ) return;
144
-		foreach ( $this->_active_message_types as $message_type ) {
145
-			$ref = ucwords( str_replace( '_' , ' ', $message_type) );
146
-			$ref = str_replace( ' ', '_', $ref );
147
-			$classname = 'EE_' . $ref . '_message_type';
143
+		if (empty($this->_active_message_types)) return;
144
+		foreach ($this->_active_message_types as $message_type) {
145
+			$ref = ucwords(str_replace('_', ' ', $message_type));
146
+			$ref = str_replace(' ', '_', $ref);
147
+			$classname = 'EE_'.$ref.'_message_type';
148 148
 
149
-			if ( !class_exists($classname) )
150
-				throw new EE_Error( sprintf( __('There is no message type for the given classname (%s)', 'event_espresso'), $classname ) );
149
+			if ( ! class_exists($classname))
150
+				throw new EE_Error(sprintf(__('There is no message type for the given classname (%s)', 'event_espresso'), $classname));
151 151
 
152
-			$a = new ReflectionClass( $classname );
152
+			$a = new ReflectionClass($classname);
153 153
 			$this->_active_message_types[$message_type]['obj'] = $a->newInstance();
154 154
 		}
155 155
 	}
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 
158 158
 
159 159
 	protected function _ajax_hooks() {
160
-		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle' ) );
161
-		add_action('wp_ajax_activate_mt', array( $this, 'activate_mt_toggle') );
162
-		add_action('wp_ajax_ee_msgs_save_settings', array( $this, 'save_settings') );
163
-		add_action('wp_ajax_ee_msgs_update_mt_form', array( $this, 'update_mt_form' ) );
164
-		add_action('wp_ajax_switch_template_pack', array( $this, 'switch_template_pack' ) );
160
+		add_action('wp_ajax_activate_messenger', array($this, 'activate_messenger_toggle'));
161
+		add_action('wp_ajax_activate_mt', array($this, 'activate_mt_toggle'));
162
+		add_action('wp_ajax_ee_msgs_save_settings', array($this, 'save_settings'));
163
+		add_action('wp_ajax_ee_msgs_update_mt_form', array($this, 'update_mt_form'));
164
+		add_action('wp_ajax_switch_template_pack', array($this, 'switch_template_pack'));
165 165
 	}
166 166
 
167 167
 
@@ -193,8 +193,8 @@  discard block
 block discarded – undo
193 193
 	*		@return void
194 194
 	*/
195 195
 	protected function _set_page_routes() {
196
-		$grp_id = ! empty( $this->_req_data['GRP_ID'] ) && ! is_array( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
197
-		$grp_id = empty( $grp_id ) && !empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $grp_id;
196
+		$grp_id = ! empty($this->_req_data['GRP_ID']) && ! is_array($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
197
+		$grp_id = empty($grp_id) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $grp_id;
198 198
 
199 199
 		$this->_page_routes = array(
200 200
 				'default'=> array(
@@ -230,35 +230,35 @@  discard block
 block discarded – undo
230 230
 				'insert_message_template' => array(
231 231
 					'func' => '_insert_or_update_message_template',
232 232
 					'capability' => 'ee_edit_messages',
233
-					'args' => array( 'new_template' => TRUE ),
233
+					'args' => array('new_template' => TRUE),
234 234
 					'noheader' => TRUE
235 235
 					 ),
236 236
 				'update_message_template' => array(
237 237
 					'func' => '_insert_or_update_message_template',
238 238
 					'capability' => 'ee_edit_message',
239 239
 					'obj_id' => $grp_id,
240
-					'args' => array( 'new_template' => FALSE ),
240
+					'args' => array('new_template' => FALSE),
241 241
 					'noheader' => TRUE
242 242
 					),
243 243
 				'trash_message_template' => array(
244 244
 					'func' => '_trash_or_restore_message_template',
245 245
 					'capability' => 'ee_delete_message',
246 246
 					'obj_id' => $grp_id,
247
-					'args' => array( 'trash' => TRUE, 'all' => TRUE ),
247
+					'args' => array('trash' => TRUE, 'all' => TRUE),
248 248
 					'noheader' => TRUE
249 249
 					),
250 250
 				'trash_message_template_context' => array(
251 251
 					'func' => '_trash_or_restore_message_template',
252 252
 					'capability' => 'ee_delete_message',
253 253
 					'obj_id' => $grp_id,
254
-					'args' => array( 'trash' => TRUE ),
254
+					'args' => array('trash' => TRUE),
255 255
 					'noheader' => TRUE
256 256
 					),
257 257
 				'restore_message_template' => array(
258 258
 					'func' => '_trash_or_restore_message_template',
259 259
 					'capability' => 'ee_delete_message',
260 260
 					'obj_id' => $grp_id,
261
-					'args' => array( 'trash' => FALSE, 'all' => TRUE ),
261
+					'args' => array('trash' => FALSE, 'all' => TRUE),
262 262
 					'noheader' => TRUE
263 263
 					),
264 264
 				'restore_message_template_context' => array(
@@ -337,7 +337,7 @@  discard block
 block discarded – undo
337 337
 						'filename' => 'messages_overview_other',
338 338
 					),
339 339
 				),
340
-				'help_tour' => array( 'Messages_Overview_Help_Tour' ),
340
+				'help_tour' => array('Messages_Overview_Help_Tour'),
341 341
 				'require_nonce' => FALSE
342 342
 				),
343 343
 			'custom_mtps' => array(
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 					),
373 373
 				'metaboxes' => array('_publish_post_box', '_register_edit_meta_boxes'),
374 374
 				'has_metaboxes' => TRUE,
375
-				'help_tour' => array( 'Message_Templates_Edit_Help_Tour' ),
375
+				'help_tour' => array('Message_Templates_Edit_Help_Tour'),
376 376
 				'help_tabs' => array(
377 377
 						'edit_message_template' => array(
378 378
 							'title' => __('Message Template Editor', 'event_espresso'),
@@ -428,7 +428,7 @@  discard block
 block discarded – undo
428 428
 							'filename' => 'messages_settings_messengers'
429 429
 							),
430 430
                     ),
431
-				'help_tour' => array( 'Messages_Settings_Help_Tour' ),
431
+				'help_tour' => array('Messages_Settings_Help_Tour'),
432 432
 				'require_nonce' => FALSE
433 433
 				)
434 434
 			/*'reports' => array(
@@ -478,43 +478,43 @@  discard block
 block discarded – undo
478 478
 
479 479
 
480 480
 	public function messages_help_tab() {
481
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_help_tab.template.php';
482
-		EEH_Template::display_template( $templatepath, array());
481
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_messages_help_tab.template.php';
482
+		EEH_Template::display_template($templatepath, array());
483 483
 	}
484 484
 
485 485
 
486 486
 	public function messengers_help_tab() {
487
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_messenger_help_tab.template.php';
488
-		EEH_Template::display_template( $templatepath, array());
487
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_messenger_help_tab.template.php';
488
+		EEH_Template::display_template($templatepath, array());
489 489
 	}
490 490
 
491 491
 
492 492
 	public function message_types_help_tab() {
493
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_message_type_help_tab.template.php';
494
-		EEH_Template::display_template( $templatepath, array());
493
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_message_type_help_tab.template.php';
494
+		EEH_Template::display_template($templatepath, array());
495 495
 	}
496 496
 
497 497
 
498 498
 	public function messages_overview_help_tab() {
499
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_overview_help_tab.template.php';
500
-		EEH_Template::display_template( $templatepath, array());
499
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_overview_help_tab.template.php';
500
+		EEH_Template::display_template($templatepath, array());
501 501
 	}
502 502
 
503 503
 
504 504
 	public function message_templates_help_tab() {
505
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_message_templates_help_tab.template.php';
506
-		EEH_Template::display_template( $templatepath, array());
505
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_message_templates_help_tab.template.php';
506
+		EEH_Template::display_template($templatepath, array());
507 507
 	}
508 508
 
509 509
 
510 510
 	public function edit_message_template_help_tab() {
511
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_templates_editor_help_tab.template.php';
512
-		$args['img1'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/editor.png' . '" alt="' . esc_attr__('Editor Title', 'event_espresso') . '" />';
513
-		$args['img2'] = '<img src="' . EE_MSG_ASSETS_URL . 'images/switch-context.png' . '" alt="' . esc_attr__('Context Switcher and Preview', 'event_espresso') . '" />';
514
-		$args['img3'] = '<img class="left" src="' . EE_MSG_ASSETS_URL . 'images/form-fields.png' . '" alt="' . esc_attr__('Message Template Form Fields', 'event_espresso') . '" />';
515
-		$args['img4'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/shortcodes-metabox.png' . '" alt="' . esc_attr__('Shortcodes Metabox', 'event_espresso') . '" />';
516
-		$args['img5'] = '<img class="right" src="' . EE_MSG_ASSETS_URL . 'images/publish-meta-box.png' . '" alt="' . esc_attr__('Publish Metabox', 'event_espresso') . '" />';
517
-		EEH_Template::display_template( $templatepath, $args);
511
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_messages_templates_editor_help_tab.template.php';
512
+		$args['img1'] = '<img src="'.EE_MSG_ASSETS_URL.'images/editor.png'.'" alt="'.esc_attr__('Editor Title', 'event_espresso').'" />';
513
+		$args['img2'] = '<img src="'.EE_MSG_ASSETS_URL.'images/switch-context.png'.'" alt="'.esc_attr__('Context Switcher and Preview', 'event_espresso').'" />';
514
+		$args['img3'] = '<img class="left" src="'.EE_MSG_ASSETS_URL.'images/form-fields.png'.'" alt="'.esc_attr__('Message Template Form Fields', 'event_espresso').'" />';
515
+		$args['img4'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/shortcodes-metabox.png'.'" alt="'.esc_attr__('Shortcodes Metabox', 'event_espresso').'" />';
516
+		$args['img5'] = '<img class="right" src="'.EE_MSG_ASSETS_URL.'images/publish-meta-box.png'.'" alt="'.esc_attr__('Publish Metabox', 'event_espresso').'" />';
517
+		EEH_Template::display_template($templatepath, $args);
518 518
 	}
519 519
 
520 520
 
@@ -522,25 +522,25 @@  discard block
 block discarded – undo
522 522
 	public function message_template_shortcodes_help_tab() {
523 523
 		$this->_set_shortcodes();
524 524
 		$args['shortcodes'] = $this->_shortcodes;
525
-		$template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_shortcodes_help_tab.template.php';
526
-		EEH_Template::display_template( $template_path, $args );
525
+		$template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_messages_shortcodes_help_tab.template.php';
526
+		EEH_Template::display_template($template_path, $args);
527 527
 	}
528 528
 
529 529
 
530 530
 
531 531
 	public function preview_message_help_tab() {
532
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_preview_help_tab.template.php';
533
-		EEH_Template::display_template( $templatepath, array());
532
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_preview_help_tab.template.php';
533
+		EEH_Template::display_template($templatepath, array());
534 534
 	}
535 535
 
536 536
 
537 537
 	public function settings_help_tab() {
538
-		$templatepath = EE_MSG_TEMPLATE_PATH . 'ee_msg_messages_settings_help_tab.template.php';
539
-		$args['img1'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-active.png' . '" alt="' . esc_attr__('Active Email Tab', 'event_espresso') . '" />';
540
-		$args['img2'] = '<img class="inline-text" src="' . EE_MSG_ASSETS_URL . 'images/email-tab-inactive.png' . '" alt="' . esc_attr__('Inactive Email Tab', 'event_espresso') . '" />';
538
+		$templatepath = EE_MSG_TEMPLATE_PATH.'ee_msg_messages_settings_help_tab.template.php';
539
+		$args['img1'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-active.png'.'" alt="'.esc_attr__('Active Email Tab', 'event_espresso').'" />';
540
+		$args['img2'] = '<img class="inline-text" src="'.EE_MSG_ASSETS_URL.'images/email-tab-inactive.png'.'" alt="'.esc_attr__('Inactive Email Tab', 'event_espresso').'" />';
541 541
 		$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>';
542 542
 		$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>';
543
-		EEH_Template::display_template( $templatepath, $args);
543
+		EEH_Template::display_template($templatepath, $args);
544 544
 	}
545 545
 
546 546
 
@@ -548,24 +548,24 @@  discard block
 block discarded – undo
548 548
 
549 549
 
550 550
 	public function load_scripts_styles() {
551
-		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL . 'ee_message_admin.css', EVENT_ESPRESSO_VERSION );
551
+		wp_register_style('espresso_ee_msg', EE_MSG_ASSETS_URL.'ee_message_admin.css', EVENT_ESPRESSO_VERSION);
552 552
 		wp_enqueue_style('espresso_ee_msg');
553 553
 
554
-		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 );
554
+		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);
555 555
 	}
556 556
 
557 557
 
558 558
 
559 559
 
560 560
 
561
-	public function wp_editor_css( $mce_css ) {
561
+	public function wp_editor_css($mce_css) {
562 562
 		//if we're on the edit_message_template route
563
-		if ( $this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger  ) {
563
+		if ($this->_req_action == 'edit_message_template' && $this->_active_messenger instanceof EE_messenger) {
564 564
 			$message_type_name = $this->_active_message_type_name;
565 565
 
566 566
 			//we're going to REPLACE the existing mce css
567 567
 			//we need to get the css file location from the active messenger
568
-			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, TRUE, 'wpeditor', $this->_variation );
568
+			$mce_css = $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, TRUE, 'wpeditor', $this->_variation);
569 569
 		}
570 570
 
571 571
 		return $mce_css;
@@ -583,37 +583,37 @@  discard block
 block discarded – undo
583 583
 			$this->_message_template_group->messenger_obj()->label['singular'],
584 584
 			$this->_message_template_group->message_type_obj()->label['singular']
585 585
 		);
586
-		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' );
586
+		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');
587 587
 
588
-		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL . 'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION );
588
+		wp_register_script('ee_msgs_edit_js', EE_MSG_ASSETS_URL.'ee_message_editor.js', array('jquery'), EVENT_ESPRESSO_VERSION);
589 589
 
590 590
 		wp_enqueue_script('ee_admin_js');
591 591
 		wp_enqueue_script('ee_msgs_edit_js');
592 592
 
593 593
 		//add in special css for tiny_mce
594
-		add_filter( 'mce_css', array( $this, 'wp_editor_css' ) );
594
+		add_filter('mce_css', array($this, 'wp_editor_css'));
595 595
 	}
596 596
 
597 597
 
598 598
 
599 599
 	public function load_scripts_styles_display_preview_message() {
600 600
 		$this->_set_message_template_group();
601
-		if ( isset( $this->_req_data['messenger'] ) ) {
601
+		if (isset($this->_req_data['messenger'])) {
602 602
 			$this->_active_messenger = $this->_active_messengers[$this->_req_data['messenger']]['obj'];
603 603
 		}
604 604
 
605
-		$message_type_name = isset( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : '';
605
+		$message_type_name = isset($this->_req_data['message_type']) ? $this->_req_data['message_type'] : '';
606 606
 
607 607
 
608
-		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation( $this->_template_pack, $message_type_name, TRUE, 'preview', $this->_variation ) );
608
+		wp_enqueue_style('espresso_preview_css', $this->_active_messenger->get_variation($this->_template_pack, $message_type_name, TRUE, 'preview', $this->_variation));
609 609
 	}
610 610
 
611 611
 
612 612
 
613 613
 	public function load_scripts_styles_settings() {
614
-		wp_register_style( 'ee-message-settings', EE_MSG_ASSETS_URL . 'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION );
615
-		wp_enqueue_style( 'ee-text-links' );
616
-		wp_enqueue_style( 'ee-message-settings' );
614
+		wp_register_style('ee-message-settings', EE_MSG_ASSETS_URL.'ee_message_settings.css', array(), EVENT_ESPRESSO_VERSION);
615
+		wp_enqueue_style('ee-text-links');
616
+		wp_enqueue_style('ee-message-settings');
617 617
 
618 618
 		wp_enqueue_script('ee-messages-settings');
619 619
 	}
@@ -649,9 +649,9 @@  discard block
 block discarded – undo
649 649
 
650 650
 	protected function _custom_mtps_preview() {
651 651
 		$this->_admin_page_title = __('Custom Message Templates (Preview)', 'event_espresso');
652
-		$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' ) . '" />';
652
+		$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').'" />';
653 653
 		$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>';
654
-		$this->display_admin_caf_preview_page( 'custom_message_types', FALSE );
654
+		$this->display_admin_caf_preview_page('custom_message_types', FALSE);
655 655
 	}
656 656
 
657 657
 
@@ -673,7 +673,7 @@  discard block
 block discarded – undo
673 673
 	 * @param bool $global whether to return just global (true) or custom templates (false)
674 674
 	 * @return array|WP_Error object
675 675
 	 */
676
-	public function get_message_templates( $perpage = 10, $type = 'in_use', $count = FALSE, $all = FALSE, $global = TRUE ) {
676
+	public function get_message_templates($perpage = 10, $type = 'in_use', $count = FALSE, $all = FALSE, $global = TRUE) {
677 677
 		global $espresso_wp_user;
678 678
 		// start with an empty array
679 679
 		$message_templates = array();
@@ -683,24 +683,24 @@  discard block
 block discarded – undo
683 683
 		$this->_req_data['orderby'] = empty($this->_req_data['orderby']) ? 'GRP_ID' : $this->_req_data['orderby'];
684 684
 		$orderby = $this->_req_data['orderby'];
685 685
 
686
-		$order = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] ) ) ? $this->_req_data['order'] : 'ASC';
686
+		$order = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'ASC';
687 687
 
688
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
689
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $perpage;
688
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
689
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $perpage;
690 690
 
691
-		$offset = ($current_page-1)*$per_page;
692
-		$limit = $all ? NULL : array( $offset, $per_page );
691
+		$offset = ($current_page - 1) * $per_page;
692
+		$limit = $all ? NULL : array($offset, $per_page);
693 693
 
694 694
 
695 695
 		//options will match what is in the _views array property
696
-		switch( $type ) {
696
+		switch ($type) {
697 697
 
698 698
 			case 'in_use':
699
-				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, TRUE );
699
+				$templates = $MTP->get_all_active_message_templates($orderby, $order, $limit, $count, $global, TRUE);
700 700
 				break;
701 701
 
702 702
 			default:
703
-				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global );
703
+				$templates = $MTP->get_all_trashed_grouped_message_templates($orderby, $order, $limit, $count, $global);
704 704
 
705 705
 		}
706 706
 
@@ -736,7 +736,7 @@  discard block
 block discarded – undo
736 736
 		$imts = $installed_objects['message_types'];
737 737
 		$installed = array();
738 738
 
739
-		foreach ( $imts as $message_type ) {
739
+		foreach ($imts as $message_type) {
740 740
 			$installed[$message_type->name]['obj'] = $message_type;
741 741
 		}
742 742
 
@@ -768,24 +768,24 @@  discard block
 block discarded – undo
768 768
 	 * @access  protected
769 769
 	 * @return void
770 770
 	 */
771
-	protected function _add_message_template(  $message_type = '', $messenger='', $GRP_ID = '' ) {
771
+	protected function _add_message_template($message_type = '', $messenger = '', $GRP_ID = '') {
772 772
 		//set values override any request data
773
-		$message_type = !empty( $message_type ) ? $message_type : '';
774
-		$message_type = empty( $message_type ) && !empty( $this->_req_data['message_type'] ) ? $this->_req_data['message_type'] : $message_type;
773
+		$message_type = ! empty($message_type) ? $message_type : '';
774
+		$message_type = empty($message_type) && ! empty($this->_req_data['message_type']) ? $this->_req_data['message_type'] : $message_type;
775 775
 
776
-		$messenger = !empty( $messenger ) ? $messenger : '';
777
-		$messenger = empty( $messenger ) && !empty( $this->_req_data['messenger'] ) ? $this->_req_data['messenger'] : $messenger;
776
+		$messenger = ! empty($messenger) ? $messenger : '';
777
+		$messenger = empty($messenger) && ! empty($this->_req_data['messenger']) ? $this->_req_data['messenger'] : $messenger;
778 778
 
779
-		$GRP_ID = !empty( $GRP_ID ) ? $GRP_ID : '';
780
-		$GRP_ID = empty( $GRP_ID ) && !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : $GRP_ID;
779
+		$GRP_ID = ! empty($GRP_ID) ? $GRP_ID : '';
780
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : $GRP_ID;
781 781
 
782 782
 		//we need messenger and message type.  They should be coming from the event editor. If not here then return error
783
-		if ( empty( $message_type ) || empty( $messenger )  )
783
+		if (empty($message_type) || empty($messenger))
784 784
 			throw new EE_error(__('Sorry, but we can\'t create new templates because we\'re missing the messenger or message type', 'event_espresso'));
785 785
 
786 786
 		//we need the GRP_ID for the template being used as the base for the new template
787
-		if ( empty( $GRP_ID ) )
788
-			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' ) );
787
+		if (empty($GRP_ID))
788
+			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'));
789 789
 
790 790
 		//let's just make sure the template gets generated!
791 791
 
@@ -804,8 +804,8 @@  discard block
 block discarded – undo
804 804
 	 * @param string $messenger    messenger slug
805 805
 	 * @param int      $GRP_ID         GRP_ID for the related message template group this new template will be based off of.
806 806
 	 */
807
-	public function add_message_template( $message_type, $messenger, $GRP_ID ) {
808
-		$this->_add_message_template( $message_type, $messenger, $GRP_ID );
807
+	public function add_message_template($message_type, $messenger, $GRP_ID) {
808
+		$this->_add_message_template($message_type, $messenger, $GRP_ID);
809 809
 	}
810 810
 
811 811
 
@@ -816,36 +816,36 @@  discard block
 block discarded – undo
816 816
 	 * @return void
817 817
 	 */
818 818
 	protected function _edit_message_template() {
819
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '');
819
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
820 820
 
821 821
 		//we filter the tinyMCE settings to remove the validation since message templates by their nature will not have valid html in the templates.
822
-		add_filter( 'tiny_mce_before_init', array( $this, 'filter_tinymce_init'), 10, 2 );
822
+		add_filter('tiny_mce_before_init', array($this, 'filter_tinymce_init'), 10, 2);
823 823
 
824
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : FALSE;
824
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : FALSE;
825 825
 
826 826
 		$this->_set_shortcodes(); //this also sets the _message_template property.
827 827
 		$message_template_group = $this->_message_template_group;
828 828
 		$c_label = $message_template_group->context_label();
829 829
 		$c_config = $message_template_group->contexts_config();
830 830
 
831
-		reset( $c_config );
832
-		$context = isset( $this->_req_data['context']) && !empty($this->_req_data['context'] ) ? strtolower($this->_req_data['context']) : key($c_config);
831
+		reset($c_config);
832
+		$context = isset($this->_req_data['context']) && ! empty($this->_req_data['context']) ? strtolower($this->_req_data['context']) : key($c_config);
833 833
 
834 834
 
835
-		if ( empty($GRP_ID) ) {
835
+		if (empty($GRP_ID)) {
836 836
 			$action = 'insert_message_template';
837 837
 			$button_both = FALSE;
838
-			$button_text = array( __( 'Save','event_espresso') );
838
+			$button_text = array(__('Save', 'event_espresso'));
839 839
 			$button_actions = array('something_different');
840 840
 			$referrer = FALSE;
841
-			$edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
841
+			$edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => TRUE), EE_MSG_ADMIN_URL);
842 842
 		} else {
843 843
 			$action = 'update_message_template';
844 844
 			$button_both = TRUE;
845 845
 			$button_text = array();
846 846
 			$button_actions = array();
847 847
 			$referrer = $this->_admin_base_url;
848
-			$edit_message_template_form_url = add_query_arg( array( 'action' => $action, 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
848
+			$edit_message_template_form_url = add_query_arg(array('action' => $action, 'noheader' => TRUE), EE_MSG_ADMIN_URL);
849 849
 		}
850 850
 
851 851
 		//set active messenger for this view
@@ -855,13 +855,13 @@  discard block
 block discarded – undo
855 855
 
856 856
 		//Do we have any validation errors?
857 857
 		$validators = $this->_get_transient();
858
-		$v_fields = !empty($validators) ? array_keys($validators) : array();
858
+		$v_fields = ! empty($validators) ? array_keys($validators) : array();
859 859
 
860 860
 
861 861
 		//we need to assemble the title from Various details
862
-		$context_label = sprintf( __('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label'] ));
862
+		$context_label = sprintf(__('(%s %s)', 'event_espresso'), $c_config[$context]['label'], ucwords($c_label['label']));
863 863
 
864
-		$title = sprintf( __(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label );
864
+		$title = sprintf(__(' %s %s Template %s', 'event_espresso'), ucwords($message_template_group->messenger_obj()->label['singular']), ucwords($message_template_group->message_type_obj()->label['singular']), $context_label);
865 865
 
866 866
 		$this->_template_args['GRP_ID'] = $GRP_ID;
867 867
 		$this->_template_args['message_template'] = $message_template_group;
@@ -872,7 +872,7 @@  discard block
 block discarded – undo
872 872
 		$MSG = new EE_messages();
873 873
 		$template_field_structure = $MSG->get_fields($message_template_group->messenger(), $message_template_group->message_type());
874 874
 
875
-		if ( !$template_field_structure ) {
875
+		if ( ! $template_field_structure) {
876 876
 			$template_field_structure = FALSE;
877 877
 			$template_fields = __('There was an error in assembling the fields for this display (you should see an error message)', 'event_espresso');
878 878
 		}
@@ -882,38 +882,38 @@  discard block
 block discarded – undo
882 882
 
883 883
 
884 884
 		//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.
885
-		if ( is_array($template_field_structure[$context]) && isset( $template_field_structure[$context]['extra']) ) {
886
-			foreach ( $template_field_structure[$context]['extra'] as $reference_field => $new_fields ) {
887
-				unset( $template_field_structure[$context][$reference_field] );
885
+		if (is_array($template_field_structure[$context]) && isset($template_field_structure[$context]['extra'])) {
886
+			foreach ($template_field_structure[$context]['extra'] as $reference_field => $new_fields) {
887
+				unset($template_field_structure[$context][$reference_field]);
888 888
 			}
889 889
 		}
890 890
 
891 891
 		//let's loop through the template_field_structure and actually assemble the input fields!
892
-		if ( !empty($template_field_structure) ) {
893
-			$id_prefix= 'ee-msg-edit-template-fields-';
894
-			foreach ( $template_field_structure[$context] as $template_field => $field_setup_array ) {
892
+		if ( ! empty($template_field_structure)) {
893
+			$id_prefix = 'ee-msg-edit-template-fields-';
894
+			foreach ($template_field_structure[$context] as $template_field => $field_setup_array) {
895 895
 				//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.
896
-				if ( $template_field == 'extra' ) {
896
+				if ($template_field == 'extra') {
897 897
 					$this->_template_args['is_extra_fields'] = TRUE;
898
-					foreach ( $field_setup_array as $reference_field => $new_fields_array ) {
899
-						foreach ( $new_fields_array as $extra_field =>  $extra_array ) {
898
+					foreach ($field_setup_array as $reference_field => $new_fields_array) {
899
+						foreach ($new_fields_array as $extra_field =>  $extra_array) {
900 900
 							//let's verify if we need this extra field via the shortcodes parameter.
901 901
 							$continue = FALSE;
902
-							if ( isset( $extra_array['shortcodes_required'] ) ) {
903
-								foreach ( (array) $extra_array['shortcodes_required'] as $shortcode ) {
904
-									if ( !array_key_exists( $shortcode, $this->_shortcodes ) )
902
+							if (isset($extra_array['shortcodes_required'])) {
903
+								foreach ((array) $extra_array['shortcodes_required'] as $shortcode) {
904
+									if ( ! array_key_exists($shortcode, $this->_shortcodes))
905 905
 										$continue = TRUE;
906 906
 								}
907
-								if ( $continue ) continue;
907
+								if ($continue) continue;
908 908
 							}
909 909
 
910
-							$field_id = $reference_field . '-' . $extra_field . '-content';
910
+							$field_id = $reference_field.'-'.$extra_field.'-content';
911 911
 							$template_form_fields[$field_id] = $extra_array;
912
-							$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $reference_field . '][content][' . $extra_field . ']';
913
-							$css_class = isset( $extra_array['css_class'] ) ? $extra_array['css_class'] : '';
914
-							$template_form_fields[$field_id]['css_class'] = !empty( $v_fields ) && in_array($extra_field, $v_fields) && ( is_array($validators[$extra_field] ) && isset( $validators[$extra_field]['msg'] ) ) ? 'validate-error ' . $css_class : $css_class;
912
+							$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$reference_field.'][content]['.$extra_field.']';
913
+							$css_class = isset($extra_array['css_class']) ? $extra_array['css_class'] : '';
914
+							$template_form_fields[$field_id]['css_class'] = ! empty($v_fields) && in_array($extra_field, $v_fields) && (is_array($validators[$extra_field]) && isset($validators[$extra_field]['msg'])) ? 'validate-error '.$css_class : $css_class;
915 915
 							$content = $message_templates[$context][$reference_field]->get('MTP_content');
916
-							$template_form_fields[$field_id]['value'] = !empty($message_templates) && isset($content[$extra_field]) ? stripslashes( html_entity_decode( $content[$extra_field], ENT_QUOTES, "UTF-8") ) : '';
916
+							$template_form_fields[$field_id]['value'] = ! empty($message_templates) && isset($content[$extra_field]) ? stripslashes(html_entity_decode($content[$extra_field], ENT_QUOTES, "UTF-8")) : '';
917 917
 
918 918
 							//do we have a validation error?  if we do then let's use that value instead
919 919
 							$template_form_fields[$field_id]['value'] = isset($validators[$extra_field]) ? $validators[$extra_field]['value'] : $template_form_fields[$field_id]['value'];
@@ -923,32 +923,32 @@  discard block
 block discarded – undo
923 923
 
924 924
 							//shortcode selector
925 925
 							$field_name_to_use = $extra_field == 'main' ? 'content' : $extra_field;
926
-							$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $field_name_to_use, $field_id );
926
+							$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($field_name_to_use, $field_id);
927 927
 
928
-							if ( isset( $extra_array['input'] ) && $extra_array['input'] == 'wp_editor' ) {
928
+							if (isset($extra_array['input']) && $extra_array['input'] == 'wp_editor') {
929 929
 								//we want to decode the entities
930
-								$template_form_fields[$field_id]['value'] = stripslashes( html_entity_decode( $template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8") );
930
+								$template_form_fields[$field_id]['value'] = stripslashes(html_entity_decode($template_form_fields[$field_id]['value'], ENT_QUOTES, "UTF-8"));
931 931
 
932 932
 							}/**/
933 933
 						}
934
-						$templatefield_MTP_id = $reference_field . '-MTP_ID';
935
-						$templatefield_templatename_id = $reference_field . '-name';
934
+						$templatefield_MTP_id = $reference_field.'-MTP_ID';
935
+						$templatefield_templatename_id = $reference_field.'-name';
936 936
 
937 937
 						$template_form_fields[$templatefield_MTP_id] = array(
938
-							'name' => 'MTP_template_fields[' . $reference_field . '][MTP_ID]',
938
+							'name' => 'MTP_template_fields['.$reference_field.'][MTP_ID]',
939 939
 							'label' => NULL,
940 940
 							'input' => 'hidden',
941 941
 							'type' => 'int',
942 942
 							'required' => FALSE,
943 943
 							'validation' => FALSE,
944
-							'value' => !empty($message_templates) ? $message_templates[$context][$reference_field]->ID() : '',
944
+							'value' => ! empty($message_templates) ? $message_templates[$context][$reference_field]->ID() : '',
945 945
 							'css_class' => '',
946 946
 							'format' => '%d',
947 947
 							'db-col' => 'MTP_ID'
948 948
 						);
949 949
 
950 950
 						$template_form_fields[$templatefield_templatename_id] = array(
951
-							'name' => 'MTP_template_fields[' . $reference_field . '][name]',
951
+							'name' => 'MTP_template_fields['.$reference_field.'][name]',
952 952
 							'label' => NULL,
953 953
 							'input' => 'hidden',
954 954
 							'type' => 'string',
@@ -962,10 +962,10 @@  discard block
 block discarded – undo
962 962
 					}
963 963
 					continue; //skip the next stuff, we got the necessary fields here for this dataset.
964 964
 				} else {
965
-					$field_id = $template_field . '-content';
965
+					$field_id = $template_field.'-content';
966 966
 					$template_form_fields[$field_id] = $field_setup_array;
967
-					$template_form_fields[$field_id]['name'] = 'MTP_template_fields[' . $template_field . '][content]';
968
-					$template_form_fields[$field_id]['value'] = !empty($message_templates) && is_array($message_templates[$context]) && isset($message_templates[$context][$template_field]) ?$message_templates[$context][$template_field]->get('MTP_content') : '';
967
+					$template_form_fields[$field_id]['name'] = 'MTP_template_fields['.$template_field.'][content]';
968
+					$template_form_fields[$field_id]['value'] = ! empty($message_templates) && is_array($message_templates[$context]) && isset($message_templates[$context][$template_field]) ? $message_templates[$context][$template_field]->get('MTP_content') : '';
969 969
 
970 970
 					//do we have a validator error for this field?  if we do then we'll use that value instead
971 971
 					$template_form_fields[$field_id]['value'] = isset($validators[$template_field]) ? $validators[$template_field]['value'] : $template_form_fields[$field_id]['value'];
@@ -973,12 +973,12 @@  discard block
 block discarded – undo
973 973
 
974 974
 					$template_form_fields[$field_id]['db-col'] = 'MTP_content';
975 975
 					$css_class = isset($field_setup_array['css_class']) ? $field_setup_array['css_class'] : '';
976
-					$template_form_fields[$field_id]['css_class'] = !empty( $v_fields ) && in_array( $template_field, $v_fields ) && isset( $validators[$template_field]['msg'] ) ? 'validate-error ' . $css_class : $css_class;
976
+					$template_form_fields[$field_id]['css_class'] = ! empty($v_fields) && in_array($template_field, $v_fields) && isset($validators[$template_field]['msg']) ? 'validate-error '.$css_class : $css_class;
977 977
 
978 978
 					//shortcode selector
979
-					$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector( $template_field, $field_id );
979
+					$template_form_fields[$field_id]['append_content'] = $this->_get_shortcode_selector($template_field, $field_id);
980 980
 
981
-					if ( isset( $field_setup_array['input'] ) && $field_setup_array['input'] == 'wp_editor' ) {
981
+					if (isset($field_setup_array['input']) && $field_setup_array['input'] == 'wp_editor') {
982 982
 						//we want to decode the entities
983 983
 						$template_form_fields[$field_id]['value'] = $template_form_fields[$field_id]['value'];
984 984
 					}/**/
@@ -986,25 +986,25 @@  discard block
 block discarded – undo
986 986
 
987 987
 				//k took care of content field(s) now let's take care of others.
988 988
 
989
-				$templatefield_MTP_id = $template_field . '-MTP_ID';
990
-				$templatefield_field_templatename_id = $template_field . '-name';
989
+				$templatefield_MTP_id = $template_field.'-MTP_ID';
990
+				$templatefield_field_templatename_id = $template_field.'-name';
991 991
 
992 992
 				//foreach template field there are actually two form fields created
993 993
 				$template_form_fields[$templatefield_MTP_id] = array(
994
-					'name' => 'MTP_template_fields[' . $template_field . '][MTP_ID]',
994
+					'name' => 'MTP_template_fields['.$template_field.'][MTP_ID]',
995 995
 					'label' => NULL,
996 996
 					'input' => 'hidden',
997 997
 					'type' => 'int',
998 998
 					'required' => FALSE,
999 999
 					'validation' => TRUE,
1000
-					'value' => !empty($message_templates) ? $message_templates[$context][$template_field]->ID() : '',
1000
+					'value' => ! empty($message_templates) ? $message_templates[$context][$template_field]->ID() : '',
1001 1001
 					'css_class' => '',
1002 1002
 					'format' => '%d',
1003 1003
 					'db-col' => 'MTP_ID'
1004 1004
 				);
1005 1005
 
1006 1006
 				$template_form_fields[$templatefield_field_templatename_id] = array(
1007
-					'name' => 'MTP_template_fields[' . $template_field . '][name]',
1007
+					'name' => 'MTP_template_fields['.$template_field.'][name]',
1008 1008
 					'label' => NULL,
1009 1009
 					'input' => 'hidden',
1010 1010
 					'type' => 'string',
@@ -1148,15 +1148,15 @@  discard block
 block discarded – undo
1148 1148
 				'value' => $GRP_ID
1149 1149
 				);
1150 1150
 			$sidebar_form_fields['ee-msg-evt-nonce'] = array(
1151
-				'name' => $action . '_nonce',
1151
+				'name' => $action.'_nonce',
1152 1152
 				'input' => 'hidden',
1153 1153
 				'type' => 'string',
1154
-				'value' => wp_create_nonce( $action . '_nonce')
1154
+				'value' => wp_create_nonce($action.'_nonce')
1155 1155
 				);
1156 1156
 
1157 1157
 			$sidebar_array = array('ee-msg-is-global', 'ee-msg-is-override', 'ee-msg-deleted', 'ee-msg-is-active');
1158 1158
 
1159
-			if ( isset($this->_req_data['template_switch']) && $this->_req_data['template_switch'] ) {
1159
+			if (isset($this->_req_data['template_switch']) && $this->_req_data['template_switch']) {
1160 1160
 				$sidebar_form_fields['ee-msg-template-switch'] = array(
1161 1161
 					'name' => 'template_switch',
1162 1162
 					'input' => 'hidden',
@@ -1166,19 +1166,19 @@  discard block
 block discarded – undo
1166 1166
 			}
1167 1167
 
1168 1168
 
1169
-			$template_fields = $this->_generate_admin_form_fields( $template_form_fields );
1170
-			$sidebar_fields = $this->_generate_admin_form_fields( $sidebar_form_fields );
1169
+			$template_fields = $this->_generate_admin_form_fields($template_form_fields);
1170
+			$sidebar_fields = $this->_generate_admin_form_fields($sidebar_form_fields);
1171 1171
 
1172 1172
 
1173 1173
 		} //end if ( !empty($template_field_structure) )
1174 1174
 
1175 1175
 		//set extra content for publish box
1176 1176
 		$this->_template_args['publish_box_extra_content'] = $sidebar_fields;
1177
-		$this->_set_publish_post_box_vars( 'id', $GRP_ID );
1177
+		$this->_set_publish_post_box_vars('id', $GRP_ID);
1178 1178
 
1179 1179
 		//add preview button
1180
-		$preview_url = parent::add_query_args_and_nonce( array( 'message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context,'GRP_ID' => $GRP_ID, 'action' => 'preview_message' ), $this->_admin_base_url );
1181
-		$preview_button = '<a href="' . $preview_url . '" class="button-secondary messages-preview-button">' . __('Preview', 'event_espresso') . '</a>';
1180
+		$preview_url = parent::add_query_args_and_nonce(array('message_type' => $message_template_group->message_type(), 'messenger' => $message_template_group->messenger(), 'context' => $context, 'GRP_ID' => $GRP_ID, 'action' => 'preview_message'), $this->_admin_base_url);
1181
+		$preview_button = '<a href="'.$preview_url.'" class="button-secondary messages-preview-button">'.__('Preview', 'event_espresso').'</a>';
1182 1182
 
1183 1183
 
1184 1184
 		//setup context switcher
@@ -1205,16 +1205,16 @@  discard block
 block discarded – undo
1205 1205
 		$this->_template_args['before_admin_page_content'] .= $this->_add_form_element_before();
1206 1206
 		$this->_template_args['after_admin_page_content'] = $this->_add_form_element_after();
1207 1207
 
1208
-		$this->_template_path = $this->_template_args['GRP_ID'] ? EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_edit_meta_box.template.php' : EE_MSG_TEMPLATE_PATH . 'ee_msg_details_main_add_meta_box.template.php';
1208
+		$this->_template_path = $this->_template_args['GRP_ID'] ? EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_edit_meta_box.template.php' : EE_MSG_TEMPLATE_PATH.'ee_msg_details_main_add_meta_box.template.php';
1209 1209
 
1210 1210
 		//send along EE_Message_Template_Group object for further template use.
1211 1211
 		$this->_template_args['MTP'] = $message_template_group;
1212 1212
 
1213
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( $this->_template_path, $this->_template_args, TRUE );
1213
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template($this->_template_path, $this->_template_args, TRUE);
1214 1214
 
1215 1215
 
1216 1216
 		//finally, let's set the admin_page title
1217
-		$this->_admin_page_title = sprintf( __('Editing %s', 'event_espresso'), $title );
1217
+		$this->_admin_page_title = sprintf(__('Editing %s', 'event_espresso'), $title);
1218 1218
 
1219 1219
 
1220 1220
 		//we need to take care of setting the shortcodes property for use elsewhere.
@@ -1227,7 +1227,7 @@  discard block
 block discarded – undo
1227 1227
 	}
1228 1228
 
1229 1229
 
1230
-	public function filter_tinymce_init( $mceInit, $editor_id ) {
1230
+	public function filter_tinymce_init($mceInit, $editor_id) {
1231 1231
 		return $mceInit;
1232 1232
 	}
1233 1233
 
@@ -1238,7 +1238,7 @@  discard block
 block discarded – undo
1238 1238
 	}
1239 1239
 
1240 1240
 	public function _add_form_element_before() {
1241
-		return '<form method="post" action="' . $this->_template_args["edit_message_template_form_url"] . '" id="ee-msg-edit-frm">';
1241
+		return '<form method="post" action="'.$this->_template_args["edit_message_template_form_url"].'" id="ee-msg-edit-frm">';
1242 1242
 	}
1243 1243
 
1244 1244
 	public function _add_form_element_after() {
@@ -1256,32 +1256,32 @@  discard block
 block discarded – undo
1256 1256
 	 * @return json json object
1257 1257
 	 */
1258 1258
 	public function switch_template_pack() {
1259
-		$GRP_ID = ! empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1260
-		$template_pack = ! empty( $this->_req_data['template_pack'] ) ? $this->_req_data['template_pack'] : '';
1259
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1260
+		$template_pack = ! empty($this->_req_data['template_pack']) ? $this->_req_data['template_pack'] : '';
1261 1261
 
1262 1262
 		//verify we have needed values.
1263
-		if ( empty( $GRP_ID ) || empty( $template_pack ) ) {
1263
+		if (empty($GRP_ID) || empty($template_pack)) {
1264 1264
 			$this->_template_args['error'] = TRUE;
1265
-			EE_Error::add_error( __('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__  );
1265
+			EE_Error::add_error(__('The required date for switching templates is not available.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1266 1266
 		} else {
1267 1267
 			//get template, set the new template_pack and then reset to default
1268
-			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1268
+			$mtpg = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1269 1269
 
1270
-			$mtpg->set_template_pack_name( $template_pack );
1270
+			$mtpg->set_template_pack_name($template_pack);
1271 1271
 			$this->_req_data['msgr'] = $mtpg->messenger();
1272 1272
 			$this->_req_data['mt'] = $mtpg->message_type();
1273 1273
 
1274 1274
 			$query_args = $this->_reset_to_default_template();
1275 1275
 
1276
-			if ( empty( $query_args['id'] ) ) {
1277
-				EE_Error::add_error( __('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1276
+			if (empty($query_args['id'])) {
1277
+				EE_Error::add_error(__('Something went wrong with switching the template pack. Please try again or contact EE support', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1278 1278
 				$this->_template_args['error'] = TRUE;
1279 1279
 			} else {
1280
-				$template_label =$mtpg->get_template_pack()->label;
1280
+				$template_label = $mtpg->get_template_pack()->label;
1281 1281
 				$template_pack_labels = $mtpg->messenger_obj()->get_supports_labels();
1282
-				EE_Error::add_success( sprintf( __('This message template has been successfully switched to use the %s %s.  Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack ) );
1282
+				EE_Error::add_success(sprintf(__('This message template has been successfully switched to use the %s %s.  Please wait while the page reloads with your new template.', 'event_espresso'), $template_label, $template_pack_labels->template_pack));
1283 1283
 				//generate the redirect url for js.
1284
-				$url = self::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1284
+				$url = self::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1285 1285
 				$this->_template_args['data']['redirect_url'] = $url;
1286 1286
 				$this->_template_args['success'] = true;
1287 1287
 			}
@@ -1302,56 +1302,56 @@  discard block
 block discarded – undo
1302 1302
 	protected function _reset_to_default_template() {
1303 1303
 		$success = TRUE;
1304 1304
 		$templates = array();
1305
-		$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1305
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1306 1306
 		//we need to make sure we've got the info we need.
1307
-		if ( !isset( $this->_req_data['msgr'] ) && !isset( $this->_req_data['mt'] ) && !isset( $this->_req_data['GRP_ID'] ) ) {
1308
-			EE_Error::add_error( __('In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset.  At least one of these is missing.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1307
+		if ( ! isset($this->_req_data['msgr']) && ! isset($this->_req_data['mt']) && ! isset($this->_req_data['GRP_ID'])) {
1308
+			EE_Error::add_error(__('In order to reset the template to its default we require the messenger, message type, and message template GRP_ID to know what is being reset.  At least one of these is missing.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1309 1309
 			$success = FALSE;
1310 1310
 		}
1311 1311
 
1312 1312
 		//all templates will be reset to whatever the defaults are for the global template matching the messenger and message type.
1313
-		$success = !empty( $GRP_ID ) ? TRUE : FALSE;
1313
+		$success = ! empty($GRP_ID) ? TRUE : FALSE;
1314 1314
 
1315
-		if ( $success ) {
1315
+		if ($success) {
1316 1316
 
1317 1317
 			//let's first determine if the incoming template is a global template, if it isn't then we need to get the global template matching messenger and message type.
1318
-			$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID( $GRP_ID );
1318
+			$MTPG = EEM_Message_Template_Group::instance()->get_one_by_ID($GRP_ID);
1319 1319
 
1320 1320
 
1321 1321
 			//note this is ONLY deleteing the template fields (Message Template rows) NOT the message template group.
1322
-			$success = $this->_delete_mtp_permanently( $GRP_ID, FALSE );
1322
+			$success = $this->_delete_mtp_permanently($GRP_ID, FALSE);
1323 1323
 
1324
-			if ( $success ) {
1324
+			if ($success) {
1325 1325
 				//if successfully deleted, lets generate the new ones.  Note. We set GLOBAL to true, because resets on ANY template will use the related global template defaults for regeneration.  This means that if a custom template is reset it resets to whatever the related global template is.  HOWEVER, we DO keep the template pack and template variation set for the current custom template when resetting.
1326
-				$templates = $this->_generate_new_templates( $this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, TRUE );
1326
+				$templates = $this->_generate_new_templates($this->_req_data['msgr'], $this->_req_data['mt'], $GRP_ID, TRUE);
1327 1327
 			}
1328 1328
 
1329 1329
 		}
1330 1330
 
1331 1331
 		//any error messages?
1332
-		if ( !$success ) {
1333
-			EE_Error::add_error( __('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1332
+		if ( ! $success) {
1333
+			EE_Error::add_error(__('Something went wrong with deleting existing templates. Unable to reset to default', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1334 1334
 		}
1335 1335
 
1336 1336
 		//all good, let's add a success message!
1337
-		if ( $success && ! empty( $templates ) ) {
1337
+		if ($success && ! empty($templates)) {
1338 1338
 			$templates = $templates[0]; //the info for the template we generated is the first element in the returned array.
1339 1339
 			EE_Error::overwrite_success();
1340
-			EE_Error::add_success( __('Templates have been reset to defaults.', 'event_espresso') );
1340
+			EE_Error::add_success(__('Templates have been reset to defaults.', 'event_espresso'));
1341 1341
 		}
1342 1342
 
1343 1343
 
1344 1344
 		$query_args = array(
1345
-			'id' => isset( $templates['GRP_ID'] ) ? $templates['GRP_ID'] : NULL,
1346
-			'context' => isset( $templates['MTP_context'] ) ? $templates['MTP_context'] : NULL,
1347
-			'action' => isset( $templates['GRP_ID'] ) ? 'edit_message_template' : 'default'
1345
+			'id' => isset($templates['GRP_ID']) ? $templates['GRP_ID'] : NULL,
1346
+			'context' => isset($templates['MTP_context']) ? $templates['MTP_context'] : NULL,
1347
+			'action' => isset($templates['GRP_ID']) ? 'edit_message_template' : 'default'
1348 1348
 			);
1349 1349
 
1350 1350
 		//if called via ajax then we return query args otherwise redirect
1351
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
1351
+		if (defined('DOING_AJAX') && DOING_AJAX) {
1352 1352
 			return $query_args;
1353 1353
 		} else {
1354
-			$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
1354
+			$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
1355 1355
 		}
1356 1356
 
1357 1357
 	}
@@ -1364,20 +1364,20 @@  discard block
 block discarded – undo
1364 1364
 	 * @param bool $send if TRUE then we are doing an actual TEST send with the results of the preview.
1365 1365
 	 * @return void
1366 1366
 	 */
1367
-	public function _preview_message( $send = FALSE ) {
1367
+	public function _preview_message($send = FALSE) {
1368 1368
 		//first make sure we've got the necessary parameters
1369
-		if ( !isset( $this->_req_data['message_type'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['GRP_ID'] ) ) {
1370
-			EE_Error::add_error( __('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1369
+		if ( ! isset($this->_req_data['message_type']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['GRP_ID'])) {
1370
+			EE_Error::add_error(__('Missing necessary parameters for displaying preview', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1371 1371
 		}
1372 1372
 
1373
-		EE_Registry::instance()->REQ->set( 'GRP_ID', $this->_req_data['GRP_ID'] );
1373
+		EE_Registry::instance()->REQ->set('GRP_ID', $this->_req_data['GRP_ID']);
1374 1374
 
1375 1375
 		$MSG = new EE_messages();
1376 1376
 
1377 1377
 		//get the preview!
1378
-		$preview = $MSG->preview_message( $this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send );
1378
+		$preview = $MSG->preview_message($this->_req_data['message_type'], $this->_req_data['context'], $this->_req_data['messenger'], $send);
1379 1379
 
1380
-		if ( $send ) {
1380
+		if ($send) {
1381 1381
 			return $preview;
1382 1382
 		}
1383 1383
 
@@ -1387,16 +1387,16 @@  discard block
 block discarded – undo
1387 1387
 			'context' => $this->_req_data['context'],
1388 1388
 			'action' => 'edit_message_template'
1389 1389
 			);
1390
-		$go_back_url = parent::add_query_args_and_nonce( $query_args, $this->_admin_base_url );
1391
-		$preview_button = '<a href="' . $go_back_url . '" class="button-secondary messages-preview-go-back-button">' . __('Go Back to Edit', 'event_espresso') . '</a>';
1390
+		$go_back_url = parent::add_query_args_and_nonce($query_args, $this->_admin_base_url);
1391
+		$preview_button = '<a href="'.$go_back_url.'" class="button-secondary messages-preview-go-back-button">'.__('Go Back to Edit', 'event_espresso').'</a>';
1392 1392
 
1393 1393
 		//let's provide a helpful title for context
1394
-		$preview_title = sprintf( __('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular']) );
1394
+		$preview_title = sprintf(__('Viewing Preview for %s %s Message Template', 'event_espresso'), ucwords($this->_active_messengers[$this->_req_data['messenger']]['obj']->label['singular']), ucwords($this->_active_message_types[$this->_req_data['message_type']]['obj']->label['singular']));
1395 1395
 
1396 1396
 
1397 1397
 		//setup display of preview.
1398 1398
 		$this->_admin_page_title = $preview_title;
1399
-		$this->_template_args['admin_page_content'] = $preview_button . '<br />' .stripslashes($preview);
1399
+		$this->_template_args['admin_page_content'] = $preview_button.'<br />'.stripslashes($preview);
1400 1400
 		$this->_template_args['data']['force_json'] = TRUE;
1401 1401
 	}
1402 1402
 
@@ -1424,9 +1424,9 @@  discard block
 block discarded – undo
1424 1424
 	 * @return void
1425 1425
 	 */
1426 1426
 	protected function _register_edit_meta_boxes() {
1427
-		add_meta_box( 'mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array( $this, 'shortcode_meta_box' ), $this->_current_screen->id, 'side', 'default' );
1428
-		add_meta_box( 'mtp_extra_actions', __('Extra Actions', 'event_espresso'), array( $this, 'extra_actions_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1429
-		add_meta_box( 'mtp_templates', __('Template Styles', 'event_espresso'), array( $this, 'template_pack_meta_box' ), $this->_current_screen->id, 'side', 'high' );
1427
+		add_meta_box('mtp_valid_shortcodes', __('Valid Shortcodes', 'event_espresso'), array($this, 'shortcode_meta_box'), $this->_current_screen->id, 'side', 'default');
1428
+		add_meta_box('mtp_extra_actions', __('Extra Actions', 'event_espresso'), array($this, 'extra_actions_meta_box'), $this->_current_screen->id, 'side', 'high');
1429
+		add_meta_box('mtp_templates', __('Template Styles', 'event_espresso'), array($this, 'template_pack_meta_box'), $this->_current_screen->id, 'side', 'high');
1430 1430
 	}
1431 1431
 
1432 1432
 
@@ -1447,10 +1447,10 @@  discard block
 block discarded – undo
1447 1447
 
1448 1448
 		$tp_select_values = array();
1449 1449
 
1450
-		foreach ( $template_packs as $tp ) {
1450
+		foreach ($template_packs as $tp) {
1451 1451
 			//only include template packs that support this messenger and message type!
1452 1452
 			$supports = $tp->get_supports();
1453
-			if ( ! isset( $supports[$this->_message_template_group->messenger()] ) || ! in_array( $this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()] ) ) {
1453
+			if ( ! isset($supports[$this->_message_template_group->messenger()]) || ! in_array($this->_message_template_group->message_type(), $supports[$this->_message_template_group->messenger()])) {
1454 1454
 				//not supported
1455 1455
 				continue;
1456 1456
 			}
@@ -1462,7 +1462,7 @@  discard block
 block discarded – undo
1462 1462
 		}
1463 1463
 
1464 1464
 		//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.
1465
-		if ( empty( $tp_select_values ) ) {
1465
+		if (empty($tp_select_values)) {
1466 1466
 			$tp_select_values[] = array(
1467 1467
 				'text' => __('Default', 'event_espresso'),
1468 1468
 				'id' => 'default'
@@ -1470,27 +1470,27 @@  discard block
 block discarded – undo
1470 1470
 		}
1471 1471
 
1472 1472
 		//setup variation select values for the currently selected template.
1473
-		$variations = $this->_message_template_group->get_template_pack()->get_variations( $this->_message_template_group->messenger(), $this->_message_template_group->message_type() );
1473
+		$variations = $this->_message_template_group->get_template_pack()->get_variations($this->_message_template_group->messenger(), $this->_message_template_group->message_type());
1474 1474
 		$variations_select_values = array();
1475
-		foreach ( $variations as $variation => $label ) {
1475
+		foreach ($variations as $variation => $label) {
1476 1476
 			$variations_select_values[] = array(
1477 1477
 				'text' => $label,
1478 1478
 				'id' => $variation
1479 1479
 				);
1480 1480
 		}
1481 1481
 
1482
-		$template_pack_labels= $this->_message_template_group->messenger_obj()->get_supports_labels();
1482
+		$template_pack_labels = $this->_message_template_group->messenger_obj()->get_supports_labels();
1483 1483
 
1484
-		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input( 'MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name() );
1485
-		$template_args['variations_selector'] = EEH_Form_Fields::select_input( 'MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation() );
1484
+		$template_args['template_packs_selector'] = EEH_Form_Fields::select_input('MTP_template_pack', $tp_select_values, $this->_message_template_group->get_template_pack_name());
1485
+		$template_args['variations_selector'] = EEH_Form_Fields::select_input('MTP_template_variation', $variations_select_values, $this->_message_template_group->get_template_pack_variation());
1486 1486
 		$template_args['template_pack_label'] = $template_pack_labels->template_pack;
1487 1487
 		$template_args['template_variation_label'] = $template_pack_labels->template_variation;
1488 1488
 		$template_args['template_pack_description'] = $template_pack_labels->template_pack_description;
1489 1489
 		$template_args['template_variation_description'] = $template_pack_labels->template_variation_description;
1490 1490
 
1491
-		$template = EE_MSG_TEMPLATE_PATH . 'template_pack_and_variations_metabox.template.php';
1491
+		$template = EE_MSG_TEMPLATE_PATH.'template_pack_and_variations_metabox.template.php';
1492 1492
 
1493
-		EEH_Template::display_template( $template, $template_args );
1493
+		EEH_Template::display_template($template, $template_args);
1494 1494
 	}
1495 1495
 
1496 1496
 
@@ -1511,52 +1511,52 @@  discard block
 block discarded – undo
1511 1511
 			'GRP_ID' => $this->_message_template_group->GRP_ID()
1512 1512
 			);
1513 1513
 
1514
-		$button = $this->get_action_link_or_button( 'reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button' );
1514
+		$button = $this->get_action_link_or_button('reset_to_default', 'reset', $extra_args, 'button-primary reset-default-button');
1515 1515
 
1516 1516
 
1517 1517
 		//test button
1518 1518
 		//first we need to see if there are any fields
1519 1519
 		$fields = $this->_message_template_group->messenger_obj()->get_test_settings_fields();
1520 1520
 
1521
-		if ( !empty( $fields ) ) {
1521
+		if ( ! empty($fields)) {
1522 1522
 			//yup there be fields
1523
-			foreach ( $fields as $field => $config ) {
1524
-				$field_id = $this->_message_template_group->messenger() . '_' . $field;
1523
+			foreach ($fields as $field => $config) {
1524
+				$field_id = $this->_message_template_group->messenger().'_'.$field;
1525 1525
 				$existing = $this->_message_template_group->messenger_obj()->get_existing_test_settings();
1526
-				$default = isset( $config['default'] ) ? $config['default'] : '';
1527
-				$default = isset( $config['value'] ) ? $config['value'] : $default;
1526
+				$default = isset($config['default']) ? $config['default'] : '';
1527
+				$default = isset($config['value']) ? $config['value'] : $default;
1528 1528
 
1529 1529
 				//if type is hidden and the value is empty something may have gone wrong so let's correct with the defaults
1530 1530
 				$fix = $config['input'] == 'hidden' && isset($existing[$field]) && empty($existing[$field]) ? $default : '';
1531
-				$existing[$field] = isset( $existing[$field] ) && empty( $fix ) ? $existing[$field] : $fix;
1531
+				$existing[$field] = isset($existing[$field]) && empty($fix) ? $existing[$field] : $fix;
1532 1532
 
1533 1533
 				$template_form_fields[$field_id] = array(
1534
-					'name' => 'test_settings_fld[' . $field . ']',
1534
+					'name' => 'test_settings_fld['.$field.']',
1535 1535
 					'label' => $config['label'],
1536 1536
 					'input' => $config['input'],
1537 1537
 					'type' => $config['type'],
1538 1538
 					'required' => $config['required'],
1539 1539
 					'validation' => $config['validation'],
1540
-					'value' => isset( $existing[$field] ) ? $existing[$field] : $default,
1540
+					'value' => isset($existing[$field]) ? $existing[$field] : $default,
1541 1541
 					'css_class' => $config['css_class'],
1542
-					'options' => isset( $config['options'] ) ? $config['options'] : array(),
1542
+					'options' => isset($config['options']) ? $config['options'] : array(),
1543 1543
 					'default' => $default,
1544 1544
 					'format' => $config['format']
1545 1545
 					);
1546 1546
 			}
1547 1547
 		}
1548 1548
 
1549
-		$test_settings_fields = !empty( $template_form_fields) ? $this->_generate_admin_form_fields( $template_form_fields, 'string', 'ee_tst_settings_flds' ) : '';
1549
+		$test_settings_fields = ! empty($template_form_fields) ? $this->_generate_admin_form_fields($template_form_fields, 'string', 'ee_tst_settings_flds') : '';
1550 1550
 
1551 1551
 		$test_settings_html = '';
1552 1552
 		//print out $test_settings_fields
1553
-		if ( !empty( $test_settings_fields ) ) {
1553
+		if ( ! empty($test_settings_fields)) {
1554 1554
 			echo $test_settings_fields;
1555
-			$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>';
1555
+			$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>';
1556 1556
 		}
1557 1557
 
1558 1558
 		//and button
1559
-		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>';
1559
+		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>';
1560 1560
 	}
1561 1561
 
1562 1562
 
@@ -1571,13 +1571,13 @@  discard block
 block discarded – undo
1571 1571
      * @param string $linked_input_id The css id of the input that the shortcodes get added to.
1572 1572
      * @return string
1573 1573
     */
1574
-	protected function _get_shortcode_selector( $field, $linked_input_id ) {
1574
+	protected function _get_shortcode_selector($field, $linked_input_id) {
1575 1575
 		$template_args = array(
1576
-			'shortcodes' => $this->_get_shortcodes( array( $field ), true ),
1576
+			'shortcodes' => $this->_get_shortcodes(array($field), true),
1577 1577
 			'fieldname' => $field,
1578 1578
 			'linked_input_id' => $linked_input_id
1579 1579
 		);
1580
-		return EEH_Template::display_template( EE_MSG_TEMPLATE_PATH . 'shortcode_selector_skeleton.template.php', $template_args, true );
1580
+		return EEH_Template::display_template(EE_MSG_TEMPLATE_PATH.'shortcode_selector_skeleton.template.php', $template_args, true);
1581 1581
 	}
1582 1582
 
1583 1583
 
@@ -1591,13 +1591,13 @@  discard block
 block discarded – undo
1591 1591
 		$shortcodes = $this->_get_shortcodes(array(), FALSE); //just make sure shortcodes property is set
1592 1592
 		$messenger = $this->_message_template_group->messenger_obj();
1593 1593
 		//now let's set the content depending on the status of the shortcodes array
1594
-		if ( empty( $shortcodes ) ) {
1595
-			$content = '<p>' . __('There are no valid shortcodes available', 'event_espresso') . '</p>';
1594
+		if (empty($shortcodes)) {
1595
+			$content = '<p>'.__('There are no valid shortcodes available', 'event_espresso').'</p>';
1596 1596
 			echo $content;
1597 1597
 		} else {
1598 1598
 			$alt = 0;
1599 1599
 			?>
1600
-			<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>
1600
+			<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>
1601 1601
 			<?php
1602 1602
 		}
1603 1603
 
@@ -1614,7 +1614,7 @@  discard block
 block discarded – undo
1614 1614
 	protected function _set_shortcodes() {
1615 1615
 
1616 1616
 		//no need to run this if the property is already set
1617
-		if ( !empty($this->_shortcodes ) ) return;
1617
+		if ( ! empty($this->_shortcodes)) return;
1618 1618
 
1619 1619
 		$this->_shortcodes = $this->_get_shortcodes();
1620 1620
 	}
@@ -1631,14 +1631,14 @@  discard block
 block discarded – undo
1631 1631
 	 * @param  boolean $merged Whether to merge all the shortcodes into one list of unique shortcodes
1632 1632
 	 * @return array          Shortcodes indexed by fieldname and the an array of shortcode/label pairs OR if merged is true just an array of shortcode/label pairs.
1633 1633
 	 */
1634
-	protected function _get_shortcodes( $fields = array(), $merged = TRUE ) {
1634
+	protected function _get_shortcodes($fields = array(), $merged = TRUE) {
1635 1635
 		$this->_set_message_template_group();
1636 1636
 
1637 1637
 		//we need the messenger and message template to retrieve the valid shortcodes array.
1638
-		$GRP_ID = isset( $this->_req_data['id'] ) && !empty( $this->_req_data['id'] ) ? absint( $this->_req_data['id'] ) : FALSE;
1639
-		$context = isset( $this->_req_data['context'] ) ? $this->_req_data['context'] : key( $this->_message_template_group->contexts_config() );
1638
+		$GRP_ID = isset($this->_req_data['id']) && ! empty($this->_req_data['id']) ? absint($this->_req_data['id']) : FALSE;
1639
+		$context = isset($this->_req_data['context']) ? $this->_req_data['context'] : key($this->_message_template_group->contexts_config());
1640 1640
 
1641
-		return !empty($GRP_ID) ? $this->_message_template_group->get_shortcodes( $context, $fields, $merged ) : array();
1641
+		return ! empty($GRP_ID) ? $this->_message_template_group->get_shortcodes($context, $fields, $merged) : array();
1642 1642
 	}
1643 1643
 
1644 1644
 
@@ -1651,19 +1651,19 @@  discard block
 block discarded – undo
1651 1651
 	 */
1652 1652
 	protected function _set_message_template_group() {
1653 1653
 
1654
-		if ( !empty( $this->_message_template_group ) )
1654
+		if ( ! empty($this->_message_template_group))
1655 1655
 			return; //get out if this is already set.
1656 1656
 
1657
-		$GRP_ID =  ! empty( $this->_req_data['GRP_ID'] ) ? absint( $this->_req_data['GRP_ID'] ) : FALSE;
1658
-		$GRP_ID = empty( $GRP_ID ) && ! empty( $this->_req_data['id'] ) ? $this->_req_data['id'] : $GRP_ID;
1657
+		$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? absint($this->_req_data['GRP_ID']) : FALSE;
1658
+		$GRP_ID = empty($GRP_ID) && ! empty($this->_req_data['id']) ? $this->_req_data['id'] : $GRP_ID;
1659 1659
 
1660 1660
 		//let's get the message templates
1661 1661
 		$MTP = EEM_Message_Template_Group::instance();
1662 1662
 
1663
-		if ( empty($GRP_ID) )
1663
+		if (empty($GRP_ID))
1664 1664
 			$this->_message_template_group = $MTP->create_default_object();
1665 1665
 		else
1666
-			$this->_message_template_group = $MTP->get_one_by_ID( $GRP_ID );
1666
+			$this->_message_template_group = $MTP->get_one_by_ID($GRP_ID);
1667 1667
 
1668 1668
 		$this->_template_pack = $this->_message_template_group->get_template_pack();
1669 1669
 		$this->_variation = $this->_message_template_group->get_template_pack_variation();
@@ -1689,26 +1689,26 @@  discard block
 block discarded – undo
1689 1689
 		<div class="ee-msg-switcher-container">
1690 1690
 			<form method="get" action="<?php echo EE_MSG_ADMIN_URL; ?>" id="ee-msg-context-switcher-frm">
1691 1691
 				<?php
1692
-					foreach ( $args as $name => $value ) {
1693
-						if ( $name == 'context' || empty($value) || $name == 'extra' ) continue;
1692
+					foreach ($args as $name => $value) {
1693
+						if ($name == 'context' || empty($value) || $name == 'extra') continue;
1694 1694
 						?>
1695 1695
 						<input type="hidden" name="<?php echo $name; ?>" value = "<?php echo $value; ?>" />
1696 1696
 						<?php
1697 1697
 					}
1698 1698
 					//setup nonce_url
1699
-					wp_nonce_field($args['action'] . '_nonce', $args['action'] . '_nonce', false);
1699
+					wp_nonce_field($args['action'].'_nonce', $args['action'].'_nonce', false);
1700 1700
 				?>
1701 1701
 				<select name="context">
1702 1702
 					<?php
1703 1703
 					$context_templates = $template_group_object->context_templates();
1704
-					if ( is_array($context_templates) ) :
1705
-							foreach ( $context_templates as $context => $template_fields ) :
1704
+					if (is_array($context_templates)) :
1705
+							foreach ($context_templates as $context => $template_fields) :
1706 1706
 								$checked = ($context == $args['context']) ? 'selected="selected"' : '';
1707 1707
 					?>
1708 1708
 					<option value="<?php echo $context; ?>" <?php echo $checked; ?>><?php echo $context_details[$context]['label']; ?></option>
1709 1709
 					<?php endforeach; endif; ?>
1710 1710
 				</select>
1711
-				<?php $button_text = sprintf( __('Switch %s', 'event_espresso'), ucwords($context_label['label']) ); ?>
1711
+				<?php $button_text = sprintf(__('Switch %s', 'event_espresso'), ucwords($context_label['label'])); ?>
1712 1712
 				<input id="submit-msg-context-switcher-sbmt" class="button-secondary" type="submit" value="<?php echo $button_text; ?>">
1713 1713
 			</form>
1714 1714
 			<?php echo $args['extra']; ?>
@@ -1732,8 +1732,8 @@  discard block
 block discarded – undo
1732 1732
 	 * @param int $index This helps us know which template field to select from the request array.
1733 1733
 	 */
1734 1734
 	protected function _set_message_template_column_values($index) {
1735
-		if ( is_array($this->_req_data['MTP_template_fields'][$index]['content'] ) ) {
1736
-			foreach ( $this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value ) {
1735
+		if (is_array($this->_req_data['MTP_template_fields'][$index]['content'])) {
1736
+			foreach ($this->_req_data['MTP_template_fields'][$index]['content'] as $field => $value) {
1737 1737
 				$this->_req_data['MTP_template_fields'][$index]['content'][$field] = $value;
1738 1738
 			}
1739 1739
 		} else {
@@ -1765,27 +1765,27 @@  discard block
 block discarded – undo
1765 1765
 
1766 1766
 
1767 1767
 
1768
-	protected function _insert_or_update_message_template($new = FALSE ) {
1768
+	protected function _insert_or_update_message_template($new = FALSE) {
1769 1769
 
1770
-		do_action ( 'AHEE_log', __FILE__, __FUNCTION__, '');
1770
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1771 1771
 		$success = 0;
1772 1772
 		$override = FALSE;
1773 1773
 
1774 1774
 		//setup notices description
1775
-		$messenger = !empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'] ) ) : false;
1776
-		$message_type = !empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'] ) ) : false;
1777
-		$context = !empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'] ) ) : false;
1775
+		$messenger = ! empty($this->_req_data['MTP_messenger']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_messenger'])) : false;
1776
+		$message_type = ! empty($this->_req_data['MTP_message_type']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_message_type'])) : false;
1777
+		$context = ! empty($this->_req_data['MTP_context']) ? ucwords(str_replace('_', ' ', $this->_req_data['MTP_context'])) : false;
1778 1778
 
1779
-		$item_desc = $messenger ? $messenger . ' ' . $message_type . ' ' . $context . ' ' : '';
1779
+		$item_desc = $messenger ? $messenger.' '.$message_type.' '.$context.' ' : '';
1780 1780
 		$item_desc .= 'Message Template';
1781 1781
 		$query_args = array();
1782 1782
 		$validates = '';
1783 1783
 
1784 1784
 		//if this is "new" then we need to generate the default contexts for the selected messenger/message_type for user to edit.
1785
-		if ( $new ) {
1786
-			$GRP_ID = !empty( $this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : 0;
1787
-			if ( $edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID ) ) {
1788
-				if ( empty($edit_array) ) {
1785
+		if ($new) {
1786
+			$GRP_ID = ! empty($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : 0;
1787
+			if ($edit_array = $this->_generate_new_templates($messenger, $message_type, $GRP_ID)) {
1788
+				if (empty($edit_array)) {
1789 1789
 					$success = 0;
1790 1790
 				} else {
1791 1791
 					$success = 1;
@@ -1804,34 +1804,34 @@  discard block
 block discarded – undo
1804 1804
 
1805 1805
 
1806 1806
 			//run update for each template field in displayed context
1807
-			if ( !isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'] ) ) {
1808
-				EE_Error::add_error( __('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
1807
+			if ( ! isset($this->_req_data['MTP_template_fields']) && empty($this->_req_data['MTP_template_fields'])) {
1808
+				EE_Error::add_error(__('There was a problem saving the template fields from the form because I didn\'t receive any actual template field data.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1809 1809
 				$success = 0;
1810 1810
 				$action_desc = '';
1811 1811
 
1812 1812
 			} else {
1813 1813
 				//first validate all fields!
1814
-				$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']);
1814
+				$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']);
1815 1815
 
1816 1816
 				//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.
1817
-				if ( is_array($validates) && !empty($validates) ) {
1817
+				if (is_array($validates) && ! empty($validates)) {
1818 1818
 					//add the transient so when the form loads we know which fields to highlight
1819
-					$this->_add_transient( 'edit_message_template', $validates );
1819
+					$this->_add_transient('edit_message_template', $validates);
1820 1820
 
1821 1821
 					$success = 0;
1822
-					$action_desc ='';
1822
+					$action_desc = '';
1823 1823
 
1824 1824
 					//setup notices
1825
-					foreach ( $validates as $field => $error ) {
1826
-						if ( isset($error['msg'] ) )
1827
-							EE_Error::add_error( $error['msg'], __FILE__, __FUNCTION__, __LINE__ );
1825
+					foreach ($validates as $field => $error) {
1826
+						if (isset($error['msg']))
1827
+							EE_Error::add_error($error['msg'], __FILE__, __FUNCTION__, __LINE__);
1828 1828
 					}
1829 1829
 
1830 1830
 				} else {
1831
-					foreach ( $this->_req_data['MTP_template_fields'] as $template_field => $content ) {
1831
+					foreach ($this->_req_data['MTP_template_fields'] as $template_field => $content) {
1832 1832
 						$set_column_values = $this->_set_message_template_column_values($template_field);
1833 1833
 
1834
-						$where_cols_n_values = array( 'MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']);
1834
+						$where_cols_n_values = array('MTP_ID' => $this->_req_data['MTP_template_fields'][$template_field]['MTP_ID']);
1835 1835
 
1836 1836
 						$message_template_fields = array(
1837 1837
 							'GRP_ID' => $set_column_values['GRP_ID'],
@@ -1839,10 +1839,10 @@  discard block
 block discarded – undo
1839 1839
 							'MTP_context' => $set_column_values['MTP_context'],
1840 1840
 							'MTP_content' => $set_column_values['MTP_content']
1841 1841
 							);
1842
-						if ( $updated = $MTP->update( $message_template_fields, array( $where_cols_n_values ) ) ) {
1843
-							if ( $updated === FALSE ) {
1844
-								$msg = sprintf( __('%s field was NOT updated for some reason', 'event_espresso'), $template_field );
1845
-								EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ );
1842
+						if ($updated = $MTP->update($message_template_fields, array($where_cols_n_values))) {
1843
+							if ($updated === FALSE) {
1844
+								$msg = sprintf(__('%s field was NOT updated for some reason', 'event_espresso'), $template_field);
1845
+								EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1846 1846
 							} else {
1847 1847
 								$success = 1;
1848 1848
 							}
@@ -1859,24 +1859,24 @@  discard block
 block discarded – undo
1859 1859
 						'MTP_is_override' => $set_column_values['MTP_is_override'],
1860 1860
 						'MTP_deleted' => $set_column_values['MTP_deleted'],
1861 1861
 						'MTP_is_active' => $set_column_values['MTP_is_active'],
1862
-						'MTP_name' => !empty( $this->_req_data['ee_msg_non_global_fields']['MTP_name'] ) ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] : '',
1863
-						'MTP_description' => !empty( $this->_req_data['ee_msg_non_global_fields']['MTP_description'] ) ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] : ''
1862
+						'MTP_name' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_name']) ? $this->_req_data['ee_msg_non_global_fields']['MTP_name'] : '',
1863
+						'MTP_description' => ! empty($this->_req_data['ee_msg_non_global_fields']['MTP_description']) ? $this->_req_data['ee_msg_non_global_fields']['MTP_description'] : ''
1864 1864
 						);
1865 1865
 
1866
-					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID'] );
1867
-					$updated = $MTPG->update( $mtpg_fields, array($mtpg_where) );
1866
+					$mtpg_where = array('GRP_ID' => $set_column_values['GRP_ID']);
1867
+					$updated = $MTPG->update($mtpg_fields, array($mtpg_where));
1868 1868
 
1869
-					if ( $updated === FALSE ) {
1870
-						$msg = sprintf( __('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), $set_column_values['GRP_ID'] );
1871
-						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__ );
1869
+					if ($updated === FALSE) {
1870
+						$msg = sprintf(__('The Message Template Group (%d) was NOT updated for some reason', 'event_espresso'), $set_column_values['GRP_ID']);
1871
+						EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1872 1872
 					} else {
1873 1873
 						//k now we need to ensure the template_pack and template_variation fields are set.
1874
-						$template_pack = ! empty( $this->_req_data['MTP_template_pack' ] ) ? $this->_req_data['MTP_template_pack'] : 'default';
1875
-						$template_variation = ! empty( $this->_req_data['MTP_template_variation'] ) ? $this->_req_data['MTP_template_variation'] : 'default';
1876
-						$mtpg_obj = $MTPG->get_one_by_ID( $set_column_values['GRP_ID'] );
1877
-						if ( $mtpg_obj instanceof EE_Message_Template_Group ) {
1878
-							$mtpg_obj->set_template_pack_name( $template_pack );
1879
-							$mtpg_obj->set_template_pack_variation( $template_variation );
1874
+						$template_pack = ! empty($this->_req_data['MTP_template_pack']) ? $this->_req_data['MTP_template_pack'] : 'default';
1875
+						$template_variation = ! empty($this->_req_data['MTP_template_variation']) ? $this->_req_data['MTP_template_variation'] : 'default';
1876
+						$mtpg_obj = $MTPG->get_one_by_ID($set_column_values['GRP_ID']);
1877
+						if ($mtpg_obj instanceof EE_Message_Template_Group) {
1878
+							$mtpg_obj->set_template_pack_name($template_pack);
1879
+							$mtpg_obj->set_template_pack_variation($template_variation);
1880 1880
 						}
1881 1881
 						$success = 1;
1882 1882
 					}
@@ -1886,7 +1886,7 @@  discard block
 block discarded – undo
1886 1886
 		}
1887 1887
 
1888 1888
 		//we return things differently if doing ajax
1889
-		if ( defined('DOING_AJAX') && DOING_AJAX ) {
1889
+		if (defined('DOING_AJAX') && DOING_AJAX) {
1890 1890
 			$this->_template_args['success'] = $success;
1891 1891
 			$this->_template_args['error'] = ! $success ? TRUE : FALSE;
1892 1892
 			$this->_template_args['content'] = '';
@@ -1894,9 +1894,9 @@  discard block
 block discarded – undo
1894 1894
 				'grpID' => $edit_array['GRP_ID'],
1895 1895
 				'templateName' => $edit_array['template_name']
1896 1896
 				);
1897
-			if ( $success ) {
1897
+			if ($success) {
1898 1898
 				EE_Error::overwrite_success();
1899
-				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') );
1899
+				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'));
1900 1900
 			}
1901 1901
 
1902 1902
 			$this->_return_json();
@@ -1904,13 +1904,13 @@  discard block
 block discarded – undo
1904 1904
 
1905 1905
 
1906 1906
 		//was a test send triggered?
1907
-		if ( isset( $this->_req_data['test_button'] ) ) {
1907
+		if (isset($this->_req_data['test_button'])) {
1908 1908
 			EE_Error::overwrite_success();
1909
-			$this->_do_test_send( $this->_req_data['MTP_context'],  $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type'] );
1909
+			$this->_do_test_send($this->_req_data['MTP_context'], $this->_req_data['MTP_messenger'], $this->_req_data['MTP_message_type']);
1910 1910
 			$override = TRUE;
1911 1911
 		}
1912 1912
 
1913
-		if ( empty( $query_args ) ) {
1913
+		if (empty($query_args)) {
1914 1914
 			$query_args = array(
1915 1915
 				'id' => $this->_req_data['GRP_ID'],
1916 1916
 				'context' => $this->_req_data['MTP_context'],
@@ -1918,7 +1918,7 @@  discard block
 block discarded – undo
1918 1918
 				);
1919 1919
 		}
1920 1920
 
1921
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, $query_args, $override );
1921
+		$this->_redirect_after_action($success, $item_desc, $action_desc, $query_args, $override);
1922 1922
 	}
1923 1923
 
1924 1924
 
@@ -1931,24 +1931,24 @@  discard block
 block discarded – undo
1931 1931
 	 * @param  string $message_type message type being tested
1932 1932
 	 * @return void
1933 1933
 	 */
1934
-	protected function _do_test_send( $context, $messenger, $message_type ) {
1934
+	protected function _do_test_send($context, $messenger, $message_type) {
1935 1935
 		//set things up for preview
1936 1936
 		$this->_req_data['messenger'] = $messenger;
1937 1937
 		$this->_req_data['message_type'] = $message_type;
1938 1938
 		$this->_req_data['context'] = $context;
1939
-		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID'] ) ? $this->_req_data['GRP_ID'] : '';
1939
+		$this->_req_data['GRP_ID'] = isset($this->_req_data['GRP_ID']) ? $this->_req_data['GRP_ID'] : '';
1940 1940
 
1941 1941
 		//let's save any existing fields that might be required by the messenger
1942
-		if ( isset( $this->_req_data['test_settings_fld'] ) ) {
1943
-			$this->_active_messengers[$messenger]['obj']->set_existing_test_settings( $this->_req_data['test_settings_fld'] );
1942
+		if (isset($this->_req_data['test_settings_fld'])) {
1943
+			$this->_active_messengers[$messenger]['obj']->set_existing_test_settings($this->_req_data['test_settings_fld']);
1944 1944
 		}
1945 1945
 
1946 1946
 		$success = $this->_preview_message(TRUE);
1947 1947
 
1948
-		if ( $success ) {
1949
-			EE_Error::add_success( __('Test message sent', 'event_espresso') );
1948
+		if ($success) {
1949
+			EE_Error::add_success(__('Test message sent', 'event_espresso'));
1950 1950
 		} else {
1951
-			EE_Error::add_error( __('The test message was not sent', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
1951
+			EE_Error::add_error(__('The test message was not sent', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
1952 1952
 		}
1953 1953
 	}
1954 1954
 
@@ -1970,11 +1970,11 @@  discard block
 block discarded – undo
1970 1970
 	protected function _generate_new_templates($messenger, $message_types, $GRP_ID = 0, $global = FALSE) {
1971 1971
 
1972 1972
 		//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.
1973
-		if ( empty( $message_types ) )
1973
+		if (empty($message_types))
1974 1974
 			return true;
1975 1975
 
1976 1976
 
1977
-		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID,  $global);
1977
+		return EEH_MSG_Template::generate_new_templates($messenger, $message_types, $GRP_ID, $global);
1978 1978
 
1979 1979
 	}
1980 1980
 
@@ -1990,33 +1990,33 @@  discard block
 block discarded – undo
1990 1990
 	 * @param boolean $all whether this is going to trash/restore all contexts within a template group (TRUE) OR just an individual context (FALSE).
1991 1991
 	 * @return void
1992 1992
 	 */
1993
-	protected function _trash_or_restore_message_template($trash = TRUE, $all = FALSE ) {
1994
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1993
+	protected function _trash_or_restore_message_template($trash = TRUE, $all = FALSE) {
1994
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1995 1995
 		$MTP = EEM_Message_Template_Group::instance();
1996 1996
 
1997 1997
 		$success = 1;
1998 1998
 
1999 1999
 		//incoming GRP_IDs
2000
-		if ( $all ) {
2000
+		if ($all) {
2001 2001
 			//Checkboxes
2002
-			if ( !empty( $this->_req_data['checkbox'] ) && is_array($this->_req_data['checkbox'] ) ) {
2002
+			if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2003 2003
 				//if array has more than one element then success message should be plural.
2004 2004
 				//todo: what about nonce?
2005
-				$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2005
+				$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2006 2006
 
2007 2007
 				//cycle through checkboxes
2008
-				while ( list( $GRP_ID, $value ) = each ($this->_req_data['checkbox']) ) {
2009
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2010
-					if ( ! $trashed_or_restored ) {
2008
+				while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2009
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2010
+					if ( ! $trashed_or_restored) {
2011 2011
 						$success = 0;
2012 2012
 					}
2013 2013
 				}
2014 2014
 			} else {
2015 2015
 				//grab single GRP_ID and handle
2016
-				$GRP_ID = isset( $this->_req_data['id'] ) ? absint($this->_req_data['id']) : 0;
2017
-				if ( ! empty( $GRP_ID ) ) {
2018
-					$trashed_or_restored = $trash ? $MTP->delete_by_ID( $GRP_ID ) : $MTP->restore_by_ID( $GRP_ID );
2019
-					if ( ! $trashed_or_restored ) {
2016
+				$GRP_ID = isset($this->_req_data['id']) ? absint($this->_req_data['id']) : 0;
2017
+				if ( ! empty($GRP_ID)) {
2018
+					$trashed_or_restored = $trash ? $MTP->delete_by_ID($GRP_ID) : $MTP->restore_by_ID($GRP_ID);
2019
+					if ( ! $trashed_or_restored) {
2020 2020
 						$success = 0;
2021 2021
 					}
2022 2022
 				} else {
@@ -2028,13 +2028,13 @@  discard block
 block discarded – undo
2028 2028
 
2029 2029
 		$action_desc = $trash ? __('moved to the trash', 'event_espresso') : __('restored', 'event_espresso');
2030 2030
 
2031
-		$action_desc = !empty( $this->_req_data['template_switch'] ) ? __('switched') : $action_desc;
2031
+		$action_desc = ! empty($this->_req_data['template_switch']) ? __('switched') : $action_desc;
2032 2032
 
2033 2033
 		$item_desc = $all ? _n('Message Template Group', 'Message Template Groups', $success, 'event_espresso') : _n('Message Template Context', 'Message Template Contexts', $success, 'event_espresso');
2034 2034
 
2035
-		$item_desc = !empty( $this->_req_data['template_switch'] ) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2035
+		$item_desc = ! empty($this->_req_data['template_switch']) ? _n('template', 'templates', $success, 'event_espresso') : $item_desc;
2036 2036
 
2037
-		$this->_redirect_after_action( $success, $item_desc, $action_desc, array() );
2037
+		$this->_redirect_after_action($success, $item_desc, $action_desc, array());
2038 2038
 
2039 2039
 	}
2040 2040
 
@@ -2050,26 +2050,26 @@  discard block
 block discarded – undo
2050 2050
 	 * @return void
2051 2051
 	 */
2052 2052
 	protected function _delete_message_template() {
2053
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2053
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2054 2054
 
2055 2055
 		$success = 1;
2056 2056
 
2057 2057
 		//checkboxes
2058
-		if ( !empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'] ) ) {
2058
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
2059 2059
 			//if array has more than one element then success message should be plural
2060
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
2060
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
2061 2061
 
2062 2062
 			//cycle through bulk action checkboxes
2063
-			while ( list( $GRP_ID, $value ) = each($this->_req_data['checkbox'] ) ) {
2064
-				$success = $this->_delete_mtp_permanently( $GRP_ID );
2063
+			while (list($GRP_ID, $value) = each($this->_req_data['checkbox'])) {
2064
+				$success = $this->_delete_mtp_permanently($GRP_ID);
2065 2065
 			}
2066 2066
 		} else {
2067 2067
 			//grab single grp_id and delete
2068
-			$GRP_ID = absint($this->_req_data['id'] );
2069
-			$success = $this->_delete_mtp_permanently( $GRP_ID );
2068
+			$GRP_ID = absint($this->_req_data['id']);
2069
+			$success = $this->_delete_mtp_permanently($GRP_ID);
2070 2070
 		}
2071 2071
 
2072
-		$this->_redirect_after_action( $success, 'Message Templates', 'deleted', array() );
2072
+		$this->_redirect_after_action($success, 'Message Templates', 'deleted', array());
2073 2073
 
2074 2074
 	}
2075 2075
 
@@ -2082,20 +2082,20 @@  discard block
 block discarded – undo
2082 2082
 	 * @param  bool $include_group whether to delete the Message Template Group as well.
2083 2083
 	 * @return success        boolean to indicate the success of the deletes or not.
2084 2084
 	 */
2085
-	private function _delete_mtp_permanently( $GRP_ID, $include_group = TRUE ) {
2085
+	private function _delete_mtp_permanently($GRP_ID, $include_group = TRUE) {
2086 2086
 		$success = 1;
2087 2087
 		$MTPG = EEM_Message_Template_Group::instance();
2088 2088
 		//first let's GET this group
2089
-		$MTG = $MTPG->get_one_by_ID( $GRP_ID );
2089
+		$MTG = $MTPG->get_one_by_ID($GRP_ID);
2090 2090
 		//then delete permanently all the related Message Templates
2091
-		$deleted = $MTG->delete_related_permanently( 'Message_Template' );
2091
+		$deleted = $MTG->delete_related_permanently('Message_Template');
2092 2092
 
2093
-		if ( $deleted === 0 )
2093
+		if ($deleted === 0)
2094 2094
 			$success = 0;
2095 2095
 
2096 2096
 		//now delete permanently this particular group
2097 2097
 
2098
-		if ( $include_group && ! $MTG->delete_permanently() ) {
2098
+		if ($include_group && ! $MTG->delete_permanently()) {
2099 2099
 			$success = 0;
2100 2100
 		}
2101 2101
 		return $success;
@@ -2113,7 +2113,7 @@  discard block
 block discarded – undo
2113 2113
 	*	@return string
2114 2114
 	*/
2115 2115
 	protected function _learn_more_about_message_templates_link() {
2116
-		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >' . __('learn more about how message templates works', 'event_espresso') . '</a>';
2116
+		return '<a class="hidden" style="margin:0 20px; cursor:pointer; font-size:12px;" >'.__('learn more about how message templates works', 'event_espresso').'</a>';
2117 2117
 	}
2118 2118
 
2119 2119
 
@@ -2130,10 +2130,10 @@  discard block
 block discarded – undo
2130 2130
 
2131 2131
 		$this->_set_m_mt_settings();
2132 2132
 
2133
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2133
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2134 2134
 
2135 2135
 		//let's setup the messenger tabs
2136
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger );
2136
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($this->_m_mt_settings['messenger_tabs'], 'messenger_links', '|', $selected_messenger);
2137 2137
 		$this->_template_args['before_admin_page_content'] = '<div class="ui-widget ui-helper-clearfix">';
2138 2138
 		$this->_template_args['after_admin_page_content'] = '</div><!-- end .ui-widget -->';
2139 2139
 
@@ -2152,10 +2152,10 @@  discard block
 block discarded – undo
2152 2152
 	 */
2153 2153
 	protected function _set_m_mt_settings() {
2154 2154
 		//first if this is already set then lets get out no need to regenerate data.
2155
-		if ( !empty($this->_m_mt_settings) )
2155
+		if ( ! empty($this->_m_mt_settings))
2156 2156
 			return;
2157 2157
 
2158
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2158
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2159 2159
 
2160 2160
 		//get all installed messengers and message_types
2161 2161
 		$installed_message_objects = $this->_get_installed_message_objects();
@@ -2165,10 +2165,10 @@  discard block
 block discarded – undo
2165 2165
 
2166 2166
 		//assemble the array for the _tab_text_links helper
2167 2167
 
2168
-		foreach ( $messengers as $messenger ) {
2168
+		foreach ($messengers as $messenger) {
2169 2169
 			$this->_m_mt_settings['messenger_tabs'][$messenger->name] = array(
2170 2170
 				'label' => ucwords($messenger->label['singular']),
2171
-				'class' => isset( $this->_active_messengers[$messenger->name] ) ? 'messenger-active' : '',
2171
+				'class' => isset($this->_active_messengers[$messenger->name]) ? 'messenger-active' : '',
2172 2172
 				'href' => $messenger->name,
2173 2173
 				'title' => __('Modify this Messenger', 'event_espresso'),
2174 2174
 				'slug' => $messenger->name,
@@ -2178,23 +2178,23 @@  discard block
 block discarded – undo
2178 2178
 			$message_types_for_messenger = $messenger->get_valid_message_types();
2179 2179
 
2180 2180
 			//assemble the array for the ACTIVE and INACTIVE message types with the selected messenger //note that all message types will be in the inactive box if the messenger is NOT active.
2181
-			$selected_settings = isset( $this->_active_messengers[$messenger->name]['settings'] ) ? $this->_active_messengers[$messenger->name]['settings'] : array();
2182
-			foreach ( $message_types as $message_type ) {
2181
+			$selected_settings = isset($this->_active_messengers[$messenger->name]['settings']) ? $this->_active_messengers[$messenger->name]['settings'] : array();
2182
+			foreach ($message_types as $message_type) {
2183 2183
 				//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.
2184
-				if ( ! in_array( $message_type->name, $message_types_for_messenger ) ) {
2184
+				if ( ! in_array($message_type->name, $message_types_for_messenger)) {
2185 2185
 					continue;
2186 2186
 				}
2187 2187
 
2188
-				$a_or_i = isset( $selected_settings[$messenger->name . '-message_types'][$message_type->name] ) && $selected_settings[$messenger->name . '-message_types'][$message_type->name] ? 'active' : 'inactive';
2188
+				$a_or_i = isset($selected_settings[$messenger->name.'-message_types'][$message_type->name]) && $selected_settings[$messenger->name.'-message_types'][$message_type->name] ? 'active' : 'inactive';
2189 2189
 
2190 2190
 				$this->_m_mt_settings['message_type_tabs'][$messenger->name][$a_or_i][$message_type->name] = array(
2191 2191
 						'label' => ucwords($message_type->label['singular']),
2192
-						'class' => 'message-type-' . $a_or_i,
2193
-						'slug_id' => $message_type->name . '-messagetype-' . $messenger->name,
2194
-						'mt_nonce' => wp_create_nonce($message_type->name . '_nonce'),
2195
-						'href' => 'espresso_' . $message_type->name . '_message_type_settings',
2192
+						'class' => 'message-type-'.$a_or_i,
2193
+						'slug_id' => $message_type->name.'-messagetype-'.$messenger->name,
2194
+						'mt_nonce' => wp_create_nonce($message_type->name.'_nonce'),
2195
+						'href' => 'espresso_'.$message_type->name.'_message_type_settings',
2196 2196
 						'title' => $a_or_i == 'active' ? __('Drag this message type to the Inactive window to deactivate', 'event_espresso') : __('Drag this message type to the messenger to activate', 'event_espresso'),
2197
-						'content' => $a_or_i == 'active' ? $this->_message_type_settings_content( $message_type, $messenger, TRUE ) : $this->_message_type_settings_content( $message_type, $messenger ),
2197
+						'content' => $a_or_i == 'active' ? $this->_message_type_settings_content($message_type, $messenger, TRUE) : $this->_message_type_settings_content($message_type, $messenger),
2198 2198
 						'slug' => $message_type->name,
2199 2199
 						'active' => $a_or_i == 'active' ? TRUE : FALSE,
2200 2200
 						'obj' => $message_type
@@ -2211,34 +2211,34 @@  discard block
 block discarded – undo
2211 2211
 	 * @param  boolean $active       Whether the message type is active or not
2212 2212
 	 * @return string                html output for the content
2213 2213
 	 */
2214
-	protected function _message_type_settings_content( $message_type, $messenger, $active = FALSE ) {
2214
+	protected function _message_type_settings_content($message_type, $messenger, $active = FALSE) {
2215 2215
 		//get message type fields
2216 2216
 		$fields = $message_type->get_admin_settings_fields();
2217
-		$settings_template_args['template_form_fields']= '';
2217
+		$settings_template_args['template_form_fields'] = '';
2218 2218
 
2219
-		if ( !empty( $fields ) && $active ) {
2219
+		if ( ! empty($fields) && $active) {
2220 2220
 
2221
-			$existing_settings = $message_type->get_existing_admin_settings( $messenger->name );
2221
+			$existing_settings = $message_type->get_existing_admin_settings($messenger->name);
2222 2222
 
2223
-			foreach( $fields as $fldname => $fldprops ) {
2224
-				$field_id = $messenger->name . '-' . $message_type->name . '-' . $fldname;
2223
+			foreach ($fields as $fldname => $fldprops) {
2224
+				$field_id = $messenger->name.'-'.$message_type->name.'-'.$fldname;
2225 2225
 				$template_form_field[$field_id] = array(
2226
-					'name' => 'message_type_settings[' . $fldname . ']',
2226
+					'name' => 'message_type_settings['.$fldname.']',
2227 2227
 					'label' => $fldprops['label'],
2228 2228
 					'input' => $fldprops['field_type'],
2229 2229
 					'type' => $fldprops['value_type'],
2230 2230
 					'required' => $fldprops['required'],
2231 2231
 					'validation' => $fldprops['validation'],
2232
-					'value' => isset( $existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2233
-					'options' => isset( $fldprops['options'] ) ? $fldprops['options'] : array(),
2234
-					'default' => isset( $existing_settings[$fldname] ) ? $existing_settings[$fldname] : $fldprops['default'],
2232
+					'value' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2233
+					'options' => isset($fldprops['options']) ? $fldprops['options'] : array(),
2234
+					'default' => isset($existing_settings[$fldname]) ? $existing_settings[$fldname] : $fldprops['default'],
2235 2235
 					'css_class' => 'no-drag',
2236 2236
 					'format' => $fldprops['format']
2237 2237
 					);
2238 2238
 			}
2239 2239
 
2240 2240
 
2241
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_mt_activate_form' ) : '';
2241
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_mt_activate_form') : '';
2242 2242
 		}
2243 2243
 
2244 2244
 		$settings_template_args['description'] = $message_type->description;
@@ -2258,13 +2258,13 @@  discard block
 block discarded – undo
2258 2258
 					)
2259 2259
 				);
2260 2260
 
2261
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2262
-		$settings_template_args['show_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : '';
2261
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2262
+		$settings_template_args['show_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : '';
2263 2263
 
2264 2264
 
2265 2265
 
2266
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_mt_settings_content.template.php';
2267
-		$content = EEH_Template::display_template( $template, $settings_template_args, TRUE );
2266
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_mt_settings_content.template.php';
2267
+		$content = EEH_Template::display_template($template, $settings_template_args, TRUE);
2268 2268
 		return $content;
2269 2269
 	}
2270 2270
 
@@ -2281,21 +2281,21 @@  discard block
 block discarded – undo
2281 2281
 		$m_boxes = $mt_boxes = array();
2282 2282
 		$m_template_args = $mt_template_args = array();
2283 2283
 
2284
-		$selected_messenger = isset( $this->_req_data['selected_messenger'] ) ? $this->_req_data['selected_messenger'] : 'email';
2284
+		$selected_messenger = isset($this->_req_data['selected_messenger']) ? $this->_req_data['selected_messenger'] : 'email';
2285 2285
 
2286
-		foreach ( $this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array ) {
2286
+		foreach ($this->_m_mt_settings['messenger_tabs'] as $messenger => $tab_array) {
2287 2287
 
2288
-			$hide_on_message = isset( $this->_active_messengers[$messenger] ) ? '' : 'hidden';
2289
-			$hide_off_message = isset( $this->_active_messengers[$messenger] ) ? 'hidden' : '';
2288
+			$hide_on_message = isset($this->_active_messengers[$messenger]) ? '' : 'hidden';
2289
+			$hide_off_message = isset($this->_active_messengers[$messenger]) ? 'hidden' : '';
2290 2290
 
2291 2291
 			//messenger meta boxes
2292 2292
 			$active = $selected_messenger == $messenger ? TRUE : FALSE;
2293
-			$active_mt_tabs = isset(  $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] ) ?  $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : '';
2294
-			$m_boxes[$messenger . '_a_box'] = sprintf( __('%s Settings', 'event_espresso'), $tab_array['label'] );
2295
-			$m_template_args[$messenger . '_a_box'] = array(
2296
-					'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2297
-					'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '',
2298
-					'content' => $this->_get_messenger_box_content( $tab_array['obj'] ),
2293
+			$active_mt_tabs = isset($this->_m_mt_settings['message_type_tabs'][$messenger]['active']) ? $this->_m_mt_settings['message_type_tabs'][$messenger]['active'] : '';
2294
+			$m_boxes[$messenger.'_a_box'] = sprintf(__('%s Settings', 'event_espresso'), $tab_array['label']);
2295
+			$m_template_args[$messenger.'_a_box'] = array(
2296
+					'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2297
+					'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '',
2298
+					'content' => $this->_get_messenger_box_content($tab_array['obj']),
2299 2299
 					'hidden' => $active ? '' : ' hidden',
2300 2300
 					'hide_on_message' => $hide_on_message,
2301 2301
 					'messenger' => $messenger,
@@ -2304,10 +2304,10 @@  discard block
 block discarded – undo
2304 2304
 
2305 2305
 
2306 2306
 			//message type meta boxes (which is really just the inactive container for each messenger showing inactive message types for that messenger)
2307
-			$mt_boxes[$messenger . '_i_box'] = __('Inactive Message Types', 'event_espresso');
2308
-			$mt_template_args[$messenger . '_i_box'] = array(
2309
-				'active_message_types' => !empty( $active_mt_tabs ) ? $this->_get_mt_tabs( $active_mt_tabs ) : '',
2310
-				'inactive_message_types' => isset( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) ? $this->_get_mt_tabs( $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'] ) : '',
2307
+			$mt_boxes[$messenger.'_i_box'] = __('Inactive Message Types', 'event_espresso');
2308
+			$mt_template_args[$messenger.'_i_box'] = array(
2309
+				'active_message_types' => ! empty($active_mt_tabs) ? $this->_get_mt_tabs($active_mt_tabs) : '',
2310
+				'inactive_message_types' => isset($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) ? $this->_get_mt_tabs($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive']) : '',
2311 2311
 				'hidden' => $active ? '' : ' hidden',
2312 2312
 				'hide_on_message' => $hide_on_message,
2313 2313
 				'hide_off_message' => $hide_off_message,
@@ -2317,19 +2317,19 @@  discard block
 block discarded – undo
2317 2317
 		}
2318 2318
 
2319 2319
 		//register messenger metaboxes
2320
-		$m_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_mt_meta_box.template.php';
2321
-		foreach ( $m_boxes as $box => $label ) {
2322
-			$callback_args = array( 'template_path' => $m_template_path, 'template_args' => $m_template_args[$box] );
2323
-			$msgr = str_replace( '_a_box', '', $box );
2324
-			add_meta_box( 'espresso_' . $msgr . '_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args );
2320
+		$m_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_mt_meta_box.template.php';
2321
+		foreach ($m_boxes as $box => $label) {
2322
+			$callback_args = array('template_path' => $m_template_path, 'template_args' => $m_template_args[$box]);
2323
+			$msgr = str_replace('_a_box', '', $box);
2324
+			add_meta_box('espresso_'.$msgr.'_settings', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'normal', 'high', $callback_args);
2325 2325
 		}
2326 2326
 
2327 2327
 		//register message type metaboxes
2328
-		$mt_template_path = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_messenger_meta_box.template.php';
2329
-		foreach ( $mt_boxes as $box => $label ) {
2330
-			$callback_args = array( 'template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box] );
2331
-			$mt = str_replace( '_i_box', '', $box );
2332
-			add_meta_box( 'espresso_' . $mt . '_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args );
2328
+		$mt_template_path = EE_MSG_TEMPLATE_PATH.'ee_msg_details_messenger_meta_box.template.php';
2329
+		foreach ($mt_boxes as $box => $label) {
2330
+			$callback_args = array('template_path' => $mt_template_path, 'template_args' => $mt_template_args[$box]);
2331
+			$mt = str_replace('_i_box', '', $box);
2332
+			add_meta_box('espresso_'.$mt.'_inactive_mts', $label, create_function('$post, $metabox', 'echo EEH_Template::display_template( $metabox["args"]["template_path"], $metabox["args"]["template_args"], TRUE );'), $this->_current_screen_id, 'side', 'high', $callback_args);
2333 2333
 		}
2334 2334
 
2335 2335
 	}
@@ -2340,13 +2340,13 @@  discard block
 block discarded – undo
2340 2340
 	 * @param  array $tab_array  This is an array of message type tab details used to generate the tabs
2341 2341
 	 * @return string            html formatted tabs
2342 2342
 	 */
2343
-	protected function _get_mt_tabs( $tab_array ) {
2343
+	protected function _get_mt_tabs($tab_array) {
2344 2344
 		$tab_array = (array) $tab_array;
2345
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_details_mt_settings_tab_item.template.php';
2345
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_details_mt_settings_tab_item.template.php';
2346 2346
 		$tabs = '';
2347 2347
 
2348
-		foreach ( $tab_array as $tab ) {
2349
-			$tabs .=  EEH_Template::display_template( $template, $tab, TRUE );
2348
+		foreach ($tab_array as $tab) {
2349
+			$tabs .= EEH_Template::display_template($template, $tab, TRUE);
2350 2350
 		}
2351 2351
 
2352 2352
 		return $tabs;
@@ -2360,7 +2360,7 @@  discard block
 block discarded – undo
2360 2360
 	 * @param  object $messenger The messenger we're setting up content for
2361 2361
 	 * @return string            html formatted content
2362 2362
 	 */
2363
-	protected function _get_messenger_box_content( $messenger ) {
2363
+	protected function _get_messenger_box_content($messenger) {
2364 2364
 
2365 2365
 		$fields = $messenger->get_admin_settings_fields();
2366 2366
 		$settings_template_args['template_form_fields'] = '';
@@ -2369,27 +2369,27 @@  discard block
 block discarded – undo
2369 2369
 		$settings_template_args['active'] = isset($this->_active_messengers[$messenger->name]) ? TRUE : FALSE;
2370 2370
 
2371 2371
 
2372
-		if ( !empty( $fields ) ) {
2372
+		if ( ! empty($fields)) {
2373 2373
 
2374 2374
 			$existing_settings = $messenger->get_existing_admin_settings();
2375 2375
 
2376
-			foreach( $fields as $fldname => $fldprops ) {
2377
-				$field_id = $messenger->name . '-' . $fldname;
2376
+			foreach ($fields as $fldname => $fldprops) {
2377
+				$field_id = $messenger->name.'-'.$fldname;
2378 2378
 				$template_form_field[$field_id] = array(
2379
-					'name' => 'messenger_settings[' . $field_id . ']',
2379
+					'name' => 'messenger_settings['.$field_id.']',
2380 2380
 					'label' => $fldprops['label'],
2381 2381
 					'input' => $fldprops['field_type'],
2382 2382
 					'type' => $fldprops['value_type'],
2383 2383
 					'required' => $fldprops['required'],
2384 2384
 					'validation' => $fldprops['validation'],
2385
-					'value' => isset( $existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'],
2385
+					'value' => isset($existing_settings[$field_id]) ? $existing_settings[$field_id] : $fldprops['default'],
2386 2386
 					'css_class' => '',
2387 2387
 					'format' => $fldprops['format']
2388 2388
 					);
2389 2389
 			}
2390 2390
 
2391 2391
 
2392
-			$settings_template_args['template_form_fields'] = !empty($template_form_field) ? $this->_generate_admin_form_fields( $template_form_field, 'string', 'ee_m_activate_form' ) : '';
2392
+			$settings_template_args['template_form_fields'] = ! empty($template_form_field) ? $this->_generate_admin_form_fields($template_form_field, 'string', 'ee_m_activate_form') : '';
2393 2393
 		}
2394 2394
 
2395 2395
 		//we also need some hidden fields
@@ -2405,8 +2405,8 @@  discard block
 block discarded – undo
2405 2405
 			);
2406 2406
 
2407 2407
 		//make sure any active message types that are existing are included in the hidden fields
2408
-		if ( isset( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] ) ) {
2409
-			foreach ( $this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values ) {
2408
+		if (isset($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'])) {
2409
+			foreach ($this->_m_mt_settings['message_type_tabs'][$messenger->name]['active'] as $mt => $values) {
2410 2410
 				$settings_template_args['hidden_fields']['messenger_settings[message_types]['.$mt.']'] = array(
2411 2411
 						'type' => 'hidden',
2412 2412
 						'value' => $mt
@@ -2414,25 +2414,25 @@  discard block
 block discarded – undo
2414 2414
 			}
2415 2415
 		}
2416 2416
 
2417
-		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields( $settings_template_args['hidden_fields'], 'array' );
2417
+		$settings_template_args['hidden_fields'] = $this->_generate_admin_form_fields($settings_template_args['hidden_fields'], 'array');
2418 2418
 
2419
-		$active = isset( $this->_active_messengers[$messenger->name] ) ? TRUE : FALSE;
2419
+		$active = isset($this->_active_messengers[$messenger->name]) ? TRUE : FALSE;
2420 2420
 
2421 2421
 		$settings_template_args['messenger'] = $messenger->name;
2422 2422
 		$settings_template_args['description'] = $messenger->description;
2423 2423
 		$settings_template_args['show_hide_edit_form'] = $active ? '' : ' hidden';
2424 2424
 
2425 2425
 
2426
-		$settings_template_args['show_hide_edit_form'] = isset( $this->_active_messengers[$messenger->name] ) ? $settings_template_args['show_hide_edit_form'] : ' hidden';
2426
+		$settings_template_args['show_hide_edit_form'] = isset($this->_active_messengers[$messenger->name]) ? $settings_template_args['show_hide_edit_form'] : ' hidden';
2427 2427
 
2428
-		$settings_template_args['show_hide_edit_form'] = empty( $settings_template_args['template_form_fields'] ) ? ' hidden' : $settings_template_args['show_hide_edit_form'];
2428
+		$settings_template_args['show_hide_edit_form'] = empty($settings_template_args['template_form_fields']) ? ' hidden' : $settings_template_args['show_hide_edit_form'];
2429 2429
 
2430 2430
 
2431 2431
 		$settings_template_args['on_off_action'] = $active ? 'messenger-off' : 'messenger-on';
2432
-		$settings_template_args['nonce'] = wp_create_nonce('activate_' . $messenger->name . '_toggle_nonce');
2432
+		$settings_template_args['nonce'] = wp_create_nonce('activate_'.$messenger->name.'_toggle_nonce');
2433 2433
 		$settings_template_args['on_off_status'] = $active ? true : false;
2434
-		$template = EE_MSG_TEMPLATE_PATH . 'ee_msg_m_settings_content.template.php';
2435
-		$content = EEH_Template::display_template( $template, $settings_template_args, TRUE);
2434
+		$template = EE_MSG_TEMPLATE_PATH.'ee_msg_m_settings_content.template.php';
2435
+		$content = EEH_Template::display_template($template, $settings_template_args, TRUE);
2436 2436
 		return $content;
2437 2437
 	}
2438 2438
 
@@ -2446,39 +2446,39 @@  discard block
 block discarded – undo
2446 2446
 	public function activate_messenger_toggle() {
2447 2447
 		$success = TRUE;
2448 2448
 		//let's check that we have required data
2449
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
2450
-			EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2449
+		if ( ! isset($this->_req_data['messenger'])) {
2450
+			EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2451 2451
 			$success = FALSE;
2452 2452
 		}
2453 2453
 
2454 2454
 		//do a nonce check here since we're not arriving via a normal route
2455
-		$nonce = isset($this->_req_data[ 'activate_nonce' ]) ? sanitize_text_field( $this->_req_data[ 'activate_nonce'] ) : '';
2456
-		$nonce_ref = 'activate_' . $this->_req_data['messenger'] . '_toggle_nonce';
2455
+		$nonce = isset($this->_req_data['activate_nonce']) ? sanitize_text_field($this->_req_data['activate_nonce']) : '';
2456
+		$nonce_ref = 'activate_'.$this->_req_data['messenger'].'_toggle_nonce';
2457 2457
 
2458
-		$this->_verify_nonce( $nonce, $nonce_ref );
2458
+		$this->_verify_nonce($nonce, $nonce_ref);
2459 2459
 
2460 2460
 
2461 2461
 
2462
-		if ( !isset( $this->_req_data[ 'status' ])) {
2463
-			EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2462
+		if ( ! isset($this->_req_data['status'])) {
2463
+			EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2464 2464
 			$success = FALSE;
2465 2465
 		}
2466 2466
 
2467 2467
 		//do check to verify we have a valid status.
2468 2468
 		$status = $this->_req_data['status'];
2469 2469
 
2470
-		if ( $status != 'off' && $status != 'on' ) {
2471
-			EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ );
2470
+		if ($status != 'off' && $status != 'on') {
2471
+			EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "off" or "on"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__);
2472 2472
 			$success = FALSE;
2473 2473
 		}
2474 2474
 
2475
-		if ( $success ) {
2475
+		if ($success) {
2476 2476
 			//made it here?  Stop dawdling then!!
2477
-			if ( $status == 'off' ) {
2477
+			if ($status == 'off') {
2478 2478
 				//off = deactivate.  get it?
2479
-				$success = $this->_activate_messenger( $this->_req_data['messenger'], TRUE );
2479
+				$success = $this->_activate_messenger($this->_req_data['messenger'], TRUE);
2480 2480
 			} else {
2481
-				$success = $this->_activate_messenger( $this->_req_data['messenger'] );
2481
+				$success = $this->_activate_messenger($this->_req_data['messenger']);
2482 2482
 			}
2483 2483
 		}
2484 2484
 
@@ -2504,26 +2504,26 @@  discard block
 block discarded – undo
2504 2504
 
2505 2505
 
2506 2506
 		//let's make sure we have the necessary data
2507
-		if ( !isset( $this->_req_data[ 'message_type' ] ) ) {
2508
-			EE_Error::add_error( __('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2507
+		if ( ! isset($this->_req_data['message_type'])) {
2508
+			EE_Error::add_error(__('Message Type name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2509 2509
 			$success = FALSE;
2510 2510
 		}
2511 2511
 
2512 2512
 
2513 2513
 		//do a nonce check here since we're not arriving via a normal route
2514
-		$nonce = isset( $this->_req_data['mt_nonce'] ) ? sanitize_text_field( $this->_req_data['mt_nonce'] ) : '';
2515
-		$nonce_ref = $this->_req_data['message_type'] . '_nonce';
2514
+		$nonce = isset($this->_req_data['mt_nonce']) ? sanitize_text_field($this->_req_data['mt_nonce']) : '';
2515
+		$nonce_ref = $this->_req_data['message_type'].'_nonce';
2516 2516
 
2517
-		$this->_verify_nonce( $nonce, $nonce_ref );
2517
+		$this->_verify_nonce($nonce, $nonce_ref);
2518 2518
 
2519 2519
 
2520
-		if ( !isset( $this->_req_data[ 'messenger' ] ) ) {
2521
-			EE_Error::add_error( __('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2520
+		if ( ! isset($this->_req_data['messenger'])) {
2521
+			EE_Error::add_error(__('Messenger name needed to toggle activation. None given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2522 2522
 			$success = FALSE;
2523 2523
 		}
2524 2524
 
2525
-		if ( !isset( $this->_req_data[ 'status' ])) {
2526
-			EE_Error::add_error( __('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2525
+		if ( ! isset($this->_req_data['status'])) {
2526
+			EE_Error::add_error(__('Messenger status needed to know whether activation or deactivation is happening. No status is given', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2527 2527
 			$success = FALSE;
2528 2528
 		}
2529 2529
 
@@ -2531,16 +2531,16 @@  discard block
 block discarded – undo
2531 2531
 		//do check to verify we have a valid status.
2532 2532
 		$status = $this->_req_data['status'];
2533 2533
 
2534
-		if ( $status != 'activate' && $status != 'deactivate' ) {
2535
-			EE_Error::add_error( sprintf( __('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status'] ), __FILE__, __FUNCTION__, __LINE__ );
2534
+		if ($status != 'activate' && $status != 'deactivate') {
2535
+			EE_Error::add_error(sprintf(__('The given status (%s) is not valid. Must be "active" or "inactive"', 'event_espresso'), $this->_req_data['status']), __FILE__, __FUNCTION__, __LINE__);
2536 2536
 			$success = FALSE;
2537 2537
 		}
2538 2538
 
2539 2539
 
2540
-		if ( $success ) {
2540
+		if ($success) {
2541 2541
 			//made it here? um, what are you waiting for then?
2542 2542
 			$deactivate = $status == 'deactivate' ? TRUE : FALSE;
2543
-			$success = $this->_activate_messenger( $this->_req_data['messenger'], $deactivate, $this->_req_data['message_type'] );
2543
+			$success = $this->_activate_messenger($this->_req_data['messenger'], $deactivate, $this->_req_data['message_type']);
2544 2544
 		}
2545 2545
 
2546 2546
 		$this->_template_args['success'] = $success;
@@ -2567,28 +2567,28 @@  discard block
 block discarded – undo
2567 2567
 		$templates = TRUE;
2568 2568
 		$this->_set_m_mt_settings();
2569 2569
 
2570
-		if ( !$deactivate ) {
2570
+		if ( ! $deactivate) {
2571 2571
 
2572 2572
 
2573 2573
 			//we are activating.  we can use $this->_m_mt_settings to get all the installed messengers
2574
-			$this->_active_messengers[$messenger]['settings'] = !isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings'];
2574
+			$this->_active_messengers[$messenger]['settings'] = ! isset($this->_active_messengers[$messenger]['settings']) ? array() : $this->_active_messengers[$messenger]['settings'];
2575 2575
 			$this->_active_messengers[$messenger]['obj'] = $this->_m_mt_settings['messenger_tabs'][$messenger]['obj'];
2576 2576
 
2577 2577
 			//get has_active so we can sure its kept up to date.
2578
-			$has_activated = get_option( 'ee_has_activated_messages' );
2578
+			$has_activated = get_option('ee_has_activated_messages');
2579 2579
 
2580
-			if ( empty( $has_activated[$messenger] ) ) {
2580
+			if (empty($has_activated[$messenger])) {
2581 2581
 				$has_activated[$messenger] = array();
2582 2582
 			}
2583 2583
 
2584 2584
 			//k we need to get what default message types are to be associated with the messenger that's been activated.
2585 2585
 			$default_types = $message_type ? (array) $message_type : $this->_active_messengers[$messenger]['obj']->get_default_message_types();
2586 2586
 
2587
-			foreach ( $default_types as $type ) {
2587
+			foreach ($default_types as $type) {
2588 2588
 				$settings_fields = $this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$type]['obj']->get_admin_settings_fields();
2589
-				if ( !empty( $settings_fields ) ) {
2589
+				if ( ! empty($settings_fields)) {
2590 2590
 					//we have fields for this message type so let's get the defaults for saving.
2591
-					foreach ( $settings_fields as $field => $values ) {
2591
+					foreach ($settings_fields as $field => $values) {
2592 2592
 						$settings[$field] = $values['default'];
2593 2593
 					}
2594 2594
 					//let's set the data for reloading this message type form in ajax
@@ -2596,9 +2596,9 @@  discard block
 block discarded – undo
2596 2596
 				} else {
2597 2597
 					$settings = array();
2598 2598
 				}
2599
-				$this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$type]['settings'] =  $settings;
2599
+				$this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$type]['settings'] = $settings;
2600 2600
 
2601
-				if ( ! in_array( $type, $has_activated[$messenger] ) ) {
2601
+				if ( ! in_array($type, $has_activated[$messenger])) {
2602 2602
 					$has_activated[$messenger][] = $type;
2603 2603
 				}
2604 2604
 			}
@@ -2606,41 +2606,41 @@  discard block
 block discarded – undo
2606 2606
 			//any default settings for the messenger?
2607 2607
 			$msgr_settings = $this->_active_messengers[$messenger]['obj']->get_admin_settings_fields();
2608 2608
 
2609
-			if ( !empty( $msgr_settings ) ) {
2610
-				foreach ( $msgr_settings as $field => $value ) {
2609
+			if ( ! empty($msgr_settings)) {
2610
+				foreach ($msgr_settings as $field => $value) {
2611 2611
 					$this->_active_messengers[$messenger]['settings'][$field] = $value;
2612 2612
 				}
2613 2613
 			}
2614 2614
 
2615 2615
 			//update settings in database
2616
-			EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2617
-			update_option( 'ee_has_activated_messages', $has_activated );
2616
+			EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2617
+			update_option('ee_has_activated_messages', $has_activated);
2618 2618
 
2619 2619
 
2620 2620
 			//generate new templates (if necessary)
2621
-			$templates = $this->_generate_new_templates( $messenger, $default_types, 0, TRUE );
2621
+			$templates = $this->_generate_new_templates($messenger, $default_types, 0, TRUE);
2622 2622
 
2623 2623
 			EE_Error::overwrite_success();
2624 2624
 
2625 2625
 			//if generation failed then we need to remove the active messenger.
2626
-			if ( !$templates ) {
2626
+			if ( ! $templates) {
2627 2627
 				unset($this->_active_messengers[$messenger]);
2628
-				EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2628
+				EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2629 2629
 			} else {
2630 2630
 				//all is good let's do a success message
2631
-				if ( $message_type ) {
2632
-					EE_Error::add_success( sprintf( __('%s message type has been successfully activated with the %s messenger', 'event_espresso'),ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords( $this->_active_messengers[$messenger]['obj']->label['singular'] ) ) );
2631
+				if ($message_type) {
2632
+					EE_Error::add_success(sprintf(__('%s message type has been successfully activated with the %s messenger', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['inactive'][$message_type]['obj']->label['singular']), ucwords($this->_active_messengers[$messenger]['obj']->label['singular'])));
2633 2633
 
2634 2634
 					//if message type was invoice then let's make sure we activate the invoice payment method.
2635
-					if ( $message_type == 'invoice' ) {
2636
-						EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
2637
-						$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( 'Invoice' );
2638
-						if ( $pm instanceof EE_Payment_Method ) {
2639
-							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' ) );
2635
+					if ($message_type == 'invoice') {
2636
+						EE_Registry::instance()->load_lib('Payment_Method_Manager');
2637
+						$pm = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type('Invoice');
2638
+						if ($pm instanceof EE_Payment_Method) {
2639
+							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'));
2640 2640
 						}
2641 2641
 					}
2642 2642
 				} else {
2643
-					EE_Error::add_success( sprintf( __('%s messenger has been successfully activated', 'event_espresso'), ucwords( $this->_active_messengers[$messenger]['obj']->label['singular'] ) ) );
2643
+					EE_Error::add_success(sprintf(__('%s messenger has been successfully activated', 'event_espresso'), ucwords($this->_active_messengers[$messenger]['obj']->label['singular'])));
2644 2644
 				}
2645 2645
 			}
2646 2646
 
@@ -2656,36 +2656,36 @@  discard block
 block discarded – undo
2656 2656
 			$update_array = array(
2657 2657
 				'MTP_messenger' => $messenger);
2658 2658
 
2659
-			if ( $message_type ) {
2659
+			if ($message_type) {
2660 2660
 				$update_array['MTP_message_type'] = $message_type;
2661 2661
 			}
2662 2662
 
2663
-			$success = $MTP->update( array( 'MTP_is_active' => 0 ), array($update_array) );
2663
+			$success = $MTP->update(array('MTP_is_active' => 0), array($update_array));
2664 2664
 
2665 2665
 			$messenger_obj = $this->_active_messengers[$messenger]['obj'];
2666 2666
 
2667 2667
 			//if this is a message type deactivation then we're only unsetting the message type otherwise unset the messenger
2668
-			if ( $message_type ) {
2669
-				unset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] );
2668
+			if ($message_type) {
2669
+				unset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type]);
2670 2670
 			} else {
2671
-				unset( $this->_active_messengers[$messenger] );
2671
+				unset($this->_active_messengers[$messenger]);
2672 2672
 			}
2673 2673
 
2674
-			EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2674
+			EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2675 2675
 			EE_Error::overwrite_success();
2676
-			if ( $message_type ) {
2677
-				EE_Error::add_success( sprintf( __('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular']) ) );
2676
+			if ($message_type) {
2677
+				EE_Error::add_success(sprintf(__('%s message type has been successfully deactivated', 'event_espresso'), ucwords($this->_m_mt_settings['message_type_tabs'][$messenger]['active'][$message_type]['obj']->label['singular'])));
2678 2678
 			} else {
2679
-				EE_Error::add_success( sprintf( __('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'] ) ) );
2679
+				EE_Error::add_success(sprintf(__('%s messenger has been successfully deactivated', 'event_espresso'), ucwords($messenger_obj->label['singular'])));
2680 2680
 			}
2681 2681
 
2682 2682
 			//if messenger was html or message type was invoice then let's make sure we deactivate invoice payment method.
2683
-			if ( $messenger == 'html'  || $message_type == 'invoice') {
2684
-				EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
2685
-				$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( 'invoice' );
2686
-				if ( $count_updated > 0 ) {
2687
-					$msg = $message_type == 'invoice' ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then vist the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' ) : __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso' );
2688
-					EE_Error::add_attention( $msg );
2683
+			if ($messenger == 'html' || $message_type == 'invoice') {
2684
+				EE_Registry::instance()->load_lib('Payment_Method_Manager');
2685
+				$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method('invoice');
2686
+				if ($count_updated > 0) {
2687
+					$msg = $message_type == 'invoice' ? __('Deactivating the invoice message type also automatically deactivates the invoice payment method. In order for invoices to be generated the invoice message type must be active. If you completed this action by mistake, simply reactivate the invoice message type and then vist the payment methods admin page to reactivate the invoice payment method.', 'event_espresso') : __('Deactivating the html messenger also automatically deactivates the invoice payment method.  In order for invoices to be generated the html messenger must be be active.  If you completed this action by mistake, simply reactivate the html messenger, then visit the payment methods admin page to reactivate the invoice payment method.', 'event_espresso');
2688
+					EE_Error::add_attention($msg);
2689 2689
 				}
2690 2690
 			}
2691 2691
 
@@ -2702,8 +2702,8 @@  discard block
 block discarded – undo
2702 2702
 	 * @return string html data
2703 2703
 	 */
2704 2704
 	public function update_mt_form() {
2705
-		if ( !isset( $this->_req_data['messenger'] ) || !isset( $this->_req_data['message_type'] ) ) {
2706
-			EE_Error::add_error( __('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__ );
2705
+		if ( ! isset($this->_req_data['messenger']) || ! isset($this->_req_data['message_type'])) {
2706
+			EE_Error::add_error(__('Require message type or messenger to send an updated form'), __FILE__, __FUNCTION__, __LINE__);
2707 2707
 			$this->_return_json();
2708 2708
 		}
2709 2709
 
@@ -2712,7 +2712,7 @@  discard block
 block discarded – undo
2712 2712
 		$message_type = $message_types[$this->_req_data['message_type']]['obj'];
2713 2713
 		$messenger = $this->_active_messengers[$this->_req_data['messenger']]['obj'];
2714 2714
 
2715
-		$content = $this->_message_type_settings_content ( $message_type, $messenger, TRUE, TRUE );
2715
+		$content = $this->_message_type_settings_content($message_type, $messenger, TRUE, TRUE);
2716 2716
 		$this->_template_args['success'] = true;
2717 2717
 		$this->_template_args['content'] = $content;
2718 2718
 		$this->_return_json();
@@ -2726,36 +2726,36 @@  discard block
 block discarded – undo
2726 2726
 	 * @return json success or fail message
2727 2727
 	 */
2728 2728
 	public function save_settings() {
2729
-		if ( !isset( $this->_req_data['type'] ) ) {
2730
-			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2729
+		if ( ! isset($this->_req_data['type'])) {
2730
+			EE_Error::add_error(__('Cannot save settings because type is unknown (messenger settings or messsage type settings?)', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2731 2731
 			$this->_template_args['error'] = TRUE;
2732 2732
 			$this->_return_json();
2733 2733
 		}
2734 2734
 
2735 2735
 
2736
-		if ( $this->_req_data['type'] == 'messenger' ) {
2736
+		if ($this->_req_data['type'] == 'messenger') {
2737 2737
 			$settings = $this->_req_data['messenger_settings']; //this should be an array.
2738 2738
 			$messenger = $settings['messenger'];
2739 2739
 			//let's setup the settings data
2740
-			foreach ( $settings as $key => $value ) {
2741
-				switch ( $key ) {
2740
+			foreach ($settings as $key => $value) {
2741
+				switch ($key) {
2742 2742
 					case 'messenger' :
2743
-						unset( $settings['messenger'] );
2743
+						unset($settings['messenger']);
2744 2744
 						break;
2745 2745
 					case 'message_types' :
2746
-						if ( isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] ) ) {
2747
-							foreach ( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'] as $mt => $v ) {
2748
-								if ( isset( $settings['message_types'][$mt] ) )
2749
-									$settings[$messenger . '-message_types'][$mt]['settings'] = isset( $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] ) ? $this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$mt] : array();
2746
+						if (isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'])) {
2747
+							foreach ($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'] as $mt => $v) {
2748
+								if (isset($settings['message_types'][$mt]))
2749
+									$settings[$messenger.'-message_types'][$mt]['settings'] = isset($this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt]) ? $this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$mt] : array();
2750 2750
 							}
2751 2751
 						} else {
2752
-							foreach ( $value as $mt => $v ) {
2752
+							foreach ($value as $mt => $v) {
2753 2753
 								//let's see if this message type is already present and has settings.
2754
-								$settings[$messenger . '-message_types'][$mt]['settings'] = array();
2754
+								$settings[$messenger.'-message_types'][$mt]['settings'] = array();
2755 2755
 							}
2756 2756
 						}
2757 2757
 						//k settings are set let's get rid of the message types index
2758
-						unset( $settings['message_types'] );
2758
+						unset($settings['message_types']);
2759 2759
 						break;
2760 2760
 					default :
2761 2761
 						$settings[$key] = $value;
@@ -2765,36 +2765,36 @@  discard block
 block discarded – undo
2765 2765
 			$this->_active_messengers[$messenger]['settings'] = $settings;
2766 2766
 		}
2767 2767
 
2768
-		else if ( $this->_req_data['type'] == 'message_type' ) {
2768
+		else if ($this->_req_data['type'] == 'message_type') {
2769 2769
 			$settings = $this->_req_data['message_type_settings'];
2770 2770
 			$messenger = $settings['messenger'];
2771 2771
 			$message_type = $settings['message_type'];
2772 2772
 
2773
-			foreach ( $settings as $key => $value ) {
2774
-				switch ( $key ) {
2773
+			foreach ($settings as $key => $value) {
2774
+				switch ($key) {
2775 2775
 					case 'messenger' :
2776
-						unset( $settings['messenger'] );
2776
+						unset($settings['messenger']);
2777 2777
 						break;
2778 2778
 					case 'message_type' :
2779
-						unset( $settings['message_type'] );
2779
+						unset($settings['message_type']);
2780 2780
 						break;
2781 2781
 					default :
2782 2782
 						$settings['settings'][$key] = $value;
2783
-						unset( $settings[$key] );
2783
+						unset($settings[$key]);
2784 2784
 						break;
2785 2785
 				}
2786 2786
 			}
2787 2787
 
2788
-			$this->_active_messengers[$messenger]['settings'][$messenger . '-message_types'][$message_type] = $settings;
2788
+			$this->_active_messengers[$messenger]['settings'][$messenger.'-message_types'][$message_type] = $settings;
2789 2789
 		}
2790 2790
 
2791 2791
 		//okay we should have the data all setup.  Now we just update!
2792
-		$success = EEH_MSG_Template::update_active_messengers_in_db( $this->_active_messengers );
2792
+		$success = EEH_MSG_Template::update_active_messengers_in_db($this->_active_messengers);
2793 2793
 
2794
-		if ( $success ) {
2795
-			EE_Error::add_success( __('Settings updated', 'event_espresso') );
2794
+		if ($success) {
2795
+			EE_Error::add_success(__('Settings updated', 'event_espresso'));
2796 2796
 		} else {
2797
-			EE_Error::add_error( __('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
2797
+			EE_Error::add_error(__('Settings did not get updated', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
2798 2798
 		}
2799 2799
 
2800 2800
 		$this->_template_args['success'] = $success;
Please login to merge, or discard this patch.
admin_pages/messages/Messages_Template_List_Table.class.php 1 patch
Spacing   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -1,5 +1,5 @@  discard block
 block discarded – undo
1 1
 <?php
2
-if (!defined('EVENT_ESPRESSO_VERSION') )
2
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
3 3
 	exit('NO direct script access allowed');
4 4
 
5 5
 /**
@@ -31,8 +31,8 @@  discard block
 block discarded – undo
31 31
 
32 32
 
33 33
 	protected function _setup_data() {
34
-		$this->_data = $this->_admin_page->get_message_templates( $this->_per_page, $this->_view, FALSE);
35
-		$this->_all_data_count = $this->_admin_page->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE );
34
+		$this->_data = $this->_admin_page->get_message_templates($this->_per_page, $this->_view, FALSE);
35
+		$this->_all_data_count = $this->_admin_page->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE);
36 36
 	}
37 37
 
38 38
 
@@ -41,21 +41,21 @@  discard block
 block discarded – undo
41 41
 
42 42
 	protected function _set_properties() {
43 43
 		$this->_wp_list_args = array(
44
-			'singular' => __('Message Template Group', 'event_espresso' ),
45
-			'plural' => __('Message Template', 'event_espresso' ),
44
+			'singular' => __('Message Template Group', 'event_espresso'),
45
+			'plural' => __('Message Template', 'event_espresso'),
46 46
 			'ajax' => TRUE, //for now,
47 47
 			'screen' => $this->_admin_page->get_current_screen()->id
48 48
 			);
49 49
 		$this->_columns = array(
50 50
 			//'cb' => '<input type="checkbox" />', //no deleting default (global) templates!
51 51
 			'message_type' => __('Message Type', 'event_espresso'),
52
-			'messenger' => __( 'Messenger', 'event_espresso'),
53
-			'description' => __( 'Description', 'event_espresso' ),
52
+			'messenger' => __('Messenger', 'event_espresso'),
53
+			'description' => __('Description', 'event_espresso'),
54 54
 			//'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place.
55 55
 			);
56 56
 
57 57
 		$this->_sortable_columns = array(
58
-			'messenger' => array( 'MTP_messenger' => TRUE ),
58
+			'messenger' => array('MTP_messenger' => TRUE),
59 59
 			//'message_type' => array( 'MTP_message_type' => FALSE )
60 60
 			);
61 61
 
@@ -74,16 +74,16 @@  discard block
 block discarded – undo
74 74
 	 *
75 75
 	 * @return string
76 76
 	 */
77
-	public function single_row( $item ) {
77
+	public function single_row($item) {
78 78
 		$message_type = $item->message_type_obj();
79 79
 		$messenger = $item->messenger_obj();
80 80
 
81
-		if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger ) {
81
+		if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
82 82
 			echo '';
83 83
 			return;
84 84
 		}
85 85
 
86
-		parent::single_row( $item );
86
+		parent::single_row($item);
87 87
 	}
88 88
 
89 89
 
@@ -97,18 +97,18 @@  discard block
 block discarded – undo
97 97
 
98 98
 
99 99
 		//setup messengers for selects
100
-		$i=1;
100
+		$i = 1;
101 101
 		$m_values[0]['id'] = 'all';
102
-		$m_values[0]['text'] = __('All Messengers', 'event_espresso' );
103
-		foreach ( $messengers as $messenger => $args ) {
102
+		$m_values[0]['text'] = __('All Messengers', 'event_espresso');
103
+		foreach ($messengers as $messenger => $args) {
104 104
 			$m_values[$i]['id'] = $messenger;
105 105
 			$m_values[$i]['text'] = ucwords($args['obj']->label['singular']);
106 106
 			$i++;
107 107
 		}
108 108
 
109 109
 		//lets do the same for message types
110
-		$i=1;
111
-		foreach ( $message_types as $message_type => $args ) {
110
+		$i = 1;
111
+		foreach ($message_types as $message_type => $args) {
112 112
 			$mt_values[$i]['id'] = $message_type;
113 113
 			$mt_values[$i]['text'] = ucwords($args['obj']->label['singular']);
114 114
 			$i++;
@@ -124,28 +124,28 @@  discard block
 block discarded – undo
124 124
 			'text' => __('Show All', 'event_espresso')
125 125
 			);
126 126
 
127
-		$msgr_filters = !empty($m_values) ? array_merge( $msgr_default, $m_values ) : array();
128
-		$mt_filters = !empty($mt_values) ? array_merge( $mt_default, $mt_values ) : array();
127
+		$msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array();
128
+		$mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array();
129 129
 
130
-		if ( empty( $m_values ) )
130
+		if (empty($m_values))
131 131
 			$msgr_filters[0] = array(
132 132
 				'id' => 'no_messenger_options',
133 133
 				'text' => __('No Messengers active', 'event_espresso')
134 134
 				);
135 135
 
136
-		if ( empty($mt_values) )
136
+		if (empty($mt_values))
137 137
 			$mt_filters[0] = array(
138 138
 				'id' => 'no_message_type_options',
139 139
 				'text' => __('No Message Types active', 'event_espresso')
140 140
 				);
141 141
 
142
-		if ( count( $messengers ) >= 1  && !empty( $m_values ) ) {
143
-			unset( $msgr_filters[0] );
144
-			$msgr_filters = array_values( $msgr_filters ); //reindex keys
142
+		if (count($messengers) >= 1 && ! empty($m_values)) {
143
+			unset($msgr_filters[0]);
144
+			$msgr_filters = array_values($msgr_filters); //reindex keys
145 145
 		}
146 146
 
147
-		$filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key( $this->_req_data['ee_messenger_filter_by']) : '' );
148
-		$filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key( $this->_req_data['ee_message_type_filter_by']) : '');
147
+		$filters[] = EEH_Form_Fields::select_input('ee_messenger_filter_by', $msgr_filters, isset($this->_req_data['ee_messenger_filter_by']) ? sanitize_key($this->_req_data['ee_messenger_filter_by']) : '');
148
+		$filters[] = EEH_Form_Fields::select_input('ee_message_type_filter_by', $mt_filters, isset($this->_req_data['ee_message_type_filter_by']) ? sanitize_key($this->_req_data['ee_message_type_filter_by']) : '');
149 149
 		return $filters;
150 150
 	}
151 151
 
@@ -153,20 +153,20 @@  discard block
 block discarded – undo
153 153
 	 * we're just removing the search box for message templates, not needed.
154 154
 	 * @return string (empty);
155 155
 	 */
156
-	function search_box( $text, $input_id ) {
156
+	function search_box($text, $input_id) {
157 157
 		return '';
158 158
 	}
159 159
 
160 160
 
161 161
 	protected function _add_view_counts() {
162
-		foreach ( $this->_views as $view => $args )  {
163
-			$this->_views[$view]['count'] = $this->_admin_page->get_message_templates( $this->_per_page, $view, TRUE, TRUE );
162
+		foreach ($this->_views as $view => $args) {
163
+			$this->_views[$view]['count'] = $this->_admin_page->get_message_templates($this->_per_page, $view, TRUE, TRUE);
164 164
 		}
165 165
 	}
166 166
 
167 167
 
168 168
 
169
-	public function column_cb( $item ) {
169
+	public function column_cb($item) {
170 170
 		return '';
171 171
 	}
172 172
 
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 
175 175
 
176 176
 
177
-	function column_description( $item ) {
178
-		return '<p>' . $item->message_type_obj()->description . '</p>';
177
+	function column_description($item) {
178
+		return '<p>'.$item->message_type_obj()->description.'</p>';
179 179
 	}
180 180
 
181 181
 
@@ -190,27 +190,27 @@  discard block
 block discarded – undo
190 190
 		$actions = array();
191 191
 
192 192
 		// edit link but only if item isn't trashed.
193
-		if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) {
194
-			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL );
195
-			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>';
193
+		if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) {
194
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL);
195
+			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>';
196 196
 		}
197 197
 
198
-		$name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template Group', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] );
198
+		$name_link = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template Group', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']);
199 199
 
200 200
 		//we want to display the contexts in here so we need to set them up
201 201
 		$c_label = $item->context_label();
202 202
 		$c_configs = $item->contexts_config();
203 203
 		$ctxt = array();
204 204
 		$context_templates = $item->context_templates();
205
-		foreach ( $context_templates as $context => $template_fields ) {
206
-			$mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL;
207
-			$inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : '';
205
+		foreach ($context_templates as $context => $template_fields) {
206
+			$mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL;
207
+			$inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : '';
208 208
 			$context_title = ucwords($c_configs[$context]['label']);
209
-			$edit_link = EE_Admin_Page::add_query_args_and_nonce( array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL );
210
-			$ctxt[] = EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? '<a' . $inactive . ' href="'. $edit_link . '" title="' . esc_attr__('Edit Context', 'event_espresso') . '">' . $context_title . '</a>' : $context_title;
209
+			$edit_link = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID(), 'context' => $context), EE_MSG_ADMIN_URL);
210
+			$ctxt[] = EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? '<a'.$inactive.' href="'.$edit_link.'" title="'.esc_attr__('Edit Context', 'event_espresso').'">'.$context_title.'</a>' : $context_title;
211 211
 		}
212 212
 
213
-		$ctx_content = !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ? sprintf( __('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural']) ) . implode(' | ', $ctxt) : '';
213
+		$ctx_content = ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID()) ? sprintf(__('<strong>%s:</strong> ', 'event_espresso'), ucwords($c_label['plural'])).implode(' | ', $ctxt) : '';
214 214
 
215 215
 
216 216
 		//Return the name contents
@@ -218,7 +218,7 @@  discard block
 block discarded – undo
218 218
 										/* $1%s */ $name_link,
219 219
 										/* $2%s */ $item->GRP_ID(),
220 220
 										/* %4$s */ $ctx_content,
221
-										/* $3%s */ $this->row_actions( $actions )
221
+										/* $3%s */ $this->row_actions($actions)
222 222
 		);
223 223
 	}
224 224
 
@@ -228,7 +228,7 @@  discard block
 block discarded – undo
228 228
 	 * @return string       message_type name
229 229
 	 */
230 230
 	function column_message_type($item) {
231
-		return ucwords($item->message_type_obj()->label['singular'] );
231
+		return ucwords($item->message_type_obj()->label['singular']);
232 232
 	}
233 233
 
234 234
 
Please login to merge, or discard this patch.
admin_pages/payments/Payments_Admin_Page.core.php 1 patch
Spacing   +166 added lines, -166 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
 /**
@@ -44,8 +44,8 @@  discard block
 block discarded – undo
44 44
 	 * @param bool $routing indicate whether we want to just load the object and handle routing or just load the object.
45 45
 	 * @return \Payments_Admin_Page
46 46
 	 */
47
-	public function __construct( $routing = TRUE ) {
48
-		parent::__construct( $routing );
47
+	public function __construct($routing = TRUE) {
48
+		parent::__construct($routing);
49 49
 	}
50 50
 
51 51
 
@@ -130,19 +130,19 @@  discard block
 block discarded – undo
130 130
 	protected function _set_page_config() {
131 131
 		$payment_method_list_config = array(
132 132
 			'nav'           => array(
133
-				'label' => __( 'Payment Methods', 'event_espresso' ),
133
+				'label' => __('Payment Methods', 'event_espresso'),
134 134
 				'order' => 10
135 135
 			),
136 136
 			'metaboxes'     => $this->_default_espresso_metaboxes,
137 137
 			'help_tabs'     => array_merge(
138 138
 				array(
139 139
 					'payment_methods_overview_help_tab' => array(
140
-						'title'    => __( 'Payment Methods Overview', 'event_espresso' ),
140
+						'title'    => __('Payment Methods Overview', 'event_espresso'),
141 141
 						'filename' => 'payment_methods_overview'
142 142
 					)
143 143
 				),
144 144
 				$this->_add_payment_method_help_tabs() ),
145
-			'help_tour'     => array( 'Payment_Methods_Selection_Help_Tour' ),
145
+			'help_tour'     => array('Payment_Methods_Selection_Help_Tour'),
146 146
 			'require_nonce' => false
147 147
 		);
148 148
 
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 					)
161 161
 				),
162 162
 				//'help_tour' => array( 'Payment_Methods_Settings_Help_Tour' ),
163
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
163
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
164 164
 				'require_nonce' => FALSE
165 165
 			),
166 166
 			'payment_log'=>array(
@@ -179,17 +179,17 @@  discard block
 block discarded – undo
179 179
 	/**
180 180
 	 * @return array
181 181
 	 */
182
-	protected function _add_payment_method_help_tabs(){
182
+	protected function _add_payment_method_help_tabs() {
183 183
 		EE_Registry::instance()->load_lib('Payment_Method_Manager');
184 184
 		$payment_method_types = EE_Payment_Method_Manager::instance()->payment_method_types();
185 185
 		$all_pmt_help_tabs_config = array();
186
-		foreach( $payment_method_types as $payment_method_type ){
187
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $payment_method_type->cap_name(), 'specific_payment_method_type_access' ) ) {
186
+		foreach ($payment_method_types as $payment_method_type) {
187
+			if ( ! EE_Registry::instance()->CAP->current_user_can($payment_method_type->cap_name(), 'specific_payment_method_type_access')) {
188 188
 				continue;
189 189
 			}
190
-			foreach( $payment_method_type->help_tabs_config() as $help_tab_name => $config ){
191
-				$template_args = isset( $config[ 'template_args' ] ) ? $config[ 'template_args' ] : array();
192
-				$template_args[ 'admin_page_obj' ] = $this;
190
+			foreach ($payment_method_type->help_tabs_config() as $help_tab_name => $config) {
191
+				$template_args = isset($config['template_args']) ? $config['template_args'] : array();
192
+				$template_args['admin_page_obj'] = $this;
193 193
 				$all_pmt_help_tabs_config[$help_tab_name] = array(
194 194
 					'title'=>$config['title'],
195 195
 					'content'=>EEH_Template::display_template( 
@@ -216,9 +216,9 @@  discard block
 block discarded – undo
216 216
 
217 217
 
218 218
 	public function load_scripts_styles() {
219
-		wp_enqueue_script( 'ee_admin_js' );
220
-		wp_enqueue_script( 'ee-text-links' );
221
-		wp_enqueue_script( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'espresso_payments_admin.js', array( 'espresso-ui-theme', 'ee-datepicker' ), EVENT_ESPRESSO_VERSION, TRUE );
219
+		wp_enqueue_script('ee_admin_js');
220
+		wp_enqueue_script('ee-text-links');
221
+		wp_enqueue_script('espresso_payments', EE_PAYMENTS_ASSETS_URL.'espresso_payments_admin.js', array('espresso-ui-theme', 'ee-datepicker'), EVENT_ESPRESSO_VERSION, TRUE);
222 222
 	}
223 223
 
224 224
 
@@ -227,9 +227,9 @@  discard block
 block discarded – undo
227 227
 
228 228
 	public function load_scripts_styles_default() {
229 229
 		//styles
230
-		wp_register_style( 'espresso_payments', EE_PAYMENTS_ASSETS_URL . 'ee-payments.css', array(), EVENT_ESPRESSO_VERSION );
231
-		wp_enqueue_style( 'espresso_payments' );
232
-		wp_enqueue_style( 'ee-text-links' );
230
+		wp_register_style('espresso_payments', EE_PAYMENTS_ASSETS_URL.'ee-payments.css', array(), EVENT_ESPRESSO_VERSION);
231
+		wp_enqueue_style('espresso_payments');
232
+		wp_enqueue_style('ee-text-links');
233 233
 		//scripts
234 234
 	}
235 235
 
@@ -243,44 +243,44 @@  discard block
 block discarded – undo
243 243
 		 * to the loading process.  However, people MUST setup the details for the payment method so its safe to do a
244 244
 		 * recheck here.
245 245
 		 */
246
-		EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
246
+		EE_Registry::instance()->load_lib('Payment_Method_Manager');
247 247
 		EEM_Payment_Method::instance()->verify_button_urls();
248 248
 		//setup tabs, one for each payment method type
249 249
 		$tabs = array();
250 250
 		$payment_methods = array();
251
-		foreach( EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj ) {
251
+		foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
252 252
 			// we don't want to show admin-only PMTs for now
253
-			if ( $pmt_obj instanceof EE_PMT_Admin_Only ) {
253
+			if ($pmt_obj instanceof EE_PMT_Admin_Only) {
254 254
 				continue;
255 255
 			}
256 256
 			//check access
257
-			if ( ! EE_Registry::instance()->CAP->current_user_can( $pmt_obj->cap_name(), 'specific_payment_method_type_access' ) ) {
257
+			if ( ! EE_Registry::instance()->CAP->current_user_can($pmt_obj->cap_name(), 'specific_payment_method_type_access')) {
258 258
 				continue;
259 259
 			}
260 260
 			//check for any active pms of that type
261
-			$payment_method = EEM_Payment_Method::instance()->get_one_of_type( $pmt_obj->system_name() );
262
-			if ( ! $payment_method instanceof EE_Payment_Method ) {
261
+			$payment_method = EEM_Payment_Method::instance()->get_one_of_type($pmt_obj->system_name());
262
+			if ( ! $payment_method instanceof EE_Payment_Method) {
263 263
 				$payment_method = EE_Payment_Method::new_instance(
264 264
 					array(
265
-						'PMD_slug'					=>sanitize_key( $pmt_obj->system_name() ),
265
+						'PMD_slug'					=>sanitize_key($pmt_obj->system_name()),
266 266
 						'PMD_type'					=>$pmt_obj->system_name(),
267 267
 						'PMD_name'				=>$pmt_obj->pretty_name(),
268 268
 						'PMD_admin_name'	=>$pmt_obj->pretty_name()
269 269
 					)
270 270
 				);
271 271
 			}
272
-			$payment_methods[ $payment_method->slug() ] = $payment_method;
272
+			$payment_methods[$payment_method->slug()] = $payment_method;
273 273
 		}
274
-		$payment_methods = apply_filters( 'FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods );
275
-		foreach( $payment_methods as $payment_method ) {
276
-			if ( $payment_method instanceof EE_Payment_Method ) {
274
+		$payment_methods = apply_filters('FHEE__Payments_Admin_Page___payment_methods_list__payment_methods', $payment_methods);
275
+		foreach ($payment_methods as $payment_method) {
276
+			if ($payment_method instanceof EE_Payment_Method) {
277 277
 				add_meta_box(
278 278
 					//html id
279
-					'espresso_' . $payment_method->slug() . '_payment_settings',
279
+					'espresso_'.$payment_method->slug().'_payment_settings',
280 280
 					//title
281
-					sprintf( __( '%s Settings', 'event_espresso' ), $payment_method->admin_name() ),
281
+					sprintf(__('%s Settings', 'event_espresso'), $payment_method->admin_name()),
282 282
 					//callback
283
-					array( $this, 'payment_method_settings_meta_box' ),
283
+					array($this, 'payment_method_settings_meta_box'),
284 284
 					//post type
285 285
 					null,
286 286
 					//context
@@ -288,19 +288,19 @@  discard block
 block discarded – undo
288 288
 					//priority
289 289
 					'default',
290 290
 					//callback args
291
-					array( 'payment_method' => $payment_method )
291
+					array('payment_method' => $payment_method)
292 292
 				);
293 293
 				//setup for tabbed content
294
-				$tabs[ $payment_method->slug() ] = array(
294
+				$tabs[$payment_method->slug()] = array(
295 295
 					'label' => $payment_method->admin_name(),
296 296
 					'class' => $payment_method->active() ? 'gateway-active' : '',
297
-					'href'  => 'espresso_' . $payment_method->slug() . '_payment_settings',
298
-					'title' => __( 'Modify this Payment Method', 'event_espresso' ),
297
+					'href'  => 'espresso_'.$payment_method->slug().'_payment_settings',
298
+					'title' => __('Modify this Payment Method', 'event_espresso'),
299 299
 					'slug'  => $payment_method->slug()
300 300
 				);
301 301
 			}
302 302
 		}
303
-		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links( $tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug() );
303
+		$this->_template_args['admin_page_header'] = EEH_Tabbed_Content::tab_text_links($tabs, 'payment_method_links', '|', $this->_get_active_payment_method_slug());
304 304
 		$this->display_admin_page_with_sidebar();
305 305
 
306 306
 	}
@@ -311,20 +311,20 @@  discard block
 block discarded – undo
311 311
 	 *   _get_active_payment_method_slug
312 312
 	 * 	@return string
313 313
 	 */
314
-	protected function _get_active_payment_method_slug(){
314
+	protected function _get_active_payment_method_slug() {
315 315
 		$payment_method_slug = FALSE;
316 316
 		//decide which payment method tab to open first, as dictated by the request's 'payment_method'
317
-		if ( isset( $this->_req_data['payment_method'] )) {
317
+		if (isset($this->_req_data['payment_method'])) {
318 318
 			// if they provided the current payment method, use it
319
-			$payment_method_slug = sanitize_key( $this->_req_data['payment_method'] );
319
+			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
320 320
 		}
321
-		$payment_method = EEM_Payment_Method::instance()->get_one( array( array( 'PMD_slug' => $payment_method_slug )));
321
+		$payment_method = EEM_Payment_Method::instance()->get_one(array(array('PMD_slug' => $payment_method_slug)));
322 322
 		// if that didn't work or wasn't provided, find another way to select the current pm
323
-		if ( ! $this->_verify_payment_method( $payment_method )) {
323
+		if ( ! $this->_verify_payment_method($payment_method)) {
324 324
 			// like, looking for an active one
325
-			$payment_method = EEM_Payment_Method::instance()->get_one_active( 'CART' );
325
+			$payment_method = EEM_Payment_Method::instance()->get_one_active('CART');
326 326
 			// test that one as well
327
-			if ( $this->_verify_payment_method( $payment_method )) {
327
+			if ($this->_verify_payment_method($payment_method)) {
328 328
 				$payment_method_slug = $payment_method->slug();
329 329
 			} else {
330 330
 				$payment_method_slug = 'paypal_standard';
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 	 * @param \EE_Payment_Method $payment_method
343 343
 	 * @return boolean
344 344
 	 */
345
-	protected function _verify_payment_method( $payment_method ){
345
+	protected function _verify_payment_method($payment_method) {
346 346
 		if (
347 347
 			$payment_method instanceof EE_Payment_Method &&
348 348
 			$payment_method->type_obj() instanceof EE_PMT_Base &&
349
-			EE_Registry::instance()->CAP->current_user_can( $payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access' )
349
+			EE_Registry::instance()->CAP->current_user_can($payment_method->type_obj()->cap_name(), 'specific_payment_method_type_access')
350 350
 		) {
351 351
 			return TRUE;
352 352
 		}
@@ -363,21 +363,21 @@  discard block
 block discarded – undo
363 363
 	 * @return string
364 364
 	 * @throws EE_Error
365 365
 	 */
366
-	public function payment_method_settings_meta_box( $post_obj_which_is_null, $metabox ){
367
-		$payment_method = isset( $metabox['args'], $metabox['args']['payment_method'] ) ? $metabox['args']['payment_method'] : NULL;
368
-		if ( ! $payment_method instanceof EE_Payment_Method ){
369
-			throw new EE_Error( sprintf( __( 'Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso' )));
366
+	public function payment_method_settings_meta_box($post_obj_which_is_null, $metabox) {
367
+		$payment_method = isset($metabox['args'], $metabox['args']['payment_method']) ? $metabox['args']['payment_method'] : NULL;
368
+		if ( ! $payment_method instanceof EE_Payment_Method) {
369
+			throw new EE_Error(sprintf(__('Payment method metabox setup incorrectly. No Payment method object was supplied', 'event_espresso')));
370 370
 		}
371 371
 		$payment_method_scopes = $payment_method->active();
372 372
 		// if the payment method really exists show its form, otherwise the activation template
373
-		if ( $payment_method->ID() && ! empty( $payment_method_scopes )) {
374
-				$form = $this->_generate_payment_method_settings_form( $payment_method );
375
-				if ( $form->form_data_present_in( $this->_req_data )) {
376
-					$form->receive_form_submission( $this->_req_data );
373
+		if ($payment_method->ID() && ! empty($payment_method_scopes)) {
374
+				$form = $this->_generate_payment_method_settings_form($payment_method);
375
+				if ($form->form_data_present_in($this->_req_data)) {
376
+					$form->receive_form_submission($this->_req_data);
377 377
 				}
378
-				echo $form->form_open() . $form->get_html_and_js() . $form->form_close();
378
+				echo $form->form_open().$form->get_html_and_js().$form->form_close();
379 379
 		} else {
380
-			echo $this->_activate_payment_method_button( $payment_method )->get_html_and_js();
380
+			echo $this->_activate_payment_method_button($payment_method)->get_html_and_js();
381 381
 		}
382 382
 	}
383 383
 
@@ -390,14 +390,14 @@  discard block
 block discarded – undo
390 390
 	 * @param \EE_Payment_Method $payment_method
391 391
 	 * @return \EE_Form_Section_Proper
392 392
 	 */
393
-	protected function _generate_payment_method_settings_form( EE_Payment_Method $payment_method ) {
394
-		if ( ! $payment_method instanceof EE_Payment_Method ){
393
+	protected function _generate_payment_method_settings_form(EE_Payment_Method $payment_method) {
394
+		if ( ! $payment_method instanceof EE_Payment_Method) {
395 395
 			return new EE_Form_Section_Proper();
396 396
 		}
397 397
 		return new EE_Form_Section_Proper(
398 398
 			array(
399
-				'name' 	=> $payment_method->slug() . '_settings_form',
400
-				'html_id' 	=> $payment_method->slug() . '_settings_form',
399
+				'name' 	=> $payment_method->slug().'_settings_form',
400
+				'html_id' 	=> $payment_method->slug().'_settings_form',
401 401
 				'action' 	=> EE_Admin_Page::add_query_args_and_nonce(
402 402
 					array(
403 403
 						'action' 						=> 'update_payment_method',
@@ -409,12 +409,12 @@  discard block
 block discarded – undo
409 409
 				'subsections' 			=> apply_filters(
410 410
 					'FHEE__Payments_Admin_Page___generate_payment_method_settings_form__form_subsections',
411 411
 					array(
412
-						'pci_dss_compliance_' . $payment_method->slug() 				=> $this->_pci_dss_compliance( $payment_method ),
413
-						'currency_support_' . $payment_method->slug()					=> $this->_currency_support( $payment_method ),
414
-						'payment_method_settings_' . $payment_method->slug() 	=> $this->_payment_method_settings( $payment_method ),
415
-						'update_' . $payment_method->slug()										=> $this->_update_payment_method_button( $payment_method ),
416
-						'deactivate_' . $payment_method->slug()								=> $this->_deactivate_payment_method_button( $payment_method ),
417
-						'fine_print_' . $payment_method->slug()									=> $this->_fine_print()
412
+						'pci_dss_compliance_'.$payment_method->slug() 				=> $this->_pci_dss_compliance($payment_method),
413
+						'currency_support_'.$payment_method->slug()					=> $this->_currency_support($payment_method),
414
+						'payment_method_settings_'.$payment_method->slug() 	=> $this->_payment_method_settings($payment_method),
415
+						'update_'.$payment_method->slug()										=> $this->_update_payment_method_button($payment_method),
416
+						'deactivate_'.$payment_method->slug()								=> $this->_deactivate_payment_method_button($payment_method),
417
+						'fine_print_'.$payment_method->slug()									=> $this->_fine_print()
418 418
 					),
419 419
 					$payment_method
420 420
 				)
@@ -431,19 +431,19 @@  discard block
 block discarded – undo
431 431
 	 * @param \EE_Payment_Method $payment_method
432 432
 	 * @return \EE_Form_Section_Proper
433 433
 	 */
434
-	protected function _pci_dss_compliance( EE_Payment_Method $payment_method ) {
435
-		if ( $payment_method->type_obj()->requires_https() ) {
434
+	protected function _pci_dss_compliance(EE_Payment_Method $payment_method) {
435
+		if ($payment_method->type_obj()->requires_https()) {
436 436
 			return new EE_Form_Section_HTML(
437 437
 				EEH_HTML::tr(
438 438
 					EEH_HTML::th(
439 439
 						EEH_HTML::label(
440
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
440
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
441 441
 						)
442
-					) .
442
+					).
443 443
 					EEH_HTML::td(
444
-						EEH_HTML::strong( __( 'You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso' )) .
445
-						EEH_HTML::br() .
446
-						__( 'Learn more about ', 'event_espresso' ) . EEH_HTML::link( 'https://www.pcisecuritystandards.org/merchants/index.php', __( 'PCI DSS compliance', 'event_espresso' ))
444
+						EEH_HTML::strong(__('You are responsible for your own website security and Payment Card Industry Data Security Standards (PCI DSS) compliance.', 'event_espresso')).
445
+						EEH_HTML::br().
446
+						__('Learn more about ', 'event_espresso').EEH_HTML::link('https://www.pcisecuritystandards.org/merchants/index.php', __('PCI DSS compliance', 'event_espresso'))
447 447
 					)
448 448
 				)
449 449
 			);
@@ -461,19 +461,19 @@  discard block
 block discarded – undo
461 461
 	 * @param \EE_Payment_Method $payment_method
462 462
 	 * @return \EE_Form_Section_Proper
463 463
 	 */
464
-	protected function _currency_support( EE_Payment_Method $payment_method ) {
465
-		if ( ! $payment_method->usable_for_currency( EE_Config::instance()->currency->code )) {
464
+	protected function _currency_support(EE_Payment_Method $payment_method) {
465
+		if ( ! $payment_method->usable_for_currency(EE_Config::instance()->currency->code)) {
466 466
 			return new EE_Form_Section_HTML(
467 467
 				EEH_HTML::tr(
468 468
 					EEH_HTML::th(
469 469
 						EEH_HTML::label(
470
-							EEH_HTML::strong( __( 'IMPORTANT', 'event_espresso' ), '', 'important-notice' )
470
+							EEH_HTML::strong(__('IMPORTANT', 'event_espresso'), '', 'important-notice')
471 471
 						)
472
-					) .
472
+					).
473 473
 					EEH_HTML::td(
474 474
 						EEH_HTML::strong(
475 475
 							sprintf(
476
-								__( 'This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
476
+								__('This payment method does not support the currency set on your site (%1$s) and so will not appear as a payment option to registrants. Please activate a different payment method or change your site\'s country and associated currency.', 'event_espresso'),
477 477
 								EE_Config::instance()->currency->code
478 478
 							)
479 479
 						)
@@ -493,9 +493,9 @@  discard block
 block discarded – undo
493 493
 	 * @param \EE_Payment_Method $payment_method
494 494
 	 * @return \EE_Form_Section_HTML
495 495
 	 */
496
-	protected function _payment_method_settings( EE_Payment_Method $payment_method ) {
496
+	protected function _payment_method_settings(EE_Payment_Method $payment_method) {
497 497
 		//modify the form so we only have/show fields that will be implemented for this version
498
-		return $this->_simplify_form( $payment_method->type_obj()->settings_form(), $payment_method->name() );
498
+		return $this->_simplify_form($payment_method->type_obj()->settings_form(), $payment_method->name());
499 499
 	}
500 500
 
501 501
 
@@ -508,8 +508,8 @@  discard block
 block discarded – undo
508 508
 	 * @return \EE_Payment_Method_Form
509 509
 	 * @throws \EE_Error
510 510
 	 */
511
-	protected function _simplify_form( $form_section, $payment_method_name = '' ){
512
-		if ( $form_section instanceof EE_Payment_Method_Form ) {
511
+	protected function _simplify_form($form_section, $payment_method_name = '') {
512
+		if ($form_section instanceof EE_Payment_Method_Form) {
513 513
 			$form_section->exclude(
514 514
 				array(
515 515
 					'PMD_type', //dont want them changing the type
@@ -520,7 +520,7 @@  discard block
 block discarded – undo
520 520
 			);
521 521
 			return $form_section;
522 522
 		} else {
523
-			throw new EE_Error( sprintf( __( 'The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso' ), $payment_method_name ));
523
+			throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name));
524 524
 		}
525 525
 	}
526 526
 
@@ -533,18 +533,18 @@  discard block
 block discarded – undo
533 533
 	 * @param \EE_Payment_Method $payment_method
534 534
 	 * @return \EE_Form_Section_HTML
535 535
 	 */
536
-	protected function _update_payment_method_button( EE_Payment_Method $payment_method ) {
536
+	protected function _update_payment_method_button(EE_Payment_Method $payment_method) {
537 537
 		$update_button = new EE_Submit_Input(
538 538
 			array(
539
-				'html_id' 		=> 'save_' . $payment_method->slug() . '_settings',
540
-				'default' 		=> sprintf( __( 'Update %s Payment Settings', 'event_espresso' ), $payment_method->admin_name() ),
539
+				'html_id' 		=> 'save_'.$payment_method->slug().'_settings',
540
+				'default' 		=> sprintf(__('Update %s Payment Settings', 'event_espresso'), $payment_method->admin_name()),
541 541
 				'html_label' => EEH_HTML::nbsp()
542 542
 			)
543 543
 		);
544 544
 		return new EE_Form_Section_HTML(
545
-			EEH_HTML::no_row( EEH_HTML::br(2) ) .
545
+			EEH_HTML::no_row(EEH_HTML::br(2)).
546 546
 			EEH_HTML::tr(
547
-				EEH_HTML::th( __( 'Update Settings', 'event_espresso') ) .
547
+				EEH_HTML::th(__('Update Settings', 'event_espresso')).
548 548
 				EEH_HTML::td(
549 549
 					$update_button->get_html_for_input()
550 550
 				)
@@ -561,11 +561,11 @@  discard block
 block discarded – undo
561 561
 	 * @param \EE_Payment_Method $payment_method
562 562
 	 * @return \EE_Form_Section_Proper
563 563
 	 */
564
-	protected function _deactivate_payment_method_button( EE_Payment_Method $payment_method ) {
565
-		$link_text_and_title = sprintf( __( 'Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name() );
564
+	protected function _deactivate_payment_method_button(EE_Payment_Method $payment_method) {
565
+		$link_text_and_title = sprintf(__('Deactivate %1$s Payments?', 'event_espresso'), $payment_method->admin_name());
566 566
 		return new EE_Form_Section_HTML(
567 567
 			EEH_HTML::tr(
568
-				EEH_HTML::th( __( 'Deactivate Payment Method', 'event_espresso') ) .
568
+				EEH_HTML::th(__('Deactivate Payment Method', 'event_espresso')).
569 569
 				EEH_HTML::td(
570 570
 					EEH_HTML::link(
571 571
 						EE_Admin_Page::add_query_args_and_nonce(
@@ -577,7 +577,7 @@  discard block
 block discarded – undo
577 577
 						),
578 578
 						$link_text_and_title,
579 579
 						$link_text_and_title,
580
-						'deactivate_' . $payment_method->slug(),
580
+						'deactivate_'.$payment_method->slug(),
581 581
 						'espresso-button button-secondary'
582 582
 					)
583 583
 				)
@@ -593,12 +593,12 @@  discard block
 block discarded – undo
593 593
 	 * @param \EE_Payment_Method $payment_method
594 594
 	 * @return \EE_Form_Section_Proper
595 595
 	 */
596
-	protected function _activate_payment_method_button( EE_Payment_Method $payment_method ) {
597
-		$link_text_and_title = sprintf( __( 'Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name() );
596
+	protected function _activate_payment_method_button(EE_Payment_Method $payment_method) {
597
+		$link_text_and_title = sprintf(__('Activate %1$s Payment Method?', 'event_espresso'), $payment_method->admin_name());
598 598
 		return new EE_Form_Section_Proper(
599 599
 			array(
600
-				'name' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
601
-				'html_id' 	=> 'activate_' . $payment_method->slug() . '_settings_form',
600
+				'name' 	=> 'activate_'.$payment_method->slug().'_settings_form',
601
+				'html_id' 	=> 'activate_'.$payment_method->slug().'_settings_form',
602 602
 				'action' 	=> '#',
603 603
 				'layout_strategy'		=> new EE_Admin_Two_Column_Layout(),
604 604
 				'subsections' 			=> apply_filters(
@@ -607,8 +607,8 @@  discard block
 block discarded – undo
607 607
 						new EE_Form_Section_HTML(
608 608
 							EEH_HTML::tr(
609 609
 								EEH_HTML::th(
610
-									EEH_HTML::label( __( 'Click to Activate ', 'event_espresso' ))
611
-								) .
610
+									EEH_HTML::label(__('Click to Activate ', 'event_espresso'))
611
+								).
612 612
 								EEH_HTML::td(
613 613
 									EEH_HTML::link(
614 614
 										EE_Admin_Page::add_query_args_and_nonce(
@@ -620,7 +620,7 @@  discard block
 block discarded – undo
620 620
 										),
621 621
 										$link_text_and_title,
622 622
 										$link_text_and_title,
623
-										'activate_' . $payment_method->slug(),
623
+										'activate_'.$payment_method->slug(),
624 624
 										'espresso-button-green button-primary'
625 625
 									)
626 626
 								)
@@ -642,9 +642,9 @@  discard block
 block discarded – undo
642 642
 	protected function _fine_print() {
643 643
 		return new EE_Form_Section_HTML(
644 644
 			EEH_HTML::tr(
645
-				EEH_HTML::th() .
645
+				EEH_HTML::th().
646 646
 				EEH_HTML::td(
647
-					EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' )
647
+					EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text')
648 648
 				)
649 649
 			)
650 650
 		);
@@ -656,15 +656,15 @@  discard block
 block discarded – undo
656 656
 	 * Activates a payment method of that type. Mostly assuming there is only 1 of that type (or none so far)
657 657
 	 * @global WP_User $current_user
658 658
 	 */
659
-	protected function _activate_payment_method(){
660
-		if(isset($this->_req_data['payment_method_type'])){
659
+	protected function _activate_payment_method() {
660
+		if (isset($this->_req_data['payment_method_type'])) {
661 661
 			$payment_method_type = sanitize_text_field($this->_req_data['payment_method_type']);
662 662
 			//see if one exists
663
-			EE_Registry::instance()->load_lib( 'Payment_Method_Manager' );
664
-			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type( $payment_method_type );
663
+			EE_Registry::instance()->load_lib('Payment_Method_Manager');
664
+			$payment_method = EE_Payment_Method_Manager::instance()->activate_a_payment_method_of_type($payment_method_type);
665 665
 
666
-			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default','payment_method'=>$payment_method->slug()));
667
-		}else{
666
+			$this->_redirect_after_action(1, 'Payment Method', 'activated', array('action' => 'default', 'payment_method'=>$payment_method->slug()));
667
+		} else {
668 668
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
669 669
 		}
670 670
 	}
@@ -672,14 +672,14 @@  discard block
 block discarded – undo
672 672
 	/**
673 673
 	 * Deactivates the payment method with the specified slug, and redirects.
674 674
 	 */
675
-	protected function _deactivate_payment_method(){
676
-		if(isset($this->_req_data['payment_method'])){
675
+	protected function _deactivate_payment_method() {
676
+		if (isset($this->_req_data['payment_method'])) {
677 677
 			$payment_method_slug = sanitize_key($this->_req_data['payment_method']);
678 678
 			//deactivate it
679 679
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
680
-			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method( $payment_method_slug );
681
-			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default','payment_method'=>$payment_method_slug));
682
-		}else{
680
+			$count_updated = EE_Payment_Method_Manager::instance()->deactivate_payment_method($payment_method_slug);
681
+			$this->_redirect_after_action($count_updated, 'Payment Method', 'deactivated', array('action' => 'default', 'payment_method'=>$payment_method_slug));
682
+		} else {
683 683
 			$this->_redirect_after_action(FALSE, 'Payment Method', 'deactivated', array('action' => 'default'));
684 684
 		}
685 685
 	}
@@ -693,39 +693,39 @@  discard block
 block discarded – undo
693 693
 	 * subsequently called 'headers_sent_func' which is _payment_methods_list)
694 694
 	 * @return void
695 695
 	 */
696
-	protected function _update_payment_method(){
697
-		if( $_SERVER['REQUEST_METHOD'] == 'POST'){
696
+	protected function _update_payment_method() {
697
+		if ($_SERVER['REQUEST_METHOD'] == 'POST') {
698 698
 			//ok let's find which gateway form to use based on the form input
699 699
 			EE_Registry::instance()->load_lib('Payment_Method_Manager');
700 700
 			/** @var $correct_pmt_form_to_use EE_Payment_Method_Form */
701 701
 			$correct_pmt_form_to_use = NULL;
702 702
 			$pmt_obj = NULL;
703
-			foreach(EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj){
703
+			foreach (EE_Payment_Method_Manager::instance()->payment_method_types() as $pmt_obj) {
704 704
 				/** @var $pmt_obj EE_PMT_Base */
705 705
 				//get the form and simplify it, like what we do when we display it
706 706
 				$pmt_form = $pmt_obj->settings_form();
707 707
 				$this->_simplify_form($pmt_form);
708
-				if($pmt_form->form_data_present_in($this->_req_data)){
708
+				if ($pmt_form->form_data_present_in($this->_req_data)) {
709 709
 					$correct_pmt_form_to_use = $pmt_form;
710 710
 					break;
711 711
 				}
712 712
 			}
713 713
 			//if we couldn't find the correct payment method type...
714
-			if( ! $correct_pmt_form_to_use ){
714
+			if ( ! $correct_pmt_form_to_use) {
715 715
 				EE_Error::add_error(__("We could not find which payment method type your form submission related to. Please contact support", 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
716 716
 				$this->_redirect_after_action(FALSE, 'Payment Method', 'activated', array('action' => 'default'));
717 717
 			}
718 718
 			$correct_pmt_form_to_use->receive_form_submission($this->_req_data);
719
-			if($correct_pmt_form_to_use->is_valid()){
719
+			if ($correct_pmt_form_to_use->is_valid()) {
720 720
 				$correct_pmt_form_to_use->save();
721 721
 				$pm = $correct_pmt_form_to_use->get_model_object();
722 722
 				/** @var $pm EE_Payment_Method */
723
-				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default','payment_method'=>$pm->slug()));
724
-			}else{
723
+				$this->_redirect_after_action(TRUE, 'Payment Method', 'updated', array('action' => 'default', 'payment_method'=>$pm->slug()));
724
+			} else {
725 725
 				EE_Error::add_error(
726 726
 					sprintf(
727 727
 						__('Payment method of type %s was not saved because there were validation errors. They have been marked in the form', 'event_espresso'),
728
-						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __( '"(unknown)"', 'event_espresso' )
728
+						$pmt_obj instanceof EE_PMT_Base ? $pmt_obj->pretty_name() : __('"(unknown)"', 'event_espresso')
729 729
 					),
730 730
 					__FILE__,
731 731
 					__FUNCTION__,
@@ -742,11 +742,11 @@  discard block
 block discarded – undo
742 742
 	protected function _payment_settings() {
743 743
 
744 744
 		$this->_template_args['values'] = $this->_yes_no_values;
745
-		$this->_template_args['show_pending_payment_options'] = isset( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) ? absint( EE_Registry::instance()->CFG->registration->show_pending_payment_options ) : FALSE;
745
+		$this->_template_args['show_pending_payment_options'] = isset(EE_Registry::instance()->CFG->registration->show_pending_payment_options) ? absint(EE_Registry::instance()->CFG->registration->show_pending_payment_options) : FALSE;
746 746
 
747
-		$this->_set_add_edit_form_tags( 'update_payment_settings' );
748
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
749
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( EE_PAYMENTS_TEMPLATE_PATH . 'payment_settings.template.php', $this->_template_args, TRUE );
747
+		$this->_set_add_edit_form_tags('update_payment_settings');
748
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
749
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EE_PAYMENTS_TEMPLATE_PATH.'payment_settings.template.php', $this->_template_args, TRUE);
750 750
 		$this->display_admin_page_with_sidebar();
751 751
 
752 752
 	}
@@ -760,13 +760,13 @@  discard block
 block discarded – undo
760 760
 	*		@return array
761 761
 	*/
762 762
 	protected function _update_payment_settings() {
763
-		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset( $this->_req_data['show_pending_payment_options'] ) ? $this->_req_data['show_pending_payment_options'] : FALSE;
764
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG );
763
+		EE_Registry::instance()->CFG->registration->show_pending_payment_options = isset($this->_req_data['show_pending_payment_options']) ? $this->_req_data['show_pending_payment_options'] : FALSE;
764
+		EE_Registry::instance()->CFG = apply_filters('FHEE__Payments_Admin_Page___update_payment_settings__CFG', EE_Registry::instance()->CFG);
765 765
 
766 766
 
767
-		$what = __('Payment Settings','event_espresso');
768
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
769
-		$this->_redirect_after_action( $success, $what, __('updated','event_espresso'), array( 'action' => 'payment_settings' ) );
767
+		$what = __('Payment Settings', 'event_espresso');
768
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
769
+		$this->_redirect_after_action($success, $what, __('updated', 'event_espresso'), array('action' => 'payment_settings'));
770 770
 
771 771
 	}
772 772
 	protected function _payment_log_overview_list_table() {
@@ -792,18 +792,18 @@  discard block
 block discarded – undo
792 792
 	 * @param bool $count
793 793
 	 * @return array
794 794
 	 */
795
-	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false){
796
-		EE_Registry::instance()->load_model( 'Change_Log' );
795
+	public function get_payment_logs($per_page = 50, $current_page = 0, $count = false) {
796
+		EE_Registry::instance()->load_model('Change_Log');
797 797
 		//we may need to do multiple queries (joining differently), so we actually wan tan array of query params
798
-		$query_params =  array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
798
+		$query_params = array(array('LOG_type'=>  EEM_Change_Log::type_gateway));
799 799
 		//check if they've selected a specific payment method
800
-		if( isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all'){
800
+		if (isset($this->_req_data['_payment_method']) && $this->_req_data['_payment_method'] !== 'all') {
801 801
 			$query_params[0]['OR*pm_or_pay_pm'] = array('Payment.Payment_Method.PMD_ID'=>$this->_req_data['_payment_method'],
802 802
 				'Payment_Method.PMD_ID'=>$this->_req_data['_payment_method']);
803 803
 		}
804 804
 		//take into account search
805
-		if(isset($this->_req_data['s']) && $this->_req_data['s']){
806
-			$similarity_string = array('LIKE','%'.str_replace("","%",$this->_req_data['s']) .'%');
805
+		if (isset($this->_req_data['s']) && $this->_req_data['s']) {
806
+			$similarity_string = array('LIKE', '%'.str_replace("", "%", $this->_req_data['s']).'%');
807 807
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_fname'] = $similarity_string;
808 808
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_lname'] = $similarity_string;
809 809
 			$query_params[0]['OR*s']['Payment.Transaction.Registration.Attendee.ATT_email'] = $similarity_string;
@@ -818,48 +818,48 @@  discard block
 block discarded – undo
818 818
 			$query_params[0]['OR*s']['LOG_message'] = $similarity_string;
819 819
 
820 820
 		}
821
-		if(isset( $this->_req_data['payment-filter-start-date'] ) && isset( $this->_req_data['payment-filter-end-date'] )){
821
+		if (isset($this->_req_data['payment-filter-start-date']) && isset($this->_req_data['payment-filter-end-date'])) {
822 822
 			//add date
823
-			$start_date =wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] );
824
-			$end_date = wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] );
823
+			$start_date = wp_strip_all_tags($this->_req_data['payment-filter-start-date']);
824
+			$end_date = wp_strip_all_tags($this->_req_data['payment-filter-end-date']);
825 825
 			//make sure our timestamps start and end right at the boundaries for each day
826
-			$start_date = date( 'Y-m-d', strtotime( $start_date ) ) . ' 00:00:00';
827
-			$end_date = date( 'Y-m-d', strtotime( $end_date ) ) . ' 23:59:59';
826
+			$start_date = date('Y-m-d', strtotime($start_date)).' 00:00:00';
827
+			$end_date = date('Y-m-d', strtotime($end_date)).' 23:59:59';
828 828
 
829 829
 			//convert to timestamps
830
-			$start_date = strtotime( $start_date );
831
-			$end_date = strtotime( $end_date );
830
+			$start_date = strtotime($start_date);
831
+			$end_date = strtotime($end_date);
832 832
 
833 833
 			//makes sure start date is the lowest value and vice versa
834
-			$start_date = min( $start_date, $end_date );
835
-			$end_date = max( $start_date, $end_date );
834
+			$start_date = min($start_date, $end_date);
835
+			$end_date = max($start_date, $end_date);
836 836
 
837 837
 			//convert for query
838
-			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $start_date ), 'Y-m-d H:i:s' );
839
-			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query( 'LOG_time', date( 'Y-m-d H:i:s', $end_date ), 'Y-m-d H:i:s' );
838
+			$start_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $start_date), 'Y-m-d H:i:s');
839
+			$end_date = EEM_Change_Log::instance()->convert_datetime_for_query('LOG_time', date('Y-m-d H:i:s', $end_date), 'Y-m-d H:i:s');
840 840
 
841
-			$query_params[0]['LOG_time'] = array('BETWEEN',array($start_date,$end_date));
841
+			$query_params[0]['LOG_time'] = array('BETWEEN', array($start_date, $end_date));
842 842
 
843 843
 		}
844
-		if($count){
844
+		if ($count) {
845 845
 			return EEM_Change_Log::instance()->count($query_params);
846 846
 		}
847
-		if(isset($this->_req_data['order'])){
848
-			$sort = ( isset( $this->_req_data['order'] ) && ! empty( $this->_req_data['order'] )) ? $this->_req_data['order'] : 'DESC';
847
+		if (isset($this->_req_data['order'])) {
848
+			$sort = (isset($this->_req_data['order']) && ! empty($this->_req_data['order'])) ? $this->_req_data['order'] : 'DESC';
849 849
 			$query_params['order_by'] = array('LOG_time' => $sort);
850
-		}else{
850
+		} else {
851 851
 				$query_params['order_by'] = array('LOG_time' => 'DESC');
852 852
 		}
853
-		$offset = ($current_page-1)*$per_page;
853
+		$offset = ($current_page - 1) * $per_page;
854 854
 
855
-		if( ! isset($this->_req_data['download_results'])){
856
-			$query_params['limit'] = array( $offset, $per_page );
855
+		if ( ! isset($this->_req_data['download_results'])) {
856
+			$query_params['limit'] = array($offset, $per_page);
857 857
 		}
858 858
 
859 859
 
860 860
 
861 861
 		//now they've requested to instead just download the file instead of viewing it.
862
-		if(isset($this->_req_data['download_results'])){
862
+		if (isset($this->_req_data['download_results'])) {
863 863
 			$wpdb_results = EEM_Change_Log::instance()->get_all_efficiently($query_params);
864 864
 			header('Content-Disposition: attachment');
865 865
 			header("Content-Disposition: attachment; filename=ee_payment_logs_for_".sanitize_key(site_url()));
@@ -881,36 +881,36 @@  discard block
 block discarded – undo
881 881
 	 * @param EE_Change_Log $logB
882 882
 	 * @return int
883 883
 	 */
884
-	protected function _sort_logs_again($logA,$logB){
884
+	protected function _sort_logs_again($logA, $logB) {
885 885
 		$timeA = $logA->get_raw('LOG_time');
886 886
 		$timeB = $logB->get_raw('LOG_time');
887
-		if($timeA == $timeB){
887
+		if ($timeA == $timeB) {
888 888
 			return 0;
889 889
 		}
890 890
 		$comparison = $timeA < $timeB ? -1 : 1;
891
-		if(strtoupper($this->_sort_logs_again_direction) == 'DESC'){
891
+		if (strtoupper($this->_sort_logs_again_direction) == 'DESC') {
892 892
 			return $comparison * -1;
893
-		}else{
893
+		} else {
894 894
 			return $comparison;
895 895
 		}
896 896
 	}
897 897
 
898 898
 	protected function _payment_log_details() {
899
-		EE_Registry::instance()->load_model( 'Change_Log' );
899
+		EE_Registry::instance()->load_model('Change_Log');
900 900
 		/** @var $payment_log EE_Change_Log */
901 901
 		$payment_log = EEM_Change_Log::instance()->get_one_by_ID($this->_req_data['ID']);
902 902
 		$payment_method = NULL;
903 903
 		$transaction = NULL;
904
-		if( $payment_log instanceof EE_Change_Log ){
905
-			if( $payment_log->object() instanceof EE_Payment ){
904
+		if ($payment_log instanceof EE_Change_Log) {
905
+			if ($payment_log->object() instanceof EE_Payment) {
906 906
 				$payment_method = $payment_log->object()->payment_method();
907 907
 				$transaction = $payment_log->object()->transaction();
908
-			}elseif($payment_log->object() instanceof EE_Payment_Method){
908
+			}elseif ($payment_log->object() instanceof EE_Payment_Method) {
909 909
 				$payment_method = $payment_log->object();
910 910
 			}
911 911
 		}
912 912
 		$this->_template_args['admin_page_content'] = EEH_Template::display_template(
913
-			EE_PAYMENTS_TEMPLATE_PATH . 'payment_log_details.template.php',
913
+			EE_PAYMENTS_TEMPLATE_PATH.'payment_log_details.template.php',
914 914
 			array(
915 915
 				'payment_log'=>$payment_log,
916 916
 				'payment_method'=>$payment_method,
Please login to merge, or discard this patch.
admin_pages/payments/Payment_Log_Admin_List_Table.class.php 1 patch
Spacing   +28 added lines, -28 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
 /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
35 35
 	 * @param \EE_Admin_Page $admin_page
36 36
 	 * @return Payment_Log_Admin_List_Table
37 37
 	 */
38
-	public function __construct( $admin_page ) {
38
+	public function __construct($admin_page) {
39 39
 		parent::__construct($admin_page);
40 40
 	}
41 41
 
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
 //		}else{
53 53
 //			$this->_data = $this->_admin_page->get_questions( $this->_per_page,$this->_current_page, FALSE );
54 54
 //		}
55
-		$this->_all_data_count = $this->_admin_page->get_payment_logs( $this->_per_page,$this->_current_page, TRUE );
56
-		add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons',array($this,'add_download_logs_checkbox'));
55
+		$this->_all_data_count = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page, TRUE);
56
+		add_action('AHEE__EE_Admin_List_Table__extra_tablenav__after_bottom_buttons', array($this, 'add_download_logs_checkbox'));
57 57
 	}
58 58
 
59 59
 
@@ -63,8 +63,8 @@  discard block
 block discarded – undo
63 63
 	 * adds a checkbox to the bottom of the list table, instead of at the top with the rest of the filters
64 64
 	 * @return void
65 65
 	 */
66
-	public function add_download_logs_checkbox(){
67
-		echo "<input type='submit' class='button-primary' id='download_results' name='download_results' value='".  __( 'Download Results', 'event_espresso' )."'>";
66
+	public function add_download_logs_checkbox() {
67
+		echo "<input type='submit' class='button-primary' id='download_results' name='download_results' value='".__('Download Results', 'event_espresso')."'>";
68 68
 	}
69 69
 
70 70
 
@@ -75,8 +75,8 @@  discard block
 block discarded – undo
75 75
 	 */
76 76
 	protected function _set_properties() {
77 77
 		$this->_wp_list_args = array(
78
-			'singular' => __('payment log', 'event_espresso' ),
79
-			'plural' => __('payment logs', 'event_espresso' ),
78
+			'singular' => __('payment log', 'event_espresso'),
79
+			'plural' => __('payment logs', 'event_espresso'),
80 80
 			'ajax' => TRUE, //for now,
81 81
 			'screen' => $this->_admin_page->get_current_screen()->id
82 82
 			);
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
 			);
91 91
 
92 92
 		$this->_sortable_columns = array(
93
-			'LOG_time' => array( 'LOG_time' => TRUE ),
93
+			'LOG_time' => array('LOG_time' => TRUE),
94 94
 			);
95 95
 
96 96
 		$this->_hidden_columns = array(
@@ -108,18 +108,18 @@  discard block
 block discarded – undo
108 108
 		$filters = array();
109 109
 		//todo we're currently using old functions here. We need to move things into the Events_Admin_Page() class as methods.
110 110
 		$payment_methods = EEM_Payment_Method::instance()->get_all();
111
-		$payment_method_names = array(array('id'=>'all','text'=>  __("All", 'event_espresso')),array('id'=>'0','text'=>  __("Unknown Payment Method", 'event_espresso')));
112
-		foreach($payment_methods as $payment_method){
113
-			$payment_method_names[] = array('id'=>$payment_method->ID(),'text'=>$payment_method->admin_name());
111
+		$payment_method_names = array(array('id'=>'all', 'text'=>  __("All", 'event_espresso')), array('id'=>'0', 'text'=>  __("Unknown Payment Method", 'event_espresso')));
112
+		foreach ($payment_methods as $payment_method) {
113
+			$payment_method_names[] = array('id'=>$payment_method->ID(), 'text'=>$payment_method->admin_name());
114 114
 		}
115 115
 		$filters[] = EEH_Form_Fields::select_input('_payment_method', $payment_method_names, isset($this->_req_data['_payment_method']) ? $this->_req_data['_payment_method'] : 'all');
116
-		$start_date = isset( $this->_req_data['payment-filter-start-date'] ) ? wp_strip_all_tags( $this->_req_data['payment-filter-start-date'] ) : date( 'm/d/Y', strtotime( '-6 months' ));
117
-		$end_date = isset( $this->_req_data['payment-filter-end-date'] ) ? wp_strip_all_tags( $this->_req_data['payment-filter-end-date'] ) : date( 'm/d/Y' );
116
+		$start_date = isset($this->_req_data['payment-filter-start-date']) ? wp_strip_all_tags($this->_req_data['payment-filter-start-date']) : date('m/d/Y', strtotime('-6 months'));
117
+		$end_date = isset($this->_req_data['payment-filter-end-date']) ? wp_strip_all_tags($this->_req_data['payment-filter-end-date']) : date('m/d/Y');
118 118
 		ob_start();
119 119
 		?>
120
-		<label for="txn-filter-start-date"><?php _e( 'Display Transactions from ', 'event_espresso' ); ?></label>
120
+		<label for="txn-filter-start-date"><?php _e('Display Transactions from ', 'event_espresso'); ?></label>
121 121
 		<input id="payment-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>" name="payment-filter-start-date" size="15"/>
122
-		<label for="txn-filter-end-date"><?php _e( ' until ', 'event_espresso' ); ?></label>
122
+		<label for="txn-filter-end-date"><?php _e(' until ', 'event_espresso'); ?></label>
123 123
 		<input id="payment-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>" name="payment-filter-end-date" size="15"/>
124 124
 		<?php
125 125
 		$filters[] = ob_get_clean();
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
 	 * @return void
134 134
 	 */
135 135
 	protected function _add_view_counts() {
136
-		$this->_views['all']['count'] = $this->_admin_page->get_payment_logs( $this->_per_page,$this->_current_page, TRUE );
136
+		$this->_views['all']['count'] = $this->_admin_page->get_payment_logs($this->_per_page, $this->_current_page, TRUE);
137 137
 	}
138 138
 
139 139
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	 * @return string
145 145
 	 */
146 146
 	public function column_cb($item) {
147
-		return sprintf( '<input type="checkbox" class="option_id" name="checkbox[%1$d]" value="%1$d" />', $item->ID() );
147
+		return sprintf('<input type="checkbox" class="option_id" name="checkbox[%1$d]" value="%1$d" />', $item->ID());
148 148
 	}
149 149
 
150 150
 
@@ -170,7 +170,7 @@  discard block
 block discarded – undo
170 170
 	 * @param \EE_Change_Log $item
171 171
 	 * @return string
172 172
 	 */
173
-	public function column_LOG_time(EE_Change_Log $item){
173
+	public function column_LOG_time(EE_Change_Log $item) {
174 174
 		return $item->get_datetime('LOG_time');
175 175
 	}
176 176
 
@@ -181,12 +181,12 @@  discard block
 block discarded – undo
181 181
 	 * @param \EE_Change_Log $item
182 182
 	 * @return string
183 183
 	 */
184
-	public function column_PMD_ID(EE_Change_Log $item){
185
-		if($item->object() instanceof EE_Payment_Method){
184
+	public function column_PMD_ID(EE_Change_Log $item) {
185
+		if ($item->object() instanceof EE_Payment_Method) {
186 186
 			return $item->object()->admin_name();
187
-		}elseif($item->object() instanceof EE_Payment && $item->object()->payment_method()){
187
+		}elseif ($item->object() instanceof EE_Payment && $item->object()->payment_method()) {
188 188
 			return $item->object()->payment_method()->admin_name();
189
-		}else{
189
+		} else {
190 190
 			return __("No longer exists", 'event_espresso');
191 191
 		}
192 192
 	}
@@ -198,11 +198,11 @@  discard block
 block discarded – undo
198 198
 	 * @param \EE_Change_Log $item
199 199
 	 * @return string
200 200
 	 */
201
-	public function column_TXN_ID(EE_Change_Log $item){
202
-		if($item->object() instanceof EE_Payment){
203
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_transaction', 'espresso_transactions_view_transaction', $item->object()->TXN_ID() )) {
204
-				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'view_transaction', 'TXN_ID'=>$item->object()->TXN_ID() ), TXN_ADMIN_URL );
205
-				return '<a href="'.$view_txn_lnk_url.'"  title="' . sprintf( esc_attr__( 'click to view transaction #%s', 'event_espresso' ),  $item->object()->TXN_ID() ) . '">' . sprintf( __( 'view txn %s', 'event_espresso' ),  $item->object()->TXN_ID() ) . '</a>';
201
+	public function column_TXN_ID(EE_Change_Log $item) {
202
+		if ($item->object() instanceof EE_Payment) {
203
+			if (EE_Registry::instance()->CAP->current_user_can('ee_read_transaction', 'espresso_transactions_view_transaction', $item->object()->TXN_ID())) {
204
+				$view_txn_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'view_transaction', 'TXN_ID'=>$item->object()->TXN_ID()), TXN_ADMIN_URL);
205
+				return '<a href="'.$view_txn_lnk_url.'"  title="'.sprintf(esc_attr__('click to view transaction #%s', 'event_espresso'), $item->object()->TXN_ID()).'">'.sprintf(__('view txn %s', 'event_espresso'), $item->object()->TXN_ID()).'</a>';
206 206
 			}
207 207
 		} else {
208 208
 			return __("Unable to find transaction", 'event_espresso');
Please login to merge, or discard this patch.
admin_pages/events/Events_Admin_Page.core.php 1 patch
Spacing   +398 added lines, -398 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
 /**
@@ -67,7 +67,7 @@  discard block
 block discarded – undo
67 67
 			'espresso_events' => 'edit'
68 68
 			);
69 69
 
70
-		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array( $this, 'verify_event_edit' ) );
70
+		add_action('AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', array($this, 'verify_event_edit'));
71 71
 	}
72 72
 
73 73
 	protected function _ajax_hooks() {
@@ -93,7 +93,7 @@  discard block
 block discarded – undo
93 93
 				'edit' => __('Update Event', 'event_espresso'),
94 94
 				'add_category' => __('Save New Category', 'event_espresso'),
95 95
 				'edit_category' => __('Update Category', 'event_espresso'),
96
-				'template_settings' => __( 'Update Settings', 'event_espresso' )
96
+				'template_settings' => __('Update Settings', 'event_espresso')
97 97
 				)
98 98
 		);
99 99
 	}
@@ -103,8 +103,8 @@  discard block
 block discarded – undo
103 103
 		//load field generator helper
104 104
 
105 105
 		//is there a evt_id in the request?
106
-		$evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0;
107
-		$evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id;
106
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0;
107
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
108 108
 
109 109
 
110 110
 		$this->_page_routes = array(
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
 				'help_tour' => array(
319 319
 					'Event_Editor_Help_Tour'
320 320
 					),
321
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
321
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
322 322
 				'require_nonce' => FALSE
323 323
 			),
324 324
 			'edit' => array(
@@ -374,7 +374,7 @@  discard block
 block discarded – undo
374 374
 				/*'help_tour' => array(
375 375
 					'Event_Edit_Help_Tour'
376 376
 				),*/
377
-				'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ),
377
+				'qtips' => array('EE_Event_Editor_Decaf_Tips'),
378 378
 				'require_nonce' => FALSE
379 379
 			),
380 380
 			'default_event_settings' => array(
@@ -396,7 +396,7 @@  discard block
 block discarded – undo
396 396
 						'filename' => 'events_default_settings_status'
397 397
 					)
398 398
 				),
399
-				'help_tour' => array( 'Event_Default_Settings_Help_Tour'),
399
+				'help_tour' => array('Event_Default_Settings_Help_Tour'),
400 400
 				'require_nonce' => FALSE
401 401
 			),
402 402
 			//template settings
@@ -412,7 +412,7 @@  discard block
 block discarded – undo
412 412
 						'filename' => 'general_settings_templates'
413 413
 					)
414 414
 				),
415
-				'help_tour' => array( 'Templates_Help_Tour' ),
415
+				'help_tour' => array('Templates_Help_Tour'),
416 416
 				'require_nonce' => FALSE
417 417
 			),
418 418
 			//event category stuff
@@ -436,7 +436,7 @@  discard block
 block discarded – undo
436 436
 					'label' => __('Edit Category', 'event_espresso'),
437 437
 					'order' => 15,
438 438
 					'persistent' => FALSE,
439
-					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), $this->_current_page_view_url )  : $this->_admin_base_url
439
+					'url' => isset($this->_req_data['EVT_CAT_ID']) ? add_query_arg(array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), $this->_current_page_view_url) : $this->_admin_base_url
440 440
 					),
441 441
 				'help_tabs' => array(
442 442
 					'edit_category_help_tab' => array(
@@ -506,14 +506,14 @@  discard block
 block discarded – undo
506 506
 
507 507
 	public function load_scripts_styles() {
508 508
 
509
-		wp_register_style('events-admin-css', EVENTS_ASSETS_URL . 'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
510
-		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION );
509
+		wp_register_style('events-admin-css', EVENTS_ASSETS_URL.'events-admin-page.css', array(), EVENT_ESPRESSO_VERSION);
510
+		wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION);
511 511
 		wp_enqueue_style('events-admin-css');
512 512
 		wp_enqueue_style('ee-cat-admin');
513 513
 		//todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details
514 514
 		//registers for all views
515 515
 		//scripts
516
-		wp_register_script('event_editor_js', EVENTS_ASSETS_URL . 'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
516
+		wp_register_script('event_editor_js', EVENTS_ASSETS_URL.'event_editor.js', array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), EVENT_ESPRESSO_VERSION, TRUE);
517 517
 	}
518 518
 
519 519
 	/**
@@ -531,11 +531,11 @@  discard block
 block discarded – undo
531 531
 	public function load_scripts_styles_edit() {
532 532
 		//styles
533 533
 		wp_enqueue_style('espresso-ui-theme');
534
-		wp_register_style('event-editor-css', EVENTS_ASSETS_URL . 'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION );
534
+		wp_register_style('event-editor-css', EVENTS_ASSETS_URL.'event-editor.css', array('ee-admin-css'), EVENT_ESPRESSO_VERSION);
535 535
 		wp_enqueue_style('event-editor-css');
536 536
 
537 537
 		//scripts
538
-		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL . 'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION );
538
+		wp_register_script('event-datetime-metabox', EVENTS_ASSETS_URL.'event-datetime-metabox.js', array('event_editor_js', 'ee-datepicker'), EVENT_ESPRESSO_VERSION);
539 539
 		wp_enqueue_script('event-datetime-metabox');
540 540
 
541 541
 	}
@@ -570,7 +570,7 @@  discard block
 block discarded – undo
570 570
 
571 571
 
572 572
 	public function admin_init() {
573
-		EE_Registry::$i18n_js_strings[ 'image_confirm' ] = __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' );
573
+		EE_Registry::$i18n_js_strings['image_confirm'] = __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso');
574 574
 	}
575 575
 
576 576
 
@@ -591,45 +591,45 @@  discard block
 block discarded – undo
591 591
 	 */
592 592
 	public function verify_event_edit($event = NULL) {
593 593
 		// no event?
594
-		if ( empty( $event )) {
594
+		if (empty($event)) {
595 595
 			// set event
596 596
 			$event = $this->_cpt_model_obj;
597 597
 		}
598 598
 		// STILL no event?
599
-		if ( empty ( $event )) {
599
+		if (empty ($event)) {
600 600
 			return;
601 601
 		}
602 602
 		// first check if event is active.
603
-		if ( $event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed ) {
603
+		if ($event->is_expired() || $event->is_inactive() || $event->status() == EEM_Event::cancelled || $event->status() == EEM_Event::postponed) {
604 604
 			return;
605 605
 		}
606 606
 		$orig_status = $event->status();
607 607
 		//made it here so it IS active... next check that any of the tickets are sold.
608
-		if ( $event->is_sold_out( true ) ) {
609
-			if ( $event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out  ) {
608
+		if ($event->is_sold_out(true)) {
609
+			if ($event->status() !== $orig_status && $orig_status !== EEM_Event::sold_out) {
610 610
 				EE_Error::add_attention(
611 611
 					sprintf(
612
-						__( 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso' ),
613
-						EEH_Template::pretty_status( EEM_Event::sold_out, FALSE, 'sentence' )
612
+						__('Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event.  However, this change is not permanent until you update the event.  You can change the status back to something else before updating if you wish.', 'event_espresso'),
613
+						EEH_Template::pretty_status(EEM_Event::sold_out, FALSE, 'sentence')
614 614
 					)
615 615
 				);
616 616
 			}
617 617
 			return;
618
-		} else if ( $orig_status === EEM_Event::sold_out ) {
618
+		} else if ($orig_status === EEM_Event::sold_out) {
619 619
 			EE_Error::add_attention(
620 620
 				sprintf(
621
-					__( 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
622
-						'event_espresso' ),
623
-					EEH_Template::pretty_status( $event->status(), false, 'sentence' )
621
+					__('Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets.  However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.',
622
+						'event_espresso'),
623
+					EEH_Template::pretty_status($event->status(), false, 'sentence')
624 624
 				)
625 625
 			);
626 626
 		}
627 627
 		//now we need to determine if the event has any tickets on sale.  If not then we dont' show the error
628
-		if ( ! $event->tickets_on_sale() ) {
628
+		if ( ! $event->tickets_on_sale()) {
629 629
 			return;
630 630
 		}
631 631
 		//made it here so show warning
632
-		EE_Error::add_attention( $this->_edit_event_warning() );
632
+		EE_Error::add_attention($this->_edit_event_warning());
633 633
 	}
634 634
 
635 635
 
@@ -669,7 +669,7 @@  discard block
 block discarded – undo
669 669
 			),
670 670
 		);
671 671
 
672
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) {
672
+		if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
673 673
 			$this->_views['trash'] = array(
674 674
 				'slug' => 'trash',
675 675
 				'label' => __('Trash', 'event_espresso'),
@@ -699,39 +699,39 @@  discard block
 block discarded – undo
699 699
 				'desc' => __('View Registrations for Event', 'event_espresso')
700 700
 			)
701 701
 		);
702
-		$items  = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items );
702
+		$items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items);
703 703
 		$statuses = array(
704 704
 			'sold_out_status' => array(
705
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out,
706
-				'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, FALSE, 'sentence' )
705
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out,
706
+				'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, FALSE, 'sentence')
707 707
 			),
708 708
 			'active_status' => array(
709
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active,
710
-				'desc' => EEH_Template::pretty_status( EE_Datetime::active, FALSE, 'sentence' )
709
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active,
710
+				'desc' => EEH_Template::pretty_status(EE_Datetime::active, FALSE, 'sentence')
711 711
 			),
712 712
 			'upcoming_status' => array(
713
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming,
714
-				'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, FALSE, 'sentence' )
713
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming,
714
+				'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, FALSE, 'sentence')
715 715
 			),
716 716
 			'postponed_status' => array(
717
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed,
718
-				'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, FALSE, 'sentence' )
717
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed,
718
+				'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, FALSE, 'sentence')
719 719
 			),
720 720
 			'cancelled_status' => array(
721
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled,
722
-				'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, FALSE, 'sentence' )
721
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled,
722
+				'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, FALSE, 'sentence')
723 723
 			),
724 724
 			'expired_status' => array(
725
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired,
726
-				'desc' => EEH_Template::pretty_status( EE_Datetime::expired, FALSE, 'sentence' )
725
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired,
726
+				'desc' => EEH_Template::pretty_status(EE_Datetime::expired, FALSE, 'sentence')
727 727
 			),
728 728
 			'inactive_status' => array(
729
-				'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive,
730
-				'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, FALSE, 'sentence' )
729
+				'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive,
730
+				'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, FALSE, 'sentence')
731 731
 			)
732 732
 		);
733
-		$statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses );
734
-		return array_merge( $items, $statuses );
733
+		$statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses);
734
+		return array_merge($items, $statuses);
735 735
 	}
736 736
 
737 737
 
@@ -743,8 +743,8 @@  discard block
 block discarded – undo
743 743
 	 * @return EEM_Event
744 744
 	 */
745 745
 	private function _event_model() {
746
-		if ( ! $this->_event_model instanceof EEM_Event ) {
747
-			$this->_event_model = EE_Registry::instance()->load_model( 'Event' );
746
+		if ( ! $this->_event_model instanceof EEM_Event) {
747
+			$this->_event_model = EE_Registry::instance()->load_model('Event');
748 748
 		}
749 749
 		return $this->_event_model;
750 750
 	}
@@ -763,12 +763,12 @@  discard block
 block discarded – undo
763 763
 	 * @param  string $new_slug  what the slug is
764 764
 	 * @return string            The new html string for the permalink area
765 765
 	 */
766
-	public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) {
766
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) {
767 767
 		//make sure this is only when editing
768
-		if ( !empty( $id ) ) {
769
-			$post = get_post( $id );
770
-			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">' . __('Shortcode', 'event_espresso') . '</a> ';
771
-			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' . $post->ID . ']">';
768
+		if ( ! empty($id)) {
769
+			$post = get_post($id);
770
+			$return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#"  tabindex="-1">'.__('Shortcode', 'event_espresso').'</a> ';
771
+			$return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id='.$post->ID.']">';
772 772
 		}
773 773
 		return $return;
774 774
 	}
@@ -784,8 +784,8 @@  discard block
 block discarded – undo
784 784
 	 * @return string html for generated table
785 785
 	 */
786 786
 	protected function _events_overview_list_table() {
787
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
788
-		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button' ) .
787
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
788
+		$this->_template_args['after_list_table'] = EEH_Template::get_button_or_link(get_post_type_archive_link('espresso_events'), __("View Event Archive Page", "event_espresso"), 'button').
789 789
 		$this->_display_legend($this->_event_legend_items());
790 790
 		$this->_admin_page_title .= $this->get_action_link_or_button('create_new', 'add', array(), 'add-new-h2');
791 791
 		$this->display_admin_list_table_page_with_no_sidebar();
@@ -803,51 +803,51 @@  discard block
 block discarded – undo
803 803
 
804 804
 
805 805
 
806
-	protected function _insert_update_cpt_item( $post_id, $post ) {
806
+	protected function _insert_update_cpt_item($post_id, $post) {
807 807
 
808
-		if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) {
808
+		if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') {
809 809
 			//getout we're not processing an event save.
810 810
 			return;
811 811
 		}
812 812
 
813 813
 		$event_values = array(
814
-			'EVT_display_desc' => !empty( $this->_req_data['display_desc'] ) ? 1 : 0,
815
-			'EVT_display_ticket_selector' => !empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0,
814
+			'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0,
815
+			'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0,
816 816
 			'EVT_additional_limit' => min(
817
-					apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ),
818
-					!empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : NULL ),
819
-			'EVT_default_registration_status' => !empty( $this->_req_data['EVT_default_registration_status'] ) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
820
-			'EVT_member_only' => !empty( $this->_req_data['member_only'] ) ? 1 : 0,
821
-			'EVT_allow_overflow' => !empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0,
822
-			'EVT_timezone_string' => !empty( $this->_req_data['timezone_string'] ) ? $this->_req_data['timezone_string'] : NULL,
823
-			'EVT_external_URL' => !empty( $this->_req_data['externalURL'] ) ? $this->_req_data['externalURL'] : NULL,
824
-			'EVT_phone' => !empty( $this->_req_data['event_phone'] ) ? $this->_req_data['event_phone'] : NULL
817
+					apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255),
818
+					! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : NULL ),
819
+			'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) ? $this->_req_data['EVT_default_registration_status'] : EE_Registry::instance()->CFG->registration->default_STS_ID,
820
+			'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0,
821
+			'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0,
822
+			'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) ? $this->_req_data['timezone_string'] : NULL,
823
+			'EVT_external_URL' => ! empty($this->_req_data['externalURL']) ? $this->_req_data['externalURL'] : NULL,
824
+			'EVT_phone' => ! empty($this->_req_data['event_phone']) ? $this->_req_data['event_phone'] : NULL
825 825
 			);
826 826
 
827 827
 		//update event
828
-		$success = $this->_event_model()->update_by_ID( $event_values, $post_id );
828
+		$success = $this->_event_model()->update_by_ID($event_values, $post_id);
829 829
 
830 830
 
831 831
 		//get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id!
832
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status );
833
-		$event = $this->_event_model()->get_one( array($get_one_where) );
832
+		$get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status);
833
+		$event = $this->_event_model()->get_one(array($get_one_where));
834 834
 
835 835
 
836 836
 		//the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons.
837
-		$event_update_callbacks = apply_filters( 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( array($this, '_default_venue_update' ), array( $this, '_default_tickets_update') ) );
837
+		$event_update_callbacks = apply_filters('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')));
838 838
 
839 839
 		$att_success = TRUE;
840 840
 
841
-		foreach ( $event_update_callbacks as $e_callback ) {
842
-			$_succ = call_user_func_array( $e_callback, array( $event,  $this->_req_data ) );
843
-			$att_success = !$att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
841
+		foreach ($event_update_callbacks as $e_callback) {
842
+			$_succ = call_user_func_array($e_callback, array($event, $this->_req_data));
843
+			$att_success = ! $att_success ? $att_success : $_succ; //if ANY of these updates fail then we want the appropriate global error message
844 844
 		}
845 845
 
846 846
 		//any errors?
847
-		if ( $success && FALSE === $att_success ) {
848
-			EE_Error::add_error( __('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
849
-		} else if ( $success === FALSE ) {
850
-			EE_Error::add_error( __('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
847
+		if ($success && FALSE === $att_success) {
848
+			EE_Error::add_error(__('Event Details saved successfully but something went wrong with saving attachments.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
849
+		} else if ($success === FALSE) {
850
+			EE_Error::add_error(__('Event Details did not save successfully.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
851 851
 		}
852 852
 	}
853 853
 
@@ -857,14 +857,14 @@  discard block
 block discarded – undo
857 857
 	/**
858 858
 	 * @see parent::restore_item()
859 859
 	 */
860
-	protected function _restore_cpt_item( $post_id, $revision_id ) {
860
+	protected function _restore_cpt_item($post_id, $revision_id) {
861 861
 		//copy existing event meta to new post
862 862
 		$post_evt = $this->_event_model()->get_one_by_ID($post_id);
863
-		if ( $post_evt instanceof EE_Event ) {
863
+		if ($post_evt instanceof EE_Event) {
864 864
 			//meta revision restore
865
-			$post_evt->restore_revision( $revision_id );
865
+			$post_evt->restore_revision($revision_id);
866 866
 			//related objs restore
867
-			$post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) );
867
+			$post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price'));
868 868
 		}
869 869
 	}
870 870
 
@@ -877,52 +877,52 @@  discard block
 block discarded – undo
877 877
 	 * @param  array  $data   The request data from the form
878 878
 	 * @return bool           Success or fail.
879 879
 	 */
880
-	protected function _default_venue_update( $evtobj, $data ) {
881
-		require_once( EE_MODELS . 'EEM_Venue.model.php' );
880
+	protected function _default_venue_update($evtobj, $data) {
881
+		require_once(EE_MODELS.'EEM_Venue.model.php');
882 882
 		$venue_model = EE_Registry::instance()->load_model('Venue');
883 883
 		$rows_affected = NULL;
884
-		$venue_id = !empty( $data['venue_id'] ) ? $data['venue_id'] : NULL;
884
+		$venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : NULL;
885 885
 
886 886
 		// very important.  If we don't have a venue name...
887 887
 		// then we'll get out because not necessary to create empty venue
888
-		if ( empty( $data['venue_title'] ) ) {
888
+		if (empty($data['venue_title'])) {
889 889
 			return false;
890 890
 		}
891 891
 
892 892
 		$venue_array = array(
893 893
 				'VNU_wp_user' => $evtobj->get('EVT_wp_user'),
894
-				'VNU_name' => !empty( $data['venue_title'] ) ? $data['venue_title'] : NULL,
895
-				'VNU_desc' => !empty( $data['venue_description'] ) ? $data['venue_description'] : NULL,
896
-				'VNU_identifier' => !empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : NULL,
897
-				'VNU_short_desc' => !empty( $data['venue_short_description'] ) ? $data['venue_short_description'] : NULL,
898
-				'VNU_address' => !empty( $data['address'] ) ? $data['address'] : NULL,
899
-				'VNU_address2' => !empty( $data['address2'] ) ? $data['address2'] : NULL,
900
-				'VNU_city' => !empty( $data['city'] ) ? $data['city'] : NULL,
901
-				'STA_ID' => !empty( $data['state'] ) ? $data['state'] : NULL,
902
-				'CNT_ISO' => !empty( $data['countries'] ) ? $data['countries'] : NULL,
903
-				'VNU_zip' => !empty( $data['zip'] ) ? $data['zip'] : NULL,
904
-				'VNU_phone' => !empty( $data['venue_phone'] ) ? $data['venue_phone'] : NULL,
905
-				'VNU_capacity' => !empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : NULL,
906
-				'VNU_url' => !empty($data['venue_url'] ) ? $data['venue_url'] : NULL,
907
-				'VNU_virtual_phone' => !empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
908
-				'VNU_virtual_url' => !empty( $data['virtual_url'] ) ? $data['virtual_url'] : NULL,
909
-				'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0,
894
+				'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : NULL,
895
+				'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : NULL,
896
+				'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : NULL,
897
+				'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] : NULL,
898
+				'VNU_address' => ! empty($data['address']) ? $data['address'] : NULL,
899
+				'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : NULL,
900
+				'VNU_city' => ! empty($data['city']) ? $data['city'] : NULL,
901
+				'STA_ID' => ! empty($data['state']) ? $data['state'] : NULL,
902
+				'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : NULL,
903
+				'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : NULL,
904
+				'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : NULL,
905
+				'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : NULL,
906
+				'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : NULL,
907
+				'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : NULL,
908
+				'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : NULL,
909
+				'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0,
910 910
 				'status' => 'publish'
911 911
 			);
912 912
 
913 913
 
914 914
 		//if we've got the venue_id then we're just updating the existing venue so let's do that and then get out.
915
-		if ( !empty( $venue_id ) ) {
916
-			$update_where = array( $venue_model->primary_key_name() => $venue_id );
917
-			$rows_affected = $venue_model->update( $venue_array, array( $update_where ) );
915
+		if ( ! empty($venue_id)) {
916
+			$update_where = array($venue_model->primary_key_name() => $venue_id);
917
+			$rows_affected = $venue_model->update($venue_array, array($update_where));
918 918
 			//we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present.
919
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
919
+			$evtobj->_add_relation_to($venue_id, 'Venue');
920 920
 			return $rows_affected > 0 ? TRUE : FALSE;
921 921
 		} else {
922 922
 			//we insert the venue
923
-			$venue_id = $venue_model->insert( $venue_array );
924
-			$evtobj->_add_relation_to( $venue_id, 'Venue' );
925
-			return !empty( $venue_id ) ? TRUE : FALSE;
923
+			$venue_id = $venue_model->insert($venue_array);
924
+			$evtobj->_add_relation_to($venue_id, 'Venue');
925
+			return ! empty($venue_id) ? TRUE : FALSE;
926 926
 		}
927 927
 		//when we have the ancestor come in it's already been handled by the revision save.
928 928
 	}
@@ -936,54 +936,54 @@  discard block
 block discarded – undo
936 936
 	 * @param  array    $data   The request data from the form
937 937
 	 * @return bool             success or fail
938 938
 	 */
939
-	protected function _default_tickets_update( EE_Event $evtobj, $data ) {
939
+	protected function _default_tickets_update(EE_Event $evtobj, $data) {
940 940
 		$success = true;
941 941
 		$saved_dtt = null;
942 942
 		$saved_tickets = array();
943
-		$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
943
+		$incoming_date_formats = array('Y-m-d', 'h:i a');
944 944
 
945
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
945
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
946 946
 			//trim all values to ensure any excess whitespace is removed.
947
-			$dtt =  array_map( 'trim', $dtt );
948
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
947
+			$dtt = array_map('trim', $dtt);
948
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
949 949
 			$datetime_values = array(
950
-				'DTT_ID' 		=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
950
+				'DTT_ID' 		=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
951 951
 				'DTT_EVT_start' => $dtt['DTT_EVT_start'],
952 952
 				'DTT_EVT_end' 	=> $dtt['DTT_EVT_end'],
953
-				'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'],
953
+				'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
954 954
 				'DTT_order' 	=> $row,
955 955
 			);
956 956
 
957 957
 			//if we have an id then let's get existing object first and then set the new values.  Otherwise we instantiate a new object for save.
958 958
 
959
-			if ( !empty( $dtt['DTT_ID'] ) ) {
960
-				$DTM = EE_Registry::instance()->load_model('Datetime', array( $evtobj->get_timezone() ) )->get_one_by_ID($dtt['DTT_ID'] );
961
-				$DTM->set_date_format( $incoming_date_formats[0] );
962
-				$DTM->set_time_format( $incoming_date_formats[1] );
963
-				foreach ( $datetime_values as $field => $value ) {
964
-					$DTM->set( $field, $value );
959
+			if ( ! empty($dtt['DTT_ID'])) {
960
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($evtobj->get_timezone()))->get_one_by_ID($dtt['DTT_ID']);
961
+				$DTM->set_date_format($incoming_date_formats[0]);
962
+				$DTM->set_time_format($incoming_date_formats[1]);
963
+				foreach ($datetime_values as $field => $value) {
964
+					$DTM->set($field, $value);
965 965
 				}
966 966
 
967 967
 				//make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.  We need to do this so we dont' TRASH the parent DTT.
968 968
 				$saved_dtts[$DTM->ID()] = $DTM;
969 969
 			} else {
970
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values ), FALSE, FALSE );
971
-				$DTM->set_date_format( $incoming_date_formats[0] );
972
-				$DTM->set_time_format( $incoming_date_formats[1] );
973
-				$DTM->set_timezone( $evtobj->get_timezone() );
974
-				foreach ( $datetime_values as $field => $value ) {
975
-					$DTM->set( $field, $value );
970
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values), FALSE, FALSE);
971
+				$DTM->set_date_format($incoming_date_formats[0]);
972
+				$DTM->set_time_format($incoming_date_formats[1]);
973
+				$DTM->set_timezone($evtobj->get_timezone());
974
+				foreach ($datetime_values as $field => $value) {
975
+					$DTM->set($field, $value);
976 976
 				}
977 977
 			}
978 978
 			$DTM->save();
979 979
 
980
-			$DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' );
980
+			$DTT = $evtobj->_add_relation_to($DTM, 'Datetime');
981 981
 
982 982
 			//load DTT helper
983 983
 
984 984
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
985
-			if( $DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end') ) {
986
-				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start') );
985
+			if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) {
986
+				$DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start'));
987 987
 				$DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days');
988 988
 				$DTT->save();
989 989
 			}
@@ -991,45 +991,45 @@  discard block
 block discarded – undo
991 991
 			//now we got to make sure we add the new DTT_ID to the $saved_dtts array  because it is possible there was a new one created for the autosave.
992 992
 			$saved_dtt = $DTT;
993 993
 
994
-			$success = !$success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
994
+			$success = ! $success ? $success : $DTT; //if ANY of these updates fail then we want the appropriate global error message. //todod this is actually sucky we need a better error message but this is what it is for now.
995 995
 		}
996 996
 
997 997
 		//no dtts get deleted so we don't do any of that logic here.
998 998
 		//update tickets next
999
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
1000
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
1001
-			$incoming_date_formats = array( 'Y-m-d', 'h:i a' );
999
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
1000
+		foreach ($data['edit_tickets'] as $row => $tkt) {
1001
+			$incoming_date_formats = array('Y-m-d', 'h:i a');
1002 1002
 			$update_prices = false;
1003
-			$ticket_price = isset( $data['edit_prices'][$row][1]['PRC_amount'] ) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1003
+			$ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) ? $data['edit_prices'][$row][1]['PRC_amount'] : 0;
1004 1004
 
1005 1005
 			// trim inputs to ensure any excess whitespace is removed.
1006
-			$tkt = array_map( 'trim', $tkt );
1006
+			$tkt = array_map('trim', $tkt);
1007 1007
 
1008
-			if ( empty( $tkt['TKT_start_date'] ) ) {
1008
+			if (empty($tkt['TKT_start_date'])) {
1009 1009
 				//let's use now in the set timezone.
1010
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
1011
-				$tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] );
1010
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
1011
+				$tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]);
1012 1012
 			}
1013 1013
 
1014
-			if ( empty( $tkt['TKT_end_date'] ) ) {
1014
+			if (empty($tkt['TKT_end_date'])) {
1015 1015
 				//use the start date of the first datetime
1016 1016
 				$dtt = $evtobj->first_datetime();
1017
-				$tkt['TKT_end_date'] = $dtt->start_date_and_time( $incoming_date_formats[0], $incoming_date_formats[1] );
1017
+				$tkt['TKT_end_date'] = $dtt->start_date_and_time($incoming_date_formats[0], $incoming_date_formats[1]);
1018 1018
 			}
1019 1019
 
1020 1020
 			$TKT_values = array(
1021
-				'TKT_ID' 			=> !empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
1022
-				'TTM_ID' 			=> !empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
1023
-				'TKT_name' 			=> !empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
1024
-				'TKT_description' 	=> !empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '',
1021
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
1022
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
1023
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
1024
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '',
1025 1025
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
1026 1026
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
1027
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt['TKT_qty'],
1028
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt[ 'TKT_uses' ],
1029
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
1030
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
1027
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
1028
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
1029
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
1030
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
1031 1031
 				'TKT_row' 			=> $row,
1032
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row,
1032
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row,
1033 1033
 				'TKT_price' 		=> $ticket_price
1034 1034
 			);
1035 1035
 
@@ -1037,7 +1037,7 @@  discard block
 block discarded – undo
1037 1037
 
1038 1038
 
1039 1039
 			//if this is a default TKT, then we need to set the TKT_ID to 0 and update accordingly, which means in turn that the prices will become new prices as well.
1040
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
1040
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
1041 1041
 				$TKT_values['TKT_ID'] = 0;
1042 1042
 				$TKT_values['TKT_is_default'] = 0;
1043 1043
 				$TKT_values['TKT_price'] = $ticket_price;
@@ -1048,58 +1048,58 @@  discard block
 block discarded – undo
1048 1048
 			//we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified.
1049 1049
 			//keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
1050 1050
 
1051
-			if ( !empty( $tkt['TKT_ID'] ) ) {
1052
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $evtobj->get_timezone() ) )->get_one_by_ID( $tkt['TKT_ID'] );
1053
-				if ( $TKT instanceof EE_Ticket ) {
1054
-					$ticket_sold = $TKT->count_related( 'Registration', array( array( 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) ) ) ) > 0 ? true : false;
1051
+			if ( ! empty($tkt['TKT_ID'])) {
1052
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($evtobj->get_timezone()))->get_one_by_ID($tkt['TKT_ID']);
1053
+				if ($TKT instanceof EE_Ticket) {
1054
+					$ticket_sold = $TKT->count_related('Registration', array(array('STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))))) > 0 ? true : false;
1055 1055
 					//let's just check the total price for the existing ticket and determine if it matches the new total price.  if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket.
1056
-					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) && ! $TKT->get( 'TKT_deleted' ) ? true : false;
1057
-					$TKT->set_date_format( $incoming_date_formats[ 0 ] );
1058
-					$TKT->set_time_format( $incoming_date_formats[ 1 ] );
1056
+					$create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') && ! $TKT->get('TKT_deleted') ? true : false;
1057
+					$TKT->set_date_format($incoming_date_formats[0]);
1058
+					$TKT->set_time_format($incoming_date_formats[1]);
1059 1059
 					//set new values
1060
-					foreach ( $TKT_values as $field => $value ) {
1061
-						if ( $field == 'TKT_qty' ) {
1062
-							$TKT->set_qty( $value );
1060
+					foreach ($TKT_values as $field => $value) {
1061
+						if ($field == 'TKT_qty') {
1062
+							$TKT->set_qty($value);
1063 1063
 						} else {
1064
-							$TKT->set( $field, $value );
1064
+							$TKT->set($field, $value);
1065 1065
 						}
1066 1066
 					}
1067 1067
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
1068
-					if ( $create_new_TKT ) {
1068
+					if ($create_new_TKT) {
1069 1069
 						//archive the old ticket first
1070
-						$TKT->set( 'TKT_deleted', 1 );
1070
+						$TKT->set('TKT_deleted', 1);
1071 1071
 						$TKT->save();
1072 1072
 						//make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine.
1073
-						$saved_tickets[ $TKT->ID() ] = $TKT;
1073
+						$saved_tickets[$TKT->ID()] = $TKT;
1074 1074
 						//create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it.
1075 1075
 						$TKT = clone $TKT;
1076
-						$TKT->set( 'TKT_ID', 0 );
1077
-						$TKT->set( 'TKT_deleted', 0 );
1078
-						$TKT->set( 'TKT_price', $ticket_price );
1079
-						$TKT->set( 'TKT_sold', 0 );
1076
+						$TKT->set('TKT_ID', 0);
1077
+						$TKT->set('TKT_deleted', 0);
1078
+						$TKT->set('TKT_price', $ticket_price);
1079
+						$TKT->set('TKT_sold', 0);
1080 1080
 						//now we need to make sure that $new prices are created as well and attached to new ticket.
1081 1081
 						$update_prices = true;
1082 1082
 					}
1083 1083
 					//make sure price is set if it hasn't been already
1084
-					$TKT->set( 'TKT_price', $ticket_price );
1084
+					$TKT->set('TKT_price', $ticket_price);
1085 1085
 				}
1086 1086
 
1087 1087
 			} else {
1088 1088
 				//no TKT_id so a new TKT
1089 1089
 				$TKT_values['TKT_price'] = $ticket_price;
1090
-				$TKT = EE_Registry::instance()->load_class('Ticket', array( $TKT_values ), FALSE, FALSE );
1091
-				if ( $TKT instanceof EE_Ticket ) {
1090
+				$TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), FALSE, FALSE);
1091
+				if ($TKT instanceof EE_Ticket) {
1092 1092
 					//need to reset values to properly account for the date formats
1093
-					$TKT->set_date_format( $incoming_date_formats[0] );
1094
-					$TKT->set_time_format( $incoming_date_formats[1] );
1095
-					$TKT->set_timezone( $evtobj->get_timezone() );
1093
+					$TKT->set_date_format($incoming_date_formats[0]);
1094
+					$TKT->set_time_format($incoming_date_formats[1]);
1095
+					$TKT->set_timezone($evtobj->get_timezone());
1096 1096
 
1097 1097
 					//set new values
1098
-					foreach ( $TKT_values as $field => $value ) {
1099
-						if ( $field == 'TKT_qty' ) {
1100
-							$TKT->set_qty( $value );
1098
+					foreach ($TKT_values as $field => $value) {
1099
+						if ($field == 'TKT_qty') {
1100
+							$TKT->set_qty($value);
1101 1101
 						} else {
1102
-							$TKT->set( $field, $value );
1102
+							$TKT->set($field, $value);
1103 1103
 						}
1104 1104
 					}
1105 1105
 
@@ -1107,31 +1107,31 @@  discard block
 block discarded – undo
1107 1107
 				}
1108 1108
 			}
1109 1109
 			// cap ticket qty by datetime reg limits
1110
-			$TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) );
1110
+			$TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit')));
1111 1111
 			//update ticket.
1112 1112
 			$TKT->save();
1113 1113
 
1114 1114
 			//before going any further make sure our dates are setup correctly so that the end date is always equal or greater than the start date.
1115
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
1116
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
1115
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
1116
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
1117 1117
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
1118 1118
 				$TKT->save();
1119 1119
 			}
1120 1120
 
1121 1121
 			//initially let's add the ticket to the dtt
1122
-			$saved_dtt->_add_relation_to( $TKT, 'Ticket' );
1122
+			$saved_dtt->_add_relation_to($TKT, 'Ticket');
1123 1123
 
1124 1124
 			$saved_tickets[$TKT->ID()] = $TKT;
1125 1125
 
1126 1126
 			//add prices to ticket
1127
-			$this->_add_prices_to_ticket( $data['edit_prices'][$row], $TKT, $update_prices );
1127
+			$this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices);
1128 1128
 		}
1129 1129
 		//however now we need to handle permanently deleting tickets via the ui.  Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold.  However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db.
1130
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
1131
-		$tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) );
1130
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
1131
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
1132 1132
 
1133
-		foreach ( $tickets_removed as $id ) {
1134
-			$id = absint( $id );
1133
+		foreach ($tickets_removed as $id) {
1134
+			$id = absint($id);
1135 1135
 
1136 1136
 			//get the ticket for this id
1137 1137
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
@@ -1139,7 +1139,7 @@  discard block
 block discarded – undo
1139 1139
 			//need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold)
1140 1140
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
1141 1141
 
1142
-			foreach( $dtts as $dtt ) {
1142
+			foreach ($dtts as $dtt) {
1143 1143
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
1144 1144
 			}
1145 1145
 
@@ -1150,7 +1150,7 @@  discard block
 block discarded – undo
1150 1150
 			//finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships)
1151 1151
 			$tkt_to_remove->delete_permanently();
1152 1152
 		}
1153
-		return array( $saved_dtt, $saved_tickets );
1153
+		return array($saved_dtt, $saved_tickets);
1154 1154
 	}
1155 1155
 
1156 1156
 
@@ -1165,31 +1165,31 @@  discard block
 block discarded – undo
1165 1165
 	 * @param bool 		$new_prices Whether attach existing incoming prices or create new ones.
1166 1166
 	 * @return  void
1167 1167
 	 */
1168
-	private function  _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = FALSE ) {
1169
-		foreach ( $prices as $row => $prc ) {
1168
+	private function  _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = FALSE) {
1169
+		foreach ($prices as $row => $prc) {
1170 1170
 			$PRC_values = array(
1171
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
1172
-				'PRT_ID' => !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL,
1173
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
1174
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
1175
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
1171
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
1172
+				'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL,
1173
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
1174
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
1175
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
1176 1176
 				'PRC_is_default' => 0, //make sure prices are NOT set as default from this context
1177 1177
 				'PRC_order' => $row
1178 1178
 			);
1179 1179
 
1180
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
1180
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
1181 1181
 				$PRC_values['PRC_ID'] = 0;
1182
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
1182
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
1183 1183
 			} else {
1184
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
1184
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
1185 1185
 				//update this price with new values
1186
-				foreach ( $PRC_values as $field => $newprc ) {
1187
-					$PRC->set( $field, $newprc );
1186
+				foreach ($PRC_values as $field => $newprc) {
1187
+					$PRC->set($field, $newprc);
1188 1188
 				}
1189 1189
 				$PRC->save();
1190 1190
 			}
1191 1191
 
1192
-			$ticket->_add_relation_to( $PRC, 'Price' );
1192
+			$ticket->_add_relation_to($PRC, 'Price');
1193 1193
 		}
1194 1194
 	}
1195 1195
 
@@ -1212,33 +1212,33 @@  discard block
 block discarded – undo
1212 1212
 
1213 1213
 		return; //TEMPORARILY EXITING CAUSE THIS IS A TODO
1214 1214
 
1215
-		$postid = isset( $this->_req_data['post_ID'] ) ? $this->_req_data['post_ID'] : NULL;
1215
+		$postid = isset($this->_req_data['post_ID']) ? $this->_req_data['post_ID'] : NULL;
1216 1216
 
1217 1217
 
1218 1218
 		//if no postid then get out cause we need it for stuff in here
1219
-		if ( empty( $postid ) ) return;
1219
+		if (empty($postid)) return;
1220 1220
 
1221 1221
 
1222 1222
 		//handle datetime saves
1223 1223
 		$items = array();
1224 1224
 
1225
-		$get_one_where = array( $this->_event_model()->primary_key_name() => $postid );
1226
-		$event = $this->_event_model()->get_one( array($get_one_where) );
1225
+		$get_one_where = array($this->_event_model()->primary_key_name() => $postid);
1226
+		$event = $this->_event_model()->get_one(array($get_one_where));
1227 1227
 
1228 1228
 		//now let's get the attached datetimes from the most recent autosave
1229 1229
 		$dtts = $event->get_many_related('Datetime');
1230 1230
 
1231 1231
 		$dtt_ids = array();
1232
-		foreach( $dtts as $dtt ) {
1232
+		foreach ($dtts as $dtt) {
1233 1233
 			$dtt_ids[] = $dtt->ID();
1234 1234
 			$order = $dtt->order();
1235 1235
 			$this->_template_args['data']['items']['ID-'.$order] = $dtt->ID();
1236 1236
 		}
1237
-		$this->_template_args['data']['items']['datetime_IDS'] = serialize( $dtt_ids );
1237
+		$this->_template_args['data']['items']['datetime_IDS'] = serialize($dtt_ids);
1238 1238
 
1239 1239
 		//handle DECAF venues
1240 1240
 		//we need to make sure that the venue_id gets updated in the form so that future autosaves will properly conntect that venue to the event.
1241
-		if ( $do_venue_autosaves = apply_filters( 'FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE ) ) {
1241
+		if ($do_venue_autosaves = apply_filters('FHEE__Events_Admin_Page__ee_autosave_edit_do_decaf_venue_save', TRUE)) {
1242 1242
 			$venue = $event->get_first_related('Venue');
1243 1243
 			$this->_template_args['data']['items']['venue-id'] = $venue->ID();
1244 1244
 		}
@@ -1249,23 +1249,23 @@  discard block
 block discarded – undo
1249 1249
 
1250 1250
 		$ticket_ids = array();
1251 1251
 		$price_ids = array();
1252
-		foreach ( $tickets as $ticket ) {
1252
+		foreach ($tickets as $ticket) {
1253 1253
 			$ticket_ids[] = $price->ID();
1254 1254
 			$ticket_order = $price->get('TKT_order');
1255
-			$this->_template_args['data']['items']['edit-ticket-id-' . $ticket_order] = $ticket->ID();
1256
-			$this->_template_args['data']['items']['edit-ticket-event-id-' . $order] = $event->ID();
1255
+			$this->_template_args['data']['items']['edit-ticket-id-'.$ticket_order] = $ticket->ID();
1256
+			$this->_template_args['data']['items']['edit-ticket-event-id-'.$order] = $event->ID();
1257 1257
 
1258 1258
 			//now we have to make sure the prices are updated appropriately
1259 1259
 			$prices = $ticket->get_many_related('Prices');
1260 1260
 
1261
-			foreach ( $prices as $price ) {
1261
+			foreach ($prices as $price) {
1262 1262
 				$price_ids[] = $price->ID();
1263 1263
 				$price_order = $price->get('PRC_order');
1264
-				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-' . $ticket_order . '-' . $price_order] = $price->ID();
1265
-				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-' . $ticket_row . '-' . $price_row] = $price->ID();
1266
-				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-' . $ticket_row . '-' . $price_row] = $price->get('PRC_is_default');
1264
+				$this->_template_args['data']['items']['quick-edit-ticket-price-id-ticketrow-'.$ticket_order.'-'.$price_order] = $price->ID();
1265
+				$this->_template_args['data']['items']['edit-ticket-price-id-ticketrow-'.$ticket_row.'-'.$price_row] = $price->ID();
1266
+				$this->_template_args['data']['items']['edit-ticket-price-is-default-ticketrow-'.$ticket_row.'-'.$price_row] = $price->get('PRC_is_default');
1267 1267
 			}
1268
-			$this->_template_args['data']['items']['price-IDs-ticketrow-' . $ticket_row] = implode(',', $price_ids);
1268
+			$this->_template_args['data']['items']['price-IDs-ticketrow-'.$ticket_row] = implode(',', $price_ids);
1269 1269
 		}
1270 1270
 		$this->_template_args['data']['items']['ticket-IDs'] = implode(',', $ticket_ids);
1271 1271
 	}
@@ -1285,9 +1285,9 @@  discard block
 block discarded – undo
1285 1285
 		//load formatter helper
1286 1286
 
1287 1287
   		//args for getting related registrations
1288
-  		$approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) );
1289
-  		$not_approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved ) );
1290
-  		$pending_payment_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment ) );
1288
+  		$approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved));
1289
+  		$not_approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_not_approved));
1290
+  		$pending_payment_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_pending_payment));
1291 1291
 
1292 1292
 
1293 1293
 		// publish box
@@ -1316,9 +1316,9 @@  discard block
 block discarded – undo
1316 1316
 				),
1317 1317
 				REG_ADMIN_URL
1318 1318
 			),
1319
-			'approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $approved_query_args ),
1320
-			'not_approved_regs' => $this->_cpt_model_obj->count_related( 'Registration', $not_approved_query_args ),
1321
-			'pending_payment_regs' => $this->_cpt_model_obj->count_related( 'Registration', $pending_payment_query_args ),
1319
+			'approved_regs' => $this->_cpt_model_obj->count_related('Registration', $approved_query_args),
1320
+			'not_approved_regs' => $this->_cpt_model_obj->count_related('Registration', $not_approved_query_args),
1321
+			'pending_payment_regs' => $this->_cpt_model_obj->count_related('Registration', $pending_payment_query_args),
1322 1322
 			'misc_pub_section_class' => apply_filters(
1323 1323
 				'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class',
1324 1324
 				'misc-pub-section'
@@ -1337,9 +1337,9 @@  discard block
 block discarded – undo
1337 1337
 			'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add',
1338 1338
 			$this->_cpt_model_obj
1339 1339
 		);
1340
-		$publish_box_extra_args[ 'event_editor_overview_add' ] = ob_get_clean();
1340
+		$publish_box_extra_args['event_editor_overview_add'] = ob_get_clean();
1341 1341
 		// load template
1342
-		EEH_Template::display_template( EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', $publish_box_extra_args );
1342
+		EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', $publish_box_extra_args);
1343 1343
 	}
1344 1344
 
1345 1345
 
@@ -1371,16 +1371,16 @@  discard block
 block discarded – undo
1371 1371
 		$this->verify_cpt_object();
1372 1372
 		add_meta_box(
1373 1373
 			'espresso_event_editor_tickets',
1374
-			__( 'Event Datetime & Ticket', 'event_espresso' ),
1375
-			array( $this, 'ticket_metabox' ),
1374
+			__('Event Datetime & Ticket', 'event_espresso'),
1375
+			array($this, 'ticket_metabox'),
1376 1376
 			$this->page_slug,
1377 1377
 			'normal',
1378 1378
 			'high'
1379 1379
 		);
1380 1380
 		add_meta_box(
1381 1381
 			'espresso_event_editor_event_options',
1382
-			__( 'Event Registration Options', 'event_espresso' ),
1383
-			array( $this, 'registration_options_meta_box' ),
1382
+			__('Event Registration Options', 'event_espresso'),
1383
+			array($this, 'registration_options_meta_box'),
1384 1384
 			$this->page_slug,
1385 1385
 			'side',
1386 1386
 			'default'
@@ -1410,36 +1410,36 @@  discard block
 block discarded – undo
1410 1410
 			'disabled' => ''
1411 1411
 			);
1412 1412
 
1413
-		$event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : NULL;
1413
+		$event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : NULL;
1414 1414
 
1415
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
1415
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
1416 1416
 
1417 1417
 		/**
1418 1418
 		 * 1. Start with retrieving Datetimes
1419 1419
 		 * 2. Fore each datetime get related tickets
1420 1420
 		 * 3. For each ticket get related prices
1421 1421
 		 */
1422
-		$times = EE_Registry::instance()->load_model('Datetime' )->get_all_event_dates( $event_id );
1422
+		$times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id);
1423 1423
 		/** @type EE_Datetime $first_datetime */
1424
-		$first_datetime = reset( $times );
1424
+		$first_datetime = reset($times);
1425 1425
 		//do we get related tickets?
1426
-		if ( $first_datetime instanceof EE_Datetime 
1427
-			&& $first_datetime->ID() !== 0 ) {
1426
+		if ($first_datetime instanceof EE_Datetime 
1427
+			&& $first_datetime->ID() !== 0) {
1428 1428
 			$existing_datetime_ids[] = $first_datetime->get('DTT_ID');
1429 1429
 			$template_args['time'] = $first_datetime;
1430 1430
 			$related_tickets = $first_datetime->tickets(
1431 1431
 				array(
1432
-					array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ),
1432
+					array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)),
1433 1433
 					'default_where_conditions' => 'none'
1434 1434
 				)
1435 1435
 			);
1436 1436
 
1437
-			if ( !empty($related_tickets) ) {
1437
+			if ( ! empty($related_tickets)) {
1438 1438
 				$template_args['total_ticket_rows'] = count($related_tickets);
1439 1439
 				$row = 0;
1440
-				foreach ( $related_tickets as $ticket ) {
1440
+				foreach ($related_tickets as $ticket) {
1441 1441
 					$existing_ticket_ids[] = $ticket->get('TKT_ID');
1442
-					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row );
1442
+					$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, FALSE, $row);
1443 1443
 
1444 1444
 					$row++;
1445 1445
 				}
@@ -1447,13 +1447,13 @@  discard block
 block discarded – undo
1447 1447
 				$template_args['total_ticket_rows'] = 1;
1448 1448
 				/** @type EE_Ticket $ticket */
1449 1449
 				$ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object();
1450
-				$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket );
1450
+				$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket);
1451 1451
 			}
1452 1452
 		} else {
1453 1453
 			$template_args['time'] = $times[0];
1454 1454
 			/** @type EE_Ticket $ticket */
1455 1455
 			$ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
1456
-			$template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] );
1456
+			$template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]);
1457 1457
 			// NOTE: we're just sending the first default row
1458 1458
 			// (decaf can't manage default tickets so this should be sufficient);
1459 1459
 		}
@@ -1462,8 +1462,8 @@  discard block
 block discarded – undo
1462 1462
 		$template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info');
1463 1463
 		$template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
1464 1464
 		$template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
1465
-		$template_args['ticket_js_structure'] = $this->_get_ticket_row( EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE );
1466
-		$template = apply_filters( 'FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' );
1465
+		$template_args['ticket_js_structure'] = $this->_get_ticket_row(EE_Registry::instance()->load_model('Ticket')->create_default_object(), TRUE);
1466
+		$template = apply_filters('FHEE__Events_Admin_Page__ticket_metabox__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php');
1467 1467
 		EEH_Template::display_template($template, $template_args);
1468 1468
 	}
1469 1469
 
@@ -1478,21 +1478,21 @@  discard block
 block discarded – undo
1478 1478
 	 * @param int        $row
1479 1479
 	 * @return string generated html for the ticket row.
1480 1480
 	 */
1481
-	private function _get_ticket_row( $ticket, $skeleton = FALSE, $row = 0 ) {
1481
+	private function _get_ticket_row($ticket, $skeleton = FALSE, $row = 0) {
1482 1482
 		$template_args = array(
1483
-			'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(),
1484
-			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && !$skeleton ? ' tkt-archived' : '',
1483
+			'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(),
1484
+			'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' : '',
1485 1485
 			'ticketrow' => $skeleton ? 'TICKETNUM' : $row,
1486 1486
 			'TKT_ID' => $ticket->get('TKT_ID'),
1487 1487
 			'TKT_name' => $ticket->get('TKT_name'),
1488 1488
 			'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'),
1489 1489
 			'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'),
1490 1490
 			'TKT_is_default' => $ticket->get('TKT_is_default'),
1491
-			'TKT_qty' => $ticket->get_pretty('TKT_qty','input'),
1491
+			'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'),
1492 1492
 			'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets',
1493 1493
 			'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'),
1494
-			'trash_icon' => ( $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted') ) ) && ( !empty( $ticket ) && $ticket->get('TKT_sold') === 0 ) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1495
-			'disabled' => $skeleton || ( !empty( $ticket ) && ! $ticket->get('TKT_deleted' ) ) ? '' : ' disabled=disabled'
1494
+			'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon',
1495
+			'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' : ' disabled=disabled'
1496 1496
 			);
1497 1497
 
1498 1498
 		$price = $ticket->ID() !== 0 ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) : EE_Registry::instance()->load_model('Price')->create_default_object();
@@ -1508,23 +1508,23 @@  discard block
 block discarded – undo
1508 1508
 
1509 1509
 		//make sure we have default start and end dates if skeleton
1510 1510
 		//handle rows that should NOT be empty
1511
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1511
+		if (empty($template_args['TKT_start_date'])) {
1512 1512
 			//if empty then the start date will be now.
1513 1513
 			$template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp'));
1514 1514
 		}
1515 1515
 
1516
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1516
+		if (empty($template_args['TKT_end_date'])) {
1517 1517
 			//get the earliest datetime (if present);
1518
-			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1518
+			$earliest_dtt = $this->_cpt_model_obj->ID() > 0 ? $this->_cpt_model_obj->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1519 1519
 
1520
-			if ( !empty( $earliest_dtt ) )
1520
+			if ( ! empty($earliest_dtt))
1521 1521
 				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a');
1522 1522
 			else
1523
-				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d")+7, date("Y") ) );
1523
+				$template_args['TKT_end_date'] = date('Y-m-d h:i a', mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")));
1524 1524
 		}
1525 1525
 
1526
-		$template_args = array_merge( $template_args, $price_args );
1527
-		$template = apply_filters( 'FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', $ticket);
1526
+		$template_args = array_merge($template_args, $price_args);
1527
+		$template = apply_filters('FHEE__Events_Admin_Page__get_ticket_row__template', EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', $ticket);
1528 1528
 		return EEH_Template::display_template($template, $template_args, TRUE);
1529 1529
 	}
1530 1530
 
@@ -1553,8 +1553,8 @@  discard block
 block discarded – undo
1553 1553
 		$template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status());
1554 1554
 		$template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description());
1555 1555
 		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false);
1556
-		$template_args['additional_registration_options'] = apply_filters( 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values );
1557
-		$templatepath = EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php';
1556
+		$template_args['additional_registration_options'] = apply_filters('FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', '', $template_args, $yes_no_values, $default_reg_status_values);
1557
+		$templatepath = EVENTS_TEMPLATE_PATH.'event_registration_options.template.php';
1558 1558
 		EEH_Template::display_template($templatepath, $template_args);
1559 1559
 	}
1560 1560
 
@@ -1582,21 +1582,21 @@  discard block
 block discarded – undo
1582 1582
 		$EEME = $this->_event_model();
1583 1583
 
1584 1584
 		$offset = ($current_page - 1) * $per_page;
1585
-		$limit = $count ? NULL : $offset . ',' . $per_page;
1585
+		$limit = $count ? NULL : $offset.','.$per_page;
1586 1586
 		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID';
1587 1587
 		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC";
1588 1588
 
1589 1589
 		if (isset($this->_req_data['month_range'])) {
1590 1590
 			$pieces = explode(' ', $this->_req_data['month_range'], 3);
1591
-			$month_r = !empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1592
-			$year_r = !empty($pieces[1]) ? $pieces[1] : '';
1591
+			$month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : '';
1592
+			$year_r = ! empty($pieces[1]) ? $pieces[1] : '';
1593 1593
 		}
1594 1594
 
1595 1595
 		$where = array();
1596 1596
 
1597
-		$status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL;
1597
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL;
1598 1598
 		//determine what post_status our condition will have for the query.
1599
-		switch ( $status ) {
1599
+		switch ($status) {
1600 1600
 			case 'month' :
1601 1601
 			case 'today' :
1602 1602
 			case NULL :
@@ -1604,7 +1604,7 @@  discard block
 block discarded – undo
1604 1604
 				break;
1605 1605
 
1606 1606
 			case 'draft' :
1607
-				$where['status'] = array( 'IN', array('draft', 'auto-draft') );
1607
+				$where['status'] = array('IN', array('draft', 'auto-draft'));
1608 1608
 				break;
1609 1609
 
1610 1610
 			default :
@@ -1612,43 +1612,43 @@  discard block
 block discarded – undo
1612 1612
 		}
1613 1613
 
1614 1614
 		//categories?
1615
-		$category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1615
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
1616 1616
 
1617
-		if ( !empty ( $category ) ) {
1617
+		if ( ! empty ($category)) {
1618 1618
 			$where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories';
1619 1619
 			$where['Term_Taxonomy.term_id'] = $category;
1620 1620
 		}
1621 1621
 
1622 1622
 		//date where conditions
1623
-		$start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' );
1623
+		$start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start');
1624 1624
 		if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') {
1625
-			$DateTime = new DateTime( $year_r . '-' . $month_r . '-01 00:00:00', new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) );
1626
-			$start = $DateTime->format( implode( ' ', $start_formats  ) );
1627
-			$end = $DateTime->setDate( $year_r, $month_r, $DateTime->format('t') )->setTime(23,59,59)->format( implode( ' ', $start_formats ) );
1628
-			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array( $start, $end ) );
1625
+			$DateTime = new DateTime($year_r.'-'.$month_r.'-01 00:00:00', new DateTimeZone(EEM_Datetime::instance()->get_timezone()));
1626
+			$start = $DateTime->format(implode(' ', $start_formats));
1627
+			$end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1628
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1629 1629
 		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') {
1630
-			$DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1631
-			$start = $DateTime->setTime( 0,0,0 )->format( implode( ' ', $start_formats ) );
1632
-			$end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1633
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1634
-		} else if ( isset($this->_req_data['status']) && $this->_req_data['status'] == 'month' ) {
1635
-			$now = date( 'Y-m-01' );
1636
-			$DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) );
1637
-			$start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) );
1638
-			$end = $DateTime->setDate( date('Y'), date('m'), $DateTime->format('t' ) )->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) );
1639
-			$where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) );
1630
+			$DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone()));
1631
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1632
+			$end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1633
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1634
+		} else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') {
1635
+			$now = date('Y-m-01');
1636
+			$DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone()));
1637
+			$start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats));
1638
+			$end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t'))->setTime(23, 59, 59)->format(implode(' ', $start_formats));
1639
+			$where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end));
1640 1640
 		}
1641 1641
 
1642 1642
 
1643
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1644
-			$where['EVT_wp_user'] =  get_current_user_id();
1643
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1644
+			$where['EVT_wp_user'] = get_current_user_id();
1645 1645
 		} else {
1646
-			if ( ! isset( $where['status'] ) ) {
1647
-				if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) {
1646
+			if ( ! isset($where['status'])) {
1647
+				if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) {
1648 1648
 					$where['OR'] = array(
1649
-						'status*restrict_private' => array( '!=', 'private' ),
1649
+						'status*restrict_private' => array('!=', 'private'),
1650 1650
 						'AND' => array(
1651
-							'status*inclusive' => array( '=', 'private' ),
1651
+							'status*inclusive' => array('=', 'private'),
1652 1652
 							'EVT_wp_user' => get_current_user_id()
1653 1653
 						)
1654 1654
 					);
@@ -1656,16 +1656,16 @@  discard block
 block discarded – undo
1656 1656
 			}
1657 1657
 		}
1658 1658
 
1659
-		if ( isset( $this->_req_data['EVT_wp_user'] ) ) {
1660
-			if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) {
1659
+		if (isset($this->_req_data['EVT_wp_user'])) {
1660
+			if ($this->_req_data['EVT_wp_user'] != get_current_user_id() && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) {
1661 1661
 				$where['EVT_wp_user'] = $this->_req_data['EVT_wp_user'];
1662 1662
 			}
1663 1663
 		}
1664 1664
 
1665 1665
 
1666 1666
 		//search query handling
1667
-		if ( isset( $this->_req_data['s'] ) ) {
1668
-			$search_string = '%' . $this->_req_data['s'] . '%';
1667
+		if (isset($this->_req_data['s'])) {
1668
+			$search_string = '%'.$this->_req_data['s'].'%';
1669 1669
 			$where['OR'] = array(
1670 1670
 				'EVT_name' => array('LIKE', $search_string),
1671 1671
 				'EVT_desc' => array('LIKE', $search_string),
@@ -1674,32 +1674,32 @@  discard block
 block discarded – undo
1674 1674
 		}
1675 1675
 
1676 1676
 
1677
-		$where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data );
1678
-		$query_params = apply_filters( 'FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID' ), $this->_req_data );
1677
+		$where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data);
1678
+		$query_params = apply_filters('FHEE__Events_Admin_Page__get_events__query_params', array($where, 'limit' => $limit, 'order_by' => $orderby, 'order' => $order, 'group_by' => 'EVT_ID'), $this->_req_data);
1679 1679
 
1680 1680
 
1681 1681
 		//let's first check if we have special requests coming in.
1682
-		if ( isset( $this->_req_data['active_status'] ) ) {
1683
-			switch ( $this->_req_data['active_status'] ) {
1682
+		if (isset($this->_req_data['active_status'])) {
1683
+			switch ($this->_req_data['active_status']) {
1684 1684
 				case 'upcoming' :
1685
-					return $EEME->get_upcoming_events( $query_params, $count );
1685
+					return $EEME->get_upcoming_events($query_params, $count);
1686 1686
 					break;
1687 1687
 
1688 1688
 				case 'expired' :
1689
-					return $EEME->get_expired_events( $query_params, $count );
1689
+					return $EEME->get_expired_events($query_params, $count);
1690 1690
 					break;
1691 1691
 
1692 1692
 				case 'active' :
1693
-					return $EEME->get_active_events( $query_params, $count );
1693
+					return $EEME->get_active_events($query_params, $count);
1694 1694
 					break;
1695 1695
 
1696 1696
 				case 'inactive' :
1697
-					return $EEME->get_inactive_events( $query_params, $count );
1697
+					return $EEME->get_inactive_events($query_params, $count);
1698 1698
 					break;
1699 1699
 			}
1700 1700
 		}
1701 1701
 
1702
-		$events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params );
1702
+		$events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params);
1703 1703
 
1704 1704
 		return $events;
1705 1705
 	}
@@ -1708,23 +1708,23 @@  discard block
 block discarded – undo
1708 1708
 
1709 1709
 
1710 1710
 	//handling for WordPress CPT actions (trash, restore, delete)
1711
-	public function trash_cpt_item( $post_id ) {
1711
+	public function trash_cpt_item($post_id) {
1712 1712
 		$this->_req_data['EVT_ID'] = $post_id;
1713
-		$this->_trash_or_restore_event( 'trash', FALSE );
1713
+		$this->_trash_or_restore_event('trash', FALSE);
1714 1714
 	}
1715 1715
 
1716 1716
 
1717 1717
 
1718 1718
 
1719
-	public function restore_cpt_item( $post_id ) {
1719
+	public function restore_cpt_item($post_id) {
1720 1720
 		$this->_req_data['EVT_ID'] = $post_id;
1721
-		$this->_trash_or_restore_event( 'draft', FALSE );
1721
+		$this->_trash_or_restore_event('draft', FALSE);
1722 1722
 	}
1723 1723
 
1724 1724
 
1725
-	public function delete_cpt_item( $post_id ) {
1725
+	public function delete_cpt_item($post_id) {
1726 1726
 		$this->_req_data['EVT_ID'] = $post_id;
1727
-		$this->_delete_event( FALSE );
1727
+		$this->_delete_event(FALSE);
1728 1728
 	}
1729 1729
 
1730 1730
 
@@ -1736,7 +1736,7 @@  discard block
 block discarded – undo
1736 1736
 	 * @param  string $event_status
1737 1737
 	 * @return void
1738 1738
 	 */
1739
-	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE ) {
1739
+	protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = TRUE) {
1740 1740
 		//determine the event id and set to array.
1741 1741
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : FALSE;
1742 1742
 		// loop thru events
@@ -1744,7 +1744,7 @@  discard block
 block discarded – undo
1744 1744
 			// clean status
1745 1745
 			$event_status = sanitize_key($event_status);
1746 1746
 			// grab status
1747
-			if (!empty($event_status)) {
1747
+			if ( ! empty($event_status)) {
1748 1748
 				$success = $this->_change_event_status($EVT_ID, $event_status);
1749 1749
 			} else {
1750 1750
 				$success = FALSE;
@@ -1758,7 +1758,7 @@  discard block
 block discarded – undo
1758 1758
 		}
1759 1759
 		$action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash';
1760 1760
 
1761
-		if ( $redirect_after )
1761
+		if ($redirect_after)
1762 1762
 			$this->_redirect_after_action($success, 'Event', $action, array('action' => 'default'));
1763 1763
 	}
1764 1764
 
@@ -1773,7 +1773,7 @@  discard block
 block discarded – undo
1773 1773
 		// clean status
1774 1774
 		$event_status = sanitize_key($event_status);
1775 1775
 		// grab status
1776
-		if (!empty($event_status)) {
1776
+		if ( ! empty($event_status)) {
1777 1777
 			$success = TRUE;
1778 1778
 			//determine the event id and set to array.
1779 1779
 			$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
@@ -1808,15 +1808,15 @@  discard block
 block discarded – undo
1808 1808
 	 * @param  string $event_status
1809 1809
 	 * @return bool
1810 1810
 	 */
1811
-	private function _change_event_status( $EVT_ID = 0, $event_status = '') {
1811
+	private function _change_event_status($EVT_ID = 0, $event_status = '') {
1812 1812
 		// grab event id
1813
-		if (!$EVT_ID) {
1813
+		if ( ! $EVT_ID) {
1814 1814
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1815 1815
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1816 1816
 			return FALSE;
1817 1817
 		}
1818 1818
 
1819
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1819
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1820 1820
 
1821 1821
 		// clean status
1822 1822
 		$event_status = sanitize_key($event_status);
@@ -1842,7 +1842,7 @@  discard block
 block discarded – undo
1842 1842
 				$hook = FALSE;
1843 1843
 		}
1844 1844
 		//use class to change status
1845
-		$this->_cpt_model_obj->set_status( $event_status );
1845
+		$this->_cpt_model_obj->set_status($event_status);
1846 1846
 		$success = $this->_cpt_model_obj->save();
1847 1847
 
1848 1848
 		if ($success === FALSE) {
@@ -1864,15 +1864,15 @@  discard block
 block discarded – undo
1864 1864
 	 * @access protected
1865 1865
 	 * @param bool $redirect_after
1866 1866
 	 */
1867
-	protected function _delete_event( $redirect_after = TRUE ) {
1867
+	protected function _delete_event($redirect_after = TRUE) {
1868 1868
 		//determine the event id and set to array.
1869 1869
 		$EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : NULL;
1870
-		$EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID;
1870
+		$EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID;
1871 1871
 
1872 1872
 
1873 1873
 		// loop thru events
1874 1874
 		if ($EVT_ID) {
1875
-			$success = $this->_permanently_delete_event( $EVT_ID );
1875
+			$success = $this->_permanently_delete_event($EVT_ID);
1876 1876
 			// get list of events with no prices
1877 1877
 			$espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array());
1878 1878
 			// remove this event from the list of events with no prices
@@ -1886,7 +1886,7 @@  discard block
 block discarded – undo
1886 1886
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1887 1887
 		}
1888 1888
 
1889
-		if ( $redirect_after )
1889
+		if ($redirect_after)
1890 1890
 			$this->_redirect_after_action($success, 'Event', 'deleted', array('action' => 'default', 'status' => 'trash'));
1891 1891
 	}
1892 1892
 
@@ -1904,12 +1904,12 @@  discard block
 block discarded – undo
1904 1904
 		$EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array();
1905 1905
 		// loop thru events
1906 1906
 		foreach ($EVT_IDs as $EVT_ID) {
1907
-			$EVT_ID = absint( $EVT_ID );
1908
-			if ( $EVT_ID ) {
1909
-				$results = $this->_permanently_delete_event( $EVT_ID );
1907
+			$EVT_ID = absint($EVT_ID);
1908
+			if ($EVT_ID) {
1909
+				$results = $this->_permanently_delete_event($EVT_ID);
1910 1910
 				$success = $results !== FALSE ? $success : FALSE;
1911 1911
 				// remove this event from the list of events with no prices
1912
-				unset( $espresso_no_ticket_prices[ $EVT_ID ] );
1912
+				unset($espresso_no_ticket_prices[$EVT_ID]);
1913 1913
 			} else {
1914 1914
 				$success = FALSE;
1915 1915
 				$msg = __('An error occurred. An event could not be deleted because a valid event ID was not not supplied.', 'event_espresso');
@@ -1929,21 +1929,21 @@  discard block
 block discarded – undo
1929 1929
 	 * @param  int $EVT_ID
1930 1930
 	 * @return bool
1931 1931
 	 */
1932
-	private function _permanently_delete_event( $EVT_ID = 0 ) {
1932
+	private function _permanently_delete_event($EVT_ID = 0) {
1933 1933
 		// grab event id
1934
-		if ( ! $EVT_ID ) {
1934
+		if ( ! $EVT_ID) {
1935 1935
 			$msg = __('An error occurred. No Event ID or an invalid Event ID was received.', 'event_espresso');
1936 1936
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1937 1937
 			return FALSE;
1938 1938
 		}
1939
-		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID );
1939
+		$this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID);
1940 1940
 
1941 1941
 		//need to delete related tickets and prices first.
1942 1942
 		$datetimes = $this->_cpt_model_obj->get_many_related('Datetime');
1943
-		foreach ( $datetimes as $datetime ) {
1943
+		foreach ($datetimes as $datetime) {
1944 1944
 			$this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime');
1945 1945
 			$tickets = $datetime->get_many_related('Ticket');
1946
-			foreach ( $tickets as $ticket ) {
1946
+			foreach ($tickets as $ticket) {
1947 1947
 				$ticket->_remove_relation_to($datetime, 'Datetime');
1948 1948
 				$ticket->delete_related_permanently('Price');
1949 1949
 				$ticket->delete_permanently();
@@ -1953,14 +1953,14 @@  discard block
 block discarded – undo
1953 1953
 
1954 1954
 		//what about related venues or terms?
1955 1955
 		$venues = $this->_cpt_model_obj->get_many_related('Venue');
1956
-		foreach ( $venues as $venue ) {
1956
+		foreach ($venues as $venue) {
1957 1957
 			$this->_cpt_model_obj->_remove_relation_to($venue, 'Venue');
1958 1958
 		}
1959 1959
 
1960 1960
 		//any attached question groups?
1961 1961
 		$question_groups = $this->_cpt_model_obj->get_many_related('Question_Group');
1962
-		if ( !empty( $question_groups ) ) {
1963
-			foreach ( $question_groups as $question_group ) {
1962
+		if ( ! empty($question_groups)) {
1963
+			foreach ($question_groups as $question_group) {
1964 1964
 				$this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group');
1965 1965
 			}
1966 1966
 		}
@@ -1969,12 +1969,12 @@  discard block
 block discarded – undo
1969 1969
 
1970 1970
 
1971 1971
 		//Message Template Groups
1972
-		$this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' );
1972
+		$this->_cpt_model_obj->_remove_relations('Message_Template_Group');
1973 1973
 
1974 1974
 		/** @type EE_Term_Taxonomy[] $term_taxonomies */
1975 1975
 		$term_taxonomies = $this->_cpt_model_obj->term_taxonomies();
1976 1976
 
1977
-		foreach ( $term_taxonomies as $term_taxonomy ) {
1977
+		foreach ($term_taxonomies as $term_taxonomy) {
1978 1978
 			$this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy);
1979 1979
 		}
1980 1980
 
@@ -1988,7 +1988,7 @@  discard block
 block discarded – undo
1988 1988
 			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
1989 1989
 			return FALSE;
1990 1990
 		}
1991
-		do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID );
1991
+		do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID);
1992 1992
 		return TRUE;
1993 1993
 	}
1994 1994
 
@@ -2005,7 +2005,7 @@  discard block
 block discarded – undo
2005 2005
 	 */
2006 2006
 	public function total_events() {
2007 2007
 
2008
-		$count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true );
2008
+		$count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true);
2009 2009
 		return $count;
2010 2010
 	}
2011 2011
 
@@ -2020,10 +2020,10 @@  discard block
 block discarded – undo
2020 2020
 	 */
2021 2021
 	public function total_events_draft() {
2022 2022
 		$where = array(
2023
-			'status' => array( 'IN', array('draft', 'auto-draft' ) )
2023
+			'status' => array('IN', array('draft', 'auto-draft'))
2024 2024
 			);
2025 2025
 
2026
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2026
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2027 2027
 		return $count;
2028 2028
 	}
2029 2029
 
@@ -2042,7 +2042,7 @@  discard block
 block discarded – undo
2042 2042
 			'status' => 'trash'
2043 2043
 			);
2044 2044
 
2045
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
2045
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
2046 2046
 		return $count;
2047 2047
 	}
2048 2048
 
@@ -2070,11 +2070,11 @@  discard block
 block discarded – undo
2070 2070
 			// translated
2071 2071
 			TRUE
2072 2072
 		);
2073
-		$this->_template_args['default_reg_status'] = isset( EE_Registry::instance()->CFG->registration->default_STS_ID ) ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) : EEM_Registration::status_id_pending_payment;
2073
+		$this->_template_args['default_reg_status'] = isset(EE_Registry::instance()->CFG->registration->default_STS_ID) ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) : EEM_Registration::status_id_pending_payment;
2074 2074
 
2075 2075
 		$this->_set_add_edit_form_tags('update_default_event_settings');
2076 2076
 		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
2077
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH . 'event_settings.template.php', $this->_template_args, TRUE);
2077
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_TEMPLATE_PATH.'event_settings.template.php', $this->_template_args, TRUE);
2078 2078
 		$this->display_admin_page_with_sidebar();
2079 2079
 	}
2080 2080
 
@@ -2100,9 +2100,9 @@  discard block
 block discarded – undo
2100 2100
 
2101 2101
 	protected function _template_settings() {
2102 2102
 		$this->_admin_page_title = __('Template Settings (Preview)', 'event_espresso');
2103
-		$this->_template_args['preview_img'] = '<img src="' . EVENTS_ASSETS_URL . DS . 'images' . DS . 'caffeinated_template_features.jpg" alt="' . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) . '" />';
2104
-		$this->_template_args['preview_text'] = '<strong>'.__( 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso' ).'</strong>';
2105
-		$this->display_admin_caf_preview_page( 'template_settings_tab' );
2103
+		$this->_template_args['preview_img'] = '<img src="'.EVENTS_ASSETS_URL.DS.'images'.DS.'caffeinated_template_features.jpg" alt="'.esc_attr__('Template Settings Preview screenshot', 'event_espresso').'" />';
2104
+		$this->_template_args['preview_text'] = '<strong>'.__('Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', 'event_espresso').'</strong>';
2105
+		$this->display_admin_caf_preview_page('template_settings_tab');
2106 2106
 	}
2107 2107
 
2108 2108
 
@@ -2115,22 +2115,22 @@  discard block
 block discarded – undo
2115 2115
 	 * @return void
2116 2116
 	 */
2117 2117
 	private function _set_category_object() {
2118
-		if ( isset( $this->_category->id ) && !empty( $this->_category->id ) )
2118
+		if (isset($this->_category->id) && ! empty($this->_category->id))
2119 2119
 			return; //already have the category object so get out.
2120 2120
 
2121 2121
 		//set default category object
2122 2122
 		$this->_set_empty_category_object();
2123 2123
 
2124 2124
 		//only set if we've got an id
2125
-		if ( !isset($this->_req_data['EVT_CAT_ID'] ) ) {
2125
+		if ( ! isset($this->_req_data['EVT_CAT_ID'])) {
2126 2126
 			return;
2127 2127
 		}
2128 2128
 
2129 2129
 		$category_id = absint($this->_req_data['EVT_CAT_ID']);
2130 2130
 
2131
-		$term = get_term( $category_id, 'espresso_event_categories' );
2131
+		$term = get_term($category_id, 'espresso_event_categories');
2132 2132
 
2133
-		if ( !empty( $term ) ) {
2133
+		if ( ! empty($term)) {
2134 2134
 			$this->_category->category_name = $term->name;
2135 2135
 			$this->_category->category_identifier = $term->slug;
2136 2136
 			$this->_category->category_desc = $term->description;
@@ -2144,13 +2144,13 @@  discard block
 block discarded – undo
2144 2144
 
2145 2145
 	private function _set_empty_category_object() {
2146 2146
 		$this->_category = new stdClass();
2147
-		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc  = '';
2147
+		$this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = '';
2148 2148
 		$this->_category->id = $this->_category->parent = 0;
2149 2149
 	}
2150 2150
 
2151 2151
 
2152 2152
 	protected function _category_list_table() {
2153
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
2153
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
2154 2154
 		$this->_search_btn_label = __('Categories', 'event_espresso');
2155 2155
 		$this->_admin_page_title .= $this->get_action_link_or_button('add_category', 'add_category', array(), 'add-new-h2');
2156 2156
 		$this->display_admin_list_table_page_with_sidebar();
@@ -2166,14 +2166,14 @@  discard block
 block discarded – undo
2166 2166
 		$this->_set_add_edit_form_tags($route);
2167 2167
 
2168 2168
 		$this->_set_category_object();
2169
-		$id = !empty($this->_category->id) ? $this->_category->id : '';
2169
+		$id = ! empty($this->_category->id) ? $this->_category->id : '';
2170 2170
 
2171 2171
 		$delete_action = 'delete_category';
2172 2172
 
2173 2173
 		//custom redirect
2174
-		$redirect = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'category_list'), $this->_admin_base_url );
2174
+		$redirect = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'category_list'), $this->_admin_base_url);
2175 2175
 
2176
-		$this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect );
2176
+		$this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect);
2177 2177
 
2178 2178
 		//take care of contents
2179 2179
 		$this->_template_args['admin_page_content'] = $this->_category_details_content();
@@ -2187,25 +2187,25 @@  discard block
 block discarded – undo
2187 2187
 			'type' => 'wp_editor',
2188 2188
 			'value' => EEH_Formatter::admin_format_content($this->_category->category_desc),
2189 2189
 			'class' => 'my_editor_custom',
2190
-			'wpeditor_args' => array('media_buttons' => FALSE )
2190
+			'wpeditor_args' => array('media_buttons' => FALSE)
2191 2191
 		);
2192
-		$_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' );
2192
+		$_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array');
2193 2193
 
2194
-		$all_terms = get_terms( array('espresso_event_categories' ), array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) );
2194
+		$all_terms = get_terms(array('espresso_event_categories'), array('hide_empty' => 0, 'exclude' => array($this->_category->id)));
2195 2195
 
2196 2196
 		//setup category select for term parents.
2197 2197
 		$category_select_values[] = array(
2198 2198
 			'text' => __('No Parent', 'event_espresso'),
2199 2199
 			'id' => 0
2200 2200
 			);
2201
-		foreach ( $all_terms as $term ) {
2201
+		foreach ($all_terms as $term) {
2202 2202
 			$category_select_values[] = array(
2203 2203
 				'text' => $term->name,
2204 2204
 				'id' => $term->term_id
2205 2205
 				);
2206 2206
 		}
2207 2207
 
2208
-		$category_select = EEH_Form_Fields::select_input( 'category_parent', $category_select_values, $this->_category->parent );
2208
+		$category_select = EEH_Form_Fields::select_input('category_parent', $category_select_values, $this->_category->parent);
2209 2209
 
2210 2210
 		$template_args = array(
2211 2211
 			'category' => $this->_category,
@@ -2215,15 +2215,15 @@  discard block
 block discarded – undo
2215 2215
 			'disable' => '',
2216 2216
 			'disabled_message' => FALSE
2217 2217
 			);
2218
-		$template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php';
2219
-		return EEH_Template::display_template($template, $template_args, TRUE );
2218
+		$template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php';
2219
+		return EEH_Template::display_template($template, $template_args, TRUE);
2220 2220
 	}
2221 2221
 
2222 2222
 
2223 2223
 	protected function _delete_categories() {
2224
-		$cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2224
+		$cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] : (array) $this->_req_data['category_id'];
2225 2225
 
2226
-		foreach ( $cat_ids as $cat_id ) {
2226
+		foreach ($cat_ids as $cat_id) {
2227 2227
 			$this->_delete_category($cat_id);
2228 2228
 		}
2229 2229
 
@@ -2231,7 +2231,7 @@  discard block
 block discarded – undo
2231 2231
 		$query_args = array(
2232 2232
 			'action' => 'category_list'
2233 2233
 			);
2234
-		$this->_redirect_after_action(0,'','',$query_args);
2234
+		$this->_redirect_after_action(0, '', '', $query_args);
2235 2235
 
2236 2236
 	}
2237 2237
 
@@ -2241,61 +2241,61 @@  discard block
 block discarded – undo
2241 2241
 
2242 2242
 	protected function _delete_category($cat_id) {
2243 2243
 		global $wpdb;
2244
-		$cat_id = absint( $cat_id );
2245
-		wp_delete_term( $cat_id, 'espresso_event_categories' );
2244
+		$cat_id = absint($cat_id);
2245
+		wp_delete_term($cat_id, 'espresso_event_categories');
2246 2246
 	}
2247 2247
 
2248 2248
 
2249 2249
 
2250 2250
 	protected function _insert_or_update_category($new_category) {
2251 2251
 
2252
-		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( TRUE );
2252
+		$cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(TRUE);
2253 2253
 		$success = 0; //we already have a success message so lets not send another.
2254 2254
 
2255
-		if ( $cat_id ) {
2255
+		if ($cat_id) {
2256 2256
 			$query_args = array(
2257 2257
 				'action'     => 'edit_category',
2258 2258
 				'EVT_CAT_ID' => $cat_id
2259 2259
 			);
2260 2260
 		} else {
2261
-			$query_args = array( 'action' => 'add_category' );
2261
+			$query_args = array('action' => 'add_category');
2262 2262
 		}
2263
-		$this->_redirect_after_action( $success, '','', $query_args, TRUE );
2263
+		$this->_redirect_after_action($success, '', '', $query_args, TRUE);
2264 2264
 
2265 2265
 	}
2266 2266
 
2267 2267
 
2268 2268
 
2269
-	private function _insert_category( $update = FALSE ) {
2269
+	private function _insert_category($update = FALSE) {
2270 2270
 		$cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : '';
2271
-		$category_name= isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : '';
2272
-		$category_desc= isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : '';
2273
-		$category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0;
2271
+		$category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : '';
2272
+		$category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : '';
2273
+		$category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0;
2274 2274
 
2275
-		if ( empty( $category_name ) ) {
2276
-			$msg = __( 'You must add a name for the category.', 'event_espresso' );
2277
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2275
+		if (empty($category_name)) {
2276
+			$msg = __('You must add a name for the category.', 'event_espresso');
2277
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2278 2278
 			return false;
2279 2279
 		}
2280 2280
 
2281
-		$term_args=array(
2281
+		$term_args = array(
2282 2282
 			'name'=>$category_name,
2283 2283
 			'description'=>$category_desc,
2284 2284
 			'parent'=>$category_parent
2285 2285
 		);
2286 2286
 		//was the category_identifier input disabled?
2287
-		if(isset($this->_req_data['category_identifier'])){
2287
+		if (isset($this->_req_data['category_identifier'])) {
2288 2288
 			$term_args['slug'] = $this->_req_data['category_identifier'];
2289 2289
 		}
2290
-		$insert_ids = $update ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) :wp_insert_term( $category_name, 'espresso_event_categories', $term_args );
2290
+		$insert_ids = $update ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) : wp_insert_term($category_name, 'espresso_event_categories', $term_args);
2291 2291
 
2292
-		if ( !is_array( $insert_ids ) ) {
2293
-			$msg = __( 'An error occurred and the category has not been saved to the database.', 'event_espresso' );
2294
-			EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ );
2292
+		if ( ! is_array($insert_ids)) {
2293
+			$msg = __('An error occurred and the category has not been saved to the database.', 'event_espresso');
2294
+			EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__);
2295 2295
 		} else {
2296 2296
 			$cat_id = $insert_ids['term_id'];
2297
-			$msg = sprintf ( __('The category %s was successfuly saved', 'event_espresso'), $category_name );
2298
-			EE_Error::add_success( $msg );
2297
+			$msg = sprintf(__('The category %s was successfuly saved', 'event_espresso'), $category_name);
2298
+			EE_Error::add_success($msg);
2299 2299
 		}
2300 2300
 
2301 2301
 		return $cat_id;
@@ -2304,32 +2304,32 @@  discard block
 block discarded – undo
2304 2304
 
2305 2305
 
2306 2306
 
2307
-	public function get_categories( $per_page = 10, $current_page = 1, $count = FALSE ) {
2307
+	public function get_categories($per_page = 10, $current_page = 1, $count = FALSE) {
2308 2308
 		global $wpdb;
2309 2309
 
2310 2310
 		//testing term stuff
2311
-		$orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id';
2312
-		$order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC';
2313
-		$limit = ($current_page-1)*$per_page;
2311
+		$orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id';
2312
+		$order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC';
2313
+		$limit = ($current_page - 1) * $per_page;
2314 2314
 
2315
-		$where = array( 'taxonomy' => 'espresso_event_categories' );
2315
+		$where = array('taxonomy' => 'espresso_event_categories');
2316 2316
 
2317
-		if ( isset( $this->_req_data['s'] ) ) {
2318
-			$sstr = '%' . $this->_req_data['s'] . '%';
2317
+		if (isset($this->_req_data['s'])) {
2318
+			$sstr = '%'.$this->_req_data['s'].'%';
2319 2319
 			$where['OR'] = array(
2320
-				'Term.name' => array( 'LIKE', $sstr),
2321
-				'description' => array( 'LIKE', $sstr )
2320
+				'Term.name' => array('LIKE', $sstr),
2321
+				'description' => array('LIKE', $sstr)
2322 2322
 				);
2323 2323
 		}
2324 2324
 
2325 2325
 		$query_params = array(
2326
-			$where ,
2327
-			'order_by' => array( $orderby => $order ),
2328
-			'limit' => $limit . ',' . $per_page,
2326
+			$where,
2327
+			'order_by' => array($orderby => $order),
2328
+			'limit' => $limit.','.$per_page,
2329 2329
 			'force_join' => array('Term')
2330 2330
 			);
2331 2331
 
2332
-		$categories = $count ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) :EEM_Term_Taxonomy::instance()->get_all( $query_params );
2332
+		$categories = $count ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') : EEM_Term_Taxonomy::instance()->get_all($query_params);
2333 2333
 
2334 2334
 		return $categories;
2335 2335
 	}
Please login to merge, or discard this patch.
admin_pages/general_settings/General_Settings_Admin_Page.core.php 1 patch
Spacing   +280 added lines, -281 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
 /**
@@ -40,8 +40,8 @@  discard block
 block discarded – undo
40 40
 
41 41
 
42 42
 
43
-	public function __construct( $routing = TRUE ) {
44
-		parent::__construct( $routing );
43
+	public function __construct($routing = TRUE) {
44
+		parent::__construct($routing);
45 45
 	}
46 46
 
47 47
 
@@ -57,10 +57,10 @@  discard block
 block discarded – undo
57 57
 
58 58
 
59 59
 	protected function _ajax_hooks() {
60
-		add_action('wp_ajax_espresso_display_country_settings', array( $this, 'display_country_settings'));
61
-		add_action('wp_ajax_espresso_display_country_states', array( $this, 'display_country_states'));
62
-		add_action('wp_ajax_espresso_delete_state', array( $this, 'delete_state'), 10, 3 );
63
-		add_action('wp_ajax_espresso_add_new_state', array( $this, 'add_new_state'));
60
+		add_action('wp_ajax_espresso_display_country_settings', array($this, 'display_country_settings'));
61
+		add_action('wp_ajax_espresso_display_country_states', array($this, 'display_country_states'));
62
+		add_action('wp_ajax_espresso_delete_state', array($this, 'delete_state'), 10, 3);
63
+		add_action('wp_ajax_espresso_add_new_state', array($this, 'add_new_state'));
64 64
 	}
65 65
 
66 66
 
@@ -153,14 +153,14 @@  discard block
 block discarded – undo
153 153
 					'label' => __('Critical Pages', 'event_espresso'),
154 154
 					'order' => 50
155 155
 					),
156
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
156
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
157 157
                			'help_tabs' => array(
158 158
 					'general_settings_critical_pages_help_tab' => array(
159 159
 						'title' => __('Critical Pages', 'event_espresso'),
160 160
 						'filename' => 'general_settings_critical_pages'
161 161
 						)
162 162
 					),
163
-				'help_tour' => array( 'Critical_Pages_Help_Tour' ),
163
+				'help_tour' => array('Critical_Pages_Help_Tour'),
164 164
 				'require_nonce' => FALSE
165 165
 				),
166 166
 			'default' => array(
@@ -174,8 +174,8 @@  discard block
 block discarded – undo
174 174
 						'filename' => 'general_settings_your_organization'
175 175
 						)
176 176
 					),
177
-				'help_tour' => array( 'Your_Organization_Help_Tour' ),
178
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
177
+				'help_tour' => array('Your_Organization_Help_Tour'),
178
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
179 179
 				'require_nonce' => FALSE
180 180
 				),
181 181
 			'admin_option_settings' => array(
@@ -183,14 +183,14 @@  discard block
 block discarded – undo
183 183
 					'label' => __('Admin Options', 'event_espresso'),
184 184
 					'order' => 60
185 185
 					),
186
-				'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
186
+				'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
187 187
                 			'help_tabs' => array(
188 188
 					'general_settings_admin_options_help_tab' => array(
189 189
 						'title' => __('Admin Options', 'event_espresso'),
190 190
 						'filename' => 'general_settings_admin_options'
191 191
 						)
192 192
 					),
193
-				'help_tour' => array( 'Admin_Options_Help_Tour' ),
193
+				'help_tour' => array('Admin_Options_Help_Tour'),
194 194
 				'require_nonce' => FALSE
195 195
 				),
196 196
 			'country_settings' => array(
@@ -204,7 +204,7 @@  discard block
 block discarded – undo
204 204
 						'filename' => 'general_settings_countries'
205 205
 						)
206 206
 					),
207
-				'help_tour' => array( 'Countries_Help_Tour' ),
207
+				'help_tour' => array('Countries_Help_Tour'),
208 208
 				'require_nonce' => FALSE
209 209
 				)
210 210
 			);
@@ -222,11 +222,11 @@  discard block
 block discarded – undo
222 222
 	}
223 223
 
224 224
 	public function admin_init() {
225
-		EE_Registry::$i18n_js_strings[ 'invalid_server_response' ] = __( 'An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso' );
226
-		EE_Registry::$i18n_js_strings[ 'error_occurred' ] = __( 'An error occurred! Please refresh the page and try again.', 'event_espresso' );
227
-		EE_Registry::$i18n_js_strings[ 'confirm_delete_state' ] = __( 'Are you sure you want to delete this State / Province?', 'event_espresso' );
228
-		$protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://';
229
-		EE_Registry::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php?page=espresso_general_settings', $protocol );
225
+		EE_Registry::$i18n_js_strings['invalid_server_response'] = __('An error occurred! Your request may have been processed, but a valid response from the server was not received. Please refresh the page and try again.', 'event_espresso');
226
+		EE_Registry::$i18n_js_strings['error_occurred'] = __('An error occurred! Please refresh the page and try again.', 'event_espresso');
227
+		EE_Registry::$i18n_js_strings['confirm_delete_state'] = __('Are you sure you want to delete this State / Province?', 'event_espresso');
228
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
229
+		EE_Registry::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php?page=espresso_general_settings', $protocol);
230 230
 	}
231 231
 
232 232
 	public function admin_notices() {}
@@ -239,21 +239,21 @@  discard block
 block discarded – undo
239 239
 		//scripts
240 240
 		wp_enqueue_script('media-upload');
241 241
 		wp_enqueue_script('thickbox');
242
-		wp_register_script( 'organization_settings', GEN_SET_ASSETS_URL . 'your_organization_settings.js', array( 'jquery','media-upload','thickbox' ), EVENT_ESPRESSO_VERSION, TRUE );
243
-		wp_register_style( 'organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION );
244
-		wp_enqueue_script( 'organization_settings' );
245
-		wp_enqueue_style( 'organization-css' );
246
-		$confirm_image_delete = array( 'text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', 'event_espresso'));
247
-		wp_localize_script( 'organization_settings', 'confirm_image_delete', $confirm_image_delete );
242
+		wp_register_script('organization_settings', GEN_SET_ASSETS_URL.'your_organization_settings.js', array('jquery', 'media-upload', 'thickbox'), EVENT_ESPRESSO_VERSION, TRUE);
243
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
244
+		wp_enqueue_script('organization_settings');
245
+		wp_enqueue_style('organization-css');
246
+		$confirm_image_delete = array('text' => __('Do you really want to delete this image? Please remember to save your settings to complete the removal.', 'event_espresso'));
247
+		wp_localize_script('organization_settings', 'confirm_image_delete', $confirm_image_delete);
248 248
 
249 249
 	}
250 250
 
251 251
 	public function load_scripts_styles_country_settings() {
252 252
 		//scripts
253
-		wp_register_script( 'gen_settings_countries', GEN_SET_ASSETS_URL . 'gen_settings_countries.js', array( 'ee_admin_js' ), EVENT_ESPRESSO_VERSION, TRUE );
254
-		wp_register_style( 'organization-css', GEN_SET_ASSETS_URL . 'organization.css', array(), EVENT_ESPRESSO_VERSION );
255
-		wp_enqueue_script( 'gen_settings_countries' );
256
-		wp_enqueue_style( 'organization-css' );
253
+		wp_register_script('gen_settings_countries', GEN_SET_ASSETS_URL.'gen_settings_countries.js', array('ee_admin_js'), EVENT_ESPRESSO_VERSION, TRUE);
254
+		wp_register_style('organization-css', GEN_SET_ASSETS_URL.'organization.css', array(), EVENT_ESPRESSO_VERSION);
255
+		wp_enqueue_script('gen_settings_countries');
256
+		wp_enqueue_style('organization-css');
257 257
 
258 258
 	}
259 259
 
@@ -270,31 +270,31 @@  discard block
 block discarded – undo
270 270
 		$this->_transient_garbage_collection();
271 271
 		$this->_template_args['values'] = $this->_yes_no_values;
272 272
 
273
-		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id ) ?EE_Registry::instance()->CFG->core->reg_page_id : NULL;
274
-		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id ) ? get_page(EE_Registry::instance()->CFG->core->reg_page_id ) : FALSE;
273
+		$this->_template_args['reg_page_id'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) ? EE_Registry::instance()->CFG->core->reg_page_id : NULL;
274
+		$this->_template_args['reg_page_obj'] = isset(EE_Registry::instance()->CFG->core->reg_page_id) ? get_page(EE_Registry::instance()->CFG->core->reg_page_id) : FALSE;
275 275
 
276
-		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) ?EE_Registry::instance()->CFG->core->txn_page_id : NULL;
277
-		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id ) ? get_page(EE_Registry::instance()->CFG->core->txn_page_id ) : FALSE;
276
+		$this->_template_args['txn_page_id'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) ? EE_Registry::instance()->CFG->core->txn_page_id : NULL;
277
+		$this->_template_args['txn_page_obj'] = isset(EE_Registry::instance()->CFG->core->txn_page_id) ? get_page(EE_Registry::instance()->CFG->core->txn_page_id) : FALSE;
278 278
 
279
-		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id ) ?EE_Registry::instance()->CFG->core->thank_you_page_id : NULL;
280
-		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id ) ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id ) : FALSE;
279
+		$this->_template_args['thank_you_page_id'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) ? EE_Registry::instance()->CFG->core->thank_you_page_id : NULL;
280
+		$this->_template_args['thank_you_page_obj'] = isset(EE_Registry::instance()->CFG->core->thank_you_page_id) ? get_page(EE_Registry::instance()->CFG->core->thank_you_page_id) : FALSE;
281 281
 
282
-		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id ) ?EE_Registry::instance()->CFG->core->cancel_page_id : NULL;
283
-		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id ) ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id ) : FALSE;
282
+		$this->_template_args['cancel_page_id'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) ? EE_Registry::instance()->CFG->core->cancel_page_id : NULL;
283
+		$this->_template_args['cancel_page_obj'] = isset(EE_Registry::instance()->CFG->core->cancel_page_id) ? get_page(EE_Registry::instance()->CFG->core->cancel_page_id) : FALSE;
284 284
 
285
-		$this->_set_add_edit_form_tags( 'update_espresso_page_settings' );
286
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
287
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'espresso_page_settings.template.php', $this->_template_args, TRUE );
285
+		$this->_set_add_edit_form_tags('update_espresso_page_settings');
286
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
287
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'espresso_page_settings.template.php', $this->_template_args, TRUE);
288 288
 		$this->display_admin_page_with_sidebar();
289 289
 
290 290
 	}
291 291
 
292 292
 	protected function _update_espresso_page_settings() {
293 293
 		// capture incoming request data
294
-		$reg_page_id = isset( $this->_req_data['reg_page_id'] ) ? absint( $this->_req_data['reg_page_id'] ) : EE_Registry::instance()->CFG->core->reg_page_id;
295
-		$txn_page_id = isset( $this->_req_data['txn_page_id'] ) ? absint( $this->_req_data['txn_page_id'] ) : EE_Registry::instance()->CFG->core->txn_page_id;
296
-		$thank_you_page_id = isset( $this->_req_data['thank_you_page_id'] ) ? absint( $this->_req_data['thank_you_page_id'] ) : EE_Registry::instance()->CFG->core->thank_you_page_id;
297
-		$cancel_page_id = isset( $this->_req_data['cancel_page_id'] ) ? absint( $this->_req_data['cancel_page_id'] ) : EE_Registry::instance()->CFG->core->cancel_page_id;
294
+		$reg_page_id = isset($this->_req_data['reg_page_id']) ? absint($this->_req_data['reg_page_id']) : EE_Registry::instance()->CFG->core->reg_page_id;
295
+		$txn_page_id = isset($this->_req_data['txn_page_id']) ? absint($this->_req_data['txn_page_id']) : EE_Registry::instance()->CFG->core->txn_page_id;
296
+		$thank_you_page_id = isset($this->_req_data['thank_you_page_id']) ? absint($this->_req_data['thank_you_page_id']) : EE_Registry::instance()->CFG->core->thank_you_page_id;
297
+		$cancel_page_id = isset($this->_req_data['cancel_page_id']) ? absint($this->_req_data['cancel_page_id']) : EE_Registry::instance()->CFG->core->cancel_page_id;
298 298
 		// pack critical_pages into an array
299 299
 		$critical_pages = array(
300 300
 			'reg_page_id' 				=> $reg_page_id,
@@ -302,17 +302,17 @@  discard block
 block discarded – undo
302 302
 			'thank_you_page_id' 	=> $thank_you_page_id,
303 303
 			'cancel_page_id' 		=> $cancel_page_id
304 304
 		);
305
-		foreach ( $critical_pages as $critical_page_name => $critical_page_id ) {
305
+		foreach ($critical_pages as $critical_page_name => $critical_page_id) {
306 306
 			// has the page changed ?
307
-			if ( EE_Registry::instance()->CFG->core->{$critical_page_name} != $critical_page_id ) {
307
+			if (EE_Registry::instance()->CFG->core->{$critical_page_name} != $critical_page_id) {
308 308
 				// grab post object for old page
309
-				$post = get_post( EE_Registry::instance()->CFG->core->{$critical_page_name} );
309
+				$post = get_post(EE_Registry::instance()->CFG->core->{$critical_page_name} );
310 310
 				// update post shortcodes for old page
311
-				EE_Admin::parse_post_content_on_save( $critical_page_id, $post );
311
+				EE_Admin::parse_post_content_on_save($critical_page_id, $post);
312 312
 				// grab post object for new page
313
-				$post = get_post( $critical_page_id );
313
+				$post = get_post($critical_page_id);
314 314
 				// update post shortcodes for new page
315
-				EE_Admin::parse_post_content_on_save( $critical_page_id, $post );
315
+				EE_Admin::parse_post_content_on_save($critical_page_id, $post);
316 316
 			}
317 317
 		}
318 318
 		// set page IDs
@@ -321,14 +321,14 @@  discard block
 block discarded – undo
321 321
 		EE_Registry::instance()->CFG->core->thank_you_page_id = $thank_you_page_id;
322 322
 		EE_Registry::instance()->CFG->core->cancel_page_id = $cancel_page_id;
323 323
 
324
-		EE_Registry::instance()->CFG->core = apply_filters( 'FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', EE_Registry::instance()->CFG->core, $this->_req_data );
324
+		EE_Registry::instance()->CFG->core = apply_filters('FHEE__General_Settings_Admin_Page___update_espresso_page_settings__CFG_core', EE_Registry::instance()->CFG->core, $this->_req_data);
325 325
 
326 326
 		$what = __('Critical Pages & Shortcodes', 'event_espresso');
327
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->core, __FILE__, __FUNCTION__, __LINE__ );
327
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->core, __FILE__, __FUNCTION__, __LINE__);
328 328
 		$query_args = array(
329 329
 			'action' => 'critical_pages'
330 330
 			);
331
-		$this->_redirect_after_action( FALSE, '', '', $query_args, TRUE );
331
+		$this->_redirect_after_action(FALSE, '', '', $query_args, TRUE);
332 332
 
333 333
 	}
334 334
 
@@ -343,34 +343,34 @@  discard block
 block discarded – undo
343 343
 
344 344
 	protected function _your_organization_settings() {
345 345
 
346
-		$this->_template_args['site_license_key'] = isset( EE_Registry::instance()->NET_CFG->core->site_license_key ) ? EE_Registry::instance()->NET_CFG->core->get_pretty( 'site_license_key' ) : '';
347
-		$this->_template_args['organization_name'] = isset( EE_Registry::instance()->CFG->organization->name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : '';
348
-		$this->_template_args['organization_address_1'] = isset( EE_Registry::instance()->CFG->organization->address_1 ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'address_1' ) : '';
349
-		$this->_template_args['organization_address_2'] = isset( EE_Registry::instance()->CFG->organization->address_2 ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'address_2' ) : '';
350
-		$this->_template_args['organization_city'] = isset( EE_Registry::instance()->CFG->organization->city ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'city' ) : '';
351
-		$this->_template_args['organization_zip'] = isset( EE_Registry::instance()->CFG->organization->zip ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'zip' ) : '';
352
-		$this->_template_args['organization_email'] = isset( EE_Registry::instance()->CFG->organization->email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : '';
353
-		$this->_template_args['organization_phone'] = isset( EE_Registry::instance()->CFG->organization->phone ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'phone' ) : '';
354
-		$this->_template_args['organization_vat'] = isset( EE_Registry::instance()->CFG->organization->vat ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'vat' ) : '';
355
-		$this->_template_args['currency_sign'] = isset( EE_Registry::instance()->CFG->currency->sign ) ? EE_Registry::instance()->CFG->currency->get_pretty( 'sign' ) : '$';
356
-		$this->_template_args['organization_logo_url'] = isset( EE_Registry::instance()->CFG->organization->logo_url ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ) : FALSE;
357
-		$this->_template_args['organization_facebook'] = isset( EE_Registry::instance()->CFG->organization->facebook ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ) : '';
358
-		$this->_template_args['organization_twitter'] = isset( EE_Registry::instance()->CFG->organization->twitter ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ) : '';
359
-		$this->_template_args['organization_linkedin'] = isset( EE_Registry::instance()->CFG->organization->linkedin ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ) : '';
360
-		$this->_template_args['organization_pinterest'] = isset( EE_Registry::instance()->CFG->organization->pinterest ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ) : '';
361
-		$this->_template_args['organization_google'] = isset( EE_Registry::instance()->CFG->organization->google ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'google' ) : '';
362
-		$this->_template_args['organization_instagram'] = isset( EE_Registry::instance()->CFG->organization->instagram ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ) : '';
346
+		$this->_template_args['site_license_key'] = isset(EE_Registry::instance()->NET_CFG->core->site_license_key) ? EE_Registry::instance()->NET_CFG->core->get_pretty('site_license_key') : '';
347
+		$this->_template_args['organization_name'] = isset(EE_Registry::instance()->CFG->organization->name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : '';
348
+		$this->_template_args['organization_address_1'] = isset(EE_Registry::instance()->CFG->organization->address_1) ? EE_Registry::instance()->CFG->organization->get_pretty('address_1') : '';
349
+		$this->_template_args['organization_address_2'] = isset(EE_Registry::instance()->CFG->organization->address_2) ? EE_Registry::instance()->CFG->organization->get_pretty('address_2') : '';
350
+		$this->_template_args['organization_city'] = isset(EE_Registry::instance()->CFG->organization->city) ? EE_Registry::instance()->CFG->organization->get_pretty('city') : '';
351
+		$this->_template_args['organization_zip'] = isset(EE_Registry::instance()->CFG->organization->zip) ? EE_Registry::instance()->CFG->organization->get_pretty('zip') : '';
352
+		$this->_template_args['organization_email'] = isset(EE_Registry::instance()->CFG->organization->email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : '';
353
+		$this->_template_args['organization_phone'] = isset(EE_Registry::instance()->CFG->organization->phone) ? EE_Registry::instance()->CFG->organization->get_pretty('phone') : '';
354
+		$this->_template_args['organization_vat'] = isset(EE_Registry::instance()->CFG->organization->vat) ? EE_Registry::instance()->CFG->organization->get_pretty('vat') : '';
355
+		$this->_template_args['currency_sign'] = isset(EE_Registry::instance()->CFG->currency->sign) ? EE_Registry::instance()->CFG->currency->get_pretty('sign') : '$';
356
+		$this->_template_args['organization_logo_url'] = isset(EE_Registry::instance()->CFG->organization->logo_url) ? EE_Registry::instance()->CFG->organization->get_pretty('logo_url') : FALSE;
357
+		$this->_template_args['organization_facebook'] = isset(EE_Registry::instance()->CFG->organization->facebook) ? EE_Registry::instance()->CFG->organization->get_pretty('facebook') : '';
358
+		$this->_template_args['organization_twitter'] = isset(EE_Registry::instance()->CFG->organization->twitter) ? EE_Registry::instance()->CFG->organization->get_pretty('twitter') : '';
359
+		$this->_template_args['organization_linkedin'] = isset(EE_Registry::instance()->CFG->organization->linkedin) ? EE_Registry::instance()->CFG->organization->get_pretty('linkedin') : '';
360
+		$this->_template_args['organization_pinterest'] = isset(EE_Registry::instance()->CFG->organization->pinterest) ? EE_Registry::instance()->CFG->organization->get_pretty('pinterest') : '';
361
+		$this->_template_args['organization_google'] = isset(EE_Registry::instance()->CFG->organization->google) ? EE_Registry::instance()->CFG->organization->get_pretty('google') : '';
362
+		$this->_template_args['organization_instagram'] = isset(EE_Registry::instance()->CFG->organization->instagram) ? EE_Registry::instance()->CFG->organization->get_pretty('instagram') : '';
363 363
 		//UXIP settings
364
-		$this->_template_args['ee_ueip_optin'] = isset( EE_Registry::instance()->CFG->core->ee_ueip_optin ) ? EE_Registry::instance()->CFG->core->get_pretty( 'ee_ueip_optin' ) : TRUE;
364
+		$this->_template_args['ee_ueip_optin'] = isset(EE_Registry::instance()->CFG->core->ee_ueip_optin) ? EE_Registry::instance()->CFG->core->get_pretty('ee_ueip_optin') : TRUE;
365 365
 
366
-		$STA_ID = isset( EE_Registry::instance()->CFG->organization->STA_ID ) ? EE_Registry::instance()->CFG->organization->STA_ID : 4;
366
+		$STA_ID = isset(EE_Registry::instance()->CFG->organization->STA_ID) ? EE_Registry::instance()->CFG->organization->STA_ID : 4;
367 367
 		$this->_template_args['states'] = new EE_Question_Form_Input(
368
-				EE_Question::new_instance ( array(
368
+				EE_Question::new_instance(array(
369 369
 					'QST_ID'=> 0,
370 370
 					'QST_display_text'=> __('State/Province', 'event_espresso'),
371 371
 					'QST_system'=>'admin-state'
372 372
 				)),
373
-				EE_Answer::new_instance ( array(
373
+				EE_Answer::new_instance(array(
374 374
 					'ANS_ID' => 0,
375 375
 					'ANS_value' => $STA_ID
376 376
 				)),
@@ -382,14 +382,14 @@  discard block
 block discarded – undo
382 382
 				)
383 383
 			);
384 384
 
385
-		$CNT_ISO = isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
385
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
386 386
 		$this->_template_args['countries'] = new EE_Question_Form_Input(
387
-				EE_Question::new_instance ( array(
387
+				EE_Question::new_instance(array(
388 388
 					'QST_ID'=> 0,
389 389
 					'QST_display_text'=> __('Country', 'event_espresso'),
390 390
 					'QST_system'=>'admin-country'
391 391
 				)),
392
-				EE_Answer::new_instance ( array(
392
+				EE_Answer::new_instance(array(
393 393
 					'ANS_ID' => 0,
394 394
 					'ANS_value' => $CNT_ISO
395 395
 				)),
@@ -401,51 +401,51 @@  discard block
 block discarded – undo
401 401
 				)
402 402
 			);
403 403
 
404
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
405
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
404
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
405
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
406 406
 
407 407
 		//PUE verification stuff
408
-		$ver_option_key = 'puvererr_' . basename( EE_PLUGIN_BASENAME );
409
-		$verify_fail = get_option( $ver_option_key );
410
-		$this->_template_args['site_license_key_verified'] = $verify_fail || !empty( $verify_fail ) || ( empty( $this->_template_args['site_license_key'] ) && empty( $verify_fail ) )? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
408
+		$ver_option_key = 'puvererr_'.basename(EE_PLUGIN_BASENAME);
409
+		$verify_fail = get_option($ver_option_key);
410
+		$this->_template_args['site_license_key_verified'] = $verify_fail || ! empty($verify_fail) || (empty($this->_template_args['site_license_key']) && empty($verify_fail)) ? '<span class="dashicons dashicons-admin-network ee-icon-color-ee-red ee-icon-size-20"></span>' : '<span class="dashicons dashicons-admin-network ee-icon-color-ee-green ee-icon-size-20"></span>';
411 411
 
412
-		$this->_set_add_edit_form_tags( 'update_your_organization_settings' );
413
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
414
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'your_organization_settings.template.php', $this->_template_args, TRUE );
412
+		$this->_set_add_edit_form_tags('update_your_organization_settings');
413
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
414
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'your_organization_settings.template.php', $this->_template_args, TRUE);
415 415
 
416 416
 		$this->display_admin_page_with_sidebar();
417 417
 	}
418 418
 
419 419
 	protected function _update_your_organization_settings() {
420
-		if ( is_main_site() )
421
-			EE_Registry::instance()->NET_CFG->core->site_license_key = isset( $this->_req_data['site_license_key'] ) ? sanitize_text_field( $this->_req_data['site_license_key'] ) : EE_Registry::instance()->NET_CFG->core->site_license_key;
422
-		EE_Registry::instance()->CFG->organization->name = isset( $this->_req_data['organization_name'] ) ? sanitize_text_field( $this->_req_data['organization_name'] ) : EE_Registry::instance()->CFG->organization->name;
423
-		EE_Registry::instance()->CFG->organization->address_1 = isset( $this->_req_data['organization_address_1'] ) ? sanitize_text_field( $this->_req_data['organization_address_1'] ) : EE_Registry::instance()->CFG->organization->address_1;
424
-		EE_Registry::instance()->CFG->organization->address_2 = isset( $this->_req_data['organization_address_2'] ) ? sanitize_text_field( $this->_req_data['organization_address_2'] ) : EE_Registry::instance()->CFG->organization->address_2;
425
-		EE_Registry::instance()->CFG->organization->city = isset( $this->_req_data['organization_city'] ) ? sanitize_text_field( $this->_req_data['organization_city'] ) : EE_Registry::instance()->CFG->organization->city;
426
-		EE_Registry::instance()->CFG->organization->STA_ID = isset( $this->_req_data['organization_state'] ) ? absint( $this->_req_data['organization_state'] ) : EE_Registry::instance()->CFG->organization->STA_ID;
427
-		EE_Registry::instance()->CFG->organization->CNT_ISO = isset( $this->_req_data['organization_country'] ) ? sanitize_text_field( $this->_req_data['organization_country'] ) : EE_Registry::instance()->CFG->organization->CNT_ISO;
428
-		EE_Registry::instance()->CFG->organization->zip = isset( $this->_req_data['organization_zip'] ) ? sanitize_text_field( $this->_req_data['organization_zip'] ) : EE_Registry::instance()->CFG->organization->zip;
429
-		EE_Registry::instance()->CFG->organization->email = isset( $this->_req_data['organization_email'] ) ? sanitize_email( $this->_req_data['organization_email'] ) : EE_Registry::instance()->CFG->organization->email;
430
-		EE_Registry::instance()->CFG->organization->vat = isset( $this->_req_data['organization_vat'] ) ? sanitize_text_field( $this->_req_data['organization_vat'] ) : EE_Registry::instance()->CFG->organization->vat;
431
-		EE_Registry::instance()->CFG->organization->phone = isset( $this->_req_data['organization_phone'] ) ? sanitize_text_field( $this->_req_data['organization_phone'] ) : EE_Registry::instance()->CFG->organization->phone;
432
-		EE_Registry::instance()->CFG->organization->logo_url = isset( $this->_req_data['organization_logo_url'] ) ? esc_url_raw( $this->_req_data['organization_logo_url'] ) : EE_Registry::instance()->CFG->organization->logo_url;
433
-		EE_Registry::instance()->CFG->organization->facebook = isset( $this->_req_data['organization_facebook'] ) ? esc_url_raw( $this->_req_data['organization_facebook'] ) : EE_Registry::instance()->CFG->organization->facebook;
434
-		EE_Registry::instance()->CFG->organization->twitter = isset( $this->_req_data['organization_twitter'] ) ? esc_url_raw( $this->_req_data['organization_twitter'] ) : EE_Registry::instance()->CFG->organization->twitter;
435
-		EE_Registry::instance()->CFG->organization->linkedin = isset( $this->_req_data['organization_linkedin'] ) ? esc_url_raw( $this->_req_data['organization_linkedin'] ) : EE_Registry::instance()->CFG->organization->linkedin;
436
-		EE_Registry::instance()->CFG->organization->pinterest = isset( $this->_req_data['organization_pinterest'] ) ? esc_url_raw( $this->_req_data['organization_pinterest'] ) : EE_Registry::instance()->CFG->organization->pinterest;
437
-		EE_Registry::instance()->CFG->organization->google = isset( $this->_req_data['organization_google'] ) ? esc_url_raw( $this->_req_data['organization_google'] ) : EE_Registry::instance()->CFG->organization->google;
438
-		EE_Registry::instance()->CFG->organization->instagram = isset( $this->_req_data['organization_instagram'] ) ? esc_url_raw( $this->_req_data['organization_instagram'] ) : EE_Registry::instance()->CFG->organization->instagram;
439
-		EE_Registry::instance()->CFG->core->ee_ueip_optin = isset( $this->_req_data['ueip_optin'] ) && !empty( $this->_req_data['ueip_optin'] ) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin;
440
-
441
-		EE_Registry::instance()->CFG->currency = new EE_Currency_Config( EE_Registry::instance()->CFG->organization->CNT_ISO );
442
-
443
-		EE_Registry::instance()->CFG = apply_filters( 'FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', EE_Registry::instance()->CFG );
420
+		if (is_main_site())
421
+			EE_Registry::instance()->NET_CFG->core->site_license_key = isset($this->_req_data['site_license_key']) ? sanitize_text_field($this->_req_data['site_license_key']) : EE_Registry::instance()->NET_CFG->core->site_license_key;
422
+		EE_Registry::instance()->CFG->organization->name = isset($this->_req_data['organization_name']) ? sanitize_text_field($this->_req_data['organization_name']) : EE_Registry::instance()->CFG->organization->name;
423
+		EE_Registry::instance()->CFG->organization->address_1 = isset($this->_req_data['organization_address_1']) ? sanitize_text_field($this->_req_data['organization_address_1']) : EE_Registry::instance()->CFG->organization->address_1;
424
+		EE_Registry::instance()->CFG->organization->address_2 = isset($this->_req_data['organization_address_2']) ? sanitize_text_field($this->_req_data['organization_address_2']) : EE_Registry::instance()->CFG->organization->address_2;
425
+		EE_Registry::instance()->CFG->organization->city = isset($this->_req_data['organization_city']) ? sanitize_text_field($this->_req_data['organization_city']) : EE_Registry::instance()->CFG->organization->city;
426
+		EE_Registry::instance()->CFG->organization->STA_ID = isset($this->_req_data['organization_state']) ? absint($this->_req_data['organization_state']) : EE_Registry::instance()->CFG->organization->STA_ID;
427
+		EE_Registry::instance()->CFG->organization->CNT_ISO = isset($this->_req_data['organization_country']) ? sanitize_text_field($this->_req_data['organization_country']) : EE_Registry::instance()->CFG->organization->CNT_ISO;
428
+		EE_Registry::instance()->CFG->organization->zip = isset($this->_req_data['organization_zip']) ? sanitize_text_field($this->_req_data['organization_zip']) : EE_Registry::instance()->CFG->organization->zip;
429
+		EE_Registry::instance()->CFG->organization->email = isset($this->_req_data['organization_email']) ? sanitize_email($this->_req_data['organization_email']) : EE_Registry::instance()->CFG->organization->email;
430
+		EE_Registry::instance()->CFG->organization->vat = isset($this->_req_data['organization_vat']) ? sanitize_text_field($this->_req_data['organization_vat']) : EE_Registry::instance()->CFG->organization->vat;
431
+		EE_Registry::instance()->CFG->organization->phone = isset($this->_req_data['organization_phone']) ? sanitize_text_field($this->_req_data['organization_phone']) : EE_Registry::instance()->CFG->organization->phone;
432
+		EE_Registry::instance()->CFG->organization->logo_url = isset($this->_req_data['organization_logo_url']) ? esc_url_raw($this->_req_data['organization_logo_url']) : EE_Registry::instance()->CFG->organization->logo_url;
433
+		EE_Registry::instance()->CFG->organization->facebook = isset($this->_req_data['organization_facebook']) ? esc_url_raw($this->_req_data['organization_facebook']) : EE_Registry::instance()->CFG->organization->facebook;
434
+		EE_Registry::instance()->CFG->organization->twitter = isset($this->_req_data['organization_twitter']) ? esc_url_raw($this->_req_data['organization_twitter']) : EE_Registry::instance()->CFG->organization->twitter;
435
+		EE_Registry::instance()->CFG->organization->linkedin = isset($this->_req_data['organization_linkedin']) ? esc_url_raw($this->_req_data['organization_linkedin']) : EE_Registry::instance()->CFG->organization->linkedin;
436
+		EE_Registry::instance()->CFG->organization->pinterest = isset($this->_req_data['organization_pinterest']) ? esc_url_raw($this->_req_data['organization_pinterest']) : EE_Registry::instance()->CFG->organization->pinterest;
437
+		EE_Registry::instance()->CFG->organization->google = isset($this->_req_data['organization_google']) ? esc_url_raw($this->_req_data['organization_google']) : EE_Registry::instance()->CFG->organization->google;
438
+		EE_Registry::instance()->CFG->organization->instagram = isset($this->_req_data['organization_instagram']) ? esc_url_raw($this->_req_data['organization_instagram']) : EE_Registry::instance()->CFG->organization->instagram;
439
+		EE_Registry::instance()->CFG->core->ee_ueip_optin = isset($this->_req_data['ueip_optin']) && ! empty($this->_req_data['ueip_optin']) ? $this->_req_data['ueip_optin'] : EE_Registry::instance()->CFG->core->ee_ueip_optin;
440
+
441
+		EE_Registry::instance()->CFG->currency = new EE_Currency_Config(EE_Registry::instance()->CFG->organization->CNT_ISO);
442
+
443
+		EE_Registry::instance()->CFG = apply_filters('FHEE__General_Settings_Admin_Page___update_your_organization_settings__CFG', EE_Registry::instance()->CFG);
444 444
 
445 445
 		$what = 'Your Organization Settings';
446
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__ );
446
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG, __FILE__, __FUNCTION__, __LINE__);
447 447
 
448
-		$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'default' ) );
448
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'default'));
449 449
 
450 450
 	}
451 451
 
@@ -456,36 +456,36 @@  discard block
 block discarded – undo
456 456
 	protected function _admin_option_settings() {
457 457
 
458 458
 		$this->_template_args['values'] = $this->_yes_no_values;
459
-		$this->_template_args['use_personnel_manager'] = isset( EE_Registry::instance()->CFG->admin->use_personnel_manager ) ? absint( EE_Registry::instance()->CFG->admin->use_personnel_manager ) : FALSE;
460
-		$this->_template_args['use_dashboard_widget'] = isset( EE_Registry::instance()->CFG->admin->use_dashboard_widget ) ? absint( EE_Registry::instance()->CFG->admin->use_dashboard_widget ) : TRUE;
461
-		$this->_template_args['events_in_dashboard'] = isset( EE_Registry::instance()->CFG->admin->events_in_dashboard ) ? absint( EE_Registry::instance()->CFG->admin->events_in_dashboard ) : 30;
462
-		$this->_template_args['use_event_timezones'] = isset( EE_Registry::instance()->CFG->admin->use_event_timezones ) ? absint( EE_Registry::instance()->CFG->admin->use_event_timezones ) : FALSE;
463
-		$this->_template_args['show_reg_footer'] = isset( EE_Registry::instance()->CFG->admin->show_reg_footer ) ? absint( EE_Registry::instance()->CFG->admin->show_reg_footer ) : TRUE;
464
-		$this->_template_args['affiliate_id'] = isset( EE_Registry::instance()->CFG->admin->affiliate_id ) ? EE_Registry::instance()->CFG->admin->get_pretty('affiliate_id') : '';
465
-		$this->_template_args['help_tour_activation'] = isset( EE_Registry::instance()->CFG->admin->help_tour_activation ) ? absint( EE_Registry::instance()->CFG->admin->help_tour_activation ): 1;
466
-
467
-		$this->_set_add_edit_form_tags( 'update_admin_option_settings' );
468
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
459
+		$this->_template_args['use_personnel_manager'] = isset(EE_Registry::instance()->CFG->admin->use_personnel_manager) ? absint(EE_Registry::instance()->CFG->admin->use_personnel_manager) : FALSE;
460
+		$this->_template_args['use_dashboard_widget'] = isset(EE_Registry::instance()->CFG->admin->use_dashboard_widget) ? absint(EE_Registry::instance()->CFG->admin->use_dashboard_widget) : TRUE;
461
+		$this->_template_args['events_in_dashboard'] = isset(EE_Registry::instance()->CFG->admin->events_in_dashboard) ? absint(EE_Registry::instance()->CFG->admin->events_in_dashboard) : 30;
462
+		$this->_template_args['use_event_timezones'] = isset(EE_Registry::instance()->CFG->admin->use_event_timezones) ? absint(EE_Registry::instance()->CFG->admin->use_event_timezones) : FALSE;
463
+		$this->_template_args['show_reg_footer'] = isset(EE_Registry::instance()->CFG->admin->show_reg_footer) ? absint(EE_Registry::instance()->CFG->admin->show_reg_footer) : TRUE;
464
+		$this->_template_args['affiliate_id'] = isset(EE_Registry::instance()->CFG->admin->affiliate_id) ? EE_Registry::instance()->CFG->admin->get_pretty('affiliate_id') : '';
465
+		$this->_template_args['help_tour_activation'] = isset(EE_Registry::instance()->CFG->admin->help_tour_activation) ? absint(EE_Registry::instance()->CFG->admin->help_tour_activation) : 1;
466
+
467
+		$this->_set_add_edit_form_tags('update_admin_option_settings');
468
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
469 469
 		$this->_template_args['template_args'] = $this->_template_args;
470
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'admin_option_settings.template.php', $this->_template_args, TRUE );
470
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'admin_option_settings.template.php', $this->_template_args, TRUE);
471 471
 		$this->display_admin_page_with_sidebar();
472 472
 	}
473 473
 
474 474
 	protected function _update_admin_option_settings() {
475
-		EE_Registry::instance()->CFG->admin->use_personnel_manager = isset( $this->_req_data['use_personnel_manager'] ) ? absint( $this->_req_data['use_personnel_manager'] ) : EE_Registry::instance()->CFG->admin->use_personnel_manager;
476
-		EE_Registry::instance()->CFG->admin->use_dashboard_widget = isset( $this->_req_data['use_dashboard_widget'] ) ? absint( $this->_req_data['use_dashboard_widget'] ) : EE_Registry::instance()->CFG->admin->use_dashboard_widget;
477
-		EE_Registry::instance()->CFG->admin->events_in_dashboard = isset( $this->_req_data['events_in_dashboard'] ) ? absint( $this->_req_data['events_in_dashboard'] ) : EE_Registry::instance()->CFG->admin->events_in_dashboard;
478
-		EE_Registry::instance()->CFG->admin->use_event_timezones = isset( $this->_req_data['use_event_timezones'] ) ? absint( $this->_req_data['use_event_timezones'] ) : EE_Registry::instance()->CFG->admin->use_event_timezones;
479
-		EE_Registry::instance()->CFG->admin->show_reg_footer = isset( $this->_req_data['show_reg_footer'] ) ? absint( $this->_req_data['show_reg_footer'] ) : EE_Registry::instance()->CFG->admin->show_reg_footer;
480
-		EE_Registry::instance()->CFG->admin->affiliate_id = isset( $this->_req_data['affiliate_id'] ) ? sanitize_text_field( $this->_req_data['affiliate_id'] ) : EE_Registry::instance()->CFG->admin->affiliate_id;
481
-		EE_Registry::instance()->CFG->admin->help_tour_activation = isset( $this->_req_data['help_tour_activation'] ) ? absint( $this->_req_data['help_tour_activation'] ) : EE_Registry::instance()->CFG->admin->help_tour_activation;
475
+		EE_Registry::instance()->CFG->admin->use_personnel_manager = isset($this->_req_data['use_personnel_manager']) ? absint($this->_req_data['use_personnel_manager']) : EE_Registry::instance()->CFG->admin->use_personnel_manager;
476
+		EE_Registry::instance()->CFG->admin->use_dashboard_widget = isset($this->_req_data['use_dashboard_widget']) ? absint($this->_req_data['use_dashboard_widget']) : EE_Registry::instance()->CFG->admin->use_dashboard_widget;
477
+		EE_Registry::instance()->CFG->admin->events_in_dashboard = isset($this->_req_data['events_in_dashboard']) ? absint($this->_req_data['events_in_dashboard']) : EE_Registry::instance()->CFG->admin->events_in_dashboard;
478
+		EE_Registry::instance()->CFG->admin->use_event_timezones = isset($this->_req_data['use_event_timezones']) ? absint($this->_req_data['use_event_timezones']) : EE_Registry::instance()->CFG->admin->use_event_timezones;
479
+		EE_Registry::instance()->CFG->admin->show_reg_footer = isset($this->_req_data['show_reg_footer']) ? absint($this->_req_data['show_reg_footer']) : EE_Registry::instance()->CFG->admin->show_reg_footer;
480
+		EE_Registry::instance()->CFG->admin->affiliate_id = isset($this->_req_data['affiliate_id']) ? sanitize_text_field($this->_req_data['affiliate_id']) : EE_Registry::instance()->CFG->admin->affiliate_id;
481
+		EE_Registry::instance()->CFG->admin->help_tour_activation = isset($this->_req_data['help_tour_activation']) ? absint($this->_req_data['help_tour_activation']) : EE_Registry::instance()->CFG->admin->help_tour_activation;
482 482
 
483
-		EE_Registry::instance()->CFG->admin = apply_filters( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', EE_Registry::instance()->CFG->admin );
483
+		EE_Registry::instance()->CFG->admin = apply_filters('FHEE__General_Settings_Admin_Page___update_admin_option_settings__CFG_admin', EE_Registry::instance()->CFG->admin);
484 484
 
485 485
 		$what = 'Admin Options';
486
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->admin, __FILE__, __FUNCTION__, __LINE__ );
487
-		$success = apply_filters( 'FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', $success );
488
-		$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'admin_option_settings' ) );
486
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->admin, __FILE__, __FUNCTION__, __LINE__);
487
+		$success = apply_filters('FHEE__General_Settings_Admin_Page___update_admin_option_settings__success', $success);
488
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'admin_option_settings'));
489 489
 
490 490
 	}
491 491
 
@@ -498,20 +498,20 @@  discard block
 block discarded – undo
498 498
 
499 499
 	protected function _country_settings() {
500 500
 
501
-		$CNT_ISO = isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
502
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : $CNT_ISO;
501
+		$CNT_ISO = isset(EE_Registry::instance()->CFG->organization->CNT_ISO) ? EE_Registry::instance()->CFG->organization->CNT_ISO : 'US';
502
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
503 503
 
504 504
 		//load field generator helper
505 505
 
506 506
 		$this->_template_args['values'] = $this->_yes_no_values;
507 507
 
508 508
 		$this->_template_args['countries'] = new EE_Question_Form_Input(
509
-				EE_Question::new_instance ( array(
509
+				EE_Question::new_instance(array(
510 510
 					'QST_ID'=> 0,
511 511
 					'QST_display_text'=> __('Select Country', 'event_espresso'),
512 512
 					'QST_system'=>'admin-country'
513 513
 				)),
514
-				EE_Answer::new_instance ( array(
514
+				EE_Answer::new_instance(array(
515 515
 					'ANS_ID' => 0,
516 516
 					'ANS_value' => $CNT_ISO
517 517
 				)),
@@ -524,14 +524,14 @@  discard block
 block discarded – undo
524 524
 			);
525 525
 //		EEH_Debug_Tools::printr( $this->_template_args['countries'], 'countries  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
526 526
 
527
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
528
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
527
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
528
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
529 529
 		$this->_template_args['country_details_settings'] = $this->display_country_settings();
530 530
 		$this->_template_args['country_states_settings'] = $this->display_country_states();
531 531
 
532
-		$this->_set_add_edit_form_tags( 'update_country_settings' );
533
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
534
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'countries_settings.template.php', $this->_template_args, TRUE );
532
+		$this->_set_add_edit_form_tags('update_country_settings');
533
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
534
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'countries_settings.template.php', $this->_template_args, TRUE);
535 535
 		$this->display_admin_page_with_no_sidebar();
536 536
 	}
537 537
 
@@ -544,43 +544,43 @@  discard block
 block discarded – undo
544 544
 	 * 		@param 	string 		$CNT_ISO
545 545
 	 * 		@return 		mixed		string | array
546 546
 	 */
547
-	public function display_country_settings( $CNT_ISO = '' ) {
547
+	public function display_country_settings($CNT_ISO = '') {
548 548
 
549
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : $CNT_ISO;
550
-		if ( ! $CNT_ISO ) {
549
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : $CNT_ISO;
550
+		if ( ! $CNT_ISO) {
551 551
 			return '';
552 552
 		}
553 553
 
554 554
 		// for ajax
555
-		remove_all_filters( 'FHEE__EEH_Form_Fields__label_html' );
556
-		remove_all_filters( 'FHEE__EEH_Form_Fields__input_html' );
557
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'country_form_field_label_wrap' ), 10, 2 );
558
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'country_form_field_input__wrap' ), 10, 2 );
559
-		$country = EEM_Country::instance()->get_one_by_ID( $CNT_ISO );
555
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
556
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
557
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'country_form_field_label_wrap'), 10, 2);
558
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'country_form_field_input__wrap'), 10, 2);
559
+		$country = EEM_Country::instance()->get_one_by_ID($CNT_ISO);
560 560
 		//EEH_Debug_Tools::printr( $country, '$country  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
561 561
 		$country_input_types = array(
562
-			'CNT_active' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE  ),
563
-			'CNT_ISO' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
564
-			'CNT_ISO3' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
565
-			'RGN_ID' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
566
-			'CNT_name' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'regular-text' ),
567
-			'CNT_cur_code' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
568
-			'CNT_cur_single' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'medium-text' ),
569
-			'CNT_cur_plural' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'medium-text' ),
570
-			'CNT_cur_sign' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text', 'htmlentities' => FALSE ),
571
-			'CNT_cur_sign_b4' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE ),
572
-			'CNT_cur_dec_plc' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => 0, 'text' => '' ), array( 'id' => 1, 'text' => '' ), array( 'id' => 2, 'text' => '' ), array( 'id' => 3, 'text' => '' ))),
573
-			'CNT_cur_dec_mrk' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => ',', 'text' => __(', (comma)', 'event_espresso')), array( 'id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE ),
574
-			'CNT_cur_thsnds' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => array( array( 'id' => ',', 'text' => __(', (comma)', 'event_espresso')), array( 'id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE ),
575
-			'CNT_tel_code' => array( 'type' => 'TEXT', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => 'small-text' ),
576
-			'CNT_is_EU' => array( 'type' => 'RADIO_BTN', 'input_name' => 'cntry[' . $CNT_ISO . ']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE  )
562
+			'CNT_active' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE),
563
+			'CNT_ISO' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
564
+			'CNT_ISO3' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
565
+			'RGN_ID' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
566
+			'CNT_name' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'regular-text'),
567
+			'CNT_cur_code' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
568
+			'CNT_cur_single' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'medium-text'),
569
+			'CNT_cur_plural' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'medium-text'),
570
+			'CNT_cur_sign' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text', 'htmlentities' => FALSE),
571
+			'CNT_cur_sign_b4' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE),
572
+			'CNT_cur_dec_plc' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => 0, 'text' => ''), array('id' => 1, 'text' => ''), array('id' => 2, 'text' => ''), array('id' => 3, 'text' => ''))),
573
+			'CNT_cur_dec_mrk' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => ',', 'text' => __(', (comma)', 'event_espresso')), array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE),
574
+			'CNT_cur_thsnds' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => array(array('id' => ',', 'text' => __(', (comma)', 'event_espresso')), array('id' => '.', 'text' => __('. (decimal)', 'event_espresso'))), 'use_desc_4_label' => TRUE),
575
+			'CNT_tel_code' => array('type' => 'TEXT', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => 'small-text'),
576
+			'CNT_is_EU' => array('type' => 'RADIO_BTN', 'input_name' => 'cntry['.$CNT_ISO.']', 'class' => '', 'options' => $this->_yes_no_values, 'use_desc_4_label' => TRUE)
577 577
 		);
578
-		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object( $country, $country_input_types );
579
-		$country_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'country_details_settings.template.php', $this->_template_args, TRUE );
578
+		$this->_template_args['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($country, $country_input_types);
579
+		$country_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'country_details_settings.template.php', $this->_template_args, TRUE);
580 580
 
581
-		if ( defined( 'DOING_AJAX' )) {
582
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
583
-			echo json_encode( array( 'return_data' => $country_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'] ));
581
+		if (defined('DOING_AJAX')) {
582
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
583
+			echo json_encode(array('return_data' => $country_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors']));
584 584
 			die();
585 585
 		} else {
586 586
 			return $country_details_settings;
@@ -598,49 +598,49 @@  discard block
 block discarded – undo
598 598
 	 * 		@param 	string 		$CNT_ISO
599 599
 	 * 		@return 		string
600 600
 	 */
601
-	public function display_country_states( $CNT_ISO = '' ) {
601
+	public function display_country_states($CNT_ISO = '') {
602 602
 
603
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? sanitize_text_field( $this->_req_data['country'] ) : $CNT_ISO;
603
+		$CNT_ISO = isset($this->_req_data['country']) ? sanitize_text_field($this->_req_data['country']) : $CNT_ISO;
604 604
 
605
-		if ( ! $CNT_ISO ) {
605
+		if ( ! $CNT_ISO) {
606 606
 			return '';
607 607
 		}
608 608
 		// for ajax
609
-		remove_all_filters( 'FHEE__EEH_Form_Fields__label_html' );
610
-		remove_all_filters( 'FHEE__EEH_Form_Fields__input_html' );
611
-		add_filter( 'FHEE__EEH_Form_Fields__label_html', array( $this, 'state_form_field_label_wrap' ), 10, 2 );
612
-		add_filter( 'FHEE__EEH_Form_Fields__input_html', array( $this, 'state_form_field_input__wrap' ), 10, 2 );
613
-		$states = EEM_State::instance()->get_all_states_for_these_countries( array( $CNT_ISO => $CNT_ISO ));
609
+		remove_all_filters('FHEE__EEH_Form_Fields__label_html');
610
+		remove_all_filters('FHEE__EEH_Form_Fields__input_html');
611
+		add_filter('FHEE__EEH_Form_Fields__label_html', array($this, 'state_form_field_label_wrap'), 10, 2);
612
+		add_filter('FHEE__EEH_Form_Fields__input_html', array($this, 'state_form_field_input__wrap'), 10, 2);
613
+		$states = EEM_State::instance()->get_all_states_for_these_countries(array($CNT_ISO => $CNT_ISO));
614 614
 
615 615
 //			echo '<h4>$CNT_ISO : ' . $CNT_ISO . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
616 616
 //			global $wpdb;
617 617
 //			echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
618 618
 //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
619
-		if ( $states ) {
620
-			foreach ( $states as $STA_ID => $state ) {
621
-				if ( $state instanceof EE_State ) {
619
+		if ($states) {
620
+			foreach ($states as $STA_ID => $state) {
621
+				if ($state instanceof EE_State) {
622 622
 					//STA_abbrev 	STA_name 	STA_active
623 623
 					$state_input_types = array(
624
-						'STA_abbrev' => array( 'type' => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'mid-text' ),
625
-						'STA_name'   => array( 'type'       => 'TEXT', 'input_name' => 'states[' . $STA_ID . ']', 'class' => 'regular-text' ),
626
-						'STA_active' => array( 'type' => 'RADIO_BTN', 'input_name' => 'states[' . $STA_ID . ']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true )
624
+						'STA_abbrev' => array('type' => 'TEXT', 'input_name' => 'states['.$STA_ID.']', 'class' => 'mid-text'),
625
+						'STA_name'   => array('type'       => 'TEXT', 'input_name' => 'states['.$STA_ID.']', 'class' => 'regular-text'),
626
+						'STA_active' => array('type' => 'RADIO_BTN', 'input_name' => 'states['.$STA_ID.']', 'options' => $this->_yes_no_values, 'use_desc_4_label' => true)
627 627
 					);
628
-					$this->_template_args[ 'states' ][ $STA_ID ][ 'inputs' ] = EE_Question_Form_Input::generate_question_form_inputs_for_object( $state, $state_input_types );
629
-					$query_args = array( 'action'     => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev() );
630
-					$this->_template_args[ 'states' ][ $STA_ID ][ 'delete_state_url' ] = EE_Admin_Page::add_query_args_and_nonce( $query_args, GEN_SET_ADMIN_URL );
628
+					$this->_template_args['states'][$STA_ID]['inputs'] = EE_Question_Form_Input::generate_question_form_inputs_for_object($state, $state_input_types);
629
+					$query_args = array('action'     => 'delete_state', 'STA_ID' => $STA_ID, 'CNT_ISO' => $CNT_ISO, 'STA_abbrev' => $state->abbrev());
630
+					$this->_template_args['states'][$STA_ID]['delete_state_url'] = EE_Admin_Page::add_query_args_and_nonce($query_args, GEN_SET_ADMIN_URL);
631 631
 				}
632 632
 			}
633 633
 		} else {
634 634
 			$this->_template_args['states'] = FALSE;
635 635
 		}
636 636
 //		EEH_Debug_Tools::printr( $this->_template_args['states'], 'states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
637
-		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce( array( 'action' => 'add_new_state' ),  GEN_SET_ADMIN_URL );
637
+		$this->_template_args['add_new_state_url'] = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'add_new_state'), GEN_SET_ADMIN_URL);
638 638
 
639
-		$state_details_settings = EEH_Template::display_template( GEN_SET_TEMPLATE_PATH . 'state_details_settings.template.php', $this->_template_args, TRUE );
639
+		$state_details_settings = EEH_Template::display_template(GEN_SET_TEMPLATE_PATH.'state_details_settings.template.php', $this->_template_args, TRUE);
640 640
 
641
-		if ( defined( 'DOING_AJAX' )) {
642
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
643
-			echo json_encode( array( 'return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors'] ));
641
+		if (defined('DOING_AJAX')) {
642
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
643
+			echo json_encode(array('return_data' => $state_details_settings, 'success' => $notices['success'], 'errors' => $notices['errors']));
644 644
 			die();
645 645
 		} else {
646 646
 			return $state_details_settings;
@@ -661,40 +661,39 @@  discard block
 block discarded – undo
661 661
 
662 662
 		$success = TRUE;
663 663
 
664
-		$CNT_ISO = isset( $this->_req_data['CNT_ISO'] ) ? strtoupper( sanitize_text_field( $this->_req_data['CNT_ISO'] )) : FALSE;
665
-		if ( ! $CNT_ISO ) {
666
-			EE_Error::add_error( __( 'No Country ISO code or an invalid Country ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
664
+		$CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : FALSE;
665
+		if ( ! $CNT_ISO) {
666
+			EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
667 667
 			$success = FALSE;
668 668
 		}
669
-		$STA_abbrev = isset( $this->_req_data['STA_abbrev'] ) ? sanitize_text_field( $this->_req_data['STA_abbrev'] ) : FALSE;
670
-		if ( ! $STA_abbrev ) {
671
-			EE_Error::add_error( __( 'No State ISO code or an invalid State ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
669
+		$STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : FALSE;
670
+		if ( ! $STA_abbrev) {
671
+			EE_Error::add_error(__('No State ISO code or an invalid State ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
672 672
 			$success = FALSE;
673 673
 		}
674
-		$STA_name = isset( $this->_req_data['STA_name'] ) ?  sanitize_text_field( $this->_req_data['STA_name'] ) :
675
-			FALSE;
676
-		if ( ! $STA_name ) {
677
-			EE_Error::add_error( __( 'No State name or an invalid State name was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
674
+		$STA_name = isset($this->_req_data['STA_name']) ? sanitize_text_field($this->_req_data['STA_name']) : FALSE;
675
+		if ( ! $STA_name) {
676
+			EE_Error::add_error(__('No State name or an invalid State name was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
678 677
 			$success = FALSE;
679 678
 		}
680 679
 
681
-		if ( $success ) {
680
+		if ($success) {
682 681
 			$cols_n_values = array(
683 682
 				'CNT_ISO' => $CNT_ISO,
684 683
 				'STA_abbrev' => $STA_abbrev,
685 684
 				'STA_name' => $STA_name,
686 685
 				'STA_active' => TRUE
687 686
 			);
688
-			$success = EEM_State::instance()->insert ( $cols_n_values );
689
-			EE_Error::add_success( __( 'The State was added successfully.', 'event_espresso' ) );
687
+			$success = EEM_State::instance()->insert($cols_n_values);
688
+			EE_Error::add_success(__('The State was added successfully.', 'event_espresso'));
690 689
 		}
691 690
 
692
-		if ( defined( 'DOING_AJAX' )) {
693
-			$notices = EE_Error::get_notices( FALSE, FALSE, FALSE );
694
-			echo json_encode( array_merge( $notices, array( 'return_data' => $CNT_ISO ) ) );
691
+		if (defined('DOING_AJAX')) {
692
+			$notices = EE_Error::get_notices(FALSE, FALSE, FALSE);
693
+			echo json_encode(array_merge($notices, array('return_data' => $CNT_ISO)));
695 694
 			die();
696 695
 		} else {
697
-			$this->_redirect_after_action( $success, 'State', 'added', array( 'action' => 'country_settings' ) );
696
+			$this->_redirect_after_action($success, 'State', 'added', array('action' => 'country_settings'));
698 697
 		}
699 698
 	}
700 699
 
@@ -707,25 +706,25 @@  discard block
 block discarded – undo
707 706
 	 * 		@return 		boolean | void
708 707
 	 */
709 708
 	public function delete_state() {
710
-		$CNT_ISO = isset( $this->_req_data['CNT_ISO'] ) ? strtoupper( sanitize_text_field( $this->_req_data['CNT_ISO'] )) : FALSE;
711
-		$STA_ID = isset( $this->_req_data['STA_ID'] ) ? sanitize_text_field( $this->_req_data['STA_ID'] ) : FALSE;
712
-		$STA_abbrev = isset( $this->_req_data['STA_abbrev'] ) ? sanitize_text_field( $this->_req_data['STA_abbrev'] ) : FALSE;
713
-		if ( ! $STA_ID ) {
714
-			EE_Error::add_error( __( 'No State ID or an invalid State ID was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
709
+		$CNT_ISO = isset($this->_req_data['CNT_ISO']) ? strtoupper(sanitize_text_field($this->_req_data['CNT_ISO'])) : FALSE;
710
+		$STA_ID = isset($this->_req_data['STA_ID']) ? sanitize_text_field($this->_req_data['STA_ID']) : FALSE;
711
+		$STA_abbrev = isset($this->_req_data['STA_abbrev']) ? sanitize_text_field($this->_req_data['STA_abbrev']) : FALSE;
712
+		if ( ! $STA_ID) {
713
+			EE_Error::add_error(__('No State ID or an invalid State ID was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
715 714
 			return FALSE;
716 715
 		}
717
-		$success = EEM_State::instance()->delete_by_ID( $STA_ID );
718
-		if ( $success !== FALSE ) {
719
-			do_action( 'AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, array( 'STA_abbrev' => $STA_abbrev ));
720
-			EE_Error::add_success( __( 'The State was deleted successfully.', 'event_espresso' ));
716
+		$success = EEM_State::instance()->delete_by_ID($STA_ID);
717
+		if ($success !== FALSE) {
718
+			do_action('AHEE__General_Settings_Admin_Page__delete_state__state_deleted', $CNT_ISO, $STA_ID, array('STA_abbrev' => $STA_abbrev));
719
+			EE_Error::add_success(__('The State was deleted successfully.', 'event_espresso'));
721 720
 		}
722
-		if ( defined( 'DOING_AJAX' )) {
723
-			$notices = EE_Error::get_notices( FALSE, FALSE );
721
+		if (defined('DOING_AJAX')) {
722
+			$notices = EE_Error::get_notices(FALSE, FALSE);
724 723
 			$notices['return_data'] = TRUE;
725
-			echo json_encode( $notices );
724
+			echo json_encode($notices);
726 725
 			die();
727 726
 		} else {
728
-			$this->_redirect_after_action( $success, 'State', 'deleted', array( 'action' => 'country_settings' ) );
727
+			$this->_redirect_after_action($success, 'State', 'deleted', array('action' => 'country_settings'));
729 728
 		}
730 729
 	}
731 730
 
@@ -741,63 +740,63 @@  discard block
 block discarded – undo
741 740
 	protected function _update_country_settings() {
742 741
 //		EEH_Debug_Tools::printr( $this->_req_data, '$this->_req_data  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
743 742
 		// grab the country ISO code
744
-		$CNT_ISO = isset( $this->_req_data['country'] ) ? strtoupper( sanitize_text_field( $this->_req_data['country'] )) : FALSE;
745
-		if ( ! $CNT_ISO ) {
746
-			EE_Error::add_error( __( 'No Country ISO code or an invalid Country ISO code was received.', 'event_espresso' ), __FILE__, __FUNCTION__, __LINE__ );
743
+		$CNT_ISO = isset($this->_req_data['country']) ? strtoupper(sanitize_text_field($this->_req_data['country'])) : FALSE;
744
+		if ( ! $CNT_ISO) {
745
+			EE_Error::add_error(__('No Country ISO code or an invalid Country ISO code was received.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
747 746
 			return;
748 747
 		}
749 748
 		$cols_n_values = array();
750
-		$cols_n_values['CNT_ISO3'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'] ) ? strtoupper( sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'] )) : FALSE;
751
-		$cols_n_values['RGN_ID'] = isset( $this->_req_data['cntry'][$CNT_ISO]['RGN_ID'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['RGN_ID'] ) : NULL;
752
-		$cols_n_values['CNT_name'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_name'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_name'] ) : NULL;
753
-		$cols_n_values['CNT_cur_code'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'] ) ? strtoupper( sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'] )) : 'USD';
754
-		$cols_n_values['CNT_cur_single'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single'] ) : 'dollar';
755
-		$cols_n_values['CNT_cur_plural'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural'] ) : 'dollars';
756
-		$cols_n_values['CNT_cur_sign'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign'] ) : '$';
757
-		$cols_n_values['CNT_cur_sign_b4'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4'] ) : TRUE;
758
-		$cols_n_values['CNT_cur_dec_plc'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc'] ) : 2;
759
-		$cols_n_values['CNT_cur_dec_mrk'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk'] ) : '.';
760
-		$cols_n_values['CNT_cur_thsnds'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds'] ) : ',';
761
-		$cols_n_values['CNT_tel_code'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'] ) ? sanitize_text_field( $this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code'] ) : NULL;
762
-		$cols_n_values['CNT_is_EU'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU'] ) : FALSE;
763
-		$cols_n_values['CNT_active'] = isset( $this->_req_data['cntry'][$CNT_ISO]['CNT_active'] ) ? absint( $this->_req_data['cntry'][$CNT_ISO]['CNT_active'] ) : FALSE;
749
+		$cols_n_values['CNT_ISO3'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_ISO3'])) : FALSE;
750
+		$cols_n_values['RGN_ID'] = isset($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) ? absint($this->_req_data['cntry'][$CNT_ISO]['RGN_ID']) : NULL;
751
+		$cols_n_values['CNT_name'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_name']) : NULL;
752
+		$cols_n_values['CNT_cur_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code']) ? strtoupper(sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_code'])) : 'USD';
753
+		$cols_n_values['CNT_cur_single'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_single']) : 'dollar';
754
+		$cols_n_values['CNT_cur_plural'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_plural']) : 'dollars';
755
+		$cols_n_values['CNT_cur_sign'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign']) : '$';
756
+		$cols_n_values['CNT_cur_sign_b4'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_sign_b4']) : TRUE;
757
+		$cols_n_values['CNT_cur_dec_plc'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_plc']) : 2;
758
+		$cols_n_values['CNT_cur_dec_mrk'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_dec_mrk']) : '.';
759
+		$cols_n_values['CNT_cur_thsnds'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_cur_thsnds']) : ',';
760
+		$cols_n_values['CNT_tel_code'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) ? sanitize_text_field($this->_req_data['cntry'][$CNT_ISO]['CNT_tel_code']) : NULL;
761
+		$cols_n_values['CNT_is_EU'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_is_EU']) : FALSE;
762
+		$cols_n_values['CNT_active'] = isset($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) ? absint($this->_req_data['cntry'][$CNT_ISO]['CNT_active']) : FALSE;
764 763
 		// allow filtering of country data
765
-		$cols_n_values = apply_filters( 'FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', $cols_n_values );
764
+		$cols_n_values = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__cols_n_values', $cols_n_values);
766 765
 		//EEH_Debug_Tools::printr( $cols_n_values, '$cols_n_values  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
767 766
 		// where values
768
-		$where_cols_n_values = array( array( 'CNT_ISO' => $CNT_ISO ));
767
+		$where_cols_n_values = array(array('CNT_ISO' => $CNT_ISO));
769 768
 		// run the update
770
-		$success = EEM_Country::instance()->update( $cols_n_values, $where_cols_n_values );
769
+		$success = EEM_Country::instance()->update($cols_n_values, $where_cols_n_values);
771 770
 //		global $wpdb;
772 771
 //		echo '<h4>' . $wpdb->last_query . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
773 772
 //		echo '<h4>$success : ' . $success . '  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span></h4>';
774
-		if ( isset( $this->_req_data['states'] ) && is_array( $this->_req_data['states'] ) && $success !== FALSE ) {
773
+		if (isset($this->_req_data['states']) && is_array($this->_req_data['states']) && $success !== FALSE) {
775 774
 			// allow filtering of states data
776
-			$states = apply_filters( 'FHEE__General_Settings_Admin_Page___update_country_settings__states', $this->_req_data['states'] );
775
+			$states = apply_filters('FHEE__General_Settings_Admin_Page___update_country_settings__states', $this->_req_data['states']);
777 776
 //			EEH_Debug_Tools::printr( $states, '$states  <br /><span style="font-size:10px;font-weight:normal;">' . __FILE__ . '<br />line no: ' . __LINE__ . '</span>', 'auto' );
778 777
 			// loop thru state data ( looks like : states[75][STA_name] )
779
-			foreach( $states as $STA_ID => $state ) {
778
+			foreach ($states as $STA_ID => $state) {
780 779
 				$cols_n_values = array(
781 780
 					'CNT_ISO' 		=> $CNT_ISO,
782
-					'STA_abbrev' => sanitize_text_field( $state['STA_abbrev'] ),
783
-					'STA_name' 	=> sanitize_text_field( $state['STA_name'] ),
784
-					'STA_active' 	=> (bool)absint( $state['STA_active'] )
781
+					'STA_abbrev' => sanitize_text_field($state['STA_abbrev']),
782
+					'STA_name' 	=> sanitize_text_field($state['STA_name']),
783
+					'STA_active' 	=> (bool) absint($state['STA_active'])
785 784
 				);
786 785
 				// where values
787
-				$where_cols_n_values = array( array( 'STA_ID' => $STA_ID ));
786
+				$where_cols_n_values = array(array('STA_ID' => $STA_ID));
788 787
 				// run the update
789
-				$success = EEM_State::instance()->update( $cols_n_values, $where_cols_n_values );
790
-				if ( $success !== FALSE ) {
791
-					do_action( 'AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, $STA_ID, $cols_n_values );
788
+				$success = EEM_State::instance()->update($cols_n_values, $where_cols_n_values);
789
+				if ($success !== FALSE) {
790
+					do_action('AHEE__General_Settings_Admin_Page__update_country_settings__state_saved', $CNT_ISO, $STA_ID, $cols_n_values);
792 791
 				}
793 792
 			}
794 793
 		}
795 794
 		// check if country being edited matches org option country, and if so, then  update EE_Config with new settings
796
-		if ( isset( EE_Registry::instance()->CFG->organization->CNT_ISO ) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO ) {
797
-			EE_Registry::instance()->CFG->currency = new EE_Currency_Config( $CNT_ISO );
795
+		if (isset(EE_Registry::instance()->CFG->organization->CNT_ISO) && $CNT_ISO == EE_Registry::instance()->CFG->organization->CNT_ISO) {
796
+			EE_Registry::instance()->CFG->currency = new EE_Currency_Config($CNT_ISO);
798 797
 			EE_Registry::instance()->CFG->update_espresso_config();
799 798
 		}
800
-		$this->_redirect_after_action( $success, 'Countries', 'updated', array( 'action' => 'country_settings', 'country' => $CNT_ISO ));
799
+		$this->_redirect_after_action($success, 'Countries', 'updated', array('action' => 'country_settings', 'country' => $CNT_ISO));
801 800
 	}
802 801
 
803 802
 
@@ -811,11 +810,11 @@  discard block
 block discarded – undo
811 810
 	 * 		@param 		string 		$label
812 811
 	 * 		@return 		string
813 812
 	 */
814
-	public function country_form_field_label_wrap( $label, $required_text ) {
813
+	public function country_form_field_label_wrap($label, $required_text) {
815 814
 		return '
816 815
 			<tr>
817 816
 				<th>
818
-					' . $label  . '
817
+					' . $label.'
819 818
 				</th>';
820 819
 	}
821 820
 
@@ -829,10 +828,10 @@  discard block
 block discarded – undo
829 828
 	 * 		@param 		string 		$label
830 829
 	 * 		@return 		string
831 830
 	 */
832
-	public function country_form_field_input__wrap( $input, $label ) {
831
+	public function country_form_field_input__wrap($input, $label) {
833 832
 		return '
834 833
 				<td class="general-settings-country-input-td">
835
-					' . $input . '
834
+					' . $input.'
836 835
 				</td>
837 836
 			</tr>';
838 837
 	}
@@ -848,7 +847,7 @@  discard block
 block discarded – undo
848 847
 	 * 		@param 		string 		$required_text
849 848
 	 * 		@return 		string
850 849
 	 */
851
-	public function state_form_field_label_wrap( $label, $required_text  ) {
850
+	public function state_form_field_label_wrap($label, $required_text) {
852 851
 		return $required_text;
853 852
 	}
854 853
 
@@ -862,10 +861,10 @@  discard block
 block discarded – undo
862 861
 	 * 		@param 		string 		$label
863 862
 	 * 		@return 		string
864 863
 	 */
865
-	public function state_form_field_input__wrap( $input, $label ) {
864
+	public function state_form_field_input__wrap($input, $label) {
866 865
 		return '
867 866
 				<td class="general-settings-country-state-input-td">
868
-					' . $input . '
867
+					' . $input.'
869 868
 				</td>';
870 869
 
871 870
 	}
@@ -888,10 +887,10 @@  discard block
 block discarded – undo
888 887
 	 * @param int $ee_page_id
889 888
 	 * @return string
890 889
 	 */
891
-	public static function edit_view_links( $ee_page_id ) {
892
-		$links = '<a href="' . add_query_arg( array( 'post' => $ee_page_id, 'action' => 'edit' ),  admin_url( 'post.php' )) . '" >' . __('Edit', 'event_espresso') . '</a>';
890
+	public static function edit_view_links($ee_page_id) {
891
+		$links = '<a href="'.add_query_arg(array('post' => $ee_page_id, 'action' => 'edit'), admin_url('post.php')).'" >'.__('Edit', 'event_espresso').'</a>';
893 892
 		$links .= ' &nbsp;|&nbsp; ';
894
-		$links .= '<a href="' . get_permalink( $ee_page_id ) . '" >' . __('View', 'event_espresso') . '</a>';
893
+		$links .= '<a href="'.get_permalink($ee_page_id).'" >'.__('View', 'event_espresso').'</a>';
895 894
 		return $links;
896 895
 	}
897 896
 
@@ -904,27 +903,27 @@  discard block
 block discarded – undo
904 903
 	 * @param WP page object $ee_page
905 904
 	 * @return string
906 905
 	 */
907
-	public static function page_and_shortcode_status( $ee_page, $shortcode ) {
906
+	public static function page_and_shortcode_status($ee_page, $shortcode) {
908 907
 
909 908
 		// page status
910
-		if ( isset( $ee_page->post_status ) && $ee_page->post_status == 'publish') {
909
+		if (isset($ee_page->post_status) && $ee_page->post_status == 'publish') {
911 910
 			$pg_colour = 'green';
912
-			$pg_status = sprintf( __('Page%sStatus%sOK', 'event_espresso'), '&nbsp;' , '&nbsp;' );
911
+			$pg_status = sprintf(__('Page%sStatus%sOK', 'event_espresso'), '&nbsp;', '&nbsp;');
913 912
 		 } else {
914 913
 			$pg_colour = 'red';
915
-			$pg_status = sprintf( __('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;'  );
914
+			$pg_status = sprintf(__('Page%sVisibility%sProblem', 'event_espresso'), '&nbsp;', '&nbsp;');
916 915
 		}
917 916
 
918 917
 		// shortcode status
919
-		if ( isset( $ee_page->post_content ) && strpos( $ee_page->post_content, $shortcode ) !== FALSE ) {
918
+		if (isset($ee_page->post_content) && strpos($ee_page->post_content, $shortcode) !== FALSE) {
920 919
 			$sc_colour = 'green';
921
-			$sc_status = sprintf( __('Shortcode%sOK', 'event_espresso'), '&nbsp;' );
920
+			$sc_status = sprintf(__('Shortcode%sOK', 'event_espresso'), '&nbsp;');
922 921
 		 } else {
923 922
 			$sc_colour = 'red';
924
-			$sc_status = sprintf( __('Shortcode%sProblem', 'event_espresso'), '&nbsp;' );
923
+			$sc_status = sprintf(__('Shortcode%sProblem', 'event_espresso'), '&nbsp;');
925 924
 		}
926 925
 
927
-		return '<span style="color:' . $pg_colour . '; margin-right:2em;"><strong>' . $pg_status . '</strong></span><span style="color:' . $sc_colour . '"><strong>' . $sc_status . '</strong></span>';
926
+		return '<span style="color:'.$pg_colour.'; margin-right:2em;"><strong>'.$pg_status.'</strong></span><span style="color:'.$sc_colour.'"><strong>'.$sc_status.'</strong></span>';
928 927
 
929 928
 	}
930 929
 
@@ -939,20 +938,20 @@  discard block
 block discarded – undo
939 938
 	 * @param unknown_type $level
940 939
 	 * @return unknown
941 940
 	 */
942
-	public static function page_settings_dropdown( $default = 0, $parent = 0, $level = 0 ) {
941
+	public static function page_settings_dropdown($default = 0, $parent = 0, $level = 0) {
943 942
 		global $wpdb;
944
-		$items = $wpdb->get_results( $wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", $parent) );
943
+		$items = $wpdb->get_results($wpdb->prepare("SELECT ID, post_parent, post_title FROM $wpdb->posts WHERE post_parent = %d AND post_type = 'page' AND post_status != 'trash' ORDER BY menu_order", $parent));
945 944
 
946
-		if ( $items ) {
947
-			foreach ( $items as $item ) {
948
-				$pad = str_repeat( '&nbsp;', $level * 3 );
949
-				if ( $item->ID == $default)
945
+		if ($items) {
946
+			foreach ($items as $item) {
947
+				$pad = str_repeat('&nbsp;', $level * 3);
948
+				if ($item->ID == $default)
950 949
 					$current = ' selected="selected"';
951 950
 				else
952 951
 					$current = '';
953 952
 
954
-				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad " . esc_html($item->post_title) . "</option>";
955
-				parent_dropdown( $default, $item->ID, $level +1 );
953
+				echo "\n\t<option class='level-$level' value='$item->ID'$current>$pad ".esc_html($item->post_title)."</option>";
954
+				parent_dropdown($default, $item->ID, $level + 1);
956 955
 			}
957 956
 		} else {
958 957
 			return false;
Please login to merge, or discard this patch.