@@ -517,7 +517,7 @@ discard block |
||
517 | 517 | * This prepares the datetime for internal usage as a PHP DateTime object OR null (if nullable is |
518 | 518 | * allowed) |
519 | 519 | * @param string $datetime_string mysql timestamp in UTC |
520 | - * @return mixed null | DateTime |
|
520 | + * @return null|DbSafeDateTime null | DateTime |
|
521 | 521 | */ |
522 | 522 | public function prepare_for_set_from_db( $datetime_string ) { |
523 | 523 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
@@ -653,7 +653,7 @@ discard block |
||
653 | 653 | * |
654 | 654 | * @param \DateTimeZone $DateTimeZone |
655 | 655 | * @param int $time |
656 | - * @return mixed |
|
656 | + * @return string |
|
657 | 657 | */ |
658 | 658 | public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
659 | 659 | $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php use EventEspresso\core\domain\entities\DbSafeDateTime; |
2 | 2 | |
3 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
4 | - exit( 'No direct script access allowed' ); |
|
3 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
4 | + exit('No direct script access allowed'); |
|
5 | 5 | } |
6 | 6 | /** |
7 | 7 | * EE_Datetime_Field |
@@ -120,15 +120,15 @@ discard block |
||
120 | 120 | * @param string $pretty_date_format |
121 | 121 | * @param string $pretty_time_format |
122 | 122 | */ |
123 | - public function __construct( $table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '' ){ |
|
123 | + public function __construct($table_column, $nice_name, $nullable, $default_value, $timezone_string = '', $date_format = '', $time_format = '', $pretty_date_format = '', $pretty_time_format = '') { |
|
124 | 124 | |
125 | - $this->_date_format = ! empty( $date_format ) ? $date_format : get_option('date_format'); |
|
126 | - $this->_time_format = ! empty( $time_format ) ? $time_format : get_option('time_format'); |
|
127 | - $this->_pretty_date_format = ! empty( $pretty_date_format ) ? $pretty_date_format : get_option('date_format'); |
|
128 | - $this->_pretty_time_format = ! empty( $pretty_time_format ) ? $pretty_time_format : get_option('time_format'); |
|
125 | + $this->_date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
126 | + $this->_time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
127 | + $this->_pretty_date_format = ! empty($pretty_date_format) ? $pretty_date_format : get_option('date_format'); |
|
128 | + $this->_pretty_time_format = ! empty($pretty_time_format) ? $pretty_time_format : get_option('time_format'); |
|
129 | 129 | |
130 | - parent::__construct( $table_column, $nice_name, $nullable, $default_value ); |
|
131 | - $this->set_timezone( $timezone_string ); |
|
130 | + parent::__construct($table_column, $nice_name, $nullable, $default_value); |
|
131 | + $this->set_timezone($timezone_string); |
|
132 | 132 | |
133 | 133 | } |
134 | 134 | |
@@ -147,7 +147,7 @@ discard block |
||
147 | 147 | * @return DateTimeZone |
148 | 148 | */ |
149 | 149 | public function get_UTC_DateTimeZone() { |
150 | - return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string( 'UTC' ); |
|
150 | + return $this->_UTC_DateTimeZone instanceof DateTimeZone ? $this->_UTC_DateTimeZone : $this->_create_timezone_object_from_timezone_string('UTC'); |
|
151 | 151 | } |
152 | 152 | |
153 | 153 | |
@@ -156,7 +156,7 @@ discard block |
||
156 | 156 | * @return DateTimeZone |
157 | 157 | */ |
158 | 158 | public function get_blog_DateTimeZone() { |
159 | - return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string( '' ); |
|
159 | + return $this->_blog_DateTimeZone instanceof DateTimeZone ? $this->_blog_DateTimeZone : $this->_create_timezone_object_from_timezone_string(''); |
|
160 | 160 | } |
161 | 161 | |
162 | 162 | |
@@ -166,8 +166,8 @@ discard block |
||
166 | 166 | * @param string|int $value_inputted_for_field_on_model_object could be a string formatted date time or int unix timestamp |
167 | 167 | * @return DateTime |
168 | 168 | */ |
169 | - public function prepare_for_set( $value_inputted_for_field_on_model_object ) { |
|
170 | - return $this->_get_date_object( $value_inputted_for_field_on_model_object ); |
|
169 | + public function prepare_for_set($value_inputted_for_field_on_model_object) { |
|
170 | + return $this->_get_date_object($value_inputted_for_field_on_model_object); |
|
171 | 171 | } |
172 | 172 | |
173 | 173 | |
@@ -183,9 +183,9 @@ discard block |
||
183 | 183 | * @param bool $pretty If we're returning the pretty formats or standard format string. |
184 | 184 | * @return string The final assembled format string. |
185 | 185 | */ |
186 | - protected function _get_date_time_output( $pretty = FALSE ) { |
|
186 | + protected function _get_date_time_output($pretty = FALSE) { |
|
187 | 187 | |
188 | - switch ( $this->_date_time_output ) { |
|
188 | + switch ($this->_date_time_output) { |
|
189 | 189 | case 'time' : |
190 | 190 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
191 | 191 | break; |
@@ -195,7 +195,7 @@ discard block |
||
195 | 195 | break; |
196 | 196 | |
197 | 197 | default : |
198 | - return $pretty ? $this->_pretty_date_format . ' ' . $this->_pretty_time_format : $this->_date_format . ' ' . $this->_time_format; |
|
198 | + return $pretty ? $this->_pretty_date_format.' '.$this->_pretty_time_format : $this->_date_format.' '.$this->_time_format; |
|
199 | 199 | } |
200 | 200 | } |
201 | 201 | |
@@ -209,7 +209,7 @@ discard block |
||
209 | 209 | * @param string $what acceptable values are 'time' or 'date'. Any other value will be set but will always result in both 'date' and 'time' being returned. |
210 | 210 | * @return void |
211 | 211 | */ |
212 | - public function set_date_time_output( $what = NULL ) { |
|
212 | + public function set_date_time_output($what = NULL) { |
|
213 | 213 | $this->_date_time_output = $what; |
214 | 214 | } |
215 | 215 | |
@@ -225,15 +225,15 @@ discard block |
||
225 | 225 | * @param string $timezone_string A valid timezone string as described by @link http://www.php.net/manual/en/timezones.php |
226 | 226 | * @return void |
227 | 227 | */ |
228 | - public function set_timezone( $timezone_string ) { |
|
229 | - if( empty( $timezone_string ) && $this->_timezone_string != NULL ){ |
|
228 | + public function set_timezone($timezone_string) { |
|
229 | + if (empty($timezone_string) && $this->_timezone_string != NULL) { |
|
230 | 230 | // leave the timezone AS-IS if we already have one and |
231 | 231 | // the function arg didn't provide one |
232 | 232 | return; |
233 | 233 | } |
234 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
235 | - $this->_timezone_string = ! empty( $timezone_string ) ? $timezone_string : 'UTC'; |
|
236 | - $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string( $this->_timezone_string ); |
|
234 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
235 | + $this->_timezone_string = ! empty($timezone_string) ? $timezone_string : 'UTC'; |
|
236 | + $this->_DateTimeZone = $this->_create_timezone_object_from_timezone_string($this->_timezone_string); |
|
237 | 237 | } |
238 | 238 | |
239 | 239 | |
@@ -245,8 +245,8 @@ discard block |
||
245 | 245 | * @param string $timezone_string |
246 | 246 | * @return \DateTimeZone |
247 | 247 | */ |
248 | - protected function _create_timezone_object_from_timezone_string( $timezone_string = '' ) { |
|
249 | - return new DateTimeZone( EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ) ); |
|
248 | + protected function _create_timezone_object_from_timezone_string($timezone_string = '') { |
|
249 | + return new DateTimeZone(EEH_DTT_Helper::get_valid_timezone_string($timezone_string)); |
|
250 | 250 | } |
251 | 251 | |
252 | 252 | |
@@ -271,8 +271,8 @@ discard block |
||
271 | 271 | * @param bool $pretty Whether to set pretty format or not. |
272 | 272 | * @return void |
273 | 273 | */ |
274 | - public function set_date_format( $format, $pretty = false ) { |
|
275 | - if ( $pretty ) { |
|
274 | + public function set_date_format($format, $pretty = false) { |
|
275 | + if ($pretty) { |
|
276 | 276 | $this->_pretty_date_format = $format; |
277 | 277 | } else { |
278 | 278 | $this->_date_format = $format; |
@@ -287,7 +287,7 @@ discard block |
||
287 | 287 | * @param bool $pretty Whether to get pretty format or not. |
288 | 288 | * @return string |
289 | 289 | */ |
290 | - public function get_date_format( $pretty = false ) { |
|
290 | + public function get_date_format($pretty = false) { |
|
291 | 291 | return $pretty ? $this->_pretty_date_format : $this->_date_format; |
292 | 292 | } |
293 | 293 | |
@@ -302,8 +302,8 @@ discard block |
||
302 | 302 | * @param bool $pretty Whether to set pretty format or not. |
303 | 303 | * @return void |
304 | 304 | */ |
305 | - public function set_time_format( $format, $pretty = false ) { |
|
306 | - if ( $pretty ) { |
|
305 | + public function set_time_format($format, $pretty = false) { |
|
306 | + if ($pretty) { |
|
307 | 307 | $this->_pretty_time_format = $format; |
308 | 308 | } else { |
309 | 309 | $this->_time_format = $format; |
@@ -318,7 +318,7 @@ discard block |
||
318 | 318 | * @param bool $pretty Whether to get pretty format or not. |
319 | 319 | * @return string |
320 | 320 | */ |
321 | - public function get_time_format( $pretty = false ) { |
|
321 | + public function get_time_format($pretty = false) { |
|
322 | 322 | return $pretty ? $this->_pretty_time_format : $this->_time_format; |
323 | 323 | } |
324 | 324 | |
@@ -333,7 +333,7 @@ discard block |
||
333 | 333 | * @param string $format a new pretty date format (corresponding to formats accepted by PHP date() function) |
334 | 334 | * @return void |
335 | 335 | */ |
336 | - public function set_pretty_date_format( $format ) { |
|
336 | + public function set_pretty_date_format($format) { |
|
337 | 337 | $this->_pretty_date_format = $format; |
338 | 338 | } |
339 | 339 | |
@@ -350,7 +350,7 @@ discard block |
||
350 | 350 | * @param string $format a new pretty time format (corresponding to formats accepted by PHP date() function) |
351 | 351 | * @return void |
352 | 352 | */ |
353 | - public function set_pretty_time_format( $format ) { |
|
353 | + public function set_pretty_time_format($format) { |
|
354 | 354 | $this->_pretty_time_format = $format; |
355 | 355 | } |
356 | 356 | |
@@ -362,9 +362,9 @@ discard block |
||
362 | 362 | * @param DateTime $current current DateTime object for the datetime field |
363 | 363 | * @return DateTime |
364 | 364 | */ |
365 | - public function prepare_for_set_with_new_time( $time_to_set_string, DateTime $current ){ |
|
365 | + public function prepare_for_set_with_new_time($time_to_set_string, DateTime $current) { |
|
366 | 366 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
367 | - if ( $time_to_set_string instanceof DateTime ) { |
|
367 | + if ($time_to_set_string instanceof DateTime) { |
|
368 | 368 | $parsed = array( |
369 | 369 | 'hour' => $time_to_set_string->format('H'), |
370 | 370 | 'minute' => $time_to_set_string->format('i'), |
@@ -372,12 +372,12 @@ discard block |
||
372 | 372 | ); |
373 | 373 | } else { |
374 | 374 | //parse incoming string |
375 | - $parsed = date_parse_from_format( $this->_time_format, $time_to_set_string ); |
|
375 | + $parsed = date_parse_from_format($this->_time_format, $time_to_set_string); |
|
376 | 376 | } |
377 | 377 | |
378 | 378 | //make sure $current is in the correct timezone. |
379 | - $current->setTimezone( $this->_DateTimeZone ); |
|
380 | - return $current->setTime( $parsed['hour'], $parsed['minute'], $parsed['second'] ); |
|
379 | + $current->setTimezone($this->_DateTimeZone); |
|
380 | + return $current->setTime($parsed['hour'], $parsed['minute'], $parsed['second']); |
|
381 | 381 | } |
382 | 382 | |
383 | 383 | |
@@ -388,9 +388,9 @@ discard block |
||
388 | 388 | * @param DateTime $current current DateTime object for the datetime field |
389 | 389 | * @return DateTime |
390 | 390 | */ |
391 | - public function prepare_for_set_with_new_date( $date_to_set_string, DateTime $current ){ |
|
391 | + public function prepare_for_set_with_new_date($date_to_set_string, DateTime $current) { |
|
392 | 392 | //if $time_to_set_string is datetime object, then let's use it to set the parse array. Otherwise parse the string. |
393 | - if ( $date_to_set_string instanceof DateTime ) { |
|
393 | + if ($date_to_set_string instanceof DateTime) { |
|
394 | 394 | $parsed = array( |
395 | 395 | 'year' => $date_to_set_string->format('Y'), |
396 | 396 | 'month' => $date_to_set_string->format('m'), |
@@ -398,12 +398,12 @@ discard block |
||
398 | 398 | ); |
399 | 399 | } else { |
400 | 400 | //parse incoming string |
401 | - $parsed = date_parse_from_format( $this->_date_format, $date_to_set_string ); |
|
401 | + $parsed = date_parse_from_format($this->_date_format, $date_to_set_string); |
|
402 | 402 | } |
403 | 403 | |
404 | 404 | //make sure $current is in the correct timezone |
405 | - $current->setTimezone( $this->_DateTimeZone ); |
|
406 | - return $current->setDate( $parsed['year'], $parsed['month'], $parsed['day'] ); |
|
405 | + $current->setTimezone($this->_DateTimeZone); |
|
406 | + return $current->setDate($parsed['year'], $parsed['month'], $parsed['day']); |
|
407 | 407 | } |
408 | 408 | |
409 | 409 | |
@@ -415,8 +415,8 @@ discard block |
||
415 | 415 | * @param DateTime $DateTime |
416 | 416 | * @return string formatted date time for given timezone |
417 | 417 | */ |
418 | - public function prepare_for_get( $DateTime ) { |
|
419 | - return $this->_prepare_for_display( $DateTime ); |
|
418 | + public function prepare_for_get($DateTime) { |
|
419 | + return $this->_prepare_for_display($DateTime); |
|
420 | 420 | } |
421 | 421 | |
422 | 422 | |
@@ -431,8 +431,8 @@ discard block |
||
431 | 431 | * @param null $schema |
432 | 432 | * @return string |
433 | 433 | */ |
434 | - public function prepare_for_pretty_echoing( $DateTime, $schema = null ) { |
|
435 | - return $this->_prepare_for_display( $DateTime, $schema ? $schema : true ); |
|
434 | + public function prepare_for_pretty_echoing($DateTime, $schema = null) { |
|
435 | + return $this->_prepare_for_display($DateTime, $schema ? $schema : true); |
|
436 | 436 | } |
437 | 437 | |
438 | 438 | |
@@ -446,36 +446,36 @@ discard block |
||
446 | 446 | * @return string |
447 | 447 | * @throws \EE_Error |
448 | 448 | */ |
449 | - protected function _prepare_for_display( $DateTime, $schema = false ) { |
|
450 | - if ( ! $DateTime instanceof DateTime ) { |
|
451 | - if ( $this->_nullable ) { |
|
449 | + protected function _prepare_for_display($DateTime, $schema = false) { |
|
450 | + if ( ! $DateTime instanceof DateTime) { |
|
451 | + if ($this->_nullable) { |
|
452 | 452 | return ''; |
453 | 453 | } else { |
454 | - if ( WP_DEBUG ) { |
|
455 | - throw new EE_Error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso' ), $this->_nicename ) ); |
|
454 | + if (WP_DEBUG) { |
|
455 | + throw new EE_Error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable.', 'event_espresso'), $this->_nicename)); |
|
456 | 456 | } else { |
457 | - $DateTime = new DateTime( \EE_Datetime_Field::now ); |
|
458 | - EE_Error::add_error( sprintf( __('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso' ), $this->_nicename ) ); |
|
457 | + $DateTime = new DateTime(\EE_Datetime_Field::now); |
|
458 | + EE_Error::add_error(sprintf(__('EE_Datetime_Field::_prepare_for_display requires a DateTime class to be the value for the $DateTime argument because the %s field is not nullable. When WP_DEBUG is false, the value is set to "now" instead of throwing an exception.', 'event_espresso'), $this->_nicename)); |
|
459 | 459 | } |
460 | 460 | } |
461 | 461 | } |
462 | - $format_string = $this->_get_date_time_output( $schema ); |
|
462 | + $format_string = $this->_get_date_time_output($schema); |
|
463 | 463 | //make sure datetime_value is in the correct timezone (in case that's been updated). |
464 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
465 | - if ( $schema ) { |
|
466 | - if( $this->_display_timezone() ) { |
|
464 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
465 | + if ($schema) { |
|
466 | + if ($this->_display_timezone()) { |
|
467 | 467 | //must be explicit because schema could equal true. |
468 | - if( $schema === 'no_html' ){ |
|
469 | - $timezone_string = ' (' . $DateTime->format( 'T' ) . ')'; |
|
470 | - }else{ |
|
471 | - $timezone_string = ' <span class="ee_dtt_timezone_string">(' . $DateTime->format( 'T' ) . ')</span>'; |
|
468 | + if ($schema === 'no_html') { |
|
469 | + $timezone_string = ' ('.$DateTime->format('T').')'; |
|
470 | + } else { |
|
471 | + $timezone_string = ' <span class="ee_dtt_timezone_string">('.$DateTime->format('T').')</span>'; |
|
472 | 472 | } |
473 | 473 | } else { |
474 | 474 | $timezone_string = ''; |
475 | 475 | } |
476 | - return $DateTime->format( $format_string ) . $timezone_string; |
|
476 | + return $DateTime->format($format_string).$timezone_string; |
|
477 | 477 | } else { |
478 | - return $DateTime->format( $format_string ); |
|
478 | + return $DateTime->format($format_string); |
|
479 | 479 | } |
480 | 480 | } |
481 | 481 | |
@@ -489,24 +489,24 @@ discard block |
||
489 | 489 | * @return string mysql timestamp in UTC |
490 | 490 | * @throws \EE_Error |
491 | 491 | */ |
492 | - public function prepare_for_use_in_db( $datetime_value ) { |
|
492 | + public function prepare_for_use_in_db($datetime_value) { |
|
493 | 493 | //we allow an empty value or DateTime object, but nothing else. |
494 | - if ( ! empty( $datetime_value ) && ! $datetime_value instanceof DateTime ) { |
|
495 | - throw new EE_Error( __('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso' ) ); |
|
494 | + if ( ! empty($datetime_value) && ! $datetime_value instanceof DateTime) { |
|
495 | + throw new EE_Error(__('The incoming value being prepared for setting in the database must either be empty or a php DateTime object', 'event_espresso')); |
|
496 | 496 | } |
497 | 497 | |
498 | - if ( $datetime_value instanceof DateTime ) { |
|
498 | + if ($datetime_value instanceof DateTime) { |
|
499 | 499 | if ( ! $datetime_value instanceof DbSafeDateTime) { |
500 | 500 | $datetime_value = new DbSafeDateTime( |
501 | - $datetime_value->format( EE_Datetime_Field::mysql_timestamp_format ), |
|
502 | - new \DateTimeZone( $datetime_value->format( 'e' ) ) |
|
501 | + $datetime_value->format(EE_Datetime_Field::mysql_timestamp_format), |
|
502 | + new \DateTimeZone($datetime_value->format('e')) |
|
503 | 503 | ); |
504 | 504 | } |
505 | - return $datetime_value->setTimezone( $this->get_UTC_DateTimeZone() )->format( EE_Datetime_Field::mysql_timestamp_format ); |
|
505 | + return $datetime_value->setTimezone($this->get_UTC_DateTimeZone())->format(EE_Datetime_Field::mysql_timestamp_format); |
|
506 | 506 | } |
507 | 507 | |
508 | 508 | // if $datetime_value is empty, and ! $this->_nullable, use current_time() but set the GMT flag to true |
509 | - return ! $this->_nullable && empty( $datetime_value ) ? current_time( 'mysql', true ) : null; |
|
509 | + return ! $this->_nullable && empty($datetime_value) ? current_time('mysql', true) : null; |
|
510 | 510 | } |
511 | 511 | |
512 | 512 | |
@@ -519,14 +519,14 @@ discard block |
||
519 | 519 | * @param string $datetime_string mysql timestamp in UTC |
520 | 520 | * @return mixed null | DateTime |
521 | 521 | */ |
522 | - public function prepare_for_set_from_db( $datetime_string ) { |
|
522 | + public function prepare_for_set_from_db($datetime_string) { |
|
523 | 523 | //if $datetime_value is empty, and ! $this->_nullable, just use time() |
524 | - if ( empty( $datetime_string) && $this->_nullable ) { |
|
524 | + if (empty($datetime_string) && $this->_nullable) { |
|
525 | 525 | return null; |
526 | 526 | } |
527 | 527 | // datetime strings from the db should ALWAYS be in UTC+0, so use UTC_DateTimeZone when creating |
528 | - if ( empty( $datetime_string ) ) { |
|
529 | - $DateTime = new DbSafeDateTime( \EE_Datetime_Field::now, $this->get_UTC_DateTimeZone() ); |
|
528 | + if (empty($datetime_string)) { |
|
529 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone()); |
|
530 | 530 | } else { |
531 | 531 | $DateTime = DateTime::createFromFormat( |
532 | 532 | EE_Datetime_Field::mysql_timestamp_format, |
@@ -534,17 +534,17 @@ discard block |
||
534 | 534 | $this->get_UTC_DateTimeZone() |
535 | 535 | ); |
536 | 536 | $DateTime = new DbSafeDateTime( |
537 | - $DateTime->format( \EE_Datetime_Field::mysql_timestamp_format ), |
|
537 | + $DateTime->format(\EE_Datetime_Field::mysql_timestamp_format), |
|
538 | 538 | $this->get_UTC_DateTimeZone() |
539 | 539 | ); |
540 | 540 | } |
541 | 541 | |
542 | - if ( ! $DateTime instanceof DbSafeDateTime ) { |
|
542 | + if ( ! $DateTime instanceof DbSafeDateTime) { |
|
543 | 543 | // if still no datetime object, then let's just use now |
544 | - $DateTime = new DbSafeDateTime( \EE_Datetime_Field::now, $this->get_UTC_DateTimeZone() ); |
|
544 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->get_UTC_DateTimeZone()); |
|
545 | 545 | } |
546 | 546 | // THEN apply the field's set DateTimeZone |
547 | - $DateTime->setTimezone( $this->_DateTimeZone ); |
|
547 | + $DateTime->setTimezone($this->_DateTimeZone); |
|
548 | 548 | return $DateTime; |
549 | 549 | } |
550 | 550 | |
@@ -561,15 +561,15 @@ discard block |
||
561 | 561 | protected function _display_timezone() { |
562 | 562 | |
563 | 563 | // first let's do a comparison of timezone strings. If they match then we can get out without any further calculations |
564 | - $blog_string = get_option( 'timezone_string' ); |
|
565 | - if ( $blog_string == $this->_timezone_string ) { |
|
564 | + $blog_string = get_option('timezone_string'); |
|
565 | + if ($blog_string == $this->_timezone_string) { |
|
566 | 566 | return FALSE; |
567 | 567 | } |
568 | 568 | // now we need to calc the offset for the timezone string so we can compare with the blog offset. |
569 | - $this_offset = $this->get_timezone_offset( $this->_DateTimeZone ); |
|
570 | - $blog_offset = $this->get_timezone_offset( $this->get_blog_DateTimeZone() ); |
|
569 | + $this_offset = $this->get_timezone_offset($this->_DateTimeZone); |
|
570 | + $blog_offset = $this->get_timezone_offset($this->get_blog_DateTimeZone()); |
|
571 | 571 | // now compare |
572 | - if ( $blog_offset === $this_offset ) { |
|
572 | + if ($blog_offset === $this_offset) { |
|
573 | 573 | return FALSE; |
574 | 574 | } |
575 | 575 | return TRUE; |
@@ -587,24 +587,24 @@ discard block |
||
587 | 587 | * |
588 | 588 | * @return DateTime |
589 | 589 | */ |
590 | - protected function _get_date_object( $date_string ) { |
|
590 | + protected function _get_date_object($date_string) { |
|
591 | 591 | //first if this is an empty date_string and nullable is allowed, just return null. |
592 | - if ( $this->_nullable && empty( $date_string ) ) { |
|
592 | + if ($this->_nullable && empty($date_string)) { |
|
593 | 593 | return null; |
594 | 594 | } |
595 | 595 | |
596 | 596 | // if incoming date |
597 | - if ( $date_string instanceof DateTime ) { |
|
598 | - $date_string->setTimezone( $this->_DateTimeZone ); |
|
597 | + if ($date_string instanceof DateTime) { |
|
598 | + $date_string->setTimezone($this->_DateTimeZone); |
|
599 | 599 | return $date_string; |
600 | 600 | } |
601 | 601 | // if empty date_string and made it here. |
602 | 602 | // Return a datetime object for now in the given timezone. |
603 | - if ( empty( $date_string ) ) { |
|
604 | - return new DbSafeDateTime( \EE_Datetime_Field::now, $this->_DateTimeZone ); |
|
603 | + if (empty($date_string)) { |
|
604 | + return new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
605 | 605 | } |
606 | 606 | // if $date_string is matches something that looks like a Unix timestamp let's just use it. |
607 | - if ( preg_match( EE_Datetime_Field::unix_timestamp_regex, $date_string ) ) { |
|
607 | + if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $date_string)) { |
|
608 | 608 | try { |
609 | 609 | /** |
610 | 610 | * This is operating under the assumption that the incoming Unix timestamp is |
@@ -612,36 +612,36 @@ discard block |
||
612 | 612 | * current_time('timestamp'); |
613 | 613 | * |
614 | 614 | */ |
615 | - $DateTime = new DbSafeDateTime( \EE_Datetime_Field::now, $this->_DateTimeZone ); |
|
616 | - $DateTime->setTimestamp( $date_string ); |
|
615 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
616 | + $DateTime->setTimestamp($date_string); |
|
617 | 617 | return $DateTime; |
618 | - } catch ( Exception $e ) { |
|
618 | + } catch (Exception $e) { |
|
619 | 619 | // should be rare, but if things got fooled then let's just continue |
620 | 620 | } |
621 | 621 | } |
622 | 622 | //not a unix timestamp. So we will use the set format on this object and set timezone to |
623 | 623 | //create the DateTime object. |
624 | - $format = $this->_date_format . ' ' . $this->_time_format; |
|
624 | + $format = $this->_date_format.' '.$this->_time_format; |
|
625 | 625 | try { |
626 | - $DateTime = DateTime::createFromFormat( $format, $date_string, $this->_DateTimeZone ); |
|
627 | - if ( $DateTime instanceof DateTime ) { |
|
626 | + $DateTime = DateTime::createFromFormat($format, $date_string, $this->_DateTimeZone); |
|
627 | + if ($DateTime instanceof DateTime) { |
|
628 | 628 | $DateTime = new DbSafeDateTime( |
629 | - $DateTime->format( \EE_Datetime_Field::mysql_timestamp_format ), |
|
629 | + $DateTime->format(\EE_Datetime_Field::mysql_timestamp_format), |
|
630 | 630 | $this->_DateTimeZone |
631 | 631 | ); |
632 | 632 | } |
633 | - if ( ! $DateTime instanceof DbSafeDateTime ) { |
|
633 | + if ( ! $DateTime instanceof DbSafeDateTime) { |
|
634 | 634 | throw new EE_Error( |
635 | 635 | sprintf( |
636 | - __( '"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso' ), |
|
636 | + __('"%1$s" does not represent a valid Date Time in the format "%2$s".', 'event_espresso'), |
|
637 | 637 | $date_string, |
638 | 638 | $format |
639 | 639 | ) |
640 | 640 | ); |
641 | 641 | } |
642 | - } catch ( Exception $e ) { |
|
642 | + } catch (Exception $e) { |
|
643 | 643 | // if we made it here then likely then something went really wrong. Instead of throwing an exception, let's just return a DateTime object for now, in the set timezone. |
644 | - $DateTime = new DbSafeDateTime( \EE_Datetime_Field::now, $this->_DateTimeZone ); |
|
644 | + $DateTime = new DbSafeDateTime(\EE_Datetime_Field::now, $this->_DateTimeZone); |
|
645 | 645 | } |
646 | 646 | return $DateTime; |
647 | 647 | } |
@@ -655,9 +655,9 @@ discard block |
||
655 | 655 | * @param int $time |
656 | 656 | * @return mixed |
657 | 657 | */ |
658 | - public function get_timezone_offset( DateTimeZone $DateTimeZone, $time = null ) { |
|
659 | - $time = preg_match( EE_Datetime_Field::unix_timestamp_regex, $time ) ? $time : time(); |
|
660 | - $transitions = $DateTimeZone->getTransitions( $time ); |
|
658 | + public function get_timezone_offset(DateTimeZone $DateTimeZone, $time = null) { |
|
659 | + $time = preg_match(EE_Datetime_Field::unix_timestamp_regex, $time) ? $time : time(); |
|
660 | + $transitions = $DateTimeZone->getTransitions($time); |
|
661 | 661 | return $transitions[0]['offset']; |
662 | 662 | } |
663 | 663 | |
@@ -669,10 +669,10 @@ discard block |
||
669 | 669 | * @param string $timezone_string |
670 | 670 | * @return string abbreviation |
671 | 671 | */ |
672 | - public function get_timezone_abbrev( $timezone_string ) { |
|
673 | - $timezone_string = EEH_DTT_Helper::get_valid_timezone_string( $timezone_string ); |
|
674 | - $dateTime = new DateTime( \EE_Datetime_Field::now, new DateTimeZone( $timezone_string ) ); |
|
675 | - return $dateTime->format( 'T' ); |
|
672 | + public function get_timezone_abbrev($timezone_string) { |
|
673 | + $timezone_string = EEH_DTT_Helper::get_valid_timezone_string($timezone_string); |
|
674 | + $dateTime = new DateTime(\EE_Datetime_Field::now, new DateTimeZone($timezone_string)); |
|
675 | + return $dateTime->format('T'); |
|
676 | 676 | } |
677 | 677 | |
678 | 678 | /** |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | * @return |
681 | 681 | */ |
682 | 682 | public function get_default_value() { |
683 | - if( $this->_default_value === EE_Datetime_Field::now ) { |
|
683 | + if ($this->_default_value === EE_Datetime_Field::now) { |
|
684 | 684 | return time(); |
685 | 685 | } else { |
686 | 686 | return parent::get_default_value(); |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\domain\entities; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -32,23 +32,23 @@ discard block |
||
32 | 32 | |
33 | 33 | |
34 | 34 | public function __toString() { |
35 | - return $this->format( DbSafeDateTime::db_safe_timestamp_format ); |
|
35 | + return $this->format(DbSafeDateTime::db_safe_timestamp_format); |
|
36 | 36 | } |
37 | 37 | |
38 | 38 | |
39 | 39 | |
40 | 40 | public function __sleep() { |
41 | - $this->_datetime_string = $this->format( DbSafeDateTime::db_safe_timestamp_format ); |
|
42 | - return array( '_datetime_string' ); |
|
41 | + $this->_datetime_string = $this->format(DbSafeDateTime::db_safe_timestamp_format); |
|
42 | + return array('_datetime_string'); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | |
47 | 47 | public function __wakeup() { |
48 | - $date = \DateTime::createFromFormat( DbSafeDateTime::db_safe_timestamp_format, $this->_datetime_string ); |
|
48 | + $date = \DateTime::createFromFormat(DbSafeDateTime::db_safe_timestamp_format, $this->_datetime_string); |
|
49 | 49 | $this->__construct( |
50 | - $date->format( \EE_Datetime_Field::mysql_timestamp_format), |
|
51 | - new \DateTimeZone( $date->format( 'e' ) ) |
|
50 | + $date->format(\EE_Datetime_Field::mysql_timestamp_format), |
|
51 | + new \DateTimeZone($date->format('e')) |
|
52 | 52 | ); |
53 | 53 | } |
54 | 54 |
@@ -1,5 +1,5 @@ discard block |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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 |
||
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. |
@@ -244,28 +244,28 @@ discard block |
||
244 | 244 | array( |
245 | 245 | $datetime_values, |
246 | 246 | $timezone, |
247 | - array( $this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
247 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
248 | 248 | ), |
249 | 249 | false, |
250 | 250 | false |
251 | 251 | ); |
252 | 252 | |
253 | 253 | //reset date and times to match the format |
254 | - $DTM->set_date_format( $this->_date_format_strings['date'] ); |
|
255 | - $DTM->set_time_format( $this->_date_format_strings['time'] ); |
|
256 | - foreach( $datetime_values as $field => $value ) { |
|
257 | - $DTM->set( $field, $value ); |
|
254 | + $DTM->set_date_format($this->_date_format_strings['date']); |
|
255 | + $DTM->set_time_format($this->_date_format_strings['time']); |
|
256 | + foreach ($datetime_values as $field => $value) { |
|
257 | + $DTM->set($field, $value); |
|
258 | 258 | } |
259 | 259 | } |
260 | 260 | |
261 | 261 | |
262 | 262 | $DTM->save(); |
263 | - $DTM = $evt_obj->_add_relation_to( $DTM, 'Datetime' ); |
|
263 | + $DTM = $evt_obj->_add_relation_to($DTM, 'Datetime'); |
|
264 | 264 | $evt_obj->save(); |
265 | 265 | |
266 | 266 | //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. |
267 | - if( $DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end') ) { |
|
268 | - $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start') ); |
|
267 | + if ($DTM->get_raw('DTT_EVT_start') > $DTM->get_raw('DTT_EVT_end')) { |
|
268 | + $DTM->set('DTT_EVT_end', $DTM->get('DTT_EVT_start')); |
|
269 | 269 | $DTM = EEH_DTT_Helper::date_time_add($DTM, 'DTT_EVT_end', 'days'); |
270 | 270 | $DTM->save(); |
271 | 271 | } |
@@ -280,25 +280,25 @@ discard block |
||
280 | 280 | } |
281 | 281 | |
282 | 282 | //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. |
283 | - $old_datetimes = explode(',', $data['datetime_IDs'] ); |
|
283 | + $old_datetimes = explode(',', $data['datetime_IDs']); |
|
284 | 284 | $old_datetimes = $old_datetimes[0] == '' ? array() : $old_datetimes; |
285 | 285 | |
286 | - if ( is_array( $old_datetimes ) ) { |
|
287 | - $dtts_to_delete = array_diff( $old_datetimes, $saved_dtt_ids ); |
|
288 | - foreach ( $dtts_to_delete as $id ) { |
|
289 | - $id = absint( $id ); |
|
290 | - if ( empty( $id ) ) |
|
286 | + if (is_array($old_datetimes)) { |
|
287 | + $dtts_to_delete = array_diff($old_datetimes, $saved_dtt_ids); |
|
288 | + foreach ($dtts_to_delete as $id) { |
|
289 | + $id = absint($id); |
|
290 | + if (empty($id)) |
|
291 | 291 | continue; |
292 | 292 | |
293 | 293 | $dtt_to_remove = EE_Registry::instance()->load_model('Datetime')->get_one_by_ID($id); |
294 | 294 | |
295 | 295 | //remove tkt relationships. |
296 | 296 | $related_tickets = $dtt_to_remove->get_many_related('Ticket'); |
297 | - foreach ( $related_tickets as $tkt ) { |
|
297 | + foreach ($related_tickets as $tkt) { |
|
298 | 298 | $dtt_to_remove->_remove_relation_to($tkt, 'Ticket'); |
299 | 299 | } |
300 | 300 | |
301 | - $evt_obj->_remove_relation_to( $id, 'Datetime' ); |
|
301 | + $evt_obj->_remove_relation_to($id, 'Datetime'); |
|
302 | 302 | $dtt_to_remove->refresh_cache_of_related_objects(); |
303 | 303 | |
304 | 304 | } |
@@ -319,85 +319,85 @@ discard block |
||
319 | 319 | * @param array $data incoming request data |
320 | 320 | * @return EE_Ticket[] |
321 | 321 | */ |
322 | - protected function _update_tkts( $evtobj, $saved_dtts, $data ) { |
|
322 | + protected function _update_tkts($evtobj, $saved_dtts, $data) { |
|
323 | 323 | |
324 | 324 | $new_tkt = null; |
325 | 325 | $new_default = null; |
326 | 326 | //stripslashes because WP filtered the $_POST ($data) array to add slashes |
327 | 327 | $data = stripslashes_deep($data); |
328 | - $timezone = isset( $data['timezone_string'] ) ? $data['timezone_string'] : NULL; |
|
328 | + $timezone = isset($data['timezone_string']) ? $data['timezone_string'] : NULL; |
|
329 | 329 | $saved_tickets = $dtts_on_existing = array(); |
330 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode(',', $data['ticket_IDs'] ) : array(); |
|
330 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
331 | 331 | |
332 | 332 | //load money helper |
333 | 333 | |
334 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
334 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
335 | 335 | |
336 | 336 | $update_prices = $create_new_TKT = FALSE; |
337 | 337 | |
338 | 338 | //figure out what dtts were added to the ticket and what dtts were removed from the ticket in the session. |
339 | 339 | |
340 | - $starting_tkt_dtt_rows = explode(',',$data['starting_ticket_datetime_rows'][$row]); |
|
341 | - $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row] ); |
|
340 | + $starting_tkt_dtt_rows = explode(',', $data['starting_ticket_datetime_rows'][$row]); |
|
341 | + $tkt_dtt_rows = explode(',', $data['ticket_datetime_rows'][$row]); |
|
342 | 342 | $dtts_added = array_diff($tkt_dtt_rows, $starting_tkt_dtt_rows); |
343 | 343 | $dtts_removed = array_diff($starting_tkt_dtt_rows, $tkt_dtt_rows); |
344 | 344 | |
345 | 345 | // trim inputs to ensure any excess whitespace is removed. |
346 | 346 | $tkt = array_map( |
347 | - function( $ticket_data ) { |
|
348 | - return is_array( $ticket_data ) ? $ticket_data : trim( $ticket_data ); |
|
347 | + function($ticket_data) { |
|
348 | + return is_array($ticket_data) ? $ticket_data : trim($ticket_data); |
|
349 | 349 | }, |
350 | 350 | $tkt |
351 | 351 | ); |
352 | 352 | |
353 | 353 | //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. |
354 | 354 | //note incoming ['TKT_price'] value is already in standard notation (via js). |
355 | - $ticket_price = isset( $tkt['TKT_price'] ) ? round ( (float) $tkt['TKT_price'], 3 ) : 0; |
|
355 | + $ticket_price = isset($tkt['TKT_price']) ? round((float) $tkt['TKT_price'], 3) : 0; |
|
356 | 356 | |
357 | 357 | //note incoming base price needs converted from localized value. |
358 | - $base_price = isset( $tkt['TKT_base_price'] ) ? EEH_Money::convert_to_float_from_localized_money( $tkt['TKT_base_price'] ) : 0; |
|
358 | + $base_price = isset($tkt['TKT_base_price']) ? EEH_Money::convert_to_float_from_localized_money($tkt['TKT_base_price']) : 0; |
|
359 | 359 | //if ticket price == 0 and $base_price != 0 then ticket price == base_price |
360 | 360 | $ticket_price = $ticket_price === 0 && $base_price !== 0 ? $base_price : $ticket_price; |
361 | - $base_price_id = isset( $tkt['TKT_base_price_ID'] ) ? $tkt['TKT_base_price_ID'] : 0; |
|
361 | + $base_price_id = isset($tkt['TKT_base_price_ID']) ? $tkt['TKT_base_price_ID'] : 0; |
|
362 | 362 | |
363 | 363 | $price_rows = is_array($data['edit_prices']) && isset($data['edit_prices'][$row]) ? $data['edit_prices'][$row] : array(); |
364 | 364 | |
365 | 365 | $now = null; |
366 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
366 | + if (empty($tkt['TKT_start_date'])) { |
|
367 | 367 | //lets' use now in the set timezone. |
368 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
369 | - $tkt['TKT_start_date'] = $now->format( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
368 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
369 | + $tkt['TKT_start_date'] = $now->format($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
370 | 370 | } |
371 | 371 | |
372 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
372 | + if (empty($tkt['TKT_end_date'])) { |
|
373 | 373 | /** |
374 | 374 | * set the TKT_end_date to the first datetime attached to the ticket. |
375 | 375 | */ |
376 | - $first_dtt = $saved_dtts[reset( $tkt_dtt_rows )]; |
|
377 | - $tkt['TKT_end_date'] = $first_dtt->start_date_and_time( $this->_date_format_strings['date'] . ' ' . $this->_date_format_string['time'] ); |
|
376 | + $first_dtt = $saved_dtts[reset($tkt_dtt_rows)]; |
|
377 | + $tkt['TKT_end_date'] = $first_dtt->start_date_and_time($this->_date_format_strings['date'].' '.$this->_date_format_string['time']); |
|
378 | 378 | } |
379 | 379 | |
380 | 380 | $TKT_values = array( |
381 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : NULL, |
|
382 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
383 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
384 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
381 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : NULL, |
|
382 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
383 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
384 | + 'TKT_description' => ! empty($tkt['TKT_description']) && $tkt['TKT_description'] != __('You can modify this description', 'event_espresso') ? $tkt['TKT_description'] : '', |
|
385 | 385 | 'TKT_start_date' => $tkt['TKT_start_date'], |
386 | 386 | 'TKT_end_date' => $tkt['TKT_end_date'], |
387 | - 'TKT_qty' => ! isset( $tkt[ 'TKT_qty' ] ) || $tkt[ 'TKT_qty' ] === '' ? EE_INF : $tkt[ 'TKT_qty' ], |
|
388 | - 'TKT_uses' => ! isset( $tkt[ 'TKT_uses' ] ) || $tkt[ 'TKT_uses' ] === '' ? EE_INF : $tkt['TKT_uses'], |
|
389 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
390 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
387 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
388 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
389 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
390 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
391 | 391 | 'TKT_row' => $row, |
392 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : 0, |
|
393 | - 'TKT_taxable' => ! empty( $tkt['TKT_taxable'] ) ? 1 : 0, |
|
394 | - 'TKT_required' => ! empty( $tkt['TKT_required'] ) ? 1 : 0, |
|
392 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : 0, |
|
393 | + 'TKT_taxable' => ! empty($tkt['TKT_taxable']) ? 1 : 0, |
|
394 | + 'TKT_required' => ! empty($tkt['TKT_required']) ? 1 : 0, |
|
395 | 395 | 'TKT_price' => $ticket_price |
396 | 396 | ); |
397 | 397 | |
398 | 398 | |
399 | 399 | //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. |
400 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
400 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
401 | 401 | $TKT_values['TKT_ID'] = 0; |
402 | 402 | $TKT_values['TKT_is_default'] = 0; |
403 | 403 | $update_prices = TRUE; |
@@ -409,21 +409,21 @@ discard block |
||
409 | 409 | // but DID have it's items modified. |
410 | 410 | // keep in mind that if the TKT has been sold (and we have changed pricing information), |
411 | 411 | // then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
412 | - if ( absint( $TKT_values['TKT_ID'] ) ) { |
|
413 | - $TKT = EE_Registry::instance()->load_model( 'Ticket', array( $timezone ) )->get_one_by_ID( $tkt['TKT_ID'] ); |
|
414 | - if ( $TKT instanceof EE_Ticket ) { |
|
412 | + if (absint($TKT_values['TKT_ID'])) { |
|
413 | + $TKT = EE_Registry::instance()->load_model('Ticket', array($timezone))->get_one_by_ID($tkt['TKT_ID']); |
|
414 | + if ($TKT instanceof EE_Ticket) { |
|
415 | 415 | |
416 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
416 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
417 | 417 | // are there any registrations using this ticket ? |
418 | 418 | $tickets_sold = $TKT->count_related( |
419 | 419 | 'Registration', |
420 | - array( array( |
|
421 | - 'STS_ID' => array( 'NOT IN', array( EEM_Registration::status_id_incomplete ) ) |
|
422 | - ) ) |
|
420 | + array(array( |
|
421 | + 'STS_ID' => array('NOT IN', array(EEM_Registration::status_id_incomplete)) |
|
422 | + )) |
|
423 | 423 | ); |
424 | 424 | //set ticket formats |
425 | - $TKT->set_date_format( $this->_date_format_strings['date'] ); |
|
426 | - $TKT->set_time_format( $this->_date_format_strings['time'] ); |
|
425 | + $TKT->set_date_format($this->_date_format_strings['date']); |
|
426 | + $TKT->set_time_format($this->_date_format_strings['time']); |
|
427 | 427 | |
428 | 428 | // let's just check the total price for the existing ticket |
429 | 429 | // and determine if it matches the new total price. |
@@ -433,17 +433,17 @@ discard block |
||
433 | 433 | ? TRUE : FALSE; |
434 | 434 | |
435 | 435 | //set new values |
436 | - foreach ( $TKT_values as $field => $value ) { |
|
437 | - if ( $field === 'TKT_qty' ) { |
|
438 | - $TKT->set_qty( $value ); |
|
436 | + foreach ($TKT_values as $field => $value) { |
|
437 | + if ($field === 'TKT_qty') { |
|
438 | + $TKT->set_qty($value); |
|
439 | 439 | } else { |
440 | - $TKT->set( $field, $value ); |
|
440 | + $TKT->set($field, $value); |
|
441 | 441 | } |
442 | 442 | } |
443 | 443 | |
444 | 444 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
445 | - if ( $create_new_TKT ) { |
|
446 | - $new_tkt = $this->_duplicate_ticket( $TKT, $price_rows, $ticket_price, $base_price, $base_price_id ); |
|
445 | + if ($create_new_TKT) { |
|
446 | + $new_tkt = $this->_duplicate_ticket($TKT, $price_rows, $ticket_price, $base_price, $base_price_id); |
|
447 | 447 | } |
448 | 448 | } |
449 | 449 | |
@@ -452,12 +452,12 @@ discard block |
||
452 | 452 | $TKT = EE_Ticket::new_instance( |
453 | 453 | $TKT_values, |
454 | 454 | $timezone, |
455 | - array( $this->_date_format_strings[ 'date' ], $this->_date_format_strings[ 'time' ] ) |
|
455 | + array($this->_date_format_strings['date'], $this->_date_format_strings['time']) |
|
456 | 456 | ); |
457 | - if ( $TKT instanceof EE_Ticket ) { |
|
457 | + if ($TKT instanceof EE_Ticket) { |
|
458 | 458 | // make sure ticket has an ID of setting relations won't work |
459 | 459 | $TKT->save(); |
460 | - $TKT = $this->_update_ticket_datetimes( $TKT, $saved_dtts, $dtts_added, $dtts_removed ); |
|
460 | + $TKT = $this->_update_ticket_datetimes($TKT, $saved_dtts, $dtts_added, $dtts_removed); |
|
461 | 461 | $update_prices = TRUE; |
462 | 462 | } |
463 | 463 | } |
@@ -465,37 +465,37 @@ discard block |
||
465 | 465 | //$TKT->save(); |
466 | 466 | |
467 | 467 | //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. |
468 | - if( $TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date') ) { |
|
469 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date') ); |
|
468 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
469 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
470 | 470 | $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
471 | 471 | } |
472 | 472 | |
473 | 473 | //let's make sure the base price is handled |
474 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( array(), $TKT, $update_prices, $base_price, $base_price_id ) : $TKT; |
|
474 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket(array(), $TKT, $update_prices, $base_price, $base_price_id) : $TKT; |
|
475 | 475 | |
476 | 476 | //add/update price_modifiers |
477 | - $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket( $price_rows, $TKT, $update_prices ) : $TKT; |
|
477 | + $TKT = ! $create_new_TKT ? $this->_add_prices_to_ticket($price_rows, $TKT, $update_prices) : $TKT; |
|
478 | 478 | |
479 | 479 | //need to make sue that the TKT_price is accurate after saving the prices. |
480 | 480 | $TKT->ensure_TKT_Price_correct(); |
481 | 481 | |
482 | 482 | //handle CREATING a default tkt from the incoming tkt but ONLY if this isn't an autosave. |
483 | - if ( ! defined('DOING_AUTOSAVE' ) ) { |
|
484 | - if ( !empty($tkt['TKT_is_default_selector'] ) ) { |
|
483 | + if ( ! defined('DOING_AUTOSAVE')) { |
|
484 | + if ( ! empty($tkt['TKT_is_default_selector'])) { |
|
485 | 485 | $update_prices = TRUE; |
486 | 486 | $new_default = clone $TKT; |
487 | - $new_default->set( 'TKT_ID', 0 ); |
|
488 | - $new_default->set( 'TKT_is_default', 1 ); |
|
489 | - $new_default->set( 'TKT_row', 1 ); |
|
490 | - $new_default->set( 'TKT_price', $ticket_price ); |
|
487 | + $new_default->set('TKT_ID', 0); |
|
488 | + $new_default->set('TKT_is_default', 1); |
|
489 | + $new_default->set('TKT_row', 1); |
|
490 | + $new_default->set('TKT_price', $ticket_price); |
|
491 | 491 | //remove any dtt relations cause we DON'T want dtt relations attached (note this is just removing the cached relations in the object) |
492 | 492 | $new_default->_remove_relations('Datetime'); |
493 | 493 | //todo we need to add the current attached prices as new prices to the new default ticket. |
494 | - $new_default = $this->_add_prices_to_ticket( $price_rows, $new_default, $update_prices ); |
|
494 | + $new_default = $this->_add_prices_to_ticket($price_rows, $new_default, $update_prices); |
|
495 | 495 | //don't forget the base price! |
496 | - $new_default = $this->_add_prices_to_ticket( array(), $new_default, $update_prices, $base_price, $base_price_id ); |
|
496 | + $new_default = $this->_add_prices_to_ticket(array(), $new_default, $update_prices, $base_price, $base_price_id); |
|
497 | 497 | $new_default->save(); |
498 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data ); |
|
498 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_default_ticket', $new_default, $row, $TKT, $data); |
|
499 | 499 | } |
500 | 500 | } |
501 | 501 | |
@@ -506,19 +506,19 @@ discard block |
||
506 | 506 | //let's assign any tickets that have been setup to the saved_tickets tracker |
507 | 507 | //save existing TKT |
508 | 508 | $TKT->save(); |
509 | - if ( $create_new_TKT && $new_tkt instanceof EE_Ticket ) { |
|
509 | + if ($create_new_TKT && $new_tkt instanceof EE_Ticket) { |
|
510 | 510 | //save new TKT |
511 | 511 | $new_tkt->save(); |
512 | 512 | //add new ticket to array |
513 | - $saved_tickets[ $new_tkt->ID() ] = $new_tkt; |
|
513 | + $saved_tickets[$new_tkt->ID()] = $new_tkt; |
|
514 | 514 | |
515 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data ); |
|
515 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_new_ticket', $new_tkt, $row, $tkt, $data); |
|
516 | 516 | |
517 | 517 | } else { |
518 | 518 | //add tkt to saved tkts |
519 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
519 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
520 | 520 | |
521 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data ); |
|
521 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_update_ticket', $TKT, $row, $tkt, $data); |
|
522 | 522 | } |
523 | 523 | |
524 | 524 | } |
@@ -528,22 +528,22 @@ discard block |
||
528 | 528 | // (i.e. autosaves are happening and then in between autosaves the user trashes a ticket). |
529 | 529 | // Or a draft event was saved and in the process of editing a ticket is trashed. |
530 | 530 | // No sense in keeping all the related data in the db! |
531 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
532 | - $tickets_removed = array_diff( $old_tickets, array_keys($saved_tickets) ); |
|
531 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
532 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
533 | 533 | |
534 | - foreach ( $tickets_removed as $id ) { |
|
535 | - $id = absint( $id ); |
|
534 | + foreach ($tickets_removed as $id) { |
|
535 | + $id = absint($id); |
|
536 | 536 | |
537 | 537 | //get the ticket for this id |
538 | 538 | $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
539 | 539 | |
540 | 540 | //if this tkt is a default tkt we leave it alone cause it won't be attached to the datetime |
541 | - if ( $tkt_to_remove->get('TKT_is_default') ) |
|
541 | + if ($tkt_to_remove->get('TKT_is_default')) |
|
542 | 542 | continue; |
543 | 543 | |
544 | 544 | // if this tkt has any registrations attached so then we just ARCHIVE |
545 | 545 | // because we don't actually permanently delete these tickets. |
546 | - if ( $tkt_to_remove->count_related('Registration') > 0 ) { |
|
546 | + if ($tkt_to_remove->count_related('Registration') > 0) { |
|
547 | 547 | $tkt_to_remove->delete(); |
548 | 548 | continue; |
549 | 549 | } |
@@ -552,7 +552,7 @@ discard block |
||
552 | 552 | // (remember this process can ONLY kick off if there are NO tkts_sold) |
553 | 553 | $dtts = $tkt_to_remove->get_many_related('Datetime'); |
554 | 554 | |
555 | - foreach( $dtts as $dtt ) { |
|
555 | + foreach ($dtts as $dtt) { |
|
556 | 556 | $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
557 | 557 | } |
558 | 558 | |
@@ -560,7 +560,7 @@ discard block |
||
560 | 560 | // tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
561 | 561 | $tkt_to_remove->delete_related_permanently('Price'); |
562 | 562 | |
563 | - do_action( 'AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove ); |
|
563 | + do_action('AHEE__espresso_events_Pricing_Hooks___update_tkts_delete_ticket', $tkt_to_remove); |
|
564 | 564 | |
565 | 565 | // finally let's delete this ticket |
566 | 566 | // (which should not be blocked at this point b/c we've removed all our relationships) |
@@ -592,39 +592,39 @@ discard block |
||
592 | 592 | // and removing the ticket from datetimes it got removed from. |
593 | 593 | |
594 | 594 | // first let's add datetimes |
595 | - if ( ! empty( $added_datetimes ) && is_array( $added_datetimes ) ) { |
|
596 | - foreach ( $added_datetimes as $row_id ) { |
|
595 | + if ( ! empty($added_datetimes) && is_array($added_datetimes)) { |
|
596 | + foreach ($added_datetimes as $row_id) { |
|
597 | 597 | $row_id = (int) $row_id; |
598 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
599 | - $ticket->_add_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
598 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
599 | + $ticket->_add_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
600 | 600 | // Is this an existing ticket (has an ID) and does it have any sold? |
601 | 601 | // If so, then we need to add that to the DTT sold because this DTT is getting added. |
602 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
603 | - $saved_datetimes[ $row_id ]->increase_sold( $ticket->sold() ); |
|
604 | - $saved_datetimes[ $row_id ]->save(); |
|
602 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
603 | + $saved_datetimes[$row_id]->increase_sold($ticket->sold()); |
|
604 | + $saved_datetimes[$row_id]->save(); |
|
605 | 605 | } |
606 | 606 | } |
607 | 607 | } |
608 | 608 | } |
609 | 609 | // then remove datetimes |
610 | - if ( ! empty( $removed_datetimes ) && is_array( $removed_datetimes ) ) { |
|
611 | - foreach ( $removed_datetimes as $row_id ) { |
|
612 | - $row_id = (int)$row_id; |
|
610 | + if ( ! empty($removed_datetimes) && is_array($removed_datetimes)) { |
|
611 | + foreach ($removed_datetimes as $row_id) { |
|
612 | + $row_id = (int) $row_id; |
|
613 | 613 | // its entirely possible that a datetime got deleted (instead of just removed from relationship. |
614 | 614 | // So make sure we skip over this if the dtt isn't in the $saved_datetimes array) |
615 | - if ( isset( $saved_datetimes[ $row_id ] ) && $saved_datetimes[ $row_id ] instanceof EE_Datetime ) { |
|
616 | - $ticket->_remove_relation_to( $saved_datetimes[ $row_id ], 'Datetime' ); |
|
615 | + if (isset($saved_datetimes[$row_id]) && $saved_datetimes[$row_id] instanceof EE_Datetime) { |
|
616 | + $ticket->_remove_relation_to($saved_datetimes[$row_id], 'Datetime'); |
|
617 | 617 | // Is this an existing ticket (has an ID) and does it have any sold? |
618 | 618 | // If so, then we need to remove it's sold from the DTT_sold. |
619 | - if ( $ticket->ID() && $ticket->sold() > 0 ) { |
|
620 | - $saved_datetimes[ $row_id ]->decrease_sold( $ticket->sold() ); |
|
621 | - $saved_datetimes[ $row_id ]->save(); |
|
619 | + if ($ticket->ID() && $ticket->sold() > 0) { |
|
620 | + $saved_datetimes[$row_id]->decrease_sold($ticket->sold()); |
|
621 | + $saved_datetimes[$row_id]->save(); |
|
622 | 622 | } |
623 | 623 | } |
624 | 624 | } |
625 | 625 | } |
626 | 626 | // cap ticket qty by datetime reg limits |
627 | - $ticket->set_qty( min( $ticket->qty(), $ticket->qty( 'reg_limit' ) ) ); |
|
627 | + $ticket->set_qty(min($ticket->qty(), $ticket->qty('reg_limit'))); |
|
628 | 628 | return $ticket; |
629 | 629 | } |
630 | 630 | |
@@ -645,39 +645,39 @@ discard block |
||
645 | 645 | EE_Ticket $ticket, |
646 | 646 | $price_rows = array(), |
647 | 647 | $ticket_price = 0, |
648 | - $base_price = 0 , |
|
648 | + $base_price = 0, |
|
649 | 649 | $base_price_id = 0 |
650 | 650 | ) { |
651 | 651 | |
652 | 652 | // create new ticket that's a copy of the existing |
653 | 653 | // except a new id of course (and not archived) |
654 | 654 | // AND has the new TKT_price associated with it. |
655 | - $new_ticket = clone( $ticket ); |
|
656 | - $new_ticket->set( 'TKT_ID', 0 ); |
|
657 | - $new_ticket->set( 'TKT_deleted', 0 ); |
|
658 | - $new_ticket->set( 'TKT_price', $ticket_price ); |
|
659 | - $new_ticket->set( 'TKT_sold', 0 ); |
|
655 | + $new_ticket = clone($ticket); |
|
656 | + $new_ticket->set('TKT_ID', 0); |
|
657 | + $new_ticket->set('TKT_deleted', 0); |
|
658 | + $new_ticket->set('TKT_price', $ticket_price); |
|
659 | + $new_ticket->set('TKT_sold', 0); |
|
660 | 660 | // let's get a new ID for this ticket |
661 | 661 | $new_ticket->save(); |
662 | 662 | // we also need to make sure this new ticket gets the same datetime attachments as the archived ticket |
663 | - $datetimes_on_existing = $ticket->get_many_related( 'Datetime' ); |
|
663 | + $datetimes_on_existing = $ticket->get_many_related('Datetime'); |
|
664 | 664 | $new_ticket = $this->_update_ticket_datetimes( |
665 | 665 | $new_ticket, |
666 | 666 | $datetimes_on_existing, |
667 | - array_keys( $datetimes_on_existing ) |
|
667 | + array_keys($datetimes_on_existing) |
|
668 | 668 | ); |
669 | 669 | |
670 | 670 | // $ticket will get archived later b/c we are NOT adding it to the saved_tickets array. |
671 | 671 | // if existing $ticket has sold amount, then we need to adjust the qty for the new TKT to = the remaining |
672 | 672 | // available. |
673 | - if ( $ticket->sold() > 0 ) { |
|
673 | + if ($ticket->sold() > 0) { |
|
674 | 674 | $new_qty = $ticket->qty() - $ticket->sold(); |
675 | - $new_ticket->set_qty( $new_qty ); |
|
675 | + $new_ticket->set_qty($new_qty); |
|
676 | 676 | } |
677 | 677 | //now we update the prices just for this ticket |
678 | - $new_ticket = $this->_add_prices_to_ticket( $price_rows, $new_ticket, true ); |
|
678 | + $new_ticket = $this->_add_prices_to_ticket($price_rows, $new_ticket, true); |
|
679 | 679 | //and we update the base price |
680 | - $new_ticket = $this->_add_prices_to_ticket( array(), $new_ticket, true, $base_price, $base_price_id ); |
|
680 | + $new_ticket = $this->_add_prices_to_ticket(array(), $new_ticket, true, $base_price, $base_price_id); |
|
681 | 681 | return $new_ticket; |
682 | 682 | } |
683 | 683 | |
@@ -697,7 +697,7 @@ discard block |
||
697 | 697 | * @param int|bool $base_price_id if present then this is the base_price_id being updated. |
698 | 698 | * @return EE_Ticket |
699 | 699 | */ |
700 | - protected function _add_prices_to_ticket( $prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE ) { |
|
700 | + protected function _add_prices_to_ticket($prices = array(), EE_Ticket $ticket, $new_prices = FALSE, $base_price = FALSE, $base_price_id = FALSE) { |
|
701 | 701 | |
702 | 702 | //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. |
703 | 703 | $current_prices_on_ticket = $base_price !== FALSE ? $ticket->base_price(TRUE) : $ticket->price_modifiers(); |
@@ -705,7 +705,7 @@ discard block |
||
705 | 705 | $updated_prices = array(); |
706 | 706 | |
707 | 707 | // if $base_price ! FALSE then updating a base price. |
708 | - if ( $base_price !== FALSE ) { |
|
708 | + if ($base_price !== FALSE) { |
|
709 | 709 | $prices[1] = array( |
710 | 710 | 'PRC_ID' => $new_prices || $base_price_id === 1 ? NULL : $base_price_id, |
711 | 711 | 'PRT_ID' => 1, |
@@ -716,47 +716,47 @@ discard block |
||
716 | 716 | } |
717 | 717 | |
718 | 718 | //possibly need to save tkt |
719 | - if ( ! $ticket->ID() ) |
|
719 | + if ( ! $ticket->ID()) |
|
720 | 720 | $ticket->save(); |
721 | 721 | |
722 | - foreach ( $prices as $row => $prc ) { |
|
723 | - $prt_id = !empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : NULL; |
|
724 | - if ( empty($prt_id) ) |
|
722 | + foreach ($prices as $row => $prc) { |
|
723 | + $prt_id = ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : NULL; |
|
724 | + if (empty($prt_id)) |
|
725 | 725 | continue; //prices MUST have a price type id. |
726 | 726 | $PRC_values = array( |
727 | - 'PRC_ID' => !empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : NULL, |
|
727 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : NULL, |
|
728 | 728 | 'PRT_ID' => $prt_id, |
729 | - 'PRC_amount' => !empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
730 | - 'PRC_name' => !empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
731 | - 'PRC_desc' => !empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
729 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
730 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
731 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
732 | 732 | 'PRC_is_default' => false, //make sure we set PRC_is_default to false for all ticket saves from event_editor |
733 | 733 | 'PRC_order' => $row |
734 | 734 | ); |
735 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
735 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
736 | 736 | $PRC_values['PRC_ID'] = 0; |
737 | - $PRC = EE_Registry::instance()->load_class('Price', array( $PRC_values ), FALSE, FALSE); |
|
737 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), FALSE, FALSE); |
|
738 | 738 | } else { |
739 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
739 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
740 | 740 | //update this price with new values |
741 | - foreach ( $PRC_values as $field => $newprc ) { |
|
742 | - $PRC->set( $field, $newprc ); |
|
741 | + foreach ($PRC_values as $field => $newprc) { |
|
742 | + $PRC->set($field, $newprc); |
|
743 | 743 | } |
744 | 744 | } |
745 | 745 | $PRC->save(); |
746 | 746 | $prcid = $PRC->ID(); |
747 | 747 | $updated_prices[$prcid] = $PRC; |
748 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
748 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
749 | 749 | } |
750 | 750 | |
751 | 751 | //now let's remove any prices that got removed from the ticket |
752 | - if ( !empty ( $current_prices_on_ticket ) ) { |
|
752 | + if ( ! empty ($current_prices_on_ticket)) { |
|
753 | 753 | $current = array_keys($current_prices_on_ticket); |
754 | 754 | $updated = array_keys($updated_prices); |
755 | 755 | $prices_to_remove = array_diff($current, $updated); |
756 | - if ( !empty( $prices_to_remove ) ) { |
|
757 | - foreach ( $prices_to_remove as $prc_id ) { |
|
756 | + if ( ! empty($prices_to_remove)) { |
|
757 | + foreach ($prices_to_remove as $prc_id) { |
|
758 | 758 | $p = $current_prices_on_ticket[$prc_id]; |
759 | - $ticket->_remove_relation_to( $p, 'Price' ); |
|
759 | + $ticket->_remove_relation_to($p, 'Price'); |
|
760 | 760 | |
761 | 761 | //delete permanently the price |
762 | 762 | $p->delete_permanently(); |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | |
770 | 770 | |
771 | 771 | |
772 | - public function autosave_handling( $event_admin_obj ) { |
|
772 | + public function autosave_handling($event_admin_obj) { |
|
773 | 773 | return $event_admin_obj; //doing nothing for the moment. |
774 | 774 | //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) |
775 | 775 | |
@@ -803,12 +803,12 @@ discard block |
||
803 | 803 | |
804 | 804 | //default main template args |
805 | 805 | $main_template_args = array( |
806 | - '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 |
|
806 | + '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 |
|
807 | 807 | 'existing_datetime_ids' => '', |
808 | 808 | 'total_dtt_rows' => 1, |
809 | - '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. |
|
809 | + '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. |
|
810 | 810 | 'datetime_rows' => '', |
811 | - 'show_tickets_container' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
811 | + 'show_tickets_container' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 1 ? ' style="display:none;"' : '', |
|
812 | 812 | 'ticket_rows' => '', |
813 | 813 | 'existing_ticket_ids' => '', |
814 | 814 | 'total_ticket_rows' => 1, |
@@ -818,7 +818,7 @@ discard block |
||
818 | 818 | |
819 | 819 | $timezone = $evtobj instanceof EE_Event ? $evtobj->timezone_string() : NULL; |
820 | 820 | |
821 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
821 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
822 | 822 | |
823 | 823 | /** |
824 | 824 | * 1. Start with retrieving Datetimes |
@@ -826,8 +826,8 @@ discard block |
||
826 | 826 | * 3. For each ticket get related prices |
827 | 827 | */ |
828 | 828 | |
829 | - $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone) ); |
|
830 | - $times = $DTM->get_all_event_dates( $evtID ); |
|
829 | + $DTM = EE_Registry::instance()->load_model('Datetime', array($timezone)); |
|
830 | + $times = $DTM->get_all_event_dates($evtID); |
|
831 | 831 | |
832 | 832 | |
833 | 833 | |
@@ -835,31 +835,31 @@ discard block |
||
835 | 835 | |
836 | 836 | /** @see https://events.codebasehq.com/projects/event-espresso/tickets/9486 for why we are counting $dttrow and then setting that on the Datetime object */ |
837 | 837 | $dttrow = 1; |
838 | - foreach ( $times as $time ) { |
|
838 | + foreach ($times as $time) { |
|
839 | 839 | $dttid = $time->get('DTT_ID'); |
840 | - $time->set( 'DTT_order', $dttrow ); |
|
840 | + $time->set('DTT_order', $dttrow); |
|
841 | 841 | $existing_datetime_ids[] = $dttid; |
842 | 842 | |
843 | 843 | //tickets attached |
844 | - $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(); |
|
844 | + $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(); |
|
845 | 845 | |
846 | 846 | //if there are no related tickets this is likely a new event OR autodraft |
847 | 847 | // event so we need to generate the default tickets because dtts |
848 | 848 | // ALWAYS have at least one related ticket!!. EXCEPT, we dont' do this if there is already more than one |
849 | 849 | // datetime on the event. |
850 | - if ( empty ( $related_tickets ) && count( $times ) < 2 ) { |
|
850 | + if (empty ($related_tickets) && count($times) < 2) { |
|
851 | 851 | $related_tickets = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
852 | 852 | |
853 | 853 | //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). |
854 | 854 | $default_prices = EEM_Price::instance()->get_all_default_prices(); |
855 | 855 | |
856 | - $main_default_ticket = reset( $related_tickets ); |
|
857 | - if ( $main_default_ticket instanceof EE_Ticket ) { |
|
858 | - foreach ( $default_prices as $default_price ) { |
|
859 | - if ( $default_price->is_base_price() ) { |
|
856 | + $main_default_ticket = reset($related_tickets); |
|
857 | + if ($main_default_ticket instanceof EE_Ticket) { |
|
858 | + foreach ($default_prices as $default_price) { |
|
859 | + if ($default_price->is_base_price()) { |
|
860 | 860 | continue; |
861 | 861 | } |
862 | - $main_default_ticket->cache( 'Price', $default_price ); |
|
862 | + $main_default_ticket->cache('Price', $default_price); |
|
863 | 863 | } |
864 | 864 | } |
865 | 865 | } |
@@ -868,11 +868,11 @@ discard block |
||
868 | 868 | //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. |
869 | 869 | |
870 | 870 | //loop through and setup the ticket rows and make sure the order is set. |
871 | - foreach ( $related_tickets as $ticket ) { |
|
871 | + foreach ($related_tickets as $ticket) { |
|
872 | 872 | $tktid = $ticket->get('TKT_ID'); |
873 | 873 | $tktrow = $ticket->get('TKT_row'); |
874 | 874 | //we only want unique tickets in our final display!! |
875 | - if ( !in_array( $tktid, $existing_ticket_ids ) ) { |
|
875 | + if ( ! in_array($tktid, $existing_ticket_ids)) { |
|
876 | 876 | $existing_ticket_ids[] = $tktid; |
877 | 877 | $all_tickets[] = $ticket; |
878 | 878 | } |
@@ -881,57 +881,57 @@ discard block |
||
881 | 881 | $datetime_tickets[$dttid][] = $tktrow; |
882 | 882 | |
883 | 883 | //temporary cache of this datetime info for this ticket for later processing of ticket rows. |
884 | - if ( !isset( $ticket_datetimes[$tktid] ) || ! in_array( $dttrow, $ticket_datetimes[$tktid] ) ) |
|
884 | + if ( ! isset($ticket_datetimes[$tktid]) || ! in_array($dttrow, $ticket_datetimes[$tktid])) |
|
885 | 885 | $ticket_datetimes[$tktid][] = $dttrow; |
886 | 886 | } |
887 | 887 | $dttrow++; |
888 | 888 | } |
889 | 889 | |
890 | - $main_template_args['total_ticket_rows'] = count( $existing_ticket_ids ); |
|
891 | - $main_template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
892 | - $main_template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
890 | + $main_template_args['total_ticket_rows'] = count($existing_ticket_ids); |
|
891 | + $main_template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
892 | + $main_template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
893 | 893 | |
894 | 894 | //sort $all_tickets by order |
895 | - usort( $all_tickets, function( $a, $b ) { |
|
895 | + usort($all_tickets, function($a, $b) { |
|
896 | 896 | $a_order = (int) $a->get('TKT_order'); |
897 | 897 | $b_order = (int) $b->get('TKT_order'); |
898 | - if ( $a_order == $b_order ) { |
|
898 | + if ($a_order == $b_order) { |
|
899 | 899 | return 0; |
900 | 900 | } |
901 | - return ( $a_order < $b_order ) ? -1 : 1; |
|
901 | + return ($a_order < $b_order) ? -1 : 1; |
|
902 | 902 | }); |
903 | 903 | |
904 | 904 | //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. |
905 | 905 | $dttrow = 1; |
906 | - foreach ( $times as $time ) { |
|
907 | - $main_template_args['datetime_rows'] .= $this->_get_datetime_row( $dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times ); |
|
906 | + foreach ($times as $time) { |
|
907 | + $main_template_args['datetime_rows'] .= $this->_get_datetime_row($dttrow, $time, $datetime_tickets, $all_tickets, FALSE, $times); |
|
908 | 908 | $dttrow++; |
909 | 909 | } |
910 | 910 | |
911 | 911 | //then loop through all tickets for the ticket rows. |
912 | 912 | $tktrow = 1; |
913 | - foreach ( $all_tickets as $ticket ) { |
|
914 | - $main_template_args['ticket_rows'] .= $this->_get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets ); |
|
913 | + foreach ($all_tickets as $ticket) { |
|
914 | + $main_template_args['ticket_rows'] .= $this->_get_ticket_row($tktrow, $ticket, $ticket_datetimes, $times, FALSE, $all_tickets); |
|
915 | 915 | $tktrow++; |
916 | 916 | } |
917 | 917 | |
918 | 918 | $main_template_args['ticket_js_structure'] = $this->_get_ticket_js_structure($times, $all_tickets); |
919 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php'; |
|
920 | - EEH_Template::display_template( $template, $main_template_args ); |
|
919 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_metabox_main.template.php'; |
|
920 | + EEH_Template::display_template($template, $main_template_args); |
|
921 | 921 | return; |
922 | 922 | } |
923 | 923 | |
924 | 924 | |
925 | 925 | |
926 | - protected function _get_datetime_row( $dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array() ) { |
|
926 | + protected function _get_datetime_row($dttrow, EE_Datetime $dtt, $datetime_tickets, $all_tickets, $default = FALSE, $all_dtts = array()) { |
|
927 | 927 | |
928 | 928 | $dtt_display_template_args = array( |
929 | - 'dtt_edit_row' => $this->_get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ), |
|
930 | - 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ), |
|
929 | + 'dtt_edit_row' => $this->_get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts), |
|
930 | + 'dtt_attached_tickets_row' => $this->_get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default), |
|
931 | 931 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow |
932 | 932 | ); |
933 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_row_wrapper.template.php'; |
|
934 | - return EEH_Template::display_template( $template, $dtt_display_template_args, TRUE); |
|
933 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_row_wrapper.template.php'; |
|
934 | + return EEH_Template::display_template($template, $dtt_display_template_args, TRUE); |
|
935 | 935 | } |
936 | 936 | |
937 | 937 | |
@@ -949,7 +949,7 @@ discard block |
||
949 | 949 | * |
950 | 950 | * @return string Generated edit row. |
951 | 951 | */ |
952 | - protected function _get_dtt_edit_row( $dttrow, $dtt, $default, $all_dtts ) { |
|
952 | + protected function _get_dtt_edit_row($dttrow, $dtt, $default, $all_dtts) { |
|
953 | 953 | |
954 | 954 | // if the incoming $dtt object is NOT an instance of EE_Datetime then force default to true. |
955 | 955 | $default = ! $dtt instanceof EE_Datetime ? true : false; |
@@ -957,36 +957,36 @@ discard block |
||
957 | 957 | $template_args = array( |
958 | 958 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
959 | 959 | 'event_datetimes_name' => $default ? 'DTTNAMEATTR' : 'edit_event_datetimes', |
960 | - 'edit_dtt_expanded' => '',//$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
960 | + 'edit_dtt_expanded' => '', //$this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? '' : ' ee-edit-editing', |
|
961 | 961 | 'DTT_ID' => $default ? '' : $dtt->ID(), |
962 | 962 | 'DTT_name' => $default ? '' : $dtt->name(), |
963 | 963 | 'DTT_description' => $default ? '' : $dtt->description(), |
964 | - 'DTT_EVT_start' => $default ? '' : $dtt->start_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
965 | - 'DTT_EVT_end' => $default ? '' : $dtt->end_date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
966 | - 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit','input'), |
|
964 | + 'DTT_EVT_start' => $default ? '' : $dtt->start_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
965 | + 'DTT_EVT_end' => $default ? '' : $dtt->end_date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
966 | + 'DTT_reg_limit' => $default ? '' : $dtt->get_pretty('DTT_reg_limit', 'input'), |
|
967 | 967 | 'DTT_order' => $default ? 'DTTNUM' : $dttrow, |
968 | 968 | 'dtt_sold' => $default ? '0' : $dtt->get('DTT_sold'), |
969 | - 'clone_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
970 | - 'trash_icon' => !empty( $dtt ) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable', |
|
969 | + 'clone_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? '' : 'clone-icon ee-icon ee-icon-clone clickable', |
|
970 | + 'trash_icon' => ! empty($dtt) && $dtt->get('DTT_sold') > 0 ? 'ee-lock-icon' : 'trash-icon dashicons dashicons-post-trash clickable', |
|
971 | 971 | 'reg_list_url' => $default || ! $dtt->event() instanceof \EE_Event |
972 | 972 | ? '' |
973 | 973 | : EE_Admin_Page::add_query_args_and_nonce( |
974 | - array( 'event_id' => $dtt->event()->ID(), 'datetime_id' => $dtt->ID() ), |
|
974 | + array('event_id' => $dtt->event()->ID(), 'datetime_id' => $dtt->ID()), |
|
975 | 975 | REG_ADMIN_URL |
976 | 976 | ) |
977 | 977 | ); |
978 | 978 | |
979 | - $template_args['show_trash'] = count( $all_dtts ) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
979 | + $template_args['show_trash'] = count($all_dtts) === 1 && $template_args['trash_icon'] !== 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
980 | 980 | |
981 | 981 | //allow filtering of template args at this point. |
982 | - $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 ); |
|
982 | + $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); |
|
983 | 983 | |
984 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_edit_row.template.php'; |
|
985 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
984 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_edit_row.template.php'; |
|
985 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
986 | 986 | } |
987 | 987 | |
988 | 988 | |
989 | - protected function _get_dtt_attached_tickets_row( $dttrow, $dtt, $datetime_tickets, $all_tickets, $default ) { |
|
989 | + protected function _get_dtt_attached_tickets_row($dttrow, $dtt, $datetime_tickets, $all_tickets, $default) { |
|
990 | 990 | |
991 | 991 | $template_args = array( |
992 | 992 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
@@ -994,47 +994,47 @@ discard block |
||
994 | 994 | 'DTT_description' => $default ? '' : $dtt->description(), |
995 | 995 | 'datetime_tickets_list' => $default ? '<li class="hidden"></li>' : '', |
996 | 996 | 'show_tickets_row' => ' style="display:none;"', //$default || $this->_adminpage_obj->get_cpt_model_obj()->ID() > 0 ? ' style="display:none;"' : '', |
997 | - '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. |
|
997 | + '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. |
|
998 | 998 | 'DTT_ID' => $default ? '' : $dtt->ID() |
999 | 999 | ); |
1000 | 1000 | |
1001 | 1001 | //need to setup the list items (but only if this isnt' a default skeleton setup) |
1002 | - if ( !$default ) { |
|
1002 | + if ( ! $default) { |
|
1003 | 1003 | $tktrow = 1; |
1004 | - foreach ( $all_tickets as $ticket ) { |
|
1005 | - $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ); |
|
1004 | + foreach ($all_tickets as $ticket) { |
|
1005 | + $template_args['datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default); |
|
1006 | 1006 | $tktrow++; |
1007 | 1007 | } |
1008 | 1008 | } |
1009 | 1009 | |
1010 | 1010 | //filter template args at this point |
1011 | - $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 ); |
|
1011 | + $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); |
|
1012 | 1012 | |
1013 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_attached_tickets_row.template.php'; |
|
1014 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1013 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_attached_tickets_row.template.php'; |
|
1014 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1015 | 1015 | } |
1016 | 1016 | |
1017 | 1017 | |
1018 | 1018 | |
1019 | - protected function _get_datetime_tickets_list_item( $dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default ) { |
|
1020 | - $tktid = !empty( $ticket ) ? $ticket->ID() : 0; |
|
1021 | - $dtt_tkts = $dtt instanceof EE_Datetime && isset( $datetime_tickets[$dtt->ID()] ) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1019 | + protected function _get_datetime_tickets_list_item($dttrow, $tktrow, $dtt, $ticket, $datetime_tickets, $default) { |
|
1020 | + $tktid = ! empty($ticket) ? $ticket->ID() : 0; |
|
1021 | + $dtt_tkts = $dtt instanceof EE_Datetime && isset($datetime_tickets[$dtt->ID()]) ? $datetime_tickets[$dtt->ID()] : array(); |
|
1022 | 1022 | |
1023 | - $displayrow = !empty( $ticket ) ? $ticket->get('TKT_row') : 0; |
|
1023 | + $displayrow = ! empty($ticket) ? $ticket->get('TKT_row') : 0; |
|
1024 | 1024 | $template_args = array( |
1025 | 1025 | 'dtt_row' => $default ? 'DTTNUM' : $dttrow, |
1026 | - 'tkt_row' => $default && empty( $ticket ) ? 'TICKETNUM' : $tktrow, |
|
1026 | + 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
|
1027 | 1027 | 'datetime_ticket_checked' => in_array($displayrow, $dtt_tkts) ? ' checked="checked"' : '', |
1028 | 1028 | 'ticket_selected' => in_array($displayrow, $dtt_tkts) ? ' ticket-selected' : '', |
1029 | - 'TKT_name' => $default && empty( $ticket ) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1030 | - 'tkt_status_class' => ( $default && empty( $ticket ) ) || $this->_is_creating_event ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(), |
|
1029 | + 'TKT_name' => $default && empty($ticket) ? 'TKTNAME' : $ticket->get('TKT_name'), |
|
1030 | + 'tkt_status_class' => ($default && empty($ticket)) || $this->_is_creating_event ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(), |
|
1031 | 1031 | ); |
1032 | 1032 | |
1033 | 1033 | //filter template args |
1034 | - $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 ); |
|
1034 | + $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); |
|
1035 | 1035 | |
1036 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1037 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1036 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_dtt_tickets_list.template.php'; |
|
1037 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1038 | 1038 | } |
1039 | 1039 | |
1040 | 1040 | |
@@ -1056,37 +1056,37 @@ discard block |
||
1056 | 1056 | * |
1057 | 1057 | * @return [type] [description] |
1058 | 1058 | */ |
1059 | - protected function _get_ticket_row( $tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array() ) { |
|
1059 | + protected function _get_ticket_row($tktrow, $ticket, $ticket_datetimes, $all_dtts, $default = FALSE, $all_tickets = array()) { |
|
1060 | 1060 | |
1061 | 1061 | //if $ticket is not an instance of EE_Ticket then force default to true. |
1062 | - $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1062 | + $default = ! $ticket instanceof EE_Ticket ? true : false; |
|
1063 | 1063 | |
1064 | - $prices = ! empty( $ticket ) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC') ) ) : array(); |
|
1064 | + $prices = ! empty($ticket) && ! $default ? $ticket->get_many_related('Price', array('default_where_conditions' => 'none', 'order_by' => array('PRC_order' => 'ASC'))) : array(); |
|
1065 | 1065 | |
1066 | 1066 | //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 |
1067 | 1067 | //the object. This is done by not including any query_params. |
1068 | - if ( $ticket instanceof EE_Ticket && $ticket->is_default() && ( count( $prices ) === 1 || empty( $prices ) ) ) { |
|
1069 | - $prices = $ticket->get_many_related( 'Price' ); |
|
1068 | + if ($ticket instanceof EE_Ticket && $ticket->is_default() && (count($prices) === 1 || empty($prices))) { |
|
1069 | + $prices = $ticket->get_many_related('Price'); |
|
1070 | 1070 | } |
1071 | 1071 | |
1072 | 1072 | // 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. |
1073 | - $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default') ) ? TRUE : FALSE; |
|
1073 | + $default_dtt = $default || ($ticket instanceof EE_Ticket && $ticket->get('TKT_is_default')) ? TRUE : FALSE; |
|
1074 | 1074 | |
1075 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1075 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1076 | 1076 | |
1077 | 1077 | $ticket_subtotal = $default ? 0 : $ticket->get_ticket_subtotal(); |
1078 | - $base_price = $default ? NULL : $ticket->base_price(); |
|
1078 | + $base_price = $default ? NULL : $ticket->base_price(); |
|
1079 | 1079 | $count_price_mods = EEM_Price::instance()->get_all_default_prices(TRUE); |
1080 | 1080 | |
1081 | 1081 | //breaking out complicated condition for ticket_status |
1082 | - if ( $default ) { |
|
1083 | - $ticket_status_class = ' tkt-status-' . EE_Ticket::onsale; |
|
1082 | + if ($default) { |
|
1083 | + $ticket_status_class = ' tkt-status-'.EE_Ticket::onsale; |
|
1084 | 1084 | } else { |
1085 | - $ticket_status_class = $ticket->is_default() ? ' tkt-status-' . EE_Ticket::onsale : ' tkt-status-' . $ticket->ticket_status(); |
|
1085 | + $ticket_status_class = $ticket->is_default() ? ' tkt-status-'.EE_Ticket::onsale : ' tkt-status-'.$ticket->ticket_status(); |
|
1086 | 1086 | } |
1087 | 1087 | |
1088 | 1088 | //breaking out complicated condition for TKT_taxable |
1089 | - if ( $default ) { |
|
1089 | + if ($default) { |
|
1090 | 1090 | $TKT_taxable = ''; |
1091 | 1091 | } else { |
1092 | 1092 | $TKT_taxable = $ticket->get('TKT_taxable') ? ' checked="checked"' : ''; |
@@ -1101,19 +1101,19 @@ discard block |
||
1101 | 1101 | 'edit_tkt_expanded' => '', |
1102 | 1102 | 'edit_tickets_name' => $default ? 'TICKETNAMEATTR' : 'edit_tickets', |
1103 | 1103 | 'TKT_name' => $default ? '' : $ticket->get('TKT_name'), |
1104 | - 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1105 | - 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ), |
|
1106 | - '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), |
|
1104 | + 'TKT_start_date' => $default ? '' : $ticket->get_date('TKT_start_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1105 | + 'TKT_end_date' => $default ? '' : $ticket->get_date('TKT_end_date', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']), |
|
1106 | + '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), |
|
1107 | 1107 | 'TKT_price' => $default ? '' : EEH_Template::format_currency($ticket->get_ticket_total_with_taxes(), FALSE, FALSE), |
1108 | 1108 | 'TKT_price_code' => EE_Registry::instance()->CFG->currency->code, |
1109 | 1109 | 'TKT_price_amount' => $default ? 0 : $ticket_subtotal, |
1110 | - 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty','symbol'), |
|
1111 | - 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty','input'), |
|
1112 | - 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses','input'), |
|
1113 | - 'TKT_min' => $default ? '' : ( $ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min') ), |
|
1114 | - 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max','input'), |
|
1110 | + 'TKT_qty' => $default ? '' : $ticket->get_pretty('TKT_qty', 'symbol'), |
|
1111 | + 'TKT_qty_for_input'=> $default ? '' : $ticket->get_pretty('TKT_qty', 'input'), |
|
1112 | + 'TKT_uses' => $default ? '' : $ticket->get_pretty('TKT_uses', 'input'), |
|
1113 | + 'TKT_min' => $default ? '' : ($ticket->get('TKT_min') === -1 || $ticket->get('TKT_min') === 0 ? '' : $ticket->get('TKT_min')), |
|
1114 | + 'TKT_max' => $default ? '' : $ticket->get_pretty('TKT_max', 'input'), |
|
1115 | 1115 | 'TKT_sold' => $default ? 0 : $ticket->tickets_sold('ticket'), |
1116 | - 'TKT_registrations' => $default ? 0 : $ticket->count_registrations( array( array( 'STS_ID' => array( '!=', EEM_Registration::status_id_incomplete ) ) ) ), |
|
1116 | + 'TKT_registrations' => $default ? 0 : $ticket->count_registrations(array(array('STS_ID' => array('!=', EEM_Registration::status_id_incomplete)))), |
|
1117 | 1117 | 'TKT_ID' => $default ? 0 : $ticket->get('TKT_ID'), |
1118 | 1118 | 'TKT_description' => $default ? '' : $ticket->get('TKT_description'), |
1119 | 1119 | 'TKT_is_default' => $default ? 0 : $ticket->get('TKT_is_default'), |
@@ -1122,99 +1122,99 @@ discard block |
||
1122 | 1122 | 'ticket_price_rows' => '', |
1123 | 1123 | 'TKT_base_price' => $default || ! $base_price instanceof EE_Price ? '' : $base_price->get_pretty('PRC_amount', 'localized_float'), |
1124 | 1124 | 'TKT_base_price_ID' => $default || ! $base_price instanceof EE_Price ? 0 : $base_price->ID(), |
1125 | - 'show_price_modifier' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) ? '' : ' style="display:none;"', |
|
1126 | - 'show_price_mod_button' => count($prices) > 1 || ( $default && $count_price_mods > 0 ) || ( !$default && $ticket->get('TKT_deleted') ) ? ' style="display:none;"' : '', |
|
1125 | + 'show_price_modifier' => count($prices) > 1 || ($default && $count_price_mods > 0) ? '' : ' style="display:none;"', |
|
1126 | + 'show_price_mod_button' => count($prices) > 1 || ($default && $count_price_mods > 0) || ( ! $default && $ticket->get('TKT_deleted')) ? ' style="display:none;"' : '', |
|
1127 | 1127 | 'total_price_rows' => count($prices) > 1 ? count($prices) : 1, |
1128 | 1128 | 'ticket_datetimes_list' => $default ? '<li class="hidden"></li>' : '', |
1129 | 1129 | 'starting_ticket_datetime_rows' => $default || $default_dtt ? '' : implode(',', $tkt_dtts), |
1130 | 1130 | 'ticket_datetime_rows' => $default ? '' : implode(',', $tkt_dtts), |
1131 | - 'existing_ticket_price_ids' => $default, '', implode(',', array_keys( $prices) ), |
|
1131 | + 'existing_ticket_price_ids' => $default, '', implode(',', array_keys($prices)), |
|
1132 | 1132 | 'ticket_template_id' => $default ? 0 : $ticket->get('TTM_ID'), |
1133 | 1133 | 'TKT_taxable' => $TKT_taxable, |
1134 | 1134 | 'display_subtotal' => $ticket instanceof EE_Ticket && $ticket->get('TKT_taxable') ? '' : ' style="display:none"', |
1135 | 1135 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1136 | - 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE ), |
|
1136 | + 'TKT_subtotal_amount_display' => EEH_Template::format_currency($ticket_subtotal, FALSE, FALSE), |
|
1137 | 1137 | 'TKT_subtotal_amount' => $ticket_subtotal, |
1138 | - 'tax_rows' => $this->_get_tax_rows( $tktrow, $ticket ), |
|
1139 | - 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE: FALSE, |
|
1138 | + 'tax_rows' => $this->_get_tax_rows($tktrow, $ticket), |
|
1139 | + 'disabled' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? TRUE : FALSE, |
|
1140 | 1140 | 'ticket_archive_class' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? ' ticket-archived' : '', |
1141 | 1141 | 'trash_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? 'ee-lock-icon ' : 'trash-icon dashicons dashicons-post-trash clickable', |
1142 | 1142 | 'clone_icon' => $ticket instanceof EE_Ticket && $ticket->get('TKT_deleted') ? '' : 'clone-icon ee-icon ee-icon-clone clickable' |
1143 | 1143 | ); |
1144 | 1144 | |
1145 | - $template_args['trash_hidden'] = count( $all_tickets ) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1145 | + $template_args['trash_hidden'] = count($all_tickets) === 1 && $template_args['trash_icon'] != 'ee-lock-icon' ? ' style="display:none"' : ''; |
|
1146 | 1146 | |
1147 | 1147 | //handle rows that should NOT be empty |
1148 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1148 | + if (empty($template_args['TKT_start_date'])) { |
|
1149 | 1149 | //if empty then the start date will be now. |
1150 | - $template_args['TKT_start_date'] = date( $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] , current_time('timestamp')); |
|
1151 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1150 | + $template_args['TKT_start_date'] = date($this->_date_format_strings['date'].' '.$this->_date_format_strings['time'], current_time('timestamp')); |
|
1151 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1152 | 1152 | } |
1153 | 1153 | |
1154 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1154 | + if (empty($template_args['TKT_end_date'])) { |
|
1155 | 1155 | |
1156 | 1156 | //get the earliest datetime (if present); |
1157 | - $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; |
|
1157 | + $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; |
|
1158 | 1158 | |
1159 | - if ( !empty( $earliest_dtt ) ) { |
|
1160 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'] . ' ' . $this->_date_format_strings['time'] ); |
|
1159 | + if ( ! empty($earliest_dtt)) { |
|
1160 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', $this->_date_format_strings['date'].' '.$this->_date_format_strings['time']); |
|
1161 | 1161 | } else { |
1162 | 1162 | //default so let's just use what's been set for the default date-time which is 30 days from now. |
1163 | - $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") ) ); |
|
1163 | + $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"))); |
|
1164 | 1164 | } |
1165 | - $template_args['tkt_status_class'] = ' tkt-status-' . EE_Ticket::onsale; |
|
1165 | + $template_args['tkt_status_class'] = ' tkt-status-'.EE_Ticket::onsale; |
|
1166 | 1166 | } |
1167 | 1167 | |
1168 | 1168 | //generate ticket_datetime items |
1169 | - if ( ! $default ) { |
|
1169 | + if ( ! $default) { |
|
1170 | 1170 | $dttrow = 1; |
1171 | - foreach ( $all_dtts as $dtt ) { |
|
1172 | - $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ); |
|
1171 | + foreach ($all_dtts as $dtt) { |
|
1172 | + $template_args['ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default); |
|
1173 | 1173 | $dttrow++; |
1174 | 1174 | } |
1175 | 1175 | } |
1176 | 1176 | |
1177 | 1177 | $prcrow = 1; |
1178 | - foreach ( $prices as $price ) { |
|
1179 | - if ( $price->is_base_price() ) { |
|
1178 | + foreach ($prices as $price) { |
|
1179 | + if ($price->is_base_price()) { |
|
1180 | 1180 | $prcrow++; |
1181 | 1181 | continue; |
1182 | 1182 | } |
1183 | - $show_trash = ( count( $prices ) > 1 && $prcrow === 1 ) || count( $prices ) === 1 ? FALSE : TRUE; |
|
1184 | - $show_create = count( $prices ) > 1 && count( $prices ) !== $prcrow ? FALSE : TRUE; |
|
1185 | - $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create ); |
|
1183 | + $show_trash = (count($prices) > 1 && $prcrow === 1) || count($prices) === 1 ? FALSE : TRUE; |
|
1184 | + $show_create = count($prices) > 1 && count($prices) !== $prcrow ? FALSE : TRUE; |
|
1185 | + $template_args['ticket_price_rows'] .= $this->_get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash, $show_create); |
|
1186 | 1186 | $prcrow++; |
1187 | 1187 | } |
1188 | 1188 | |
1189 | 1189 | //filter $template_args |
1190 | - $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 ); |
|
1190 | + $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); |
|
1191 | 1191 | |
1192 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_row.template.php'; |
|
1193 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1192 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_row.template.php'; |
|
1193 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1194 | 1194 | } |
1195 | 1195 | |
1196 | 1196 | |
1197 | 1197 | |
1198 | 1198 | |
1199 | 1199 | |
1200 | - protected function _get_tax_rows( $tktrow, $ticket ) { |
|
1200 | + protected function _get_tax_rows($tktrow, $ticket) { |
|
1201 | 1201 | $tax_rows = ''; |
1202 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1202 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_tax_row.template.php'; |
|
1203 | 1203 | $template_args = array(); |
1204 | - $taxes = empty( $ticket ) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1205 | - foreach ( $taxes as $tax ) { |
|
1206 | - $tax_added = $this->_get_tax_added( $tax, $ticket ); |
|
1204 | + $taxes = empty($ticket) ? EE_Taxes::get_taxes_for_admin() : $ticket->get_ticket_taxes_for_admin(); |
|
1205 | + foreach ($taxes as $tax) { |
|
1206 | + $tax_added = $this->_get_tax_added($tax, $ticket); |
|
1207 | 1207 | $template_args = array( |
1208 | - 'display_tax' => !empty( $ticket ) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1208 | + 'display_tax' => ! empty($ticket) && $ticket->get('TKT_taxable') ? '' : ' style="display:none;"', |
|
1209 | 1209 | 'tax_id' => $tax->ID(), |
1210 | 1210 | 'tkt_row' => $tktrow, |
1211 | 1211 | 'tax_label' => $tax->get('PRC_name'), |
1212 | 1212 | 'tax_added' => $tax_added, |
1213 | - 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE ), |
|
1213 | + 'tax_added_display' => EEH_Template::format_currency($tax_added, FALSE, FALSE), |
|
1214 | 1214 | 'tax_amount' => $tax->get('PRC_amount') |
1215 | 1215 | ); |
1216 | - $template_args = apply_filters( 'FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event ); |
|
1217 | - $tax_rows .= EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1216 | + $template_args = apply_filters('FHEE__espresso_events_Pricing_Hooks___get_tax_rows__template_args', $template_args, $tktrow, $ticket, $this->_is_creating_event); |
|
1217 | + $tax_rows .= EEH_Template::display_template($template, $template_args, TRUE); |
|
1218 | 1218 | } |
1219 | 1219 | |
1220 | 1220 | |
@@ -1222,81 +1222,81 @@ discard block |
||
1222 | 1222 | } |
1223 | 1223 | |
1224 | 1224 | |
1225 | - protected function _get_tax_added( EE_Price $tax, $ticket ) { |
|
1226 | - $subtotal = empty( $ticket ) ? 0 : $ticket->get_ticket_subtotal(); |
|
1225 | + protected function _get_tax_added(EE_Price $tax, $ticket) { |
|
1226 | + $subtotal = empty($ticket) ? 0 : $ticket->get_ticket_subtotal(); |
|
1227 | 1227 | return $subtotal * $tax->get('PRC_amount') / 100; |
1228 | 1228 | } |
1229 | 1229 | |
1230 | 1230 | |
1231 | 1231 | |
1232 | 1232 | |
1233 | - protected function _get_ticket_price_row( $tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE ) { |
|
1234 | - $send_disabled = !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1233 | + protected function _get_ticket_price_row($tktrow, $prcrow, $price, $default, $ticket, $show_trash = TRUE, $show_create = TRUE) { |
|
1234 | + $send_disabled = ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE; |
|
1235 | 1235 | $template_args = array( |
1236 | 1236 | 'tkt_row' => $default && empty($ticket) ? 'TICKETNUM' : $tktrow, |
1237 | 1237 | 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
1238 | 1238 | 'edit_prices_name' => $default && empty($price) ? 'PRICENAMEATTR' : 'edit_prices', |
1239 | - '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 ), |
|
1239 | + '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), |
|
1240 | 1240 | 'PRC_ID' => $default && empty($price) ? 0 : $price->ID(), |
1241 | 1241 | 'PRC_is_default' => $default && empty($price) ? 0 : $price->get('PRC_is_default'), |
1242 | 1242 | 'PRC_name' => $default && empty($price) ? '' : $price->get('PRC_name'), |
1243 | 1243 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1244 | 1244 | 'show_plus_or_minus' => $default && empty($price) ? '' : ' style="display:none;"', |
1245 | - 'show_plus' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1246 | - 'show_minus' => $default && empty( $price ) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1247 | - 'show_currency_symbol' => $default && empty( $price ) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : '' ), |
|
1248 | - 'PRC_amount' => $default && empty( $price ) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1249 | - 'show_percentage' => $default && empty( $price ) ? ' style="display:none;"' : ( $price->is_percent() ? '' : ' style="display:none;"' ), |
|
1245 | + 'show_plus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() || $price->is_base_price() ? ' style="display:none;"' : ''), |
|
1246 | + 'show_minus' => $default && empty($price) ? ' style="display:none;"' : ($price->is_discount() ? '' : ' style="display:none;"'), |
|
1247 | + 'show_currency_symbol' => $default && empty($price) ? ' style="display:none"' : ($price->is_percent() ? ' style="display:none"' : ''), |
|
1248 | + 'PRC_amount' => $default && empty($price) ? 0 : $price->get_pretty('PRC_amount', 'localized_float'), |
|
1249 | + 'show_percentage' => $default && empty($price) ? ' style="display:none;"' : ($price->is_percent() ? '' : ' style="display:none;"'), |
|
1250 | 1250 | 'show_trash_icon' => $show_trash ? '' : ' style="display:none;"', |
1251 | 1251 | 'show_create_button' => $show_create ? '' : ' style="display:none;"', |
1252 | - 'PRC_desc' => $default && empty( $price ) ? '' : $price->get('PRC_desc'), |
|
1253 | - 'disabled' => !empty( $ticket ) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1252 | + 'PRC_desc' => $default && empty($price) ? '' : $price->get('PRC_desc'), |
|
1253 | + 'disabled' => ! empty($ticket) && $ticket->get('TKT_deleted') ? TRUE : FALSE |
|
1254 | 1254 | ); |
1255 | 1255 | |
1256 | - $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 ); |
|
1256 | + $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); |
|
1257 | 1257 | |
1258 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_price_row.template.php'; |
|
1259 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1258 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_price_row.template.php'; |
|
1259 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1260 | 1260 | } |
1261 | 1261 | |
1262 | 1262 | |
1263 | - protected function _get_price_type_selector( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1264 | - if ( $price->is_base_price() ) { |
|
1265 | - return $this->_get_base_price_template( $tktrow, $prcrow, $price, $default ); |
|
1263 | + protected function _get_price_type_selector($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1264 | + if ($price->is_base_price()) { |
|
1265 | + return $this->_get_base_price_template($tktrow, $prcrow, $price, $default); |
|
1266 | 1266 | } else { |
1267 | - return $this->_get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled ); |
|
1267 | + return $this->_get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled); |
|
1268 | 1268 | } |
1269 | 1269 | |
1270 | 1270 | } |
1271 | 1271 | |
1272 | 1272 | |
1273 | - protected function _get_base_price_template( $tktrow, $prcrow, $price, $default ) { |
|
1273 | + protected function _get_base_price_template($tktrow, $prcrow, $price, $default) { |
|
1274 | 1274 | $template_args = array( |
1275 | 1275 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1276 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1277 | - 'PRT_ID' => $default && empty( $price ) ? 1 : $price->get('PRT_ID'), |
|
1276 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1277 | + 'PRT_ID' => $default && empty($price) ? 1 : $price->get('PRT_ID'), |
|
1278 | 1278 | 'PRT_name' => __('Price', 'event_espresso'), |
1279 | 1279 | 'price_selected_operator' => '+', |
1280 | 1280 | 'price_selected_is_percent' => 0 |
1281 | 1281 | ); |
1282 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_type_base.template.php'; |
|
1282 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_type_base.template.php'; |
|
1283 | 1283 | |
1284 | - $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 ); |
|
1284 | + $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); |
|
1285 | 1285 | |
1286 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1286 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1287 | 1287 | } |
1288 | 1288 | |
1289 | 1289 | |
1290 | 1290 | |
1291 | - protected function _get_price_modifier_template( $tktrow, $prcrow, $price, $default, $disabled = FALSE ) { |
|
1292 | - $select_name = $default && empty( $price ) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices[' . $tktrow . '][' . $prcrow . '][PRT_ID]'; |
|
1293 | - $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array( array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3' ) ) ) ); |
|
1294 | - $price_option_span_template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_option_span.template.php'; |
|
1295 | - $all_price_types = $default && empty( $price ) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso')) ) : array(); |
|
1296 | - $selected_price_type_id = $default && empty( $price ) ? 0 : $price->type(); |
|
1291 | + protected function _get_price_modifier_template($tktrow, $prcrow, $price, $default, $disabled = FALSE) { |
|
1292 | + $select_name = $default && empty($price) ? 'edit_prices[TICKETNUM][PRICENUM][PRT_ID]' : 'edit_prices['.$tktrow.']['.$prcrow.'][PRT_ID]'; |
|
1293 | + $price_types = EE_Registry::instance()->load_model('Price_Type')->get_all(array(array('OR' => array('PBT_ID' => '2', 'PBT_ID*' => '3')))); |
|
1294 | + $price_option_span_template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_option_span.template.php'; |
|
1295 | + $all_price_types = $default && empty($price) ? array(array('id' => 0, 'text' => __('Select Modifier', 'event_espresso'))) : array(); |
|
1296 | + $selected_price_type_id = $default && empty($price) ? 0 : $price->type(); |
|
1297 | 1297 | $price_option_spans = ''; |
1298 | 1298 | //setup pricetypes for selector |
1299 | - foreach ( $price_types as $price_type ) { |
|
1299 | + foreach ($price_types as $price_type) { |
|
1300 | 1300 | $all_price_types[] = array( |
1301 | 1301 | 'id' => $price_type->ID(), |
1302 | 1302 | 'text' => $price_type->get('PRT_name'), |
@@ -1308,50 +1308,50 @@ discard block |
||
1308 | 1308 | 'PRT_operator' => $price_type->is_discount() ? '-' : '+', |
1309 | 1309 | 'PRT_is_percent' => $price_type->get('PRT_is_percent') ? 1 : 0 |
1310 | 1310 | ); |
1311 | - $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE ); |
|
1311 | + $price_option_spans .= EEH_Template::display_template($price_option_span_template, $spanargs, TRUE); |
|
1312 | 1312 | } |
1313 | 1313 | |
1314 | - $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1314 | + $select_params = $disabled ? 'style="width:auto;" disabled' : 'style="width:auto;"'; |
|
1315 | 1315 | $main_name = $select_name; |
1316 | - $select_name = $disabled ? 'archive_price[' . $tktrow . '][' . $prcrow . '][PRT_ID]' : $main_name; |
|
1316 | + $select_name = $disabled ? 'archive_price['.$tktrow.']['.$prcrow.'][PRT_ID]' : $main_name; |
|
1317 | 1317 | |
1318 | 1318 | $template_args = array( |
1319 | 1319 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1320 | - 'PRC_order' => $default && empty( $price ) ? 'PRICENUM' : $prcrow, |
|
1321 | - 'price_modifier_selector' => EEH_Form_Fields::select_input( $select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID' ), |
|
1320 | + 'PRC_order' => $default && empty($price) ? 'PRICENUM' : $prcrow, |
|
1321 | + 'price_modifier_selector' => EEH_Form_Fields::select_input($select_name, $all_price_types, $selected_price_type_id, $select_params, 'edit-price-PRT_ID'), |
|
1322 | 1322 | 'main_name' => $main_name, |
1323 | 1323 | 'selected_price_type_id' => $selected_price_type_id, |
1324 | 1324 | 'price_option_spans' => $price_option_spans, |
1325 | - 'price_selected_operator' => $default && empty( $price ) ? '' : ( $price->is_discount() ? '-' : '+' ), |
|
1326 | - 'price_selected_is_percent' => $default && empty( $price ) ? '' : ( $price->is_percent() ? 1 : 0 ), |
|
1325 | + 'price_selected_operator' => $default && empty($price) ? '' : ($price->is_discount() ? '-' : '+'), |
|
1326 | + 'price_selected_is_percent' => $default && empty($price) ? '' : ($price->is_percent() ? 1 : 0), |
|
1327 | 1327 | 'disabled' => $disabled |
1328 | 1328 | ); |
1329 | 1329 | |
1330 | - $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 ); |
|
1330 | + $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); |
|
1331 | 1331 | |
1332 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1332 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_price_modifier_selector.template.php'; |
|
1333 | 1333 | |
1334 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1334 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1335 | 1335 | } |
1336 | 1336 | |
1337 | 1337 | |
1338 | 1338 | |
1339 | - protected function _get_ticket_datetime_list_item( $dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default ) { |
|
1340 | - $dttid = !empty($dtt) ? $dtt->ID() : 0; |
|
1341 | - $displayrow = !empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1342 | - $tkt_dtts = $ticket instanceof EE_Ticket && isset( $ticket_datetimes[$ticket->ID()] ) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1339 | + protected function _get_ticket_datetime_list_item($dttrow, $tktrow, $dtt, $ticket, $ticket_datetimes, $default) { |
|
1340 | + $dttid = ! empty($dtt) ? $dtt->ID() : 0; |
|
1341 | + $displayrow = ! empty($dtt) ? $dtt->get('DTT_order') : 0; |
|
1342 | + $tkt_dtts = $ticket instanceof EE_Ticket && isset($ticket_datetimes[$ticket->ID()]) ? $ticket_datetimes[$ticket->ID()] : array(); |
|
1343 | 1343 | $template_args = array( |
1344 | - 'dtt_row' => $default && empty( $dtt ) ? 'DTTNUM' : $dttrow, |
|
1344 | + 'dtt_row' => $default && empty($dtt) ? 'DTTNUM' : $dttrow, |
|
1345 | 1345 | 'tkt_row' => $default ? 'TICKETNUM' : $tktrow, |
1346 | - 'ticket_datetime_selected' => in_array( $displayrow, $tkt_dtts ) ? ' ticket-selected' : '', |
|
1347 | - 'ticket_datetime_checked' => in_array( $displayrow, $tkt_dtts ) ? ' checked="checked"' : '', |
|
1348 | - 'DTT_name' => $default && empty( $dtt ) ? 'DTTNAME' : $dtt->get_dtt_display_name( TRUE ), |
|
1346 | + 'ticket_datetime_selected' => in_array($displayrow, $tkt_dtts) ? ' ticket-selected' : '', |
|
1347 | + 'ticket_datetime_checked' => in_array($displayrow, $tkt_dtts) ? ' checked="checked"' : '', |
|
1348 | + 'DTT_name' => $default && empty($dtt) ? 'DTTNAME' : $dtt->get_dtt_display_name(TRUE), |
|
1349 | 1349 | 'tkt_status_class' => '', |
1350 | 1350 | ); |
1351 | 1351 | |
1352 | - $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 ); |
|
1353 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1354 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1352 | + $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); |
|
1353 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_datetimes_list_item.template.php'; |
|
1354 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1355 | 1355 | } |
1356 | 1356 | |
1357 | 1357 | |
@@ -1359,53 +1359,53 @@ discard block |
||
1359 | 1359 | protected function _get_ticket_js_structure($all_dtts, $all_tickets) { |
1360 | 1360 | $template_args = array( |
1361 | 1361 | 'default_datetime_edit_row' => $this->_get_dtt_edit_row('DTTNUM', NULL, TRUE, $all_dtts), |
1362 | - 'default_ticket_row' => $this->_get_ticket_row( 'TICKETNUM', NULL, array(), array(), TRUE), |
|
1363 | - 'default_price_row' => $this->_get_ticket_price_row( 'TICKETNUM', 'PRICENUM', NULL, TRUE, NULL ), |
|
1362 | + 'default_ticket_row' => $this->_get_ticket_row('TICKETNUM', NULL, array(), array(), TRUE), |
|
1363 | + 'default_price_row' => $this->_get_ticket_price_row('TICKETNUM', 'PRICENUM', NULL, TRUE, NULL), |
|
1364 | 1364 | 'default_price_rows' => '', |
1365 | 1365 | 'default_base_price_amount' => 0, |
1366 | 1366 | 'default_base_price_name' => '', |
1367 | 1367 | 'default_base_price_description' => '', |
1368 | - 'default_price_modifier_selector_row' => $this->_get_price_modifier_template( 'TICKETNUM', 'PRICENUM', NULL, TRUE ), |
|
1369 | - 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row( 'DTTNUM', NULL, array(), array(), TRUE ), |
|
1368 | + 'default_price_modifier_selector_row' => $this->_get_price_modifier_template('TICKETNUM', 'PRICENUM', NULL, TRUE), |
|
1369 | + 'default_available_tickets_for_datetime' => $this->_get_dtt_attached_tickets_row('DTTNUM', NULL, array(), array(), TRUE), |
|
1370 | 1370 | 'existing_available_datetime_tickets_list' => '', |
1371 | 1371 | 'existing_available_ticket_datetimes_list' => '', |
1372 | - 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ), |
|
1373 | - 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item( 'DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE ) |
|
1372 | + 'new_available_datetime_ticket_list_item' => $this->_get_datetime_tickets_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE), |
|
1373 | + 'new_available_ticket_datetime_list_item' => $this->_get_ticket_datetime_list_item('DTTNUM', 'TICKETNUM', NULL, NULL, array(), TRUE) |
|
1374 | 1374 | ); |
1375 | 1375 | |
1376 | 1376 | $tktrow = 1; |
1377 | - foreach ( $all_tickets as $ticket ) { |
|
1378 | - $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item( 'DTTNUM', $tktrow, NULL, $ticket, array(), TRUE ); |
|
1377 | + foreach ($all_tickets as $ticket) { |
|
1378 | + $template_args['existing_available_datetime_tickets_list'] .= $this->_get_datetime_tickets_list_item('DTTNUM', $tktrow, NULL, $ticket, array(), TRUE); |
|
1379 | 1379 | $tktrow++; |
1380 | 1380 | } |
1381 | 1381 | |
1382 | 1382 | |
1383 | 1383 | $dttrow = 1; |
1384 | - foreach ( $all_dtts as $dtt ) { |
|
1385 | - $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item( $dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE ); |
|
1384 | + foreach ($all_dtts as $dtt) { |
|
1385 | + $template_args['existing_available_ticket_datetimes_list'] .= $this->_get_ticket_datetime_list_item($dttrow, 'TICKETNUM', $dtt, NULL, array(), TRUE); |
|
1386 | 1386 | $dttrow++; |
1387 | 1387 | } |
1388 | 1388 | |
1389 | 1389 | $default_prices = EE_Registry::instance()->load_model('Price')->get_all_default_prices(); |
1390 | 1390 | $prcrow = 1; |
1391 | - foreach ( $default_prices as $price ) { |
|
1392 | - if ( $price->is_base_price() ) { |
|
1391 | + foreach ($default_prices as $price) { |
|
1392 | + if ($price->is_base_price()) { |
|
1393 | 1393 | $template_args['default_base_price_amount'] = $price->get_pretty('PRC_amount', 'localized_float'); |
1394 | 1394 | $template_args['default_base_price_name'] = $price->get('PRC_name'); |
1395 | 1395 | $template_args['default_base_price_description'] = $price->get('PRC_desc'); |
1396 | 1396 | $prcrow++; |
1397 | 1397 | continue; |
1398 | 1398 | } |
1399 | - $show_trash = ( count( $default_prices ) > 1 && $prcrow === 1 ) || count( $default_prices ) === 1 ? FALSE : TRUE; |
|
1400 | - $show_create = count( $default_prices ) > 1 && count( $default_prices ) !== $prcrow ? FALSE : TRUE; |
|
1401 | - $template_args['default_price_rows'] .= $this->_get_ticket_price_row( 'TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create ); |
|
1399 | + $show_trash = (count($default_prices) > 1 && $prcrow === 1) || count($default_prices) === 1 ? FALSE : TRUE; |
|
1400 | + $show_create = count($default_prices) > 1 && count($default_prices) !== $prcrow ? FALSE : TRUE; |
|
1401 | + $template_args['default_price_rows'] .= $this->_get_ticket_price_row('TICKETNUM', $prcrow, $price, TRUE, NULL, $show_trash, $show_create); |
|
1402 | 1402 | $prcrow++; |
1403 | 1403 | } |
1404 | 1404 | |
1405 | - $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 ); |
|
1405 | + $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); |
|
1406 | 1406 | |
1407 | - $template = PRICING_TEMPLATE_PATH . 'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1408 | - return EEH_Template::display_template( $template, $template_args, TRUE ); |
|
1407 | + $template = PRICING_TEMPLATE_PATH.'event_tickets_datetime_ticket_js_structure.template.php'; |
|
1408 | + return EEH_Template::display_template($template, $template_args, TRUE); |
|
1409 | 1409 | } |
1410 | 1410 | |
1411 | 1411 |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
3 | - exit( 'NO direct script access allowed' ); |
|
2 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -63,7 +63,7 @@ discard block |
||
63 | 63 | ); |
64 | 64 | add_action( |
65 | 65 | 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
66 | - array( $this, 'verify_event_edit' ) |
|
66 | + array($this, 'verify_event_edit') |
|
67 | 67 | ); |
68 | 68 | } |
69 | 69 | |
@@ -79,22 +79,22 @@ discard block |
||
79 | 79 | $this->_admin_page_title = EVENTS_LABEL; |
80 | 80 | $this->_labels = array( |
81 | 81 | 'buttons' => array( |
82 | - 'add' => esc_html__( 'Add New Event', 'event_espresso' ), |
|
83 | - 'edit' => esc_html__( 'Edit Event', 'event_espresso' ), |
|
84 | - 'delete' => esc_html__( 'Delete Event', 'event_espresso' ), |
|
85 | - 'add_category' => esc_html__( 'Add New Category', 'event_espresso' ), |
|
86 | - 'edit_category' => esc_html__( 'Edit Category', 'event_espresso' ), |
|
87 | - 'delete_category' => esc_html__( 'Delete Category', 'event_espresso' ), |
|
82 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
83 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
84 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
85 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
86 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
87 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
88 | 88 | ), |
89 | 89 | 'editor_title' => array( |
90 | - 'espresso_events' => esc_html__( 'Enter event title here', 'event_espresso' ), |
|
90 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
91 | 91 | ), |
92 | 92 | 'publishbox' => array( |
93 | - 'create_new' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
94 | - 'edit' => esc_html__( 'Update Event', 'event_espresso' ), |
|
95 | - 'add_category' => esc_html__( 'Save New Category', 'event_espresso' ), |
|
96 | - 'edit_category' => esc_html__( 'Update Category', 'event_espresso' ), |
|
97 | - 'template_settings' => esc_html__( 'Update Settings', 'event_espresso' ), |
|
93 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
94 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
95 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
96 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
97 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
98 | 98 | ), |
99 | 99 | ); |
100 | 100 | } |
@@ -105,9 +105,9 @@ discard block |
||
105 | 105 | //load formatter helper |
106 | 106 | //load field generator helper |
107 | 107 | //is there a evt_id in the request? |
108 | - $evt_id = ! empty( $this->_req_data['EVT_ID'] ) && ! is_array( $this->_req_data['EVT_ID'] ) |
|
108 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
109 | 109 | ? $this->_req_data['EVT_ID'] : 0; |
110 | - $evt_id = ! empty( $this->_req_data['post'] ) ? $this->_req_data['post'] : $evt_id; |
|
110 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
111 | 111 | $this->_page_routes = array( |
112 | 112 | 'default' => array( |
113 | 113 | 'func' => '_events_overview_list_table', |
@@ -130,27 +130,27 @@ discard block |
||
130 | 130 | ), |
131 | 131 | 'trash_event' => array( |
132 | 132 | 'func' => '_trash_or_restore_event', |
133 | - 'args' => array( 'event_status' => 'trash' ), |
|
133 | + 'args' => array('event_status' => 'trash'), |
|
134 | 134 | 'capability' => 'ee_delete_event', |
135 | 135 | 'obj_id' => $evt_id, |
136 | 136 | 'noheader' => true, |
137 | 137 | ), |
138 | 138 | 'trash_events' => array( |
139 | 139 | 'func' => '_trash_or_restore_events', |
140 | - 'args' => array( 'event_status' => 'trash' ), |
|
140 | + 'args' => array('event_status' => 'trash'), |
|
141 | 141 | 'capability' => 'ee_delete_events', |
142 | 142 | 'noheader' => true, |
143 | 143 | ), |
144 | 144 | 'restore_event' => array( |
145 | 145 | 'func' => '_trash_or_restore_event', |
146 | - 'args' => array( 'event_status' => 'draft' ), |
|
146 | + 'args' => array('event_status' => 'draft'), |
|
147 | 147 | 'capability' => 'ee_delete_event', |
148 | 148 | 'obj_id' => $evt_id, |
149 | 149 | 'noheader' => true, |
150 | 150 | ), |
151 | 151 | 'restore_events' => array( |
152 | 152 | 'func' => '_trash_or_restore_events', |
153 | - 'args' => array( 'event_status' => 'draft' ), |
|
153 | + 'args' => array('event_status' => 'draft'), |
|
154 | 154 | 'capability' => 'ee_delete_events', |
155 | 155 | 'noheader' => true, |
156 | 156 | ), |
@@ -186,12 +186,12 @@ discard block |
||
186 | 186 | 'add_category' => array( |
187 | 187 | 'func' => '_category_details', |
188 | 188 | 'capability' => 'ee_edit_event_category', |
189 | - 'args' => array( 'add' ), |
|
189 | + 'args' => array('add'), |
|
190 | 190 | ), |
191 | 191 | 'edit_category' => array( |
192 | 192 | 'func' => '_category_details', |
193 | 193 | 'capability' => 'ee_edit_event_category', |
194 | - 'args' => array( 'edit' ), |
|
194 | + 'args' => array('edit'), |
|
195 | 195 | ), |
196 | 196 | 'delete_categories' => array( |
197 | 197 | 'func' => '_delete_categories', |
@@ -205,13 +205,13 @@ discard block |
||
205 | 205 | ), |
206 | 206 | 'insert_category' => array( |
207 | 207 | 'func' => '_insert_or_update_category', |
208 | - 'args' => array( 'new_category' => true ), |
|
208 | + 'args' => array('new_category' => true), |
|
209 | 209 | 'capability' => 'ee_edit_event_category', |
210 | 210 | 'noheader' => true, |
211 | 211 | ), |
212 | 212 | 'update_category' => array( |
213 | 213 | 'func' => '_insert_or_update_category', |
214 | - 'args' => array( 'new_category' => false ), |
|
214 | + 'args' => array('new_category' => false), |
|
215 | 215 | 'capability' => 'ee_edit_event_category', |
216 | 216 | 'noheader' => true, |
217 | 217 | ), |
@@ -228,29 +228,29 @@ discard block |
||
228 | 228 | $this->_page_config = array( |
229 | 229 | 'default' => array( |
230 | 230 | 'nav' => array( |
231 | - 'label' => esc_html__( 'Overview', 'event_espresso' ), |
|
231 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
232 | 232 | 'order' => 10, |
233 | 233 | ), |
234 | 234 | 'list_table' => 'Events_Admin_List_Table', |
235 | 235 | 'help_tabs' => array( |
236 | 236 | 'events_overview_help_tab' => array( |
237 | - 'title' => esc_html__( 'Events Overview', 'event_espresso' ), |
|
237 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
238 | 238 | 'filename' => 'events_overview', |
239 | 239 | ), |
240 | 240 | 'events_overview_table_column_headings_help_tab' => array( |
241 | - 'title' => esc_html__( 'Events Overview Table Column Headings', 'event_espresso' ), |
|
241 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
242 | 242 | 'filename' => 'events_overview_table_column_headings', |
243 | 243 | ), |
244 | 244 | 'events_overview_filters_help_tab' => array( |
245 | - 'title' => esc_html__( 'Events Overview Filters', 'event_espresso' ), |
|
245 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
246 | 246 | 'filename' => 'events_overview_filters', |
247 | 247 | ), |
248 | 248 | 'events_overview_view_help_tab' => array( |
249 | - 'title' => esc_html__( 'Events Overview Views', 'event_espresso' ), |
|
249 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
250 | 250 | 'filename' => 'events_overview_views', |
251 | 251 | ), |
252 | 252 | 'events_overview_other_help_tab' => array( |
253 | - 'title' => esc_html__( 'Events Overview Other', 'event_espresso' ), |
|
253 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
254 | 254 | 'filename' => 'events_overview_other', |
255 | 255 | ), |
256 | 256 | ), |
@@ -265,218 +265,218 @@ discard block |
||
265 | 265 | ), |
266 | 266 | 'create_new' => array( |
267 | 267 | 'nav' => array( |
268 | - 'label' => esc_html__( 'Add Event', 'event_espresso' ), |
|
268 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
269 | 269 | 'order' => 5, |
270 | 270 | 'persistent' => false, |
271 | 271 | ), |
272 | - 'metaboxes' => array( '_register_event_editor_meta_boxes' ), |
|
272 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
273 | 273 | 'help_tabs' => array( |
274 | 274 | 'event_editor_help_tab' => array( |
275 | - 'title' => esc_html__( 'Event Editor', 'event_espresso' ), |
|
275 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
276 | 276 | 'filename' => 'event_editor', |
277 | 277 | ), |
278 | 278 | 'event_editor_title_richtexteditor_help_tab' => array( |
279 | - 'title' => esc_html__( 'Event Title & Rich Text Editor', 'event_espresso' ), |
|
279 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
280 | 280 | 'filename' => 'event_editor_title_richtexteditor', |
281 | 281 | ), |
282 | 282 | 'event_editor_venue_details_help_tab' => array( |
283 | - 'title' => esc_html__( 'Event Venue Details', 'event_espresso' ), |
|
283 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
284 | 284 | 'filename' => 'event_editor_venue_details', |
285 | 285 | ), |
286 | 286 | 'event_editor_event_datetimes_help_tab' => array( |
287 | - 'title' => esc_html__( 'Event Datetimes', 'event_espresso' ), |
|
287 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
288 | 288 | 'filename' => 'event_editor_event_datetimes', |
289 | 289 | ), |
290 | 290 | 'event_editor_event_tickets_help_tab' => array( |
291 | - 'title' => esc_html__( 'Event Tickets', 'event_espresso' ), |
|
291 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
292 | 292 | 'filename' => 'event_editor_event_tickets', |
293 | 293 | ), |
294 | 294 | 'event_editor_event_registration_options_help_tab' => array( |
295 | - 'title' => esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
295 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
296 | 296 | 'filename' => 'event_editor_event_registration_options', |
297 | 297 | ), |
298 | 298 | 'event_editor_tags_categories_help_tab' => array( |
299 | - 'title' => esc_html__( 'Event Tags & Categories', 'event_espresso' ), |
|
299 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
300 | 300 | 'filename' => 'event_editor_tags_categories', |
301 | 301 | ), |
302 | 302 | 'event_editor_questions_registrants_help_tab' => array( |
303 | - 'title' => esc_html__( 'Questions for Registrants', 'event_espresso' ), |
|
303 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
304 | 304 | 'filename' => 'event_editor_questions_registrants', |
305 | 305 | ), |
306 | 306 | 'event_editor_save_new_event_help_tab' => array( |
307 | - 'title' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
307 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
308 | 308 | 'filename' => 'event_editor_save_new_event', |
309 | 309 | ), |
310 | 310 | 'event_editor_other_help_tab' => array( |
311 | - 'title' => esc_html__( 'Event Other', 'event_espresso' ), |
|
311 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
312 | 312 | 'filename' => 'event_editor_other', |
313 | 313 | ), |
314 | 314 | ), |
315 | 315 | 'help_tour' => array( |
316 | 316 | 'Event_Editor_Help_Tour', |
317 | 317 | ), |
318 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
318 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
319 | 319 | 'require_nonce' => false, |
320 | 320 | ), |
321 | 321 | 'edit' => array( |
322 | 322 | 'nav' => array( |
323 | - 'label' => esc_html__( 'Edit Event', 'event_espresso' ), |
|
323 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
324 | 324 | 'order' => 5, |
325 | 325 | 'persistent' => false, |
326 | - 'url' => isset( $this->_req_data['post'] ) |
|
326 | + 'url' => isset($this->_req_data['post']) |
|
327 | 327 | ? EE_Admin_Page::add_query_args_and_nonce( |
328 | - array( 'post' => $this->_req_data['post'], 'action' => 'edit' ), |
|
328 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
329 | 329 | $this->_current_page_view_url |
330 | 330 | ) |
331 | 331 | : $this->_admin_base_url, |
332 | 332 | ), |
333 | - 'metaboxes' => array( '_register_event_editor_meta_boxes' ), |
|
333 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
334 | 334 | 'help_tabs' => array( |
335 | 335 | 'event_editor_help_tab' => array( |
336 | - 'title' => esc_html__( 'Event Editor', 'event_espresso' ), |
|
336 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
337 | 337 | 'filename' => 'event_editor', |
338 | 338 | ), |
339 | 339 | 'event_editor_title_richtexteditor_help_tab' => array( |
340 | - 'title' => esc_html__( 'Event Title & Rich Text Editor', 'event_espresso' ), |
|
340 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
341 | 341 | 'filename' => 'event_editor_title_richtexteditor', |
342 | 342 | ), |
343 | 343 | 'event_editor_venue_details_help_tab' => array( |
344 | - 'title' => esc_html__( 'Event Venue Details', 'event_espresso' ), |
|
344 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
345 | 345 | 'filename' => 'event_editor_venue_details', |
346 | 346 | ), |
347 | 347 | 'event_editor_event_datetimes_help_tab' => array( |
348 | - 'title' => esc_html__( 'Event Datetimes', 'event_espresso' ), |
|
348 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
349 | 349 | 'filename' => 'event_editor_event_datetimes', |
350 | 350 | ), |
351 | 351 | 'event_editor_event_tickets_help_tab' => array( |
352 | - 'title' => esc_html__( 'Event Tickets', 'event_espresso' ), |
|
352 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
353 | 353 | 'filename' => 'event_editor_event_tickets', |
354 | 354 | ), |
355 | 355 | 'event_editor_event_registration_options_help_tab' => array( |
356 | - 'title' => esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
356 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
357 | 357 | 'filename' => 'event_editor_event_registration_options', |
358 | 358 | ), |
359 | 359 | 'event_editor_tags_categories_help_tab' => array( |
360 | - 'title' => esc_html__( 'Event Tags & Categories', 'event_espresso' ), |
|
360 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
361 | 361 | 'filename' => 'event_editor_tags_categories', |
362 | 362 | ), |
363 | 363 | 'event_editor_questions_registrants_help_tab' => array( |
364 | - 'title' => esc_html__( 'Questions for Registrants', 'event_espresso' ), |
|
364 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
365 | 365 | 'filename' => 'event_editor_questions_registrants', |
366 | 366 | ), |
367 | 367 | 'event_editor_save_new_event_help_tab' => array( |
368 | - 'title' => esc_html__( 'Save New Event', 'event_espresso' ), |
|
368 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
369 | 369 | 'filename' => 'event_editor_save_new_event', |
370 | 370 | ), |
371 | 371 | 'event_editor_other_help_tab' => array( |
372 | - 'title' => esc_html__( 'Event Other', 'event_espresso' ), |
|
372 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
373 | 373 | 'filename' => 'event_editor_other', |
374 | 374 | ), |
375 | 375 | ), |
376 | 376 | /*'help_tour' => array( |
377 | 377 | 'Event_Edit_Help_Tour' |
378 | 378 | ),*/ |
379 | - 'qtips' => array( 'EE_Event_Editor_Decaf_Tips' ), |
|
379 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
380 | 380 | 'require_nonce' => false, |
381 | 381 | ), |
382 | 382 | 'default_event_settings' => array( |
383 | 383 | 'nav' => array( |
384 | - 'label' => esc_html__( 'Default Settings', 'event_espresso' ), |
|
384 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
385 | 385 | 'order' => 40, |
386 | 386 | ), |
387 | - 'metaboxes' => array_merge( $this->_default_espresso_metaboxes, array( '_publish_post_box' ) ), |
|
387 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
388 | 388 | 'labels' => array( |
389 | - 'publishbox' => esc_html__( 'Update Settings', 'event_espresso' ), |
|
389 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
390 | 390 | ), |
391 | 391 | 'help_tabs' => array( |
392 | 392 | 'default_settings_help_tab' => array( |
393 | - 'title' => esc_html__( 'Default Event Settings', 'event_espresso' ), |
|
393 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
394 | 394 | 'filename' => 'events_default_settings', |
395 | 395 | ), |
396 | 396 | 'default_settings_status_help_tab' => array( |
397 | - 'title' => esc_html__( 'Default Registration Status', 'event_espresso' ), |
|
397 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
398 | 398 | 'filename' => 'events_default_settings_status', |
399 | 399 | ), |
400 | 400 | ), |
401 | - 'help_tour' => array( 'Event_Default_Settings_Help_Tour' ), |
|
401 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
402 | 402 | 'require_nonce' => false, |
403 | 403 | ), |
404 | 404 | //template settings |
405 | 405 | 'template_settings' => array( |
406 | 406 | 'nav' => array( |
407 | - 'label' => esc_html__( 'Templates', 'event_espresso' ), |
|
407 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
408 | 408 | 'order' => 30, |
409 | 409 | ), |
410 | 410 | 'metaboxes' => $this->_default_espresso_metaboxes, |
411 | 411 | 'help_tabs' => array( |
412 | 412 | 'general_settings_templates_help_tab' => array( |
413 | - 'title' => esc_html__( 'Templates', 'event_espresso' ), |
|
413 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
414 | 414 | 'filename' => 'general_settings_templates', |
415 | 415 | ), |
416 | 416 | ), |
417 | - 'help_tour' => array( 'Templates_Help_Tour' ), |
|
417 | + 'help_tour' => array('Templates_Help_Tour'), |
|
418 | 418 | 'require_nonce' => false, |
419 | 419 | ), |
420 | 420 | //event category stuff |
421 | 421 | 'add_category' => array( |
422 | 422 | 'nav' => array( |
423 | - 'label' => esc_html__( 'Add Category', 'event_espresso' ), |
|
423 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
424 | 424 | 'order' => 15, |
425 | 425 | 'persistent' => false, |
426 | 426 | ), |
427 | 427 | 'help_tabs' => array( |
428 | 428 | 'add_category_help_tab' => array( |
429 | - 'title' => esc_html__( 'Add New Event Category', 'event_espresso' ), |
|
429 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
430 | 430 | 'filename' => 'events_add_category', |
431 | 431 | ), |
432 | 432 | ), |
433 | - 'help_tour' => array( 'Event_Add_Category_Help_Tour' ), |
|
434 | - 'metaboxes' => array( '_publish_post_box' ), |
|
433 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
434 | + 'metaboxes' => array('_publish_post_box'), |
|
435 | 435 | 'require_nonce' => false, |
436 | 436 | ), |
437 | 437 | 'edit_category' => array( |
438 | 438 | 'nav' => array( |
439 | - 'label' => esc_html__( 'Edit Category', 'event_espresso' ), |
|
439 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
440 | 440 | 'order' => 15, |
441 | 441 | 'persistent' => false, |
442 | - 'url' => isset( $this->_req_data['EVT_CAT_ID'] ) |
|
442 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
443 | 443 | ? add_query_arg( |
444 | - array( 'EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID'] ), |
|
444 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
445 | 445 | $this->_current_page_view_url |
446 | 446 | ) |
447 | 447 | : $this->_admin_base_url, |
448 | 448 | ), |
449 | 449 | 'help_tabs' => array( |
450 | 450 | 'edit_category_help_tab' => array( |
451 | - 'title' => esc_html__( 'Edit Event Category', 'event_espresso' ), |
|
451 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
452 | 452 | 'filename' => 'events_edit_category', |
453 | 453 | ), |
454 | 454 | ), |
455 | 455 | /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
456 | - 'metaboxes' => array( '_publish_post_box' ), |
|
456 | + 'metaboxes' => array('_publish_post_box'), |
|
457 | 457 | 'require_nonce' => false, |
458 | 458 | ), |
459 | 459 | 'category_list' => array( |
460 | 460 | 'nav' => array( |
461 | - 'label' => esc_html__( 'Categories', 'event_espresso' ), |
|
461 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
462 | 462 | 'order' => 20, |
463 | 463 | ), |
464 | 464 | 'list_table' => 'Event_Categories_Admin_List_Table', |
465 | 465 | 'help_tabs' => array( |
466 | 466 | 'events_categories_help_tab' => array( |
467 | - 'title' => esc_html__( 'Event Categories', 'event_espresso' ), |
|
467 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
468 | 468 | 'filename' => 'events_categories', |
469 | 469 | ), |
470 | 470 | 'events_categories_table_column_headings_help_tab' => array( |
471 | - 'title' => esc_html__( 'Event Categories Table Column Headings', 'event_espresso' ), |
|
471 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
472 | 472 | 'filename' => 'events_categories_table_column_headings', |
473 | 473 | ), |
474 | 474 | 'events_categories_view_help_tab' => array( |
475 | - 'title' => esc_html__( 'Event Categories Views', 'event_espresso' ), |
|
475 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
476 | 476 | 'filename' => 'events_categories_views', |
477 | 477 | ), |
478 | 478 | 'events_categories_other_help_tab' => array( |
479 | - 'title' => esc_html__( 'Event Categories Other', 'event_espresso' ), |
|
479 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
480 | 480 | 'filename' => 'events_categories_other', |
481 | 481 | ), |
482 | 482 | ), |
@@ -505,7 +505,7 @@ discard block |
||
505 | 505 | |
506 | 506 | protected function _add_screen_options_category_list() { |
507 | 507 | $page_title = $this->_admin_page_title; |
508 | - $this->_admin_page_title = esc_html__( 'Categories', 'event_espresso' ); |
|
508 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
509 | 509 | $this->_per_page_screen_option(); |
510 | 510 | $this->_admin_page_title = $page_title; |
511 | 511 | } |
@@ -521,20 +521,20 @@ discard block |
||
521 | 521 | public function load_scripts_styles() { |
522 | 522 | wp_register_style( |
523 | 523 | 'events-admin-css', |
524 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
524 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
525 | 525 | array(), |
526 | 526 | EVENT_ESPRESSO_VERSION |
527 | 527 | ); |
528 | - wp_register_style( 'ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION ); |
|
529 | - wp_enqueue_style( 'events-admin-css' ); |
|
530 | - wp_enqueue_style( 'ee-cat-admin' ); |
|
528 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
529 | + wp_enqueue_style('events-admin-css'); |
|
530 | + wp_enqueue_style('ee-cat-admin'); |
|
531 | 531 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
532 | 532 | //registers for all views |
533 | 533 | //scripts |
534 | 534 | wp_register_script( |
535 | 535 | 'event_editor_js', |
536 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
537 | - array( 'ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon' ), |
|
536 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
537 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
538 | 538 | EVENT_ESPRESSO_VERSION, |
539 | 539 | true |
540 | 540 | ); |
@@ -560,22 +560,22 @@ discard block |
||
560 | 560 | */ |
561 | 561 | public function load_scripts_styles_edit() { |
562 | 562 | //styles |
563 | - wp_enqueue_style( 'espresso-ui-theme' ); |
|
563 | + wp_enqueue_style('espresso-ui-theme'); |
|
564 | 564 | wp_register_style( |
565 | 565 | 'event-editor-css', |
566 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
567 | - array( 'ee-admin-css' ), |
|
566 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
567 | + array('ee-admin-css'), |
|
568 | 568 | EVENT_ESPRESSO_VERSION |
569 | 569 | ); |
570 | - wp_enqueue_style( 'event-editor-css' ); |
|
570 | + wp_enqueue_style('event-editor-css'); |
|
571 | 571 | //scripts |
572 | 572 | wp_register_script( |
573 | 573 | 'event-datetime-metabox', |
574 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
575 | - array( 'event_editor_js', 'ee-datepicker' ), |
|
574 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
575 | + array('event_editor_js', 'ee-datepicker'), |
|
576 | 576 | EVENT_ESPRESSO_VERSION |
577 | 577 | ); |
578 | - wp_enqueue_script( 'event-datetime-metabox' ); |
|
578 | + wp_enqueue_script('event-datetime-metabox'); |
|
579 | 579 | } |
580 | 580 | |
581 | 581 | |
@@ -595,10 +595,10 @@ discard block |
||
595 | 595 | $this->_views = array( |
596 | 596 | 'all' => array( |
597 | 597 | 'slug' => 'all', |
598 | - 'label' => esc_html__( 'All', 'event_espresso' ), |
|
598 | + 'label' => esc_html__('All', 'event_espresso'), |
|
599 | 599 | 'count' => 0, |
600 | 600 | 'bulk_action' => array( |
601 | - 'delete_categories' => esc_html__( 'Delete Permanently', 'event_espresso' ), |
|
601 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
602 | 602 | ), |
603 | 603 | ), |
604 | 604 | ); |
@@ -634,14 +634,14 @@ discard block |
||
634 | 634 | * @access public |
635 | 635 | * @return void |
636 | 636 | */ |
637 | - public function verify_event_edit( $event = null ) { |
|
637 | + public function verify_event_edit($event = null) { |
|
638 | 638 | // no event? |
639 | - if ( empty( $event ) ) { |
|
639 | + if (empty($event)) { |
|
640 | 640 | // set event |
641 | 641 | $event = $this->_cpt_model_obj; |
642 | 642 | } |
643 | 643 | // STILL no event? |
644 | - if ( empty ( $event ) ) { |
|
644 | + if (empty ($event)) { |
|
645 | 645 | return; |
646 | 646 | } |
647 | 647 | $orig_status = $event->status(); |
@@ -655,32 +655,32 @@ discard block |
||
655 | 655 | return; |
656 | 656 | } |
657 | 657 | //made it here so it IS active... next check that any of the tickets are sold. |
658 | - if ( $event->is_sold_out( true ) ) { |
|
659 | - if ( $orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status ) { |
|
658 | + if ($event->is_sold_out(true)) { |
|
659 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
660 | 660 | EE_Error::add_attention( |
661 | 661 | sprintf( |
662 | 662 | esc_html__( |
663 | 663 | 'Please note that the Event Status has automatically been changed to %s because there are no more spaces available for this event. However, this change is not permanent until you update the event. You can change the status back to something else before updating if you wish.', |
664 | 664 | 'event_espresso' |
665 | 665 | ), |
666 | - EEH_Template::pretty_status( EEM_Event::sold_out, false, 'sentence' ) |
|
666 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
667 | 667 | ) |
668 | 668 | ); |
669 | 669 | } |
670 | 670 | return; |
671 | - } else if ( $orig_status === EEM_Event::sold_out ) { |
|
671 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
672 | 672 | EE_Error::add_attention( |
673 | 673 | sprintf( |
674 | 674 | esc_html__( |
675 | 675 | 'Please note that the Event Status has automatically been changed to %s because more spaces have become available for this event, most likely due to abandoned transactions freeing up reserved tickets. However, this change is not permanent until you update the event. If you wish, you can change the status back to something else before updating.', |
676 | 676 | 'event_espresso' |
677 | 677 | ), |
678 | - EEH_Template::pretty_status( $event->status(), false, 'sentence' ) |
|
678 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
679 | 679 | ) |
680 | 680 | ); |
681 | 681 | } |
682 | 682 | //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
683 | - if ( ! $event->tickets_on_sale() ) { |
|
683 | + if ( ! $event->tickets_on_sale()) { |
|
684 | 684 | return; |
685 | 685 | } |
686 | 686 | //made it here so show warning |
@@ -698,7 +698,7 @@ discard block |
||
698 | 698 | */ |
699 | 699 | protected function _edit_event_warning() { |
700 | 700 | // we don't want to add warnings during these requests |
701 | - if ( isset( $this->_req_data['action'] ) && $this->_req_data['action'] === 'editpost' ) { |
|
701 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
702 | 702 | return; |
703 | 703 | } |
704 | 704 | EE_Error::add_attention( |
@@ -717,14 +717,14 @@ discard block |
||
717 | 717 | * @return string |
718 | 718 | */ |
719 | 719 | protected function _create_new_cpt_item() { |
720 | - $gmt_offset = get_option( 'gmt_offset' ); |
|
720 | + $gmt_offset = get_option('gmt_offset'); |
|
721 | 721 | //only nag them about setting their timezone if it's their first event, and they haven't already done it |
722 | - if( $gmt_offset === '0' && ! EEM_Event::instance()->exists(array()) ) { |
|
722 | + if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
723 | 723 | EE_Error::add_attention( |
724 | 724 | sprintf( |
725 | - __( 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
725 | + __('Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
726 | 726 | or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.'), |
727 | - '<a href="' . admin_url( 'options-general.php' ) . '">', |
|
727 | + '<a href="'.admin_url('options-general.php').'">', |
|
728 | 728 | '</a>' |
729 | 729 | ), |
730 | 730 | __FILE__, |
@@ -741,29 +741,29 @@ discard block |
||
741 | 741 | $this->_views = array( |
742 | 742 | 'all' => array( |
743 | 743 | 'slug' => 'all', |
744 | - 'label' => esc_html__( 'View All Events', 'event_espresso' ), |
|
744 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
745 | 745 | 'count' => 0, |
746 | 746 | 'bulk_action' => array( |
747 | - 'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
747 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
748 | 748 | ), |
749 | 749 | ), |
750 | 750 | 'draft' => array( |
751 | 751 | 'slug' => 'draft', |
752 | - 'label' => esc_html__( 'Draft', 'event_espresso' ), |
|
752 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
753 | 753 | 'count' => 0, |
754 | 754 | 'bulk_action' => array( |
755 | - 'trash_events' => esc_html__( 'Move to Trash', 'event_espresso' ), |
|
755 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
756 | 756 | ), |
757 | 757 | ), |
758 | 758 | ); |
759 | - if ( EE_Registry::instance()->CAP->current_user_can( 'ee_delete_events', 'espresso_events_trash_events' ) ) { |
|
759 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
760 | 760 | $this->_views['trash'] = array( |
761 | 761 | 'slug' => 'trash', |
762 | - 'label' => esc_html__( 'Trash', 'event_espresso' ), |
|
762 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
763 | 763 | 'count' => 0, |
764 | 764 | 'bulk_action' => array( |
765 | - 'restore_events' => esc_html__( 'Restore From Trash', 'event_espresso' ), |
|
766 | - 'delete_events' => esc_html__( 'Delete Permanently', 'event_espresso' ), |
|
765 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
766 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
767 | 767 | ), |
768 | 768 | ); |
769 | 769 | } |
@@ -778,50 +778,50 @@ discard block |
||
778 | 778 | $items = array( |
779 | 779 | 'view_details' => array( |
780 | 780 | 'class' => 'dashicons dashicons-search', |
781 | - 'desc' => esc_html__( 'View Event', 'event_espresso' ), |
|
781 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
782 | 782 | ), |
783 | 783 | 'edit_event' => array( |
784 | 784 | 'class' => 'ee-icon ee-icon-calendar-edit', |
785 | - 'desc' => esc_html__( 'Edit Event Details', 'event_espresso' ), |
|
785 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
786 | 786 | ), |
787 | 787 | 'view_attendees' => array( |
788 | 788 | 'class' => 'dashicons dashicons-groups', |
789 | - 'desc' => esc_html__( 'View Registrations for Event', 'event_espresso' ), |
|
789 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
790 | 790 | ), |
791 | 791 | ); |
792 | - $items = apply_filters( 'FHEE__Events_Admin_Page___event_legend_items__items', $items ); |
|
792 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
793 | 793 | $statuses = array( |
794 | 794 | 'sold_out_status' => array( |
795 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
796 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::sold_out, false, 'sentence' ), |
|
795 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
796 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
797 | 797 | ), |
798 | 798 | 'active_status' => array( |
799 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
800 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::active, false, 'sentence' ), |
|
799 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
800 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
801 | 801 | ), |
802 | 802 | 'upcoming_status' => array( |
803 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
804 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::upcoming, false, 'sentence' ), |
|
803 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
804 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
805 | 805 | ), |
806 | 806 | 'postponed_status' => array( |
807 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
808 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::postponed, false, 'sentence' ), |
|
807 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
808 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
809 | 809 | ), |
810 | 810 | 'cancelled_status' => array( |
811 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
812 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::cancelled, false, 'sentence' ), |
|
811 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
812 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
813 | 813 | ), |
814 | 814 | 'expired_status' => array( |
815 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
816 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::expired, false, 'sentence' ), |
|
815 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
816 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
817 | 817 | ), |
818 | 818 | 'inactive_status' => array( |
819 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
820 | - 'desc' => EEH_Template::pretty_status( EE_Datetime::inactive, false, 'sentence' ), |
|
819 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
820 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
821 | 821 | ), |
822 | 822 | ); |
823 | - $statuses = apply_filters( 'FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses ); |
|
824 | - return array_merge( $items, $statuses ); |
|
823 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
824 | + return array_merge($items, $statuses); |
|
825 | 825 | } |
826 | 826 | |
827 | 827 | |
@@ -832,8 +832,8 @@ discard block |
||
832 | 832 | * @return EEM_Event |
833 | 833 | */ |
834 | 834 | private function _event_model() { |
835 | - if ( ! $this->_event_model instanceof EEM_Event ) { |
|
836 | - $this->_event_model = EE_Registry::instance()->load_model( 'Event' ); |
|
835 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
836 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
837 | 837 | } |
838 | 838 | return $this->_event_model; |
839 | 839 | } |
@@ -850,12 +850,12 @@ discard block |
||
850 | 850 | * @param string $new_slug what the slug is |
851 | 851 | * @return string The new html string for the permalink area |
852 | 852 | */ |
853 | - public function extra_permalink_field_buttons( $return, $id, $new_title, $new_slug ) { |
|
853 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) { |
|
854 | 854 | //make sure this is only when editing |
855 | - if ( ! empty( $id ) ) { |
|
856 | - $post = get_post( $id ); |
|
855 | + if ( ! empty($id)) { |
|
856 | + $post = get_post($id); |
|
857 | 857 | $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
858 | - . esc_html__( 'Shortcode', 'event_espresso' ) |
|
858 | + . esc_html__('Shortcode', 'event_espresso') |
|
859 | 859 | . '</a> '; |
860 | 860 | $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
861 | 861 | . $post->ID |
@@ -874,14 +874,14 @@ discard block |
||
874 | 874 | * @return void |
875 | 875 | */ |
876 | 876 | protected function _events_overview_list_table() { |
877 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
877 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
878 | 878 | $this->_template_args['after_list_table'] = EEH_Template::get_button_or_link( |
879 | - get_post_type_archive_link( 'espresso_events' ), |
|
880 | - esc_html__( "View Event Archive Page", "event_espresso" ), |
|
879 | + get_post_type_archive_link('espresso_events'), |
|
880 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
881 | 881 | 'button' |
882 | 882 | ); |
883 | - $this->_template_args['after_list_table'] .= $this->_display_legend( $this->_event_legend_items() ); |
|
884 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
883 | + $this->_template_args['after_list_table'] .= $this->_display_legend($this->_event_legend_items()); |
|
884 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
885 | 885 | 'create_new', |
886 | 886 | 'add', |
887 | 887 | array(), |
@@ -907,48 +907,48 @@ discard block |
||
907 | 907 | * @param string $post_id |
908 | 908 | * @param object $post |
909 | 909 | */ |
910 | - protected function _insert_update_cpt_item( $post_id, $post ) { |
|
911 | - if ( $post instanceof WP_Post && $post->post_type !== 'espresso_events' ) { |
|
910 | + protected function _insert_update_cpt_item($post_id, $post) { |
|
911 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
912 | 912 | //get out we're not processing an event save. |
913 | 913 | return; |
914 | 914 | } |
915 | 915 | $event_values = array( |
916 | - 'EVT_display_desc' => ! empty( $this->_req_data['display_desc'] ) ? 1 : 0, |
|
917 | - 'EVT_display_ticket_selector' => ! empty( $this->_req_data['display_ticket_selector'] ) ? 1 : 0, |
|
916 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
917 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
918 | 918 | 'EVT_additional_limit' => min( |
919 | - apply_filters( 'FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255 ), |
|
920 | - ! empty( $this->_req_data['additional_limit'] ) ? $this->_req_data['additional_limit'] : null |
|
919 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
920 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
921 | 921 | ), |
922 | - 'EVT_default_registration_status' => ! empty( $this->_req_data['EVT_default_registration_status'] ) |
|
922 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
923 | 923 | ? $this->_req_data['EVT_default_registration_status'] |
924 | 924 | : EE_Registry::instance()->CFG->registration->default_STS_ID, |
925 | - 'EVT_member_only' => ! empty( $this->_req_data['member_only'] ) ? 1 : 0, |
|
926 | - 'EVT_allow_overflow' => ! empty( $this->_req_data['EVT_allow_overflow'] ) ? 1 : 0, |
|
927 | - 'EVT_timezone_string' => ! empty( $this->_req_data['timezone_string'] ) |
|
925 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
926 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
927 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
928 | 928 | ? $this->_req_data['timezone_string'] : null, |
929 | - 'EVT_external_URL' => ! empty( $this->_req_data['externalURL'] ) |
|
929 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
930 | 930 | ? $this->_req_data['externalURL'] : null, |
931 | - 'EVT_phone' => ! empty( $this->_req_data['event_phone'] ) |
|
931 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
932 | 932 | ? $this->_req_data['event_phone'] : null, |
933 | 933 | ); |
934 | 934 | //update event |
935 | - $success = $this->_event_model()->update_by_ID( $event_values, $post_id ); |
|
935 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
936 | 936 | //get event_object for other metaboxes... though it would seem to make sense to just use $this->_event_model()->get_one_by_ID( $post_id ).. i have to setup where conditions to override the filters in the model that filter out autodraft and inherit statuses so we GET the inherit id! |
937 | - $get_one_where = array( $this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status ); |
|
938 | - $event = $this->_event_model()->get_one( array( $get_one_where ) ); |
|
937 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
938 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
939 | 939 | //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
940 | 940 | $event_update_callbacks = apply_filters( |
941 | 941 | 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
942 | - array( array( $this, '_default_venue_update' ), array( $this, '_default_tickets_update' ) ) |
|
942 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
943 | 943 | ); |
944 | 944 | $att_success = true; |
945 | - foreach ( $event_update_callbacks as $e_callback ) { |
|
946 | - $_succ = call_user_func_array( $e_callback, array( $event, $this->_req_data ) ); |
|
945 | + foreach ($event_update_callbacks as $e_callback) { |
|
946 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
947 | 947 | $att_success = ! $att_success ? $att_success |
948 | 948 | : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
949 | 949 | } |
950 | 950 | //any errors? |
951 | - if ( $success && false === $att_success ) { |
|
951 | + if ($success && false === $att_success) { |
|
952 | 952 | EE_Error::add_error( |
953 | 953 | esc_html__( |
954 | 954 | 'Event Details saved successfully but something went wrong with saving attachments.', |
@@ -958,9 +958,9 @@ discard block |
||
958 | 958 | __FUNCTION__, |
959 | 959 | __LINE__ |
960 | 960 | ); |
961 | - } else if ( $success === false ) { |
|
961 | + } else if ($success === false) { |
|
962 | 962 | EE_Error::add_error( |
963 | - esc_html__( 'Event Details did not save successfully.', 'event_espresso' ), |
|
963 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
964 | 964 | __FILE__, |
965 | 965 | __FUNCTION__, |
966 | 966 | __LINE__ |
@@ -975,14 +975,14 @@ discard block |
||
975 | 975 | * @param int $post_id |
976 | 976 | * @param int $revision_id |
977 | 977 | */ |
978 | - protected function _restore_cpt_item( $post_id, $revision_id ) { |
|
978 | + protected function _restore_cpt_item($post_id, $revision_id) { |
|
979 | 979 | //copy existing event meta to new post |
980 | - $post_evt = $this->_event_model()->get_one_by_ID( $post_id ); |
|
981 | - if ( $post_evt instanceof EE_Event ) { |
|
980 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
981 | + if ($post_evt instanceof EE_Event) { |
|
982 | 982 | //meta revision restore |
983 | - $post_evt->restore_revision( $revision_id ); |
|
983 | + $post_evt->restore_revision($revision_id); |
|
984 | 984 | //related objs restore |
985 | - $post_evt->restore_revision( $revision_id, array( 'Venue', 'Datetime', 'Price' ) ); |
|
985 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
986 | 986 | } |
987 | 987 | } |
988 | 988 | |
@@ -995,49 +995,49 @@ discard block |
||
995 | 995 | * @param array $data The request data from the form |
996 | 996 | * @return bool Success or fail. |
997 | 997 | */ |
998 | - protected function _default_venue_update( \EE_Event $evtobj, $data ) { |
|
999 | - require_once( EE_MODELS . 'EEM_Venue.model.php' ); |
|
1000 | - $venue_model = EE_Registry::instance()->load_model( 'Venue' ); |
|
998 | + protected function _default_venue_update(\EE_Event $evtobj, $data) { |
|
999 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
1000 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1001 | 1001 | $rows_affected = null; |
1002 | - $venue_id = ! empty( $data['venue_id'] ) ? $data['venue_id'] : null; |
|
1002 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1003 | 1003 | // very important. If we don't have a venue name... |
1004 | 1004 | // then we'll get out because not necessary to create empty venue |
1005 | - if ( empty( $data['venue_title'] ) ) { |
|
1005 | + if (empty($data['venue_title'])) { |
|
1006 | 1006 | return false; |
1007 | 1007 | } |
1008 | 1008 | $venue_array = array( |
1009 | - 'VNU_wp_user' => $evtobj->get( 'EVT_wp_user' ), |
|
1010 | - 'VNU_name' => ! empty( $data['venue_title'] ) ? $data['venue_title'] : null, |
|
1011 | - 'VNU_desc' => ! empty( $data['venue_description'] ) ? $data['venue_description'] : null, |
|
1012 | - 'VNU_identifier' => ! empty( $data['venue_identifier'] ) ? $data['venue_identifier'] : null, |
|
1013 | - 'VNU_short_desc' => ! empty( $data['venue_short_description'] ) ? $data['venue_short_description'] |
|
1009 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1010 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1011 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1012 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1013 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1014 | 1014 | : null, |
1015 | - 'VNU_address' => ! empty( $data['address'] ) ? $data['address'] : null, |
|
1016 | - 'VNU_address2' => ! empty( $data['address2'] ) ? $data['address2'] : null, |
|
1017 | - 'VNU_city' => ! empty( $data['city'] ) ? $data['city'] : null, |
|
1018 | - 'STA_ID' => ! empty( $data['state'] ) ? $data['state'] : null, |
|
1019 | - 'CNT_ISO' => ! empty( $data['countries'] ) ? $data['countries'] : null, |
|
1020 | - 'VNU_zip' => ! empty( $data['zip'] ) ? $data['zip'] : null, |
|
1021 | - 'VNU_phone' => ! empty( $data['venue_phone'] ) ? $data['venue_phone'] : null, |
|
1022 | - 'VNU_capacity' => ! empty( $data['venue_capacity'] ) ? $data['venue_capacity'] : null, |
|
1023 | - 'VNU_url' => ! empty( $data['venue_url'] ) ? $data['venue_url'] : null, |
|
1024 | - 'VNU_virtual_phone' => ! empty( $data['virtual_phone'] ) ? $data['virtual_phone'] : null, |
|
1025 | - 'VNU_virtual_url' => ! empty( $data['virtual_url'] ) ? $data['virtual_url'] : null, |
|
1026 | - 'VNU_enable_for_gmap' => isset( $data['enable_for_gmap'] ) ? 1 : 0, |
|
1015 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1016 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1017 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1018 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1019 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1020 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1021 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1022 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1023 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1024 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1025 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1026 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1027 | 1027 | 'status' => 'publish', |
1028 | 1028 | ); |
1029 | 1029 | //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
1030 | - if ( ! empty( $venue_id ) ) { |
|
1031 | - $update_where = array( $venue_model->primary_key_name() => $venue_id ); |
|
1032 | - $rows_affected = $venue_model->update( $venue_array, array( $update_where ) ); |
|
1030 | + if ( ! empty($venue_id)) { |
|
1031 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1032 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1033 | 1033 | //we've gotta make sure that the venue is always attached to a revision.. add_relation_to should take care of making sure that the relation is already present. |
1034 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
1034 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1035 | 1035 | return $rows_affected > 0 ? true : false; |
1036 | 1036 | } else { |
1037 | 1037 | //we insert the venue |
1038 | - $venue_id = $venue_model->insert( $venue_array ); |
|
1039 | - $evtobj->_add_relation_to( $venue_id, 'Venue' ); |
|
1040 | - return ! empty( $venue_id ) ? true : false; |
|
1038 | + $venue_id = $venue_model->insert($venue_array); |
|
1039 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1040 | + return ! empty($venue_id) ? true : false; |
|
1041 | 1041 | } |
1042 | 1042 | //when we have the ancestor come in it's already been handled by the revision save. |
1043 | 1043 | } |
@@ -1051,53 +1051,53 @@ discard block |
||
1051 | 1051 | * @param array $data The request data from the form |
1052 | 1052 | * @return array |
1053 | 1053 | */ |
1054 | - protected function _default_tickets_update( EE_Event $evtobj, $data ) { |
|
1054 | + protected function _default_tickets_update(EE_Event $evtobj, $data) { |
|
1055 | 1055 | $success = true; |
1056 | 1056 | $saved_dtt = null; |
1057 | 1057 | $saved_tickets = array(); |
1058 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1059 | - foreach ( $data['edit_event_datetimes'] as $row => $dtt ) { |
|
1058 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1059 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1060 | 1060 | //trim all values to ensure any excess whitespace is removed. |
1061 | - $dtt = array_map( 'trim', $dtt ); |
|
1062 | - $dtt['DTT_EVT_end'] = isset( $dtt['DTT_EVT_end'] ) && ! empty( $dtt['DTT_EVT_end'] ) ? $dtt['DTT_EVT_end'] |
|
1061 | + $dtt = array_map('trim', $dtt); |
|
1062 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1063 | 1063 | : $dtt['DTT_EVT_start']; |
1064 | 1064 | $datetime_values = array( |
1065 | - 'DTT_ID' => ! empty( $dtt['DTT_ID'] ) ? $dtt['DTT_ID'] : null, |
|
1065 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1066 | 1066 | 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
1067 | 1067 | 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
1068 | - 'DTT_reg_limit' => empty( $dtt['DTT_reg_limit'] ) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1068 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1069 | 1069 | 'DTT_order' => $row, |
1070 | 1070 | ); |
1071 | 1071 | //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. |
1072 | - if ( ! empty( $dtt['DTT_ID'] ) ) { |
|
1072 | + if ( ! empty($dtt['DTT_ID'])) { |
|
1073 | 1073 | $DTM = EE_Registry::instance() |
1074 | - ->load_model( 'Datetime', array( $evtobj->get_timezone() ) ) |
|
1075 | - ->get_one_by_ID( $dtt['DTT_ID'] ); |
|
1076 | - $DTM->set_date_format( $incoming_date_formats[0] ); |
|
1077 | - $DTM->set_time_format( $incoming_date_formats[1] ); |
|
1078 | - foreach ( $datetime_values as $field => $value ) { |
|
1079 | - $DTM->set( $field, $value ); |
|
1074 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1075 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
1076 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1077 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1078 | + foreach ($datetime_values as $field => $value) { |
|
1079 | + $DTM->set($field, $value); |
|
1080 | 1080 | } |
1081 | 1081 | //make sure the $dtt_id here is saved just in case after the add_relation_to() the autosave replaces it. We need to do this so we dont' TRASH the parent DTT. |
1082 | - $saved_dtts[ $DTM->ID() ] = $DTM; |
|
1082 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
1083 | 1083 | } else { |
1084 | 1084 | $DTM = EE_Registry::instance()->load_class( |
1085 | 1085 | 'Datetime', |
1086 | - array( $datetime_values, $evtobj->get_timezone(), $incoming_date_formats ), |
|
1086 | + array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1087 | 1087 | false, |
1088 | 1088 | false |
1089 | 1089 | ); |
1090 | - foreach ( $datetime_values as $field => $value ) { |
|
1091 | - $DTM->set( $field, $value ); |
|
1090 | + foreach ($datetime_values as $field => $value) { |
|
1091 | + $DTM->set($field, $value); |
|
1092 | 1092 | } |
1093 | 1093 | } |
1094 | 1094 | $DTM->save(); |
1095 | - $DTT = $evtobj->_add_relation_to( $DTM, 'Datetime' ); |
|
1095 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1096 | 1096 | //load DTT helper |
1097 | 1097 | //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. |
1098 | - if ( $DTT->get_raw( 'DTT_EVT_start' ) > $DTT->get_raw( 'DTT_EVT_end' ) ) { |
|
1099 | - $DTT->set( 'DTT_EVT_end', $DTT->get( 'DTT_EVT_start' ) ); |
|
1100 | - $DTT = EEH_DTT_Helper::date_time_add( $DTT, 'DTT_EVT_end', 'days' ); |
|
1098 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1099 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1100 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1101 | 1101 | $DTT->save(); |
1102 | 1102 | } |
1103 | 1103 | //now we got to make sure we add the new DTT_ID to the $saved_dtts array because it is possible there was a new one created for the autosave. |
@@ -1108,20 +1108,20 @@ discard block |
||
1108 | 1108 | } |
1109 | 1109 | //no dtts get deleted so we don't do any of that logic here. |
1110 | 1110 | //update tickets next |
1111 | - $old_tickets = isset( $data['ticket_IDs'] ) ? explode( ',', $data['ticket_IDs'] ) : array(); |
|
1112 | - foreach ( $data['edit_tickets'] as $row => $tkt ) { |
|
1113 | - $incoming_date_formats = array( 'Y-m-d', 'h:i a' ); |
|
1111 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1112 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1113 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1114 | 1114 | $update_prices = false; |
1115 | - $ticket_price = isset( $data['edit_prices'][ $row ][1]['PRC_amount'] ) |
|
1116 | - ? $data['edit_prices'][ $row ][1]['PRC_amount'] : 0; |
|
1115 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1116 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1117 | 1117 | // trim inputs to ensure any excess whitespace is removed. |
1118 | - $tkt = array_map( 'trim', $tkt ); |
|
1119 | - if ( empty( $tkt['TKT_start_date'] ) ) { |
|
1118 | + $tkt = array_map('trim', $tkt); |
|
1119 | + if (empty($tkt['TKT_start_date'])) { |
|
1120 | 1120 | //let's use now in the set timezone. |
1121 | - $now = new DateTime( 'now', new DateTimeZone( $evtobj->get_timezone() ) ); |
|
1122 | - $tkt['TKT_start_date'] = $now->format( $incoming_date_formats[0] . ' ' . $incoming_date_formats[1] ); |
|
1121 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1122 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1123 | 1123 | } |
1124 | - if ( empty( $tkt['TKT_end_date'] ) ) { |
|
1124 | + if (empty($tkt['TKT_end_date'])) { |
|
1125 | 1125 | //use the start date of the first datetime |
1126 | 1126 | $dtt = $evtobj->first_datetime(); |
1127 | 1127 | $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
@@ -1130,22 +1130,22 @@ discard block |
||
1130 | 1130 | ); |
1131 | 1131 | } |
1132 | 1132 | $TKT_values = array( |
1133 | - 'TKT_ID' => ! empty( $tkt['TKT_ID'] ) ? $tkt['TKT_ID'] : null, |
|
1134 | - 'TTM_ID' => ! empty( $tkt['TTM_ID'] ) ? $tkt['TTM_ID'] : 0, |
|
1135 | - 'TKT_name' => ! empty( $tkt['TKT_name'] ) ? $tkt['TKT_name'] : '', |
|
1136 | - 'TKT_description' => ! empty( $tkt['TKT_description'] ) ? $tkt['TKT_description'] : '', |
|
1133 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1134 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1135 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1136 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1137 | 1137 | 'TKT_start_date' => $tkt['TKT_start_date'], |
1138 | 1138 | 'TKT_end_date' => $tkt['TKT_end_date'], |
1139 | - 'TKT_qty' => ! isset( $tkt['TKT_qty'] ) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1140 | - 'TKT_uses' => ! isset( $tkt['TKT_uses'] ) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1141 | - 'TKT_min' => empty( $tkt['TKT_min'] ) ? 0 : $tkt['TKT_min'], |
|
1142 | - 'TKT_max' => empty( $tkt['TKT_max'] ) ? EE_INF : $tkt['TKT_max'], |
|
1139 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1140 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1141 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1142 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1143 | 1143 | 'TKT_row' => $row, |
1144 | - 'TKT_order' => isset( $tkt['TKT_order'] ) ? $tkt['TKT_order'] : $row, |
|
1144 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1145 | 1145 | 'TKT_price' => $ticket_price, |
1146 | 1146 | ); |
1147 | 1147 | //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. |
1148 | - if ( isset( $tkt['TKT_is_default'] ) && $tkt['TKT_is_default'] ) { |
|
1148 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1149 | 1149 | $TKT_values['TKT_ID'] = 0; |
1150 | 1150 | $TKT_values['TKT_is_default'] = 0; |
1151 | 1151 | $TKT_values['TKT_price'] = $ticket_price; |
@@ -1154,110 +1154,110 @@ discard block |
||
1154 | 1154 | //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
1155 | 1155 | //we actually do our saves a head of doing any add_relations to because its entirely possible that this ticket didn't removed or added to any datetime in the session but DID have it's items modified. |
1156 | 1156 | //keep in mind that if the TKT has been sold (and we have changed pricing information), then we won't be updating the tkt but instead a new tkt will be created and the old one archived. |
1157 | - if ( ! empty( $tkt['TKT_ID'] ) ) { |
|
1157 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1158 | 1158 | $TKT = EE_Registry::instance() |
1159 | - ->load_model( 'Ticket', array( $evtobj->get_timezone() ) ) |
|
1160 | - ->get_one_by_ID( $tkt['TKT_ID'] ); |
|
1161 | - if ( $TKT instanceof EE_Ticket ) { |
|
1159 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1160 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
1161 | + if ($TKT instanceof EE_Ticket) { |
|
1162 | 1162 | $ticket_sold = $TKT->count_related( |
1163 | 1163 | 'Registration', |
1164 | 1164 | array( |
1165 | 1165 | array( |
1166 | 1166 | 'STS_ID' => array( |
1167 | 1167 | 'NOT IN', |
1168 | - array( EEM_Registration::status_id_incomplete ), |
|
1168 | + array(EEM_Registration::status_id_incomplete), |
|
1169 | 1169 | ), |
1170 | 1170 | ), |
1171 | 1171 | ) |
1172 | 1172 | ) > 0 ? true : false; |
1173 | 1173 | //let's just check the total price for the existing ticket and determine if it matches the new total price. if they are different then we create a new ticket (if tkts sold) if they aren't different then we go ahead and modify existing ticket. |
1174 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get( 'TKT_price' ) |
|
1174 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1175 | 1175 | && ! $TKT->get( |
1176 | 1176 | 'TKT_deleted' |
1177 | 1177 | ) ? true : false; |
1178 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1179 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1178 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1179 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1180 | 1180 | //set new values |
1181 | - foreach ( $TKT_values as $field => $value ) { |
|
1182 | - if ( $field == 'TKT_qty' ) { |
|
1183 | - $TKT->set_qty( $value ); |
|
1181 | + foreach ($TKT_values as $field => $value) { |
|
1182 | + if ($field == 'TKT_qty') { |
|
1183 | + $TKT->set_qty($value); |
|
1184 | 1184 | } else { |
1185 | - $TKT->set( $field, $value ); |
|
1185 | + $TKT->set($field, $value); |
|
1186 | 1186 | } |
1187 | 1187 | } |
1188 | 1188 | //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
1189 | - if ( $create_new_TKT ) { |
|
1189 | + if ($create_new_TKT) { |
|
1190 | 1190 | //archive the old ticket first |
1191 | - $TKT->set( 'TKT_deleted', 1 ); |
|
1191 | + $TKT->set('TKT_deleted', 1); |
|
1192 | 1192 | $TKT->save(); |
1193 | 1193 | //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
1194 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1194 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1195 | 1195 | //create new ticket that's a copy of the existing except a new id of course (and not archived) AND has the new TKT_price associated with it. |
1196 | 1196 | $TKT = clone $TKT; |
1197 | - $TKT->set( 'TKT_ID', 0 ); |
|
1198 | - $TKT->set( 'TKT_deleted', 0 ); |
|
1199 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1200 | - $TKT->set( 'TKT_sold', 0 ); |
|
1197 | + $TKT->set('TKT_ID', 0); |
|
1198 | + $TKT->set('TKT_deleted', 0); |
|
1199 | + $TKT->set('TKT_price', $ticket_price); |
|
1200 | + $TKT->set('TKT_sold', 0); |
|
1201 | 1201 | //now we need to make sure that $new prices are created as well and attached to new ticket. |
1202 | 1202 | $update_prices = true; |
1203 | 1203 | } |
1204 | 1204 | //make sure price is set if it hasn't been already |
1205 | - $TKT->set( 'TKT_price', $ticket_price ); |
|
1205 | + $TKT->set('TKT_price', $ticket_price); |
|
1206 | 1206 | } |
1207 | 1207 | } else { |
1208 | 1208 | //no TKT_id so a new TKT |
1209 | 1209 | $TKT_values['TKT_price'] = $ticket_price; |
1210 | - $TKT = EE_Registry::instance()->load_class( 'Ticket', array( $TKT_values ), false, false ); |
|
1211 | - if ( $TKT instanceof EE_Ticket ) { |
|
1210 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1211 | + if ($TKT instanceof EE_Ticket) { |
|
1212 | 1212 | //need to reset values to properly account for the date formats |
1213 | - $TKT->set_date_format( $incoming_date_formats[0] ); |
|
1214 | - $TKT->set_time_format( $incoming_date_formats[1] ); |
|
1215 | - $TKT->set_timezone( $evtobj->get_timezone() ); |
|
1213 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1214 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1215 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1216 | 1216 | //set new values |
1217 | - foreach ( $TKT_values as $field => $value ) { |
|
1218 | - if ( $field == 'TKT_qty' ) { |
|
1219 | - $TKT->set_qty( $value ); |
|
1217 | + foreach ($TKT_values as $field => $value) { |
|
1218 | + if ($field == 'TKT_qty') { |
|
1219 | + $TKT->set_qty($value); |
|
1220 | 1220 | } else { |
1221 | - $TKT->set( $field, $value ); |
|
1221 | + $TKT->set($field, $value); |
|
1222 | 1222 | } |
1223 | 1223 | } |
1224 | 1224 | $update_prices = true; |
1225 | 1225 | } |
1226 | 1226 | } |
1227 | 1227 | // cap ticket qty by datetime reg limits |
1228 | - $TKT->set_qty( min( $TKT->qty(), $TKT->qty( 'reg_limit' ) ) ); |
|
1228 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1229 | 1229 | //update ticket. |
1230 | 1230 | $TKT->save(); |
1231 | 1231 | //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. |
1232 | - if ( $TKT->get_raw( 'TKT_start_date' ) > $TKT->get_raw( 'TKT_end_date' ) ) { |
|
1233 | - $TKT->set( 'TKT_end_date', $TKT->get( 'TKT_start_date' ) ); |
|
1234 | - $TKT = EEH_DTT_Helper::date_time_add( $TKT, 'TKT_end_date', 'days' ); |
|
1232 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1233 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1234 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1235 | 1235 | $TKT->save(); |
1236 | 1236 | } |
1237 | 1237 | //initially let's add the ticket to the dtt |
1238 | - $saved_dtt->_add_relation_to( $TKT, 'Ticket' ); |
|
1239 | - $saved_tickets[ $TKT->ID() ] = $TKT; |
|
1238 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1239 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1240 | 1240 | //add prices to ticket |
1241 | - $this->_add_prices_to_ticket( $data['edit_prices'][ $row ], $TKT, $update_prices ); |
|
1241 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1242 | 1242 | } |
1243 | 1243 | //however now we need to handle permanently deleting tickets via the ui. Keep in mind that the ui does not allow deleting/archiving tickets that have ticket sold. However, it does allow for deleting tickets that have no tickets sold, in which case we want to get rid of permanently because there is no need to save in db. |
1244 | - $old_tickets = isset( $old_tickets[0] ) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1245 | - $tickets_removed = array_diff( $old_tickets, array_keys( $saved_tickets ) ); |
|
1246 | - foreach ( $tickets_removed as $id ) { |
|
1247 | - $id = absint( $id ); |
|
1244 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1245 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1246 | + foreach ($tickets_removed as $id) { |
|
1247 | + $id = absint($id); |
|
1248 | 1248 | //get the ticket for this id |
1249 | - $tkt_to_remove = EE_Registry::instance()->load_model( 'Ticket' )->get_one_by_ID( $id ); |
|
1249 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1250 | 1250 | //need to get all the related datetimes on this ticket and remove from every single one of them (remember this process can ONLY kick off if there are NO tkts_sold) |
1251 | - $dtts = $tkt_to_remove->get_many_related( 'Datetime' ); |
|
1252 | - foreach ( $dtts as $dtt ) { |
|
1253 | - $tkt_to_remove->_remove_relation_to( $dtt, 'Datetime' ); |
|
1251 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1252 | + foreach ($dtts as $dtt) { |
|
1253 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1254 | 1254 | } |
1255 | 1255 | //need to do the same for prices (except these prices can also be deleted because again, tickets can only be trashed if they don't have any TKTs sold (otherwise they are just archived)) |
1256 | - $tkt_to_remove->delete_related_permanently( 'Price' ); |
|
1256 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
1257 | 1257 | //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
1258 | 1258 | $tkt_to_remove->delete_permanently(); |
1259 | 1259 | } |
1260 | - return array( $saved_dtt, $saved_tickets ); |
|
1260 | + return array($saved_dtt, $saved_tickets); |
|
1261 | 1261 | } |
1262 | 1262 | |
1263 | 1263 | |
@@ -1274,29 +1274,29 @@ discard block |
||
1274 | 1274 | * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
1275 | 1275 | * @return void |
1276 | 1276 | */ |
1277 | - private function _add_prices_to_ticket( $prices, EE_Ticket $ticket, $new_prices = false ) { |
|
1278 | - foreach ( $prices as $row => $prc ) { |
|
1277 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) { |
|
1278 | + foreach ($prices as $row => $prc) { |
|
1279 | 1279 | $PRC_values = array( |
1280 | - 'PRC_ID' => ! empty( $prc['PRC_ID'] ) ? $prc['PRC_ID'] : null, |
|
1281 | - 'PRT_ID' => ! empty( $prc['PRT_ID'] ) ? $prc['PRT_ID'] : null, |
|
1282 | - 'PRC_amount' => ! empty( $prc['PRC_amount'] ) ? $prc['PRC_amount'] : 0, |
|
1283 | - 'PRC_name' => ! empty( $prc['PRC_name'] ) ? $prc['PRC_name'] : '', |
|
1284 | - 'PRC_desc' => ! empty( $prc['PRC_desc'] ) ? $prc['PRC_desc'] : '', |
|
1280 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1281 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1282 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1283 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1284 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1285 | 1285 | 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
1286 | 1286 | 'PRC_order' => $row, |
1287 | 1287 | ); |
1288 | - if ( $new_prices || empty( $PRC_values['PRC_ID'] ) ) { |
|
1288 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1289 | 1289 | $PRC_values['PRC_ID'] = 0; |
1290 | - $PRC = EE_Registry::instance()->load_class( 'Price', array( $PRC_values ), false, false ); |
|
1290 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1291 | 1291 | } else { |
1292 | - $PRC = EE_Registry::instance()->load_model( 'Price' )->get_one_by_ID( $prc['PRC_ID'] ); |
|
1292 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1293 | 1293 | //update this price with new values |
1294 | - foreach ( $PRC_values as $field => $newprc ) { |
|
1295 | - $PRC->set( $field, $newprc ); |
|
1294 | + foreach ($PRC_values as $field => $newprc) { |
|
1295 | + $PRC->set($field, $newprc); |
|
1296 | 1296 | } |
1297 | 1297 | $PRC->save(); |
1298 | 1298 | } |
1299 | - $ticket->_add_relation_to( $PRC, 'Price' ); |
|
1299 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1300 | 1300 | } |
1301 | 1301 | } |
1302 | 1302 | |
@@ -1328,7 +1328,7 @@ discard block |
||
1328 | 1328 | private function _generate_publish_box_extra_content() { |
1329 | 1329 | //load formatter helper |
1330 | 1330 | //args for getting related registrations |
1331 | - $approved_query_args = array( array( 'REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved ) ); |
|
1331 | + $approved_query_args = array(array('REG_deleted' => 0, 'STS_ID' => EEM_Registration::status_id_approved)); |
|
1332 | 1332 | $not_approved_query_args = array( |
1333 | 1333 | array( |
1334 | 1334 | 'REG_deleted' => 0, |
@@ -1399,7 +1399,7 @@ discard block |
||
1399 | 1399 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
1400 | 1400 | // load template |
1401 | 1401 | EEH_Template::display_template( |
1402 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1402 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
1403 | 1403 | $publish_box_extra_args |
1404 | 1404 | ); |
1405 | 1405 | } |
@@ -1433,16 +1433,16 @@ discard block |
||
1433 | 1433 | $this->verify_cpt_object(); |
1434 | 1434 | add_meta_box( |
1435 | 1435 | 'espresso_event_editor_tickets', |
1436 | - esc_html__( 'Event Datetime & Ticket', 'event_espresso' ), |
|
1437 | - array( $this, 'ticket_metabox' ), |
|
1436 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1437 | + array($this, 'ticket_metabox'), |
|
1438 | 1438 | $this->page_slug, |
1439 | 1439 | 'normal', |
1440 | 1440 | 'high' |
1441 | 1441 | ); |
1442 | 1442 | add_meta_box( |
1443 | 1443 | 'espresso_event_editor_event_options', |
1444 | - esc_html__( 'Event Registration Options', 'event_espresso' ), |
|
1445 | - array( $this, 'registration_options_meta_box' ), |
|
1444 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1445 | + array($this, 'registration_options_meta_box'), |
|
1446 | 1446 | $this->page_slug, |
1447 | 1447 | 'side', |
1448 | 1448 | 'default' |
@@ -1470,65 +1470,65 @@ discard block |
||
1470 | 1470 | 'trash_icon' => 'ee-lock-icon', |
1471 | 1471 | 'disabled' => '', |
1472 | 1472 | ); |
1473 | - $event_id = is_object( $this->_cpt_model_obj ) ? $this->_cpt_model_obj->ID() : null; |
|
1474 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
1473 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1474 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1475 | 1475 | /** |
1476 | 1476 | * 1. Start with retrieving Datetimes |
1477 | 1477 | * 2. Fore each datetime get related tickets |
1478 | 1478 | * 3. For each ticket get related prices |
1479 | 1479 | */ |
1480 | - $times = EE_Registry::instance()->load_model( 'Datetime' )->get_all_event_dates( $event_id ); |
|
1480 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1481 | 1481 | /** @type EE_Datetime $first_datetime */ |
1482 | - $first_datetime = reset( $times ); |
|
1482 | + $first_datetime = reset($times); |
|
1483 | 1483 | //do we get related tickets? |
1484 | - if ( $first_datetime instanceof EE_Datetime |
|
1484 | + if ($first_datetime instanceof EE_Datetime |
|
1485 | 1485 | && $first_datetime->ID() !== 0 |
1486 | 1486 | ) { |
1487 | - $existing_datetime_ids[] = $first_datetime->get( 'DTT_ID' ); |
|
1487 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1488 | 1488 | $template_args['time'] = $first_datetime; |
1489 | 1489 | $related_tickets = $first_datetime->tickets( |
1490 | 1490 | array( |
1491 | - array( 'OR' => array( 'TKT_deleted' => 1, 'TKT_deleted*' => 0 ) ), |
|
1491 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1492 | 1492 | 'default_where_conditions' => 'none', |
1493 | 1493 | ) |
1494 | 1494 | ); |
1495 | - if ( ! empty( $related_tickets ) ) { |
|
1496 | - $template_args['total_ticket_rows'] = count( $related_tickets ); |
|
1495 | + if ( ! empty($related_tickets)) { |
|
1496 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
1497 | 1497 | $row = 0; |
1498 | - foreach ( $related_tickets as $ticket ) { |
|
1499 | - $existing_ticket_ids[] = $ticket->get( 'TKT_ID' ); |
|
1500 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket, false, $row ); |
|
1498 | + foreach ($related_tickets as $ticket) { |
|
1499 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1500 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1501 | 1501 | $row++; |
1502 | 1502 | } |
1503 | 1503 | } else { |
1504 | 1504 | $template_args['total_ticket_rows'] = 1; |
1505 | 1505 | /** @type EE_Ticket $ticket */ |
1506 | - $ticket = EE_Registry::instance()->load_model( 'Ticket' )->create_default_object(); |
|
1507 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket ); |
|
1506 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1507 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1508 | 1508 | } |
1509 | 1509 | } else { |
1510 | 1510 | $template_args['time'] = $times[0]; |
1511 | 1511 | /** @type EE_Ticket $ticket */ |
1512 | - $ticket = EE_Registry::instance()->load_model( 'Ticket' )->get_all_default_tickets(); |
|
1513 | - $template_args['ticket_rows'] .= $this->_get_ticket_row( $ticket[1] ); |
|
1512 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1513 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1514 | 1514 | // NOTE: we're just sending the first default row |
1515 | 1515 | // (decaf can't manage default tickets so this should be sufficient); |
1516 | 1516 | } |
1517 | 1517 | $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
1518 | 1518 | 'event_editor_event_datetimes_help_tab' |
1519 | 1519 | ); |
1520 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link( 'ticket_options_info' ); |
|
1521 | - $template_args['existing_datetime_ids'] = implode( ',', $existing_datetime_ids ); |
|
1522 | - $template_args['existing_ticket_ids'] = implode( ',', $existing_ticket_ids ); |
|
1520 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1521 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1522 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1523 | 1523 | $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
1524 | - EE_Registry::instance()->load_model( 'Ticket' )->create_default_object(), |
|
1524 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1525 | 1525 | true |
1526 | 1526 | ); |
1527 | 1527 | $template = apply_filters( |
1528 | 1528 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
1529 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1529 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
1530 | 1530 | ); |
1531 | - EEH_Template::display_template( $template, $template_args ); |
|
1531 | + EEH_Template::display_template($template, $template_args); |
|
1532 | 1532 | } |
1533 | 1533 | |
1534 | 1534 | |
@@ -1542,74 +1542,74 @@ discard block |
||
1542 | 1542 | * @param int $row |
1543 | 1543 | * @return string generated html for the ticket row. |
1544 | 1544 | */ |
1545 | - private function _get_ticket_row( $ticket, $skeleton = false, $row = 0 ) { |
|
1545 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) { |
|
1546 | 1546 | $template_args = array( |
1547 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1547 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1548 | 1548 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
1549 | 1549 | : '', |
1550 | 1550 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
1551 | - 'TKT_ID' => $ticket->get( 'TKT_ID' ), |
|
1552 | - 'TKT_name' => $ticket->get( 'TKT_name' ), |
|
1553 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date( 'TKT_start_date', 'Y-m-d h:i a' ), |
|
1554 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date( 'TKT_end_date', 'Y-m-d h:i a' ), |
|
1555 | - 'TKT_is_default' => $ticket->get( 'TKT_is_default' ), |
|
1556 | - 'TKT_qty' => $ticket->get_pretty( 'TKT_qty', 'input' ), |
|
1551 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1552 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
1553 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1554 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1555 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1556 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1557 | 1557 | 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
1558 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get( 'TKT_sold' ), |
|
1559 | - 'trash_icon' => ( $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) ) |
|
1560 | - && ( ! empty( $ticket ) && $ticket->get( 'TKT_sold' ) === 0 ) |
|
1558 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1559 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1560 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1561 | 1561 | ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
1562 | - 'disabled' => $skeleton || ( ! empty( $ticket ) && ! $ticket->get( 'TKT_deleted' ) ) ? '' |
|
1562 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1563 | 1563 | : ' disabled=disabled', |
1564 | 1564 | ); |
1565 | 1565 | $price = $ticket->ID() !== 0 |
1566 | - ? $ticket->get_first_related( 'Price', array( 'default_where_conditions' => 'none' ) ) |
|
1567 | - : EE_Registry::instance()->load_model( 'Price' )->create_default_object(); |
|
1566 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1567 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1568 | 1568 | $price_args = array( |
1569 | 1569 | 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
1570 | - 'PRC_amount' => $price->get( 'PRC_amount' ), |
|
1571 | - 'PRT_ID' => $price->get( 'PRT_ID' ), |
|
1572 | - 'PRC_ID' => $price->get( 'PRC_ID' ), |
|
1573 | - 'PRC_is_default' => $price->get( 'PRC_is_default' ), |
|
1570 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
1571 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
1572 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
1573 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1574 | 1574 | ); |
1575 | 1575 | //make sure we have default start and end dates if skeleton |
1576 | 1576 | //handle rows that should NOT be empty |
1577 | - if ( empty( $template_args['TKT_start_date'] ) ) { |
|
1577 | + if (empty($template_args['TKT_start_date'])) { |
|
1578 | 1578 | //if empty then the start date will be now. |
1579 | - $template_args['TKT_start_date'] = date( 'Y-m-d h:i a', current_time( 'timestamp' ) ); |
|
1579 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1580 | 1580 | } |
1581 | - if ( empty( $template_args['TKT_end_date'] ) ) { |
|
1581 | + if (empty($template_args['TKT_end_date'])) { |
|
1582 | 1582 | //get the earliest datetime (if present); |
1583 | 1583 | $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
1584 | 1584 | ? $this->_cpt_model_obj->get_first_related( |
1585 | 1585 | 'Datetime', |
1586 | - array( 'order_by' => array( 'DTT_EVT_start' => 'ASC' ) ) |
|
1586 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1587 | 1587 | ) |
1588 | 1588 | : null; |
1589 | - if ( ! empty( $earliest_dtt ) ) { |
|
1590 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime( 'DTT_EVT_start', 'Y-m-d', 'h:i a' ); |
|
1589 | + if ( ! empty($earliest_dtt)) { |
|
1590 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1591 | 1591 | } else { |
1592 | 1592 | $template_args['TKT_end_date'] = date( |
1593 | 1593 | 'Y-m-d h:i a', |
1594 | - mktime( 0, 0, 0, date( "m" ), date( "d" ) + 7, date( "Y" ) ) |
|
1594 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1595 | 1595 | ); |
1596 | 1596 | } |
1597 | 1597 | } |
1598 | - $template_args = array_merge( $template_args, $price_args ); |
|
1598 | + $template_args = array_merge($template_args, $price_args); |
|
1599 | 1599 | $template = apply_filters( |
1600 | 1600 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
1601 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1601 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
1602 | 1602 | $ticket |
1603 | 1603 | ); |
1604 | - return EEH_Template::display_template( $template, $template_args, true ); |
|
1604 | + return EEH_Template::display_template($template, $template_args, true); |
|
1605 | 1605 | } |
1606 | 1606 | |
1607 | 1607 | |
1608 | 1608 | |
1609 | 1609 | public function registration_options_meta_box() { |
1610 | 1610 | $yes_no_values = array( |
1611 | - array( 'id' => true, 'text' => esc_html__( 'Yes', 'event_espresso' ) ), |
|
1612 | - array( 'id' => false, 'text' => esc_html__( 'No', 'event_espresso' ) ), |
|
1611 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1612 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1613 | 1613 | ); |
1614 | 1614 | $default_reg_status_values = EEM_Registration::reg_status_array( |
1615 | 1615 | array( |
@@ -1621,7 +1621,7 @@ discard block |
||
1621 | 1621 | ); |
1622 | 1622 | //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
1623 | 1623 | $template_args['_event'] = $this->_cpt_model_obj; |
1624 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status( false ); |
|
1624 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1625 | 1625 | $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
1626 | 1626 | $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
1627 | 1627 | 'default_reg_status', |
@@ -1649,7 +1649,7 @@ discard block |
||
1649 | 1649 | $default_reg_status_values |
1650 | 1650 | ); |
1651 | 1651 | EEH_Template::display_template( |
1652 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1652 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1653 | 1653 | $template_args |
1654 | 1654 | ); |
1655 | 1655 | } |
@@ -1668,97 +1668,97 @@ discard block |
||
1668 | 1668 | * that match the given _view and paging parameters. |
1669 | 1669 | * @return array an array of event objects. |
1670 | 1670 | */ |
1671 | - public function get_events( $per_page = 10, $current_page = 1, $count = false ) { |
|
1671 | + public function get_events($per_page = 10, $current_page = 1, $count = false) { |
|
1672 | 1672 | $EEME = $this->_event_model(); |
1673 | - $offset = ( $current_page - 1 ) * $per_page; |
|
1674 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1675 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1676 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : "DESC"; |
|
1677 | - if ( isset( $this->_req_data['month_range'] ) ) { |
|
1678 | - $pieces = explode( ' ', $this->_req_data['month_range'], 3 ); |
|
1679 | - $month_r = ! empty( $pieces[0] ) ? date( 'm', strtotime( $pieces[0] ) ) : ''; |
|
1680 | - $year_r = ! empty( $pieces[1] ) ? $pieces[1] : ''; |
|
1673 | + $offset = ($current_page - 1) * $per_page; |
|
1674 | + $limit = $count ? null : $offset.','.$per_page; |
|
1675 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1676 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1677 | + if (isset($this->_req_data['month_range'])) { |
|
1678 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1679 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1680 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1681 | 1681 | } |
1682 | 1682 | $where = array(); |
1683 | - $status = isset( $this->_req_data['status'] ) ? $this->_req_data['status'] : null; |
|
1683 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1684 | 1684 | //determine what post_status our condition will have for the query. |
1685 | - switch ( $status ) { |
|
1685 | + switch ($status) { |
|
1686 | 1686 | case 'month' : |
1687 | 1687 | case 'today' : |
1688 | 1688 | case null : |
1689 | 1689 | case 'all' : |
1690 | 1690 | break; |
1691 | 1691 | case 'draft' : |
1692 | - $where['status'] = array( 'IN', array( 'draft', 'auto-draft' ) ); |
|
1692 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1693 | 1693 | break; |
1694 | 1694 | default : |
1695 | 1695 | $where['status'] = $status; |
1696 | 1696 | } |
1697 | 1697 | //categories? |
1698 | - $category = isset( $this->_req_data['EVT_CAT'] ) && $this->_req_data['EVT_CAT'] > 0 |
|
1698 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1699 | 1699 | ? $this->_req_data['EVT_CAT'] : null; |
1700 | - if ( ! empty ( $category ) ) { |
|
1700 | + if ( ! empty ($category)) { |
|
1701 | 1701 | $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
1702 | 1702 | $where['Term_Taxonomy.term_id'] = $category; |
1703 | 1703 | } |
1704 | 1704 | //date where conditions |
1705 | - $start_formats = EEM_Datetime::instance()->get_formats_for( 'DTT_EVT_start' ); |
|
1706 | - if ( isset( $this->_req_data['month_range'] ) && $this->_req_data['month_range'] != '' ) { |
|
1705 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1706 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1707 | 1707 | $DateTime = new DateTime( |
1708 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1709 | - new DateTimeZone( EEM_Datetime::instance()->get_timezone() ) |
|
1708 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
1709 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1710 | 1710 | ); |
1711 | - $start = $DateTime->format( implode( ' ', $start_formats ) ); |
|
1712 | - $end = $DateTime->setDate( $year_r, $month_r, $DateTime->format( 't' ) )->setTime( 23, 59, 59 )->format( |
|
1713 | - implode( ' ', $start_formats ) |
|
1711 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1712 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime->format('t'))->setTime(23, 59, 59)->format( |
|
1713 | + implode(' ', $start_formats) |
|
1714 | 1714 | ); |
1715 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1716 | - } else if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'today' ) { |
|
1717 | - $DateTime = new DateTime( 'now', new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1718 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1719 | - $end = $DateTime->setTime( 23, 59, 59 )->format( implode( ' ', $start_formats ) ); |
|
1720 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1721 | - } else if ( isset( $this->_req_data['status'] ) && $this->_req_data['status'] == 'month' ) { |
|
1722 | - $now = date( 'Y-m-01' ); |
|
1723 | - $DateTime = new DateTime( $now, new DateTimeZone( EEM_Event::instance()->get_timezone() ) ); |
|
1724 | - $start = $DateTime->setTime( 0, 0, 0 )->format( implode( ' ', $start_formats ) ); |
|
1725 | - $end = $DateTime->setDate( date( 'Y' ), date( 'm' ), $DateTime->format( 't' ) ) |
|
1726 | - ->setTime( 23, 59, 59 ) |
|
1727 | - ->format( implode( ' ', $start_formats ) ); |
|
1728 | - $where['Datetime.DTT_EVT_start'] = array( 'BETWEEN', array( $start, $end ) ); |
|
1715 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1716 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1717 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1718 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1719 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1720 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1721 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1722 | + $now = date('Y-m-01'); |
|
1723 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1724 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1725 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1726 | + ->setTime(23, 59, 59) |
|
1727 | + ->format(implode(' ', $start_formats)); |
|
1728 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1729 | 1729 | } |
1730 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) ) { |
|
1730 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1731 | 1731 | $where['EVT_wp_user'] = get_current_user_id(); |
1732 | 1732 | } else { |
1733 | - if ( ! isset( $where['status'] ) ) { |
|
1734 | - if ( ! EE_Registry::instance()->CAP->current_user_can( 'ee_read_private_events', 'get_events' ) ) { |
|
1733 | + if ( ! isset($where['status'])) { |
|
1734 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1735 | 1735 | $where['OR'] = array( |
1736 | - 'status*restrict_private' => array( '!=', 'private' ), |
|
1736 | + 'status*restrict_private' => array('!=', 'private'), |
|
1737 | 1737 | 'AND' => array( |
1738 | - 'status*inclusive' => array( '=', 'private' ), |
|
1738 | + 'status*inclusive' => array('=', 'private'), |
|
1739 | 1739 | 'EVT_wp_user' => get_current_user_id(), |
1740 | 1740 | ), |
1741 | 1741 | ); |
1742 | 1742 | } |
1743 | 1743 | } |
1744 | 1744 | } |
1745 | - if ( isset( $this->_req_data['EVT_wp_user'] ) ) { |
|
1746 | - if ( $this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1747 | - && EE_Registry::instance()->CAP->current_user_can( 'ee_read_others_events', 'get_events' ) |
|
1745 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1746 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1747 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1748 | 1748 | ) { |
1749 | 1749 | $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
1750 | 1750 | } |
1751 | 1751 | } |
1752 | 1752 | //search query handling |
1753 | - if ( isset( $this->_req_data['s'] ) ) { |
|
1754 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1753 | + if (isset($this->_req_data['s'])) { |
|
1754 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1755 | 1755 | $where['OR'] = array( |
1756 | - 'EVT_name' => array( 'LIKE', $search_string ), |
|
1757 | - 'EVT_desc' => array( 'LIKE', $search_string ), |
|
1758 | - 'EVT_short_desc' => array( 'LIKE', $search_string ), |
|
1756 | + 'EVT_name' => array('LIKE', $search_string), |
|
1757 | + 'EVT_desc' => array('LIKE', $search_string), |
|
1758 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
1759 | 1759 | ); |
1760 | 1760 | } |
1761 | - $where = apply_filters( 'FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data ); |
|
1761 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1762 | 1762 | $query_params = apply_filters( |
1763 | 1763 | 'FHEE__Events_Admin_Page__get_events__query_params', |
1764 | 1764 | array( |
@@ -1771,23 +1771,23 @@ discard block |
||
1771 | 1771 | $this->_req_data |
1772 | 1772 | ); |
1773 | 1773 | //let's first check if we have special requests coming in. |
1774 | - if ( isset( $this->_req_data['active_status'] ) ) { |
|
1775 | - switch ( $this->_req_data['active_status'] ) { |
|
1774 | + if (isset($this->_req_data['active_status'])) { |
|
1775 | + switch ($this->_req_data['active_status']) { |
|
1776 | 1776 | case 'upcoming' : |
1777 | - return $EEME->get_upcoming_events( $query_params, $count ); |
|
1777 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1778 | 1778 | break; |
1779 | 1779 | case 'expired' : |
1780 | - return $EEME->get_expired_events( $query_params, $count ); |
|
1780 | + return $EEME->get_expired_events($query_params, $count); |
|
1781 | 1781 | break; |
1782 | 1782 | case 'active' : |
1783 | - return $EEME->get_active_events( $query_params, $count ); |
|
1783 | + return $EEME->get_active_events($query_params, $count); |
|
1784 | 1784 | break; |
1785 | 1785 | case 'inactive' : |
1786 | - return $EEME->get_inactive_events( $query_params, $count ); |
|
1786 | + return $EEME->get_inactive_events($query_params, $count); |
|
1787 | 1787 | break; |
1788 | 1788 | } |
1789 | 1789 | } |
1790 | - $events = $count ? $EEME->count( array( $where ), 'EVT_ID', true ) : $EEME->get_all( $query_params ); |
|
1790 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1791 | 1791 | return $events; |
1792 | 1792 | } |
1793 | 1793 | |
@@ -1798,9 +1798,9 @@ discard block |
||
1798 | 1798 | * |
1799 | 1799 | * @param string $post_id |
1800 | 1800 | */ |
1801 | - public function trash_cpt_item( $post_id ) { |
|
1801 | + public function trash_cpt_item($post_id) { |
|
1802 | 1802 | $this->_req_data['EVT_ID'] = $post_id; |
1803 | - $this->_trash_or_restore_event( 'trash', false ); |
|
1803 | + $this->_trash_or_restore_event('trash', false); |
|
1804 | 1804 | } |
1805 | 1805 | |
1806 | 1806 | |
@@ -1808,9 +1808,9 @@ discard block |
||
1808 | 1808 | /** |
1809 | 1809 | * @param string $post_id |
1810 | 1810 | */ |
1811 | - public function restore_cpt_item( $post_id ) { |
|
1811 | + public function restore_cpt_item($post_id) { |
|
1812 | 1812 | $this->_req_data['EVT_ID'] = $post_id; |
1813 | - $this->_trash_or_restore_event( 'draft', false ); |
|
1813 | + $this->_trash_or_restore_event('draft', false); |
|
1814 | 1814 | } |
1815 | 1815 | |
1816 | 1816 | |
@@ -1818,9 +1818,9 @@ discard block |
||
1818 | 1818 | /** |
1819 | 1819 | * @param string $post_id |
1820 | 1820 | */ |
1821 | - public function delete_cpt_item( $post_id ) { |
|
1821 | + public function delete_cpt_item($post_id) { |
|
1822 | 1822 | $this->_req_data['EVT_ID'] = $post_id; |
1823 | - $this->_delete_event( false ); |
|
1823 | + $this->_delete_event(false); |
|
1824 | 1824 | } |
1825 | 1825 | |
1826 | 1826 | |
@@ -1832,23 +1832,23 @@ discard block |
||
1832 | 1832 | * @param string $event_status |
1833 | 1833 | * @param bool $redirect_after |
1834 | 1834 | */ |
1835 | - protected function _trash_or_restore_event( $event_status = 'trash', $redirect_after = true ) { |
|
1835 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) { |
|
1836 | 1836 | //determine the event id and set to array. |
1837 | - $EVT_ID = isset( $this->_req_data['EVT_ID'] ) ? absint( $this->_req_data['EVT_ID'] ) : false; |
|
1837 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1838 | 1838 | // loop thru events |
1839 | - if ( $EVT_ID ) { |
|
1839 | + if ($EVT_ID) { |
|
1840 | 1840 | // clean status |
1841 | - $event_status = sanitize_key( $event_status ); |
|
1841 | + $event_status = sanitize_key($event_status); |
|
1842 | 1842 | // grab status |
1843 | - if ( ! empty( $event_status ) ) { |
|
1844 | - $success = $this->_change_event_status( $EVT_ID, $event_status ); |
|
1843 | + if ( ! empty($event_status)) { |
|
1844 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1845 | 1845 | } else { |
1846 | 1846 | $success = false; |
1847 | 1847 | $msg = esc_html__( |
1848 | 1848 | 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
1849 | 1849 | 'event_espresso' |
1850 | 1850 | ); |
1851 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1851 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1852 | 1852 | } |
1853 | 1853 | } else { |
1854 | 1854 | $success = false; |
@@ -1856,11 +1856,11 @@ discard block |
||
1856 | 1856 | 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
1857 | 1857 | 'event_espresso' |
1858 | 1858 | ); |
1859 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1859 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1860 | 1860 | } |
1861 | 1861 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1862 | - if ( $redirect_after ) { |
|
1863 | - $this->_redirect_after_action( $success, 'Event', $action, array( 'action' => 'default' ) ); |
|
1862 | + if ($redirect_after) { |
|
1863 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1864 | 1864 | } |
1865 | 1865 | } |
1866 | 1866 | |
@@ -1873,18 +1873,18 @@ discard block |
||
1873 | 1873 | * @param string $event_status |
1874 | 1874 | * @return void |
1875 | 1875 | */ |
1876 | - protected function _trash_or_restore_events( $event_status = 'trash' ) { |
|
1876 | + protected function _trash_or_restore_events($event_status = 'trash') { |
|
1877 | 1877 | // clean status |
1878 | - $event_status = sanitize_key( $event_status ); |
|
1878 | + $event_status = sanitize_key($event_status); |
|
1879 | 1879 | // grab status |
1880 | - if ( ! empty( $event_status ) ) { |
|
1880 | + if ( ! empty($event_status)) { |
|
1881 | 1881 | $success = true; |
1882 | 1882 | //determine the event id and set to array. |
1883 | - $EVT_IDs = isset( $this->_req_data['EVT_IDs'] ) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1883 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1884 | 1884 | // loop thru events |
1885 | - foreach ( $EVT_IDs as $EVT_ID ) { |
|
1886 | - if ( $EVT_ID = absint( $EVT_ID ) ) { |
|
1887 | - $results = $this->_change_event_status( $EVT_ID, $event_status ); |
|
1885 | + foreach ($EVT_IDs as $EVT_ID) { |
|
1886 | + if ($EVT_ID = absint($EVT_ID)) { |
|
1887 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1888 | 1888 | $success = $results !== false ? $success : false; |
1889 | 1889 | } else { |
1890 | 1890 | $msg = sprintf( |
@@ -1894,7 +1894,7 @@ discard block |
||
1894 | 1894 | ), |
1895 | 1895 | $EVT_ID |
1896 | 1896 | ); |
1897 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1897 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1898 | 1898 | $success = false; |
1899 | 1899 | } |
1900 | 1900 | } |
@@ -1904,12 +1904,12 @@ discard block |
||
1904 | 1904 | 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
1905 | 1905 | 'event_espresso' |
1906 | 1906 | ); |
1907 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1907 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1908 | 1908 | } |
1909 | 1909 | // in order to force a pluralized result message we need to send back a success status greater than 1 |
1910 | 1910 | $success = $success ? 2 : false; |
1911 | 1911 | $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
1912 | - $this->_redirect_after_action( $success, 'Events', $action, array( 'action' => 'default' ) ); |
|
1912 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1913 | 1913 | } |
1914 | 1914 | |
1915 | 1915 | |
@@ -1922,30 +1922,30 @@ discard block |
||
1922 | 1922 | * @param string $event_status |
1923 | 1923 | * @return bool |
1924 | 1924 | */ |
1925 | - private function _change_event_status( $EVT_ID = 0, $event_status = '' ) { |
|
1925 | + private function _change_event_status($EVT_ID = 0, $event_status = '') { |
|
1926 | 1926 | // grab event id |
1927 | - if ( ! $EVT_ID ) { |
|
1927 | + if ( ! $EVT_ID) { |
|
1928 | 1928 | $msg = esc_html__( |
1929 | 1929 | 'An error occurred. No Event ID or an invalid Event ID was received.', |
1930 | 1930 | 'event_espresso' |
1931 | 1931 | ); |
1932 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1932 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1933 | 1933 | return false; |
1934 | 1934 | } |
1935 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
1935 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
1936 | 1936 | // clean status |
1937 | - $event_status = sanitize_key( $event_status ); |
|
1937 | + $event_status = sanitize_key($event_status); |
|
1938 | 1938 | // grab status |
1939 | - if ( empty( $event_status ) ) { |
|
1939 | + if (empty($event_status)) { |
|
1940 | 1940 | $msg = esc_html__( |
1941 | 1941 | 'An error occurred. No Event Status or an invalid Event Status was received.', |
1942 | 1942 | 'event_espresso' |
1943 | 1943 | ); |
1944 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1944 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1945 | 1945 | return false; |
1946 | 1946 | } |
1947 | 1947 | // was event trashed or restored ? |
1948 | - switch ( $event_status ) { |
|
1948 | + switch ($event_status) { |
|
1949 | 1949 | case 'draft' : |
1950 | 1950 | $action = 'restored from the trash'; |
1951 | 1951 | $hook = 'AHEE_event_restored_from_trash'; |
@@ -1959,15 +1959,15 @@ discard block |
||
1959 | 1959 | $hook = false; |
1960 | 1960 | } |
1961 | 1961 | //use class to change status |
1962 | - $this->_cpt_model_obj->set_status( $event_status ); |
|
1962 | + $this->_cpt_model_obj->set_status($event_status); |
|
1963 | 1963 | $success = $this->_cpt_model_obj->save(); |
1964 | - if ( $success === false ) { |
|
1965 | - $msg = sprintf( esc_html__( 'An error occurred. The event could not be %s.', 'event_espresso' ), $action ); |
|
1966 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
1964 | + if ($success === false) { |
|
1965 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
1966 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1967 | 1967 | return false; |
1968 | 1968 | } |
1969 | - if ( $hook ) { |
|
1970 | - do_action( $hook ); |
|
1969 | + if ($hook) { |
|
1970 | + do_action($hook); |
|
1971 | 1971 | } |
1972 | 1972 | return true; |
1973 | 1973 | } |
@@ -1980,34 +1980,34 @@ discard block |
||
1980 | 1980 | * @access protected |
1981 | 1981 | * @param bool $redirect_after |
1982 | 1982 | */ |
1983 | - protected function _delete_event( $redirect_after = true ) { |
|
1983 | + protected function _delete_event($redirect_after = true) { |
|
1984 | 1984 | //determine the event id and set to array. |
1985 | - $EVT_ID = isset( $this->_req_data['EVT_ID'] ) ? absint( $this->_req_data['EVT_ID'] ) : null; |
|
1986 | - $EVT_ID = isset( $this->_req_data['post'] ) ? absint( $this->_req_data['post'] ) : $EVT_ID; |
|
1985 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
1986 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
1987 | 1987 | // loop thru events |
1988 | - if ( $EVT_ID ) { |
|
1989 | - $success = $this->_permanently_delete_event( $EVT_ID ); |
|
1988 | + if ($EVT_ID) { |
|
1989 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
1990 | 1990 | // get list of events with no prices |
1991 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', array() ); |
|
1991 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
1992 | 1992 | // remove this event from the list of events with no prices |
1993 | - if ( isset( $espresso_no_ticket_prices[ $EVT_ID ] ) ) { |
|
1994 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
1993 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
1994 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
1995 | 1995 | } |
1996 | - update_option( 'ee_no_ticket_prices', $espresso_no_ticket_prices ); |
|
1996 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
1997 | 1997 | } else { |
1998 | 1998 | $success = false; |
1999 | 1999 | $msg = esc_html__( |
2000 | 2000 | 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
2001 | 2001 | 'event_espresso' |
2002 | 2002 | ); |
2003 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2003 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2004 | 2004 | } |
2005 | - if ( $redirect_after ) { |
|
2005 | + if ($redirect_after) { |
|
2006 | 2006 | $this->_redirect_after_action( |
2007 | 2007 | $success, |
2008 | 2008 | 'Event', |
2009 | 2009 | 'deleted', |
2010 | - array( 'action' => 'default', 'status' => 'trash' ) |
|
2010 | + array('action' => 'default', 'status' => 'trash') |
|
2011 | 2011 | ); |
2012 | 2012 | } |
2013 | 2013 | } |
@@ -2023,30 +2023,30 @@ discard block |
||
2023 | 2023 | protected function _delete_events() { |
2024 | 2024 | $success = true; |
2025 | 2025 | // get list of events with no prices |
2026 | - $espresso_no_ticket_prices = get_option( 'ee_no_ticket_prices', array() ); |
|
2026 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2027 | 2027 | //determine the event id and set to array. |
2028 | - $EVT_IDs = isset( $this->_req_data['EVT_IDs'] ) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2028 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2029 | 2029 | // loop thru events |
2030 | - foreach ( $EVT_IDs as $EVT_ID ) { |
|
2031 | - $EVT_ID = absint( $EVT_ID ); |
|
2032 | - if ( $EVT_ID ) { |
|
2033 | - $results = $this->_permanently_delete_event( $EVT_ID ); |
|
2030 | + foreach ($EVT_IDs as $EVT_ID) { |
|
2031 | + $EVT_ID = absint($EVT_ID); |
|
2032 | + if ($EVT_ID) { |
|
2033 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
2034 | 2034 | $success = $results !== false ? $success : false; |
2035 | 2035 | // remove this event from the list of events with no prices |
2036 | - unset( $espresso_no_ticket_prices[ $EVT_ID ] ); |
|
2036 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2037 | 2037 | } else { |
2038 | 2038 | $success = false; |
2039 | 2039 | $msg = esc_html__( |
2040 | 2040 | 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
2041 | 2041 | 'event_espresso' |
2042 | 2042 | ); |
2043 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2043 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2044 | 2044 | } |
2045 | 2045 | } |
2046 | - update_option( 'ee_no_ticket_prices', $espresso_no_ticket_prices ); |
|
2046 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2047 | 2047 | // in order to force a pluralized result message we need to send back a success status greater than 1 |
2048 | 2048 | $success = $success ? 2 : false; |
2049 | - $this->_redirect_after_action( $success, 'Events', 'deleted', array( 'action' => 'default' ) ); |
|
2049 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2050 | 2050 | } |
2051 | 2051 | |
2052 | 2052 | |
@@ -2058,70 +2058,70 @@ discard block |
||
2058 | 2058 | * @param int $EVT_ID |
2059 | 2059 | * @return bool |
2060 | 2060 | */ |
2061 | - private function _permanently_delete_event( $EVT_ID = 0 ) { |
|
2061 | + private function _permanently_delete_event($EVT_ID = 0) { |
|
2062 | 2062 | // grab event id |
2063 | - if ( ! $EVT_ID ) { |
|
2063 | + if ( ! $EVT_ID) { |
|
2064 | 2064 | $msg = esc_html__( |
2065 | 2065 | 'An error occurred. No Event ID or an invalid Event ID was received.', |
2066 | 2066 | 'event_espresso' |
2067 | 2067 | ); |
2068 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2068 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2069 | 2069 | return false; |
2070 | 2070 | } |
2071 | 2071 | if ( |
2072 | 2072 | ! $this->_cpt_model_obj instanceof EE_Event |
2073 | 2073 | || $this->_cpt_model_obj->ID() !== $EVT_ID |
2074 | 2074 | ) { |
2075 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID( $EVT_ID ); |
|
2075 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2076 | 2076 | } |
2077 | - if ( ! $this->_cpt_model_obj instanceof EE_Event ) { |
|
2077 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2078 | 2078 | return false; |
2079 | 2079 | } |
2080 | 2080 | //need to delete related tickets and prices first. |
2081 | - $datetimes = $this->_cpt_model_obj->get_many_related( 'Datetime' ); |
|
2082 | - foreach ( $datetimes as $datetime ) { |
|
2083 | - $this->_cpt_model_obj->_remove_relation_to( $datetime, 'Datetime' ); |
|
2084 | - $tickets = $datetime->get_many_related( 'Ticket' ); |
|
2085 | - foreach ( $tickets as $ticket ) { |
|
2086 | - $ticket->_remove_relation_to( $datetime, 'Datetime' ); |
|
2087 | - $ticket->delete_related_permanently( 'Price' ); |
|
2081 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2082 | + foreach ($datetimes as $datetime) { |
|
2083 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2084 | + $tickets = $datetime->get_many_related('Ticket'); |
|
2085 | + foreach ($tickets as $ticket) { |
|
2086 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2087 | + $ticket->delete_related_permanently('Price'); |
|
2088 | 2088 | $ticket->delete_permanently(); |
2089 | 2089 | } |
2090 | 2090 | $datetime->delete(); |
2091 | 2091 | } |
2092 | 2092 | //what about related venues or terms? |
2093 | - $venues = $this->_cpt_model_obj->get_many_related( 'Venue' ); |
|
2094 | - foreach ( $venues as $venue ) { |
|
2095 | - $this->_cpt_model_obj->_remove_relation_to( $venue, 'Venue' ); |
|
2093 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2094 | + foreach ($venues as $venue) { |
|
2095 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2096 | 2096 | } |
2097 | 2097 | //any attached question groups? |
2098 | - $question_groups = $this->_cpt_model_obj->get_many_related( 'Question_Group' ); |
|
2099 | - if ( ! empty( $question_groups ) ) { |
|
2100 | - foreach ( $question_groups as $question_group ) { |
|
2101 | - $this->_cpt_model_obj->_remove_relation_to( $question_group, 'Question_Group' ); |
|
2098 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2099 | + if ( ! empty($question_groups)) { |
|
2100 | + foreach ($question_groups as $question_group) { |
|
2101 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2102 | 2102 | } |
2103 | 2103 | } |
2104 | 2104 | //Message Template Groups |
2105 | - $this->_cpt_model_obj->_remove_relations( 'Message_Template_Group' ); |
|
2105 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2106 | 2106 | /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
2107 | 2107 | $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
2108 | - foreach ( $term_taxonomies as $term_taxonomy ) { |
|
2109 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy( $term_taxonomy ); |
|
2108 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
2109 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2110 | 2110 | } |
2111 | 2111 | $success = $this->_cpt_model_obj->delete_permanently(); |
2112 | 2112 | // did it all go as planned ? |
2113 | - if ( $success ) { |
|
2114 | - $msg = sprintf( esc_html__( 'Event ID # %d has been deleted.', 'event_espresso' ), $EVT_ID ); |
|
2115 | - EE_Error::add_success( $msg ); |
|
2113 | + if ($success) { |
|
2114 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2115 | + EE_Error::add_success($msg); |
|
2116 | 2116 | } else { |
2117 | 2117 | $msg = sprintf( |
2118 | - esc_html__( 'An error occurred. Event ID # %d could not be deleted.', 'event_espresso' ), |
|
2118 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2119 | 2119 | $EVT_ID |
2120 | 2120 | ); |
2121 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2121 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2122 | 2122 | return false; |
2123 | 2123 | } |
2124 | - do_action( 'AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID ); |
|
2124 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2125 | 2125 | return true; |
2126 | 2126 | } |
2127 | 2127 | |
@@ -2134,7 +2134,7 @@ discard block |
||
2134 | 2134 | * @return int |
2135 | 2135 | */ |
2136 | 2136 | public function total_events() { |
2137 | - $count = EEM_Event::instance()->count( array( 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2137 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2138 | 2138 | return $count; |
2139 | 2139 | } |
2140 | 2140 | |
@@ -2148,9 +2148,9 @@ discard block |
||
2148 | 2148 | */ |
2149 | 2149 | public function total_events_draft() { |
2150 | 2150 | $where = array( |
2151 | - 'status' => array( 'IN', array( 'draft', 'auto-draft' ) ), |
|
2151 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
2152 | 2152 | ); |
2153 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2153 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2154 | 2154 | return $count; |
2155 | 2155 | } |
2156 | 2156 | |
@@ -2166,7 +2166,7 @@ discard block |
||
2166 | 2166 | $where = array( |
2167 | 2167 | 'status' => 'trash', |
2168 | 2168 | ); |
2169 | - $count = EEM_Event::instance()->count( array( $where, 'caps' => 'read_admin' ), 'EVT_ID', true ); |
|
2169 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2170 | 2170 | return $count; |
2171 | 2171 | } |
2172 | 2172 | |
@@ -2197,12 +2197,12 @@ discard block |
||
2197 | 2197 | EE_Registry::instance()->CFG->registration->default_STS_ID, |
2198 | 2198 | $this->_template_args['reg_status_array'] |
2199 | 2199 | ) |
2200 | - ? sanitize_text_field( EE_Registry::instance()->CFG->registration->default_STS_ID ) |
|
2200 | + ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2201 | 2201 | : EEM_Registration::status_id_pending_payment; |
2202 | - $this->_set_add_edit_form_tags( 'update_default_event_settings' ); |
|
2203 | - $this->_set_publish_post_box_vars( null, false, false, null, false ); |
|
2202 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2203 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2204 | 2204 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2205 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2205 | + EVENTS_TEMPLATE_PATH.'event_settings.template.php', |
|
2206 | 2206 | $this->_template_args, |
2207 | 2207 | true |
2208 | 2208 | ); |
@@ -2218,8 +2218,8 @@ discard block |
||
2218 | 2218 | * @return void |
2219 | 2219 | */ |
2220 | 2220 | protected function _update_default_event_settings() { |
2221 | - EE_Config::instance()->registration->default_STS_ID = isset( $this->_req_data['default_reg_status'] ) |
|
2222 | - ? sanitize_text_field( $this->_req_data['default_reg_status'] ) |
|
2221 | + EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2222 | + ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2223 | 2223 | : EEM_Registration::status_id_pending_payment; |
2224 | 2224 | $what = 'Default Event Settings'; |
2225 | 2225 | $success = $this->_update_espresso_configuration( |
@@ -2229,7 +2229,7 @@ discard block |
||
2229 | 2229 | __FUNCTION__, |
2230 | 2230 | __LINE__ |
2231 | 2231 | ); |
2232 | - $this->_redirect_after_action( $success, $what, 'updated', array( 'action' => 'default_event_settings' ) ); |
|
2232 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2233 | 2233 | } |
2234 | 2234 | |
2235 | 2235 | |
@@ -2239,20 +2239,20 @@ discard block |
||
2239 | 2239 | |
2240 | 2240 | |
2241 | 2241 | protected function _template_settings() { |
2242 | - $this->_admin_page_title = esc_html__( 'Template Settings (Preview)', 'event_espresso' ); |
|
2242 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2243 | 2243 | $this->_template_args['preview_img'] = '<img src="' |
2244 | 2244 | . EVENTS_ASSETS_URL |
2245 | 2245 | . DS |
2246 | 2246 | . 'images' |
2247 | 2247 | . DS |
2248 | 2248 | . 'caffeinated_template_features.jpg" alt="' |
2249 | - . esc_attr__( 'Template Settings Preview screenshot', 'event_espresso' ) |
|
2249 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2250 | 2250 | . '" />'; |
2251 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2251 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
2252 | 2252 | 'Template Settings is a feature that is only available in the Caffeinated version of Event Espresso. Template Settings allow you to configure some of the appearance options for both the Event List and Event Details pages.', |
2253 | 2253 | 'event_espresso' |
2254 | - ) . '</strong>'; |
|
2255 | - $this->display_admin_caf_preview_page( 'template_settings_tab' ); |
|
2254 | + ).'</strong>'; |
|
2255 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2256 | 2256 | } |
2257 | 2257 | |
2258 | 2258 | |
@@ -2264,18 +2264,18 @@ discard block |
||
2264 | 2264 | * @return void |
2265 | 2265 | */ |
2266 | 2266 | private function _set_category_object() { |
2267 | - if ( isset( $this->_category->id ) && ! empty( $this->_category->id ) ) { |
|
2267 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2268 | 2268 | return; |
2269 | 2269 | } //already have the category object so get out. |
2270 | 2270 | //set default category object |
2271 | 2271 | $this->_set_empty_category_object(); |
2272 | 2272 | //only set if we've got an id |
2273 | - if ( ! isset( $this->_req_data['EVT_CAT_ID'] ) ) { |
|
2273 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2274 | 2274 | return; |
2275 | 2275 | } |
2276 | - $category_id = absint( $this->_req_data['EVT_CAT_ID'] ); |
|
2277 | - $term = get_term( $category_id, 'espresso_event_categories' ); |
|
2278 | - if ( ! empty( $term ) ) { |
|
2276 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2277 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2278 | + if ( ! empty($term)) { |
|
2279 | 2279 | $this->_category->category_name = $term->name; |
2280 | 2280 | $this->_category->category_identifier = $term->slug; |
2281 | 2281 | $this->_category->category_desc = $term->description; |
@@ -2295,9 +2295,9 @@ discard block |
||
2295 | 2295 | |
2296 | 2296 | |
2297 | 2297 | protected function _category_list_table() { |
2298 | - do_action( 'AHEE_log', __FILE__, __FUNCTION__, '' ); |
|
2299 | - $this->_search_btn_label = esc_html__( 'Categories', 'event_espresso' ); |
|
2300 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2298 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2299 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2300 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
2301 | 2301 | 'add_category', |
2302 | 2302 | 'add_category', |
2303 | 2303 | array(), |
@@ -2311,20 +2311,20 @@ discard block |
||
2311 | 2311 | /** |
2312 | 2312 | * @param $view |
2313 | 2313 | */ |
2314 | - protected function _category_details( $view ) { |
|
2314 | + protected function _category_details($view) { |
|
2315 | 2315 | //load formatter helper |
2316 | 2316 | //load field generator helper |
2317 | 2317 | $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
2318 | - $this->_set_add_edit_form_tags( $route ); |
|
2318 | + $this->_set_add_edit_form_tags($route); |
|
2319 | 2319 | $this->_set_category_object(); |
2320 | - $id = ! empty( $this->_category->id ) ? $this->_category->id : ''; |
|
2320 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2321 | 2321 | $delete_action = 'delete_category'; |
2322 | 2322 | //custom redirect |
2323 | 2323 | $redirect = EE_Admin_Page::add_query_args_and_nonce( |
2324 | - array( 'action' => 'category_list' ), |
|
2324 | + array('action' => 'category_list'), |
|
2325 | 2325 | $this->_admin_base_url |
2326 | 2326 | ); |
2327 | - $this->_set_publish_post_box_vars( 'EVT_CAT_ID', $id, $delete_action, $redirect ); |
|
2327 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2328 | 2328 | //take care of contents |
2329 | 2329 | $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
2330 | 2330 | $this->display_admin_page_with_sidebar(); |
@@ -2338,21 +2338,21 @@ discard block |
||
2338 | 2338 | protected function _category_details_content() { |
2339 | 2339 | $editor_args['category_desc'] = array( |
2340 | 2340 | 'type' => 'wp_editor', |
2341 | - 'value' => EEH_Formatter::admin_format_content( $this->_category->category_desc ), |
|
2341 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2342 | 2342 | 'class' => 'my_editor_custom', |
2343 | - 'wpeditor_args' => array( 'media_buttons' => false ), |
|
2343 | + 'wpeditor_args' => array('media_buttons' => false), |
|
2344 | 2344 | ); |
2345 | - $_wp_editor = $this->_generate_admin_form_fields( $editor_args, 'array' ); |
|
2345 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2346 | 2346 | $all_terms = get_terms( |
2347 | - array( 'espresso_event_categories' ), |
|
2348 | - array( 'hide_empty' => 0, 'exclude' => array( $this->_category->id ) ) |
|
2347 | + array('espresso_event_categories'), |
|
2348 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2349 | 2349 | ); |
2350 | 2350 | //setup category select for term parents. |
2351 | 2351 | $category_select_values[] = array( |
2352 | - 'text' => esc_html__( 'No Parent', 'event_espresso' ), |
|
2352 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2353 | 2353 | 'id' => 0, |
2354 | 2354 | ); |
2355 | - foreach ( $all_terms as $term ) { |
|
2355 | + foreach ($all_terms as $term) { |
|
2356 | 2356 | $category_select_values[] = array( |
2357 | 2357 | 'text' => $term->name, |
2358 | 2358 | 'id' => $term->term_id, |
@@ -2366,28 +2366,28 @@ discard block |
||
2366 | 2366 | $template_args = array( |
2367 | 2367 | 'category' => $this->_category, |
2368 | 2368 | 'category_select' => $category_select, |
2369 | - 'unique_id_info_help_link' => $this->_get_help_tab_link( 'unique_id_info' ), |
|
2369 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2370 | 2370 | 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
2371 | 2371 | 'disable' => '', |
2372 | 2372 | 'disabled_message' => false, |
2373 | 2373 | ); |
2374 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2375 | - return EEH_Template::display_template( $template, $template_args, true ); |
|
2374 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2375 | + return EEH_Template::display_template($template, $template_args, true); |
|
2376 | 2376 | } |
2377 | 2377 | |
2378 | 2378 | |
2379 | 2379 | |
2380 | 2380 | protected function _delete_categories() { |
2381 | - $cat_ids = isset( $this->_req_data['EVT_CAT_ID'] ) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2381 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2382 | 2382 | : (array) $this->_req_data['category_id']; |
2383 | - foreach ( $cat_ids as $cat_id ) { |
|
2384 | - $this->_delete_category( $cat_id ); |
|
2383 | + foreach ($cat_ids as $cat_id) { |
|
2384 | + $this->_delete_category($cat_id); |
|
2385 | 2385 | } |
2386 | 2386 | //doesn't matter what page we're coming from... we're going to the same place after delete. |
2387 | 2387 | $query_args = array( |
2388 | 2388 | 'action' => 'category_list', |
2389 | 2389 | ); |
2390 | - $this->_redirect_after_action( 0, '', '', $query_args ); |
|
2390 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2391 | 2391 | } |
2392 | 2392 | |
2393 | 2393 | |
@@ -2395,9 +2395,9 @@ discard block |
||
2395 | 2395 | /** |
2396 | 2396 | * @param $cat_id |
2397 | 2397 | */ |
2398 | - protected function _delete_category( $cat_id ) { |
|
2399 | - $cat_id = absint( $cat_id ); |
|
2400 | - wp_delete_term( $cat_id, 'espresso_event_categories' ); |
|
2398 | + protected function _delete_category($cat_id) { |
|
2399 | + $cat_id = absint($cat_id); |
|
2400 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2401 | 2401 | } |
2402 | 2402 | |
2403 | 2403 | |
@@ -2405,18 +2405,18 @@ discard block |
||
2405 | 2405 | /** |
2406 | 2406 | * @param $new_category |
2407 | 2407 | */ |
2408 | - protected function _insert_or_update_category( $new_category ) { |
|
2409 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category( true ); |
|
2408 | + protected function _insert_or_update_category($new_category) { |
|
2409 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2410 | 2410 | $success = 0; //we already have a success message so lets not send another. |
2411 | - if ( $cat_id ) { |
|
2411 | + if ($cat_id) { |
|
2412 | 2412 | $query_args = array( |
2413 | 2413 | 'action' => 'edit_category', |
2414 | 2414 | 'EVT_CAT_ID' => $cat_id, |
2415 | 2415 | ); |
2416 | 2416 | } else { |
2417 | - $query_args = array( 'action' => 'add_category' ); |
|
2417 | + $query_args = array('action' => 'add_category'); |
|
2418 | 2418 | } |
2419 | - $this->_redirect_after_action( $success, '', '', $query_args, true ); |
|
2419 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2420 | 2420 | } |
2421 | 2421 | |
2422 | 2422 | |
@@ -2425,14 +2425,14 @@ discard block |
||
2425 | 2425 | * @param bool $update |
2426 | 2426 | * @return bool|mixed|string |
2427 | 2427 | */ |
2428 | - private function _insert_category( $update = false ) { |
|
2428 | + private function _insert_category($update = false) { |
|
2429 | 2429 | $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
2430 | - $category_name = isset( $this->_req_data['category_name'] ) ? $this->_req_data['category_name'] : ''; |
|
2431 | - $category_desc = isset( $this->_req_data['category_desc'] ) ? $this->_req_data['category_desc'] : ''; |
|
2432 | - $category_parent = isset( $this->_req_data['category_parent'] ) ? $this->_req_data['category_parent'] : 0; |
|
2433 | - if ( empty( $category_name ) ) { |
|
2434 | - $msg = esc_html__( 'You must add a name for the category.', 'event_espresso' ); |
|
2435 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2430 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2431 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2432 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2433 | + if (empty($category_name)) { |
|
2434 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2435 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2436 | 2436 | return false; |
2437 | 2437 | } |
2438 | 2438 | $term_args = array( |
@@ -2441,22 +2441,22 @@ discard block |
||
2441 | 2441 | 'parent' => $category_parent, |
2442 | 2442 | ); |
2443 | 2443 | //was the category_identifier input disabled? |
2444 | - if ( isset( $this->_req_data['category_identifier'] ) ) { |
|
2444 | + if (isset($this->_req_data['category_identifier'])) { |
|
2445 | 2445 | $term_args['slug'] = $this->_req_data['category_identifier']; |
2446 | 2446 | } |
2447 | 2447 | $insert_ids = $update |
2448 | - ? wp_update_term( $cat_id, 'espresso_event_categories', $term_args ) |
|
2449 | - : wp_insert_term( $category_name, 'espresso_event_categories', $term_args ); |
|
2450 | - if ( ! is_array( $insert_ids ) ) { |
|
2448 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2449 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2450 | + if ( ! is_array($insert_ids)) { |
|
2451 | 2451 | $msg = esc_html__( |
2452 | 2452 | 'An error occurred and the category has not been saved to the database.', |
2453 | 2453 | 'event_espresso' |
2454 | 2454 | ); |
2455 | - EE_Error::add_error( $msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
2455 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2456 | 2456 | } else { |
2457 | 2457 | $cat_id = $insert_ids['term_id']; |
2458 | - $msg = sprintf( esc_html__( 'The category %s was successfully saved', 'event_espresso' ), $category_name ); |
|
2459 | - EE_Error::add_success( $msg ); |
|
2458 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2459 | + EE_Error::add_success($msg); |
|
2460 | 2460 | } |
2461 | 2461 | return $cat_id; |
2462 | 2462 | } |
@@ -2469,28 +2469,28 @@ discard block |
||
2469 | 2469 | * @param bool $count |
2470 | 2470 | * @return \EE_Base_Class[]|int |
2471 | 2471 | */ |
2472 | - public function get_categories( $per_page = 10, $current_page = 1, $count = false ) { |
|
2472 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) { |
|
2473 | 2473 | //testing term stuff |
2474 | - $orderby = isset( $this->_req_data['orderby'] ) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2475 | - $order = isset( $this->_req_data['order'] ) ? $this->_req_data['order'] : 'DESC'; |
|
2476 | - $limit = ( $current_page - 1 ) * $per_page; |
|
2477 | - $where = array( 'taxonomy' => 'espresso_event_categories' ); |
|
2478 | - if ( isset( $this->_req_data['s'] ) ) { |
|
2479 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2474 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2475 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2476 | + $limit = ($current_page - 1) * $per_page; |
|
2477 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2478 | + if (isset($this->_req_data['s'])) { |
|
2479 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2480 | 2480 | $where['OR'] = array( |
2481 | - 'Term.name' => array( 'LIKE', $sstr ), |
|
2482 | - 'description' => array( 'LIKE', $sstr ), |
|
2481 | + 'Term.name' => array('LIKE', $sstr), |
|
2482 | + 'description' => array('LIKE', $sstr), |
|
2483 | 2483 | ); |
2484 | 2484 | } |
2485 | 2485 | $query_params = array( |
2486 | 2486 | $where, |
2487 | - 'order_by' => array( $orderby => $order ), |
|
2488 | - 'limit' => $limit . ',' . $per_page, |
|
2489 | - 'force_join' => array( 'Term' ), |
|
2487 | + 'order_by' => array($orderby => $order), |
|
2488 | + 'limit' => $limit.','.$per_page, |
|
2489 | + 'force_join' => array('Term'), |
|
2490 | 2490 | ); |
2491 | 2491 | $categories = $count |
2492 | - ? EEM_Term_Taxonomy::instance()->count( $query_params, 'term_id' ) |
|
2493 | - : EEM_Term_Taxonomy::instance()->get_all( $query_params ); |
|
2492 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2493 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2494 | 2494 | return $categories; |
2495 | 2495 | } |
2496 | 2496 |