Completed
Branch BUG-9647-cpt-queries (303307)
by
unknown
31:50 queued 15:24
created
core/services/address/formatters/MultiLineAddressFormatter.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -1,8 +1,8 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 namespace EventEspresso\core\services\address\formatters;
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
 
@@ -28,7 +28,7 @@  discard block
 block discarded – undo
28 28
 	 * @param string $CNT_ISO
29 29
 	 * @return string
30 30
 	 */
31
-	public function format( $address, $address2, $city, $state, $zip, $country, $CNT_ISO ) {
31
+	public function format($address, $address2, $city, $state, $zip, $country, $CNT_ISO) {
32 32
 		$address_formats = apply_filters(
33 33
 			'FHEE__EE_Inline_Address_Formatter__address_formats',
34 34
 			array(
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
 			)
40 40
 		);
41 41
 		// if the incoming country has a set format, use that, else use the default
42
-		$formatted_address = isset( $address_formats[ $CNT_ISO ] ) ? $address_formats[ $CNT_ISO ]
42
+		$formatted_address = isset($address_formats[$CNT_ISO]) ? $address_formats[$CNT_ISO]
43 43
 			: $address_formats['ZZZ'];
44 44
 		return $this->parse_formatted_address(
45 45
 			$address,
Please login to merge, or discard this patch.
core/EE_Registry.core.php 2 patches
Doc Comments   +1 added lines patch added patch discarded remove patch
@@ -278,6 +278,7 @@
 block discarded – undo
278 278
 
279 279
 	/**
280 280
 	 * @param mixed string | EED_Module $module
281
+	 * @param string $module
281 282
 	 */
282 283
 	public function add_module( $module ) {
283 284
 		if ( $module instanceof EED_Module ) {
Please login to merge, or discard this patch.
Spacing   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -178,10 +178,10 @@  discard block
 block discarded – undo
178 178
 	 * @param  \EE_Dependency_Map $dependency_map
179 179
 	 * @return \EE_Registry instance
180 180
 	 */
181
-	public static function instance( \EE_Dependency_Map $dependency_map = null ) {
181
+	public static function instance(\EE_Dependency_Map $dependency_map = null) {
182 182
 		// check if class object is instantiated
183
-		if ( ! self::$_instance instanceof EE_Registry ) {
184
-			self::$_instance = new EE_Registry( $dependency_map );
183
+		if ( ! self::$_instance instanceof EE_Registry) {
184
+			self::$_instance = new EE_Registry($dependency_map);
185 185
 		}
186 186
 		return self::$_instance;
187 187
 	}
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 	 * @param  \EE_Dependency_Map $dependency_map
197 197
 	 * @return \EE_Registry
198 198
 	 */
199
-	protected function __construct( \EE_Dependency_Map $dependency_map ) {
199
+	protected function __construct(\EE_Dependency_Map $dependency_map) {
200 200
 		$this->_dependency_map = $dependency_map;
201
-		add_action( 'EE_Load_Espresso_Core__handle_request__initialize_core_loading', array( $this, 'initialize' ) );
201
+		add_action('EE_Load_Espresso_Core__handle_request__initialize_core_loading', array($this, 'initialize'));
202 202
 	}
203 203
 
204 204
 
@@ -225,19 +225,19 @@  discard block
 block discarded – undo
225 225
 		$this->modules = new StdClass();
226 226
 		$this->shortcodes = new StdClass();
227 227
 		$this->widgets = new StdClass();
228
-		$this->load_core( 'Base', array(), true );
228
+		$this->load_core('Base', array(), true);
229 229
 		// add our request and response objects to the cache
230
-		$request_loader = $this->_dependency_map->class_loader( 'EE_Request' );
230
+		$request_loader = $this->_dependency_map->class_loader('EE_Request');
231 231
 		$this->_set_cached_class(
232 232
 			$request_loader(),
233 233
 			'EE_Request'
234 234
 		);
235
-		$response_loader = $this->_dependency_map->class_loader( 'EE_Response' );
235
+		$response_loader = $this->_dependency_map->class_loader('EE_Response');
236 236
 		$this->_set_cached_class(
237 237
 			$response_loader(),
238 238
 			'EE_Response'
239 239
 		);
240
-		add_action( 'AHEE__EE_System__set_hooks_for_core', array( $this, 'init' ) );
240
+		add_action('AHEE__EE_System__set_hooks_for_core', array($this, 'init'));
241 241
 	}
242 242
 
243 243
 
@@ -250,10 +250,10 @@  discard block
 block discarded – undo
250 250
 	 */
251 251
 	public function init() {
252 252
 		// Get current page protocol
253
-		$protocol = isset( $_SERVER[ 'HTTPS' ] ) ? 'https://' : 'http://';
253
+		$protocol = isset($_SERVER['HTTPS']) ? 'https://' : 'http://';
254 254
 		// Output admin-ajax.php URL with same protocol as current page
255
-		self::$i18n_js_strings[ 'ajax_url' ] = admin_url( 'admin-ajax.php', $protocol );
256
-		self::$i18n_js_strings[ 'wp_debug' ] = defined( 'WP_DEBUG' ) ? WP_DEBUG : false;
255
+		self::$i18n_js_strings['ajax_url'] = admin_url('admin-ajax.php', $protocol);
256
+		self::$i18n_js_strings['wp_debug'] = defined('WP_DEBUG') ? WP_DEBUG : false;
257 257
 	}
258 258
 
259 259
 
@@ -264,14 +264,14 @@  discard block
 block discarded – undo
264 264
 	 * @return string
265 265
 	 */
266 266
 	public static function localize_i18n_js_strings() {
267
-		$i18n_js_strings = (array)EE_Registry::$i18n_js_strings;
268
-		foreach ( $i18n_js_strings as $key => $value ) {
269
-			if ( is_scalar( $value ) ) {
270
-				$i18n_js_strings[ $key ] = html_entity_decode( (string)$value, ENT_QUOTES, 'UTF-8' );
267
+		$i18n_js_strings = (array) EE_Registry::$i18n_js_strings;
268
+		foreach ($i18n_js_strings as $key => $value) {
269
+			if (is_scalar($value)) {
270
+				$i18n_js_strings[$key] = html_entity_decode((string) $value, ENT_QUOTES, 'UTF-8');
271 271
 			}
272 272
 		}
273 273
 
274
-		return "/* <![CDATA[ */ var eei18n = " . wp_json_encode( $i18n_js_strings ) . '; /* ]]> */';
274
+		return "/* <![CDATA[ */ var eei18n = ".wp_json_encode($i18n_js_strings).'; /* ]]> */';
275 275
 	}
276 276
 
277 277
 
@@ -279,15 +279,15 @@  discard block
 block discarded – undo
279 279
 	/**
280 280
 	 * @param mixed string | EED_Module $module
281 281
 	 */
282
-	public function add_module( $module ) {
283
-		if ( $module instanceof EED_Module ) {
284
-			$module_class = get_class( $module );
282
+	public function add_module($module) {
283
+		if ($module instanceof EED_Module) {
284
+			$module_class = get_class($module);
285 285
 			$this->modules->{$module_class} = $module;
286 286
 		} else {
287
-			if ( ! class_exists( 'EE_Module_Request_Router' ) ) {
288
-				$this->load_core( 'Module_Request_Router' );
287
+			if ( ! class_exists('EE_Module_Request_Router')) {
288
+				$this->load_core('Module_Request_Router');
289 289
 			}
290
-			$this->modules->{$module} = EE_Module_Request_Router::module_factory( $module );
290
+			$this->modules->{$module} = EE_Module_Request_Router::module_factory($module);
291 291
 		}
292 292
 	}
293 293
 
@@ -297,8 +297,8 @@  discard block
 block discarded – undo
297 297
 	 * @param string $module_name
298 298
 	 * @return mixed EED_Module | NULL
299 299
 	 */
300
-	public function get_module( $module_name = '' ) {
301
-		return isset( $this->modules->{$module_name} ) ? $this->modules->{$module_name} : null;
300
+	public function get_module($module_name = '') {
301
+		return isset($this->modules->{$module_name} ) ? $this->modules->{$module_name} : null;
302 302
 	}
303 303
 
304 304
 
@@ -312,20 +312,20 @@  discard block
 block discarded – undo
312 312
 	 * @param bool $load_only
313 313
 	 * @return mixed
314 314
 	 */
315
-	public function load_core( $class_name, $arguments = array(), $load_only = false ) {
315
+	public function load_core($class_name, $arguments = array(), $load_only = false) {
316 316
 		$core_paths = apply_filters(
317 317
 			'FHEE__EE_Registry__load_core__core_paths',
318 318
 			array(
319 319
 				EE_CORE,
320 320
 				EE_ADMIN,
321 321
 				EE_CPTS,
322
-				EE_CORE . 'data_migration_scripts' . DS,
323
-				EE_CORE . 'request_stack' . DS,
324
-				EE_CORE . 'middleware' . DS,
322
+				EE_CORE.'data_migration_scripts'.DS,
323
+				EE_CORE.'request_stack'.DS,
324
+				EE_CORE.'middleware'.DS,
325 325
 			)
326 326
 		);
327 327
 		// retrieve instantiated class
328
-		return $this->_load( $core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only );
328
+		return $this->_load($core_paths, 'EE_', $class_name, 'core', $arguments, false, true, $load_only);
329 329
 	}
330 330
 
331 331
 
@@ -339,15 +339,15 @@  discard block
 block discarded – undo
339 339
 	 * @param bool $load_only
340 340
 	 * @return mixed
341 341
 	 */
342
-	public function load_service( $class_name, $arguments = array(), $load_only = false ) {
342
+	public function load_service($class_name, $arguments = array(), $load_only = false) {
343 343
 		$service_paths = apply_filters(
344 344
 			'FHEE__EE_Registry__load_service__service_paths',
345 345
 			array(
346
-				EE_CORE . 'services' . DS,
346
+				EE_CORE.'services'.DS,
347 347
 			)
348 348
 		);
349 349
 		// retrieve instantiated class
350
-		return $this->_load( $service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only );
350
+		return $this->_load($service_paths, 'EE_', $class_name, 'class', $arguments, false, true, $load_only);
351 351
 	}
352 352
 
353 353
 
@@ -360,9 +360,9 @@  discard block
 block discarded – undo
360 360
 	 * @param mixed $arguments
361 361
 	 * @return EE_Data_Migration_Script_Base
362 362
 	 */
363
-	public function load_dms( $class_name, $arguments = array() ) {
363
+	public function load_dms($class_name, $arguments = array()) {
364 364
 		// retrieve instantiated class
365
-		return $this->_load( EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false );
365
+		return $this->_load(EE_Data_Migration_Manager::instance()->get_data_migration_script_folders(), 'EE_DMS_', $class_name, 'dms', $arguments, false, false, false);
366 366
 	}
367 367
 
368 368
 
@@ -377,14 +377,14 @@  discard block
 block discarded – undo
377 377
 	 * @param bool $load_only whether or not to just load the file and NOT instantiate, or load AND instantiate (default)
378 378
 	 * @return EE_Base_Class | bool
379 379
 	 */
380
-	public function load_class( $class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false ) {
381
-		$paths = apply_filters( 'FHEE__EE_Registry__load_class__paths', array(
380
+	public function load_class($class_name, $arguments = array(), $from_db = false, $cache = true, $load_only = false) {
381
+		$paths = apply_filters('FHEE__EE_Registry__load_class__paths', array(
382 382
 			EE_CORE,
383 383
 			EE_CLASSES,
384 384
 			EE_BUSINESS
385
-		) );
385
+		));
386 386
 		// retrieve instantiated class
387
-		return $this->_load( $paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only );
387
+		return $this->_load($paths, 'EE_', $class_name, 'class', $arguments, $from_db, $cache, $load_only);
388 388
 	}
389 389
 
390 390
 
@@ -397,11 +397,11 @@  discard block
 block discarded – undo
397 397
 	 * @param bool $load_only
398 398
 	 * @return EEH_Base | bool
399 399
 	 */
400
-	public function load_helper( $class_name, $arguments = array(), $load_only = true ) {
400
+	public function load_helper($class_name, $arguments = array(), $load_only = true) {
401 401
 		// todo: add doing_it_wrong() in a few versions after all addons have had calls to this method removed
402
-		$helper_paths = apply_filters( 'FHEE__EE_Registry__load_helper__helper_paths', array( EE_HELPERS ) );
402
+		$helper_paths = apply_filters('FHEE__EE_Registry__load_helper__helper_paths', array(EE_HELPERS));
403 403
 		// retrieve instantiated class
404
-		return $this->_load( $helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only );
404
+		return $this->_load($helper_paths, 'EEH_', $class_name, 'helper', $arguments, false, true, $load_only);
405 405
 	}
406 406
 
407 407
 
@@ -416,16 +416,16 @@  discard block
 block discarded – undo
416 416
 	 * @param bool $cache  whether to cache the object or not.
417 417
 	 * @return mixed
418 418
 	 */
419
-	public function load_lib( $class_name, $arguments = array(), $load_only = false, $cache = true ) {
419
+	public function load_lib($class_name, $arguments = array(), $load_only = false, $cache = true) {
420 420
 		$paths = array(
421 421
 			EE_LIBRARIES,
422
-			EE_LIBRARIES . 'messages' . DS,
423
-			EE_LIBRARIES . 'shortcodes' . DS,
424
-			EE_LIBRARIES . 'qtips' . DS,
425
-			EE_LIBRARIES . 'payment_methods' . DS,
422
+			EE_LIBRARIES.'messages'.DS,
423
+			EE_LIBRARIES.'shortcodes'.DS,
424
+			EE_LIBRARIES.'qtips'.DS,
425
+			EE_LIBRARIES.'payment_methods'.DS,
426 426
 		);
427 427
 		// retrieve instantiated class
428
-		return $this->_load( $paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only );
428
+		return $this->_load($paths, 'EE_', $class_name, 'lib', $arguments, false, $cache, $load_only);
429 429
 	}
430 430
 
431 431
 
@@ -438,13 +438,13 @@  discard block
 block discarded – undo
438 438
 	 * @param bool $load_only
439 439
 	 * @return EEM_Base | bool
440 440
 	 */
441
-	public function load_model( $class_name, $arguments = array(), $load_only = false ) {
442
-		$paths = apply_filters( 'FHEE__EE_Registry__load_model__paths', array(
441
+	public function load_model($class_name, $arguments = array(), $load_only = false) {
442
+		$paths = apply_filters('FHEE__EE_Registry__load_model__paths', array(
443 443
 			EE_MODELS,
444 444
 			EE_CORE
445
-		) );
445
+		));
446 446
 		// retrieve instantiated class
447
-		return $this->_load( $paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only );
447
+		return $this->_load($paths, 'EEM_', $class_name, 'model', $arguments, false, true, $load_only);
448 448
 	}
449 449
 
450 450
 
@@ -457,15 +457,15 @@  discard block
 block discarded – undo
457 457
 	 * @param bool $load_only
458 458
 	 * @return mixed | bool
459 459
 	 */
460
-	public function load_model_class( $class_name, $arguments = array(), $load_only = true ) {
460
+	public function load_model_class($class_name, $arguments = array(), $load_only = true) {
461 461
 		$paths = array(
462
-			EE_MODELS . 'fields' . DS,
463
-			EE_MODELS . 'helpers' . DS,
464
-			EE_MODELS . 'relations' . DS,
465
-			EE_MODELS . 'strategies' . DS
462
+			EE_MODELS.'fields'.DS,
463
+			EE_MODELS.'helpers'.DS,
464
+			EE_MODELS.'relations'.DS,
465
+			EE_MODELS.'strategies'.DS
466 466
 		);
467 467
 		// retrieve instantiated class
468
-		return $this->_load( $paths, 'EE_', $class_name, '', $arguments, false, true, $load_only );
468
+		return $this->_load($paths, 'EE_', $class_name, '', $arguments, false, true, $load_only);
469 469
 	}
470 470
 
471 471
 
@@ -475,8 +475,8 @@  discard block
 block discarded – undo
475 475
 	 * @param string $model_name like Event, Attendee, Question_Group_Question, etc.
476 476
 	 * @return boolean
477 477
 	 */
478
-	public function is_model_name( $model_name ) {
479
-		return isset( $this->models[ $model_name ] ) ? true : false;
478
+	public function is_model_name($model_name) {
479
+		return isset($this->models[$model_name]) ? true : false;
480 480
 	}
481 481
 
482 482
 
@@ -491,9 +491,9 @@  discard block
 block discarded – undo
491 491
 	 * @param bool $load_only
492 492
 	 * @return mixed
493 493
 	 */
494
-	public function load_file( $path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true ) {
494
+	public function load_file($path_to_file, $file_name, $type = '', $arguments = array(), $load_only = true) {
495 495
 		// retrieve instantiated class
496
-		return $this->_load( $path_to_file, '', $file_name, $type, $arguments, false, true, $load_only );
496
+		return $this->_load($path_to_file, '', $file_name, $type, $arguments, false, true, $load_only);
497 497
 	}
498 498
 
499 499
 
@@ -508,9 +508,9 @@  discard block
 block discarded – undo
508 508
 	 * @param bool $load_only
509 509
 	 * @return EE_Addon
510 510
 	 */
511
-	public function load_addon( $path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false ) {
511
+	public function load_addon($path_to_file, $class_name, $type = 'class', $arguments = array(), $load_only = false) {
512 512
 		// retrieve instantiated class
513
-		return $this->_load( $path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only );
513
+		return $this->_load($path_to_file, 'addon', $class_name, $type, $arguments, false, true, $load_only);
514 514
 	}
515 515
 
516 516
 
@@ -541,46 +541,46 @@  discard block
 block discarded – undo
541 541
 		$load_only = false
542 542
 	) {
543 543
 		// strip php file extension
544
-		$class_name = str_replace( '.php', '', trim( $class_name ) );
544
+		$class_name = str_replace('.php', '', trim($class_name));
545 545
 		// does the class have a prefix ?
546
-		if ( ! empty( $class_prefix ) && $class_prefix != 'addon' ) {
546
+		if ( ! empty($class_prefix) && $class_prefix != 'addon') {
547 547
 			// make sure $class_prefix is uppercase
548
-			$class_prefix = strtoupper( trim( $class_prefix ) );
548
+			$class_prefix = strtoupper(trim($class_prefix));
549 549
 			// add class prefix ONCE!!!
550
-			$class_name = $class_prefix . str_replace( $class_prefix, '', $class_name );
550
+			$class_name = $class_prefix.str_replace($class_prefix, '', $class_name);
551 551
 		}
552
-		$class_exists = class_exists( $class_name );
552
+		$class_exists = class_exists($class_name);
553 553
 		// if we're only loading the class and it already exists, then let's just return true immediately
554
-		if ( $load_only && $class_exists ) {
554
+		if ($load_only && $class_exists) {
555 555
 			return true;
556 556
 		}
557 557
 		// $this->_cache_on is toggled during the recursive loading that can occur with dependency injection
558 558
 		// $cache is controlled by individual calls to separate Registry loader methods like load_class()
559 559
 		// $load_only is also controlled by individual calls to separate Registry loader methods like load_file()
560
-		if ( $this->_cache_on && $cache && ! $load_only ) {
560
+		if ($this->_cache_on && $cache && ! $load_only) {
561 561
 			// return object if it's already cached
562
-			$cached_class = $this->_get_cached_class( $class_name, $class_prefix );
563
-			if ( $cached_class !== null ) {
562
+			$cached_class = $this->_get_cached_class($class_name, $class_prefix);
563
+			if ($cached_class !== null) {
564 564
 				return $cached_class;
565 565
 			}
566 566
 		}
567 567
 		// if the class doesn't already exist.. then we need to try and find the file and load it
568
-		if ( ! $class_exists ) {
568
+		if ( ! $class_exists) {
569 569
 			// get full path to file
570
-			$path = $this->_resolve_path( $class_name, $type, $file_paths );
570
+			$path = $this->_resolve_path($class_name, $type, $file_paths);
571 571
 			// load the file
572
-			$loaded = $this->_require_file( $path, $class_name, $type, $file_paths );
572
+			$loaded = $this->_require_file($path, $class_name, $type, $file_paths);
573 573
 			// if loading failed, or we are only loading a file but NOT instantiating an object
574
-			if ( ! $loaded || $load_only ) {
574
+			if ( ! $loaded || $load_only) {
575 575
 				// return boolean if only loading, or null if an object was expected
576 576
 				return $load_only ? $loaded : null;
577 577
 			}
578 578
 		}
579 579
 		// instantiate the requested object
580
-		$class_obj = $this->_create_object( $class_name, $arguments, $type, $from_db );
581
-		if ( $this->_cache_on && $cache ) {
580
+		$class_obj = $this->_create_object($class_name, $arguments, $type, $from_db);
581
+		if ($this->_cache_on && $cache) {
582 582
 			// save it for later... kinda like gum  { : $
583
-			$this->_set_cached_class( $class_obj, $class_name, $class_prefix, $from_db );
583
+			$this->_set_cached_class($class_obj, $class_name, $class_prefix, $from_db);
584 584
 		}
585 585
 		$this->_cache_on = true;
586 586
 		return $class_obj;
@@ -603,21 +603,21 @@  discard block
 block discarded – undo
603 603
 	 * @param string $class_prefix
604 604
 	 * @return null|object
605 605
 	 */
606
-	protected function _get_cached_class( $class_name, $class_prefix = '' ) {
607
-		if ( isset( $this->_class_abbreviations[ $class_name ] ) ) {
608
-			$class_abbreviation = $this->_class_abbreviations[ $class_name ];
606
+	protected function _get_cached_class($class_name, $class_prefix = '') {
607
+		if (isset($this->_class_abbreviations[$class_name])) {
608
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
609 609
 		} else {
610 610
 			// have to specify something, but not anything that will conflict
611 611
 			$class_abbreviation = 'FANCY_BATMAN_PANTS';
612 612
 		}
613 613
 		// check if class has already been loaded, and return it if it has been
614
-		if ( isset( $this->{$class_abbreviation} ) && ! is_null( $this->{$class_abbreviation} ) ) {
614
+		if (isset($this->{$class_abbreviation} ) && ! is_null($this->{$class_abbreviation} )) {
615 615
 			return $this->{$class_abbreviation};
616
-		} else if ( isset ( $this->{$class_name} ) ) {
616
+		} else if (isset ($this->{$class_name} )) {
617 617
 			return $this->{$class_name};
618
-		} else if ( isset ( $this->LIB->{$class_name} ) ) {
618
+		} else if (isset ($this->LIB->{$class_name} )) {
619 619
 			return $this->LIB->{$class_name};
620
-		} else if ( $class_prefix == 'addon' && isset ( $this->addons->{$class_name} ) ) {
620
+		} else if ($class_prefix == 'addon' && isset ($this->addons->{$class_name} )) {
621 621
 			return $this->addons->{$class_name};
622 622
 		}
623 623
 		return null;
@@ -638,20 +638,20 @@  discard block
 block discarded – undo
638 638
 	 * @param array $file_paths
639 639
 	 * @return string | bool
640 640
 	 */
641
-	protected function _resolve_path( $class_name, $type = '', $file_paths = array() ) {
641
+	protected function _resolve_path($class_name, $type = '', $file_paths = array()) {
642 642
 		// make sure $file_paths is an array
643
-		$file_paths = is_array( $file_paths ) ? $file_paths : array( $file_paths );
643
+		$file_paths = is_array($file_paths) ? $file_paths : array($file_paths);
644 644
 		// cycle thru paths
645
-		foreach ( $file_paths as $key => $file_path ) {
645
+		foreach ($file_paths as $key => $file_path) {
646 646
 			// convert all separators to proper DS, if no filepath, then use EE_CLASSES
647
-			$file_path = $file_path ? str_replace( array( '/', '\\' ), DS, $file_path ) : EE_CLASSES;
647
+			$file_path = $file_path ? str_replace(array('/', '\\'), DS, $file_path) : EE_CLASSES;
648 648
 			// prep file type
649
-			$type = ! empty( $type ) ? trim( $type, '.' ) . '.' : '';
649
+			$type = ! empty($type) ? trim($type, '.').'.' : '';
650 650
 			// build full file path
651
-			$file_paths[ $key ] = rtrim( $file_path, DS ) . DS . $class_name . '.' . $type . 'php';
651
+			$file_paths[$key] = rtrim($file_path, DS).DS.$class_name.'.'.$type.'php';
652 652
 			//does the file exist and can be read ?
653
-			if ( is_readable( $file_paths[ $key ] ) ) {
654
-				return $file_paths[ $key ];
653
+			if (is_readable($file_paths[$key])) {
654
+				return $file_paths[$key];
655 655
 			}
656 656
 		}
657 657
 		return false;
@@ -673,29 +673,29 @@  discard block
 block discarded – undo
673 673
 	 * @return boolean
674 674
 	 * @throws \EE_Error
675 675
 	 */
676
-	protected function _require_file( $path, $class_name, $type = '', $file_paths = array() ) {
676
+	protected function _require_file($path, $class_name, $type = '', $file_paths = array()) {
677 677
 		// don't give up! you gotta...
678 678
 		try {
679 679
 			//does the file exist and can it be read ?
680
-			if ( ! $path ) {
680
+			if ( ! $path) {
681 681
 				// so sorry, can't find the file
682
-				throw new EE_Error (
682
+				throw new EE_Error(
683 683
 					sprintf(
684
-						__( 'The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso' ),
685
-						trim( $type, '.' ),
684
+						__('The %1$s file %2$s could not be located or is not readable due to file permissions. Please ensure that the following filepath(s) are correct: %3$s', 'event_espresso'),
685
+						trim($type, '.'),
686 686
 						$class_name,
687
-						'<br />' . implode( ',<br />', $file_paths )
687
+						'<br />'.implode(',<br />', $file_paths)
688 688
 					)
689 689
 				);
690 690
 			}
691 691
 			// get the file
692
-			require_once( $path );
692
+			require_once($path);
693 693
 			// if the class isn't already declared somewhere
694
-			if ( class_exists( $class_name, false ) === false ) {
694
+			if (class_exists($class_name, false) === false) {
695 695
 				// so sorry, not a class
696 696
 				throw new EE_Error(
697 697
 					sprintf(
698
-						__( 'The %s file %s does not appear to contain the %s Class.', 'event_espresso' ),
698
+						__('The %s file %s does not appear to contain the %s Class.', 'event_espresso'),
699 699
 						$type,
700 700
 						$path,
701 701
 						$class_name
@@ -703,7 +703,7 @@  discard block
 block discarded – undo
703 703
 				);
704 704
 			}
705 705
 
706
-		} catch ( EE_Error $e ) {
706
+		} catch (EE_Error $e) {
707 707
 			$e->get_error();
708 708
 			return false;
709 709
 		}
@@ -735,55 +735,55 @@  discard block
 block discarded – undo
735 735
 	 * @return null | object
736 736
 	 * @throws \EE_Error
737 737
 	 */
738
-	protected function _create_object( $class_name, $arguments = array(), $type = '', $from_db = false ) {
738
+	protected function _create_object($class_name, $arguments = array(), $type = '', $from_db = false) {
739 739
 		$class_obj = null;
740 740
 		// don't give up! you gotta...
741 741
 		try {
742 742
 			// create reflection
743
-			$reflector = $this->get_ReflectionClass( $class_name );
743
+			$reflector = $this->get_ReflectionClass($class_name);
744 744
 			// make sure arguments are an array
745
-			$arguments = is_array( $arguments ) ? $arguments : array( $arguments );
745
+			$arguments = is_array($arguments) ? $arguments : array($arguments);
746 746
 			// and if arguments array is numerically and sequentially indexed, then we want it to remain as is,
747 747
 			// else wrap it in an additional array so that it doesn't get split into multiple parameters
748
-			$arguments = $this->_array_is_numerically_and_sequentially_indexed( $arguments )
748
+			$arguments = $this->_array_is_numerically_and_sequentially_indexed($arguments)
749 749
 				? $arguments
750
-				: array( $arguments );
750
+				: array($arguments);
751 751
 			// attempt to inject dependencies ?
752
-			if ( $this->_dependency_map->has( $class_name ) ) {
753
-				$arguments = $this->_resolve_dependencies( $reflector, $class_name, $arguments );
752
+			if ($this->_dependency_map->has($class_name)) {
753
+				$arguments = $this->_resolve_dependencies($reflector, $class_name, $arguments);
754 754
 			}
755 755
 			// instantiate the class and add to the LIB array for tracking
756 756
 			// EE_Base_Classes are instantiated via new_instance by default (models call them via new_instance_from_db)
757
-			if ( $reflector->getConstructor() === null || $reflector->isAbstract() ) {
757
+			if ($reflector->getConstructor() === null || $reflector->isAbstract()) {
758 758
 				// no constructor = static methods only... nothing to instantiate, loading file was enough
759 759
 				//$instantiation_mode = "no constructor";
760 760
 				$class_obj = true;
761
-			} else if ( $from_db && method_exists( $class_name, 'new_instance_from_db' ) ) {
761
+			} else if ($from_db && method_exists($class_name, 'new_instance_from_db')) {
762 762
 				//$instantiation_mode = "new_instance_from_db";
763
-				$class_obj = call_user_func_array( array( $class_name, 'new_instance_from_db' ), $arguments );
764
-			} else if ( method_exists( $class_name, 'new_instance' ) ) {
763
+				$class_obj = call_user_func_array(array($class_name, 'new_instance_from_db'), $arguments);
764
+			} else if (method_exists($class_name, 'new_instance')) {
765 765
 				//$instantiation_mode = "new_instance";
766
-				$class_obj = call_user_func_array( array( $class_name, 'new_instance' ), $arguments );
767
-			} else if ( method_exists( $class_name, 'instance' ) ) {
766
+				$class_obj = call_user_func_array(array($class_name, 'new_instance'), $arguments);
767
+			} else if (method_exists($class_name, 'instance')) {
768 768
 				//$instantiation_mode = "instance";
769
-				$class_obj = call_user_func_array( array( $class_name, 'instance' ), $arguments );
770
-			} else if ( $reflector->isInstantiable() ) {
769
+				$class_obj = call_user_func_array(array($class_name, 'instance'), $arguments);
770
+			} else if ($reflector->isInstantiable()) {
771 771
 				//$instantiation_mode = "isInstantiable";
772
-				$class_obj = $reflector->newInstanceArgs( $arguments );
772
+				$class_obj = $reflector->newInstanceArgs($arguments);
773 773
 			} else {
774 774
 				// heh ? something's not right !
775 775
 				//$instantiation_mode = 'none';
776 776
 				throw new EE_Error(
777 777
 					sprintf(
778
-						__( 'The %s file %s could not be instantiated.', 'event_espresso' ),
778
+						__('The %s file %s could not be instantiated.', 'event_espresso'),
779 779
 						$type,
780 780
 						$class_name
781 781
 					)
782 782
 				);
783 783
 			}
784
-		} catch ( Exception $e ) {
785
-			if ( ! $e instanceof EE_Error ) {
786
-				$e = new EE_Error( $e->getMessage() );
784
+		} catch (Exception $e) {
785
+			if ( ! $e instanceof EE_Error) {
786
+				$e = new EE_Error($e->getMessage());
787 787
 			}
788 788
 			$e->get_error();
789 789
 		}
@@ -797,8 +797,8 @@  discard block
 block discarded – undo
797 797
 	 * @param array $array
798 798
 	 * @return bool
799 799
 	 */
800
-	protected function _array_is_numerically_and_sequentially_indexed( array $array ) {
801
-		return ! empty( $array ) ? array_keys( $array ) === range( 0, count( $array ) - 1 ) : true;
800
+	protected function _array_is_numerically_and_sequentially_indexed(array $array) {
801
+		return ! empty($array) ? array_keys($array) === range(0, count($array) - 1) : true;
802 802
 	}
803 803
 
804 804
 
@@ -813,14 +813,14 @@  discard block
 block discarded – undo
813 813
 	 * @param string $class_name
814 814
 	 * @return ReflectionClass
815 815
 	 */
816
-	public function get_ReflectionClass( $class_name ) {
816
+	public function get_ReflectionClass($class_name) {
817 817
 		if (
818
-			! isset( $this->_reflectors[ $class_name ] )
819
-			|| ! $this->_reflectors[ $class_name ] instanceof ReflectionClass
818
+			! isset($this->_reflectors[$class_name])
819
+			|| ! $this->_reflectors[$class_name] instanceof ReflectionClass
820 820
 		) {
821
-			$this->_reflectors[ $class_name ] = new ReflectionClass( $class_name );
821
+			$this->_reflectors[$class_name] = new ReflectionClass($class_name);
822 822
 		}
823
-		return $this->_reflectors[ $class_name ];
823
+		return $this->_reflectors[$class_name];
824 824
 	}
825 825
 
826 826
 
@@ -845,45 +845,45 @@  discard block
 block discarded – undo
845 845
 	 * @param array $arguments
846 846
 	 * @return array
847 847
 	 */
848
-	protected function _resolve_dependencies( ReflectionClass $reflector, $class_name, $arguments = array() ) {
848
+	protected function _resolve_dependencies(ReflectionClass $reflector, $class_name, $arguments = array()) {
849 849
 		// let's examine the constructor
850 850
 		$constructor = $reflector->getConstructor();
851 851
 		// whu? huh? nothing?
852
-		if ( ! $constructor ) {
852
+		if ( ! $constructor) {
853 853
 			return $arguments;
854 854
 		}
855 855
 		// get constructor parameters
856 856
 		$params = $constructor->getParameters();
857 857
 		// and the keys for the incoming arguments array so that we can compare existing arguments with what is expected
858
-		$argument_keys = array_keys( $arguments );
858
+		$argument_keys = array_keys($arguments);
859 859
 		// now loop thru all of the constructors expected parameters
860
-		foreach ( $params as $index => $param ) {
860
+		foreach ($params as $index => $param) {
861 861
 			// is this a dependency for a specific class ?
862 862
 			$param_class = $param->getClass() ? $param->getClass()->name : null;
863 863
 			if (
864 864
 				// param is not even a class
865
-				empty( $param_class )
865
+				empty($param_class)
866 866
 				// and something already exists in the incoming arguments for this param
867
-				&& isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] )
867
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
868 868
 			) {
869 869
 				// so let's skip this argument and move on to the next
870 870
 				continue;
871 871
 			} else if (
872 872
 				// parameter is type hinted as a class, exists as an incoming argument, AND it's the correct class
873
-				! empty( $param_class )
874
-				&& isset( $argument_keys[ $index ], $arguments[ $argument_keys[ $index ] ] )
875
-				&& $arguments[ $argument_keys[ $index ] ] instanceof $param_class
873
+				! empty($param_class)
874
+				&& isset($argument_keys[$index], $arguments[$argument_keys[$index]])
875
+				&& $arguments[$argument_keys[$index]] instanceof $param_class
876 876
 			) {
877 877
 				// skip this argument and move on to the next
878 878
 				continue;
879 879
 			} else if (
880 880
 				// parameter is type hinted as a class, and should be injected
881
-				! empty( $param_class )
882
-				&& $this->_dependency_map->has_dependency_for_class( $class_name, $param_class )
881
+				! empty($param_class)
882
+				&& $this->_dependency_map->has_dependency_for_class($class_name, $param_class)
883 883
 			) {
884
-				$arguments = $this->_resolve_dependency( $class_name, $param_class, $arguments, $index );
884
+				$arguments = $this->_resolve_dependency($class_name, $param_class, $arguments, $index);
885 885
 			} else {
886
-				$arguments[ $index ] = $param->getDefaultValue();
886
+				$arguments[$index] = $param->getDefaultValue();
887 887
 			}
888 888
 
889 889
 		}
@@ -900,7 +900,7 @@  discard block
 block discarded – undo
900 900
 	 * @param mixed $index
901 901
 	 * @return array
902 902
 	 */
903
-	protected function _resolve_dependency( $class_name, $param_class , $arguments, $index ) {
903
+	protected function _resolve_dependency($class_name, $param_class, $arguments, $index) {
904 904
 		$dependency = null;
905 905
 		// should dependency be loaded from cache ?
906 906
 		$cache_on = $this->_dependency_map->loading_strategy_for_class_dependency(
@@ -910,30 +910,30 @@  discard block
 block discarded – undo
910 910
 			: false;
911 911
 		// we might have a dependency...
912 912
 		// let's MAYBE try and find it in our cache if that's what's been requested
913
-		$cached_class = $cache_on ? $this->_get_cached_class( $param_class ) : null;
913
+		$cached_class = $cache_on ? $this->_get_cached_class($param_class) : null;
914 914
 		// and grab it if it exists
915
-		if ( $cached_class instanceof $param_class ) {
915
+		if ($cached_class instanceof $param_class) {
916 916
 			$dependency = $cached_class;
917
-		} else if ( $param_class != $class_name ) {
917
+		} else if ($param_class != $class_name) {
918 918
 			// obtain the loader method from the dependency map
919
-			$loader = $this->_dependency_map->class_loader( $param_class );
919
+			$loader = $this->_dependency_map->class_loader($param_class);
920 920
 			// is loader a custom closure ?
921
-			if ( $loader instanceof Closure ) {
921
+			if ($loader instanceof Closure) {
922 922
 				$dependency = $loader();
923 923
 			} else {
924 924
 				// set the cache on property for the recursive loading call
925 925
 				$this->_cache_on = $cache_on;
926 926
 				// if not, then let's try and load it via the registry
927
-				$dependency = $this->{$loader}( $param_class );
927
+				$dependency = $this->{$loader}($param_class);
928 928
 			}
929 929
 		}
930 930
 		// did we successfully find the correct dependency ?
931
-		if ( $dependency instanceof $param_class ) {
931
+		if ($dependency instanceof $param_class) {
932 932
 			// then let's inject it into the incoming array of arguments at the correct location
933
-			if ( isset( $argument_keys[ $index ] ) ) {
934
-				$arguments[ $argument_keys[ $index ] ] = $dependency;
933
+			if (isset($argument_keys[$index])) {
934
+				$arguments[$argument_keys[$index]] = $dependency;
935 935
 			} else {
936
-				$arguments[ $index ] = $dependency;
936
+				$arguments[$index] = $dependency;
937 937
 			}
938 938
 		}
939 939
 		return $arguments;
@@ -958,16 +958,16 @@  discard block
 block discarded – undo
958 958
 	 * @param bool $from_db
959 959
 	 * @return void
960 960
 	 */
961
-	protected function _set_cached_class( $class_obj, $class_name, $class_prefix = '', $from_db = false ) {
961
+	protected function _set_cached_class($class_obj, $class_name, $class_prefix = '', $from_db = false) {
962 962
 		// return newly instantiated class
963
-		if ( isset( $this->_class_abbreviations[ $class_name ] ) ) {
964
-			$class_abbreviation = $this->_class_abbreviations[ $class_name ];
963
+		if (isset($this->_class_abbreviations[$class_name])) {
964
+			$class_abbreviation = $this->_class_abbreviations[$class_name];
965 965
 			$this->{$class_abbreviation} = $class_obj;
966
-		} else if ( property_exists( $this, $class_name ) ) {
966
+		} else if (property_exists($this, $class_name)) {
967 967
 			$this->{$class_name} = $class_obj;
968
-		} else if ( $class_prefix == 'addon' ) {
968
+		} else if ($class_prefix == 'addon') {
969 969
 			$this->addons->{$class_name} = $class_obj;
970
-		} else if ( ! $from_db ) {
970
+		} else if ( ! $from_db) {
971 971
 			$this->LIB->{$class_name} = $class_obj;
972 972
 		}
973 973
 	}
@@ -984,12 +984,12 @@  discard block
 block discarded – undo
984 984
 	 * @param array  $arguments
985 985
 	 * @return object
986 986
 	 */
987
-	public static function factory( $classname, $arguments = array() ) {
988
-		$loader = self::instance()->_dependency_map->class_loader( $classname );
989
-		if ( $loader instanceof Closure ) {
990
-			return $loader( $arguments );
991
-		} else if ( method_exists( EE_Registry::instance(), $loader ) ) {
992
-			return EE_Registry::instance()->{$loader}( $classname, $arguments );
987
+	public static function factory($classname, $arguments = array()) {
988
+		$loader = self::instance()->_dependency_map->class_loader($classname);
989
+		if ($loader instanceof Closure) {
990
+			return $loader($arguments);
991
+		} else if (method_exists(EE_Registry::instance(), $loader)) {
992
+			return EE_Registry::instance()->{$loader}($classname, $arguments);
993 993
 		}
994 994
 		return null;
995 995
 	}
@@ -1002,9 +1002,9 @@  discard block
 block discarded – undo
1002 1002
 	 * @param string $name
1003 1003
 	 * @return EE_Addon
1004 1004
 	 */
1005
-	public function get_addon_by_name( $name ) {
1006
-		foreach ( $this->addons as $addon ) {
1007
-			if ( $addon->name() == $name ) {
1005
+	public function get_addon_by_name($name) {
1006
+		foreach ($this->addons as $addon) {
1007
+			if ($addon->name() == $name) {
1008 1008
 				return $addon;
1009 1009
 			}
1010 1010
 		}
@@ -1020,8 +1020,8 @@  discard block
 block discarded – undo
1020 1020
 	 */
1021 1021
 	public function get_addons_by_name() {
1022 1022
 		$addons = array();
1023
-		foreach ( $this->addons as $addon ) {
1024
-			$addons[ $addon->name() ] = $addon;
1023
+		foreach ($this->addons as $addon) {
1024
+			$addons[$addon->name()] = $addon;
1025 1025
 		}
1026 1026
 		return $addons;
1027 1027
 	}
@@ -1036,14 +1036,14 @@  discard block
 block discarded – undo
1036 1036
 	 * @return \EEM_Base
1037 1037
 	 * @throws \EE_Error
1038 1038
 	 */
1039
-	public function reset_model( $model_name ) {
1040
-		$model = $this->load_model( $model_name );
1041
-		$model_class_name = get_class( $model );
1039
+	public function reset_model($model_name) {
1040
+		$model = $this->load_model($model_name);
1041
+		$model_class_name = get_class($model);
1042 1042
 		//get that model reset it and make sure we nuke the old reference to it
1043
-		if ( $model instanceof $model_class_name && is_callable( array( $model_class_name, 'reset' ))) {
1043
+		if ($model instanceof $model_class_name && is_callable(array($model_class_name, 'reset'))) {
1044 1044
 			$this->LIB->{$model_class_name} = $model::reset();
1045 1045
 		} else {
1046
-			throw new EE_Error( sprintf( __( 'Model %s does not have a method "reset"', 'event_espresso' ), $model_name ) );
1046
+			throw new EE_Error(sprintf(__('Model %s does not have a method "reset"', 'event_espresso'), $model_name));
1047 1047
 		}
1048 1048
 		return $this->LIB->{$model_class_name};
1049 1049
 	}
@@ -1061,15 +1061,15 @@  discard block
 block discarded – undo
1061 1061
 	 * currently reinstantiate the singletons at the moment)
1062 1062
 	 * @return EE_Registry
1063 1063
 	 */
1064
-	public static function reset( $hard = false, $reinstantiate = true ) {
1064
+	public static function reset($hard = false, $reinstantiate = true) {
1065 1065
 		$instance = self::instance();
1066 1066
 		EEH_Activation::reset();
1067 1067
 		$instance->_cache_on = true;
1068
-		$instance->CFG = EE_Config::reset( $hard, $reinstantiate );
1068
+		$instance->CFG = EE_Config::reset($hard, $reinstantiate);
1069 1069
 		$instance->LIB->EE_Data_Migration_Manager = EE_Data_Migration_Manager::reset();
1070 1070
 		$instance->LIB = new stdClass();
1071
-		foreach ( array_keys( $instance->non_abstract_db_models ) as $model_name ) {
1072
-			$instance->reset_model( $model_name );
1071
+		foreach (array_keys($instance->non_abstract_db_models) as $model_name) {
1072
+			$instance->reset_model($model_name);
1073 1073
 		}
1074 1074
 		return $instance;
1075 1075
 	}
@@ -1089,7 +1089,7 @@  discard block
 block discarded – undo
1089 1089
 	 * @param $a
1090 1090
 	 * @param $b
1091 1091
 	 */
1092
-	final function __call( $a, $b ) {
1092
+	final function __call($a, $b) {
1093 1093
 	}
1094 1094
 
1095 1095
 
@@ -1097,7 +1097,7 @@  discard block
 block discarded – undo
1097 1097
 	/**
1098 1098
 	 * @param $a
1099 1099
 	 */
1100
-	final function __get( $a ) {
1100
+	final function __get($a) {
1101 1101
 	}
1102 1102
 
1103 1103
 
@@ -1106,7 +1106,7 @@  discard block
 block discarded – undo
1106 1106
 	 * @param $a
1107 1107
 	 * @param $b
1108 1108
 	 */
1109
-	final function __set( $a, $b ) {
1109
+	final function __set($a, $b) {
1110 1110
 	}
1111 1111
 
1112 1112
 
@@ -1114,7 +1114,7 @@  discard block
 block discarded – undo
1114 1114
 	/**
1115 1115
 	 * @param $a
1116 1116
 	 */
1117
-	final function __isset( $a ) {
1117
+	final function __isset($a) {
1118 1118
 	}
1119 1119
 
1120 1120
 
@@ -1122,7 +1122,7 @@  discard block
 block discarded – undo
1122 1122
 	/**
1123 1123
 	 * @param $a
1124 1124
 	 */
1125
-	final function __unset( $a ) {
1125
+	final function __unset($a) {
1126 1126
 	}
1127 1127
 
1128 1128
 
@@ -1169,7 +1169,7 @@  discard block
 block discarded – undo
1169 1169
 	 * @param $a
1170 1170
 	 * @param $b
1171 1171
 	 */
1172
-	final static function __callStatic( $a, $b ) {
1172
+	final static function __callStatic($a, $b) {
1173 1173
 	}
1174 1174
 
1175 1175
 	/**
@@ -1178,9 +1178,9 @@  discard block
 block discarded – undo
1178 1178
 	 */
1179 1179
 	public function cpt_models() {
1180 1180
 		$cpt_models = array();
1181
-		foreach( $this->non_abstract_db_models as $short_name => $classname ) {
1182
-			if( is_subclass_of(  $classname, 'EEM_CPT_Base' ) ) {
1183
-				$cpt_models[ $short_name ] = $classname;
1181
+		foreach ($this->non_abstract_db_models as $short_name => $classname) {
1182
+			if (is_subclass_of($classname, 'EEM_CPT_Base')) {
1183
+				$cpt_models[$short_name] = $classname;
1184 1184
 			}
1185 1185
 		}
1186 1186
 		return $cpt_models;
Please login to merge, or discard this patch.
core/EE_Request_Handler.core.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -351,7 +351,7 @@  discard block
 block discarded – undo
351 351
 	 *    remove param
352 352
 	 *
353 353
 	 * @access    public
354
-	 * @param $key
354
+	 * @param string $key
355 355
 	 * @return    void
356 356
 	 */
357 357
 	public function un_set( $key ) {
@@ -391,7 +391,7 @@  discard block
 block discarded – undo
391 391
 	 *    add_output
392 392
 	 *
393 393
 	 * @access    public
394
-	 * @param $string
394
+	 * @param string $string
395 395
 	 * @return    void
396 396
 	 */
397 397
 	public function add_output( $string ) {
@@ -456,14 +456,14 @@  discard block
 block discarded – undo
456 456
 
457 457
 
458 458
 	/**
459
-	 * @return bool
459
+	 * @return boolean|null
460 460
 	 */
461 461
 	public function __clone() {}
462 462
 
463 463
 
464 464
 
465 465
 	/**
466
-	 * @return bool
466
+	 * @return boolean|null
467 467
 	 */
468 468
 	public function __wakeup() {}
469 469
 
Please login to merge, or discard this patch.
Spacing   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -1,4 +1,4 @@  discard block
 block discarded – undo
1
-<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed');}
1
+<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) {exit('No direct script access allowed'); }
2 2
 /**
3 3
  * class EE_Request_Handler
4 4
  *
@@ -50,13 +50,13 @@  discard block
 block discarded – undo
50 50
 	 * @param  EE_Request $request
51 51
 	 * @return \EE_Request_Handler
52 52
 	 */
53
-	public function __construct( EE_Request $request ) {
53
+	public function __construct(EE_Request $request) {
54 54
 		// grab request vars
55 55
 		$this->_params = $request->params();
56 56
 		// AJAX ???
57
-		$this->ajax = defined( 'DOING_AJAX' ) && DOING_AJAX ? true : false;
58
-		$this->front_ajax = defined( 'EE_FRONT_AJAX' ) && EE_FRONT_AJAX ? true : false;
59
-		do_action( 'AHEE__EE_Request_Handler__construct__complete' );
57
+		$this->ajax = defined('DOING_AJAX') && DOING_AJAX ? true : false;
58
+		$this->front_ajax = defined('EE_FRONT_AJAX') && EE_FRONT_AJAX ? true : false;
59
+		do_action('AHEE__EE_Request_Handler__construct__complete');
60 60
 	}
61 61
 
62 62
 
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
 	 * @param WP $wp
69 69
 	 * @return void
70 70
 	 */
71
-	public function parse_request( $wp = null ) {
71
+	public function parse_request($wp = null) {
72 72
 		//if somebody forgot to provide us with WP, that's ok because its global
73
-		if ( ! $wp instanceof WP ) {
73
+		if ( ! $wp instanceof WP) {
74 74
 			global $wp;
75 75
 		}
76
-		$this->set_request_vars( $wp );
76
+		$this->set_request_vars($wp);
77 77
 	}
78 78
 
79 79
 
@@ -85,14 +85,14 @@  discard block
 block discarded – undo
85 85
 	 * @param WP $wp
86 86
 	 * @return void
87 87
 	 */
88
-	public function set_request_vars( $wp = null ) {
89
-		if ( ! is_admin() ) {
88
+	public function set_request_vars($wp = null) {
89
+		if ( ! is_admin()) {
90 90
 			// set request post_id
91
-			$this->set( 'post_id', $this->get_post_id_from_request( $wp ));
91
+			$this->set('post_id', $this->get_post_id_from_request($wp));
92 92
 			// set request post name
93
-			$this->set( 'post_name', $this->get_post_name_from_request( $wp ));
93
+			$this->set('post_name', $this->get_post_name_from_request($wp));
94 94
 			// set request post_type
95
-			$this->set( 'post_type', $this->get_post_type_from_request( $wp ));
95
+			$this->set('post_type', $this->get_post_type_from_request($wp));
96 96
 			// true or false ? is this page being used by EE ?
97 97
 			$this->set_espresso_page();
98 98
 		}
@@ -107,19 +107,19 @@  discard block
 block discarded – undo
107 107
 	 * @param WP $wp
108 108
 	 * @return int
109 109
 	 */
110
-	public function get_post_id_from_request( $wp = null ) {
111
-		if ( ! $wp instanceof WP ){
110
+	public function get_post_id_from_request($wp = null) {
111
+		if ( ! $wp instanceof WP) {
112 112
 			global $wp;
113 113
 		}
114 114
 		$post_id = null;
115
-		if ( isset( $wp->query_vars['p'] )) {
115
+		if (isset($wp->query_vars['p'])) {
116 116
 			$post_id = $wp->query_vars['p'];
117 117
 		}
118
-		if ( ! $post_id && isset( $wp->query_vars['page_id'] )) {
118
+		if ( ! $post_id && isset($wp->query_vars['page_id'])) {
119 119
 			$post_id = $wp->query_vars['page_id'];
120 120
 		}
121
-		if ( ! $post_id && isset( $wp->request ) && is_numeric( basename( $wp->request ))) {
122
-			$post_id = basename( $wp->request );
121
+		if ( ! $post_id && isset($wp->request) && is_numeric(basename($wp->request))) {
122
+			$post_id = basename($wp->request);
123 123
 		}
124 124
 		return $post_id;
125 125
 	}
@@ -133,35 +133,35 @@  discard block
 block discarded – undo
133 133
 	 * @param WP $wp
134 134
 	 * @return string
135 135
 	 */
136
-	public function get_post_name_from_request( $wp = null ) {
137
-		if ( ! $wp instanceof WP ){
136
+	public function get_post_name_from_request($wp = null) {
137
+		if ( ! $wp instanceof WP) {
138 138
 			global $wp;
139 139
 		}
140 140
 		$post_name = null;
141
-		if ( isset( $wp->query_vars['name'] ) && ! empty( $wp->query_vars['name'] )) {
141
+		if (isset($wp->query_vars['name']) && ! empty($wp->query_vars['name'])) {
142 142
 			$post_name = $wp->query_vars['name'];
143 143
 		}
144
-		if ( ! $post_name && isset( $wp->query_vars['pagename'] ) && ! empty( $wp->query_vars['pagename'] )) {
144
+		if ( ! $post_name && isset($wp->query_vars['pagename']) && ! empty($wp->query_vars['pagename'])) {
145 145
 			$post_name = $wp->query_vars['pagename'];
146 146
 		}
147
-		if ( ! $post_name && isset( $wp->request ) && ! empty( $wp->request )) {
148
-			$possible_post_name = basename( $wp->request );
149
-			if ( ! is_numeric( $possible_post_name )) {
147
+		if ( ! $post_name && isset($wp->request) && ! empty($wp->request)) {
148
+			$possible_post_name = basename($wp->request);
149
+			if ( ! is_numeric($possible_post_name)) {
150 150
 				/** @type WPDB $wpdb */
151 151
 				global $wpdb;
152 152
 				$SQL = "SELECT ID from $wpdb->posts WHERE post_status='publish' AND post_name=%s";
153
-				$possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $possible_post_name ));
154
-				if ( $possible_post_name ) {
153
+				$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $possible_post_name));
154
+				if ($possible_post_name) {
155 155
 					$post_name = $possible_post_name;
156 156
 				}
157 157
 			}
158 158
 		}
159
-		if ( ! $post_name && $this->get( 'post_id' )) {
159
+		if ( ! $post_name && $this->get('post_id')) {
160 160
 			/** @type WPDB $wpdb */
161 161
 			global $wpdb;
162 162
 			$SQL = "SELECT post_name from $wpdb->posts WHERE post_status='publish' AND ID=%d";
163
-			$possible_post_name = $wpdb->get_var( $wpdb->prepare( $SQL, $this->get( 'post_id' )));
164
-			if( $possible_post_name ) {
163
+			$possible_post_name = $wpdb->get_var($wpdb->prepare($SQL, $this->get('post_id')));
164
+			if ($possible_post_name) {
165 165
 				$post_name = $possible_post_name;
166 166
 			}
167 167
 		}
@@ -177,11 +177,11 @@  discard block
 block discarded – undo
177 177
 	 * @param WP $wp
178 178
 	 * @return mixed
179 179
 	 */
180
-	public function get_post_type_from_request( $wp = null ) {
181
-		if ( ! $wp instanceof WP ){
180
+	public function get_post_type_from_request($wp = null) {
181
+		if ( ! $wp instanceof WP) {
182 182
 			global $wp;
183 183
 		}
184
-		return isset( $wp->query_vars['post_type'] ) ? $wp->query_vars['post_type'] : null;
184
+		return isset($wp->query_vars['post_type']) ? $wp->query_vars['post_type'] : null;
185 185
 	}
186 186
 
187 187
 
@@ -191,18 +191,18 @@  discard block
 block discarded – undo
191 191
 	 * @param  WP $wp
192 192
 	 * @return bool|string|void
193 193
 	 */
194
-	public function get_current_page_permalink( $wp = null ) {
195
-		$post_id = $this->get_post_id_from_request( $wp );
196
-		if ( $post_id ) {
197
-			$current_page_permalink = get_permalink( $post_id );
194
+	public function get_current_page_permalink($wp = null) {
195
+		$post_id = $this->get_post_id_from_request($wp);
196
+		if ($post_id) {
197
+			$current_page_permalink = get_permalink($post_id);
198 198
 		} else {
199
-			if ( ! $wp instanceof WP ) {
199
+			if ( ! $wp instanceof WP) {
200 200
 				global $wp;
201 201
 			}
202
-			if ( $wp->request ) {
203
-				$current_page_permalink = site_url( $wp->request );
202
+			if ($wp->request) {
203
+				$current_page_permalink = site_url($wp->request);
204 204
 			} else {
205
-				$current_page_permalink = esc_url( site_url( $_SERVER[ 'REQUEST_URI' ] ) );
205
+				$current_page_permalink = esc_url(site_url($_SERVER['REQUEST_URI']));
206 206
 			}
207 207
 		}
208 208
 		return $current_page_permalink;
@@ -219,41 +219,41 @@  discard block
 block discarded – undo
219 219
 	public function test_for_espresso_page() {
220 220
 		global $wp;
221 221
 		/** @type EE_CPT_Strategy $EE_CPT_Strategy */
222
-		$EE_CPT_Strategy = EE_Registry::instance()->load_core( 'CPT_Strategy' );
222
+		$EE_CPT_Strategy = EE_Registry::instance()->load_core('CPT_Strategy');
223 223
 		$espresso_CPT_taxonomies = $EE_CPT_Strategy->get_CPT_taxonomies();
224
-		if ( is_array( $espresso_CPT_taxonomies ) ) {
225
-			foreach ( $espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details ) {
226
-				if ( isset( $wp->query_vars, $wp->query_vars[ $espresso_CPT_taxonomy ] ) ) {
224
+		if (is_array($espresso_CPT_taxonomies)) {
225
+			foreach ($espresso_CPT_taxonomies as $espresso_CPT_taxonomy =>$details) {
226
+				if (isset($wp->query_vars, $wp->query_vars[$espresso_CPT_taxonomy])) {
227 227
 					return true;
228 228
 				}
229 229
 			}
230 230
 		}
231 231
 		// load espresso CPT endpoints
232 232
 		$espresso_CPT_endpoints = $EE_CPT_Strategy->get_CPT_endpoints();
233
-		$post_type_CPT_endpoints = array_flip( $espresso_CPT_endpoints );
234
-		$post_types = (array)$this->get( 'post_type' );
235
-		foreach ( $post_types as $post_type ) {
233
+		$post_type_CPT_endpoints = array_flip($espresso_CPT_endpoints);
234
+		$post_types = (array) $this->get('post_type');
235
+		foreach ($post_types as $post_type) {
236 236
 			// was a post name passed ?
237
-			if ( isset( $post_type_CPT_endpoints[ $post_type ] ) ) {
237
+			if (isset($post_type_CPT_endpoints[$post_type])) {
238 238
 				// kk we know this is an espresso page, but is it a specific post ?
239
-				if ( ! $this->get( 'post_name' ) ) {
239
+				if ( ! $this->get('post_name')) {
240 240
 					// there's no specific post name set, so maybe it's one of our endpoints like www.domain.com/events
241
-					$post_name = isset( $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] ) ? $post_type_CPT_endpoints[ $this->get( 'post_type' ) ] : null;
241
+					$post_name = isset($post_type_CPT_endpoints[$this->get('post_type')]) ? $post_type_CPT_endpoints[$this->get('post_type')] : null;
242 242
 					// if the post type matches on of our then set the endpoint
243
-					if ( $post_name ) {
244
-						$this->set( 'post_name', $post_name );
243
+					if ($post_name) {
244
+						$this->set('post_name', $post_name);
245 245
 					}
246 246
 				}
247 247
 				return true;
248 248
 			}
249 249
 		}
250
-		if ( $this->get( 'post_name' )) {
250
+		if ($this->get('post_name')) {
251 251
 			// load all pages using espresso shortcodes
252
-			$post_shortcodes = isset( EE_Registry::instance()->CFG->core->post_shortcodes ) ? EE_Registry::instance()->CFG->core->post_shortcodes : array();
252
+			$post_shortcodes = isset(EE_Registry::instance()->CFG->core->post_shortcodes) ? EE_Registry::instance()->CFG->core->post_shortcodes : array();
253 253
 			// make sure core pages are included
254
-			$espresso_pages = array_merge( $espresso_CPT_endpoints, $post_shortcodes );
254
+			$espresso_pages = array_merge($espresso_CPT_endpoints, $post_shortcodes);
255 255
 			// was a post name passed ?
256
-			if (  isset( $espresso_pages[ $this->get( 'post_name' ) ] )) {
256
+			if (isset($espresso_pages[$this->get('post_name')])) {
257 257
 				 return true;
258 258
 			}
259 259
 		}
@@ -269,7 +269,7 @@  discard block
 block discarded – undo
269 269
 	 * @param null|bool $value
270 270
 	 * @return    mixed
271 271
 	 */
272
-	public function set_espresso_page( $value = null ) {
272
+	public function set_espresso_page($value = null) {
273 273
 		$value = $value ? $value : $this->test_for_espresso_page();
274 274
 		$this->_params['is_espresso_page'] = $value;
275 275
 	}
@@ -283,7 +283,7 @@  discard block
 block discarded – undo
283 283
 	 *  @return 	mixed
284 284
 	 */
285 285
 	public function is_espresso_page() {
286
-		return isset( $this->_params['is_espresso_page'] ) ? $this->_params['is_espresso_page'] : false;
286
+		return isset($this->_params['is_espresso_page']) ? $this->_params['is_espresso_page'] : false;
287 287
 	}
288 288
 
289 289
 
@@ -307,14 +307,14 @@  discard block
 block discarded – undo
307 307
 	 * @param bool $override_ee
308 308
 	 * @return    void
309 309
 	 */
310
-	public function set( $key, $value, $override_ee = false ) {
310
+	public function set($key, $value, $override_ee = false) {
311 311
 		// don't allow "ee" to be overwritten unless explicitly instructed to do so
312 312
 		if (
313 313
 			$key !== 'ee' ||
314
-			( $key === 'ee' && empty( $this->_params['ee'] ))
315
-			|| ( $key === 'ee' && ! empty( $this->_params['ee'] ) && $override_ee )
314
+			($key === 'ee' && empty($this->_params['ee']))
315
+			|| ($key === 'ee' && ! empty($this->_params['ee']) && $override_ee)
316 316
 		) {
317
-			$this->_params[ $key ] = $value;
317
+			$this->_params[$key] = $value;
318 318
 		}
319 319
 	}
320 320
 
@@ -328,8 +328,8 @@  discard block
 block discarded – undo
328 328
 	 * @param null $default
329 329
 	 * @return    mixed
330 330
 	 */
331
-	public function get( $key, $default = null ) {
332
-		return isset( $this->_params[ $key ] ) ? $this->_params[ $key ] : $default;
331
+	public function get($key, $default = null) {
332
+		return isset($this->_params[$key]) ? $this->_params[$key] : $default;
333 333
 	}
334 334
 
335 335
 
@@ -341,8 +341,8 @@  discard block
 block discarded – undo
341 341
 	 * @param $key
342 342
 	 * @return    boolean
343 343
 	 */
344
-	public function is_set( $key ) {
345
-		return isset( $this->_params[ $key ] ) ? true : false;
344
+	public function is_set($key) {
345
+		return isset($this->_params[$key]) ? true : false;
346 346
 	}
347 347
 
348 348
 
@@ -354,8 +354,8 @@  discard block
 block discarded – undo
354 354
 	 * @param $key
355 355
 	 * @return    void
356 356
 	 */
357
-	public function un_set( $key ) {
358
-		unset( $this->_params[ $key ] );
357
+	public function un_set($key) {
358
+		unset($this->_params[$key]);
359 359
 	}
360 360
 
361 361
 
@@ -368,8 +368,8 @@  discard block
 block discarded – undo
368 368
 	 * @param $value
369 369
 	 * @return    void
370 370
 	 */
371
-	public function set_notice( $key, $value ) {
372
-		$this->_notice[ $key ] = $value;
371
+	public function set_notice($key, $value) {
372
+		$this->_notice[$key] = $value;
373 373
 	}
374 374
 
375 375
 
@@ -381,8 +381,8 @@  discard block
 block discarded – undo
381 381
 	 * @param $key
382 382
 	 * @return    mixed
383 383
 	 */
384
-	public function get_notice( $key ) {
385
-		return isset( $this->_notice[ $key ] ) ? $this->_notice[ $key ] : null;
384
+	public function get_notice($key) {
385
+		return isset($this->_notice[$key]) ? $this->_notice[$key] : null;
386 386
 	}
387 387
 
388 388
 
@@ -394,7 +394,7 @@  discard block
 block discarded – undo
394 394
 	 * @param $string
395 395
 	 * @return    void
396 396
 	 */
397
-	public function add_output( $string ) {
397
+	public function add_output($string) {
398 398
 		$this->_output .= $string;
399 399
 	}
400 400
 
@@ -416,8 +416,8 @@  discard block
 block discarded – undo
416 416
 	 * @param $item
417 417
 	 * @param $key
418 418
 	 */
419
-	public function sanitize_text_field_for_array_walk( &$item, &$key ) {
420
-		$item = strpos( $item, 'email' ) !== false ? sanitize_email( $item ) : sanitize_text_field( $item );
419
+	public function sanitize_text_field_for_array_walk(&$item, &$key) {
420
+		$item = strpos($item, 'email') !== false ? sanitize_email($item) : sanitize_text_field($item);
421 421
 	}
422 422
 
423 423
 
@@ -427,7 +427,7 @@  discard block
 block discarded – undo
427 427
 	 * @param $b
428 428
 	 * @return bool
429 429
 	 */
430
-	public function __set($a,$b) { return false; }
430
+	public function __set($a, $b) { return false; }
431 431
 
432 432
 
433 433
 
Please login to merge, or discard this patch.
admin/extend/messages/Custom_Messages_Template_List_Table.class.php 1 patch
Spacing   +59 added lines, -59 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,7 +30,7 @@  discard block
 block discarded – undo
30 30
 class Custom_Messages_Template_List_Table extends EE_Admin_List_Table {
31 31
 
32 32
 
33
-	public function __construct( $admin_page ) {
33
+	public function __construct($admin_page) {
34 34
 		//Set parent defaults
35 35
 		parent::__construct($admin_page);
36 36
 	}
@@ -49,8 +49,8 @@  discard block
 block discarded – undo
49 49
 
50 50
 
51 51
 	protected function _setup_data() {
52
-		$this->_data = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, FALSE, FALSE, FALSE );
53
-		$this->_all_data_count = $this->get_admin_page()->get_message_templates( $this->_per_page, $this->_view, TRUE, TRUE, FALSE );
52
+		$this->_data = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, FALSE, FALSE, FALSE);
53
+		$this->_all_data_count = $this->get_admin_page()->get_message_templates($this->_per_page, $this->_view, TRUE, TRUE, FALSE);
54 54
 	}
55 55
 
56 56
 
@@ -59,8 +59,8 @@  discard block
 block discarded – undo
59 59
 
60 60
 	protected function _set_properties() {
61 61
 		$this->_wp_list_args = array(
62
-			'singular' => __('Message Template Group', 'event_espresso' ),
63
-			'plural' => __('Message Template', 'event_espresso' ),
62
+			'singular' => __('Message Template Group', 'event_espresso'),
63
+			'plural' => __('Message Template', 'event_espresso'),
64 64
 			'ajax' => TRUE, //for now,
65 65
 			'screen' => $this->get_admin_page()->get_current_screen()->id
66 66
 			);
@@ -69,15 +69,15 @@  discard block
 block discarded – undo
69 69
 			'cb' => '<input type="checkbox" />',
70 70
 			'name' => __('Template Name', 'event_espresso'),
71 71
 			'message_type' => __('Message Type', 'event_espresso'),
72
-			'messenger' => __( 'Messenger', 'event_espresso'),
73
-			'description' => __( 'Description', 'event_espresso' ),
74
-			'events' => __( 'Events', 'event_espresso'), //count of events using this template.
72
+			'messenger' => __('Messenger', 'event_espresso'),
73
+			'description' => __('Description', 'event_espresso'),
74
+			'events' => __('Events', 'event_espresso'), //count of events using this template.
75 75
 			'actions' => ''
76 76
 			//'messages_sent' => __( 'Total Sent', 'event_espresso' ) //todo this will come later when we've got message tracking in place.
77 77
 			);
78 78
 
79 79
 		$this->_sortable_columns = array(
80
-			'messenger' => array( 'MTP_messenger' => TRUE ),
80
+			'messenger' => array('MTP_messenger' => TRUE),
81 81
 			//'message_type' => array( 'MTP_message_type' => FALSE )
82 82
 			);
83 83
 
@@ -96,16 +96,16 @@  discard block
 block discarded – undo
96 96
 	 *
97 97
 	 * @return string
98 98
 	 */
99
-	public function single_row( $item ) {
99
+	public function single_row($item) {
100 100
 		$message_type = $item->message_type_obj();
101 101
 		$messenger = $item->messenger_obj();
102 102
 
103
-		if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger ) {
103
+		if ( ! $message_type instanceof EE_message_type || ! $messenger instanceof EE_messenger) {
104 104
 			echo '';
105 105
 			return;
106 106
 		}
107 107
 
108
-		parent::single_row( $item );
108
+		parent::single_row($item);
109 109
 	}
110 110
 
111 111
 
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
 		$mt_values = $this->get_admin_page()->get_message_types_for_list_table();
122 122
 		//setup messengers for selects
123 123
 		$m_values[0]['id'] = 'all';
124
-		$m_values[0]['text'] = __('All Messengers', 'event_espresso' );
124
+		$m_values[0]['text'] = __('All Messengers', 'event_espresso');
125 125
 
126 126
 		$msgr_default[0] = array(
127 127
 			'id' => 'none_selected',
@@ -133,28 +133,28 @@  discard block
 block discarded – undo
133 133
 			'text' => __('Show All', 'event_espresso')
134 134
 			);
135 135
 
136
-		$msgr_filters = !empty($m_values) ? array_merge( $msgr_default, $m_values ) : array();
137
-		$mt_filters = !empty($mt_values) ? array_merge( $mt_default, $mt_values ) : array();
136
+		$msgr_filters = ! empty($m_values) ? array_merge($msgr_default, $m_values) : array();
137
+		$mt_filters = ! empty($mt_values) ? array_merge($mt_default, $mt_values) : array();
138 138
 
139
-		if ( empty( $m_values ) )
139
+		if (empty($m_values))
140 140
 			$msgr_filters[0] = array(
141 141
 				'id' => 'no_messenger_options',
142 142
 				'text' => __('No Messengers active', 'event_espresso')
143 143
 				);
144 144
 
145
-		if ( empty($mt_values) )
145
+		if (empty($mt_values))
146 146
 			$mt_filters[0] = array(
147 147
 				'id' => 'no_message_type_options',
148 148
 				'text' => __('No Message Types active', 'event_espresso')
149 149
 				);
150 150
 
151
-		if ( count( $m_values ) >= 1  && !empty( $m_values ) ) {
152
-			unset( $msgr_filters[0] );
153
-			$msgr_filters = array_values( $msgr_filters ); //reindex keys
151
+		if (count($m_values) >= 1 && ! empty($m_values)) {
152
+			unset($msgr_filters[0]);
153
+			$msgr_filters = array_values($msgr_filters); //reindex keys
154 154
 		}
155 155
 
156
-		$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']) : '' );
157
-		$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']) : '');
156
+		$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']) : '');
157
+		$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']) : '');
158 158
 		return $filters;
159 159
 	}
160 160
 
@@ -162,14 +162,14 @@  discard block
 block discarded – undo
162 162
 	 * we're just removing the search box for message templates, not needed.
163 163
 	 * @return string (empty);
164 164
 	 */
165
-	function search_box( $text, $input_id ) {
165
+	function search_box($text, $input_id) {
166 166
 		return '';
167 167
 	}
168 168
 
169 169
 
170 170
 	protected function _add_view_counts() {
171
-		foreach ( $this->_views as $view => $args )  {
172
-			$this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( $this->_per_page, $view, TRUE, TRUE, FALSE );
171
+		foreach ($this->_views as $view => $args) {
172
+			$this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates($this->_per_page, $view, TRUE, TRUE, FALSE);
173 173
 		}
174 174
 	}
175 175
 
@@ -183,16 +183,16 @@  discard block
 block discarded – undo
183 183
 	 * @return string
184 184
 	 */
185 185
 	public function no_items() {
186
-		if ( $this->_view !== 'trashed' )
187
-			printf( __('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>' );
186
+		if ($this->_view !== 'trashed')
187
+			printf(__('%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', 'event_espresso'), '<strong>', '</strong>');
188 188
 		else
189 189
 			parent::no_items();
190 190
 	}
191 191
 
192 192
 
193 193
 
194
-	public function column_cb( $item ) {
195
-		return sprintf( '<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID() );
194
+	public function column_cb($item) {
195
+		return sprintf('<input type="checkbox" name="checkbox[%s] value="1" />', $item->GRP_ID());
196 196
 	}
197 197
 
198 198
 
@@ -200,29 +200,29 @@  discard block
 block discarded – undo
200 200
 
201 201
 
202 202
 
203
-	function column_name( $item ) {
204
-		return '<p>' . $item->name() . '</p>';
203
+	function column_name($item) {
204
+		return '<p>'.$item->name().'</p>';
205 205
 	}
206 206
 
207 207
 
208 208
 
209 209
 
210
-	function column_description( $item ) {
211
-		return '<p>' . $item->description() . '</p>';
210
+	function column_description($item) {
211
+		return '<p>'.$item->description().'</p>';
212 212
 	}
213 213
 
214 214
 
215 215
 
216
-	function column_actions( $item ) {
217
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_edit_messages', 'espresso_messages_add_new_message_template' ) ) {
216
+	function column_actions($item) {
217
+		if (EE_Registry::instance()->CAP->current_user_can('ee_edit_messages', 'espresso_messages_add_new_message_template')) {
218 218
 			$create_args = array(
219 219
 				'GRP_ID' => $item->ID(),
220 220
 				'messenger' => $item->messenger(),
221 221
 				'message_type' => $item->message_type(),
222 222
 				'action' => 'add_new_message_template'
223 223
 				);
224
-			$create_link = EE_Admin_Page::add_query_args_and_nonce( $create_args, EE_MSG_ADMIN_URL );
225
-			return sprintf( '<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso') );
224
+			$create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL);
225
+			return sprintf('<p><a href="%s" class="button button-small">%s</a></p>', $create_link, __('Create Custom', 'event_espresso'));
226 226
 		}
227 227
 		return '';
228 228
 	}
@@ -239,27 +239,27 @@  discard block
 block discarded – undo
239 239
 		$actions = array();
240 240
 
241 241
 		// edit link but only if item isn't trashed.
242
-		if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_edit_message', 'espresso_messages_edit_message_template', $item->ID() ) ) {
243
-			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'edit_message_template', 'id'=>$item->GRP_ID() ), EE_MSG_ADMIN_URL );
244
-			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="' . esc_attr__( 'Edit Template', 'event_espresso' ) . '">' . __( 'Edit', 'event_espresso' ) . '</a>';
242
+		if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_edit_message', 'espresso_messages_edit_message_template', $item->ID())) {
243
+			$edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'edit_message_template', 'id'=>$item->GRP_ID()), EE_MSG_ADMIN_URL);
244
+			$actions['edit'] = '<a href="'.$edit_lnk_url.'" title="'.esc_attr__('Edit Template', 'event_espresso').'">'.__('Edit', 'event_espresso').'</a>';
245 245
 		}
246 246
 
247
-		$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', 'event_espresso' ) . '">' . ucwords( $item->messenger_obj()->label['singular'] ) . '</a>' : ucwords( $item->messenger_obj()->label['singular'] );
248
-		$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
247
+		$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', 'event_espresso').'">'.ucwords($item->messenger_obj()->label['singular']).'</a>' : ucwords($item->messenger_obj()->label['singular']);
248
+		$trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'trash_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL);
249 249
 		// restore link
250
-		$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
250
+		$restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'restore_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL);
251 251
 		// delete price link
252
-		$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce( array( 'action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE ), EE_MSG_ADMIN_URL );
252
+		$delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'delete_message_template', 'id'=>$item->GRP_ID(), 'noheader' => TRUE), EE_MSG_ADMIN_URL);
253 253
 
254
-		if ( !$item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_trash_message_template', $item->ID() ) ) {
255
-			$actions['trash'] = '<a href="'.$trash_lnk_url.'" title="' . esc_attr__( 'Move Template Group to Trash', 'event_espresso' ) . '">' . __( 'Move to Trash', 'event_espresso' ) . '</a>';
254
+		if ( ! $item->get('MTP_deleted') && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_trash_message_template', $item->ID())) {
255
+			$actions['trash'] = '<a href="'.$trash_lnk_url.'" title="'.esc_attr__('Move Template Group to Trash', 'event_espresso').'">'.__('Move to Trash', 'event_espresso').'</a>';
256 256
 		} else {
257
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_restore_message_template', $item->ID() ) ) {
258
-				$actions['restore'] = '<a href="'.$restore_lnk_url.'" title="' . esc_attr__( 'Restore Message Template', 'event_espresso' ) . '">' . __( 'Restore', 'event_espresso' ) . '</a>';
257
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_restore_message_template', $item->ID())) {
258
+				$actions['restore'] = '<a href="'.$restore_lnk_url.'" title="'.esc_attr__('Restore Message Template', 'event_espresso').'">'.__('Restore', 'event_espresso').'</a>';
259 259
 			}
260 260
 
261
-			if ( $this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can( 'ee_delete_message', 'espresso_messages_delete_message_template', $item->ID() ) ) {
262
-				$actions['delete'] = '<a href="'.$delete_lnk_url.'" title="' . esc_attr__( 'Delete Template Group Permanently', 'event_espresso' ) . '">' . __( 'Delete Permanently', 'event_espresso' ) . '</a>';
261
+			if ($this->_view == 'trashed' && EE_Registry::instance()->CAP->current_user_can('ee_delete_message', 'espresso_messages_delete_message_template', $item->ID())) {
262
+				$actions['delete'] = '<a href="'.$delete_lnk_url.'" title="'.esc_attr__('Delete Template Group Permanently', 'event_espresso').'">'.__('Delete Permanently', 'event_espresso').'</a>';
263 263
 			}
264 264
 		}
265 265
 
@@ -268,15 +268,15 @@  discard block
 block discarded – undo
268 268
 		$c_configs = $item->contexts_config();
269 269
 		$ctxt = array();
270 270
 		$context_templates = $item->context_templates();
271
-		foreach ( $context_templates as $context => $template_fields ) {
272
-			$mtp_to = !empty( $context_templates[$context]['to'] ) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL;
273
-			$inactive = empty( $mtp_to ) && !empty( $context_templates[$context]['to'] ) ? ' class="mtp-inactive"' : '';
271
+		foreach ($context_templates as $context => $template_fields) {
272
+			$mtp_to = ! empty($context_templates[$context]['to']) && $context_templates[$context]['to'] instanceof EE_Message_Template ? $context_templates[$context]['to']->get('MTP_content') : NULL;
273
+			$inactive = empty($mtp_to) && ! empty($context_templates[$context]['to']) ? ' class="mtp-inactive"' : '';
274 274
 			$context_title = ucwords($c_configs[$context]['label']);
275
-			$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 );
276
-			$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;
275
+			$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);
276
+			$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;
277 277
 		}
278 278
 
279
-		$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) : '';
279
+		$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) : '';
280 280
 
281 281
 
282 282
 		//Return the name contents
@@ -284,7 +284,7 @@  discard block
 block discarded – undo
284 284
 										/* $1%s */ $name_link,
285 285
 										/* $2%s */ $item->GRP_ID(),
286 286
 										/* %4$s */ $ctx_content,
287
-										/* $3%s */ $this->row_actions( $actions )
287
+										/* $3%s */ $this->row_actions($actions)
288 288
 		);
289 289
 	}
290 290
 
@@ -305,7 +305,7 @@  discard block
 block discarded – undo
305 305
 	 * @return string       message_type name
306 306
 	 */
307 307
 	function column_message_type($item) {
308
-		return ucwords($item->message_type_obj()->label['singular'] );
308
+		return ucwords($item->message_type_obj()->label['singular']);
309 309
 	}
310 310
 
311 311
 
Please login to merge, or discard this patch.
caffeinated/admin/extend/events/Extend_Events_Admin_Page.core.php 1 patch
Spacing   +216 added lines, -216 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,25 +30,25 @@  discard block
 block discarded – undo
30 30
 class Extend_Events_Admin_Page extends Events_Admin_Page {
31 31
 
32 32
 
33
-	public function __construct( $routing = TRUE ) {
34
-		parent::__construct( $routing );
35
-		define( 'EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND . 'events/templates/');
36
-		define( 'EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND . 'events/assets/');
37
-		define( 'EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL . 'events/assets/');
33
+	public function __construct($routing = TRUE) {
34
+		parent::__construct($routing);
35
+		define('EVENTS_CAF_TEMPLATE_PATH', EE_CORE_CAF_ADMIN_EXTEND.'events/templates/');
36
+		define('EVENTS_CAF_ASSETS', EE_CORE_CAF_ADMIN_EXTEND.'events/assets/');
37
+		define('EVENTS_CAF_ASSETS_URL', EE_CORE_CAF_ADMIN_EXTEND_URL.'events/assets/');
38 38
 	}
39 39
 
40 40
 
41 41
 	protected function _extend_page_config() {
42 42
 
43
-		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND . 'events';
43
+		$this->_admin_base_path = EE_CORE_CAF_ADMIN_EXTEND.'events';
44 44
 		$default_espresso_boxes = $this->_default_espresso_metaboxes;
45 45
 
46 46
 		//is there a evt_id in the request?
47
-		$evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) ? $this->_req_data['EVT_ID'] : 0;
48
-		$evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id;
47
+		$evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) ? $this->_req_data['EVT_ID'] : 0;
48
+		$evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id;
49 49
 
50 50
 		//tkt_id?
51
-		$tkt_id = !empty( $this->_req_data['TKT_ID'] ) && ! is_array( $this->_req_data['TKT_ID'] ) ? $this->_req_data['TKT_ID'] : 0;
51
+		$tkt_id = ! empty($this->_req_data['TKT_ID']) && ! is_array($this->_req_data['TKT_ID']) ? $this->_req_data['TKT_ID'] : 0;
52 52
 
53 53
 		$new_page_routes = array(
54 54
 			'duplicate_event' => array(
@@ -66,13 +66,13 @@  discard block
 block discarded – undo
66 66
 				'capability' => 'ee_delete_default_ticket',
67 67
 				'obj_id' => $tkt_id,
68 68
 				'noheader' => TRUE,
69
-				'args' => array( 'trash' => TRUE )
69
+				'args' => array('trash' => TRUE)
70 70
 				),
71 71
 			'trash_tickets' => array(
72 72
 				'func' => '_trash_or_restore_ticket',
73 73
 				'capability' => 'ee_delete_default_tickets',
74 74
 				'noheader' => TRUE,
75
-				'args' => array( 'trash' => TRUE )
75
+				'args' => array('trash' => TRUE)
76 76
 				),
77 77
 			'restore_ticket' => array(
78 78
 				'func' => '_trash_or_restore_ticket',
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
 				)
133 133
 			);
134 134
 
135
-		$this->_page_routes = array_merge( $this->_page_routes, $new_page_routes );
135
+		$this->_page_routes = array_merge($this->_page_routes, $new_page_routes);
136 136
 
137 137
 
138 138
 		//partial route/config override
@@ -144,8 +144,8 @@  discard block
 block discarded – undo
144 144
 		$this->_page_config['default']['list_table'] = 'Extend_Events_Admin_List_Table';
145 145
 
146 146
 		//add tickets tab but only if there are more than one default ticket!
147
-		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(array( array('TKT_is_default' => 1 ) ), 'TKT_ID', TRUE );
148
-		if ( $tkt_count > 1 ) {
147
+		$tkt_count = EEM_Ticket::instance()->count_deleted_and_undeleted(array(array('TKT_is_default' => 1)), 'TKT_ID', TRUE);
148
+		if ($tkt_count > 1) {
149 149
 			$new_page_config = array(
150 150
 				'ticket_list_table' => array(
151 151
 					'nav' => array(
@@ -164,14 +164,14 @@  discard block
 block discarded – undo
164 164
 				'label' => __('Templates'),
165 165
 				'order' => 30
166 166
 			),
167
-			'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ),
167
+			'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')),
168 168
 			'help_tabs' => array(
169 169
 				'general_settings_templates_help_tab' => array(
170 170
 					'title' => __('Templates', 'event_espresso'),
171 171
 					'filename' => 'general_settings_templates'
172 172
 				)
173 173
 			),
174
-			'help_tour' => array( 'Templates_Help_Tour' ),
174
+			'help_tour' => array('Templates_Help_Tour'),
175 175
 			'require_nonce' => FALSE
176 176
 		);
177 177
 
@@ -190,26 +190,26 @@  discard block
 block discarded – undo
190 190
 //				'metaboxes' => $default_espresso_boxes,
191 191
 //				'require_nonce' => FALSE
192 192
 //		);
193
-		$this->_page_config = array_merge( $this->_page_config, $new_page_config );
193
+		$this->_page_config = array_merge($this->_page_config, $new_page_config);
194 194
 
195 195
 		//add filters and actions
196 196
 		//modifying _views
197
-		add_filter('FHEE_event_datetime_metabox_add_additional_date_time_template', array( $this, 'add_additional_datetime_button' ), 10, 2 );
198
-		add_filter('FHEE_event_datetime_metabox_clone_button_template', array( $this, 'add_datetime_clone_button' ), 10, 2 );
199
-		add_filter('FHEE_event_datetime_metabox_timezones_template', array( $this, 'datetime_timezones_template'), 10, 2 );
197
+		add_filter('FHEE_event_datetime_metabox_add_additional_date_time_template', array($this, 'add_additional_datetime_button'), 10, 2);
198
+		add_filter('FHEE_event_datetime_metabox_clone_button_template', array($this, 'add_datetime_clone_button'), 10, 2);
199
+		add_filter('FHEE_event_datetime_metabox_timezones_template', array($this, 'datetime_timezones_template'), 10, 2);
200 200
 
201 201
 
202 202
 		//filters for event list table
203
-		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array( $this, 'list_table_filters'), 10, 2);
204
-		add_filter('FHEE__Events_Admin_List_Table__column_actions__action_links', array( $this, 'extra_list_table_actions'), 10, 2 );
203
+		add_filter('FHEE__Extend_Events_Admin_List_Table__filters', array($this, 'list_table_filters'), 10, 2);
204
+		add_filter('FHEE__Events_Admin_List_Table__column_actions__action_links', array($this, 'extra_list_table_actions'), 10, 2);
205 205
 
206 206
 		//legend item
207
-		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array( $this, 'additional_legend_items') );
207
+		add_filter('FHEE__Events_Admin_Page___event_legend_items__items', array($this, 'additional_legend_items'));
208 208
 
209
-		add_action('admin_init', array( $this, 'admin_init') );
209
+		add_action('admin_init', array($this, 'admin_init'));
210 210
 
211 211
 		//heartbeat stuff
212
-		add_filter( 'heartbeat_received', array( $this, 'heartbeat_response' ), 10, 2 );
212
+		add_filter('heartbeat_received', array($this, 'heartbeat_response'), 10, 2);
213 213
 
214 214
 	}
215 215
 
@@ -222,12 +222,12 @@  discard block
 block discarded – undo
222 222
 		EE_Registry::$i18n_js_strings = array_merge(
223 223
 			EE_Registry::$i18n_js_strings,
224 224
 			array(
225
-				'image_confirm'          => __( 'Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso' ),
226
-				'event_starts_on'        => __( 'Event Starts on', 'event_espresso' ),
227
-				'event_ends_on'          => __( 'Event Ends on', 'event_espresso' ),
228
-				'event_datetime_actions' => __( 'Actions', 'event_espresso' ),
229
-				'event_clone_dt_msg'     => __( 'Clone this Event Date and Time', 'event_espresso' ),
230
-				'remove_event_dt_msg'    => __( 'Remove this Event Time', 'event_espresso' )
225
+				'image_confirm'          => __('Do you really want to delete this image? Please remember to update your event to complete the removal.', 'event_espresso'),
226
+				'event_starts_on'        => __('Event Starts on', 'event_espresso'),
227
+				'event_ends_on'          => __('Event Ends on', 'event_espresso'),
228
+				'event_datetime_actions' => __('Actions', 'event_espresso'),
229
+				'event_clone_dt_msg'     => __('Clone this Event Date and Time', 'event_espresso'),
230
+				'remove_event_dt_msg'    => __('Remove this Event Time', 'event_espresso')
231 231
 			)
232 232
 		);
233 233
 	}
@@ -242,12 +242,12 @@  discard block
 block discarded – undo
242 242
 	 *
243 243
 	 * @return array  possibly appended response.
244 244
 	 */
245
-	public function heartbeat_response( $response, $data ) {
245
+	public function heartbeat_response($response, $data) {
246 246
 		/**
247 247
 		 * check whether count of tickets is approaching the potential
248 248
 		 * limits for the server.
249 249
 		 */
250
-		if ( ! empty( $data['input_count'] ) ) {
250
+		if ( ! empty($data['input_count'])) {
251 251
 			$response['max_input_vars_check'] = EE_Registry::instance()->CFG->environment->max_input_vars_limit_check($data['input_count']);
252 252
 		}
253 253
 
@@ -262,13 +262,13 @@  discard block
 block discarded – undo
262 262
 
263 263
 
264 264
 
265
-	public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) {
266
-		$return = parent::extra_permalink_field_buttons( $return, $id, $new_title, $new_slug );
265
+	public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) {
266
+		$return = parent::extra_permalink_field_buttons($return, $id, $new_title, $new_slug);
267 267
 		//make sure this is only when editing
268
-		if ( !empty( $id ) ) {
269
-			$href = EE_Admin_Page::add_query_args_and_nonce( array('action' => 'duplicate_event', 'EVT_ID' => $id), $this->_admin_base_url );
268
+		if ( ! empty($id)) {
269
+			$href = EE_Admin_Page::add_query_args_and_nonce(array('action' => 'duplicate_event', 'EVT_ID' => $id), $this->_admin_base_url);
270 270
 			$title = esc_attr__('Duplicate Event', 'event_espresso');
271
-			$return .= '<a href="' . $href . '" title="' . $title . '" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">' . $title  . '</button>';
271
+			$return .= '<a href="'.$href.'" title="'.$title.'" id="ee-duplicate-event-button" class="button button-small"  value="duplicate_event">'.$title.'</button>';
272 272
 		}
273 273
 		return $return;
274 274
 	}
@@ -291,7 +291,7 @@  discard block
 block discarded – undo
291 291
 				'label' => __('Trash', 'event_espresso'),
292 292
 				'count' => 0,
293 293
 				'bulk_action' => array(
294
-					'restore_tickets' => __('Restore from Trash' , 'event_espresso'),
294
+					'restore_tickets' => __('Restore from Trash', 'event_espresso'),
295 295
 					'delete_tickets' => __('Delete Permanently', 'event_espresso')
296 296
 					)
297 297
 				)
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
 
303 303
 	public function load_scripts_styles_edit() {
304
-		wp_register_script( 'ee-event-editor-heartbeat', EVENTS_CAF_ASSETS_URL . 'event-editor-heartbeat.js', array( 'ee_admin_js', 'heartbeat' ), EVENT_ESPRESSO_VERSION, TRUE );
304
+		wp_register_script('ee-event-editor-heartbeat', EVENTS_CAF_ASSETS_URL.'event-editor-heartbeat.js', array('ee_admin_js', 'heartbeat'), EVENT_ESPRESSO_VERSION, TRUE);
305 305
 
306 306
 		/**
307 307
 		 * load accounting js.
@@ -320,20 +320,20 @@  discard block
 block discarded – undo
320 320
 
321 321
 
322 322
 
323
-	public function add_additional_datetime_button( $template, $template_args ) {
324
-		return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_add_additional_time.template.php', $template_args, TRUE);
323
+	public function add_additional_datetime_button($template, $template_args) {
324
+		return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_add_additional_time.template.php', $template_args, TRUE);
325 325
 	}
326 326
 
327 327
 
328 328
 
329
-	public function add_datetime_clone_button( $template, $template_args ) {
330
-		return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_metabox_clone_button.template.php', $template_args, TRUE );
329
+	public function add_datetime_clone_button($template, $template_args) {
330
+		return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_metabox_clone_button.template.php', $template_args, TRUE);
331 331
 	}
332 332
 
333 333
 
334 334
 
335
-	public function datetime_timezones_template( $template, $template_args ) {
336
-		return EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'event_datetime_timezones.template.php', $template_args, TRUE );
335
+	public function datetime_timezones_template($template, $template_args) {
336
+		return EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'event_datetime_timezones.template.php', $template_args, TRUE);
337 337
 	}
338 338
 
339 339
 
@@ -342,11 +342,11 @@  discard block
 block discarded – undo
342 342
 	protected function _set_list_table_views_default() {
343 343
 		parent::_set_list_table_views_default();
344 344
 		$export_label = __('Export Events', 'event_espresso');
345
-		if ( EE_Registry::instance()->CAP->current_user_can( 'export', 'espresso_events_export' ) ) {
345
+		if (EE_Registry::instance()->CAP->current_user_can('export', 'espresso_events_export')) {
346 346
 //			$this->_views['all']['bulk_action']['export_events'] = $export_label;
347 347
 //			$this->_views['draft']['bulk_action']['export_events'] = $export_label;
348 348
 
349
-			if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) {
349
+			if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) {
350 350
 //				$this->_views['trash']['bulk_action']['export_events'] = $export_label;
351 351
 			}
352 352
 		}
@@ -372,7 +372,7 @@  discard block
 block discarded – undo
372 372
 			)
373 373
 		);
374 374
 
375
-		$this->_views = array_merge( $this->_views, $new_views);
375
+		$this->_views = array_merge($this->_views, $new_views);
376 376
 	}
377 377
 
378 378
 
@@ -386,17 +386,17 @@  discard block
 block discarded – undo
386 386
 
387 387
 
388 388
 
389
-	public function extra_list_table_actions( $actionlinks, $event ) {
390
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_reports', $event->ID() ) ) {
389
+	public function extra_list_table_actions($actionlinks, $event) {
390
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_reports', $event->ID())) {
391 391
 			$reports_query_args = array(
392 392
 					'action' => 'reports',
393 393
 					'EVT_ID' => $event->ID()
394 394
 				);
395
-			$reports_link = EE_Admin_Page::add_query_args_and_nonce( $reports_query_args, REG_ADMIN_URL );
396
-			$actionlinks[] = '<a href="' . $reports_link . '" title="' .  esc_attr__('View Report', 'event_espresso') . '"><div class="dashicons dashicons-chart-bar"></div></a>' . "\n\t";
395
+			$reports_link = EE_Admin_Page::add_query_args_and_nonce($reports_query_args, REG_ADMIN_URL);
396
+			$actionlinks[] = '<a href="'.$reports_link.'" title="'.esc_attr__('View Report', 'event_espresso').'"><div class="dashicons dashicons-chart-bar"></div></a>'."\n\t";
397 397
 		}
398
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_messages', 'view_filtered_messages' ) ) {
399
-			EE_Registry::instance()->load_helper( 'MSG_Template' );
398
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_messages', 'view_filtered_messages')) {
399
+			EE_Registry::instance()->load_helper('MSG_Template');
400 400
 			$actionlinks[] = EEH_MSG_Template::get_message_action_link(
401 401
 				'see_notifications_for',
402 402
 				null,
@@ -411,15 +411,15 @@  discard block
 block discarded – undo
411 411
 
412 412
 
413 413
 	public function additional_legend_items($items) {
414
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_registrations', 'espresso_registrations_reports' ) ) {
414
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_registrations', 'espresso_registrations_reports')) {
415 415
 			$items['reports'] = array(
416 416
 					'class' => 'dashicons dashicons-chart-bar',
417 417
 					'desc' => __('Event Reports', 'event_espresso')
418 418
 				);
419 419
 		}
420
-		if ( EE_Registry::instance()->CAP->current_user_can( 'ee_read_messages', 'view_filtered_messages' ) ) {
421
-			$related_for_icon = EEH_MSG_Template::get_message_action_icon( 'see_notifications_for' );
422
-			if ( isset( $related_for_icon['css_class']) && isset( $related_for_icon['label'] ) ) {
420
+		if (EE_Registry::instance()->CAP->current_user_can('ee_read_messages', 'view_filtered_messages')) {
421
+			$related_for_icon = EEH_MSG_Template::get_message_action_icon('see_notifications_for');
422
+			if (isset($related_for_icon['css_class']) && isset($related_for_icon['label'])) {
423 423
 				$items['view_related_messages'] = array(
424 424
 					'class' => $related_for_icon['css_class'],
425 425
 					'desc' => $related_for_icon['label'],
@@ -444,17 +444,17 @@  discard block
 block discarded – undo
444 444
 	 */
445 445
 	protected function _duplicate_event() {
446 446
 		//first make sure the ID for the event is in the request.  If it isnt' then we need to bail and redirect back to overview list table (cause how did we get here?)
447
-		if ( !isset( $this->_req_data['EVT_ID'] ) ) {
448
-			EE_Error::add_error( __('In order to duplicate an event an Event ID is required.  None was given.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
449
-			$this->_redirect_after_action( FALSE, '', '', array(), TRUE );
447
+		if ( ! isset($this->_req_data['EVT_ID'])) {
448
+			EE_Error::add_error(__('In order to duplicate an event an Event ID is required.  None was given.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
449
+			$this->_redirect_after_action(FALSE, '', '', array(), TRUE);
450 450
 			return;
451 451
 		}
452 452
 
453 453
 		//k we've got EVT_ID so let's use that to get the event we'll duplicate
454
-		$orig_event = EEM_Event::instance()->get_one_by_ID( $this->_req_data['EVT_ID'] );
454
+		$orig_event = EEM_Event::instance()->get_one_by_ID($this->_req_data['EVT_ID']);
455 455
 
456
-		if ( ! $orig_event instanceof EE_Event )
457
-			throw new EE_Error( sprintf( __('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID'] ) );
456
+		if ( ! $orig_event instanceof EE_Event)
457
+			throw new EE_Error(sprintf(__('An EE_Event object could not be retrieved for the given ID (%s)', 'event_espresso '), $this->_req_data['EVT_ID']));
458 458
 
459 459
 		//k now let's clone the $orig_event before getting relations
460 460
 		$new_event = clone $orig_event;
@@ -467,43 +467,43 @@  discard block
 block discarded – undo
467 467
 
468 468
 
469 469
 		//reset the ID and modify other details to make it clear this is a dupe
470
-		$new_event->set( 'EVT_ID', 0 );
471
-		$new_name = $new_event->name() . ' ' . __('**DUPLICATE**', 'event_espresso');
472
-		$new_event->set( 'EVT_name',  $new_name );
473
-		$new_event->set( 'EVT_slug',  wp_unique_post_slug( sanitize_title( $orig_event->name() ), 0, 'publish', 'espresso_events', 0 ) );
474
-		$new_event->set( 'status', 'draft' );
470
+		$new_event->set('EVT_ID', 0);
471
+		$new_name = $new_event->name().' '.__('**DUPLICATE**', 'event_espresso');
472
+		$new_event->set('EVT_name', $new_name);
473
+		$new_event->set('EVT_slug', wp_unique_post_slug(sanitize_title($orig_event->name()), 0, 'publish', 'espresso_events', 0));
474
+		$new_event->set('status', 'draft');
475 475
 
476 476
 		//duplicate discussion settings
477
-		$new_event->set( 'comment_status', $orig_event->get('comment_status') );
478
-		$new_event->set( 'ping_status', $orig_event->get( 'ping_status' ) );
477
+		$new_event->set('comment_status', $orig_event->get('comment_status'));
478
+		$new_event->set('ping_status', $orig_event->get('ping_status'));
479 479
 
480 480
 		//save the new event
481 481
 		$new_event->save();
482 482
 
483 483
 		//venues
484
-		foreach( $orig_ven as $ven ) {
485
-			$new_event->_add_relation_to( $ven, 'Venue' );
484
+		foreach ($orig_ven as $ven) {
485
+			$new_event->_add_relation_to($ven, 'Venue');
486 486
 		}
487 487
 		$new_event->save();
488 488
 
489 489
 
490 490
 		//now we need to get the question group relations and handle that
491 491
 		//first primary question groups
492
-		$orig_primary_qgs = $orig_event->get_many_related('Question_Group', array( array('Event_Question_Group.EQG_primary' => 1 ) ) );
493
-		if ( !empty( $orig_primary_qgs ) ) {
494
-			foreach ( $orig_primary_qgs as $id => $obj ) {
495
-				if ( $obj instanceof EE_Question_Group ) {
496
-					$new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 1 ) );
492
+		$orig_primary_qgs = $orig_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 1)));
493
+		if ( ! empty($orig_primary_qgs)) {
494
+			foreach ($orig_primary_qgs as $id => $obj) {
495
+				if ($obj instanceof EE_Question_Group) {
496
+					$new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 1));
497 497
 				}
498 498
 			}
499 499
 		}
500 500
 
501 501
 		//next additional attendee question groups
502
-		$orig_additional_qgs = $orig_event->get_many_related('Question_Group', array( array('Event_Question_Group.EQG_primary' => 0 ) ) );
503
-		if ( !empty( $orig_additional_qgs ) ) {
504
-			foreach ( $orig_additional_qgs as $id => $obj ) {
505
-				if ( $obj instanceof EE_Question_Group ) {
506
-					$new_event->_add_relation_to( $obj, 'Question_Group', array( 'EQG_primary' => 0 ) );
502
+		$orig_additional_qgs = $orig_event->get_many_related('Question_Group', array(array('Event_Question_Group.EQG_primary' => 0)));
503
+		if ( ! empty($orig_additional_qgs)) {
504
+			foreach ($orig_additional_qgs as $id => $obj) {
505
+				if ($obj instanceof EE_Question_Group) {
506
+					$new_event->_add_relation_to($obj, 'Question_Group', array('EQG_primary' => 0));
507 507
 				}
508 508
 			}
509 509
 		}
@@ -514,7 +514,7 @@  discard block
 block discarded – undo
514 514
 
515 515
 		//k now that we have the new event saved we can loop through the datetimes and start adding relations.
516 516
 		$cloned_tickets = array();
517
-		foreach ( $orig_datetimes as $orig_dtt ) {
517
+		foreach ($orig_datetimes as $orig_dtt) {
518 518
 			$new_dtt = clone $orig_dtt;
519 519
 			$orig_tkts = $orig_dtt->tickets();
520 520
 
@@ -522,22 +522,22 @@  discard block
 block discarded – undo
522 522
 			$new_dtt->set('DTT_ID', 0);
523 523
 			$new_dtt->set('DTT_sold', 0);
524 524
 			$new_dtt->save();
525
-			$new_event->_add_relation_to( $new_dtt, 'Datetime');
525
+			$new_event->_add_relation_to($new_dtt, 'Datetime');
526 526
 			$new_event->save();
527 527
 
528 528
 			//now let's get the ticket relations setup.
529
-			foreach ( (array) $orig_tkts as $orig_tkt ) {
529
+			foreach ((array) $orig_tkts as $orig_tkt) {
530 530
 				//it's possible a datetime will have no tickets so let's verify we HAVE a ticket first.
531
-				if ( ! $orig_tkt instanceof EE_Ticket )
531
+				if ( ! $orig_tkt instanceof EE_Ticket)
532 532
 					continue;
533 533
 
534 534
 				//is this ticket archived?  If it is then let's skip
535
-				if ( $orig_tkt->get( 'TKT_deleted' ) ) {
535
+				if ($orig_tkt->get('TKT_deleted')) {
536 536
 					continue;
537 537
 				}
538 538
 
539 539
 				//does this original ticket already exist in the clone_tickets cache?  If so we'll just use the new ticket from it.
540
-				if ( isset( $cloned_tickets[$orig_tkt->ID()] ) ) {
540
+				if (isset($cloned_tickets[$orig_tkt->ID()])) {
541 541
 					$new_tkt = $cloned_tickets[$orig_tkt->ID()];
542 542
 				} else {
543 543
 					$new_tkt = clone $orig_tkt;
@@ -549,7 +549,7 @@  discard block
 block discarded – undo
549 549
 					$new_tkt->save(); //make sure new ticket has ID.
550 550
 
551 551
 					//price relations on new ticket need to be setup.
552
-					foreach ( $orig_prices as $orig_price ) {
552
+					foreach ($orig_prices as $orig_price) {
553 553
 						$new_price = clone $orig_price;
554 554
 						$new_price->set('PRC_ID', 0);
555 555
 						$new_price->save();
@@ -566,39 +566,39 @@  discard block
 block discarded – undo
566 566
 		}
567 567
 
568 568
 		//clone taxonomy information
569
-		$taxonomies_to_clone_with = apply_filters( 'FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', array( 'espresso_event_categories', 'espresso_event_type', 'post_tag' ) );
569
+		$taxonomies_to_clone_with = apply_filters('FHEE__Extend_Events_Admin_Page___duplicate_event__taxonomies_to_clone', array('espresso_event_categories', 'espresso_event_type', 'post_tag'));
570 570
 
571 571
 		//get terms for original event (notice)
572
-		$orig_terms = wp_get_object_terms( $orig_event->ID(), $taxonomies_to_clone_with );
572
+		$orig_terms = wp_get_object_terms($orig_event->ID(), $taxonomies_to_clone_with);
573 573
 
574 574
 		//loop through terms and add them to new event.
575
-		foreach ( $orig_terms as $term ) {
576
-			wp_set_object_terms( $new_event->ID(), $term->term_id, $term->taxonomy, true );
575
+		foreach ($orig_terms as $term) {
576
+			wp_set_object_terms($new_event->ID(), $term->term_id, $term->taxonomy, true);
577 577
 		}
578 578
 
579 579
 
580
-		do_action( 'AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event );
580
+		do_action('AHEE__Extend_Events_Admin_Page___duplicate_event__after', $new_event, $orig_event);
581 581
 
582 582
 		//now let's redirect to the edit page for this duplicated event if we have a new event id.
583
-		if ( $new_event->ID() ) {
583
+		if ($new_event->ID()) {
584 584
 			$redirect_args = array(
585 585
 				'post' => $new_event->ID(),
586 586
 				'action' => 'edit'
587 587
 			);
588
-			EE_Error::add_success( __('Event successfully duplicated.  Please review the details below and make any necessary edits', 'event_espresso') );
588
+			EE_Error::add_success(__('Event successfully duplicated.  Please review the details below and make any necessary edits', 'event_espresso'));
589 589
 		} else {
590 590
 			$redirect_args = array(
591 591
 				'action' => 'default'
592 592
 				);
593
-			EE_Error::add_error( __('Not able to duplicate event.  Something went wrong.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
593
+			EE_Error::add_error(__('Not able to duplicate event.  Something went wrong.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
594 594
 		}
595 595
 
596
-		$this->_redirect_after_action(FALSE, '', '', $redirect_args, TRUE );
596
+		$this->_redirect_after_action(FALSE, '', '', $redirect_args, TRUE);
597 597
 	}
598 598
 
599 599
 
600 600
 
601
-	protected function _import_page(){
601
+	protected function _import_page() {
602 602
 
603 603
 		$title = __('Import', 'event_espresso');
604 604
 		$intro = __('If you have a previously exported Event Espresso 4 information in a Comma Separated Value (CSV) file format, you can upload the file here: ', 'event_espresso');
@@ -606,8 +606,8 @@  discard block
 block discarded – undo
606 606
 		$action = 'import_events';
607 607
 		$type = 'csv';
608 608
 		$this->_template_args['form'] = EE_Import::instance()->upload_form($title, $intro, $form_url, $action, $type);
609
-		$this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'sample_export_file'),$this->_admin_base_url);
610
-		$content = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH . 'import_page.template.php',$this->_template_args,true);
609
+		$this->_template_args['sample_file_link'] = EE_Admin_Page::add_query_args_and_nonce(array('action'=>'sample_export_file'), $this->_admin_base_url);
610
+		$content = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'import_page.template.php', $this->_template_args, true);
611 611
 
612 612
 
613 613
 		$this->_template_args['admin_page_content'] = $content;
@@ -620,9 +620,9 @@  discard block
 block discarded – undo
620 620
 	 * @return string html
621 621
 	 */
622 622
 	protected function _import_events() {
623
-		require_once(EE_CLASSES . 'EE_Import.class.php');
623
+		require_once(EE_CLASSES.'EE_Import.class.php');
624 624
 		$success = EE_Import::instance()->import();
625
-		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'),true);
625
+		$this->_redirect_after_action($success, 'Import File', 'ran', array('action' => 'import_page'), true);
626 626
 
627 627
 	}
628 628
 
@@ -636,23 +636,23 @@  discard block
 block discarded – undo
636 636
 	 * @return file
637 637
 	 */
638 638
 	protected function _events_export() {
639
-		if(isset($this->_req_data['EVT_ID'])){
639
+		if (isset($this->_req_data['EVT_ID'])) {
640 640
 			$event_ids = $this->_req_data['EVT_ID'];
641
-		}elseif(isset($this->_req_data['EVT_IDs'])){
641
+		}elseif (isset($this->_req_data['EVT_IDs'])) {
642 642
 			$event_ids = $this->_req_data['EVT_IDs'];
643
-		}else{
643
+		} else {
644 644
 			$event_ids = NULL;
645 645
 		}
646 646
 		//todo: I don't like doing this but it'll do until we modify EE_Export Class.
647 647
 		$new_request_args = array(
648 648
 			'export' => 'report',
649 649
 			'action' => 'all_event_data',
650
-			'EVT_ID' => $event_ids ,
650
+			'EVT_ID' => $event_ids,
651 651
 		);
652 652
 		$this->_req_data = array_merge($this->_req_data, $new_request_args);
653 653
 
654
-		if ( is_readable(EE_CLASSES . 'EE_Export.class.php')) {
655
-			require_once(EE_CLASSES . 'EE_Export.class.php');
654
+		if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
655
+			require_once(EE_CLASSES.'EE_Export.class.php');
656 656
 			$EE_Export = EE_Export::instance($this->_req_data);
657 657
 			$EE_Export->export();
658 658
 		}
@@ -674,11 +674,11 @@  discard block
 block discarded – undo
674 674
 			'category_ids' => $this->_req_data['EVT_CAT_ID']
675 675
 			);
676 676
 
677
-		$this->_req_data = array_merge( $this->_req_data, $new_request_args );
677
+		$this->_req_data = array_merge($this->_req_data, $new_request_args);
678 678
 
679
-		if ( is_readable( EE_CLASSES . 'EE_Export.class.php') ) {
680
-			require_once( EE_CLASSES . 'EE_Export.class.php');
681
-			$EE_Export = EE_Export::instance( $this->_req_data );
679
+		if (is_readable(EE_CLASSES.'EE_Export.class.php')) {
680
+			require_once(EE_CLASSES.'EE_Export.class.php');
681
+			$EE_Export = EE_Export::instance($this->_req_data);
682 682
 			$EE_Export->export();
683 683
 		}
684 684
 
@@ -689,7 +689,7 @@  discard block
 block discarded – undo
689 689
 	/**
690 690
 	 * Creates a sample CSV file for importing
691 691
 	 */
692
-	protected function _sample_export_file(){
692
+	protected function _sample_export_file() {
693 693
 //		require_once(EE_CLASSES . 'EE_Export.class.php');
694 694
 		EE_Export::instance()->export_sample();
695 695
 	}
@@ -706,10 +706,10 @@  discard block
 block discarded – undo
706 706
 		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
707 707
 		 * from General_Settings_Admin_Page to here.
708 708
 		 */
709
-		$this->_template_args = apply_filters( 'FHEE__General_Settings_Admin_Page__template_settings__template_args', $this->_template_args );
710
-		$this->_set_add_edit_form_tags( 'update_template_settings' );
711
-		$this->_set_publish_post_box_vars( NULL, FALSE, FALSE, NULL, FALSE );
712
-		$this->_template_args['admin_page_content'] = EEH_Template::display_template( EVENTS_CAF_TEMPLATE_PATH . 'template_settings.template.php', $this->_template_args, TRUE );
709
+		$this->_template_args = apply_filters('FHEE__General_Settings_Admin_Page__template_settings__template_args', $this->_template_args);
710
+		$this->_set_add_edit_form_tags('update_template_settings');
711
+		$this->_set_publish_post_box_vars(NULL, FALSE, FALSE, NULL, FALSE);
712
+		$this->_template_args['admin_page_content'] = EEH_Template::display_template(EVENTS_CAF_TEMPLATE_PATH.'template_settings.template.php', $this->_template_args, TRUE);
713 713
 		$this->display_admin_page_with_sidebar();
714 714
 	}
715 715
 
@@ -721,24 +721,24 @@  discard block
 block discarded – undo
721 721
 		 * Note leaving this filter in for backward compatibility this was moved in 4.6.x
722 722
 		 * from General_Settings_Admin_Page to here.
723 723
 		 */
724
-		EE_Registry::instance()->CFG->template_settings = apply_filters( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', EE_Registry::instance()->CFG->template_settings, $this->_req_data );
724
+		EE_Registry::instance()->CFG->template_settings = apply_filters('FHEE__General_Settings_Admin_Page__update_template_settings__data', EE_Registry::instance()->CFG->template_settings, $this->_req_data);
725 725
 
726 726
 
727 727
 		//update custom post type slugs and detect if we need to flush rewrite rules
728 728
 		$old_slug = EE_Registry::instance()->CFG->core->event_cpt_slug;
729
-		EE_Registry::instance()->CFG->core->event_cpt_slug = empty( $this->_req_data['event_cpt_slug'] ) ? EE_Registry::instance()->CFG->core->event_cpt_slug : sanitize_title_with_dashes( $this->_req_data['event_cpt_slug'] );
729
+		EE_Registry::instance()->CFG->core->event_cpt_slug = empty($this->_req_data['event_cpt_slug']) ? EE_Registry::instance()->CFG->core->event_cpt_slug : sanitize_title_with_dashes($this->_req_data['event_cpt_slug']);
730 730
 
731 731
 
732 732
 		$what = 'Template Settings';
733
-		$success = $this->_update_espresso_configuration( $what, EE_Registry::instance()->CFG->template_settings, __FILE__, __FUNCTION__, __LINE__ );
733
+		$success = $this->_update_espresso_configuration($what, EE_Registry::instance()->CFG->template_settings, __FILE__, __FUNCTION__, __LINE__);
734 734
 
735 735
 
736
-		if ( EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug ) {
737
-			update_option( 'ee_flush_rewrite_rules', true );
736
+		if (EE_Registry::instance()->CFG->core->event_cpt_slug != $old_slug) {
737
+			update_option('ee_flush_rewrite_rules', true);
738 738
 		}
739 739
 
740 740
 
741
-		$this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'template_settings' ) );
741
+		$this->_redirect_after_action($success, $what, 'updated', array('action' => 'template_settings'));
742 742
 
743 743
 	}
744 744
 
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
 
757 757
 		$this->verify_cpt_object();
758 758
 
759
-		add_meta_box('espresso_event_editor_event_options', __('Event Registration Options', 'event_espresso'), array( $this, 'registration_options_meta_box' ), $this->page_slug, 'side', 'core');
759
+		add_meta_box('espresso_event_editor_event_options', __('Event Registration Options', 'event_espresso'), array($this, 'registration_options_meta_box'), $this->page_slug, 'side', 'core');
760 760
 		//add_meta_box('espresso_event_types', __('Event Type', 'event_espresso'), array( $this, 'event_type_meta_box' ), $this->page_slug, 'side', 'default' ); //add this back in when the feature is ready.
761 761
 
762 762
 		//todo feature in progress
@@ -780,16 +780,16 @@  discard block
 block discarded – undo
780 780
 			array('id' => true, 'text' => __('Yes', 'event_espresso')),
781 781
 			array('id' => false, 'text' => __('No', 'event_espresso'))
782 782
 		);
783
-		$default_reg_status_values = EEM_Registration::reg_status_array(array(EEM_Registration::status_id_cancelled, EEM_Registration::status_id_declined, EEM_Registration::status_id_incomplete ), TRUE);
783
+		$default_reg_status_values = EEM_Registration::reg_status_array(array(EEM_Registration::status_id_cancelled, EEM_Registration::status_id_declined, EEM_Registration::status_id_incomplete), TRUE);
784 784
 		$template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(FALSE);
785 785
 		$template_args['_event'] = $this->_cpt_model_obj;
786 786
 		$template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit();
787 787
 		$template_args['default_registration_status'] = EEH_Form_Fields::select_input('default_reg_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status());
788 788
 		$template_args['display_description'] = EEH_Form_Fields::select_input('display_desc', $yes_no_values, $this->_cpt_model_obj->display_description());
789 789
 		$template_args['display_ticket_selector'] = EEH_Form_Fields::select_input('display_ticket_selector', $yes_no_values, $this->_cpt_model_obj->display_ticket_selector(), '', '', false);
790
-		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input('EVT_default_registration_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status() );
791
-		$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 );
792
-		$templatepath = EVENTS_CAF_TEMPLATE_PATH . 'event_registration_options.template.php';
790
+		$template_args['EVT_default_registration_status'] = EEH_Form_Fields::select_input('EVT_default_registration_status', $default_reg_status_values, $this->_cpt_model_obj->default_registration_status());
791
+		$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);
792
+		$templatepath = EVENTS_CAF_TEMPLATE_PATH.'event_registration_options.template.php';
793 793
 		EEH_Template::display_template($templatepath, $template_args);
794 794
 	}
795 795
 
@@ -802,9 +802,9 @@  discard block
 block discarded – undo
802 802
 	 * @param  array  $box  metabox args
803 803
 	 * @return string       metabox contents
804 804
 	 */
805
-	public function event_type_meta_box( $post, $box ) {
806
-		$template_args['radio_list'] = $this->wp_terms_radio($post->ID, array( 'taxonomy' => 'espresso_event_type' ) );
807
-		$template = EVENTS_CAF_TEMPLATE_PATH . 'event_type_metabox_contents.template.php';
805
+	public function event_type_meta_box($post, $box) {
806
+		$template_args['radio_list'] = $this->wp_terms_radio($post->ID, array('taxonomy' => 'espresso_event_type'));
807
+		$template = EVENTS_CAF_TEMPLATE_PATH.'event_type_metabox_contents.template.php';
808 808
 		EEH_Template::display_template($template, $template_args);
809 809
 	}
810 810
 
@@ -814,7 +814,7 @@  discard block
 block discarded – undo
814 814
 
815 815
 
816 816
 
817
-	public function wp_terms_radio( $post_id = 0, $args = array() ) {
817
+	public function wp_terms_radio($post_id = 0, $args = array()) {
818 818
 		$defaults = array(
819 819
 			'descendants_and_self' => 0,
820 820
 			'selected_cats' => false,
@@ -823,11 +823,11 @@  discard block
 block discarded – undo
823 823
 			'taxonomy' => 'category',
824 824
 			'checked_ontop' => true
825 825
 		);
826
-		$args = apply_filters( 'wp_terms_checklist_args', $args, $post_id );
826
+		$args = apply_filters('wp_terms_checklist_args', $args, $post_id);
827 827
 
828
-		extract( wp_parse_args($args, $defaults), EXTR_SKIP );
828
+		extract(wp_parse_args($args, $defaults), EXTR_SKIP);
829 829
 
830
-		if ( empty($walker) || !is_a($walker, 'Walker') )
830
+		if (empty($walker) || ! is_a($walker, 'Walker'))
831 831
 			$walker = new Walker_Radio_Checklist;
832 832
 
833 833
 		$descendants_and_self = (int) $descendants_and_self;
@@ -835,37 +835,37 @@  discard block
 block discarded – undo
835 835
 		$args = array('taxonomy' => $taxonomy);
836 836
 
837 837
 		$tax = get_taxonomy($taxonomy);
838
-		$args['disabled'] = !current_user_can($tax->cap->assign_terms);
838
+		$args['disabled'] = ! current_user_can($tax->cap->assign_terms);
839 839
 
840
-		if ( is_array( $selected_cats ) )
840
+		if (is_array($selected_cats))
841 841
 			$args['selected_cats'] = $selected_cats;
842
-		elseif ( $post_id )
842
+		elseif ($post_id)
843 843
 			$args['selected_cats'] = wp_get_object_terms($post_id, $taxonomy, array_merge($args, array('fields' => 'ids')));
844 844
 		else
845 845
 			$args['selected_cats'] = array();
846 846
 
847
-		if ( is_array( $popular_cats ) )
847
+		if (is_array($popular_cats))
848 848
 			$args['popular_cats'] = $popular_cats;
849 849
 		else
850
-			$args['popular_cats'] = get_terms( $taxonomy, array( 'fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false ) );
850
+			$args['popular_cats'] = get_terms($taxonomy, array('fields' => 'ids', 'orderby' => 'count', 'order' => 'DESC', 'number' => 10, 'hierarchical' => false));
851 851
 
852
-		if ( $descendants_and_self ) {
853
-			$categories = (array) get_terms($taxonomy, array( 'child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0 ) );
854
-			$self = get_term( $descendants_and_self, $taxonomy );
855
-			array_unshift( $categories, $self );
852
+		if ($descendants_and_self) {
853
+			$categories = (array) get_terms($taxonomy, array('child_of' => $descendants_and_self, 'hierarchical' => 0, 'hide_empty' => 0));
854
+			$self = get_term($descendants_and_self, $taxonomy);
855
+			array_unshift($categories, $self);
856 856
 		} else {
857 857
 			$categories = (array) get_terms($taxonomy, array('get' => 'all'));
858 858
 		}
859 859
 
860
-		if ( $checked_ontop ) {
860
+		if ($checked_ontop) {
861 861
 			// Post process $categories rather than adding an exclude to the get_terms() query to keep the query the same across all posts (for any query cache)
862 862
 			$checked_categories = array();
863
-			$keys = array_keys( $categories );
863
+			$keys = array_keys($categories);
864 864
 
865
-			foreach( $keys as $k ) {
866
-				if ( in_array( $categories[$k]->term_id, $args['selected_cats'] ) ) {
865
+			foreach ($keys as $k) {
866
+				if (in_array($categories[$k]->term_id, $args['selected_cats'])) {
867 867
 					$checked_categories[] = $categories[$k];
868
-					unset( $categories[$k] );
868
+					unset($categories[$k]);
869 869
 				}
870 870
 			}
871 871
 
@@ -890,18 +890,18 @@  discard block
 block discarded – undo
890 890
 	 * @param  array  $list_table_obj the list table object
891 891
 	 * @return array                  new filters
892 892
 	 */
893
-	public function list_table_filters( $oldfilters, $list_table_obj ) {
893
+	public function list_table_filters($oldfilters, $list_table_obj) {
894 894
 		$filters = array();
895 895
 
896 896
 		//first month/year filters
897 897
 		$filters[] = $this->espresso_event_months_dropdown();
898 898
 
899 899
 
900
-		$status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL;
900
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL;
901 901
 
902 902
 		//active status dropdown
903
-		if ( $status !== 'draft' )
904
-			$filter[] = $this->active_status_dropdown( isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : '' );
903
+		if ($status !== 'draft')
904
+			$filter[] = $this->active_status_dropdown(isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : '');
905 905
 
906 906
 		//category filter
907 907
 		$filters[] = $this->category_dropdown();
@@ -923,17 +923,17 @@  discard block
 block discarded – undo
923 923
 	 */
924 924
 	public function espresso_event_months_dropdown() {
925 925
 		//what we need to do is get all PRIMARY datetimes for all events to filter on. Note we need to include any other filters that are set!
926
-		$status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : NULL;
926
+		$status = isset($this->_req_data['status']) ? $this->_req_data['status'] : NULL;
927 927
 
928 928
 		//categories?
929
-		$category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
929
+		$category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 ? $this->_req_data['EVT_CAT'] : NULL;
930 930
 
931 931
 		//active status?
932
-		$active_status = isset( $this->_req_data['active_status'] ) ? $this->_req_data['active_status'] : NULL;
932
+		$active_status = isset($this->_req_data['active_status']) ? $this->_req_data['active_status'] : NULL;
933 933
 
934 934
 		$cur_date = isset($this->_req_data['month_range']) ? $this->_req_data['month_range'] : '';
935 935
 
936
-		return EEH_Form_Fields::generate_event_months_dropdown( $cur_date, $status, $category, $active_status );
936
+		return EEH_Form_Fields::generate_event_months_dropdown($cur_date, $status, $category, $active_status);
937 937
 	}
938 938
 
939 939
 
@@ -944,12 +944,12 @@  discard block
 block discarded – undo
944 944
 	 * @param  string $current_value whatever the ucrrent active status is
945 945
 	 * @return string                html dropdown.
946 946
 	 */
947
-	public function  active_status_dropdown( $current_value = '' ) {
947
+	public function  active_status_dropdown($current_value = '') {
948 948
 		$select_name = 'active_status';
949
-		$values = array('none' => __('Show Active/Inactive', 'event_espresso'), 'active' => __('Active', 'event_espresso'), 'upcoming' => __('Upcoming', 'event_espresso'), 'expired' => __('Expired', 'event_espresso'), 'inactive' => __('Inactive', 'event_espresso') );
949
+		$values = array('none' => __('Show Active/Inactive', 'event_espresso'), 'active' => __('Active', 'event_espresso'), 'upcoming' => __('Upcoming', 'event_espresso'), 'expired' => __('Expired', 'event_espresso'), 'inactive' => __('Inactive', 'event_espresso'));
950 950
 		$id = 'id="espresso-active-status-dropdown-filter"';
951 951
 		$class = 'wide';
952
-		echo EEH_Form_Fields::select_input( $select_name, $values, $current_value, $id, $class );
952
+		echo EEH_Form_Fields::select_input($select_name, $values, $current_value, $id, $class);
953 953
 	}
954 954
 
955 955
 
@@ -961,9 +961,9 @@  discard block
 block discarded – undo
961 961
 	 * @return string html
962 962
 	 */
963 963
 	public function category_dropdown() {
964
-		$cur_cat = isset( $this->_req_data['EVT_CAT'] ) ? $this->_req_data['EVT_CAT'] : -1;
964
+		$cur_cat = isset($this->_req_data['EVT_CAT']) ? $this->_req_data['EVT_CAT'] : -1;
965 965
 
966
-		return EEH_Form_Fields::generate_event_category_dropdown( $cur_cat );
966
+		return EEH_Form_Fields::generate_event_category_dropdown($cur_cat);
967 967
 	}
968 968
 
969 969
 
@@ -975,14 +975,14 @@  discard block
 block discarded – undo
975 975
 	 * @return int
976 976
 	 */
977 977
 	public function total_events_today() {
978
-		$start = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', date('Y-m-d' ) . ' 00:00:00', 'Y-m-d H:i:s', 'UTC' );
979
-		$end = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', date('Y-m-d' ) . ' 23:59:59', 'Y-m-d H:i:s', 'UTC' );
978
+		$start = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', date('Y-m-d').' 00:00:00', 'Y-m-d H:i:s', 'UTC');
979
+		$end = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', date('Y-m-d').' 23:59:59', 'Y-m-d H:i:s', 'UTC');
980 980
 
981 981
 		$where = array(
982
-			'Datetime.DTT_EVT_start' => array( 'BETWEEN', array($start, $end ) )
982
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end))
983 983
 			);
984 984
 
985
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
985
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
986 986
 		return $count;
987 987
 	}
988 988
 
@@ -997,14 +997,14 @@  discard block
 block discarded – undo
997 997
 		$this_year_r = date('Y');
998 998
 		$this_month_r = date('m');
999 999
 		$days_this_month = date('t');
1000
-		$start = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', $this_year_r . '-' . $this_month_r . '-01 00:00:00', 'Y-m-d H:i:s', 'UTC' );
1001
-		$end = EEM_Datetime::instance()->convert_datetime_for_query( 'DTT_EVT_start', $this_year_r . '-' . $this_month_r . '-' . $days_this_month . ' 23:59:59', 'Y-m-d H:i:s', 'UTC' );
1000
+		$start = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', $this_year_r.'-'.$this_month_r.'-01 00:00:00', 'Y-m-d H:i:s', 'UTC');
1001
+		$end = EEM_Datetime::instance()->convert_datetime_for_query('DTT_EVT_start', $this_year_r.'-'.$this_month_r.'-'.$days_this_month.' 23:59:59', 'Y-m-d H:i:s', 'UTC');
1002 1002
 
1003 1003
 		$where = array(
1004
-			'Datetime.DTT_EVT_start' => array( 'BETWEEN', array($start, $end ) )
1004
+			'Datetime.DTT_EVT_start' => array('BETWEEN', array($start, $end))
1005 1005
 			);
1006 1006
 
1007
-		$count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true );
1007
+		$count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true);
1008 1008
 		return $count;
1009 1009
 	}
1010 1010
 
@@ -1021,53 +1021,53 @@  discard block
 block discarded – undo
1021 1021
 
1022 1022
 
1023 1023
 
1024
-	public function get_default_tickets( $per_page = 10, $count = FALSE, $trashed = FALSE ) {
1024
+	public function get_default_tickets($per_page = 10, $count = FALSE, $trashed = FALSE) {
1025 1025
 
1026
-		$orderby= empty( $this->_req_data['orderby'] ) ? 'TKT_name' : $this->_req_data['orderby'];
1027
-		$order = empty( $this->_req_data['order'] ) ? 'ASC' : $this->_req_data['order'];
1026
+		$orderby = empty($this->_req_data['orderby']) ? 'TKT_name' : $this->_req_data['orderby'];
1027
+		$order = empty($this->_req_data['order']) ? 'ASC' : $this->_req_data['order'];
1028 1028
 
1029
-		switch ( $orderby ) {
1029
+		switch ($orderby) {
1030 1030
 			case 'TKT_name' :
1031
-				$orderby = array( 'TKT_name' => $order );
1031
+				$orderby = array('TKT_name' => $order);
1032 1032
 				break;
1033 1033
 
1034 1034
 			case 'TKT_price' :
1035
-				$orderby = array( 'TKT_price' => $order );
1035
+				$orderby = array('TKT_price' => $order);
1036 1036
 				break;
1037 1037
 
1038 1038
 			case 'TKT_uses' :
1039
-				$orderby = array( 'TKT_uses' => $order );
1039
+				$orderby = array('TKT_uses' => $order);
1040 1040
 				break;
1041 1041
 
1042 1042
 			case 'TKT_min' :
1043
-				$orderby = array( 'TKT_min' => $order );
1043
+				$orderby = array('TKT_min' => $order);
1044 1044
 				break;
1045 1045
 
1046 1046
 			case 'TKT_max' :
1047
-				$orderby = array( 'TKT_max' => $order );
1047
+				$orderby = array('TKT_max' => $order);
1048 1048
 				break;
1049 1049
 
1050 1050
 			case 'TKT_qty' :
1051
-				$orderby = array( 'TKT_qty' => $order );
1051
+				$orderby = array('TKT_qty' => $order);
1052 1052
 				break;
1053 1053
 		}
1054 1054
 
1055
-		$current_page = isset( $this->_req_data['paged'] ) && !empty( $this->_req_data['paged'] ) ? $this->_req_data['paged'] : 1;
1056
-		$per_page = isset( $this->_req_data['perpage'] ) && !empty( $this->_req_data['perpage'] ) ? $this->_req_data['perpage'] : $per_page;
1055
+		$current_page = isset($this->_req_data['paged']) && ! empty($this->_req_data['paged']) ? $this->_req_data['paged'] : 1;
1056
+		$per_page = isset($this->_req_data['perpage']) && ! empty($this->_req_data['perpage']) ? $this->_req_data['perpage'] : $per_page;
1057 1057
 
1058 1058
 		$_where = array(
1059 1059
 			'TKT_is_default' => 1,
1060 1060
 			'TKT_deleted' => $trashed
1061 1061
 			);
1062 1062
 
1063
-		$offset = ($current_page-1)*$per_page;
1064
-		$limit = array( $offset, $per_page );
1063
+		$offset = ($current_page - 1) * $per_page;
1064
+		$limit = array($offset, $per_page);
1065 1065
 
1066
-		if ( isset( $this->_req_data['s'] ) ) {
1067
-			$sstr = '%' . $this->_req_data['s'] . '%';
1066
+		if (isset($this->_req_data['s'])) {
1067
+			$sstr = '%'.$this->_req_data['s'].'%';
1068 1068
 			$_where['OR'] = array(
1069
-				'TKT_name' => array('LIKE',$sstr ),
1070
-				'TKT_description' => array('LIKE',$sstr )
1069
+				'TKT_name' => array('LIKE', $sstr),
1070
+				'TKT_description' => array('LIKE', $sstr)
1071 1071
 				);
1072 1072
 		}
1073 1073
 
@@ -1078,9 +1078,9 @@  discard block
 block discarded – undo
1078 1078
 			'group_by'=>'TKT_ID'
1079 1079
 			);
1080 1080
 
1081
-		if($count){
1081
+		if ($count) {
1082 1082
 			return EEM_Ticket::instance()->count_deleted_and_undeleted(array($_where));
1083
-		}else{
1083
+		} else {
1084 1084
 			return EEM_Ticket::instance()->get_all_deleted_and_undeleted($query_params);
1085 1085
 		}
1086 1086
 
@@ -1090,35 +1090,35 @@  discard block
 block discarded – undo
1090 1090
 
1091 1091
 
1092 1092
 
1093
-	protected function _trash_or_restore_ticket(  $trash = FALSE ) {
1093
+	protected function _trash_or_restore_ticket($trash = FALSE) {
1094 1094
 		$success = 1;
1095 1095
 
1096 1096
 		$TKT = EEM_Ticket::instance();
1097 1097
 
1098 1098
 		//checkboxes?
1099
-		if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) {
1099
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1100 1100
 			//if array has more than one element then success message should be plural
1101
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
1101
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1102 1102
 
1103 1103
 			//cycle thru the boxes
1104
-			while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) {
1105
-				if ( $trash ) {
1106
-					if ( ! $TKT->delete_by_ID( $TKT_ID ) )
1104
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1105
+				if ($trash) {
1106
+					if ( ! $TKT->delete_by_ID($TKT_ID))
1107 1107
 						$success = 0;
1108 1108
 				} else {
1109
-					if ( ! $TKT->restore_by_ID( $TKT_ID ) )
1109
+					if ( ! $TKT->restore_by_ID($TKT_ID))
1110 1110
 						$success = 0;
1111 1111
 				}
1112 1112
 			}
1113 1113
 		} else {
1114 1114
 			//grab single id and trash
1115
-			$TKT_ID = absint( $this->_req_data['TKT_ID'] );
1115
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1116 1116
 
1117
-			if ( $trash ) {
1118
-				if ( ! $TKT->delete_by_ID( $TKT_ID ) )
1117
+			if ($trash) {
1118
+				if ( ! $TKT->delete_by_ID($TKT_ID))
1119 1119
 					$success = 0;
1120 1120
 			} else {
1121
-				if ( ! $TKT->restore_by_ID( $TKT_ID ) )
1121
+				if ( ! $TKT->restore_by_ID($TKT_ID))
1122 1122
 					$success = 0;
1123 1123
 			}
1124 1124
 		}
@@ -1128,7 +1128,7 @@  discard block
 block discarded – undo
1128 1128
 			'action' => 'ticket_list_table',
1129 1129
 			'status' => $trash ? '' : 'trashed'
1130 1130
 			);
1131
-		$this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args );
1131
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1132 1132
 	}
1133 1133
 
1134 1134
 
@@ -1141,21 +1141,21 @@  discard block
 block discarded – undo
1141 1141
 		$TKT = EEM_Ticket::instance();
1142 1142
 
1143 1143
 		//checkboxes?
1144
-		if ( !empty( $this->_req_data['checkbox'] ) && is_array( $this->_req_data['checkbox'] ) ) {
1144
+		if ( ! empty($this->_req_data['checkbox']) && is_array($this->_req_data['checkbox'])) {
1145 1145
 			//if array has more than one element then success message should be plural
1146
-			$success = count( $this->_req_data['checkbox'] ) > 1 ? 2 : 1;
1146
+			$success = count($this->_req_data['checkbox']) > 1 ? 2 : 1;
1147 1147
 
1148 1148
 			//cycle thru the boxes
1149
-			while ( list( $TKT_ID, $value ) = each( $this->_req_data['checkbox'] ) ) {
1149
+			while (list($TKT_ID, $value) = each($this->_req_data['checkbox'])) {
1150 1150
 				//delete
1151
-				if ( ! $this->_delete_the_ticket( $TKT_ID ) ) {
1151
+				if ( ! $this->_delete_the_ticket($TKT_ID)) {
1152 1152
 					$success = 0;
1153 1153
 				}
1154 1154
 			}
1155 1155
 		} else {
1156 1156
 			//grab single id and trash
1157
-			$TKT_ID = absint( $this->_req_data['TKT_ID'] );
1158
-			if ( ! $this->_delete_the_ticket( $TKT_ID ) ) {
1157
+			$TKT_ID = absint($this->_req_data['TKT_ID']);
1158
+			if ( ! $this->_delete_the_ticket($TKT_ID)) {
1159 1159
 					$success = 0;
1160 1160
 				}
1161 1161
 		}
@@ -1167,16 +1167,16 @@  discard block
 block discarded – undo
1167 1167
 			);
1168 1168
 
1169 1169
 		//failsafe.  If the default ticket count === 1 then we need to redirect to event overview.
1170
-		if ( EEM_Ticket::instance()->count_deleted_and_undeleted( array( array( 'TKT_is_default' => 1 ) ), 'TKT_ID', TRUE ) )
1170
+		if (EEM_Ticket::instance()->count_deleted_and_undeleted(array(array('TKT_is_default' => 1)), 'TKT_ID', TRUE))
1171 1171
 			$query_args = array();
1172
-		$this->_redirect_after_action( $success, 'Tickets', $action_desc, $query_args );
1172
+		$this->_redirect_after_action($success, 'Tickets', $action_desc, $query_args);
1173 1173
 	}
1174 1174
 
1175 1175
 
1176 1176
 
1177 1177
 
1178
-	protected function _delete_the_ticket( $TKT_ID ) {
1179
-		$tkt = EEM_Ticket::instance()->get_one_by_ID( $TKT_ID );
1178
+	protected function _delete_the_ticket($TKT_ID) {
1179
+		$tkt = EEM_Ticket::instance()->get_one_by_ID($TKT_ID);
1180 1180
 		$tkt->_remove_relations('Datetime');
1181 1181
 		//delete all related prices first
1182 1182
 		$tkt->delete_related_permanently('Price');
Please login to merge, or discard this patch.
caffeinated/admin/new/pricing/espresso_events_Pricing_Hooks.class.php 1 patch
Spacing   +381 added lines, -381 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
 /**
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
 		$this->_name = 'pricing';
55 55
 
56 56
 		//capability check
57
-		if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_default_prices', 'advanced_ticket_datetime_metabox' ) ) {
57
+		if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_default_prices', 'advanced_ticket_datetime_metabox')) {
58 58
 			return;
59 59
 		}
60 60
 
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 		//if we were going to add our own metaboxes we'd use the below.
63 63
 		$this->_metaboxes = array(
64 64
 			0 => array(
65
-				'page_route' => array('edit','create_new'),
65
+				'page_route' => array('edit', 'create_new'),
66 66
 				'func' => 'pricing_metabox',
67 67
 				'label' => __('Event Tickets & Datetimes', 'event_espresso'),
68 68
 				'priority' => 'high',
69 69
 				'context' => 'normal'
70 70
 				),
71 71
 
72
-			);/**/
72
+			); /**/
73 73
 
74 74
 		$this->_remove_metaboxes = array(
75 75
 			0 => array(
@@ -88,24 +88,24 @@  discard block
 block discarded – undo
88 88
 		 *
89 89
 		 * @var array  Expected an array returned with 'date' and 'time' keys.
90 90
 		 */
91
-		$this->_date_format_strings = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
91
+		$this->_date_format_strings = apply_filters('FHEE__espresso_events_Pricing_Hooks___set_hooks_properties__date_format_strings', array(
92 92
 				'date' => 'Y-m-d',
93 93
 				'time' => 'h:i a'
94 94
 			));
95 95
 
96 96
 		//validate
97
-		$this->_date_format_strings['date'] = isset( $this->_date_format_strings['date'] ) ? $this->_date_format_strings['date'] : null;
98
-		$this->_date_format_strings['time'] = isset( $this->_date_format_strings['time'] ) ? $this->_date_format_strings['time'] : null;
97
+		$this->_date_format_strings['date'] = isset($this->_date_format_strings['date']) ? $this->_date_format_strings['date'] : null;
98
+		$this->_date_format_strings['time'] = isset($this->_date_format_strings['time']) ? $this->_date_format_strings['time'] : null;
99 99
 
100 100
 		//validate format strings
101
-		$format_validation = EEH_DTT_Helper::validate_format_string( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
102
-		if ( is_array( $format_validation ) ) {
103
-			$msg = '<p>' . sprintf( __( 'The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso' ), $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ) . '</p><ul>';
104
-			foreach ( $format_validation as $error ) {
105
-				$msg .= '<li>' . $error . '</li>';
101
+		$format_validation = EEH_DTT_Helper::validate_format_string($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
102
+		if (is_array($format_validation)) {
103
+			$msg = '<p>'.sprintf(__('The format "%s" was likely added via a filter and is invalid for the following reasons:', 'event_espresso'), $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']).'</p><ul>';
104
+			foreach ($format_validation as $error) {
105
+				$msg .= '<li>'.$error.'</li>';
106 106
 			}
107
-			$msg .= '</ul></p><p>' . sprintf( __( '%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso' ), '<span style="color:#D54E21;">', '</span>' ) . '</p>';
108
-			EE_Error::add_attention( $msg, __FILE__, __FUNCTION__, __LINE__ );
107
+			$msg .= '</ul></p><p>'.sprintf(__('%sPlease note that your date and time formats have been reset to "Y-m-d" and "h:i a" respectively.%s', 'event_espresso'), '<span style="color:#D54E21;">', '</span>').'</p>';
108
+			EE_Error::add_attention($msg, __FILE__, __FUNCTION__, __LINE__);
109 109
 			$this->_date_format_strings = array(
110 110
 				'date' => 'Y-m-d',
111 111
 				'time' => 'h:i a'
@@ -116,60 +116,60 @@  discard block
 block discarded – undo
116 116
 		$this->_scripts_styles = array(
117 117
 			'registers' => array(
118 118
 				'ee-tickets-datetimes-css' => array(
119
-					'url' => PRICING_ASSETS_URL . 'event-tickets-datetimes.css',
119
+					'url' => PRICING_ASSETS_URL.'event-tickets-datetimes.css',
120 120
 					'type' => 'css'
121 121
 					),
122 122
 				'ee-dtt-ticket-metabox' => array(
123
-					'url' => PRICING_ASSETS_URL . 'ee-datetime-ticket-metabox.js',
123
+					'url' => PRICING_ASSETS_URL.'ee-datetime-ticket-metabox.js',
124 124
 					'depends' => array('ee-datepicker', 'ee-dialog', 'underscore')
125 125
 					)
126 126
 				),
127 127
 			'deregisters' => array(
128
-				'event-editor-css' => array('type' => 'css' ),
128
+				'event-editor-css' => array('type' => 'css'),
129 129
 				'event-datetime-metabox' => array('type' => 'js')
130 130
 				),
131 131
 			'enqueues' => array(
132
-				'ee-tickets-datetimes-css' => array( 'edit', 'create_new' ),
133
-				'ee-dtt-ticket-metabox' => array( 'edit', 'create_new' )
132
+				'ee-tickets-datetimes-css' => array('edit', 'create_new'),
133
+				'ee-dtt-ticket-metabox' => array('edit', 'create_new')
134 134
 				),
135 135
 			'localize' => array(
136 136
 				'ee-dtt-ticket-metabox' => array(
137 137
 					'DTT_TRASH_BLOCK' => array(
138 138
 						'main_warning' => __('The Datetime you are attempting to trash is the only datetime selected for the following ticket(s):', 'event_espresso'),
139 139
 						'after_warning' => __('In order to trash this datetime you must first make sure the above ticket(s) are assigned to other datetimes.', 'event_espresso'),
140
-						'cancel_button' => '<button class="button-secondary ee-modal-cancel">' . __('Cancel', 'event_espresso') . '</button>',
140
+						'cancel_button' => '<button class="button-secondary ee-modal-cancel">'.__('Cancel', 'event_espresso').'</button>',
141 141
 						'single_warning_from_tkt' => __('The Datetime you are attempting to unassign from this ticket is the only remaining datetime for this ticket. Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
142 142
 						'single_warning_from_dtt' => __('The ticket you are attempting to unassign from this datetime cannot be unassigned because the datetime is the only remaining datetime for the ticket.  Tickets must always have at least one datetime assigned to them.', 'event_espresso'),
143
-						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button>'
143
+						'dismiss_button' => '<button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button>'
144 144
 						),
145 145
 					'DTT_ERROR_MSG' => array(
146 146
 						'no_ticket_name' => __('General Admission', 'event_espresso'),
147
-						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">' . __('Dismiss', 'event_espresso') . '</button></div>'
147
+						'dismiss_button' => '<div class="save-cancel-button-container"><button class="button-secondary ee-modal-cancel">'.__('Dismiss', 'event_espresso').'</button></div>'
148 148
 						),
149 149
 					'DTT_OVERSELL_WARNING' => array(
150 150
 						'datetime_ticket' => __('You cannot add this ticket to this datetime because it has a sold amount that is greater than the amount of spots remaining for this datetime.', 'event_espresso'),
151 151
 						'ticket_datetime' => __('You cannot add this datetime to this ticket because the ticket has a sold amount that is greater than the amount of spots remaining on the datetime.', 'event_espresso')
152 152
 						),
153
-					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats( $this->_date_format_strings['date'], $this->_date_format_strings['time'] ),
154
-					'DTT_START_OF_WEEK' => array( 'dayValue' => (int) get_option( 'start_of_week' ) )
153
+					'DTT_CONVERTED_FORMATS' => EEH_DTT_Helper::convert_php_to_js_and_moment_date_formats($this->_date_format_strings['date'], $this->_date_format_strings['time']),
154
+					'DTT_START_OF_WEEK' => array('dayValue' => (int) get_option('start_of_week'))
155 155
 					)
156 156
 				)
157 157
 			);
158 158
 
159 159
 
160
-		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array( $this, 'autosave_handling' ), 10 );
161
-		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array( $this, 'caf_updates' ), 10 );
160
+		add_action('AHEE__EE_Admin_Page_CPT__do_extra_autosave_stuff__after_Extend_Events_Admin_Page', array($this, 'autosave_handling'), 10);
161
+		add_filter('FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', array($this, 'caf_updates'), 10);
162 162
 	}
163 163
 
164 164
 
165 165
 
166
-	public function caf_updates( $update_callbacks ) {
167
-		foreach ( $update_callbacks as $key => $callback ) {
168
-			if ( $callback[1] == '_default_tickets_update' )
169
-				unset( $update_callbacks[$key] );
166
+	public function caf_updates($update_callbacks) {
167
+		foreach ($update_callbacks as $key => $callback) {
168
+			if ($callback[1] == '_default_tickets_update')
169
+				unset($update_callbacks[$key]);
170 170
 		}
171 171
 
172
-		$update_callbacks[] = array( $this, 'dtt_and_tickets_caf_update' );
172
+		$update_callbacks[] = array($this, 'dtt_and_tickets_caf_update');
173 173
 		return $update_callbacks;
174 174
 	}
175 175
 
@@ -182,11 +182,11 @@  discard block
 block discarded – undo
182 182
 	 * @param  array    $data   The request data from the form
183 183
 	 * @return bool             success or fail
184 184
 	 */
185
-	public function dtt_and_tickets_caf_update( $evtobj, $data ) {
185
+	public function dtt_and_tickets_caf_update($evtobj, $data) {
186 186
 		//first we need to start with datetimes cause they are the "root" items attached to events.
187
-		$saved_dtts = $this->_update_dtts( $evtobj, $data );
187
+		$saved_dtts = $this->_update_dtts($evtobj, $data);
188 188
 		//next tackle the tickets (and prices?)
189
-		$this->_update_tkts( $evtobj, $saved_dtts, $data );
189
+		$this->_update_tkts($evtobj, $saved_dtts, $data);
190 190
 	}
191 191
 
192 192
 
@@ -197,41 +197,41 @@  discard block
 block discarded – undo
197 197
 	 * @param  array    	$data    the request data from the form
198 198
 	 * @return EE_Datetime[]
199 199
 	 */
200
-	protected function _update_dtts( $evt_obj, $data ) {
201
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
200
+	protected function _update_dtts($evt_obj, $data) {
201
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
202 202
 		$saved_dtt_ids = array();
203 203
 		$saved_dtt_objs = array();
204 204
 
205
-		foreach ( $data['edit_event_datetimes'] as $row => $dtt ) {
205
+		foreach ($data['edit_event_datetimes'] as $row => $dtt) {
206 206
 			//trim all values to ensure any excess whitespace is removed.
207 207
 			$dtt = array_map(
208
-				function( $datetime_data ) {
209
-					return is_array( $datetime_data ) ? $datetime_data : trim( $datetime_data );
208
+				function($datetime_data) {
209
+					return is_array($datetime_data) ? $datetime_data : trim($datetime_data);
210 210
 				},
211 211
 				$dtt
212 212
 			);
213
-			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
213
+			$dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] : $dtt['DTT_EVT_start'];
214 214
 			$datetime_values = array(
215
-				'DTT_ID' 			=> ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : NULL,
216
-				'DTT_name' 			=> ! empty( $dtt['DTT_name'] ) ? $dtt['DTT_name'] : '',
217
-				'DTT_description' 	=> ! empty( $dtt['DTT_description'] ) ? $dtt['DTT_description'] : '',
215
+				'DTT_ID' 			=> ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : NULL,
216
+				'DTT_name' 			=> ! empty($dtt['DTT_name']) ? $dtt['DTT_name'] : '',
217
+				'DTT_description' 	=> ! empty($dtt['DTT_description']) ? $dtt['DTT_description'] : '',
218 218
 				'DTT_EVT_start' 	=> $dtt['DTT_EVT_start'],
219 219
 				'DTT_EVT_end' 		=> $dtt['DTT_EVT_end'],
220
-				'DTT_reg_limit' 	=> empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt[ 'DTT_reg_limit' ],
221
-				'DTT_order' 		=> ! isset( $dtt['DTT_order'] ) ? $row : $dtt['DTT_order'],
220
+				'DTT_reg_limit' 	=> empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'],
221
+				'DTT_order' 		=> ! isset($dtt['DTT_order']) ? $row : $dtt['DTT_order'],
222 222
 			);
223 223
 
224 224
 			//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.
225 225
 
226
-			if ( !empty( $dtt['DTT_ID'] ) ) {
227
-				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) )->get_one_by_ID($dtt['DTT_ID'] );
226
+			if ( ! empty($dtt['DTT_ID'])) {
227
+				$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone))->get_one_by_ID($dtt['DTT_ID']);
228 228
 
229 229
 				//set date and time format according to what is set in this class.
230
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
231
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
230
+				$DTM->set_date_format($this->_date_format_strings['date']);
231
+				$DTM->set_time_format($this->_date_format_strings['time']);
232 232
 
233
-				foreach ( $datetime_values as $field => $value ) {
234
-					$DTM->set( $field, $value );
233
+				foreach ($datetime_values as $field => $value) {
234
+					$DTM->set($field, $value);
235 235
 				}
236 236
 
237 237
 				// make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it.
@@ -239,24 +239,24 @@  discard block
 block discarded – undo
239 239
 				$saved_dtt_ids[$DTM->ID()] = $DTM->ID();
240 240
 
241 241
 			} else {
242
-				$DTM = EE_Registry::instance()->load_class('Datetime', array( $datetime_values, $timezone ), FALSE, FALSE );
242
+				$DTM = EE_Registry::instance()->load_class('Datetime', array($datetime_values, $timezone), FALSE, FALSE);
243 243
 
244 244
 				//reset date and times to match the format
245
-				$DTM->set_date_format( $this->_date_format_strings['date'] );
246
-				$DTM->set_time_format( $this->_date_format_strings['time'] );
247
-				foreach( $datetime_values as $field => $value ) {
248
-					$DTM->set( $field, $value );
245
+				$DTM->set_date_format($this->_date_format_strings['date']);
246
+				$DTM->set_time_format($this->_date_format_strings['time']);
247
+				foreach ($datetime_values as $field => $value) {
248
+					$DTM->set($field, $value);
249 249
 				}
250 250
 			}
251 251
 
252 252
 
253 253
 			$DTM->save();
254
-			$DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' );
254
+			$DTM = $evt_obj->_add_relation_to($DTM, 'Datetime');
255 255
 			$evt_obj->save();
256 256
 
257 257
 			//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.
258
-			if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) {
259
-				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') );
258
+			if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) {
259
+				$DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start'));
260 260
 				$DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days');
261 261
 				$DTM->save();
262 262
 			}
@@ -271,25 +271,25 @@  discard block
 block discarded – undo
271 271
 		}
272 272
 
273 273
 		//now we need to REMOVE any dtts that got deleted.  Keep in mind that this process will only kick in for DTT's that don't have any DTT_sold on them. So its safe to permanently delete at this point.
274
-		$old_datetimes = explode(',', $data['datetime_IDs'] );
274
+		$old_datetimes = explode(',', $data['datetime_IDs']);
275 275
 		$old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes;
276 276
 
277
-		if ( is_array( $old_datetimes ) ) {
278
-			$dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids );
279
-			foreach ( $dtts_to_delete as $id ) {
280
-				$id = absint( $id );
281
-				if ( empty( $id ) )
277
+		if (is_array($old_datetimes)) {
278
+			$dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids);
279
+			foreach ($dtts_to_delete as $id) {
280
+				$id = absint($id);
281
+				if (empty($id))
282 282
 					continue;
283 283
 
284 284
 				$dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id);
285 285
 
286 286
 				//remove tkt relationships.
287 287
 				$related_tickets = $dtt_to_remove->get_many_related('Ticket');
288
-				foreach ( $related_tickets as $tkt ) {
288
+				foreach ($related_tickets as $tkt) {
289 289
 					$dtt_to_remove->_remove_relation_to($tkt, 'Ticket');
290 290
 				}
291 291
 
292
-				$evt_obj->_remove_relation_to( $id, 'Datetime' );
292
+				$evt_obj->_remove_relation_to($id, 'Datetime');
293 293
 				$dtt_to_remove->refresh_cache_of_related_objects();
294 294
 
295 295
 			}
@@ -310,85 +310,85 @@  discard block
 block discarded – undo
310 310
 	 * @param  array            $data       incoming request data
311 311
 	 * @return EE_Ticket[]
312 312
 	 */
313
-	protected function _update_tkts( $evtobj, $saved_dtts, $data ) {
313
+	protected function _update_tkts($evtobj, $saved_dtts, $data) {
314 314
 
315 315
 		$new_tkt = null;
316 316
 		$new_default = null;
317 317
 		//stripslashes because WP filtered the $_POST ($data) array to add slashes
318 318
 		$data = stripslashes_deep($data);
319
-		$timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL;
319
+		$timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL;
320 320
 		$saved_tickets = $dtts_on_existing = array();
321
-		$old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array();
321
+		$old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array();
322 322
 
323 323
 		//load money helper
324 324
 
325
-		foreach ( $data['edit_tickets'] as $row => $tkt ) {
325
+		foreach ($data['edit_tickets'] as $row => $tkt) {
326 326
 
327 327
 			$update_prices = $create_new_TKT = FALSE;
328 328
 
329 329
 			//figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session.
330 330
 
331
-			$starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]);
332
-			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] );
331
+			$starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]);
332
+			$tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]);
333 333
 			$dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows);
334 334
 			$dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows);
335 335
 
336 336
 			// trim inputs to ensure any excess whitespace is removed.
337 337
 			$tkt = array_map(
338
-				function( $ticket_data ) {
339
-					return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data );
338
+				function($ticket_data) {
339
+					return is_array($ticket_data) ? $ticket_data : trim($ticket_data);
340 340
 				},
341 341
 				$tkt
342 342
 			);
343 343
 
344 344
 			//note we are doing conversions to floats here instead of allowing EE_Money_Field to handle because we're doing calcs prior to using the models.
345 345
 			//note incoming ['TKT_price'] value is already in standard notation (via js).
346
-			$ticket_price = isset( $tkt['TKT_price'] ) ?  round ( (float) $tkt['TKT_price'], 3 ) : 0;
346
+			$ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0;
347 347
 
348 348
 			//note incoming base price needs converted from localized value.
349
-			$base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0;
349
+			$base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0;
350 350
 			//if ticket price == 0 and $base_price != 0 then ticket price == base_price
351 351
 			$ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price;
352
-			$base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0;
352
+			$base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0;
353 353
 
354 354
 			$price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array();
355 355
 
356 356
 			$now = null;
357
-			if ( empty( $tkt['TKT_start_date'] ) ) {
357
+			if (empty($tkt['TKT_start_date'])) {
358 358
 				//lets' use now in the set timezone.
359
-				$now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) );
360
-				$tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
359
+				$now = new DateTime('now', new DateTimeZone($evtobj->get_timezone()));
360
+				$tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
361 361
 			}
362 362
 
363
-			if ( empty( $tkt['TKT_end_date'] ) ) {
363
+			if (empty($tkt['TKT_end_date'])) {
364 364
 				/**
365 365
 				 * set the TKT_end_date to the first datetime attached to the ticket.
366 366
 				 */
367
-				$first_dtt = $saved_dtts[reset( $tkt_dtt_rows )];
368
-				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] );
367
+				$first_dtt = $saved_dtts[reset($tkt_dtt_rows)];
368
+				$tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']);
369 369
 			}
370 370
 
371 371
 			$TKT_values = array(
372
-				'TKT_ID' 			=> ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL,
373
-				'TTM_ID' 			=> ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0,
374
-				'TKT_name' 			=> ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '',
375
-				'TKT_description' 	=> ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
372
+				'TKT_ID' 			=> ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL,
373
+				'TTM_ID' 			=> ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0,
374
+				'TKT_name' 			=> ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '',
375
+				'TKT_description' 	=> ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '',
376 376
 				'TKT_start_date' 	=> $tkt['TKT_start_date'],
377 377
 				'TKT_end_date' 		=> $tkt['TKT_end_date'],
378
-				'TKT_qty' 			=> ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ],
379
-				'TKT_uses' 			=> ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'],
380
-				'TKT_min' 			=> empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'],
381
-				'TKT_max' 			=> empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'],
378
+				'TKT_qty' 			=> ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'],
379
+				'TKT_uses' 			=> ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'],
380
+				'TKT_min' 			=> empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'],
381
+				'TKT_max' 			=> empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'],
382 382
 				'TKT_row' 			=> $row,
383
-				'TKT_order' 		=> isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0,
384
-				'TKT_taxable' 		=> ! empty( $tkt['TKT_taxable'] ) ? 1 : 0,
385
-				'TKT_required' 		=> ! empty( $tkt['TKT_required'] ) ? 1 : 0,
383
+				'TKT_order' 		=> isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0,
384
+				'TKT_taxable' 		=> ! empty($tkt['TKT_taxable']) ? 1 : 0,
385
+				'TKT_required' 		=> ! empty($tkt['TKT_required']) ? 1 : 0,
386 386
 				'TKT_price' 		=> $ticket_price
387 387
 			);
388 388
 
389 389
 
390 390
 			//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.
391
-			if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) {
391
+			if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) {
392 392
 				$TKT_values['TKT_ID'] = 0;
393 393
 				$TKT_values['TKT_is_default'] = 0;
394 394
 				$update_prices = TRUE;
@@ -400,21 +400,21 @@  discard block
 block discarded – undo
400 400
 			// but DID have it's items modified.
401 401
 			// keep in mind that if the TKT has been sold (and we have changed pricing information),
402 402
 			// then we won't be updating the tkt but instead a new tkt will be created and the old one archived.
403
-			if ( absint( $TKT_values['TKT_ID'] ) ) {
404
-				$TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] );
405
-				if ( $TKT instanceof EE_Ticket ) {
403
+			if (absint($TKT_values['TKT_ID'])) {
404
+				$TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']);
405
+				if ($TKT instanceof EE_Ticket) {
406 406
 
407
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
407
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
408 408
 					// are there any registrations using this ticket ?
409 409
 					$tickets_sold = $TKT->count_related(
410 410
 						'Registration',
411
-						array( array(
412
-								'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) )
413
-						) )
411
+						array(array(
412
+								'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete))
413
+						))
414 414
 					);
415 415
 					//set ticket formats
416
-					$TKT->set_date_format( $this->_date_format_strings['date'] );
417
-					$TKT->set_time_format( $this->_date_format_strings['time'] );
416
+					$TKT->set_date_format($this->_date_format_strings['date']);
417
+					$TKT->set_time_format($this->_date_format_strings['time']);
418 418
 
419 419
 					// let's just check the total price for the existing ticket
420 420
 					// and determine if it matches the new total price.
@@ -424,17 +424,17 @@  discard block
 block discarded – undo
424 424
 							? TRUE : FALSE;
425 425
 
426 426
 					//set new values
427
-					foreach ( $TKT_values as $field => $value ) {
428
-						if ( $field === 'TKT_qty' ) {
429
-							$TKT->set_qty( $value );
427
+					foreach ($TKT_values as $field => $value) {
428
+						if ($field === 'TKT_qty') {
429
+							$TKT->set_qty($value);
430 430
 						} else {
431
-							$TKT->set( $field, $value );
431
+							$TKT->set($field, $value);
432 432
 						}
433 433
 					}
434 434
 
435 435
 					//if $create_new_TKT is false then we can safely update the existing ticket.  Otherwise we have to create a new ticket.
436
-					if ( $create_new_TKT ) {
437
-						$new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id );
436
+					if ($create_new_TKT) {
437
+						$new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id);
438 438
 					}
439 439
 				}
440 440
 
@@ -443,12 +443,12 @@  discard block
 block discarded – undo
443 443
 				$TKT = EE_Ticket::new_instance(
444 444
 					$TKT_values,
445 445
 					$timezone,
446
-					array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ]  )
446
+					array($this->_date_format_strings['date'], $this->_date_format_strings['time'])
447 447
 				);
448
-				if ( $TKT instanceof EE_Ticket ) {
448
+				if ($TKT instanceof EE_Ticket) {
449 449
 					// make sure ticket has an ID of setting relations won't work
450 450
 					$TKT->save();
451
-					$TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed );
451
+					$TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed);
452 452
 					$update_prices = TRUE;
453 453
 				}
454 454
 			}
@@ -456,37 +456,37 @@  discard block
 block discarded – undo
456 456
 			//$TKT->save();
457 457
 
458 458
 			//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.
459
-			if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) {
460
-				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date') );
459
+			if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) {
460
+				$TKT->set('TKT_end_date', $TKT->get('TKT_start_date'));
461 461
 				$TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days');
462 462
 			}
463 463
 
464 464
 			//let's make sure the base price is handled
465
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT;
465
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT;
466 466
 
467 467
 			//add/update price_modifiers
468
-			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT;
468
+			$TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT;
469 469
 
470 470
 			//need to make sue that the TKT_price is accurate after saving the prices.
471 471
 			$TKT->ensure_TKT_Price_correct();
472 472
 
473 473
 			//handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave.
474
-			if ( ! defined('DOING_AUTOSAVE' ) ) {
475
-				if ( !empty($tkt['TKT_is_default_selector'] ) ) {
474
+			if ( ! defined('DOING_AUTOSAVE')) {
475
+				if ( ! empty($tkt['TKT_is_default_selector'])) {
476 476
 					$update_prices = TRUE;
477 477
 					$new_default = clone $TKT;
478
-					$new_default->set( 'TKT_ID', 0 );
479
-					$new_default->set( 'TKT_is_default', 1 );
480
-					$new_default->set( 'TKT_row', 1 );
481
-					$new_default->set( 'TKT_price', $ticket_price );
478
+					$new_default->set('TKT_ID', 0);
479
+					$new_default->set('TKT_is_default', 1);
480
+					$new_default->set('TKT_row', 1);
481
+					$new_default->set('TKT_price', $ticket_price);
482 482
 					//remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object)
483 483
 					$new_default->_remove_relations('Datetime');
484 484
 					//todo we need to add the current attached prices as new prices to the new default ticket.
485
-					$new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices );
485
+					$new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices);
486 486
 					//don't forget the base price!
487
-					$new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id );
487
+					$new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id);
488 488
 					$new_default->save();
489
-					do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data );
489
+					do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data);
490 490
 				}
491 491
 			}
492 492
 
@@ -497,19 +497,19 @@  discard block
 block discarded – undo
497 497
 			//let's assign any tickets that have been setup to the saved_tickets tracker
498 498
 			//save existing TKT
499 499
 			$TKT->save();
500
-			if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) {
500
+			if ($create_new_TKT && $new_tkt instanceof EE_Ticket) {
501 501
 				//save new TKT
502 502
 				$new_tkt->save();
503 503
 				//add new ticket to array
504
-				$saved_tickets[ $new_tkt->ID() ] = $new_tkt;
504
+				$saved_tickets[$new_tkt->ID()] = $new_tkt;
505 505
 
506
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data );
506
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data);
507 507
 
508 508
 			} else {
509 509
 				//add tkt to saved tkts
510
-				$saved_tickets[ $TKT->ID() ] = $TKT;
510
+				$saved_tickets[$TKT->ID()] = $TKT;
511 511
 
512
-				do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data );
512
+				do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data);
513 513
 			}
514 514
 
515 515
 		}
@@ -519,22 +519,22 @@  discard block
 block discarded – undo
519 519
 		// (i.e. autosaves are happening and then in between autosaves the user trashes a ticket).
520 520
 		// Or a draft event was saved and in the process of editing a ticket is trashed.
521 521
 		// No sense in keeping all the related data in the db!
522
-		$old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets;
523
-		$tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) );
522
+		$old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets;
523
+		$tickets_removed = array_diff($old_tickets, array_keys($saved_tickets));
524 524
 
525
-		foreach ( $tickets_removed as $id ) {
526
-			$id = absint( $id );
525
+		foreach ($tickets_removed as $id) {
526
+			$id = absint($id);
527 527
 
528 528
 			//get the ticket for this id
529 529
 			$tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id);
530 530
 
531 531
 			//if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime
532
-			if ( $tkt_to_remove->get('TKT_is_default') )
532
+			if ($tkt_to_remove->get('TKT_is_default'))
533 533
 				continue;
534 534
 
535 535
 			// if this tkt has any registrations attached so then we just ARCHIVE
536 536
 			// because we don't actually permanently delete these tickets.
537
-			if ( $tkt_to_remove->count_related('Registration') > 0 ) {
537
+			if ($tkt_to_remove->count_related('Registration') > 0) {
538 538
 				$tkt_to_remove->delete();
539 539
 				continue;
540 540
 			}
@@ -543,7 +543,7 @@  discard block
 block discarded – undo
543 543
 			// (remember this process can ONLY kick off if there are NO tkts_sold)
544 544
 			$dtts = $tkt_to_remove->get_many_related('Datetime');
545 545
 
546
-			foreach( $dtts as $dtt ) {
546
+			foreach ($dtts as $dtt) {
547 547
 				$tkt_to_remove->_remove_relation_to($dtt, 'Datetime');
548 548
 			}
549 549
 
@@ -551,7 +551,7 @@  discard block
 block discarded – undo
551 551
 			// tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived))
552 552
 			$tkt_to_remove->delete_related_permanently('Price');
553 553
 
554
-			do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove );
554
+			do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove);
555 555
 
556 556
 			// finally let's delete this ticket
557 557
 			// (which should not be blocked at this point b/c we've removed all our relationships)
@@ -583,39 +583,39 @@  discard block
 block discarded – undo
583 583
 		// and removing the ticket from datetimes it got removed from.
584 584
 
585 585
 		// first let's add datetimes
586
-		if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) {
587
-			foreach ( $added_datetimes as $row_id ) {
586
+		if ( ! empty($added_datetimes) && is_array($added_datetimes)) {
587
+			foreach ($added_datetimes as $row_id) {
588 588
 				$row_id = (int) $row_id;
589
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
590
-					$ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
589
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
590
+					$ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime');
591 591
 					// Is this an existing ticket (has an ID) and does it have any sold?
592 592
 					// If so, then we need to add that to the DTT sold because this DTT is getting added.
593
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
594
-						$saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() );
595
-						$saved_datetimes[ $row_id ]->save();
593
+					if ($ticket->ID() && $ticket->sold() > 0) {
594
+						$saved_datetimes[$row_id]->increase_sold($ticket->sold());
595
+						$saved_datetimes[$row_id]->save();
596 596
 					}
597 597
 				}
598 598
 			}
599 599
 		}
600 600
 		// then remove datetimes
601
-		if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) {
602
-			foreach ( $removed_datetimes as $row_id ) {
603
-				$row_id = (int)$row_id;
601
+		if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) {
602
+			foreach ($removed_datetimes as $row_id) {
603
+				$row_id = (int) $row_id;
604 604
 				// its entirely possible that a datetime got deleted (instead of just removed from relationship.
605 605
 				// So make sure we skip over this if the dtt isn't in the $saved_datetimes array)
606
-				if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) {
607
-					$ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' );
606
+				if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) {
607
+					$ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime');
608 608
 					// Is this an existing ticket (has an ID) and does it have any sold?
609 609
 					// If so, then we need to remove it's sold from the DTT_sold.
610
-					if ( $ticket->ID() && $ticket->sold() > 0 ) {
611
-						$saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() );
612
-						$saved_datetimes[ $row_id ]->save();
610
+					if ($ticket->ID() && $ticket->sold() > 0) {
611
+						$saved_datetimes[$row_id]->decrease_sold($ticket->sold());
612
+						$saved_datetimes[$row_id]->save();
613 613
 					}
614 614
 				}
615 615
 			}
616 616
 		}
617 617
 		// cap ticket qty by datetime reg limits
618
-		$ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) );
618
+		$ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit')));
619 619
 		return $ticket;
620 620
 	}
621 621
 
@@ -636,39 +636,39 @@  discard block
 block discarded – undo
636 636
 		EE_Ticket $ticket,
637 637
 		$price_rows = array(),
638 638
 		$ticket_price = 0,
639
-		$base_price = 0 ,
639
+		$base_price = 0,
640 640
 		$base_price_id = 0
641 641
 	) {
642 642
 
643 643
 		// create new ticket that's a copy of the existing
644 644
 		// except a new id of course (and not archived)
645 645
 		// AND has the new TKT_price associated with it.
646
-		$new_ticket = clone( $ticket );
647
-		$new_ticket->set( 'TKT_ID', 0 );
648
-		$new_ticket->set( 'TKT_deleted', 0 );
649
-		$new_ticket->set( 'TKT_price', $ticket_price );
650
-		$new_ticket->set( 'TKT_sold', 0 );
646
+		$new_ticket = clone($ticket);
647
+		$new_ticket->set('TKT_ID', 0);
648
+		$new_ticket->set('TKT_deleted', 0);
649
+		$new_ticket->set('TKT_price', $ticket_price);
650
+		$new_ticket->set('TKT_sold', 0);
651 651
 		// let's get a new ID for this ticket
652 652
 		$new_ticket->save();
653 653
 		// we also need to make sure this new ticket gets the same datetime attachments as the archived ticket
654
-		$datetimes_on_existing = $ticket->get_many_related( 'Datetime' );
654
+		$datetimes_on_existing = $ticket->get_many_related('Datetime');
655 655
 		$new_ticket = $this->_update_ticket_datetimes(
656 656
 			$new_ticket,
657 657
 			$datetimes_on_existing,
658
-			array_keys( $datetimes_on_existing )
658
+			array_keys($datetimes_on_existing)
659 659
 		);
660 660
 
661 661
 		// $ticket will get archived later b/c we are NOT adding it to the saved_tickets array.
662 662
 		// if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining
663 663
 		// available.
664
-		if ( $ticket->sold() > 0 ) {
664
+		if ($ticket->sold() > 0) {
665 665
 			$new_qty = $ticket->qty() - $ticket->sold();
666
-			$new_ticket->set_qty( $new_qty );
666
+			$new_ticket->set_qty($new_qty);
667 667
 		}
668 668
 		//now we update the prices just for this ticket
669
-		$new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true );
669
+		$new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true);
670 670
 		//and we update the base price
671
-		$new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id );
671
+		$new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id);
672 672
 		return $new_ticket;
673 673
 	}
674 674
 
@@ -688,7 +688,7 @@  discard block
 block discarded – undo
688 688
 	 * @param int|bool 		$base_price_id  if present then this is the base_price_id being updated.
689 689
 	 * @return EE_Ticket
690 690
 	 */
691
-	protected function  _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) {
691
+	protected function  _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) {
692 692
 
693 693
 		//let's just get any current prices that may exist on the given ticket so we can remove any prices that got trashed in this session.
694 694
 		$current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers();
@@ -696,7 +696,7 @@  discard block
 block discarded – undo
696 696
 		$updated_prices = array();
697 697
 
698 698
 		// if $base_price ! FALSE then updating a base price.
699
-		if ( $base_price !== FALSE ) {
699
+		if ($base_price !== FALSE) {
700 700
 			$prices[1] = array(
701 701
 				'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id,
702 702
 				'PRT_ID' => 1,
@@ -707,47 +707,47 @@  discard block
 block discarded – undo
707 707
 		}
708 708
 
709 709
 		//possibly need to save tkt
710
-		if ( ! $ticket->ID() )
710
+		if ( ! $ticket->ID())
711 711
 			$ticket->save();
712 712
 
713
-		foreach ( $prices as $row => $prc ) {
714
-			$prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL;
715
-			if ( empty($prt_id) )
713
+		foreach ($prices as $row => $prc) {
714
+			$prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL;
715
+			if (empty($prt_id))
716 716
 				continue; //prices MUST have a price type id.
717 717
 			$PRC_values = array(
718
-				'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL,
718
+				'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL,
719 719
 				'PRT_ID' => $prt_id,
720
-				'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0,
721
-				'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '',
722
-				'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '',
720
+				'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0,
721
+				'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '',
722
+				'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '',
723 723
 				'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor
724 724
 				'PRC_order' => $row
725 725
 				);
726
-			if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) {
726
+			if ($new_prices || empty($PRC_values['PRC_ID'])) {
727 727
 				$PRC_values['PRC_ID'] = 0;
728
-				$PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE);
728
+				$PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE);
729 729
 			} else {
730
-				$PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] );
730
+				$PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']);
731 731
 				//update this price with new values
732
-				foreach ( $PRC_values as $field => $newprc ) {
733
-					$PRC->set( $field, $newprc );
732
+				foreach ($PRC_values as $field => $newprc) {
733
+					$PRC->set($field, $newprc);
734 734
 				}
735 735
 			}
736 736
 			$PRC->save();
737 737
 			$prcid = $PRC->ID();
738 738
 			$updated_prices[$prcid] = $PRC;
739
-			$ticket->_add_relation_to( $PRC, 'Price' );
739
+			$ticket->_add_relation_to($PRC, 'Price');
740 740
 		}
741 741
 
742 742
 		//now let's remove any prices that got removed from the ticket
743
-		if ( !empty ( $current_prices_on_ticket ) ) {
743
+		if ( ! empty ($current_prices_on_ticket)) {
744 744
 			$current = array_keys($current_prices_on_ticket);
745 745
 			$updated = array_keys($updated_prices);
746 746
 			$prices_to_remove = array_diff($current, $updated);
747
-			if ( !empty( $prices_to_remove ) ) {
748
-				foreach ( $prices_to_remove as $prc_id ) {
747
+			if ( ! empty($prices_to_remove)) {
748
+				foreach ($prices_to_remove as $prc_id) {
749 749
 					$p = $current_prices_on_ticket[$prc_id];
750
-					$ticket->_remove_relation_to( $p, 'Price' );
750
+					$ticket->_remove_relation_to($p, 'Price');
751 751
 
752 752
 					//delete permanently the price
753 753
 					$p->delete_permanently();
@@ -760,7 +760,7 @@  discard block
 block discarded – undo
760 760
 
761 761
 
762 762
 
763
-	public function autosave_handling( $event_admin_obj ) {
763
+	public function autosave_handling($event_admin_obj) {
764 764
 		return $event_admin_obj; //doing nothing for the moment.
765 765
 		//todo when I get to this remember that I need to set the template args on the $event_admin_obj (use the set_template_args() method)
766 766
 
@@ -794,12 +794,12 @@  discard block
 block discarded – undo
794 794
 
795 795
 		//default main template args
796 796
 		$main_template_args = array(
797
-			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
797
+			'event_datetime_help_link' => EEH_Template::get_help_tab_link('event_editor_event_datetimes_help_tab', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add a filter to the template for the help text in the Events_Admin_Page core file so we can add further help
798 798
 			'existing_datetime_ids' => '',
799 799
 			'total_dtt_rows' => 1,
800
-			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
800
+			'add_new_dtt_help_link' => EEH_Template::get_help_tab_link('add_new_dtt_info', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
801 801
 			'datetime_rows' => '',
802
-			'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
802
+			'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '',
803 803
 			'ticket_rows' => '',
804 804
 			'existing_ticket_ids' => '',
805 805
 			'total_ticket_rows' => 1,
@@ -809,7 +809,7 @@  discard block
 block discarded – undo
809 809
 
810 810
 		$timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL;
811 811
 
812
-		do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' );
812
+		do_action('AHEE_log', __FILE__, __FUNCTION__, '');
813 813
 
814 814
 		/**
815 815
 		 * 1. Start with retrieving Datetimes
@@ -817,8 +817,8 @@  discard block
 block discarded – undo
817 817
 		 * 3. For each ticket get related prices
818 818
 		 */
819 819
 
820
-		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) );
821
-		$times = $DTM->get_all_event_dates( $evtID );
820
+		$DTM = EE_Registry::instance()->load_model('Datetime', array($timezone));
821
+		$times = $DTM->get_all_event_dates($evtID);
822 822
 
823 823
 
824 824
 
@@ -826,31 +826,31 @@  discard block
 block discarded – undo
826 826
 
827 827
 		/** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */
828 828
 		$dttrow = 1;
829
-		foreach ( $times as $time ) {
829
+		foreach ($times as $time) {
830 830
 			$dttid = $time->get('DTT_ID');
831
-			$time->set( 'DTT_order', $dttrow );
831
+			$time->set('DTT_order', $dttrow);
832 832
 			$existing_datetime_ids[] = $dttid;
833 833
 
834 834
 			//tickets attached
835
-			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array( array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC' ) ) ) : array();
835
+			$related_tickets = $time->ID() > 0 ? $time->get_many_related('Ticket', array(array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), 'default_where_conditions' => 'none', 'order_by' => array('TKT_order' => 'ASC'))) : array();
836 836
 
837 837
 			//if there are no related tickets this is likely a new event OR autodraft
838 838
 			// event so we need to generate the default tickets because dtts
839 839
 			// ALWAYS have at least one related ticket!!.  EXCEPT, we dont' do this if there is already more than one
840 840
 			// datetime on the event.
841
-			if ( empty ( $related_tickets ) && count( $times ) < 2 ) {
841
+			if (empty ($related_tickets) && count($times) < 2) {
842 842
 				$related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets();
843 843
 
844 844
 				//this should be ordered by TKT_ID, so let's grab the first default ticket (which will be the main default) and ensure it has any default prices added to it (but do NOT save).
845 845
 				$default_prices = EEM_Price::instance()->get_all_default_prices();
846 846
 
847
-				$main_default_ticket = reset( $related_tickets );
848
-				if ( $main_default_ticket instanceof EE_Ticket ) {
849
-					foreach ( $default_prices as $default_price ) {
850
-						if ( $default_price->is_base_price() ) {
847
+				$main_default_ticket = reset($related_tickets);
848
+				if ($main_default_ticket instanceof EE_Ticket) {
849
+					foreach ($default_prices as $default_price) {
850
+						if ($default_price->is_base_price()) {
851 851
 							continue;
852 852
 						}
853
-						$main_default_ticket->cache( 'Price', $default_price );
853
+						$main_default_ticket->cache('Price', $default_price);
854 854
 					}
855 855
 				}
856 856
 			}
@@ -859,11 +859,11 @@  discard block
 block discarded – undo
859 859
 			//we can't actually setup rows in this loop yet cause we don't know all the unique tickets for this event yet (tickets are linked through all datetimes). So we're going to temporarily cache some of that information.
860 860
 
861 861
 			//loop through and setup the ticket rows and make sure the order is set.
862
-			foreach ( $related_tickets as $ticket ) {
862
+			foreach ($related_tickets as $ticket) {
863 863
 				$tktid = $ticket->get('TKT_ID');
864 864
 				$tktrow = $ticket->get('TKT_row');
865 865
 				//we only want unique tickets in our final display!!
866
-				if ( !in_array( $tktid, $existing_ticket_ids ) ) {
866
+				if ( ! in_array($tktid, $existing_ticket_ids)) {
867 867
 					$existing_ticket_ids[] = $tktid;
868 868
 					$all_tickets[] = $ticket;
869 869
 				}
@@ -872,57 +872,57 @@  discard block
 block discarded – undo
872 872
 				$datetime_tickets[$dttid][] = $tktrow;
873 873
 
874 874
 				//temporary cache of this datetime info for this ticket for later processing of ticket rows.
875
-				if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) )
875
+				if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid]))
876 876
 					$ticket_datetimes[$tktid][] = $dttrow;
877 877
 			}
878 878
 			$dttrow++;
879 879
 		}
880 880
 
881
-		$main_template_args['total_ticket_rows'] = count( $existing_ticket_ids );
882
-		$main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids );
883
-		$main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids );
881
+		$main_template_args['total_ticket_rows'] = count($existing_ticket_ids);
882
+		$main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids);
883
+		$main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids);
884 884
 
885 885
 		//sort $all_tickets by order
886
-		usort( $all_tickets, function( $a, $b ) {
886
+		usort($all_tickets, function($a, $b) {
887 887
 			$a_order = (int) $a->get('TKT_order');
888 888
 			$b_order = (int) $b->get('TKT_order');
889
-			if ( $a_order == $b_order ) {
889
+			if ($a_order == $b_order) {
890 890
 				return 0;
891 891
 			}
892
-			return ( $a_order < $b_order ) ? -1 : 1;
892
+			return ($a_order < $b_order) ? -1 : 1;
893 893
 		});
894 894
 
895 895
 		//k NOW we have all the data we need for setting up the dtt rows and ticket rows so we start our dtt loop again.
896 896
 		$dttrow = 1;
897
-		foreach ( $times as $time ) {
898
-			$main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times );
897
+		foreach ($times as $time) {
898
+			$main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times);
899 899
 			$dttrow++;
900 900
 		}
901 901
 
902 902
 		//then loop through all tickets for the ticket rows.
903 903
 		$tktrow = 1;
904
-		foreach ( $all_tickets as $ticket ) {
905
-			$main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets );
904
+		foreach ($all_tickets as $ticket) {
905
+			$main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets);
906 906
 			$tktrow++;
907 907
 		}
908 908
 
909 909
 		$main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets);
910
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php';
911
-		EEH_Template::display_template( $template, $main_template_args );
910
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php';
911
+		EEH_Template::display_template($template, $main_template_args);
912 912
 		return;
913 913
 	}
914 914
 
915 915
 
916 916
 
917
-	protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) {
917
+	protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) {
918 918
 
919 919
 		$dtt_display_template_args = array(
920
-			'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ),
921
-			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ),
920
+			'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts),
921
+			'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default),
922 922
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow
923 923
 			);
924
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php';
925
-		return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE);
924
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php';
925
+		return EEH_Template::display_template($template, $dtt_display_template_args, TRUE);
926 926
 	}
927 927
 
928 928
 
@@ -940,7 +940,7 @@  discard block
 block discarded – undo
940 940
 	 *
941 941
 	 * @return string Generated edit row.
942 942
 	 */
943
-	protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) {
943
+	protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) {
944 944
 
945 945
 		// if the incomign $dtt object is NOT an instance of EE_Datetime then force default to true.
946 946
 		$default = ! $dtt instanceof EE_Datetime ? true : false;
@@ -948,30 +948,30 @@  discard block
 block discarded – undo
948 948
 		$template_args = array(
949 949
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
950 950
 			'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes',
951
-			'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
951
+			'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing',
952 952
 			'DTT_ID' => $default ? '' : $dtt->ID(),
953 953
 			'DTT_name' => $default ? '' : $dtt->name(),
954 954
 			'DTT_description' => $default ? '' : $dtt->description(),
955
-			'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
956
-			'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
957
-			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'),
955
+			'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
956
+			'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
957
+			'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'),
958 958
 			'DTT_order' => $default ? 'DTTNUM' : $dttrow,
959 959
 			'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'),
960
-			'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
961
-			'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0  ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
960
+			'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable',
961
+			'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable'
962 962
 			);
963 963
 
964
-		$template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
964
+		$template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : '';
965 965
 
966 966
 		//allow filtering of template args at this point.
967
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event );
967
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_edit_row__template_args', $template_args, $dttrow, $dtt, $default, $all_dtts, $this->_is_creating_event);
968 968
 
969
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php';
970
-		return EEH_Template::display_template( $template, $template_args, TRUE );
969
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php';
970
+		return EEH_Template::display_template($template, $template_args, TRUE);
971 971
 	}
972 972
 
973 973
 
974
-	protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) {
974
+	protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) {
975 975
 
976 976
 		$template_args = array(
977 977
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
@@ -979,47 +979,47 @@  discard block
 block discarded – undo
979 979
 			'DTT_description' => $default ? '' : $dtt->description(),
980 980
 			'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '',
981 981
 			'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '',
982
-			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE ), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
982
+			'add_new_datetime_ticket_help_link' => EEH_Template::get_help_tab_link('add_new_ticket_via_datetime', $this->_adminpage_obj->page_slug, $this->_adminpage_obj->get_req_action(), FALSE, FALSE), //todo need to add this help info id to the Events_Admin_Page core file so we can access it here.
983 983
 			'DTT_ID' => $default ? '' : $dtt->ID()
984 984
 			);
985 985
 
986 986
 		//need to setup the list items (but only if this isnt' a default skeleton setup)
987
-		if ( !$default ) {
987
+		if ( ! $default) {
988 988
 			$tktrow = 1;
989
-			foreach ( $all_tickets as $ticket ) {
990
-				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default );
989
+			foreach ($all_tickets as $ticket) {
990
+				$template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default);
991 991
 				$tktrow++;
992 992
 			}
993 993
 		}
994 994
 
995 995
 		//filter template args at this point
996
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event );
996
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_dtt_attached_ticket_row__template_args', $template_args, $dttrow, $dtt, $datetime_tickets, $all_tickets, $default, $this->_is_creating_event);
997 997
 
998
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php';
999
-		return EEH_Template::display_template( $template, $template_args, TRUE );
998
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php';
999
+		return EEH_Template::display_template($template, $template_args, TRUE);
1000 1000
 	}
1001 1001
 
1002 1002
 
1003 1003
 
1004
-	protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) {
1005
-		$tktid = !empty( $ticket ) ? $ticket->ID() : 0;
1006
-		$dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array();
1004
+	protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) {
1005
+		$tktid = ! empty($ticket) ? $ticket->ID() : 0;
1006
+		$dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array();
1007 1007
 
1008
-		$displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0;
1008
+		$displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0;
1009 1009
 		$template_args = array(
1010 1010
 			'dtt_row' => $default ? 'DTTNUM' : $dttrow,
1011
-			'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow,
1011
+			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1012 1012
 			'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '',
1013 1013
 			'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '',
1014
-			'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'),
1015
-			'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(),
1014
+			'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'),
1015
+			'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(),
1016 1016
 			);
1017 1017
 
1018 1018
 		//filter template args
1019
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event );
1019
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_datetime_tickets_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default, $this->_is_creating_event);
1020 1020
 
1021
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php';
1022
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1021
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php';
1022
+		return EEH_Template::display_template($template, $template_args, TRUE);
1023 1023
 	}
1024 1024
 
1025 1025
 
@@ -1041,37 +1041,37 @@  discard block
 block discarded – undo
1041 1041
 	 *
1042 1042
 	 * @return [type] [description]
1043 1043
 	 */
1044
-	protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) {
1044
+	protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) {
1045 1045
 
1046 1046
 		//if $ticket is not an instance of EE_Ticket then force default to true.
1047
-		$default =  ! $ticket instanceof EE_Ticket ? true : false;
1047
+		$default = ! $ticket instanceof EE_Ticket ? true : false;
1048 1048
 
1049
-		$prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array();
1049
+		$prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array();
1050 1050
 
1051 1051
 		//if there is only one price (which would be the base price) or NO prices and this ticket is a default ticket, let's just make sure there are no cached default prices on
1052 1052
 		//the object.  This is done by not including any query_params.
1053
-		if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1  || empty( $prices ) ) ) {
1054
-			$prices = $ticket->get_many_related( 'Price' );
1053
+		if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) {
1054
+			$prices = $ticket->get_many_related('Price');
1055 1055
 		}
1056 1056
 
1057 1057
 		// check if we're dealing with a default ticket in which case we don't want any starting_ticket_datetime_row values set (otherwise there won't be any new relationships created for tickets based off of the default ticket).  This will future proof in case there is ever any behaviour change between what the primary_key defaults to.
1058
-		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE;
1058
+		$default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE;
1059 1059
 
1060
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1060
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1061 1061
 
1062 1062
 		$ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal();
1063
-		$base_price = $default ? NULL :  $ticket->base_price();
1063
+		$base_price = $default ? NULL : $ticket->base_price();
1064 1064
 		$count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE);
1065 1065
 
1066 1066
 		//breaking out complicated condition for ticket_status
1067
-		if ( $default ) {
1068
-			$ticket_status_class = ' tkt-status-' . EE_Ticket::onsale;
1067
+		if ($default) {
1068
+			$ticket_status_class = ' tkt-status-'.EE_Ticket::onsale;
1069 1069
 		} else {
1070
-			$ticket_status_class =  $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status();
1070
+			$ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status();
1071 1071
 		}
1072 1072
 
1073 1073
 		//breaking out complicated condition for TKT_taxable
1074
-		if ( $default ) {
1074
+		if ($default) {
1075 1075
 			$TKT_taxable = '';
1076 1076
 		} else {
1077 1077
 			$TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : '';
@@ -1086,19 +1086,19 @@  discard block
 block discarded – undo
1086 1086
 			'edit_tkt_expanded' => '',
1087 1087
 			'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets',
1088 1088
 			'TKT_name' => $default ? '' : $ticket->get('TKT_name'),
1089
-			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ),
1090
-			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time']  ),
1091
-			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status( EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1089
+			'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1090
+			'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']),
1091
+			'TKT_status' => $default ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->is_default() ? EEH_Template::pretty_status(EE_Ticket::onsale, FALSE, 'sentence') : $ticket->ticket_status(TRUE),
1092 1092
 			'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE),
1093 1093
 			'TKT_price_code' => EE_Registry::instance()->CFG->currency->code,
1094 1094
 			'TKT_price_amount' => $default ? 0 : $ticket_subtotal,
1095
-			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'),
1096
-			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'),
1097
-			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'),
1098
-			'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ),
1099
-			'TKT_max' => $default ? '' :  $ticket->get_pretty('TKT_max','input'),
1095
+			'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'),
1096
+			'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'),
1097
+			'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'),
1098
+			'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')),
1099
+			'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'),
1100 1100
 			'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'),
1101
-			'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ),
1101
+			'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))),
1102 1102
 			'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'),
1103 1103
 			'TKT_description' => $default ? '' : $ticket->get('TKT_description'),
1104 1104
 			'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'),
@@ -1107,99 +1107,99 @@  discard block
 block discarded – undo
1107 1107
 			'ticket_price_rows' => '',
1108 1108
 			'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'),
1109 1109
 			'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(),
1110
-			'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"',
1111
-			'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '',
1110
+			'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"',
1111
+			'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '',
1112 1112
 			'total_price_rows' => count($prices) > 1 ? count($prices) : 1,
1113 1113
 			'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '',
1114 1114
 			'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts),
1115 1115
 			'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts),
1116
-			'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ),
1116
+			'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)),
1117 1117
 			'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'),
1118 1118
 			'TKT_taxable' => $TKT_taxable,
1119 1119
 			'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"',
1120 1120
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1121
-			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ),
1121
+			'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE),
1122 1122
 			'TKT_subtotal_amount' => $ticket_subtotal,
1123
-			'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ),
1124
-			'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE,
1123
+			'tax_rows' => $this->_get_tax_rows($tktrow, $ticket),
1124
+			'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE,
1125 1125
 			'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '',
1126 1126
 			'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable',
1127 1127
 			'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable'
1128 1128
 			);
1129 1129
 
1130
-		$template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1130
+		$template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : '';
1131 1131
 
1132 1132
 		//handle rows that should NOT be empty
1133
-		if ( empty( $template_args['TKT_start_date'] ) ) {
1133
+		if (empty($template_args['TKT_start_date'])) {
1134 1134
 			//if empty then the start date will be now.
1135
-			$template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp'));
1136
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1135
+			$template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp'));
1136
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1137 1137
 		}
1138 1138
 
1139
-		if ( empty( $template_args['TKT_end_date'] ) ) {
1139
+		if (empty($template_args['TKT_end_date'])) {
1140 1140
 
1141 1141
 			//get the earliest datetime (if present);
1142
-			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC' ) ) ) : NULL;
1142
+			$earliest_dtt = $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? $this->_adminpage_obj->get_cpt_model_obj()->get_first_related('Datetime', array('order_by'=> array('DTT_EVT_start' => 'ASC'))) : NULL;
1143 1143
 
1144
-			if ( !empty( $earliest_dtt ) ) {
1145
-				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] );
1144
+			if ( ! empty($earliest_dtt)) {
1145
+				$template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']);
1146 1146
 			} else {
1147 1147
 				//default so let's just use what's been set for the default date-time which is 30 days from now.
1148
-				$template_args['TKT_end_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , mktime(24, 0, 0, date("m"), date("d") + 29, date("Y") )  );
1148
+				$template_args['TKT_end_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], mktime(24, 0, 0, date("m"), date("d") + 29, date("Y")));
1149 1149
 			}
1150
-			$template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale;
1150
+			$template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale;
1151 1151
 		}
1152 1152
 
1153 1153
 		//generate ticket_datetime items
1154
-		if ( ! $default ) {
1154
+		if ( ! $default) {
1155 1155
 			$dttrow = 1;
1156
-			foreach ( $all_dtts as $dtt ) {
1157
-				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default );
1156
+			foreach ($all_dtts as $dtt) {
1157
+				$template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default);
1158 1158
 				$dttrow++;
1159 1159
 			}
1160 1160
 		}
1161 1161
 
1162 1162
 		$prcrow = 1;
1163
-		foreach ( $prices as $price ) {
1164
-			if ( $price->is_base_price() ) {
1163
+		foreach ($prices as $price) {
1164
+			if ($price->is_base_price()) {
1165 1165
 				$prcrow++;
1166 1166
 				continue;
1167 1167
 			}
1168
-			$show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1  ? FALSE : TRUE;
1169
-			$show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE;
1170
-			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create );
1168
+			$show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE;
1169
+			$show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE;
1170
+			$template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create);
1171 1171
 			$prcrow++;
1172 1172
 		}
1173 1173
 
1174 1174
 		//filter $template_args
1175
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event );
1175
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_row__template_args', $template_args, $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default, $all_tickets, $this->_is_creating_event);
1176 1176
 
1177
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php';
1178
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1177
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php';
1178
+		return EEH_Template::display_template($template, $template_args, TRUE);
1179 1179
 	}
1180 1180
 
1181 1181
 
1182 1182
 
1183 1183
 
1184 1184
 
1185
-	protected function _get_tax_rows( $tktrow, $ticket ) {
1185
+	protected function _get_tax_rows($tktrow, $ticket) {
1186 1186
 		$tax_rows = '';
1187
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php';
1187
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php';
1188 1188
 		$template_args = array();
1189
-		$taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1190
-		foreach ( $taxes as $tax ) {
1191
-			$tax_added = $this->_get_tax_added( $tax, $ticket );
1189
+		$taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin();
1190
+		foreach ($taxes as $tax) {
1191
+			$tax_added = $this->_get_tax_added($tax, $ticket);
1192 1192
 			$template_args = array(
1193
-				'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1193
+				'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"',
1194 1194
 				'tax_id' => $tax->ID(),
1195 1195
 				'tkt_row' => $tktrow,
1196 1196
 				'tax_label' => $tax->get('PRC_name'),
1197 1197
 				'tax_added' => $tax_added,
1198
-				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ),
1198
+				'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE),
1199 1199
 				'tax_amount' => $tax->get('PRC_amount')
1200 1200
 				);
1201
-			$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event  );
1202
-			$tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE );
1201
+			$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event);
1202
+			$tax_rows .= EEH_Template::display_template($template, $template_args, TRUE);
1203 1203
 		}
1204 1204
 
1205 1205
 
@@ -1207,81 +1207,81 @@  discard block
 block discarded – undo
1207 1207
 	}
1208 1208
 
1209 1209
 
1210
-	protected function _get_tax_added( EE_Price $tax, $ticket ) {
1211
-		$subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal();
1210
+	protected function _get_tax_added(EE_Price $tax, $ticket) {
1211
+		$subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal();
1212 1212
 		return $subtotal * $tax->get('PRC_amount') / 100;
1213 1213
 	}
1214 1214
 
1215 1215
 
1216 1216
 
1217 1217
 
1218
-	protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) {
1219
-		$send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1218
+	protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) {
1219
+		$send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE;
1220 1220
 		$template_args = array(
1221 1221
 			'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow,
1222 1222
 			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1223 1223
 			'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices',
1224
-			'price_type_selector' => $default && empty( $price ) ? $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ) : $this->_get_price_type_selector( $tktrow, $prcrow, $price, $default, $send_disabled ),
1224
+			'price_type_selector' => $default && empty($price) ? $this->_get_base_price_template($tktrow, $prcrow, $price, $default) : $this->_get_price_type_selector($tktrow, $prcrow, $price, $default, $send_disabled),
1225 1225
 			'PRC_ID' => $default && empty($price) ? 0 : $price->ID(),
1226 1226
 			'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'),
1227 1227
 			'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'),
1228 1228
 			'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign,
1229 1229
 			'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"',
1230
-			'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1231
-			'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1232
-			'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ),
1233
-			'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1234
-			'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ),
1230
+			'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''),
1231
+			'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'),
1232
+			'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''),
1233
+			'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'),
1234
+			'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'),
1235 1235
 			'show_trash_icon' => $show_trash ? '' : ' style="display:none;"',
1236 1236
 			'show_create_button' => $show_create ? '' : ' style="display:none;"',
1237
-			'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'),
1238
-			'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1237
+			'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'),
1238
+			'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE
1239 1239
 			);
1240 1240
 
1241
-	$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event );
1241
+	$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_price_row__template_args', $template_args, $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create, $this->_is_creating_event);
1242 1242
 
1243
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php';
1244
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1243
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php';
1244
+		return EEH_Template::display_template($template, $template_args, TRUE);
1245 1245
 	}
1246 1246
 
1247 1247
 
1248
-	protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1249
-		if ( $price->is_base_price() ) {
1250
-			return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default );
1248
+	protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1249
+		if ($price->is_base_price()) {
1250
+			return $this->_get_base_price_template($tktrow, $prcrow, $price, $default);
1251 1251
 		} else {
1252
-			return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled );
1252
+			return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled);
1253 1253
 		}
1254 1254
 
1255 1255
 	}
1256 1256
 
1257 1257
 
1258
-	protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) {
1258
+	protected function _get_base_price_template($tktrow, $prcrow, $price, $default) {
1259 1259
 		$template_args = array(
1260 1260
 				'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1261
-				'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1262
-				'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'),
1261
+				'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1262
+				'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'),
1263 1263
 				'PRT_name' => __('Price', 'event_espresso'),
1264 1264
 				'price_selected_operator' => '+',
1265 1265
 				'price_selected_is_percent' => 0
1266 1266
 			);
1267
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php';
1267
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php';
1268 1268
 
1269
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event );
1269
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_base_price_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $this->_is_creating_event);
1270 1270
 
1271
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1271
+		return EEH_Template::display_template($template, $template_args, TRUE);
1272 1272
 	}
1273 1273
 
1274 1274
 
1275 1275
 
1276
-	protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) {
1277
-		$select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]';
1278
-		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) );
1279
-		$price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php';
1280
-		$all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array();
1281
-		$selected_price_type_id = $default && empty( $price ) ? 0 : $price->type();
1276
+	protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) {
1277
+		$select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]';
1278
+		$price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3'))));
1279
+		$price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php';
1280
+		$all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array();
1281
+		$selected_price_type_id = $default && empty($price) ? 0 : $price->type();
1282 1282
 		$price_option_spans = '';
1283 1283
 		//setup pricetypes for selector
1284
-		foreach ( $price_types as $price_type ) {
1284
+		foreach ($price_types as $price_type) {
1285 1285
 			$all_price_types[] = array(
1286 1286
 				'id' => $price_type->ID(),
1287 1287
 				'text' => $price_type->get('PRT_name'),
@@ -1293,50 +1293,50 @@  discard block
 block discarded – undo
1293 1293
 				'PRT_operator' => $price_type->is_discount() ? '-' : '+',
1294 1294
 				'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0
1295 1295
 				);
1296
-			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE );
1296
+			$price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE);
1297 1297
 		}
1298 1298
 
1299
-		$select_params = $disabled ? 'style="width:auto;" disabled'  : 'style="width:auto;"';
1299
+		$select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"';
1300 1300
 		$main_name = $select_name;
1301
-		$select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name;
1301
+		$select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name;
1302 1302
 
1303 1303
 		$template_args = array(
1304 1304
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1305
-			'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow,
1306
-			'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ),
1305
+			'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow,
1306
+			'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'),
1307 1307
 			'main_name' => $main_name,
1308 1308
 			'selected_price_type_id' => $selected_price_type_id,
1309 1309
 			'price_option_spans' => $price_option_spans,
1310
-			'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ),
1311
-			'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ),
1310
+			'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'),
1311
+			'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0),
1312 1312
 			'disabled' => $disabled
1313 1313
 			);
1314 1314
 
1315
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event );
1315
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_price_modifier_template__template_args', $template_args, $tktrow, $prcrow, $price, $default, $disabled, $this->_is_creating_event);
1316 1316
 
1317
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php';
1317
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php';
1318 1318
 
1319
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1319
+		return EEH_Template::display_template($template, $template_args, TRUE);
1320 1320
 	}
1321 1321
 
1322 1322
 
1323 1323
 
1324
-	protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) {
1325
-		$dttid = !empty($dtt) ? $dtt->ID() : 0;
1326
-		$displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0;
1327
-		$tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array();
1324
+	protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) {
1325
+		$dttid = ! empty($dtt) ? $dtt->ID() : 0;
1326
+		$displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0;
1327
+		$tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array();
1328 1328
 		$template_args = array(
1329
-			'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow,
1329
+			'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow,
1330 1330
 			'tkt_row' => $default ? 'TICKETNUM' : $tktrow,
1331
-			'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '',
1332
-			'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '',
1333
-			'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ),
1331
+			'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '',
1332
+			'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '',
1333
+			'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE),
1334 1334
 			'tkt_status_class' => '',
1335 1335
 			);
1336 1336
 
1337
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event );
1338
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1339
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1337
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_datetime_list_item__template_args', $template_args, $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default, $this->_is_creating_event);
1338
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php';
1339
+		return EEH_Template::display_template($template, $template_args, TRUE);
1340 1340
 	}
1341 1341
 
1342 1342
 
@@ -1344,53 +1344,53 @@  discard block
 block discarded – undo
1344 1344
 	protected function _get_ticket_js_structure($all_dtts, $all_tickets) {
1345 1345
 		$template_args = array(
1346 1346
 			'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts),
1347
-			'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE),
1348
-			'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ),
1347
+			'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE),
1348
+			'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL),
1349 1349
 			'default_price_rows' => '',
1350 1350
 			'default_base_price_amount' => 0,
1351 1351
 			'default_base_price_name' => '',
1352 1352
 			'default_base_price_description' => '',
1353
-			'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ),
1354
-			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ),
1353
+			'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE),
1354
+			'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE),
1355 1355
 			'existing_available_datetime_tickets_list' => '',
1356 1356
 			'existing_available_ticket_datetimes_list' => '',
1357
-			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ),
1358
-			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE )
1357
+			'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE),
1358
+			'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE)
1359 1359
 			);
1360 1360
 
1361 1361
 		$tktrow = 1;
1362
-		foreach ( $all_tickets as $ticket ) {
1363
-			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE );
1362
+		foreach ($all_tickets as $ticket) {
1363
+			$template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE);
1364 1364
 			$tktrow++;
1365 1365
 		}
1366 1366
 
1367 1367
 
1368 1368
 		$dttrow = 1;
1369
-		foreach ( $all_dtts as $dtt ) {
1370
-			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE );
1369
+		foreach ($all_dtts as $dtt) {
1370
+			$template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE);
1371 1371
 			$dttrow++;
1372 1372
 		}
1373 1373
 
1374 1374
 		$default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices();
1375 1375
 		$prcrow = 1;
1376
-		foreach ( $default_prices as $price ) {
1377
-			if ( $price->is_base_price() ) {
1376
+		foreach ($default_prices as $price) {
1377
+			if ($price->is_base_price()) {
1378 1378
 				$template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float');
1379 1379
 				$template_args['default_base_price_name'] = $price->get('PRC_name');
1380 1380
 				$template_args['default_base_price_description'] = $price->get('PRC_desc');
1381 1381
 				$prcrow++;
1382 1382
 				continue;
1383 1383
 			}
1384
-			$show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1  ? FALSE : TRUE;
1385
-			$show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE;
1386
-			$template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create );
1384
+			$show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE;
1385
+			$show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE;
1386
+			$template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create);
1387 1387
 			$prcrow++;
1388 1388
 		}
1389 1389
 
1390
-		$template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event );
1390
+		$template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_ticket_js_structure__template_args', $template_args, $all_dtts, $all_tickets, $this->_is_creating_event);
1391 1391
 
1392
-		$template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php';
1393
-		return EEH_Template::display_template( $template, $template_args, TRUE );
1392
+		$template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php';
1393
+		return EEH_Template::display_template($template, $template_args, TRUE);
1394 1394
 	}
1395 1395
 
1396 1396
 
Please login to merge, or discard this patch.
caffeinated/modules/recaptcha/EED_Recaptcha.module.php 1 patch
Spacing   +130 added lines, -131 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 	 * @return EED_Recaptcha
44 44
 	 */
45 45
 	public static function instance() {
46
-		return parent::get_instance( __CLASS__ );
46
+		return parent::get_instance(__CLASS__);
47 47
 	}
48 48
 
49 49
 
@@ -59,32 +59,32 @@  discard block
 block discarded – undo
59 59
 		if (
60 60
 			EE_Registry::instance()->CFG->registration->use_captcha
61 61
 			&& ! (
62
-				EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options'
63
-				&& (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true
62
+				EE_Registry::instance()->REQ->get('step', '') === 'payment_options'
63
+				&& (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true
64 64
 			)
65 65
 		) {
66 66
 			EED_Recaptcha::set_definitions();
67 67
 			EED_Recaptcha::enqueue_styles_and_scripts();
68
-			add_action( 'wp', array( 'EED_Recaptcha', 'set_late_hooks' ), 1, 0 );
68
+			add_action('wp', array('EED_Recaptcha', 'set_late_hooks'), 1, 0);
69 69
 			add_action(
70 70
 				'AHEE__before_spco_whats_next_buttons',
71
-				array( 'EED_Recaptcha', 'display_recaptcha' ), 10, 0
71
+				array('EED_Recaptcha', 'display_recaptcha'), 10, 0
72 72
 			);
73 73
 			add_filter(
74 74
 				'FHEE__EED_Single_Page_Checkout__init___continue_reg',
75
-				array( 'EED_Recaptcha', 'not_a_robot' ), 10
75
+				array('EED_Recaptcha', 'not_a_robot'), 10
76 76
 			);
77 77
 			add_filter(
78 78
 				'FHEE__EE_SPCO_Reg_Step__set_completed___completed',
79
-				array( 'EED_Recaptcha', 'not_a_robot' ), 10
79
+				array('EED_Recaptcha', 'not_a_robot'), 10
80 80
 			);
81 81
 			add_filter(
82 82
 				'FHEE__EE_SPCO_JSON_Response___toString__JSON_response',
83
-				array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1
83
+				array('EED_Recaptcha', 'recaptcha_response'), 10, 1
84 84
 			);
85 85
 			add_filter(
86 86
 				'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array',
87
-				array( 'EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method' ), 10, 1
87
+				array('EED_Recaptcha', 'bypass_recaptcha_for_spco_load_payment_method'), 10, 1
88 88
 			);
89 89
 		}
90 90
 	}
@@ -103,18 +103,18 @@  discard block
 block discarded – undo
103 103
 		if (
104 104
 			EE_Registry::instance()->CFG->registration->use_captcha
105 105
 			&& ! (
106
-				EE_Registry::instance()->REQ->get( 'step', '' ) === 'payment_options'
107
-				&& (boolean) EE_Registry::instance()->REQ->get( 'revisit', false ) === true
106
+				EE_Registry::instance()->REQ->get('step', '') === 'payment_options'
107
+				&& (boolean) EE_Registry::instance()->REQ->get('revisit', false) === true
108 108
 			)
109 109
 		) {
110 110
 			EED_Recaptcha::enqueue_styles_and_scripts();
111
-			add_filter( 'FHEE__EED_Single_Page_Checkout__init___continue_reg', array( 'EED_Recaptcha', 'not_a_robot' ), 10 );
112
-			add_filter( 'FHEE__EE_SPCO_Reg_Step__set_completed___completed', array( 'EED_Recaptcha', 'not_a_robot' ), 10 );
113
-			add_filter( 'FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array( 'EED_Recaptcha', 'recaptcha_response' ), 10, 1 );
111
+			add_filter('FHEE__EED_Single_Page_Checkout__init___continue_reg', array('EED_Recaptcha', 'not_a_robot'), 10);
112
+			add_filter('FHEE__EE_SPCO_Reg_Step__set_completed___completed', array('EED_Recaptcha', 'not_a_robot'), 10);
113
+			add_filter('FHEE__EE_SPCO_JSON_Response___toString__JSON_response', array('EED_Recaptcha', 'recaptcha_response'), 10, 1);
114 114
 		}
115 115
 		// admin settings
116
-		add_action( 'AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array( 'EED_Recaptcha', 'admin_settings' ), 10, 1 );
117
-		add_filter( 'FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array( 'EED_Recaptcha', 'update_admin_settings' ), 10, 1 );
116
+		add_action('AHEE__Extend_Registration_Form_Admin_Page___reg_form_settings_template', array('EED_Recaptcha', 'admin_settings'), 10, 1);
117
+		add_filter('FHEE__Extend_Registration_Form_Admin_Page___update_reg_form_settings__CFG_registration', array('EED_Recaptcha', 'update_admin_settings'), 10, 1);
118 118
 	}
119 119
 
120 120
 
@@ -126,11 +126,11 @@  discard block
 block discarded – undo
126 126
 	 *  @return 	void
127 127
 	 */
128 128
 	public static function set_definitions() {
129
-		if ( is_user_logged_in() ) {
129
+		if (is_user_logged_in()) {
130 130
 			EED_Recaptcha::$_not_a_robot = true;
131 131
 		}
132
-		define( 'RECAPTCHA_BASE_PATH', rtrim( str_replace( array( '\\', '/' ), DS, plugin_dir_path( __FILE__ )), DS ) . DS );
133
-		define( 'RECAPTCHA_BASE_URL', plugin_dir_url( __FILE__ ));
132
+		define('RECAPTCHA_BASE_PATH', rtrim(str_replace(array('\\', '/'), DS, plugin_dir_path(__FILE__)), DS).DS);
133
+		define('RECAPTCHA_BASE_URL', plugin_dir_url(__FILE__));
134 134
 	}
135 135
 
136 136
 
@@ -144,7 +144,7 @@  discard block
 block discarded – undo
144 144
 	public static function set_late_hooks() {
145 145
 		add_filter(
146 146
 			'FHEE__Single_Page_Checkout__translate_js_strings__ajax_submit',
147
-			array( 'EED_Recaptcha', 'not_a_robot' )
147
+			array('EED_Recaptcha', 'not_a_robot')
148 148
 		);
149 149
 	}
150 150
 
@@ -157,11 +157,11 @@  discard block
 block discarded – undo
157 157
 	 *  @return 	void
158 158
 	 */
159 159
 	public static function enqueue_styles_and_scripts() {
160
-		wp_register_script( 'espresso_recaptcha', RECAPTCHA_BASE_URL . 'scripts' . DS . 'espresso_recaptcha.js', array( 'single_page_checkout' ), EVENT_ESPRESSO_VERSION, TRUE );
161
-		wp_register_script( 'google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl=' . EE_Registry::instance()->CFG->registration->recaptcha_language, array( 'espresso_recaptcha' ), EVENT_ESPRESSO_VERSION, TRUE );
162
-		EE_Registry::$i18n_js_strings['no_SPCO_error'] = __( 'It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso' );
163
-		EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __( 'There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso' );
164
-		EE_Registry::$i18n_js_strings['recaptcha_fail'] = __( 'Please complete the anti-spam test before proceeding.', 'event_espresso' );
160
+		wp_register_script('espresso_recaptcha', RECAPTCHA_BASE_URL.'scripts'.DS.'espresso_recaptcha.js', array('single_page_checkout'), EVENT_ESPRESSO_VERSION, TRUE);
161
+		wp_register_script('google_recaptcha', 'https://www.google.com/recaptcha/api.js?hl='.EE_Registry::instance()->CFG->registration->recaptcha_language, array('espresso_recaptcha'), EVENT_ESPRESSO_VERSION, TRUE);
162
+		EE_Registry::$i18n_js_strings['no_SPCO_error'] = __('It appears the Single Page Checkout javascript was not loaded properly! Please refresh the page and try again or contact support.', 'event_espresso');
163
+		EE_Registry::$i18n_js_strings['no_recaptcha_error'] = __('There appears to be a problem with the reCAPTCHA configuration! Please check the admin settings or contact support.', 'event_espresso');
164
+		EE_Registry::$i18n_js_strings['recaptcha_fail'] = __('Please complete the anti-spam test before proceeding.', 'event_espresso');
165 165
 	}
166 166
 
167 167
 
@@ -172,7 +172,7 @@  discard block
 block discarded – undo
172 172
 	 * @access    public
173 173
 	 * @param \WP $WP
174 174
 	 */
175
-	public function run( $WP ) {
175
+	public function run($WP) {
176 176
 	}
177 177
 
178 178
 
@@ -182,8 +182,7 @@  discard block
 block discarded – undo
182 182
 	 *  @return boolean
183 183
 	 */
184 184
 	public static function not_a_robot() {
185
-		$not_a_robot = is_bool( EED_Recaptcha::$_not_a_robot ) ? EED_Recaptcha::$_not_a_robot :
186
-			EED_Recaptcha::recaptcha_passed();
185
+		$not_a_robot = is_bool(EED_Recaptcha::$_not_a_robot) ? EED_Recaptcha::$_not_a_robot : EED_Recaptcha::recaptcha_passed();
187 186
 		return $not_a_robot;
188 187
 	}
189 188
 
@@ -199,22 +198,22 @@  discard block
 block discarded – undo
199 198
 	 */
200 199
 	public static function display_recaptcha() {
201 200
 		// logged in means you have already passed a turing test of sorts
202
-		if ( is_user_logged_in() ) {
201
+		if (is_user_logged_in()) {
203 202
 			return;
204 203
 		}
205 204
 		// don't display if not using recaptcha or user is logged in
206
-		if ( EE_Registry::instance()->CFG->registration->use_captcha ) {
205
+		if (EE_Registry::instance()->CFG->registration->use_captcha) {
207 206
 			// only display if they have NOT passed the test yet
208
-			if ( ! EED_Recaptcha::$_not_a_robot ) {
207
+			if ( ! EED_Recaptcha::$_not_a_robot) {
209 208
 				EEH_Template::display_template(
210
-					RECAPTCHA_BASE_PATH . DS . 'templates' . DS . 'recaptcha.template.php',
209
+					RECAPTCHA_BASE_PATH.DS.'templates'.DS.'recaptcha.template.php',
211 210
 					array(
212 211
 						'recaptcha_publickey' 	=> EE_Registry::instance()->CFG->registration->recaptcha_publickey,
213 212
 						'recaptcha_theme' 		=> EE_Registry::instance()->CFG->registration->recaptcha_theme,
214 213
 						'recaptcha_type' 			=> EE_Registry::instance()->CFG->registration->recaptcha_type
215 214
 					)
216 215
 				);
217
-				wp_enqueue_script( 'google_recaptcha' );
216
+				wp_enqueue_script('google_recaptcha');
218 217
 			}
219 218
 		}
220 219
 	}
@@ -245,17 +244,17 @@  discard block
 block discarded – undo
245 244
 	 */
246 245
 	public static function recaptcha_passed() {
247 246
 		// logged in means you have already passed a turing test of sorts
248
-		if ( is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha() ) {
247
+		if (is_user_logged_in() || EED_Recaptcha::_bypass_recaptcha()) {
249 248
 			return TRUE;
250 249
 		}
251 250
 		// was test already passed?
252
-		$recaptcha_passed = EE_Registry::instance()->SSN->get_session_data( 'recaptcha_passed' );
253
-		$recaptcha_passed = filter_var( $recaptcha_passed, FILTER_VALIDATE_BOOLEAN );
251
+		$recaptcha_passed = EE_Registry::instance()->SSN->get_session_data('recaptcha_passed');
252
+		$recaptcha_passed = filter_var($recaptcha_passed, FILTER_VALIDATE_BOOLEAN);
254 253
 		// verify recaptcha
255 254
 		EED_Recaptcha::_get_recaptcha_response();
256
-		if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response ) {
255
+		if ( ! $recaptcha_passed && EED_Recaptcha::$_recaptcha_response) {
257 256
 			$recaptcha_passed = EED_Recaptcha::_process_recaptcha_response();
258
-			EE_Registry::instance()->SSN->set_session_data( array( 'recaptcha_passed' => $recaptcha_passed ));
257
+			EE_Registry::instance()->SSN->set_session_data(array('recaptcha_passed' => $recaptcha_passed));
259 258
 			EE_Registry::instance()->SSN->update();
260 259
 		}
261 260
 		EED_Recaptcha::$_not_a_robot = $recaptcha_passed;
@@ -271,8 +270,8 @@  discard block
 block discarded – undo
271 270
 	 * @param array $recaptcha_response
272 271
 	 * @return boolean
273 272
 	 */
274
-	public static function recaptcha_response( $recaptcha_response = array() ) {
275
-		if ( EED_Recaptcha::_bypass_recaptcha() ) {
273
+	public static function recaptcha_response($recaptcha_response = array()) {
274
+		if (EED_Recaptcha::_bypass_recaptcha()) {
276 275
 			$recaptcha_response['bypass_recaptcha'] = TRUE;
277 276
 			$recaptcha_response['recaptcha_passed'] = TRUE;
278 277
 		} else {
@@ -292,16 +291,16 @@  discard block
 block discarded – undo
292 291
 	 */
293 292
 	private static function _bypass_recaptcha() {
294 293
 		// an array of key value pairs that must match exactly with the incoming request, in order to bypass recaptcha for the current request ONLY
295
-		$bypass_request_params_array = apply_filters( 'FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array() );
294
+		$bypass_request_params_array = apply_filters('FHEE__EED_Recaptcha___bypass_recaptcha__bypass_request_params_array', array());
296 295
 		// does $bypass_request_params_array have any values ?
297
-		if ( empty( $bypass_request_params_array )) {
296
+		if (empty($bypass_request_params_array)) {
298 297
 			return FALSE;
299 298
 		}
300 299
 		// initially set bypass to TRUE
301 300
 		$bypass_recaptcha = TRUE;
302
-		foreach ( $bypass_request_params_array as $key => $value ) {
301
+		foreach ($bypass_request_params_array as $key => $value) {
303 302
 			// if $key is not found or value doesn't match exactly, then toggle bypass to FALSE, otherwise carry over it's value. This way, one missed setting results in no bypass
304
-			$bypass_recaptcha = isset( $_REQUEST[ $key ] ) && $_REQUEST[ $key ] === $value ? $bypass_recaptcha : FALSE;
303
+			$bypass_recaptcha = isset($_REQUEST[$key]) && $_REQUEST[$key] === $value ? $bypass_recaptcha : FALSE;
305 304
 		}
306 305
 		return $bypass_recaptcha;
307 306
 	}
@@ -316,7 +315,7 @@  discard block
 block discarded – undo
316 315
 	 * 	@return 	boolean
317 316
 	 */
318 317
 	private static function _get_recaptcha_response() {
319
-		EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get( 'g-recaptcha-response', false );
318
+		EED_Recaptcha::$_recaptcha_response = EE_Registry::instance()->REQ->get('g-recaptcha-response', false);
320 319
 	}
321 320
 
322 321
 
@@ -330,26 +329,26 @@  discard block
 block discarded – undo
330 329
 	 */
331 330
 	private static function _process_recaptcha_response() {
332 331
 		// verify library is loaded
333
-		if ( ! class_exists( '\\ReCaptcha\\ReCaptcha' )) {
334
-			require_once( RECAPTCHA_BASE_PATH . DS . 'autoload.php' );
332
+		if ( ! class_exists('\\ReCaptcha\\ReCaptcha')) {
333
+			require_once(RECAPTCHA_BASE_PATH.DS.'autoload.php');
335 334
 		}
336 335
 		// The response from reCAPTCHA
337 336
 		EED_Recaptcha::_get_recaptcha_response();
338 337
 		$recaptcha_response = EED_Recaptcha::$_recaptcha_response;
339 338
 		// Was there a reCAPTCHA response?
340
-		if ( $recaptcha_response ) {
339
+		if ($recaptcha_response) {
341 340
 			// if allow_url_fopen is Off, then set a different request method
342
-			$request_method = ! ini_get( 'allow_url_fopen' ) ? new \ReCaptcha\RequestMethod\SocketPost() : null;
341
+			$request_method = ! ini_get('allow_url_fopen') ? new \ReCaptcha\RequestMethod\SocketPost() : null;
343 342
 			$recaptcha = new \ReCaptcha\ReCaptcha(
344 343
 				EE_Registry::instance()->CFG->registration->recaptcha_privatekey,
345 344
 				$request_method
346 345
 			);
347 346
 			$recaptcha_response = $recaptcha->verify(
348 347
 				EED_Recaptcha::$_recaptcha_response,
349
-				$_SERVER[ 'REMOTE_ADDR' ]
348
+				$_SERVER['REMOTE_ADDR']
350 349
 			);
351 350
 		}
352
-		if ( $recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess() ) {
351
+		if ($recaptcha_response instanceof \ReCaptcha\Response && $recaptcha_response->isSuccess()) {
353 352
 			return TRUE;
354 353
 		}
355 354
 		// sorry... it appears you can't don't know what soup or hamburgers are !!!
@@ -393,12 +392,12 @@  discard block
 block discarded – undo
393 392
 				'subsections' 			=> apply_filters(
394 393
 					'FHEE__EED_Recaptcha___recaptcha_settings_form__form_subsections',
395 394
 					array(
396
-						'main_settings_hdr' 				=> new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Anti-spam Settings', 'event_espresso' ) . EEH_Template::get_help_tab_link( 'recaptcha_info' ))),
395
+						'main_settings_hdr' 				=> new EE_Form_Section_HTML(EEH_HTML::h2(__('reCAPTCHA Anti-spam Settings', 'event_espresso').EEH_Template::get_help_tab_link('recaptcha_info'))),
397 396
 						'main_settings' 						=> EED_Recaptcha::_recaptcha_main_settings(),
398
-						'appearance_settings_hdr' 	=> new EE_Form_Section_HTML( EEH_HTML::h2( __( 'reCAPTCHA Appearance', 'event_espresso' ) )),
397
+						'appearance_settings_hdr' 	=> new EE_Form_Section_HTML(EEH_HTML::h2(__('reCAPTCHA Appearance', 'event_espresso'))),
399 398
 						'appearance_settings' 			=> EED_Recaptcha::_recaptcha_appearance_settings(),
400 399
 						// 'recaptcha_example' 				=> new EE_Form_Section_HTML( EED_Recaptcha::display_recaptcha() ),
401
-						'required_fields_note' 			=> new EE_Form_Section_HTML( EEH_HTML::p( __( 'All fields marked with a * are required fields', 'event_espresso' ), '', 'grey-text' ))
400
+						'required_fields_note' 			=> new EE_Form_Section_HTML(EEH_HTML::p(__('All fields marked with a * are required fields', 'event_espresso'), '', 'grey-text'))
402 401
 					)
403 402
 				)
404 403
 			)
@@ -425,28 +424,28 @@  discard block
 block discarded – undo
425 424
 					array(
426 425
 						'use_captcha' 				=> new EE_Yes_No_Input(
427 426
 							array(
428
-								'html_label_text'	 	=> __( 'Use reCAPTCHA', 'event_espresso' ),
427
+								'html_label_text'	 	=> __('Use reCAPTCHA', 'event_espresso'),
429 428
 								'html_help_text' 		=> sprintf(
430
-									__( 'reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso' ),
429
+									__('reCAPTCHA is a free service that  protects your website from spam and abuse. It employs advanced risk analysis technology to separate humans from abusive actors. Sign up %1$shere%2$s to receive your Public and Private keys.', 'event_espresso'),
431 430
 									'<a href="https://www.google.com/recaptcha/intro/index.html">',
432 431
 									'</a>'
433 432
 								),
434
-								'default' 								=> isset( EE_Registry::instance()->CFG->registration->use_captcha ) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE,
433
+								'default' 								=> isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE,
435 434
 								'display_html_label_text' 	=> FALSE
436 435
 							)
437 436
 						),
438 437
 						'recaptcha_publickey' 		=> new EE_Text_Input(
439 438
 							array(
440
-								'html_label_text'	 	=> __( 'Site Key', 'event_espresso' ),
441
-								'html_help_text' 		=> __( 'The site key is used to display the widget on your site.', 'event_espresso' ),
442
-								'default' 					=> isset( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_publickey ) : ''
439
+								'html_label_text'	 	=> __('Site Key', 'event_espresso'),
440
+								'html_help_text' 		=> __('The site key is used to display the widget on your site.', 'event_espresso'),
441
+								'default' 					=> isset(EE_Registry::instance()->CFG->registration->recaptcha_publickey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_publickey) : ''
443 442
 							)
444 443
 						),
445 444
 						'recaptcha_privatekey' 		=> new EE_Text_Input(
446 445
 							array(
447
-								'html_label_text'	 	=> __( 'Secret Key', 'event_espresso' ),
448
-								'html_help_text' 		=> __( 'The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso' ),
449
-								'default' 					=> isset( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) ? stripslashes( EE_Registry::instance()->CFG->registration->recaptcha_privatekey ) : ''
446
+								'html_label_text'	 	=> __('Secret Key', 'event_espresso'),
447
+								'html_help_text' 		=> __('The secret key authorizes communication between your application backend and the reCAPTCHA server to verify the user\'s response. The secret key needs to be kept safe for security purposes.', 'event_espresso'),
448
+								'default' 					=> isset(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) ? stripslashes(EE_Registry::instance()->CFG->registration->recaptcha_privatekey) : ''
450 449
 							)
451 450
 						)
452 451
 					)
@@ -478,81 +477,81 @@  discard block
 block discarded – undo
478 477
 					array(
479 478
 						'recaptcha_theme' 		=> new EE_Radio_Button_Input(
480 479
 							array(
481
-								'light' => __( 'Light', 'event_espresso' ),
482
-								'dark' => __( 'Dark', 'event_espresso' )
480
+								'light' => __('Light', 'event_espresso'),
481
+								'dark' => __('Dark', 'event_espresso')
483 482
 							),
484 483
 							array(
485
-								'html_label_text'	 	=> __( 'Theme', 'event_espresso' ),
486
-								'html_help_text' 		=> __( 'The color theme of the widget.', 'event_espresso' ),
487
-								'default' 					=> isset( EE_Registry::instance()->CFG->registration->recaptcha_theme ) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light',
484
+								'html_label_text'	 	=> __('Theme', 'event_espresso'),
485
+								'html_help_text' 		=> __('The color theme of the widget.', 'event_espresso'),
486
+								'default' 					=> isset(EE_Registry::instance()->CFG->registration->recaptcha_theme) ? EE_Registry::instance()->CFG->registration->recaptcha_theme : 'light',
488 487
 								'display_html_label_text' => FALSE
489 488
 							)
490 489
 						),
491 490
 						'recaptcha_type' 		=> new EE_Radio_Button_Input(
492 491
 							array(
493
-								'image' => __( 'Image', 'event_espresso' ),
494
-								'audio' => __( 'Audio', 'event_espresso' )
492
+								'image' => __('Image', 'event_espresso'),
493
+								'audio' => __('Audio', 'event_espresso')
495 494
 							),
496 495
 							array(
497
-								'html_label_text'	 	=> __( 'Type', 'event_espresso' ),
498
-								'html_help_text' 		=> __( 'The type of CAPTCHA to serve.', 'event_espresso' ),
499
-								'default' 					=> isset( EE_Registry::instance()->CFG->registration->recaptcha_type ) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image',
496
+								'html_label_text'	 	=> __('Type', 'event_espresso'),
497
+								'html_help_text' 		=> __('The type of CAPTCHA to serve.', 'event_espresso'),
498
+								'default' 					=> isset(EE_Registry::instance()->CFG->registration->recaptcha_type) ? EE_Registry::instance()->CFG->registration->recaptcha_type : 'image',
500 499
 								'display_html_label_text' =>FALSE
501 500
 							)
502 501
 						),
503 502
 						'recaptcha_language' 		=> new EE_Select_Input(
504 503
 							array(
505
-								 'ar' 			=> __( 'Arabic', 'event_espresso' ),
506
-								 'bg' 		=> __( 'Bulgarian', 'event_espresso' ),
507
-								 'ca' 			=> __( 'Catalan', 'event_espresso' ),
508
-								 'zh-CN' 	=>  __( 'Chinese (Simplified)', 'event_espresso' ),
509
-								 'zh-TW' 	=>  __( 'Chinese (Traditional)	', 'event_espresso' ),
510
-								 'hr' 			=> __( 'Croatian', 'event_espresso' ),
511
-								 'cs' 			=> __( 'Czech', 'event_espresso' ),
512
-								 'da' 			=> __( 'Danish', 'event_espresso' ),
513
-								 'nl' 			=> __( 'Dutch', 'event_espresso' ),
514
-								 'en-GB' 	=>  __( 'English (UK)', 'event_espresso' ),
515
-								 'en' 			=> __( 'English (US)', 'event_espresso' ),
516
-								 'fil' 			=> __( 'Filipino', 'event_espresso' ),
517
-								 'fi' 			=> __( 'Finnish', 'event_espresso' ),
518
-								 'fr' 			=> __( 'French', 'event_espresso' ),
519
-								 'fr-CA' 	=>  __( 'French (Canadian)', 'event_espresso' ),
520
-								 'de' 			=> __( 'German', 'event_espresso' ),
521
-								 'de-AT' 	=>  __( 'German (Austria)', 'event_espresso' ),
522
-								 'de-CH' 	=>  __( 'German (Switzerland)', 'event_espresso' ),
523
-								 'el' 			=> __( 'Greek', 'event_espresso' ),
524
-								 'iw' 			=> __( 'Hebrew', 'event_espresso' ),
525
-								 'hi' 			=> __( 'Hindi', 'event_espresso' ),
526
-								 'hu' 		=> __( 'Hungarian', 'event_espresso' ),
527
-								 'id' 			=> __( 'Indonesian', 'event_espresso' ),
528
-								 'it' 			=> __( 'Italian', 'event_espresso' ),
529
-								 'ja' 			=> __( 'Japanese', 'event_espresso' ),
530
-								 'ko' 			=> __( 'Korean', 'event_espresso' ),
531
-								 'lv' 			=> __( 'Latvian', 'event_espresso' ),
532
-								 'lt' 			=> __( 'Lithuanian', 'event_espresso' ),
533
-								 'no' 		=> __( 'Norwegian', 'event_espresso' ),
534
-								 'fa' 			=> __( 'Persian', 'event_espresso' ),
535
-								 'pl' 			=> __( 'Polish', 'event_espresso' ),
536
-								 'pt' 			=> __( 'Portuguese', 'event_espresso' ),
537
-								 'pt-BR' 	=>  __( 'Portuguese (Brazil)', 'event_espresso' ),
538
-								 'pt-PT' 	=>  __( 'Portuguese (Portugal)', 'event_espresso' ),
539
-								 'ro' 			=> __( 'Romanian', 'event_espresso' ),
540
-								 'ru' 			=> __( 'Russian', 'event_espresso' ),
541
-								 'sr' 			=> __( 'Serbian', 'event_espresso' ),
542
-								 'sk' 			=> __( 'Slovak', 'event_espresso' ),
543
-								 'sl' 			=> __( 'Slovenian', 'event_espresso' ),
544
-								 'es' 			=> __( 'Spanish', 'event_espresso' ),
545
-								 'es-419' 	=>  __( 'Spanish (Latin America)', 'event_espresso' ),
546
-								 'sv' 			=> __( 'Swedish', 'event_espresso' ),
547
-								 'th' 			=> __( 'Thai', 'event_espresso' ),
548
-								 'tr' 			=> __( 'Turkish', 'event_espresso' ),
549
-								 'uk' 			=> __( 'Ukrainian', 'event_espresso' ),
550
-								 'vi' 			=> __( 'Vietnamese', 'event_espresso')
504
+								 'ar' 			=> __('Arabic', 'event_espresso'),
505
+								 'bg' 		=> __('Bulgarian', 'event_espresso'),
506
+								 'ca' 			=> __('Catalan', 'event_espresso'),
507
+								 'zh-CN' 	=>  __('Chinese (Simplified)', 'event_espresso'),
508
+								 'zh-TW' 	=>  __('Chinese (Traditional)	', 'event_espresso'),
509
+								 'hr' 			=> __('Croatian', 'event_espresso'),
510
+								 'cs' 			=> __('Czech', 'event_espresso'),
511
+								 'da' 			=> __('Danish', 'event_espresso'),
512
+								 'nl' 			=> __('Dutch', 'event_espresso'),
513
+								 'en-GB' 	=>  __('English (UK)', 'event_espresso'),
514
+								 'en' 			=> __('English (US)', 'event_espresso'),
515
+								 'fil' 			=> __('Filipino', 'event_espresso'),
516
+								 'fi' 			=> __('Finnish', 'event_espresso'),
517
+								 'fr' 			=> __('French', 'event_espresso'),
518
+								 'fr-CA' 	=>  __('French (Canadian)', 'event_espresso'),
519
+								 'de' 			=> __('German', 'event_espresso'),
520
+								 'de-AT' 	=>  __('German (Austria)', 'event_espresso'),
521
+								 'de-CH' 	=>  __('German (Switzerland)', 'event_espresso'),
522
+								 'el' 			=> __('Greek', 'event_espresso'),
523
+								 'iw' 			=> __('Hebrew', 'event_espresso'),
524
+								 'hi' 			=> __('Hindi', 'event_espresso'),
525
+								 'hu' 		=> __('Hungarian', 'event_espresso'),
526
+								 'id' 			=> __('Indonesian', 'event_espresso'),
527
+								 'it' 			=> __('Italian', 'event_espresso'),
528
+								 'ja' 			=> __('Japanese', 'event_espresso'),
529
+								 'ko' 			=> __('Korean', 'event_espresso'),
530
+								 'lv' 			=> __('Latvian', 'event_espresso'),
531
+								 'lt' 			=> __('Lithuanian', 'event_espresso'),
532
+								 'no' 		=> __('Norwegian', 'event_espresso'),
533
+								 'fa' 			=> __('Persian', 'event_espresso'),
534
+								 'pl' 			=> __('Polish', 'event_espresso'),
535
+								 'pt' 			=> __('Portuguese', 'event_espresso'),
536
+								 'pt-BR' 	=>  __('Portuguese (Brazil)', 'event_espresso'),
537
+								 'pt-PT' 	=>  __('Portuguese (Portugal)', 'event_espresso'),
538
+								 'ro' 			=> __('Romanian', 'event_espresso'),
539
+								 'ru' 			=> __('Russian', 'event_espresso'),
540
+								 'sr' 			=> __('Serbian', 'event_espresso'),
541
+								 'sk' 			=> __('Slovak', 'event_espresso'),
542
+								 'sl' 			=> __('Slovenian', 'event_espresso'),
543
+								 'es' 			=> __('Spanish', 'event_espresso'),
544
+								 'es-419' 	=>  __('Spanish (Latin America)', 'event_espresso'),
545
+								 'sv' 			=> __('Swedish', 'event_espresso'),
546
+								 'th' 			=> __('Thai', 'event_espresso'),
547
+								 'tr' 			=> __('Turkish', 'event_espresso'),
548
+								 'uk' 			=> __('Ukrainian', 'event_espresso'),
549
+								 'vi' 			=> __('Vietnamese', 'event_espresso')
551 550
 							),
552 551
 							array(
553
-								'html_label_text'	 	=> __( 'Language', 'event_espresso' ),
554
-								'html_help_text' 		=> __( 'Forces the widget to render in a specific language.', 'event_espresso' ),
555
-								'default' 					=> isset( EE_Registry::instance()->CFG->registration->recaptcha_language ) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'
552
+								'html_label_text'	 	=> __('Language', 'event_espresso'),
553
+								'html_help_text' 		=> __('Forces the widget to render in a specific language.', 'event_espresso'),
554
+								'default' 					=> isset(EE_Registry::instance()->CFG->registration->recaptcha_language) ? EE_Registry::instance()->CFG->registration->recaptcha_language : 'en'
556 555
 							)
557 556
 						)
558 557
 					)
@@ -600,25 +599,25 @@  discard block
 block discarded – undo
600 599
 	 * @param EE_Registration_Config $EE_Registration_Config
601 600
 	 * @return array
602 601
 	 */
603
-	public static function update_admin_settings( EE_Registration_Config $EE_Registration_Config ) {
602
+	public static function update_admin_settings(EE_Registration_Config $EE_Registration_Config) {
604 603
 		try {
605 604
 			$recaptcha_settings_form = EED_Recaptcha::_recaptcha_settings_form();
606 605
 			// if not displaying a form, then check for form submission
607
-			if ( $recaptcha_settings_form->was_submitted() ) {
606
+			if ($recaptcha_settings_form->was_submitted()) {
608 607
 				// capture form data
609 608
 				$recaptcha_settings_form->receive_form_submission();
610 609
 				// validate form data
611
-				if ( $recaptcha_settings_form->is_valid() ) {
610
+				if ($recaptcha_settings_form->is_valid()) {
612 611
 					// grab validated data from form
613 612
 					$valid_data = $recaptcha_settings_form->valid_data();
614 613
 					// user proofing recaptcha:  If Use reCAPTCHA is set to yes but we dont' have site or secret keys then set Use reCAPTCHA to FALSE and give error message.
615 614
 					if (
616
-						apply_filters( 'FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config )
615
+						apply_filters('FHEE__Extend_Registration_Form_Admin_Page__check_for_recaptcha_keys', TRUE, $EE_Registration_Config)
617 616
 						&& $valid_data['main_settings']['use_captcha']
618
-						&& ( ! $EE_Registration_Config->use_captcha && ( empty( $valid_data['main_settings']['recaptcha_publickey'] ) || empty( $valid_data['main_settings']['recaptcha_privatekey'] )))
617
+						&& ( ! $EE_Registration_Config->use_captcha && (empty($valid_data['main_settings']['recaptcha_publickey']) || empty($valid_data['main_settings']['recaptcha_privatekey'])))
619 618
 					) {
620 619
 						$valid_data['main_settings']['use_captcha'] = FALSE;
621
-						EE_Error::add_error( __('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__ );
620
+						EE_Error::add_error(__('The use reCAPTCHA setting has been reset to "no". In order to enable the reCAPTCHA service, you must enter a Site Key and Secret Key.', 'event_espresso'), __FILE__, __FUNCTION__, __LINE__);
622 621
 					}
623 622
 					$EE_Registration_Config->use_captcha = $valid_data['main_settings']['use_captcha'];
624 623
 					$EE_Registration_Config->recaptcha_publickey = $valid_data['main_settings']['recaptcha_publickey'];
@@ -627,12 +626,12 @@  discard block
 block discarded – undo
627 626
 					$EE_Registration_Config->recaptcha_theme = $valid_data['appearance_settings']['recaptcha_theme'];
628 627
 					$EE_Registration_Config->recaptcha_language = $valid_data['appearance_settings']['recaptcha_language'];
629 628
 				} else {
630
-					if ( $recaptcha_settings_form->submission_error_message() != '' ) {
631
-						EE_Error::add_error( $recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ );
629
+					if ($recaptcha_settings_form->submission_error_message() != '') {
630
+						EE_Error::add_error($recaptcha_settings_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__);
632 631
 					}
633 632
 				}
634 633
 			}
635
-		} catch( EE_Error $e ) {
634
+		} catch (EE_Error $e) {
636 635
 			$e->get_error();
637 636
 		}
638 637
 
Please login to merge, or discard this patch.
core/libraries/shortcodes/EE_Transaction_Shortcodes.lib.php 1 patch
Spacing   +139 added lines, -139 removed lines patch added patch discarded remove patch
@@ -1,6 +1,6 @@  discard block
 block discarded – undo
1 1
 <?php
2 2
 
3
-if (!defined('EVENT_ESPRESSO_VERSION') )
3
+if ( ! defined('EVENT_ESPRESSO_VERSION'))
4 4
 	exit('NO direct script access allowed');
5 5
 
6 6
 /**
@@ -42,25 +42,25 @@  discard block
 block discarded – undo
42 42
 		$this->_shortcodes = array(
43 43
 			'[TXN_ID]' => __('The transaction id for the purchase.', 'event_espresso'),
44 44
 			'[PAYMENT_URL]' => __('This is a link to make a payment for the event', 'event_espresso'),
45
-			'[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso') . '<ul>'
46
-				. '<li>' . sprintf( __('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
47
-				. '<li>' . sprintf( __('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
48
-				. '<li>' . sprintf( __('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
45
+			'[PAYMENT_LINK_IF_NEEDED_*]' => __('This is a special dynamic shortcode that allows one to insert a payment link conditional on there being amount owing on the transaction. Three params are available on this shortcode:', 'event_espresso').'<ul>'
46
+				. '<li>'.sprintf(__('%class:%s This can be used to indicate css class is given to the containing css element (default is "callout").', 'event_espresso'), '<strong>', '</strong>').'</li>'
47
+				. '<li>'.sprintf(__('%scustom_text:%s This should be a sprintf format text string (with %%s for where the hyperlink tags go) that is used for the generated link text (The default is "You can %%smake a payment here »%%s.)', 'event_espresso'), '<strong>', '</strong>').'</li>'
48
+				. '<li>'.sprintf(__('%scontainer_tag:%s Use this to indicate what container tag you want surrounding the payment link (default is "p").', 'event_espresso'), '<strong>', '</strong>').'</li>'
49 49
 				. '</ul>',
50
-			'[PAYMENT_DUE_DATE_*]' => __( 'This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:', 'event_espresso' )
50
+			'[PAYMENT_DUE_DATE_*]' => __('This is a special dynamic shortcode that allows one to output a payment due date.  It will only result in a date shown if there is money owing.  Three parameters are available on this shortcode:', 'event_espresso')
51 51
 				. '<ul>'
52
-				. '<li>' . sprintf( __( '%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
53
-				. '<li>' . sprintf( __( '%days_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>'
54
-				. '<li>' . sprintf( __( '%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"', 'event_espresso' ), '<strong>', '</strong>' ) . '</li>',
52
+				. '<li>'.sprintf(__('%sformat:%s This is used to indicate what format the date is in.  Default is whatever is set as date formats for your website.', 'event_espresso'), '<strong>', '</strong>').'</li>'
53
+				. '<li>'.sprintf(__('%days_until_due:%s This is the number of days form the transaction creation date that the payment is due.  Defaults to 30.', 'event_espresso'), '<strong>', '</strong>').'</li>'
54
+				. '<li>'.sprintf(__('%sprefix_text:%s You can use this to indicate what text will prefix the date string.  Defaults to "Payment in full due by:"', 'event_espresso'), '<strong>', '</strong>').'</li>',
55 55
 			'[INVOICE_LINK]' => __('This is a full html link to the invoice', 'event_espresso'),
56 56
 			'[INVOICE_URL]' => __('This is just the url for the invoice', 'event_espresso'),
57 57
 			'[INVOICE_LOGO_URL]' => __('This returns the url for the logo uploaded via the invoice settings page.', 'event_espresso'),
58 58
 			'[INVOICE_LOGO]' => __('This returns the logo uploaded via the invoice settings page wrapped in img_tags and with a "logo screen" classes. The image size is also set in the img tags automatically to match the uploaded logo.', 'event_espresso'),
59 59
 			'[INVOICE_PAYEE_NAME]' => __('This will parse to either: the value of the "Company Name" field in the invoice payment method settings; if that is blank, then the value of the Company Name in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
60
-			'[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ),
61
-			'[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso' ),
62
-			'[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso' ),
63
-			'[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso' ),
60
+			'[INVOICE_PAYEE_ADDRESS]' => __('This will parse to either: the value of the "Company Address" field in the invoice payment method settings; if that is blank, then the value of the Company Address in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
61
+			'[INVOICE_PAYMENT_INSTRUCTIONS]' => __('This will parse to the value of the "Payment Instructions" field found on the Invoice payment methods settings page', 'event_espresso'),
62
+			'[INVOICE_PAYEE_EMAIL]' => __('This will parse to either: the value of the "Company Email" field in the invoice payment method settings; if that is blank, then the value of the Company Email in the "Your Organization Settings", if that is blank then an empty string.', 'event_espresso'),
63
+			'[INVOICE_PAYEE_TAX_NUMBER_*]' => __('This will parse to either: the value of the "Company Tax Number" field in the invoice payment method settings; if that is blank, then the value of the Company Tax Number in the "Your Organization Settings", if that is blank then an empty string. Note this is also a special dynamic shortcode. You can use the "prefix" parameter to indicate what text you want to use as a prefix before this tax number.  It defaults to "VAT/Tax Number:". To change this prefix you do the following format for this shortcode: <code>[INVOICE_PAYEE_TAX_NUMBER_* prefix="GST:"]</code> and that will ouptut: GST: 12345t56.  If you have no tax number in your settings, then no prefix will be output either.', 'event_espresso'),
64 64
 			'[TOTAL_COST]' => __('The total cost for the transaction', 'event_espresso'),
65 65
 			'[TXN_STATUS]' => __('The transaction status for the transaction.', 'event_espresso'),
66 66
 			'[TXN_STATUS_ID]' => __('The ID representing the transaction status as saved in the db.  This tends to be useful for including with css classes for styling certain statuses differently from others.', 'event_espresso'),
@@ -71,52 +71,52 @@  discard block
 block discarded – undo
71 71
 			'[TOTAL_OWING]' => __('The total owing on a transaction with no attributes.', 'event_espresso'),
72 72
 			'[TXN_SUBTOTAL]' => __('The subtotal for all txn line items.', 'event_espresso'),
73 73
 			'[TXN_TAX_SUBTOTAL]' => __('The subtotal for all tax line items.', 'event_espresso'),
74
-			'[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso') . '<p></ul>' .
75
-				'<li><strong>still_owing</strong>:' . __('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso' ) . sprintf( __( '%sPlease make a payment.%s', 'event_espresso'),  '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' ) . '</li>' .
76
-				'<li><strong>none_owing</strong>:' . __('If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total oweing.', 'event_espresso') . '</li></ul></p>',
74
+			'[OWING_STATUS_MESSAGE_*]' => __('A dynamic shortcode for adjusting how total oweing gets shown. The acceptable attributes on the shortcode are:', 'event_espresso').'<p></ul>'.
75
+				'<li><strong>still_owing</strong>:'.__('If the transaction is not paid in full, then whatever is set for this attribute is shown (otherwise its just the amount oweing). The default is:', 'event_espresso').sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>').'</li>'.
76
+				'<li><strong>none_owing</strong>:'.__('If the transaction is paid in full, then you can indicate how this gets displayed.  Note, that it defaults to just be the total oweing.', 'event_espresso').'</li></ul></p>',
77 77
 			'[TXN_TOTAL_TICKETS]' => __('The total number of all tickets purchased in a transaction', 'event_espresso'),
78 78
 			'[TKT_QTY_PURCHASED]' => __('The total number of all tickets purchased in a transaction. <strong>NOTE: This shortcode is good to use in the "[TICKET_LIST]" field but has been deprecated from all other contexts in favor of the more explicit [TXN_TOTAL_TICKETS] shortcode.</strong>', 'event_espresso'),
79 79
 			'[TRANSACTION_ADMIN_URL]' => __('The url to the admin page for this transaction', 'event_espresso'),
80 80
 			'[RECEIPT_URL]' => __('This parses to the generated url for retrieving the receipt for the transaction', 'event_espresso'),
81
-			'[INVOICE_RECEIPT_SWITCHER_URL]' => __( 'This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.', 'event_espresso'),
82
-			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf( __( 'The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso' ), '<code>', '</code>' )
81
+			'[INVOICE_RECEIPT_SWITCHER_URL]' => __('This parses to the url that will switch to the receipt if an invoice is displayed, and switch to the invoice if receipt is displayed. If a message type OTHER than invoice or receipt is displayed then this will just return the url for the invoice. If the related message type is not active  then will parse to an empty string.', 'event_espresso'),
82
+			'[INVOICE_RECEIPT_SWITCHER_BUTTON]' => sprintf(__('The same as %1$s[INVOICE_RECEIPT_SWITCHER_URL]%2$s except this returns the html for a button linked to the invoice or receipt.', 'event_espresso'), '<code>', '</code>')
83 83
 			);
84 84
 	}
85 85
 
86 86
 
87
-	protected function _parser( $shortcode ) {
87
+	protected function _parser($shortcode) {
88 88
 
89 89
 		//attempt to get the transaction.  Since this is potentially used in more fields, we may have to look in the _extra_data for the transaction.
90 90
 		$transaction = $this->_data->txn instanceof EE_Transaction ? $this->_data->txn : null;
91
-		$transaction = ! $transaction instanceof EE_Transaction && is_array( $this->_extra_data ) &&  isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn: $transaction;
91
+		$transaction = ! $transaction instanceof EE_Transaction && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->txn : $transaction;
92 92
 
93 93
 		//payment
94 94
 		$payment = $this->_data->payment instanceof EE_Payment ? $this->_data->payment : null;
95
-		$payment = ! $payment instanceof EE_Payment && is_array( $this->_extra_data ) &&  isset( $this->_extra_data['data'] ) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment: $payment;
95
+		$payment = ! $payment instanceof EE_Payment && is_array($this->_extra_data) && isset($this->_extra_data['data']) && $this->_extra_data['data'] instanceof EE_Messages_Addressee ? $this->_extra_data['data']->payment : $payment;
96 96
 
97 97
 
98
-		if ( ! $transaction instanceof EE_Transaction )
98
+		if ( ! $transaction instanceof EE_Transaction)
99 99
 			return '';
100 100
 
101
-		switch ( $shortcode ) {
101
+		switch ($shortcode) {
102 102
 			case '[TXN_ID]' :
103 103
 				return $transaction->ID();
104 104
 				break;
105 105
 
106 106
 			case '[PAYMENT_URL]' :
107 107
 				$payment_url = $transaction->payment_overview_url();
108
-				return empty( $payment_url ) ? __( 'http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url;
108
+				return empty($payment_url) ? __('http://dummypaymenturlforpreview.com', 'event_espresso') : $payment_url;
109 109
 				break;
110 110
 
111 111
 			case '[INVOICE_LINK]' :
112 112
 				$invoice_url = $transaction->invoice_url();
113
-				$invoice_url = empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
114
-				return sprintf( __('%sClick here for Invoice%s', 'event_espresso'), '<a href="' . $invoice_url . '">', '</a>' );
113
+				$invoice_url = empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
114
+				return sprintf(__('%sClick here for Invoice%s', 'event_espresso'), '<a href="'.$invoice_url.'">', '</a>');
115 115
 				break; /**/
116 116
 
117 117
 			case '[INVOICE_URL]' :
118 118
 				$invoice_url = $transaction->invoice_url();
119
-				return empty( $invoice_url ) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
119
+				return empty($invoice_url) ? 'http://dummyinvoicelinksforpreview.com' : $invoice_url;
120 120
 				break;
121 121
 
122 122
 			case '[INVOICE_LOGO_URL]' :
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
 				break;
125 125
 
126 126
 			case '[INVOICE_LOGO]' :
127
-				return $this->_get_invoice_logo( TRUE );
127
+				return $this->_get_invoice_logo(TRUE);
128 128
 				break;
129 129
 
130 130
 			case '[INVOICE_PAYEE_NAME]' :
@@ -146,18 +146,18 @@  discard block
 block discarded – undo
146 146
 
147 147
 			case "[TOTAL_COST]" :
148 148
 				$total = $transaction->total();
149
-				return ! empty($total) ? EEH_Template::format_currency( $total ) : '';
149
+				return ! empty($total) ? EEH_Template::format_currency($total) : '';
150 150
 				break;
151 151
 
152 152
 			case "[PAYMENT_STATUS]" :
153 153
 				$status = $transaction->pretty_status();
154
-				return !empty($status) ? $status : __('Unknown', 'event_espresso');
154
+				return ! empty($status) ? $status : __('Unknown', 'event_espresso');
155 155
 				break; /**/
156 156
 
157 157
 			// note the [payment_status] shortcode is kind of misleading because payment status might be different from txn status so I'm adding this here for clarity.
158 158
 			case "[TXN_STATUS]" :
159 159
 				$status = $transaction->pretty_status();
160
-				return !empty( $status ) ? $status : __('Unknown', 'event_espresso');
160
+				return ! empty($status) ? $status : __('Unknown', 'event_espresso');
161 161
 				break;
162 162
 
163 163
 			case "[TXN_STATUS_ID]" :
@@ -165,21 +165,21 @@  discard block
 block discarded – undo
165 165
 				break;
166 166
 
167 167
 			case "[PAYMENT_GATEWAY]" :
168
-				return $this->_get_payment_gateway( $transaction );
168
+				return $this->_get_payment_gateway($transaction);
169 169
 				break;
170 170
 
171 171
 			case "[AMOUNT_PAID]" :
172 172
 				$amount = $payment instanceof EE_Payment ? $payment->amount() : 0;
173
-				return EEH_Template::format_currency( $amount );
173
+				return EEH_Template::format_currency($amount);
174 174
 				break;
175 175
 
176 176
 			case "[TOTAL_AMOUNT_PAID]" :
177
-				return EEH_Template::format_currency( $transaction->paid() );
177
+				return EEH_Template::format_currency($transaction->paid());
178 178
 				break;
179 179
 
180 180
 			case "[TOTAL_OWING]" :
181 181
 				$total_owing = $transaction->remaining();
182
-				return EEH_Template::format_currency( $total_owing );
182
+				return EEH_Template::format_currency($total_owing);
183 183
 				break;
184 184
 
185 185
 			case "[TXN_SUBTOTAL]" :
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
 				break;
188 188
 
189 189
 			case "[TXN_TAX_SUBTOTAL]" :
190
-				return EEH_Template::format_currency($this->_get_subtotal( TRUE ));
190
+				return EEH_Template::format_currency($this->_get_subtotal(TRUE));
191 191
 				break;
192 192
 
193 193
 			case "[TKT_QTY_PURCHASED]" :
@@ -196,9 +196,9 @@  discard block
 block discarded – undo
196 196
 				break;
197 197
 
198 198
 			case "[TRANSACTION_ADMIN_URL]" :
199
-				require_once EE_CORE . 'admin/EE_Admin_Page.core.php';
200
-				$query_args = array( 'page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID() );
201
-				$url = EE_Admin_Page::add_query_args_and_nonce( $query_args, admin_url('admin.php') );
199
+				require_once EE_CORE.'admin/EE_Admin_Page.core.php';
200
+				$query_args = array('page' => 'espresso_transactions', 'action' => 'view_transaction', 'TXN_ID' => $transaction->ID());
201
+				$url = EE_Admin_Page::add_query_args_and_nonce($query_args, admin_url('admin.php'));
202 202
 				return $url;
203 203
 				break;
204 204
 
@@ -206,14 +206,14 @@  discard block
 block discarded – undo
206 206
 				//get primary_registration
207 207
 				$reg = $this->_data->primary_reg_obj;
208 208
 
209
-				if ( ! $reg instanceof EE_Registration ) {
209
+				if ( ! $reg instanceof EE_Registration) {
210 210
 					return '';
211 211
 				}
212 212
 				return $reg->receipt_url();
213 213
 				break;
214 214
 
215 215
 			case "[INVOICE_RECEIPT_SWITCHER_URL]" :
216
-				return $this->_get_invoice_receipt_switcher( FALSE );
216
+				return $this->_get_invoice_receipt_switcher(FALSE);
217 217
 				break;
218 218
 
219 219
 			case "[INVOICE_RECEIPT_SWITCHER_BUTTON]" :
@@ -223,20 +223,20 @@  discard block
 block discarded – undo
223 223
 
224 224
 		}
225 225
 
226
-		if ( strpos( $shortcode, '[OWING_STATUS_MESSAGE_*' ) !== FALSE ) {
227
-			return $this->_get_custom_total_oweing( $shortcode );
226
+		if (strpos($shortcode, '[OWING_STATUS_MESSAGE_*') !== FALSE) {
227
+			return $this->_get_custom_total_oweing($shortcode);
228 228
 		}
229 229
 
230
-		if ( strpos( $shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*' ) !== FALSE ) {
231
-			return $this->_get_invoice_payee_tax_number( $shortcode );
230
+		if (strpos($shortcode, '[INVOICE_PAYEE_TAX_NUMBER_*') !== FALSE) {
231
+			return $this->_get_invoice_payee_tax_number($shortcode);
232 232
 		}
233 233
 
234
-		if ( strpos( $shortcode, '[PAYMENT_LINK_IF_NEEDED_*' ) !== FALSE ) {
235
-			return $this->_get_payment_link_if_needed( $shortcode );
234
+		if (strpos($shortcode, '[PAYMENT_LINK_IF_NEEDED_*') !== FALSE) {
235
+			return $this->_get_payment_link_if_needed($shortcode);
236 236
 		}
237 237
 
238
-		if ( strpos( $shortcode, '[PAYMENT_DUE_DATE_*' ) !== false ) {
239
-			return $this->_get_payment_due_date( $shortcode, $transaction );
238
+		if (strpos($shortcode, '[PAYMENT_DUE_DATE_*') !== false) {
239
+			return $this->_get_payment_due_date($shortcode, $transaction);
240 240
 		}
241 241
 
242 242
 		return '';
@@ -253,19 +253,19 @@  discard block
 block discarded – undo
253 253
 	 *
254 254
 	 * @return string parsed.
255 255
 	 */
256
-	private function _get_custom_total_oweing( $shortcode ) {
257
-		$valid_shortcodes = array( 'transaction' );
258
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
256
+	private function _get_custom_total_oweing($shortcode) {
257
+		$valid_shortcodes = array('transaction');
258
+		$attrs = $this->_get_shortcode_attrs($shortcode);
259 259
 
260 260
 		//ensure default is set.
261 261
 		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
262 262
 		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0;
263 263
 
264
-		if ( $total_owing > 0 ) {
265
-			$owing_content = ! empty( $attrs['still_owing'] ) ? $attrs['still_owing'] : sprintf( __( '%sPlease make a payment.%s', 'event_espresso'),  '<a href="[PAYMENT_URL]" class="noPrint">', '</a>' );
266
-			$owing_content = $this->_shortcode_helper->parse_message_template( $owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message );
264
+		if ($total_owing > 0) {
265
+			$owing_content = ! empty($attrs['still_owing']) ? $attrs['still_owing'] : sprintf(__('%sPlease make a payment.%s', 'event_espresso'), '<a href="[PAYMENT_URL]" class="noPrint">', '</a>');
266
+			$owing_content = $this->_shortcode_helper->parse_message_template($owing_content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message);
267 267
 		} else {
268
-			$owing_content = !empty( $attrs['none_owing']) ? $attrs['none_owing'] : '';
268
+			$owing_content = ! empty($attrs['none_owing']) ? $attrs['none_owing'] : '';
269 269
 		}
270 270
 
271 271
 		return $owing_content;
@@ -273,8 +273,8 @@  discard block
 block discarded – undo
273 273
 
274 274
 
275 275
 
276
-	private function _get_payment_gateway( $transaction ) {
277
-		$pm = $this->_get_payment_method( $transaction );
276
+	private function _get_payment_gateway($transaction) {
277
+		$pm = $this->_get_payment_method($transaction);
278 278
 		return $pm instanceof EE_Payment_Method ? $pm->name() : '';
279 279
 	}
280 280
 
@@ -289,37 +289,37 @@  discard block
 block discarded – undo
289 289
 	 *
290 290
 	 * @return string url or html
291 291
 	 */
292
-	private function _get_invoice_logo( $img_tags = FALSE ) {
292
+	private function _get_invoice_logo($img_tags = FALSE) {
293 293
 		//try to get the invoice payment method's logo for this transaction image first
294 294
 		$pm = $this->_get_payment_method();
295
-		if ( $pm instanceof EE_Payment_Method ){
296
-			$invoice_logo_url = $pm->get_extra_meta( 'pdf_logo_image', TRUE );
297
-		}else{
295
+		if ($pm instanceof EE_Payment_Method) {
296
+			$invoice_logo_url = $pm->get_extra_meta('pdf_logo_image', TRUE);
297
+		} else {
298 298
 			$invoice_logo_url = NULL;
299 299
 		}
300
-		if( empty( $invoice_logo_url ) ){
300
+		if (empty($invoice_logo_url)) {
301 301
 			$invoice_logo_url = EE_Registry::instance()->CFG->organization->logo_url;
302 302
 		}
303 303
 
304
-		if ( empty( $invoice_logo_url ) ) {
304
+		if (empty($invoice_logo_url)) {
305 305
 			return '';
306 306
 		}
307 307
 
308
-		if ( ! $img_tags ) {
308
+		if ( ! $img_tags) {
309 309
 			return $invoice_logo_url;
310 310
 		}
311 311
 
312 312
 		//image tags have been requested.
313
-		$image_size = getimagesize( $invoice_logo_url );
313
+		$image_size = getimagesize($invoice_logo_url);
314 314
 		
315 315
 		//if image is wider than 200px, set the wideth to 200
316
-		if ( $image_size[0] > 300 ) {
316
+		if ($image_size[0] > 300) {
317 317
 			$image_width = 300;
318
-		}else{
318
+		} else {
319 319
 			$image_width = $image_size[0];
320 320
 		}
321 321
 
322
-		return '<img class="logo screen" src="' . $invoice_logo_url . '" width="' . $image_width . '" alt="logo" />';
322
+		return '<img class="logo screen" src="'.$invoice_logo_url.'" width="'.$image_width.'" alt="logo" />';
323 323
 	}
324 324
 
325 325
 
@@ -336,26 +336,26 @@  discard block
 block discarded – undo
336 336
 	private function _get_invoice_payee_name() {
337 337
 		$payee_name = NULL;
338 338
 		$pm = $this->_get_payment_method();
339
-		if( $pm instanceof EE_Payment_Method ){
340
-			$payee_name = $pm->get_extra_meta( 'pdf_payee_name', TRUE );
339
+		if ($pm instanceof EE_Payment_Method) {
340
+			$payee_name = $pm->get_extra_meta('pdf_payee_name', TRUE);
341 341
 		}
342
-		$payee_name = empty( $payee_name ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'name' ) : $payee_name;
342
+		$payee_name = empty($payee_name) ? EE_Registry::instance()->CFG->organization->get_pretty('name') : $payee_name;
343 343
 		return $payee_name;
344 344
 	}
345 345
 
346 346
 	/**
347 347
 	 * gets the payment method for this transaction. Otherwise gets a default one.
348 348
 	 */
349
-	private function _get_payment_method( $transaction = null ){
350
-		if( $transaction instanceof EE_Transaction ) {
349
+	private function _get_payment_method($transaction = null) {
350
+		if ($transaction instanceof EE_Transaction) {
351 351
 			$payment_method = $transaction->payment_method();
352
-			if ( empty( $payment_method ) ) {
353
-				return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
352
+			if (empty($payment_method)) {
353
+				return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
354 354
 			}
355 355
 			return $payment_method;
356
-		}else{
356
+		} else {
357 357
 			//get the first payment method we can find
358
-			return apply_filters( 'FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
358
+			return apply_filters('FHEE__EE_Transaction_Shortcodes__get_payment_method__default', EEM_Payment_Method::instance()->get_one_of_type('Invoice'));
359 359
 		}
360 360
 	}
361 361
 
@@ -372,10 +372,10 @@  discard block
 block discarded – undo
372 372
 	private function _get_invoice_payee_email() {
373 373
 		$payee_email = NULL;
374 374
 		$pm = $this->_get_payment_method();
375
-		if( $pm instanceof EE_Payment_Method ){
376
-			$payee_email = $pm->get_extra_meta( 'pdf_payee_email', TRUE );
375
+		if ($pm instanceof EE_Payment_Method) {
376
+			$payee_email = $pm->get_extra_meta('pdf_payee_email', TRUE);
377 377
 		}
378
-		$payee_email = empty( $payee_email ) ? EE_Registry::instance()->CFG->organization->get_pretty( 'email' ) : $payee_email;
378
+		$payee_email = empty($payee_email) ? EE_Registry::instance()->CFG->organization->get_pretty('email') : $payee_email;
379 379
 		return $payee_email;
380 380
 	}
381 381
 
@@ -391,24 +391,24 @@  discard block
 block discarded – undo
391 391
 	 *
392 392
 	 * @return string
393 393
 	 */
394
-	private function _get_invoice_payee_tax_number( $shortcode ) {
394
+	private function _get_invoice_payee_tax_number($shortcode) {
395 395
 		$payee_tax_number = NULL;
396 396
 		$pm = $this->_get_payment_method();
397
-		if( $pm instanceof EE_Payment_Method ){
398
-			$payee_tax_number = $pm->get_extra_meta( 'pdf_payee_tax_number', TRUE );
397
+		if ($pm instanceof EE_Payment_Method) {
398
+			$payee_tax_number = $pm->get_extra_meta('pdf_payee_tax_number', TRUE);
399 399
 		}
400
-		$payee_tax_number = empty( $payee_tax_number ) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number;
400
+		$payee_tax_number = empty($payee_tax_number) ? EE_Registry::instance()->CFG->organization->vat : $payee_tax_number;
401 401
 
402
-		if ( empty( $payee_tax_number ) ) {
402
+		if (empty($payee_tax_number)) {
403 403
 			return '';
404 404
 		}
405 405
 
406 406
 		//any attributes?
407
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
407
+		$attrs = $this->_get_shortcode_attrs($shortcode);
408 408
 
409 409
 		//prefix?
410
-		$prefix = isset( $attrs['prefix'] ) ? $attrs['prefix'] : __( 'VAT/Tax Number: ', 'event_espresso' );
411
-		return $prefix . $payee_tax_number;
410
+		$prefix = isset($attrs['prefix']) ? $attrs['prefix'] : __('VAT/Tax Number: ', 'event_espresso');
411
+		return $prefix.$payee_tax_number;
412 412
 	}
413 413
 
414 414
 
@@ -425,22 +425,22 @@  discard block
 block discarded – undo
425 425
 	private function _get_invoice_payee_address() {
426 426
 		$payee_address = NULL;
427 427
 		$pm = $this->_get_payment_method();
428
-		if( $pm instanceof EE_Payment_Method ){
429
-			$payee_address = $pm->get_extra_meta( 'pdf_payee_address', TRUE );
428
+		if ($pm instanceof EE_Payment_Method) {
429
+			$payee_address = $pm->get_extra_meta('pdf_payee_address', TRUE);
430 430
 		}
431
-		if ( empty( $payee_address ) ) {
431
+		if (empty($payee_address)) {
432 432
 			$organization = EE_Registry::instance()->CFG->organization;
433
-			$payee_address = $organization->get_pretty( 'address_1' ) . '<br>';
434
-			$payee_address .= !empty( $organization->address_2 ) ? $organization->get_pretty( 'address_2' ) . '<br>' : '';
435
-			$payee_address .= $organization->get_pretty( 'city' ) . '<br>';
433
+			$payee_address = $organization->get_pretty('address_1').'<br>';
434
+			$payee_address .= ! empty($organization->address_2) ? $organization->get_pretty('address_2').'<br>' : '';
435
+			$payee_address .= $organization->get_pretty('city').'<br>';
436 436
 
437 437
 			//state
438
-			$state = EE_Registry::instance()->load_model( 'State' )->get_one_by_ID( $organization->STA_ID );
439
-			$payee_address .= $state instanceof EE_State ? $state->name()  : '';
438
+			$state = EE_Registry::instance()->load_model('State')->get_one_by_ID($organization->STA_ID);
439
+			$payee_address .= $state instanceof EE_State ? $state->name() : '';
440 440
 
441 441
 			//Country
442
-			$payee_address .= ! empty( $organization->CNT_ISO ) ? ', ' . $organization->CNT_ISO . '<br>' : '';
443
-			$payee_address .= ! empty( $organization->zip ) ? $organization->zip : '';
442
+			$payee_address .= ! empty($organization->CNT_ISO) ? ', '.$organization->CNT_ISO.'<br>' : '';
443
+			$payee_address .= ! empty($organization->zip) ? $organization->zip : '';
444 444
 		}
445 445
 		return $payee_address;
446 446
 	}
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
 	private function _get_invoice_payment_instructions() {
459 459
 		$instructions = NULL;
460 460
 		$pm = $this->_get_payment_method();
461
-		return ( $pm instanceof EE_Payment_Method ) ? $pm->get_extra_meta( 'pdf_instructions', TRUE) : '';
461
+		return ($pm instanceof EE_Payment_Method) ? $pm->get_extra_meta('pdf_instructions', TRUE) : '';
462 462
 	}
463 463
 
464 464
 
@@ -472,27 +472,27 @@  discard block
 block discarded – undo
472 472
 	 *
473 473
 	 * @return string
474 474
 	 */
475
-	protected function _get_invoice_receipt_switcher( $button = TRUE ) {
475
+	protected function _get_invoice_receipt_switcher($button = TRUE) {
476 476
 		$reg = $this->_data->primary_reg_obj;
477
-		$message_type = isset( $this->_extra_data['message_type'] ) ? $this->_extra_data['message_type'] : '';
478
-		if ( ! $reg instanceof EE_Registration || empty( $message_type ) ) {
477
+		$message_type = isset($this->_extra_data['message_type']) ? $this->_extra_data['message_type'] : '';
478
+		if ( ! $reg instanceof EE_Registration || empty($message_type)) {
479 479
 			return '';
480 480
 		}
481 481
 
482
-		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type  ? true : false;
483
-		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso' ) : __( 'Switch to Invoice', 'event_espresso' );
484
-		$switch_to_label = ! $switch_to_invoice ? __( 'Switch to Receipt', 'event_espresso' ) : $switch_to_label;
482
+		$switch_to_invoice = ! $message_type instanceof EE_Invoice_message_type ? true : false;
483
+		$switch_to_label = $switch_to_invoice && ! $message_type instanceof EE_Receipt_message_type ? __('View Invoice', 'event_espresso') : __('Switch to Invoice', 'event_espresso');
484
+		$switch_to_label = ! $switch_to_invoice ? __('Switch to Receipt', 'event_espresso') : $switch_to_label;
485 485
 		$switch_to_url = $switch_to_invoice ? $reg->invoice_url() : $reg->receipt_url();
486 486
 
487
-		if ( ! $button ) {
487
+		if ( ! $button) {
488 488
 			return $switch_to_url;
489 489
 		}
490 490
 
491
-		if ( ! empty( $switch_to_url ) ) {
491
+		if ( ! empty($switch_to_url)) {
492 492
 
493 493
 			return  '
494
-	<form method="post" action="' . $switch_to_url . '" >
495
-		<input class="print_button" type="submit" value="' . $switch_to_label . '" />
494
+	<form method="post" action="' . $switch_to_url.'" >
495
+		<input class="print_button" type="submit" value="' . $switch_to_label.'" />
496 496
 	</form>
497 497
 			';
498 498
 		}
@@ -512,11 +512,11 @@  discard block
 block discarded – undo
512 512
 	 *
513 513
 	 * @return string
514 514
 	 */
515
-	private function _get_receipt_url( EE_Transaction $transaction ) {
515
+	private function _get_receipt_url(EE_Transaction $transaction) {
516 516
 		//get primary_registration
517 517
 		$reg = $this->_data->primary_reg_obj;
518 518
 
519
-		if ( ! $reg instanceof EE_Registration ) {
519
+		if ( ! $reg instanceof EE_Registration) {
520 520
 			return '';
521 521
 		}
522 522
 
@@ -532,10 +532,10 @@  discard block
 block discarded – undo
532 532
 	 *
533 533
 	 * @return int
534 534
 	 */
535
-	private function _get_subtotal( $tax = FALSE ) {
536
-		$grand_total = isset( $this->_data->grand_total_line_item ) ? $this->_data->grand_total_line_item : NULL;
535
+	private function _get_subtotal($tax = FALSE) {
536
+		$grand_total = isset($this->_data->grand_total_line_item) ? $this->_data->grand_total_line_item : NULL;
537 537
 
538
-		if ( ! $grand_total instanceof EE_Line_Item ) {
538
+		if ( ! $grand_total instanceof EE_Line_Item) {
539 539
 			return 0;
540 540
 		}
541 541
 
@@ -554,26 +554,26 @@  discard block
 block discarded – undo
554 554
 	 *
555 555
 	 * @return string parsed.
556 556
 	 */
557
-	private function _get_payment_link_if_needed( $shortcode ) {
558
-		$valid_shortcodes = array( 'transaction' );
559
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
557
+	private function _get_payment_link_if_needed($shortcode) {
558
+		$valid_shortcodes = array('transaction');
559
+		$attrs = $this->_get_shortcode_attrs($shortcode);
560 560
 
561 561
 		//ensure default is set.
562 562
 		$addressee = $this->_data instanceof EE_Messages_Addressee ? $this->_data : null;
563 563
 		$total_owing = $addressee instanceof EE_Messages_Addressee && $addressee->txn instanceof EE_Transaction ? $addressee->txn->remaining() : 0;
564 564
 
565
-		if ( $total_owing > 0 ) {
566
-			$class = isset( $attrs['class'] ) ? $attrs['class'] : 'callout';
567
-			$custom_text = isset( $attrs['custom_text'] ) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
568
-			$container_tag = isset( $attrs['container_tag'] ) ? $attrs['container_tag'] : 'p';
569
-			$opening_tag = ! empty( $container_tag ) ? '<' . $container_tag : '';
570
-			$opening_tag .= ! empty( $opening_tag ) && !empty( $class ) ? ' class="' . $class . '"' : $opening_tag;
571
-			$opening_tag .= !empty( $opening_tag ) ? '>' : $opening_tag;
572
-			$closing_tag = ! empty( $container_tag ) ? '</' . $container_tag .'>' : '';
573
-			$content = $opening_tag . sprintf( $custom_text, '<a href="[PAYMENT_URL]">', '</a>' ) . $closing_tag;
565
+		if ($total_owing > 0) {
566
+			$class = isset($attrs['class']) ? $attrs['class'] : 'callout';
567
+			$custom_text = isset($attrs['custom_text']) ? $attrs['custom_text'] : 'You can %smake a payment here »%s.';
568
+			$container_tag = isset($attrs['container_tag']) ? $attrs['container_tag'] : 'p';
569
+			$opening_tag = ! empty($container_tag) ? '<'.$container_tag : '';
570
+			$opening_tag .= ! empty($opening_tag) && ! empty($class) ? ' class="'.$class.'"' : $opening_tag;
571
+			$opening_tag .= ! empty($opening_tag) ? '>' : $opening_tag;
572
+			$closing_tag = ! empty($container_tag) ? '</'.$container_tag.'>' : '';
573
+			$content = $opening_tag.sprintf($custom_text, '<a href="[PAYMENT_URL]">', '</a>').$closing_tag;
574 574
 
575 575
 			//we need to re run this string through the parser to catch any shortcodes that are in it.
576
-			$owing_content = $this->_shortcode_helper->parse_message_template( $content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message );
576
+			$owing_content = $this->_shortcode_helper->parse_message_template($content, $addressee, $valid_shortcodes, $this->_message_type, $this->_messenger, $this->_message);
577 577
 		} else {
578 578
 			return '';
579 579
 		}
@@ -593,31 +593,31 @@  discard block
 block discarded – undo
593 593
 	 * @param EE_Transaction $transaction
594 594
 	 * @return string
595 595
 	 */
596
-	protected function _get_payment_due_date( $shortcode, EE_Transaction $transaction ) {
596
+	protected function _get_payment_due_date($shortcode, EE_Transaction $transaction) {
597 597
 		//if transaction is paid in full then we can just return an empty string
598
-		if ( $transaction->remaining() === 0 ) {
598
+		if ($transaction->remaining() === 0) {
599 599
 			return '';
600 600
 		}
601 601
 
602
-		$attrs = $this->_get_shortcode_attrs( $shortcode );
603
-		$format = isset( $attrs['format'] ) ? $attrs['format'] : get_option( 'date_format' );
604
-		$days_until_due = isset( $attrs['days_until_due'] ) ? (int) $attrs['days_until_due'] : 30;
605
-		$prefix_text = isset( $attrs['prefix_text'] ) ? $attrs['prefix_text'] : __( 'Payment in full due by: ', 'event_espresso' );
606
-		$transaction_created = $transaction->get_DateTime_object( 'TXN_timestamp' );
602
+		$attrs = $this->_get_shortcode_attrs($shortcode);
603
+		$format = isset($attrs['format']) ? $attrs['format'] : get_option('date_format');
604
+		$days_until_due = isset($attrs['days_until_due']) ? (int) $attrs['days_until_due'] : 30;
605
+		$prefix_text = isset($attrs['prefix_text']) ? $attrs['prefix_text'] : __('Payment in full due by: ', 'event_espresso');
606
+		$transaction_created = $transaction->get_DateTime_object('TXN_timestamp');
607 607
 
608 608
 		//setup date due:
609 609
 		try {
610
-			if ( $transaction_created instanceof DateTime ) {
611
-				$date_due = $transaction_created->add( new DateInterval( 'P' . $days_until_due . 'D' ) )->format( $format );
610
+			if ($transaction_created instanceof DateTime) {
611
+				$date_due = $transaction_created->add(new DateInterval('P'.$days_until_due.'D'))->format($format);
612 612
 			} else {
613 613
 				throw new Exception();
614 614
 			}
615
-		} catch( Exception $e ) {
615
+		} catch (Exception $e) {
616 616
 			//format was likely invalid.
617 617
 			$date_due = 'Unable to calculate date due, likely the format string is invalid.';
618 618
 		}
619 619
 
620
-		return $prefix_text . $date_due;
620
+		return $prefix_text.$date_due;
621 621
 	}
622 622
 
623 623
 } //end EE_Transaction Shortcodes library
Please login to merge, or discard this patch.
core/libraries/rest_api/controllers/model/Read.php 1 patch
Spacing   +292 added lines, -292 removed lines patch added patch discarded remove patch
@@ -6,8 +6,8 @@  discard block
 block discarded – undo
6 6
 use EventEspresso\core\libraries\rest_api\Rest_Exception;
7 7
 use EventEspresso\core\libraries\rest_api\Model_Data_Translator;
8 8
 
9
-if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) {
10
-	exit( 'No direct script access allowed' );
9
+if ( ! defined('EVENT_ESPRESSO_VERSION')) {
10
+	exit('No direct script access allowed');
11 11
 }
12 12
 
13 13
 /**
@@ -46,22 +46,22 @@  discard block
 block discarded – undo
46 46
 	 * @param \WP_REST_Request $request
47 47
 	 * @return \WP_REST_Response|\WP_Error
48 48
 	 */
49
-	public static function handle_request_get_all( \WP_REST_Request $request) {
49
+	public static function handle_request_get_all(\WP_REST_Request $request) {
50 50
 		$controller = new Read();
51
-		try{
51
+		try {
52 52
 			$matches = $controller->parse_route(
53 53
 				$request->get_route(),
54
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)~',
55
-				array( 'version', 'model' )
54
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)~',
55
+				array('version', 'model')
56 56
 			);
57
-			$controller->set_requested_version( $matches[ 'version' ] );
58
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
59
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
57
+			$controller->set_requested_version($matches['version']);
58
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
59
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
60 60
 				return $controller->send_response(
61 61
 					new \WP_Error(
62 62
 						'endpoint_parsing_error',
63 63
 						sprintf(
64
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
64
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
65 65
 							$model_name_singular
66 66
 						)
67 67
 					)
@@ -69,12 +69,12 @@  discard block
 block discarded – undo
69 69
 			}
70 70
 			return $controller->send_response(
71 71
 					$controller->get_entities_from_model(
72
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
72
+							$controller->get_model_version_info()->load_model($model_name_singular),
73 73
 							$request
74 74
 					)
75 75
 			);
76
-		} catch( \Exception $e ) {
77
-			return $controller->send_response( $e );
76
+		} catch (\Exception $e) {
77
+			return $controller->send_response($e);
78 78
 		}
79 79
 	}
80 80
 
@@ -84,21 +84,21 @@  discard block
 block discarded – undo
84 84
 	 * @param \WP_REST_Request $request
85 85
 	 * @return \WP_REST_Response|\WP_Error
86 86
 	 */
87
-	public static function handle_request_get_one( \WP_REST_Request $request ) {
87
+	public static function handle_request_get_one(\WP_REST_Request $request) {
88 88
 		$controller = new Read();
89
-		try{
89
+		try {
90 90
 			$matches = $controller->parse_route(
91 91
 				$request->get_route(),
92
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)~',
93
-				array( 'version', 'model', 'id' ) );
94
-			$controller->set_requested_version( $matches[ 'version' ] );
95
-			$model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
96
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $model_name_singular ) ) {
92
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)~',
93
+				array('version', 'model', 'id') );
94
+			$controller->set_requested_version($matches['version']);
95
+			$model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
96
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($model_name_singular)) {
97 97
 				return $controller->send_response(
98 98
 					new \WP_Error(
99 99
 						'endpoint_parsing_error',
100 100
 						sprintf(
101
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
101
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
102 102
 							$model_name_singular
103 103
 						)
104 104
 					)
@@ -106,12 +106,12 @@  discard block
 block discarded – undo
106 106
 			}
107 107
 			return $controller->send_response(
108 108
 					$controller->get_entity_from_model(
109
-							$controller->get_model_version_info()->load_model( $model_name_singular ),
109
+							$controller->get_model_version_info()->load_model($model_name_singular),
110 110
 							$request
111 111
 						)
112 112
 				);
113
-		} catch( \Exception $e ) {
114
-			return $controller->send_response( $e );
113
+		} catch (\Exception $e) {
114
+			return $controller->send_response($e);
115 115
 		}
116 116
 	}
117 117
 
@@ -123,40 +123,40 @@  discard block
 block discarded – undo
123 123
 	 * @param \WP_REST_Request $request
124 124
 	 * @return \WP_REST_Response|\WP_Error
125 125
 	 */
126
-	public static function handle_request_get_related( \WP_REST_Request $request ) {
126
+	public static function handle_request_get_related(\WP_REST_Request $request) {
127 127
 		$controller = new Read();
128
-		try{
128
+		try {
129 129
 			$matches = $controller->parse_route(
130 130
 				$request->get_route(),
131
-				'~' . \EED_Core_Rest_Api::ee_api_namespace_for_regex . '(.*)/(.*)/(.*)~',
132
-				array( 'version', 'model', 'id', 'related_model' )
131
+				'~'.\EED_Core_Rest_Api::ee_api_namespace_for_regex.'(.*)/(.*)/(.*)~',
132
+				array('version', 'model', 'id', 'related_model')
133 133
 			);
134
-			$controller->set_requested_version( $matches[ 'version' ] );
135
-			$main_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'model' ] );
136
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $main_model_name_singular ) ) {
134
+			$controller->set_requested_version($matches['version']);
135
+			$main_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['model']);
136
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($main_model_name_singular)) {
137 137
 				return $controller->send_response(
138 138
 					new \WP_Error(
139 139
 						'endpoint_parsing_error',
140 140
 						sprintf(
141
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
141
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
142 142
 							$main_model_name_singular
143 143
 						)
144 144
 					)
145 145
 				);
146 146
 			}
147
-			$main_model = $controller->get_model_version_info()->load_model( $main_model_name_singular );
147
+			$main_model = $controller->get_model_version_info()->load_model($main_model_name_singular);
148 148
 			//assume the related model name is plural and try to find the model's name
149
-			$related_model_name_singular = \EEH_Inflector::singularize_and_upper( $matches[ 'related_model' ] );
150
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
149
+			$related_model_name_singular = \EEH_Inflector::singularize_and_upper($matches['related_model']);
150
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
151 151
 				//so the word didn't singularize well. Maybe that's just because it's a singular word?
152
-				$related_model_name_singular = \EEH_Inflector::humanize( $matches[ 'related_model' ] );
152
+				$related_model_name_singular = \EEH_Inflector::humanize($matches['related_model']);
153 153
 			}
154
-			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version( $related_model_name_singular ) ) {
154
+			if ( ! $controller->get_model_version_info()->is_model_name_in_this_version($related_model_name_singular)) {
155 155
 				return $controller->send_response(
156 156
 					new \WP_Error(
157 157
 						'endpoint_parsing_error',
158 158
 						sprintf(
159
-							__( 'There is no model for endpoint %s. Please contact event espresso support', 'event_espresso' ),
159
+							__('There is no model for endpoint %s. Please contact event espresso support', 'event_espresso'),
160 160
 							$related_model_name_singular
161 161
 						)
162 162
 					)
@@ -165,13 +165,13 @@  discard block
 block discarded – undo
165 165
 
166 166
 			return $controller->send_response(
167 167
 					$controller->get_entities_from_relation(
168
-						$request->get_param( 'id' ),
169
-						$main_model->related_settings_for( $related_model_name_singular ) ,
168
+						$request->get_param('id'),
169
+						$main_model->related_settings_for($related_model_name_singular),
170 170
 						$request
171 171
 					)
172 172
 				);
173
-		} catch( \Exception $e ) {
174
-			return $controller->send_response( $e );
173
+		} catch (\Exception $e) {
174
+			return $controller->send_response($e);
175 175
 		}
176 176
 	}
177 177
 
@@ -184,28 +184,28 @@  discard block
 block discarded – undo
184 184
 	 * @param \WP_REST_Request $request
185 185
 	 * @return array
186 186
 	 */
187
-	public function get_entities_from_model( $model, $request) {
188
-		$query_params = $this->create_model_query_params( $model, $request->get_params() );
189
-		if( ! Capabilities::current_user_has_partial_access_to( $model, $query_params[ 'caps' ] ) ) {
190
-			$model_name_plural = \EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() );
187
+	public function get_entities_from_model($model, $request) {
188
+		$query_params = $this->create_model_query_params($model, $request->get_params());
189
+		if ( ! Capabilities::current_user_has_partial_access_to($model, $query_params['caps'])) {
190
+			$model_name_plural = \EEH_Inflector::pluralize_and_lower($model->get_this_model_name());
191 191
 			return new \WP_Error(
192
-				sprintf( 'rest_%s_cannot_list', $model_name_plural ),
192
+				sprintf('rest_%s_cannot_list', $model_name_plural),
193 193
 				sprintf(
194
-					__( 'Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso' ),
194
+					__('Sorry, you are not allowed to list %1$s. Missing permissions: %2$s', 'event_espresso'),
195 195
 					$model_name_plural,
196
-					Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] )
196
+					Capabilities::get_missing_permissions_string($model, $query_params['caps'])
197 197
 				),
198
-				array( 'status' => 403 )
198
+				array('status' => 403)
199 199
 			);
200 200
 		}
201
-		if( ! $request->get_header( 'no_rest_headers' ) ) {
202
-			$this->_set_headers_from_query_params( $model, $query_params );
201
+		if ( ! $request->get_header('no_rest_headers')) {
202
+			$this->_set_headers_from_query_params($model, $query_params);
203 203
 		}
204 204
 		/** @type array $results */
205
-		$results = $model->get_all_wpdb_results( $query_params );
205
+		$results = $model->get_all_wpdb_results($query_params);
206 206
 		$nice_results = array( );
207
-		foreach ( $results as $result ) {
208
-			$nice_results[ ] = $this->create_entity_from_wpdb_result(
207
+		foreach ($results as $result) {
208
+			$nice_results[] = $this->create_entity_from_wpdb_result(
209 209
 					$model,
210 210
 					$result,
211 211
 					$request
@@ -226,64 +226,64 @@  discard block
 block discarded – undo
226 226
 	 * @param \WP_REST_Request $request
227 227
 	 * @return array
228 228
 	 */
229
-	public function get_entities_from_relation( $id,  $relation, $request ) {
230
-		$context = $this->validate_context( $request->get_param( 'caps' ));
229
+	public function get_entities_from_relation($id, $relation, $request) {
230
+		$context = $this->validate_context($request->get_param('caps'));
231 231
 		$model = $relation->get_this_model();
232 232
 		$related_model = $relation->get_other_model();
233 233
 		//check if they can access the 1st model object
234
-		$query_params = array( array( $model->primary_key_name() => $id ),'limit' => 1 );
235
-		if( $model instanceof \EEM_Soft_Delete_Base ){
234
+		$query_params = array(array($model->primary_key_name() => $id), 'limit' => 1);
235
+		if ($model instanceof \EEM_Soft_Delete_Base) {
236 236
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
237 237
 		}
238 238
 		$restricted_query_params = $query_params;
239
-		$restricted_query_params[ 'caps' ] = $context;
240
-		$this->_set_debug_info( 'main model query params', $restricted_query_params );
241
-		$this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $related_model, $context ) );
239
+		$restricted_query_params['caps'] = $context;
240
+		$this->_set_debug_info('main model query params', $restricted_query_params);
241
+		$this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($related_model, $context));
242 242
 
243
-		if(
243
+		if (
244 244
 			! (
245
-				Capabilities::current_user_has_partial_access_to( $related_model, $context )
246
-				&& $model->exists( $restricted_query_params )
245
+				Capabilities::current_user_has_partial_access_to($related_model, $context)
246
+				&& $model->exists($restricted_query_params)
247 247
 			)
248
-		){
249
-			if( $relation instanceof \EE_Belongs_To_Relation ) {
250
-				$related_model_name_maybe_plural = strtolower( $related_model->get_this_model_name() );
251
-			}else{
252
-				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower( $related_model->get_this_model_name() );
248
+		) {
249
+			if ($relation instanceof \EE_Belongs_To_Relation) {
250
+				$related_model_name_maybe_plural = strtolower($related_model->get_this_model_name());
251
+			} else {
252
+				$related_model_name_maybe_plural = \EEH_Inflector::pluralize_and_lower($related_model->get_this_model_name());
253 253
 			}
254 254
 			return new \WP_Error(
255
-				sprintf( 'rest_%s_cannot_list', $related_model_name_maybe_plural ),
255
+				sprintf('rest_%s_cannot_list', $related_model_name_maybe_plural),
256 256
 				sprintf(
257
-					__(	'Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso' ),
257
+					__('Sorry, you are not allowed to list %1$s related to %2$s. Missing permissions: %3$s', 'event_espresso'),
258 258
 					$related_model_name_maybe_plural,
259 259
 					$relation->get_this_model()->get_this_model_name(),
260 260
 					implode(
261 261
 						',',
262 262
 						array_keys(
263
-							Capabilities::get_missing_permissions( $related_model, $context )
263
+							Capabilities::get_missing_permissions($related_model, $context)
264 264
 						)
265 265
 					)
266 266
 				),
267
-				array( 'status' => 403 )
267
+				array('status' => 403)
268 268
 			);
269 269
 		}
270
-		$query_params = $this->create_model_query_params( $relation->get_other_model(), $request->get_params() );
271
-		$query_params[0][ $relation->get_this_model()->get_this_model_name() . '.' . $relation->get_this_model()->primary_key_name() ] = $id;
272
-		$query_params[ 'default_where_conditions' ] = 'none';
273
-		$query_params[ 'caps' ] = $context;
274
-		if( ! $request->get_header( 'no_rest_headers' ) ) {
275
-			$this->_set_headers_from_query_params( $relation->get_other_model(), $query_params );
270
+		$query_params = $this->create_model_query_params($relation->get_other_model(), $request->get_params());
271
+		$query_params[0][$relation->get_this_model()->get_this_model_name().'.'.$relation->get_this_model()->primary_key_name()] = $id;
272
+		$query_params['default_where_conditions'] = 'none';
273
+		$query_params['caps'] = $context;
274
+		if ( ! $request->get_header('no_rest_headers')) {
275
+			$this->_set_headers_from_query_params($relation->get_other_model(), $query_params);
276 276
 		}
277 277
 		/** @type array $results */
278
-		$results = $relation->get_other_model()->get_all_wpdb_results( $query_params );
278
+		$results = $relation->get_other_model()->get_all_wpdb_results($query_params);
279 279
 		$nice_results = array();
280
-		foreach( $results as $result ) {
280
+		foreach ($results as $result) {
281 281
 			$nice_result = $this->create_entity_from_wpdb_result(
282 282
 				$relation->get_other_model(),
283 283
 				$result,
284 284
 				$request
285 285
 			);
286
-			if( $relation instanceof \EE_HABTM_Relation ) {
286
+			if ($relation instanceof \EE_HABTM_Relation) {
287 287
 				//put the unusual stuff (properties from the HABTM relation) first, and make sure
288 288
 				//if there are conflicts we prefer the properties from the main model
289 289
 				$join_model_result = $this->create_entity_from_wpdb_result(
@@ -291,18 +291,18 @@  discard block
 block discarded – undo
291 291
 					$result,
292 292
 					$request
293 293
 				);
294
-				$joined_result = array_merge( $nice_result, $join_model_result );
294
+				$joined_result = array_merge($nice_result, $join_model_result);
295 295
 				//but keep the meta stuff from the main model
296
-				if( isset( $nice_result['meta'] ) ){
296
+				if (isset($nice_result['meta'])) {
297 297
 					$joined_result['meta'] = $nice_result['meta'];
298 298
 				}
299 299
 				$nice_result = $joined_result;
300 300
 			}
301 301
 			$nice_results[] = $nice_result;
302 302
 		}
303
-		if( $relation instanceof \EE_Belongs_To_Relation ){
304
-			return array_shift( $nice_results );
305
-		}else{
303
+		if ($relation instanceof \EE_Belongs_To_Relation) {
304
+			return array_shift($nice_results);
305
+		} else {
306 306
 			return $nice_results;
307 307
 		}
308 308
 	}
@@ -315,30 +315,30 @@  discard block
 block discarded – undo
315 315
 	 * @param array $query_params
316 316
 	 * @return void
317 317
 	 */
318
-	protected function _set_headers_from_query_params( $model, $query_params ) {
319
-		$this->_set_debug_info( 'model query params', $query_params );
320
-		$this->_set_debug_info( 'missing caps', Capabilities::get_missing_permissions_string( $model, $query_params[ 'caps' ] ) );
318
+	protected function _set_headers_from_query_params($model, $query_params) {
319
+		$this->_set_debug_info('model query params', $query_params);
320
+		$this->_set_debug_info('missing caps', Capabilities::get_missing_permissions_string($model, $query_params['caps']));
321 321
 		//normally the limit to a 2-part array, where the 2nd item is the limit
322
-		if( ! isset( $query_params[ 'limit' ] ) ) {
323
-			$query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit();
322
+		if ( ! isset($query_params['limit'])) {
323
+			$query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit();
324 324
 		}
325
-		if( is_array( $query_params[ 'limit' ] )  ) {
326
-			$limit_parts = $query_params[ 'limit' ];
325
+		if (is_array($query_params['limit'])) {
326
+			$limit_parts = $query_params['limit'];
327 327
 		} else {
328
-			$limit_parts = explode(',', $query_params[ 'limit' ] );
329
-			if( count( $limit_parts ) == 1 ){
330
-				$limit_parts = array(0, $limit_parts[ 0 ] );
328
+			$limit_parts = explode(',', $query_params['limit']);
329
+			if (count($limit_parts) == 1) {
330
+				$limit_parts = array(0, $limit_parts[0]);
331 331
 			}
332 332
 		}
333 333
 		//remove the group by and having parts of the query, as those will
334 334
 		//make the sql query return an array of values, instead of just a single value
335
-		unset( $query_params[ 'group_by' ], $query_params[ 'having' ], $query_params[ 'limit' ] );
336
-		$count = $model->count( $query_params, null, true );
335
+		unset($query_params['group_by'], $query_params['having'], $query_params['limit']);
336
+		$count = $model->count($query_params, null, true);
337 337
 
338
-		$pages = $count / $limit_parts[ 1 ];
339
-		$this->_set_response_header( 'Total', $count, false );
340
-		$this->_set_response_header( 'PageSize', $limit_parts[ 1 ], false );
341
-		$this->_set_response_header( 'TotalPages', ceil( $pages ), false );
338
+		$pages = $count / $limit_parts[1];
339
+		$this->_set_response_header('Total', $count, false);
340
+		$this->_set_response_header('PageSize', $limit_parts[1], false);
341
+		$this->_set_response_header('TotalPages', ceil($pages), false);
342 342
 	}
343 343
 
344 344
 
@@ -351,47 +351,47 @@  discard block
 block discarded – undo
351 351
 	 * @param string $deprecated no longer used
352 352
 	 * @return array ready for being converted into json for sending to client
353 353
 	 */
354
-	public function create_entity_from_wpdb_result( $model, $db_row, $rest_request, $deprecated = null ) {
355
-		if( ! $rest_request instanceof \WP_REST_Request ) {
354
+	public function create_entity_from_wpdb_result($model, $db_row, $rest_request, $deprecated = null) {
355
+		if ( ! $rest_request instanceof \WP_REST_Request) {
356 356
 			//ok so this was called in the old style, where the 3rd arg was
357 357
 			//$include, and the 4th arg was $context
358 358
 			//now setup the request just to avoid fatal errors, although we won't be able
359 359
 			//to truly make use of it because it's kinda devoid of info
360 360
 			$rest_request = new \WP_REST_Request();
361
-			$rest_request->set_param( 'include', $rest_request );
362
-			$rest_request->set_param( 'caps', $deprecated );
361
+			$rest_request->set_param('include', $rest_request);
362
+			$rest_request->set_param('caps', $deprecated);
363 363
 		}
364
-		if( $rest_request->get_param( 'caps' ) == null ) {
365
-			$rest_request->set_param( 'caps', \EEM_Base::caps_read );
364
+		if ($rest_request->get_param('caps') == null) {
365
+			$rest_request->set_param('caps', \EEM_Base::caps_read);
366 366
 		}
367
-		$entity_array = $this->_create_bare_entity_from_wpdb_results( $model, $db_row );
368
-		$entity_array = $this->_add_extra_fields( $model, $db_row, $entity_array );
369
-		$entity_array[ '_links' ] = $this->_get_entity_links( $model, $db_row, $entity_array );
370
-		$entity_array[ '_calculated_fields'] = $this->_get_entity_calculations( $model, $db_row, $rest_request );
371
-		$entity_array = $this->_include_requested_models( $model, $rest_request, $entity_array );
367
+		$entity_array = $this->_create_bare_entity_from_wpdb_results($model, $db_row);
368
+		$entity_array = $this->_add_extra_fields($model, $db_row, $entity_array);
369
+		$entity_array['_links'] = $this->_get_entity_links($model, $db_row, $entity_array);
370
+		$entity_array['_calculated_fields'] = $this->_get_entity_calculations($model, $db_row, $rest_request);
371
+		$entity_array = $this->_include_requested_models($model, $rest_request, $entity_array);
372 372
 		$entity_array = apply_filters(
373 373
 			'FHEE__Read__create_entity_from_wpdb_results__entity_before_inaccessible_field_removal',
374 374
 			$entity_array,
375 375
 			$model,
376
-			$rest_request->get_param( 'caps' ),
376
+			$rest_request->get_param('caps'),
377 377
 			$rest_request,
378 378
 			$this
379 379
 		);
380 380
 		$result_without_inaccessible_fields = Capabilities::filter_out_inaccessible_entity_fields(
381 381
 			$entity_array,
382 382
 			$model,
383
-			$rest_request->get_param( 'caps' ),
383
+			$rest_request->get_param('caps'),
384 384
 			$this->get_model_version_info()
385 385
 		);
386 386
 		$this->_set_debug_info(
387 387
 			'inaccessible fields',
388
-			array_keys( array_diff_key( $entity_array, $result_without_inaccessible_fields ) )
388
+			array_keys(array_diff_key($entity_array, $result_without_inaccessible_fields))
389 389
 		);
390 390
 		return apply_filters(
391 391
 			'FHEE__Read__create_entity_from_wpdb_results__entity_return',
392 392
 			$result_without_inaccessible_fields,
393 393
 			$model,
394
-			$rest_request->get_param( 'caps' )
394
+			$rest_request->get_param('caps')
395 395
 		);
396 396
 	}
397 397
 
@@ -403,38 +403,38 @@  discard block
 block discarded – undo
403 403
 	 * @param array $db_row
404 404
 	 * @return array entity mostly ready for converting to JSON and sending in the response
405 405
 	 */
406
-	protected function _create_bare_entity_from_wpdb_results( \EEM_Base $model, $db_row ) {
407
-		$result = $model->deduce_fields_n_values_from_cols_n_values( $db_row );
408
-		$result = array_intersect_key( $result, $this->get_model_version_info()->fields_on_model_in_this_version( $model ) );
409
-		foreach( $result as $field_name => $raw_field_value ) {
406
+	protected function _create_bare_entity_from_wpdb_results(\EEM_Base $model, $db_row) {
407
+		$result = $model->deduce_fields_n_values_from_cols_n_values($db_row);
408
+		$result = array_intersect_key($result, $this->get_model_version_info()->fields_on_model_in_this_version($model));
409
+		foreach ($result as $field_name => $raw_field_value) {
410 410
 			$field_obj = $model->field_settings_for($field_name);
411
-			$field_value = $field_obj->prepare_for_set_from_db( $raw_field_value );
412
-			if( $this->is_subclass_of_one(  $field_obj, $this->get_model_version_info()->fields_ignored() ) ){
413
-				unset( $result[ $field_name ] );
414
-			}elseif(
415
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_rendered_format() )
416
-			){
417
-				$result[ $field_name ] = array(
418
-					'raw' => $field_obj->prepare_for_get( $field_value ),
419
-					'rendered' => $field_obj->prepare_for_pretty_echoing( $field_value )
411
+			$field_value = $field_obj->prepare_for_set_from_db($raw_field_value);
412
+			if ($this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_ignored())) {
413
+				unset($result[$field_name]);
414
+			}elseif (
415
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_rendered_format())
416
+			) {
417
+				$result[$field_name] = array(
418
+					'raw' => $field_obj->prepare_for_get($field_value),
419
+					'rendered' => $field_obj->prepare_for_pretty_echoing($field_value)
420 420
 				);
421
-			}elseif(
422
-				$this->is_subclass_of_one( $field_obj, $this->get_model_version_info()->fields_that_have_pretty_format() )
423
-			){
424
-				$result[ $field_name ] = array(
425
-					'raw' => $field_obj->prepare_for_get( $field_value ),
426
-					'pretty' => $field_obj->prepare_for_pretty_echoing( $field_value )
421
+			}elseif (
422
+				$this->is_subclass_of_one($field_obj, $this->get_model_version_info()->fields_that_have_pretty_format())
423
+			) {
424
+				$result[$field_name] = array(
425
+					'raw' => $field_obj->prepare_for_get($field_value),
426
+					'pretty' => $field_obj->prepare_for_pretty_echoing($field_value)
427 427
 				);
428
-			} elseif ( $field_obj instanceof \EE_Datetime_Field ) {
429
-				$result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json(
428
+			} elseif ($field_obj instanceof \EE_Datetime_Field) {
429
+				$result[$field_name] = Model_Data_Translator::prepare_field_value_for_json(
430 430
 					$field_obj,
431 431
 					$field_value,
432 432
 					$this->get_model_version_info()->requested_version()
433 433
 				);
434 434
 			} else {
435
-				$result[ $field_name ] = Model_Data_Translator::prepare_field_value_for_json(
435
+				$result[$field_name] = Model_Data_Translator::prepare_field_value_for_json(
436 436
 					$field_obj,
437
-					$field_obj->prepare_for_get( $field_value ),
437
+					$field_obj->prepare_for_get($field_value),
438 438
 					$this->get_model_version_info()->requested_version()
439 439
 				);
440 440
 			}
@@ -449,9 +449,9 @@  discard block
 block discarded – undo
449 449
 	 * @param array $entity_array
450 450
 	 * @return array modified entity
451 451
 	 */
452
-	protected function _add_extra_fields( \EEM_Base $model, $db_row, $entity_array ) {
453
-		if( $model instanceof \EEM_CPT_Base ) {
454
-			$entity_array[ 'link' ] = get_permalink( $db_row[ $model->get_primary_key_field()->get_qualified_column() ] );
452
+	protected function _add_extra_fields(\EEM_Base $model, $db_row, $entity_array) {
453
+		if ($model instanceof \EEM_CPT_Base) {
454
+			$entity_array['link'] = get_permalink($db_row[$model->get_primary_key_field()->get_qualified_column()]);
455 455
 		}
456 456
 		return $entity_array;
457 457
 	}
@@ -465,20 +465,20 @@  discard block
 block discarded – undo
465 465
 	 * @param array $entity_array
466 466
 	 * @return array the _links item in the entity
467 467
 	 */
468
-	protected function _get_entity_links( $model, $db_row, $entity_array ) {
468
+	protected function _get_entity_links($model, $db_row, $entity_array) {
469 469
 		//add basic links
470 470
 		$links = array(
471 471
 			'self' => array(
472 472
 				array(
473 473
 					'href' => $this->get_versioned_link_to(
474
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ]
474
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()]
475 475
 					)
476 476
 				)
477 477
 			),
478 478
 			'collection' => array(
479 479
 				array(
480 480
 					'href' => $this->get_versioned_link_to(
481
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() )
481
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name())
482 482
 					)
483 483
 				)
484 484
 			),
@@ -486,24 +486,24 @@  discard block
 block discarded – undo
486 486
 
487 487
 		//add link to the wp core endpoint, if wp api is active
488 488
 		global $wp_rest_server;
489
-		if( $model instanceof \EEM_CPT_Base &&
489
+		if ($model instanceof \EEM_CPT_Base &&
490 490
 			$wp_rest_server instanceof \WP_REST_Server &&
491
-			$wp_rest_server->get_route_options( '/wp/v2/posts' ) ) {
492
-			$links[ \EED_Core_Rest_Api::ee_api_link_namespace . 'self_wp_post' ] = array(
491
+			$wp_rest_server->get_route_options('/wp/v2/posts')) {
492
+			$links[\EED_Core_Rest_Api::ee_api_link_namespace.'self_wp_post'] = array(
493 493
 				array(
494
-					'href' => rest_url( '/wp/v2/posts/' . $db_row[ $model->get_primary_key_field()->get_qualified_column() ] ),
494
+					'href' => rest_url('/wp/v2/posts/'.$db_row[$model->get_primary_key_field()->get_qualified_column()]),
495 495
 					'single' => true
496 496
 				)
497 497
 			);
498 498
 		}
499 499
 
500 500
 		//add links to related models
501
-		foreach( $this->get_model_version_info()->relation_settings( $model ) as $relation_name => $relation_obj ) {
502
-			$related_model_part = Read::get_related_entity_name( $relation_name, $relation_obj );
503
-			$links[ \EED_Core_Rest_Api::ee_api_link_namespace . $related_model_part ] = array(
501
+		foreach ($this->get_model_version_info()->relation_settings($model) as $relation_name => $relation_obj) {
502
+			$related_model_part = Read::get_related_entity_name($relation_name, $relation_obj);
503
+			$links[\EED_Core_Rest_Api::ee_api_link_namespace.$related_model_part] = array(
504 504
 				array(
505 505
 					'href' => $this->get_versioned_link_to(
506
-						\EEH_Inflector::pluralize_and_lower( $model->get_this_model_name() ) . '/' . $entity_array[ $model->primary_key_name() ] . '/' . $related_model_part
506
+						\EEH_Inflector::pluralize_and_lower($model->get_this_model_name()).'/'.$entity_array[$model->primary_key_name()].'/'.$related_model_part
507 507
 					),
508 508
 					'single' => $relation_obj instanceof \EE_Belongs_To_Relation ? true : false
509 509
 				)
@@ -519,51 +519,51 @@  discard block
 block discarded – undo
519 519
 	 * @param array $entity_array
520 520
 	 * @return array the modified entity
521 521
 	 */
522
-	protected function _include_requested_models( \EEM_Base $model, \WP_REST_Request $rest_request, $entity_array ) {
523
-		$includes_for_this_model = $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'include' ), '' );
524
-		$includes_for_this_model = $this->_remove_model_names_from_array( $includes_for_this_model );
522
+	protected function _include_requested_models(\EEM_Base $model, \WP_REST_Request $rest_request, $entity_array) {
523
+		$includes_for_this_model = $this->explode_and_get_items_prefixed_with($rest_request->get_param('include'), '');
524
+		$includes_for_this_model = $this->_remove_model_names_from_array($includes_for_this_model);
525 525
 		//if they passed in * or didn't specify any includes, return everything
526
-		if( ! in_array( '*', $includes_for_this_model )
527
-			&& ! empty( $includes_for_this_model ) ) {
528
-			if( $model->has_primary_key_field() ) {
526
+		if ( ! in_array('*', $includes_for_this_model)
527
+			&& ! empty($includes_for_this_model)) {
528
+			if ($model->has_primary_key_field()) {
529 529
 				//always include the primary key. ya just gotta know that at least
530 530
 				$includes_for_this_model[] = $model->primary_key_name();
531 531
 			}
532
-			if( $this->explode_and_get_items_prefixed_with( $rest_request->get_param( 'calculate' ), '' ) ) {
532
+			if ($this->explode_and_get_items_prefixed_with($rest_request->get_param('calculate'), '')) {
533 533
 				$includes_for_this_model[] = '_calculated_fields';
534 534
 			}
535
-			$entity_array = array_intersect_key( $entity_array, array_flip( $includes_for_this_model ) );
535
+			$entity_array = array_intersect_key($entity_array, array_flip($includes_for_this_model));
536 536
 		}
537
-		$relation_settings = $this->get_model_version_info()->relation_settings( $model );
538
-		foreach( $relation_settings as $relation_name => $relation_obj ) {
537
+		$relation_settings = $this->get_model_version_info()->relation_settings($model);
538
+		foreach ($relation_settings as $relation_name => $relation_obj) {
539 539
 			$related_fields_to_include = $this->explode_and_get_items_prefixed_with(
540
-				$rest_request->get_param( 'include' ),
540
+				$rest_request->get_param('include'),
541 541
 				$relation_name
542 542
 			);
543 543
 			$related_fields_to_calculate = $this->explode_and_get_items_prefixed_with(
544
-				$rest_request->get_param( 'calculate' ),
544
+				$rest_request->get_param('calculate'),
545 545
 				$relation_name
546 546
 			);
547 547
 			//did they specify they wanted to include a related model, or
548 548
 			//specific fields from a related model?
549 549
 			//or did they specify to calculate a field from a related model?
550
-			if( $related_fields_to_include || $related_fields_to_calculate ) {
550
+			if ($related_fields_to_include || $related_fields_to_calculate) {
551 551
 				//if so, we should include at least some part of the related model
552 552
 				$pretend_related_request = new \WP_REST_Request();
553 553
 				$pretend_related_request->set_query_params(
554 554
 					array(
555
-						'caps' => $rest_request->get_param( 'caps' ),
555
+						'caps' => $rest_request->get_param('caps'),
556 556
 						'include' => $related_fields_to_include,
557 557
 						'calculate' => $related_fields_to_calculate,
558 558
 					)
559 559
 				);
560
-				$pretend_related_request->add_header( 'no_rest_headers', true );
560
+				$pretend_related_request->add_header('no_rest_headers', true);
561 561
 				$related_results = $this->get_entities_from_relation(
562
-					$entity_array[ $model->primary_key_name() ],
562
+					$entity_array[$model->primary_key_name()],
563 563
 					$relation_obj,
564 564
 					$pretend_related_request
565 565
 				);
566
-				$entity_array[ Read::get_related_entity_name( $relation_name, $relation_obj ) ] = $related_results instanceof \WP_Error
566
+				$entity_array[Read::get_related_entity_name($relation_name, $relation_obj)] = $related_results instanceof \WP_Error
567 567
 					? null
568 568
 					: $related_results;
569 569
 			}
@@ -577,8 +577,8 @@  discard block
 block discarded – undo
577 577
 	 * @param array $arr
578 578
 	 * @return array
579 579
 	 */
580
-	private function _remove_model_names_from_array( $arr ) {
581
-		return array_diff( $arr, array_keys( \EE_Registry::instance()->non_abstract_db_models ) );
580
+	private function _remove_model_names_from_array($arr) {
581
+		return array_diff($arr, array_keys(\EE_Registry::instance()->non_abstract_db_models));
582 582
 	}
583 583
 	/**
584 584
 	 * Gets the calculated fields for the response
@@ -588,15 +588,15 @@  discard block
 block discarded – undo
588 588
 	 * @param \WP_REST_Request $rest_request
589 589
 	 * @return array the _calculations item in the entity
590 590
 	 */
591
-	protected function _get_entity_calculations( $model, $wpdb_row, $rest_request ) {
591
+	protected function _get_entity_calculations($model, $wpdb_row, $rest_request) {
592 592
 		$calculated_fields = $this->explode_and_get_items_prefixed_with(
593
-			$rest_request->get_param( 'calculate' ),
593
+			$rest_request->get_param('calculate'),
594 594
 			''
595 595
 		);
596 596
 		//note: setting calculate=* doesn't do anything
597 597
 		$calculated_fields_to_return = new \stdClass();
598
-		foreach( $calculated_fields as $field_to_calculate ) {
599
-			try{
598
+		foreach ($calculated_fields as $field_to_calculate) {
599
+			try {
600 600
 				$calculated_fields_to_return->$field_to_calculate = Model_Data_Translator::prepare_field_value_for_json(
601 601
 					null,
602 602
 					$this->_fields_calculator->retrieve_calculated_field_value(
@@ -608,10 +608,10 @@  discard block
 block discarded – undo
608 608
 					),
609 609
 					$this->get_model_version_info()->requested_version()
610 610
 				);
611
-			} catch( Rest_Exception $e ) {
611
+			} catch (Rest_Exception $e) {
612 612
 				//if we don't have permission to read it, just leave it out. but let devs know about the problem
613 613
 				$this->_set_response_header(
614
-					'Notices-Field-Calculation-Errors[' . $e->get_string_code() . '][' . $model->get_this_model_name() . '][' . $field_to_calculate . ']',
614
+					'Notices-Field-Calculation-Errors['.$e->get_string_code().']['.$model->get_this_model_name().']['.$field_to_calculate.']',
615 615
 					$e->getMessage(),
616 616
 					true
617 617
 				);
@@ -625,7 +625,7 @@  discard block
 block discarded – undo
625 625
 	 * @param string $link_part_after_version_and_slash eg "events/10/datetimes"
626 626
 	 * @return string url eg "http://mysite.com/wp-json/ee/v4.6/events/10/datetimes"
627 627
 	 */
628
-	public function get_versioned_link_to( $link_part_after_version_and_slash ) {
628
+	public function get_versioned_link_to($link_part_after_version_and_slash) {
629 629
 		return rest_url(
630 630
 			\EED_Core_Rest_Api::ee_api_namespace
631 631
 			. $this->get_model_version_info()->requested_version()
@@ -641,11 +641,11 @@  discard block
 block discarded – undo
641 641
 	 * @param \EE_Model_Relation_Base $relation_obj
642 642
 	 * @return string
643 643
 	 */
644
-	public static function get_related_entity_name( $relation_name, $relation_obj ){
645
-		if( $relation_obj instanceof \EE_Belongs_To_Relation ) {
646
-			return strtolower( $relation_name );
647
-		}else{
648
-			return \EEH_Inflector::pluralize_and_lower( $relation_name );
644
+	public static function get_related_entity_name($relation_name, $relation_obj) {
645
+		if ($relation_obj instanceof \EE_Belongs_To_Relation) {
646
+			return strtolower($relation_name);
647
+		} else {
648
+			return \EEH_Inflector::pluralize_and_lower($relation_name);
649 649
 		}
650 650
 	}
651 651
 
@@ -658,43 +658,43 @@  discard block
 block discarded – undo
658 658
 	 * @param \WP_REST_Request $request
659 659
 	 * @return array
660 660
 	 */
661
-	public function get_entity_from_model( $model, $request ) {
662
-		$query_params = array( array( $model->primary_key_name() => $request->get_param( 'id' ) ),'limit' => 1);
663
-		if( $model instanceof \EEM_Soft_Delete_Base ){
661
+	public function get_entity_from_model($model, $request) {
662
+		$query_params = array(array($model->primary_key_name() => $request->get_param('id')), 'limit' => 1);
663
+		if ($model instanceof \EEM_Soft_Delete_Base) {
664 664
 			$query_params = $model->alter_query_params_so_deleted_and_undeleted_items_included($query_params);
665 665
 		}
666 666
 		$restricted_query_params = $query_params;
667
-		$restricted_query_params[ 'caps' ] =  $this->validate_context(  $request->get_param( 'caps' ) );
668
-		$this->_set_debug_info( 'model query params', $restricted_query_params );
669
-		$model_rows = $model->get_all_wpdb_results( $restricted_query_params );
670
-		if ( ! empty ( $model_rows ) ) {
667
+		$restricted_query_params['caps'] = $this->validate_context($request->get_param('caps'));
668
+		$this->_set_debug_info('model query params', $restricted_query_params);
669
+		$model_rows = $model->get_all_wpdb_results($restricted_query_params);
670
+		if ( ! empty ($model_rows)) {
671 671
 			return $this->create_entity_from_wpdb_result(
672 672
 				$model,
673
-				array_shift( $model_rows ),
673
+				array_shift($model_rows),
674 674
 				$request );
675 675
 		} else {
676 676
 			//ok let's test to see if we WOULD have found it, had we not had restrictions from missing capabilities
677
-			$lowercase_model_name = strtolower( $model->get_this_model_name() );
678
-			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results( $query_params );
679
-			if( ! empty( $model_rows_found_sans_restrictions ) ) {
677
+			$lowercase_model_name = strtolower($model->get_this_model_name());
678
+			$model_rows_found_sans_restrictions = $model->get_all_wpdb_results($query_params);
679
+			if ( ! empty($model_rows_found_sans_restrictions)) {
680 680
 				//you got shafted- it existed but we didn't want to tell you!
681 681
 				return new \WP_Error(
682 682
 					'rest_user_cannot_read',
683 683
 					sprintf(
684
-						__( 'Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso' ),
685
-						strtolower( $model->get_this_model_name() ),
684
+						__('Sorry, you cannot read this %1$s. Missing permissions are: %2$s', 'event_espresso'),
685
+						strtolower($model->get_this_model_name()),
686 686
 						Capabilities::get_missing_permissions_string(
687 687
 							$model,
688
-							$this->validate_context( $request->get_param( 'caps' ) ) )
688
+							$this->validate_context($request->get_param('caps')) )
689 689
 					),
690
-					array( 'status' => 403 )
690
+					array('status' => 403)
691 691
 				);
692 692
 			} else {
693 693
 				//it's not you. It just doesn't exist
694 694
 				return new \WP_Error(
695
-					sprintf( 'rest_%s_invalid_id', $lowercase_model_name ),
696
-					sprintf( __( 'Invalid %s ID.', 'event_espresso' ), $lowercase_model_name ),
697
-					array( 'status' => 404 )
695
+					sprintf('rest_%s_invalid_id', $lowercase_model_name),
696
+					sprintf(__('Invalid %s ID.', 'event_espresso'), $lowercase_model_name),
697
+					array('status' => 404)
698 698
 				);
699 699
 			}
700 700
 		}
@@ -707,14 +707,14 @@  discard block
 block discarded – undo
707 707
 	 * @param string $context
708 708
 	 * @return string array key of EEM_Base::cap_contexts_to_cap_action_map()
709 709
 	 */
710
-	public function validate_context( $context ) {
711
-		if( ! $context ) {
710
+	public function validate_context($context) {
711
+		if ( ! $context) {
712 712
 			$context = \EEM_Base::caps_read;
713 713
 		}
714 714
 		$valid_contexts = \EEM_Base::valid_cap_contexts();
715
-		if( in_array( $context, $valid_contexts )  ){
715
+		if (in_array($context, $valid_contexts)) {
716 716
 			return $context;
717
-		}else{
717
+		} else {
718 718
 			return \EEM_Base::caps_read;
719 719
 		}
720 720
 	}
@@ -733,77 +733,77 @@  discard block
 block discarded – undo
733 733
 	 *                          that absolutely no results should be returned
734 734
 	 * @throws \EE_Error
735 735
 	 */
736
-	public function create_model_query_params( $model, $query_parameters ) {
736
+	public function create_model_query_params($model, $query_parameters) {
737 737
 		$model_query_params = array( );
738
-		if ( isset( $query_parameters[ 'where' ] ) ) {
739
-			$model_query_params[ 0 ] = Model_Data_Translator::prepare_conditions_query_params_for_models(
740
-				$query_parameters[ 'where' ],
738
+		if (isset($query_parameters['where'])) {
739
+			$model_query_params[0] = Model_Data_Translator::prepare_conditions_query_params_for_models(
740
+				$query_parameters['where'],
741 741
 				$model,
742 742
 				$this->get_model_version_info()->requested_version()
743 743
 			);
744 744
 		}
745
-		if ( isset( $query_parameters[ 'order_by' ] ) ) {
746
-			$order_by = $query_parameters[ 'order_by' ];
747
-		} elseif ( isset( $query_parameters[ 'orderby' ] ) ) {
748
-			$order_by = $query_parameters[ 'orderby' ];
749
-		}else{
745
+		if (isset($query_parameters['order_by'])) {
746
+			$order_by = $query_parameters['order_by'];
747
+		} elseif (isset($query_parameters['orderby'])) {
748
+			$order_by = $query_parameters['orderby'];
749
+		} else {
750 750
 			$order_by = null;
751 751
 		}
752
-		if( $order_by !== null ){
753
-			$model_query_params[ 'order_by' ] =  $order_by;
752
+		if ($order_by !== null) {
753
+			$model_query_params['order_by'] = $order_by;
754 754
 		}
755
-		if ( isset( $query_parameters[ 'group_by' ] ) ) {
756
-			$group_by = $query_parameters[ 'group_by' ];
757
-		} elseif ( isset( $query_parameters[ 'groupby' ] ) ) {
758
-			$group_by = $query_parameters[ 'groupby' ];
759
-		}else{
760
-			$group_by = array_keys( $model->get_combined_primary_key_fields() );
755
+		if (isset($query_parameters['group_by'])) {
756
+			$group_by = $query_parameters['group_by'];
757
+		} elseif (isset($query_parameters['groupby'])) {
758
+			$group_by = $query_parameters['groupby'];
759
+		} else {
760
+			$group_by = array_keys($model->get_combined_primary_key_fields());
761 761
 		}
762
-		if( $group_by !== null ){
763
-			$model_query_params[ 'group_by' ] = $group_by;
762
+		if ($group_by !== null) {
763
+			$model_query_params['group_by'] = $group_by;
764 764
 		}
765
-		if ( isset( $query_parameters[ 'having' ] ) ) {
766
-			$model_query_params[ 'having' ] = Model_Data_Translator::prepare_conditions_query_params_for_models(
767
-				$query_parameters[ 'having' ],
765
+		if (isset($query_parameters['having'])) {
766
+			$model_query_params['having'] = Model_Data_Translator::prepare_conditions_query_params_for_models(
767
+				$query_parameters['having'],
768 768
 				$model,
769 769
 				$this->get_model_version_info()->requested_version()
770 770
 			);
771 771
 		}
772
-		if ( isset( $query_parameters[ 'order' ] ) ) {
773
-			$model_query_params[ 'order' ] = $query_parameters[ 'order' ];
772
+		if (isset($query_parameters['order'])) {
773
+			$model_query_params['order'] = $query_parameters['order'];
774 774
 		}
775
-		if ( isset( $query_parameters[ 'mine' ] ) ){
776
-			$model_query_params = $model->alter_query_params_to_only_include_mine( $model_query_params );
775
+		if (isset($query_parameters['mine'])) {
776
+			$model_query_params = $model->alter_query_params_to_only_include_mine($model_query_params);
777 777
 		}
778
-		if( isset( $query_parameters[ 'limit' ] ) ) {
778
+		if (isset($query_parameters['limit'])) {
779 779
 			//limit should be either a string like '23' or '23,43', or an array with two items in it
780
-			if( ! is_array( $query_parameters[ 'limit' ] ) ) {
781
-				$limit_array = explode(',', (string)$query_parameters['limit']);
782
-			}else {
783
-				$limit_array = $query_parameters[ 'limit' ];
780
+			if ( ! is_array($query_parameters['limit'])) {
781
+				$limit_array = explode(',', (string) $query_parameters['limit']);
782
+			} else {
783
+				$limit_array = $query_parameters['limit'];
784 784
 			}
785 785
 			$sanitized_limit = array();
786
-			foreach( $limit_array as $key => $limit_part ) {
787
-				if( $this->_debug_mode && ( ! is_numeric( $limit_part ) || count( $sanitized_limit ) > 2 ) ) {
786
+			foreach ($limit_array as $key => $limit_part) {
787
+				if ($this->_debug_mode && ( ! is_numeric($limit_part) || count($sanitized_limit) > 2)) {
788 788
 					throw new \EE_Error(
789 789
 						sprintf(
790
-							__( 'An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso' ),
791
-							json_encode( $query_parameters[ 'limit' ] )
790
+							__('An invalid limit filter was provided. It was: %s. If the EE4 JSON REST API weren\'t in debug mode, this message would not appear.', 'event_espresso'),
791
+							json_encode($query_parameters['limit'])
792 792
 						)
793 793
 					);
794 794
 				}
795
-				$sanitized_limit[] = (int)$limit_part;
795
+				$sanitized_limit[] = (int) $limit_part;
796 796
 			}
797
-			$model_query_params[ 'limit' ] = implode( ',', $sanitized_limit );
798
-		}else{
799
-			$model_query_params[ 'limit' ] = \EED_Core_Rest_Api::get_default_query_limit();
797
+			$model_query_params['limit'] = implode(',', $sanitized_limit);
798
+		} else {
799
+			$model_query_params['limit'] = \EED_Core_Rest_Api::get_default_query_limit();
800 800
 		}
801
-		if( isset( $query_parameters[ 'caps' ] ) ) {
802
-			$model_query_params[ 'caps' ] = $this->validate_context( $query_parameters[ 'caps' ] );
803
-		}else{
804
-			$model_query_params[ 'caps' ] = \EEM_Base::caps_read;
801
+		if (isset($query_parameters['caps'])) {
802
+			$model_query_params['caps'] = $this->validate_context($query_parameters['caps']);
803
+		} else {
804
+			$model_query_params['caps'] = \EEM_Base::caps_read;
805 805
 		}
806
-		return apply_filters( 'FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model );
806
+		return apply_filters('FHEE__Read__create_model_query_params', $model_query_params, $query_parameters, $model);
807 807
 	}
808 808
 
809 809
 
@@ -815,13 +815,13 @@  discard block
 block discarded – undo
815 815
 	 * @param array     $query_params sub-array from @see EEM_Base::get_all()
816 816
 	 * @return array
817 817
 	 */
818
-	public function prepare_rest_query_params_key_for_models( $model,  $query_params ) {
818
+	public function prepare_rest_query_params_key_for_models($model, $query_params) {
819 819
 		$model_ready_query_params = array();
820
-		foreach( $query_params as $key => $value ) {
821
-			if( is_array( $value ) ) {
822
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_key_for_models( $model, $value );
823
-			}else{
824
-				$model_ready_query_params[ $key ] = $value;
820
+		foreach ($query_params as $key => $value) {
821
+			if (is_array($value)) {
822
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_key_for_models($model, $value);
823
+			} else {
824
+				$model_ready_query_params[$key] = $value;
825 825
 			}
826 826
 		}
827 827
 		return $model_ready_query_params;
@@ -835,13 +835,13 @@  discard block
 block discarded – undo
835 835
 	 * @param $query_params
836 836
 	 * @return array
837 837
 	 */
838
-	public function prepare_rest_query_params_values_for_models( $model, $query_params ) {
838
+	public function prepare_rest_query_params_values_for_models($model, $query_params) {
839 839
 		$model_ready_query_params = array();
840
-		foreach( $query_params as $key => $value ) {
841
-			if( is_array( $value ) ) {
842
-				$model_ready_query_params[ $key ] = $this->prepare_rest_query_params_values_for_models( $model, $value );
840
+		foreach ($query_params as $key => $value) {
841
+			if (is_array($value)) {
842
+				$model_ready_query_params[$key] = $this->prepare_rest_query_params_values_for_models($model, $value);
843 843
 			} else {
844
-				$model_ready_query_params[ $key ] = $value;
844
+				$model_ready_query_params[$key] = $value;
845 845
 			}
846 846
 		}
847 847
 		return $model_ready_query_params;
@@ -856,33 +856,33 @@  discard block
 block discarded – undo
856 856
 	 * we only return strings starting with that and a period; if no prefix was specified
857 857
 	 * we return all items containing NO periods
858 858
 	 */
859
-	public function explode_and_get_items_prefixed_with( $string_to_explode, $prefix ) {
860
-		if( is_string( $string_to_explode ) ) {
861
-			$exploded_contents = explode( ',', $string_to_explode );
862
-		} else if( is_array( $string_to_explode ) ) {
859
+	public function explode_and_get_items_prefixed_with($string_to_explode, $prefix) {
860
+		if (is_string($string_to_explode)) {
861
+			$exploded_contents = explode(',', $string_to_explode);
862
+		} else if (is_array($string_to_explode)) {
863 863
 			$exploded_contents = $string_to_explode;
864 864
 		} else {
865 865
 			$exploded_contents = array();
866 866
 		}
867 867
 		//if the string was empty, we want an empty array
868
-		$exploded_contents = array_filter( $exploded_contents );
868
+		$exploded_contents = array_filter($exploded_contents);
869 869
 		$contents_with_prefix = array();
870
-		foreach( $exploded_contents as $item ) {
871
-			$item = trim( $item );
870
+		foreach ($exploded_contents as $item) {
871
+			$item = trim($item);
872 872
 			//if no prefix was provided, so we look for items with no "." in them
873
-			if( ! $prefix ) {
873
+			if ( ! $prefix) {
874 874
 				//does this item have a period?
875
-				if( strpos( $item, '.' ) === false ) {
875
+				if (strpos($item, '.') === false) {
876 876
 					//if not, then its what we're looking for
877 877
 					$contents_with_prefix[] = $item;
878 878
 				}
879
-			} else if( strpos( $item, $prefix . '.' ) === 0 ) {
879
+			} else if (strpos($item, $prefix.'.') === 0) {
880 880
 				//this item has the prefix and a period, grab it
881 881
 				$contents_with_prefix[] = substr(
882 882
 					$item,
883
-					strpos( $item, $prefix . '.' ) + strlen( $prefix . '.' )
883
+					strpos($item, $prefix.'.') + strlen($prefix.'.')
884 884
 					);
885
-			} else if( $item === $prefix ) {
885
+			} else if ($item === $prefix) {
886 886
 				//this item is JUST the prefix
887 887
 				//so let's grab everything after, which is a blank string
888 888
 				$contents_with_prefix[] = '';
@@ -905,33 +905,33 @@  discard block
 block discarded – undo
905 905
 	 * the fields for that model, with the model's name removed from each.
906 906
 	 * If $include_string was blank or '*' returns an empty array
907 907
 	 */
908
-	public function extract_includes_for_this_model( $include_string, $model_name = null ) {
909
-		if( is_array( $include_string ) ) {
910
-			$include_string = implode( ',', $include_string );
908
+	public function extract_includes_for_this_model($include_string, $model_name = null) {
909
+		if (is_array($include_string)) {
910
+			$include_string = implode(',', $include_string);
911 911
 		}
912
-		if( $include_string === '*' || $include_string === '' ) {
912
+		if ($include_string === '*' || $include_string === '') {
913 913
 			return array();
914 914
 		}
915
-		$includes = explode( ',', $include_string );
915
+		$includes = explode(',', $include_string);
916 916
 		$extracted_fields_to_include = array();
917
-		if( $model_name ){
918
-			foreach( $includes as $field_to_include ) {
919
-				$field_to_include = trim( $field_to_include );
920
-				if( strpos( $field_to_include, $model_name . '.' ) === 0 ) {
917
+		if ($model_name) {
918
+			foreach ($includes as $field_to_include) {
919
+				$field_to_include = trim($field_to_include);
920
+				if (strpos($field_to_include, $model_name.'.') === 0) {
921 921
 					//found the model name at the exact start
922
-					$field_sans_model_name = str_replace( $model_name . '.', '', $field_to_include );
922
+					$field_sans_model_name = str_replace($model_name.'.', '', $field_to_include);
923 923
 					$extracted_fields_to_include[] = $field_sans_model_name;
924
-				}elseif( $field_to_include == $model_name ){
924
+				}elseif ($field_to_include == $model_name) {
925 925
 					$extracted_fields_to_include[] = '*';
926 926
 				}
927 927
 			}
928
-		}else{
928
+		} else {
929 929
 			//look for ones with no period
930
-			foreach( $includes as $field_to_include ) {
931
-				$field_to_include = trim( $field_to_include );
930
+			foreach ($includes as $field_to_include) {
931
+				$field_to_include = trim($field_to_include);
932 932
 				if (
933
-					strpos( $field_to_include, '.' ) === false
934
-					&& ! $this->get_model_version_info()->is_model_name_in_this_version( $field_to_include )
933
+					strpos($field_to_include, '.') === false
934
+					&& ! $this->get_model_version_info()->is_model_name_in_this_version($field_to_include)
935 935
 				) {
936 936
 					$extracted_fields_to_include[] = $field_to_include;
937 937
 				}
Please login to merge, or discard this patch.