@@ -155,12 +155,12 @@ discard block |
||
155 | 155 | */ |
156 | 156 | public static function reset( $hard_reset = false, $reinstantiate = true ) { |
157 | 157 | if ( self::$_instance instanceof EE_Config ) { |
158 | - if ($hard_reset) { |
|
159 | - self::$_instance->_addon_option_names = array(); |
|
160 | - self::$_instance->_initialize_config(); |
|
161 | - self::$_instance->update_espresso_config(); |
|
162 | - } |
|
163 | - self::$_instance->update_addon_option_names(); |
|
158 | + if ($hard_reset) { |
|
159 | + self::$_instance->_addon_option_names = array(); |
|
160 | + self::$_instance->_initialize_config(); |
|
161 | + self::$_instance->update_espresso_config(); |
|
162 | + } |
|
163 | + self::$_instance->update_addon_option_names(); |
|
164 | 164 | } |
165 | 165 | self::$_instance = null; |
166 | 166 | //we don't need to reset the static properties imo because those should |
@@ -2211,7 +2211,7 @@ discard block |
||
2211 | 2211 | $table_analysis = EE_Registry::instance()->create( 'TableAnalysis', array(), true ); |
2212 | 2212 | // get country code from organization settings or use default |
2213 | 2213 | $ORG_CNT = isset( EE_Registry::instance()->CFG->organization ) |
2214 | - && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2214 | + && EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config |
|
2215 | 2215 | ? EE_Registry::instance()->CFG->organization->CNT_ISO |
2216 | 2216 | : ''; |
2217 | 2217 | // but override if requested |
@@ -2521,12 +2521,12 @@ discard block |
||
2521 | 2521 | public $help_tour_activation; |
2522 | 2522 | |
2523 | 2523 | /** |
2524 | - * adds extra layer of encoding to session data to prevent serialization errors |
|
2525 | - * but is incompatible with some server configuration errors |
|
2526 | - * if you get "500 internal server errors" during registration, try turning this on |
|
2527 | - * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2528 | - * |
|
2529 | - * @var boolean $encode_session_data |
|
2524 | + * adds extra layer of encoding to session data to prevent serialization errors |
|
2525 | + * but is incompatible with some server configuration errors |
|
2526 | + * if you get "500 internal server errors" during registration, try turning this on |
|
2527 | + * if you get PHP fatal errors regarding base 64 methods not defined, then turn this off |
|
2528 | + * |
|
2529 | + * @var boolean $encode_session_data |
|
2530 | 2530 | */ |
2531 | 2531 | private $encode_session_data = false; |
2532 | 2532 | |
@@ -2591,21 +2591,21 @@ discard block |
||
2591 | 2591 | |
2592 | 2592 | |
2593 | 2593 | |
2594 | - /** |
|
2595 | - * @return boolean |
|
2596 | - */ |
|
2597 | - public function encode_session_data() { |
|
2598 | - return filter_var( $this->encode_session_data, FILTER_VALIDATE_BOOLEAN ); |
|
2599 | - } |
|
2594 | + /** |
|
2595 | + * @return boolean |
|
2596 | + */ |
|
2597 | + public function encode_session_data() { |
|
2598 | + return filter_var( $this->encode_session_data, FILTER_VALIDATE_BOOLEAN ); |
|
2599 | + } |
|
2600 | 2600 | |
2601 | 2601 | |
2602 | 2602 | |
2603 | - /** |
|
2604 | - * @param boolean $encode_session_data |
|
2605 | - */ |
|
2606 | - public function set_encode_session_data( $encode_session_data ) { |
|
2607 | - $this->encode_session_data = filter_var( $encode_session_data, FILTER_VALIDATE_BOOLEAN ); |
|
2608 | - } |
|
2603 | + /** |
|
2604 | + * @param boolean $encode_session_data |
|
2605 | + */ |
|
2606 | + public function set_encode_session_data( $encode_session_data ) { |
|
2607 | + $this->encode_session_data = filter_var( $encode_session_data, FILTER_VALIDATE_BOOLEAN ); |
|
2608 | + } |
|
2609 | 2609 | |
2610 | 2610 | |
2611 | 2611 | |
@@ -2649,13 +2649,13 @@ discard block |
||
2649 | 2649 | public $current_espresso_theme; |
2650 | 2650 | |
2651 | 2651 | /** |
2652 | - * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2653 | - */ |
|
2652 | + * @var EE_Ticket_Selector_Config $EED_Ticket_Selector |
|
2653 | + */ |
|
2654 | 2654 | public $EED_Ticket_Selector; |
2655 | 2655 | |
2656 | 2656 | /** |
2657 | - * @var EE_Event_Single_Config $EED_Event_Single |
|
2658 | - */ |
|
2657 | + * @var EE_Event_Single_Config $EED_Event_Single |
|
2658 | + */ |
|
2659 | 2659 | public $EED_Event_Single; |
2660 | 2660 | |
2661 | 2661 | /** |
@@ -2896,16 +2896,16 @@ discard block |
||
2896 | 2896 | */ |
2897 | 2897 | class EE_Ticket_Selector_Config extends EE_Config_Base { |
2898 | 2898 | |
2899 | - /** |
|
2900 | - * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2901 | - */ |
|
2902 | - const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2899 | + /** |
|
2900 | + * constant to indicate that a datetime selector should NEVER be shown for ticket selectors |
|
2901 | + */ |
|
2902 | + const DO_NOT_SHOW_DATETIME_SELECTOR = 'no_datetime_selector'; |
|
2903 | 2903 | |
2904 | - /** |
|
2905 | - * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2906 | - * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2907 | - */ |
|
2908 | - const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2904 | + /** |
|
2905 | + * constant to indicate that a datetime selector should only be shown for ticket selectors |
|
2906 | + * when the number of datetimes for the event matches the value set for $datetime_selector_threshold |
|
2907 | + */ |
|
2908 | + const MAYBE_SHOW_DATETIME_SELECTOR = 'maybe_datetime_selector'; |
|
2909 | 2909 | |
2910 | 2910 | /** |
2911 | 2911 | * @var boolean $show_ticket_sale_columns |
@@ -2944,7 +2944,7 @@ discard block |
||
2944 | 2944 | * class constructor |
2945 | 2945 | */ |
2946 | 2946 | public function __construct() { |
2947 | - $this->show_ticket_sale_columns = true; |
|
2947 | + $this->show_ticket_sale_columns = true; |
|
2948 | 2948 | $this->show_ticket_details = true; |
2949 | 2949 | $this->show_expired_tickets = true; |
2950 | 2950 | $this->show_datetime_selector = \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
@@ -2953,92 +2953,92 @@ discard block |
||
2953 | 2953 | |
2954 | 2954 | |
2955 | 2955 | |
2956 | - /** |
|
2957 | - * returns true if a datetime selector should be displayed |
|
2958 | - * |
|
2959 | - * @param array $datetimes |
|
2960 | - * @return bool |
|
2961 | - */ |
|
2962 | - public function showDatetimeSelector(array $datetimes) |
|
2963 | - { |
|
2964 | - // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2965 | - return ! ( |
|
2966 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
2967 | - || ( |
|
2968 | - $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
2969 | - && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
2970 | - ) |
|
2971 | - ); |
|
2972 | - } |
|
2973 | - |
|
2974 | - |
|
2975 | - /** |
|
2976 | - * @return string |
|
2977 | - */ |
|
2978 | - public function getShowDatetimeSelector() |
|
2979 | - { |
|
2980 | - return $this->show_datetime_selector; |
|
2981 | - } |
|
2956 | + /** |
|
2957 | + * returns true if a datetime selector should be displayed |
|
2958 | + * |
|
2959 | + * @param array $datetimes |
|
2960 | + * @return bool |
|
2961 | + */ |
|
2962 | + public function showDatetimeSelector(array $datetimes) |
|
2963 | + { |
|
2964 | + // if the settings are NOT: don't show OR below threshold, THEN active = true |
|
2965 | + return ! ( |
|
2966 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR |
|
2967 | + || ( |
|
2968 | + $this->getShowDatetimeSelector() === \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR |
|
2969 | + && count($datetimes) < $this->getDatetimeSelectorThreshold() |
|
2970 | + ) |
|
2971 | + ); |
|
2972 | + } |
|
2982 | 2973 | |
2983 | 2974 | |
2975 | + /** |
|
2976 | + * @return string |
|
2977 | + */ |
|
2978 | + public function getShowDatetimeSelector() |
|
2979 | + { |
|
2980 | + return $this->show_datetime_selector; |
|
2981 | + } |
|
2984 | 2982 | |
2985 | - /** |
|
2986 | - * @param bool $keys_only |
|
2987 | - * @return array |
|
2988 | - */ |
|
2989 | - public function getShowDatetimeSelectorOptions($keys_only = true) |
|
2990 | - { |
|
2991 | - return $keys_only |
|
2992 | - ? array( |
|
2993 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
2994 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
2995 | - ) |
|
2996 | - : array( |
|
2997 | - \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2998 | - 'Do not show date & time filter', 'event_espresso' |
|
2999 | - ), |
|
3000 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3001 | - 'Maybe show date & time filter', 'event_espresso' |
|
3002 | - ), |
|
3003 | - ); |
|
3004 | - } |
|
3005 | - |
|
3006 | - |
|
3007 | - |
|
3008 | - /** |
|
3009 | - * @param string $show_datetime_selector |
|
3010 | - */ |
|
3011 | - public function setShowDatetimeSelector($show_datetime_selector) |
|
3012 | - { |
|
3013 | - $this->show_datetime_selector = in_array( |
|
3014 | - $show_datetime_selector, |
|
3015 | - $this->getShowDatetimeSelectorOptions(), |
|
3016 | - true |
|
3017 | - ) |
|
3018 | - ? $show_datetime_selector |
|
3019 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3020 | - } |
|
3021 | 2983 | |
3022 | 2984 | |
2985 | + /** |
|
2986 | + * @param bool $keys_only |
|
2987 | + * @return array |
|
2988 | + */ |
|
2989 | + public function getShowDatetimeSelectorOptions($keys_only = true) |
|
2990 | + { |
|
2991 | + return $keys_only |
|
2992 | + ? array( |
|
2993 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
|
2994 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR, |
|
2995 | + ) |
|
2996 | + : array( |
|
2997 | + \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR => esc_html__( |
|
2998 | + 'Do not show date & time filter', 'event_espresso' |
|
2999 | + ), |
|
3000 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3001 | + 'Maybe show date & time filter', 'event_espresso' |
|
3002 | + ), |
|
3003 | + ); |
|
3004 | + } |
|
3023 | 3005 | |
3024 | - /** |
|
3025 | - * @return int |
|
3026 | - */ |
|
3027 | - public function getDatetimeSelectorThreshold() |
|
3028 | - { |
|
3029 | - return $this->datetime_selector_threshold; |
|
3030 | - } |
|
3031 | 3006 | |
3032 | 3007 | |
3008 | + /** |
|
3009 | + * @param string $show_datetime_selector |
|
3010 | + */ |
|
3011 | + public function setShowDatetimeSelector($show_datetime_selector) |
|
3012 | + { |
|
3013 | + $this->show_datetime_selector = in_array( |
|
3014 | + $show_datetime_selector, |
|
3015 | + $this->getShowDatetimeSelectorOptions(), |
|
3016 | + true |
|
3017 | + ) |
|
3018 | + ? $show_datetime_selector |
|
3019 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3020 | + } |
|
3033 | 3021 | |
3034 | - /** |
|
3035 | - * @param int $datetime_selector_threshold |
|
3036 | - */ |
|
3037 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3038 | - { |
|
3039 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3040 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3041 | - } |
|
3022 | + |
|
3023 | + |
|
3024 | + /** |
|
3025 | + * @return int |
|
3026 | + */ |
|
3027 | + public function getDatetimeSelectorThreshold() |
|
3028 | + { |
|
3029 | + return $this->datetime_selector_threshold; |
|
3030 | + } |
|
3031 | + |
|
3032 | + |
|
3033 | + |
|
3034 | + /** |
|
3035 | + * @param int $datetime_selector_threshold |
|
3036 | + */ |
|
3037 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3038 | + { |
|
3039 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3040 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3041 | + } |
|
3042 | 3042 | |
3043 | 3043 | |
3044 | 3044 | } |
@@ -3101,8 +3101,8 @@ discard block |
||
3101 | 3101 | */ |
3102 | 3102 | public function max_input_vars_limit_check( $input_count = 0 ) { |
3103 | 3103 | if ( ! empty( $this->php->max_input_vars ) |
3104 | - && ( $input_count >= $this->php->max_input_vars ) |
|
3105 | - && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 ) |
|
3104 | + && ( $input_count >= $this->php->max_input_vars ) |
|
3105 | + && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 ) |
|
3106 | 3106 | ) { |
3107 | 3107 | return sprintf( |
3108 | 3108 | __( |
@@ -3146,22 +3146,22 @@ discard block |
||
3146 | 3146 | class EE_Tax_Config extends EE_Config_Base |
3147 | 3147 | { |
3148 | 3148 | |
3149 | - /* |
|
3149 | + /* |
|
3150 | 3150 | * flag to indicate whether or not to display ticket prices with the taxes included |
3151 | 3151 | * |
3152 | 3152 | * @var boolean $prices_displayed_including_taxes |
3153 | 3153 | */ |
3154 | - public $prices_displayed_including_taxes; |
|
3154 | + public $prices_displayed_including_taxes; |
|
3155 | 3155 | |
3156 | 3156 | |
3157 | 3157 | |
3158 | - /** |
|
3159 | - * class constructor |
|
3160 | - */ |
|
3161 | - public function __construct() |
|
3162 | - { |
|
3163 | - $this->prices_displayed_including_taxes = true; |
|
3164 | - } |
|
3158 | + /** |
|
3159 | + * class constructor |
|
3160 | + */ |
|
3161 | + public function __construct() |
|
3162 | + { |
|
3163 | + $this->prices_displayed_including_taxes = true; |
|
3164 | + } |
|
3165 | 3165 | } |
3166 | 3166 | |
3167 | 3167 |
@@ -358,13 +358,13 @@ discard block |
||
358 | 358 | |
359 | 359 | |
360 | 360 | |
361 | - /** |
|
362 | - * get event start date. Provide either the date format, or NULL to re-use the |
|
363 | - * last-used format, or '' to use the default date format |
|
364 | - * |
|
365 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
366 | - * @return mixed string on success, FALSE on fail |
|
367 | - */ |
|
361 | + /** |
|
362 | + * get event start date. Provide either the date format, or NULL to re-use the |
|
363 | + * last-used format, or '' to use the default date format |
|
364 | + * |
|
365 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
366 | + * @return mixed string on success, FALSE on fail |
|
367 | + */ |
|
368 | 368 | public function start_date( $dt_frmt = '' ) { |
369 | 369 | return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
370 | 370 | } |
@@ -381,13 +381,13 @@ discard block |
||
381 | 381 | |
382 | 382 | |
383 | 383 | |
384 | - /** |
|
385 | - * get end date. Provide either the date format, or NULL to re-use the |
|
386 | - * last-used format, or '' to use the default date format |
|
387 | - * |
|
388 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
389 | - * @return mixed string on success, FALSE on fail |
|
390 | - */ |
|
384 | + /** |
|
385 | + * get end date. Provide either the date format, or NULL to re-use the |
|
386 | + * last-used format, or '' to use the default date format |
|
387 | + * |
|
388 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
389 | + * @return mixed string on success, FALSE on fail |
|
390 | + */ |
|
391 | 391 | public function end_date( $dt_frmt = '' ) { |
392 | 392 | return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
393 | 393 | } |
@@ -509,23 +509,23 @@ discard block |
||
509 | 509 | /** |
510 | 510 | * This returns a range representation of the date and times. |
511 | 511 | * Output is dependent on the difference (or similarity) between DTT_EVT_start and DTT_EVT_end. |
512 | - * Also, the return value is localized. |
|
513 | - * |
|
514 | - * @param string $dt_format |
|
512 | + * Also, the return value is localized. |
|
513 | + * |
|
514 | + * @param string $dt_format |
|
515 | 515 | * @param string $tm_format |
516 | 516 | * @param string $conjunction used between two different dates or times. |
517 | - * ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm |
|
518 | - * @param string $separator used between the date and time formats. |
|
519 | - * ex: Dec 1, 2016{$separator}2pm |
|
517 | + * ex: Dec 1{$conjunction}}Dec 6, or 2pm{$conjunction}3pm |
|
518 | + * @param string $separator used between the date and time formats. |
|
519 | + * ex: Dec 1, 2016{$separator}2pm |
|
520 | 520 | * @return string |
521 | 521 | * @throws \EE_Error |
522 | 522 | */ |
523 | 523 | public function date_and_time_range( |
524 | - $dt_format = '', |
|
525 | - $tm_format = '', |
|
526 | - $conjunction = ' - ' , |
|
527 | - $separator = ' ' |
|
528 | - ) { |
|
524 | + $dt_format = '', |
|
525 | + $tm_format = '', |
|
526 | + $conjunction = ' - ' , |
|
527 | + $separator = ' ' |
|
528 | + ) { |
|
529 | 529 | $dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt; |
530 | 530 | $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
531 | 531 | $full_format = $dt_format . $separator . $tm_format; |
@@ -539,14 +539,14 @@ discard block |
||
539 | 539 | //start and end date are the same but times are different |
540 | 540 | case ( $this->start_date() === $this->end_date() ) : |
541 | 541 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
542 | - . $conjunction |
|
543 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
542 | + . $conjunction |
|
543 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
544 | 544 | break; |
545 | 545 | //all other conditions |
546 | 546 | default : |
547 | 547 | $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
548 | - . $conjunction |
|
549 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
548 | + . $conjunction |
|
549 | + . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
550 | 550 | break; |
551 | 551 | } |
552 | 552 | return $output; |
@@ -630,13 +630,13 @@ discard block |
||
630 | 630 | |
631 | 631 | |
632 | 632 | /** |
633 | - * get end date and time |
|
634 | - * |
|
635 | - * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
636 | - * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
637 | - * @return mixed string on success, FALSE on fail |
|
638 | - */ |
|
639 | - public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
633 | + * get end date and time |
|
634 | + * |
|
635 | + * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
|
636 | + * @param string $tm_format - string representation of time format defaults to 'g:i a' |
|
637 | + * @return mixed string on success, FALSE on fail |
|
638 | + */ |
|
639 | + public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
640 | 640 | return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
641 | 641 | } |
642 | 642 |
@@ -1,5 +1,5 @@ discard block |
||
1 | -<?php if ( !defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
2 | - exit( 'No direct script access allowed' ); |
|
1 | +<?php if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /** |
5 | 5 | * Event Espresso |
@@ -74,9 +74,9 @@ discard block |
||
74 | 74 | * date_format and the second value is the time format |
75 | 75 | * @return EE_Datetime |
76 | 76 | */ |
77 | - public static function new_instance( $props_n_values = array(), $timezone = null, $date_formats = array() ) { |
|
78 | - $has_object = parent::_check_for_object( $props_n_values, __CLASS__, $timezone, $date_formats ); |
|
79 | - return $has_object ? $has_object : new self( $props_n_values, false, $timezone, $date_formats ); |
|
77 | + public static function new_instance($props_n_values = array(), $timezone = null, $date_formats = array()) { |
|
78 | + $has_object = parent::_check_for_object($props_n_values, __CLASS__, $timezone, $date_formats); |
|
79 | + return $has_object ? $has_object : new self($props_n_values, false, $timezone, $date_formats); |
|
80 | 80 | } |
81 | 81 | |
82 | 82 | |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * the website will be used. |
88 | 88 | * @return EE_Datetime |
89 | 89 | */ |
90 | - public static function new_instance_from_db( $props_n_values = array(), $timezone = null ) { |
|
91 | - return new self( $props_n_values, TRUE, $timezone ); |
|
90 | + public static function new_instance_from_db($props_n_values = array(), $timezone = null) { |
|
91 | + return new self($props_n_values, TRUE, $timezone); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | |
@@ -96,8 +96,8 @@ discard block |
||
96 | 96 | /** |
97 | 97 | * @param $name |
98 | 98 | */ |
99 | - public function set_name( $name ) { |
|
100 | - $this->set( 'DTT_name', $name ); |
|
99 | + public function set_name($name) { |
|
100 | + $this->set('DTT_name', $name); |
|
101 | 101 | } |
102 | 102 | |
103 | 103 | |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | /** |
106 | 106 | * @param $description |
107 | 107 | */ |
108 | - public function set_description( $description ) { |
|
109 | - $this->set( 'DTT_description', $description ); |
|
108 | + public function set_description($description) { |
|
109 | + $this->set('DTT_description', $description); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -118,8 +118,8 @@ discard block |
||
118 | 118 | * |
119 | 119 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
120 | 120 | */ |
121 | - public function set_start_date( $date ) { |
|
122 | - $this->_set_date_for( $date, 'DTT_EVT_start' ); |
|
121 | + public function set_start_date($date) { |
|
122 | + $this->_set_date_for($date, 'DTT_EVT_start'); |
|
123 | 123 | } |
124 | 124 | |
125 | 125 | |
@@ -131,8 +131,8 @@ discard block |
||
131 | 131 | * |
132 | 132 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
133 | 133 | */ |
134 | - public function set_start_time( $time ) { |
|
135 | - $this->_set_time_for( $time, 'DTT_EVT_start' ); |
|
134 | + public function set_start_time($time) { |
|
135 | + $this->_set_time_for($time, 'DTT_EVT_start'); |
|
136 | 136 | } |
137 | 137 | |
138 | 138 | |
@@ -144,8 +144,8 @@ discard block |
||
144 | 144 | * |
145 | 145 | * @param string $date a string representation of the event's date ex: Dec. 25, 2025 or 12-25-2025 |
146 | 146 | */ |
147 | - public function set_end_date( $date ) { |
|
148 | - $this->_set_date_for( $date, 'DTT_EVT_end' ); |
|
147 | + public function set_end_date($date) { |
|
148 | + $this->_set_date_for($date, 'DTT_EVT_end'); |
|
149 | 149 | } |
150 | 150 | |
151 | 151 | |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * |
158 | 158 | * @param string $time a string representation of the event time ex: 9am or 7:30 PM |
159 | 159 | */ |
160 | - public function set_end_time( $time ) { |
|
161 | - $this->_set_time_for( $time, 'DTT_EVT_end' ); |
|
160 | + public function set_end_time($time) { |
|
161 | + $this->_set_time_for($time, 'DTT_EVT_end'); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | |
@@ -170,8 +170,8 @@ discard block |
||
170 | 170 | * |
171 | 171 | * @param int $reg_limit |
172 | 172 | */ |
173 | - public function set_reg_limit( $reg_limit ) { |
|
174 | - $this->set( 'DTT_reg_limit', $reg_limit ); |
|
173 | + public function set_reg_limit($reg_limit) { |
|
174 | + $this->set('DTT_reg_limit', $reg_limit); |
|
175 | 175 | } |
176 | 176 | |
177 | 177 | |
@@ -183,7 +183,7 @@ discard block |
||
183 | 183 | * @return mixed int on success, FALSE on fail |
184 | 184 | */ |
185 | 185 | public function sold() { |
186 | - return $this->get_raw( 'DTT_sold' ); |
|
186 | + return $this->get_raw('DTT_sold'); |
|
187 | 187 | } |
188 | 188 | |
189 | 189 | |
@@ -193,10 +193,10 @@ discard block |
||
193 | 193 | * |
194 | 194 | * @param int $sold |
195 | 195 | */ |
196 | - public function set_sold( $sold ) { |
|
196 | + public function set_sold($sold) { |
|
197 | 197 | // sold can not go below zero |
198 | - $sold = max( 0, $sold ); |
|
199 | - $this->set( 'DTT_sold', $sold ); |
|
198 | + $sold = max(0, $sold); |
|
199 | + $this->set('DTT_sold', $sold); |
|
200 | 200 | } |
201 | 201 | |
202 | 202 | |
@@ -205,11 +205,11 @@ discard block |
||
205 | 205 | * increments sold by amount passed by $qty |
206 | 206 | * @param int $qty |
207 | 207 | */ |
208 | - public function increase_sold( $qty = 1 ) { |
|
208 | + public function increase_sold($qty = 1) { |
|
209 | 209 | $sold = $this->sold() + $qty; |
210 | 210 | // remove ticket reservation |
211 | - $this->decrease_reserved( $qty ); |
|
212 | - $this->set_sold( $sold ); |
|
211 | + $this->decrease_reserved($qty); |
|
212 | + $this->set_sold($sold); |
|
213 | 213 | } |
214 | 214 | |
215 | 215 | |
@@ -218,9 +218,9 @@ discard block |
||
218 | 218 | * decrements (subtracts) sold amount passed by $qty |
219 | 219 | * @param int $qty |
220 | 220 | */ |
221 | - public function decrease_sold( $qty = 1 ) { |
|
221 | + public function decrease_sold($qty = 1) { |
|
222 | 222 | $sold = $this->sold() - $qty; |
223 | - $this->set_sold( $sold ); |
|
223 | + $this->set_sold($sold); |
|
224 | 224 | } |
225 | 225 | |
226 | 226 | |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | * @return int |
232 | 232 | */ |
233 | 233 | public function reserved() { |
234 | - return $this->get_raw( 'DTT_reserved' ); |
|
234 | + return $this->get_raw('DTT_reserved'); |
|
235 | 235 | } |
236 | 236 | |
237 | 237 | |
@@ -241,10 +241,10 @@ discard block |
||
241 | 241 | * |
242 | 242 | * @param int $reserved |
243 | 243 | */ |
244 | - public function set_reserved( $reserved ) { |
|
244 | + public function set_reserved($reserved) { |
|
245 | 245 | // reserved can not go below zero |
246 | - $reserved = max( 0, (int) $reserved ); |
|
247 | - $this->set( 'DTT_reserved', $reserved ); |
|
246 | + $reserved = max(0, (int) $reserved); |
|
247 | + $this->set('DTT_reserved', $reserved); |
|
248 | 248 | } |
249 | 249 | |
250 | 250 | |
@@ -255,9 +255,9 @@ discard block |
||
255 | 255 | * @param int $qty |
256 | 256 | * @return boolean |
257 | 257 | */ |
258 | - public function increase_reserved( $qty = 1 ) { |
|
259 | - $reserved = $this->reserved() + absint( $qty ); |
|
260 | - return $this->set_reserved( $reserved ); |
|
258 | + public function increase_reserved($qty = 1) { |
|
259 | + $reserved = $this->reserved() + absint($qty); |
|
260 | + return $this->set_reserved($reserved); |
|
261 | 261 | } |
262 | 262 | |
263 | 263 | |
@@ -268,9 +268,9 @@ discard block |
||
268 | 268 | * @param int $qty |
269 | 269 | * @return boolean |
270 | 270 | */ |
271 | - public function decrease_reserved( $qty = 1 ) { |
|
272 | - $reserved = $this->reserved() - absint( $qty ); |
|
273 | - return $this->set_reserved( $reserved ); |
|
271 | + public function decrease_reserved($qty = 1) { |
|
272 | + $reserved = $this->reserved() - absint($qty); |
|
273 | + return $this->set_reserved($reserved); |
|
274 | 274 | } |
275 | 275 | |
276 | 276 | |
@@ -291,7 +291,7 @@ discard block |
||
291 | 291 | * @return string |
292 | 292 | */ |
293 | 293 | public function name() { |
294 | - return $this->get( 'DTT_name' ); |
|
294 | + return $this->get('DTT_name'); |
|
295 | 295 | } |
296 | 296 | |
297 | 297 | |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | * @return string |
302 | 302 | */ |
303 | 303 | public function description() { |
304 | - return $this->get( 'DTT_description' ); |
|
304 | + return $this->get('DTT_description'); |
|
305 | 305 | } |
306 | 306 | |
307 | 307 | |
@@ -311,7 +311,7 @@ discard block |
||
311 | 311 | * @return boolean TRUE if is primary, FALSE if not. |
312 | 312 | */ |
313 | 313 | public function is_primary() { |
314 | - return $this->get( 'DTT_is_primary' ); |
|
314 | + return $this->get('DTT_is_primary'); |
|
315 | 315 | } |
316 | 316 | |
317 | 317 | |
@@ -321,7 +321,7 @@ discard block |
||
321 | 321 | * @return int The order of the datetime for this event. |
322 | 322 | */ |
323 | 323 | public function order() { |
324 | - return $this->get( 'DTT_order' ); |
|
324 | + return $this->get('DTT_order'); |
|
325 | 325 | } |
326 | 326 | |
327 | 327 | |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | * @return int |
332 | 332 | */ |
333 | 333 | public function parent() { |
334 | - return $this->get( 'DTT_parent' ); |
|
334 | + return $this->get('DTT_parent'); |
|
335 | 335 | } |
336 | 336 | |
337 | 337 | |
@@ -347,10 +347,10 @@ discard block |
||
347 | 347 | * @param bool $echo - whether we echo or return (note echoing uses "pretty" formats, otherwise we use the standard formats) |
348 | 348 | * @return string|bool string on success, FALSE on fail |
349 | 349 | */ |
350 | - private function _show_datetime( $date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE ) { |
|
350 | + private function _show_datetime($date_or_time = NULL, $start_or_end = 'start', $dt_frmt = '', $tm_frmt = '', $echo = FALSE) { |
|
351 | 351 | $field_name = "DTT_EVT_{$start_or_end}"; |
352 | - $dtt = $this->_get_datetime( $field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo ); |
|
353 | - if ( ! $echo ) { |
|
352 | + $dtt = $this->_get_datetime($field_name, $dt_frmt, $tm_frmt, $date_or_time, $echo); |
|
353 | + if ( ! $echo) { |
|
354 | 354 | return $dtt; |
355 | 355 | } |
356 | 356 | return ''; |
@@ -365,8 +365,8 @@ discard block |
||
365 | 365 | * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
366 | 366 | * @return mixed string on success, FALSE on fail |
367 | 367 | */ |
368 | - public function start_date( $dt_frmt = '' ) { |
|
369 | - return $this->_show_datetime( 'D', 'start', $dt_frmt ); |
|
368 | + public function start_date($dt_frmt = '') { |
|
369 | + return $this->_show_datetime('D', 'start', $dt_frmt); |
|
370 | 370 | } |
371 | 371 | |
372 | 372 | |
@@ -375,8 +375,8 @@ discard block |
||
375 | 375 | * Echoes start_date() |
376 | 376 | * @param string $dt_frmt |
377 | 377 | */ |
378 | - public function e_start_date( $dt_frmt = '' ) { |
|
379 | - $this->_show_datetime( 'D', 'start', $dt_frmt, NULL, TRUE ); |
|
378 | + public function e_start_date($dt_frmt = '') { |
|
379 | + $this->_show_datetime('D', 'start', $dt_frmt, NULL, TRUE); |
|
380 | 380 | } |
381 | 381 | |
382 | 382 | |
@@ -388,8 +388,8 @@ discard block |
||
388 | 388 | * @param string $dt_frmt - string representation of date format defaults to 'F j, Y' |
389 | 389 | * @return mixed string on success, FALSE on fail |
390 | 390 | */ |
391 | - public function end_date( $dt_frmt = '' ) { |
|
392 | - return $this->_show_datetime( 'D', 'end', $dt_frmt ); |
|
391 | + public function end_date($dt_frmt = '') { |
|
392 | + return $this->_show_datetime('D', 'end', $dt_frmt); |
|
393 | 393 | } |
394 | 394 | |
395 | 395 | |
@@ -398,8 +398,8 @@ discard block |
||
398 | 398 | * Echoes the end date. See end_date() |
399 | 399 | * @param string $dt_frmt |
400 | 400 | */ |
401 | - public function e_end_date( $dt_frmt = '' ) { |
|
402 | - $this->_show_datetime( 'D', 'end', $dt_frmt, NULL, TRUE ); |
|
401 | + public function e_end_date($dt_frmt = '') { |
|
402 | + $this->_show_datetime('D', 'end', $dt_frmt, NULL, TRUE); |
|
403 | 403 | } |
404 | 404 | |
405 | 405 | |
@@ -414,11 +414,11 @@ discard block |
||
414 | 414 | * @return mixed string on success, FALSE on fail |
415 | 415 | * @throws \EE_Error |
416 | 416 | */ |
417 | - public function date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
418 | - $dt_frmt = ! empty( $dt_frmt ) ? $dt_frmt : $this->_dt_frmt; |
|
419 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $dt_frmt ) ); |
|
420 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $dt_frmt ) ); |
|
421 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
417 | + public function date_range($dt_frmt = '', $conjunction = ' - ') { |
|
418 | + $dt_frmt = ! empty($dt_frmt) ? $dt_frmt : $this->_dt_frmt; |
|
419 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $dt_frmt)); |
|
420 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $dt_frmt)); |
|
421 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
422 | 422 | } |
423 | 423 | |
424 | 424 | |
@@ -428,8 +428,8 @@ discard block |
||
428 | 428 | * @param string $conjunction |
429 | 429 | * @throws \EE_Error |
430 | 430 | */ |
431 | - public function e_date_range( $dt_frmt = '', $conjunction = ' - ' ) { |
|
432 | - echo $this->date_range( $dt_frmt, $conjunction ); |
|
431 | + public function e_date_range($dt_frmt = '', $conjunction = ' - ') { |
|
432 | + echo $this->date_range($dt_frmt, $conjunction); |
|
433 | 433 | } |
434 | 434 | |
435 | 435 | |
@@ -440,8 +440,8 @@ discard block |
||
440 | 440 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
441 | 441 | * @return mixed string on success, FALSE on fail |
442 | 442 | */ |
443 | - public function start_time( $tm_format = '' ) { |
|
444 | - return $this->_show_datetime( 'T', 'start', NULL, $tm_format ); |
|
443 | + public function start_time($tm_format = '') { |
|
444 | + return $this->_show_datetime('T', 'start', NULL, $tm_format); |
|
445 | 445 | } |
446 | 446 | |
447 | 447 | |
@@ -449,8 +449,8 @@ discard block |
||
449 | 449 | /** |
450 | 450 | * @param string $tm_format |
451 | 451 | */ |
452 | - public function e_start_time( $tm_format = '' ) { |
|
453 | - $this->_show_datetime( 'T', 'start', NULL, $tm_format, TRUE ); |
|
452 | + public function e_start_time($tm_format = '') { |
|
453 | + $this->_show_datetime('T', 'start', NULL, $tm_format, TRUE); |
|
454 | 454 | } |
455 | 455 | |
456 | 456 | |
@@ -461,8 +461,8 @@ discard block |
||
461 | 461 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
462 | 462 | * @return mixed string on success, FALSE on fail |
463 | 463 | */ |
464 | - public function end_time( $tm_format = '' ) { |
|
465 | - return $this->_show_datetime( 'T', 'end', NULL, $tm_format ); |
|
464 | + public function end_time($tm_format = '') { |
|
465 | + return $this->_show_datetime('T', 'end', NULL, $tm_format); |
|
466 | 466 | } |
467 | 467 | |
468 | 468 | |
@@ -470,8 +470,8 @@ discard block |
||
470 | 470 | /** |
471 | 471 | * @param string $tm_format |
472 | 472 | */ |
473 | - public function e_end_time( $tm_format = '' ) { |
|
474 | - $this->_show_datetime( 'T', 'end', NULL, $tm_format, TRUE ); |
|
473 | + public function e_end_time($tm_format = '') { |
|
474 | + $this->_show_datetime('T', 'end', NULL, $tm_format, TRUE); |
|
475 | 475 | } |
476 | 476 | |
477 | 477 | |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | * @return mixed string on success, FALSE on fail |
487 | 487 | * @throws \EE_Error |
488 | 488 | */ |
489 | - public function time_range( $tm_format = '', $conjunction = ' - ' ) { |
|
490 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
491 | - $start = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_start', $tm_format ) ); |
|
492 | - $end = str_replace( ' ', ' ', $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ) ); |
|
493 | - return $start !== $end ? $start . $conjunction . $end : $start; |
|
489 | + public function time_range($tm_format = '', $conjunction = ' - ') { |
|
490 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
491 | + $start = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_start', $tm_format)); |
|
492 | + $end = str_replace(' ', ' ', $this->get_i18n_datetime('DTT_EVT_end', $tm_format)); |
|
493 | + return $start !== $end ? $start.$conjunction.$end : $start; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -500,8 +500,8 @@ discard block |
||
500 | 500 | * @param string $conjunction |
501 | 501 | * @throws \EE_Error |
502 | 502 | */ |
503 | - public function e_time_range( $tm_format = '', $conjunction = ' - ' ) { |
|
504 | - echo $this->time_range( $tm_format, $conjunction ); |
|
503 | + public function e_time_range($tm_format = '', $conjunction = ' - ') { |
|
504 | + echo $this->time_range($tm_format, $conjunction); |
|
505 | 505 | } |
506 | 506 | |
507 | 507 | |
@@ -523,30 +523,30 @@ discard block |
||
523 | 523 | public function date_and_time_range( |
524 | 524 | $dt_format = '', |
525 | 525 | $tm_format = '', |
526 | - $conjunction = ' - ' , |
|
526 | + $conjunction = ' - ', |
|
527 | 527 | $separator = ' ' |
528 | 528 | ) { |
529 | - $dt_format = ! empty( $dt_format ) ? $dt_format : $this->_dt_frmt; |
|
530 | - $tm_format = ! empty( $tm_format ) ? $tm_format : $this->_tm_frmt; |
|
531 | - $full_format = $dt_format . $separator . $tm_format; |
|
529 | + $dt_format = ! empty($dt_format) ? $dt_format : $this->_dt_frmt; |
|
530 | + $tm_format = ! empty($tm_format) ? $tm_format : $this->_tm_frmt; |
|
531 | + $full_format = $dt_format.$separator.$tm_format; |
|
532 | 532 | |
533 | 533 | //the range output depends on various conditions |
534 | - switch ( true ) { |
|
534 | + switch (true) { |
|
535 | 535 | //start date timestamp and end date timestamp are the same. |
536 | - case ( $this->get_raw( 'DTT_EVT_start' ) === $this->get_raw( 'DTT_EVT_end' ) ) : |
|
537 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ); |
|
536 | + case ($this->get_raw('DTT_EVT_start') === $this->get_raw('DTT_EVT_end')) : |
|
537 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format); |
|
538 | 538 | break; |
539 | 539 | //start and end date are the same but times are different |
540 | - case ( $this->start_date() === $this->end_date() ) : |
|
541 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
540 | + case ($this->start_date() === $this->end_date()) : |
|
541 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
542 | 542 | . $conjunction |
543 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $tm_format ); |
|
543 | + . $this->get_i18n_datetime('DTT_EVT_end', $tm_format); |
|
544 | 544 | break; |
545 | 545 | //all other conditions |
546 | 546 | default : |
547 | - $output = $this->get_i18n_datetime( 'DTT_EVT_start', $full_format ) |
|
547 | + $output = $this->get_i18n_datetime('DTT_EVT_start', $full_format) |
|
548 | 548 | . $conjunction |
549 | - . $this->get_i18n_datetime( 'DTT_EVT_end', $full_format ); |
|
549 | + . $this->get_i18n_datetime('DTT_EVT_end', $full_format); |
|
550 | 550 | break; |
551 | 551 | } |
552 | 552 | return $output; |
@@ -564,8 +564,8 @@ discard block |
||
564 | 564 | * @return void |
565 | 565 | * @throws \EE_Error |
566 | 566 | */ |
567 | - public function e_date_and_time_range( $dt_format = '', $tm_format = '', $conjunction = ' - ' ) { |
|
568 | - echo $this->date_and_time_range( $dt_format, $tm_format, $conjunction ); |
|
567 | + public function e_date_and_time_range($dt_format = '', $tm_format = '', $conjunction = ' - ') { |
|
568 | + echo $this->date_and_time_range($dt_format, $tm_format, $conjunction); |
|
569 | 569 | } |
570 | 570 | |
571 | 571 | |
@@ -577,8 +577,8 @@ discard block |
||
577 | 577 | * @param string $tm_format - string representation of time format defaults to 'g:i a' |
578 | 578 | * @return mixed string on success, FALSE on fail |
579 | 579 | */ |
580 | - public function start_date_and_time( $dt_format = '', $tm_format = '' ) { |
|
581 | - return $this->_show_datetime( '', 'start', $dt_format, $tm_format ); |
|
580 | + public function start_date_and_time($dt_format = '', $tm_format = '') { |
|
581 | + return $this->_show_datetime('', 'start', $dt_format, $tm_format); |
|
582 | 582 | } |
583 | 583 | |
584 | 584 | |
@@ -587,8 +587,8 @@ discard block |
||
587 | 587 | * @param string $dt_frmt |
588 | 588 | * @param string $tm_format |
589 | 589 | */ |
590 | - public function e_start_date_and_time( $dt_frmt = '', $tm_format = '' ) { |
|
591 | - $this->_show_datetime( '', 'start', $dt_frmt, $tm_format, TRUE ); |
|
590 | + public function e_start_date_and_time($dt_frmt = '', $tm_format = '') { |
|
591 | + $this->_show_datetime('', 'start', $dt_frmt, $tm_format, TRUE); |
|
592 | 592 | } |
593 | 593 | |
594 | 594 | |
@@ -602,11 +602,11 @@ discard block |
||
602 | 602 | * @param bool $round_up |
603 | 603 | * @return float|int|mixed |
604 | 604 | */ |
605 | - public function length( $units = 'seconds', $round_up = FALSE ) { |
|
606 | - $start = $this->get_raw( 'DTT_EVT_start' ); |
|
607 | - $end = $this->get_raw( 'DTT_EVT_end' ); |
|
605 | + public function length($units = 'seconds', $round_up = FALSE) { |
|
606 | + $start = $this->get_raw('DTT_EVT_start'); |
|
607 | + $end = $this->get_raw('DTT_EVT_end'); |
|
608 | 608 | $length_in_units = $end - $start; |
609 | - switch ( $units ) { |
|
609 | + switch ($units) { |
|
610 | 610 | //NOTE: We purposefully don't use "break;" in order to chain the divisions |
611 | 611 | /** @noinspection PhpMissingBreakStatementInspection */ |
612 | 612 | case 'days': |
@@ -619,10 +619,10 @@ discard block |
||
619 | 619 | $length_in_units /= 60; |
620 | 620 | case 'seconds': |
621 | 621 | default: |
622 | - $length_in_units = ceil( $length_in_units ); |
|
622 | + $length_in_units = ceil($length_in_units); |
|
623 | 623 | } |
624 | - if ( $round_up ) { |
|
625 | - $length_in_units = max( $length_in_units, 1 ); |
|
624 | + if ($round_up) { |
|
625 | + $length_in_units = max($length_in_units, 1); |
|
626 | 626 | } |
627 | 627 | return $length_in_units; |
628 | 628 | } |
@@ -637,7 +637,7 @@ discard block |
||
637 | 637 | * @return mixed string on success, FALSE on fail |
638 | 638 | */ |
639 | 639 | public function end_date_and_time($dt_frmt = '', $tm_format = '') { |
640 | - return $this->_show_datetime( '', 'end', $dt_frmt, $tm_format ); |
|
640 | + return $this->_show_datetime('', 'end', $dt_frmt, $tm_format); |
|
641 | 641 | } |
642 | 642 | |
643 | 643 | |
@@ -646,8 +646,8 @@ discard block |
||
646 | 646 | * @param string $dt_frmt |
647 | 647 | * @param string $tm_format |
648 | 648 | */ |
649 | - public function e_end_date_and_time( $dt_frmt = '', $tm_format = '' ) { |
|
650 | - $this->_show_datetime( '', 'end', $dt_frmt, $tm_format, TRUE ); |
|
649 | + public function e_end_date_and_time($dt_frmt = '', $tm_format = '') { |
|
650 | + $this->_show_datetime('', 'end', $dt_frmt, $tm_format, TRUE); |
|
651 | 651 | } |
652 | 652 | |
653 | 653 | |
@@ -658,7 +658,7 @@ discard block |
||
658 | 658 | * @return int |
659 | 659 | */ |
660 | 660 | public function start() { |
661 | - return $this->get_raw( 'DTT_EVT_start' ); |
|
661 | + return $this->get_raw('DTT_EVT_start'); |
|
662 | 662 | } |
663 | 663 | |
664 | 664 | |
@@ -669,7 +669,7 @@ discard block |
||
669 | 669 | * @return int |
670 | 670 | */ |
671 | 671 | public function end() { |
672 | - return $this->get_raw( 'DTT_EVT_end' ); |
|
672 | + return $this->get_raw('DTT_EVT_end'); |
|
673 | 673 | } |
674 | 674 | |
675 | 675 | |
@@ -680,7 +680,7 @@ discard block |
||
680 | 680 | * @return mixed int on success, FALSE on fail |
681 | 681 | */ |
682 | 682 | public function reg_limit() { |
683 | - return $this->get_raw( 'DTT_reg_limit' ); |
|
683 | + return $this->get_raw('DTT_reg_limit'); |
|
684 | 684 | } |
685 | 685 | |
686 | 686 | |
@@ -708,15 +708,15 @@ discard block |
||
708 | 708 | * the spaces remaining for this particular datetime, hence the flag. |
709 | 709 | * @return int |
710 | 710 | */ |
711 | - public function spaces_remaining( $consider_tickets = FALSE ) { |
|
711 | + public function spaces_remaining($consider_tickets = FALSE) { |
|
712 | 712 | // tickets remaining available for purchase |
713 | 713 | //no need for special checks for infinite, because if DTT_reg_limit == EE_INF, then EE_INF - x = EE_INF |
714 | 714 | $dtt_remaining = $this->reg_limit() - $this->sold_and_reserved(); |
715 | - if ( ! $consider_tickets ) { |
|
715 | + if ( ! $consider_tickets) { |
|
716 | 716 | return $dtt_remaining; |
717 | 717 | } |
718 | 718 | $tickets_remaining = $this->tickets_remaining(); |
719 | - return min( $dtt_remaining, $tickets_remaining ); |
|
719 | + return min($dtt_remaining, $tickets_remaining); |
|
720 | 720 | } |
721 | 721 | |
722 | 722 | |
@@ -727,19 +727,19 @@ discard block |
||
727 | 727 | * @param array $query_params like EEM_Base::get_all's |
728 | 728 | * @return int |
729 | 729 | */ |
730 | - public function tickets_remaining( $query_params = array() ) { |
|
730 | + public function tickets_remaining($query_params = array()) { |
|
731 | 731 | $sum = 0; |
732 | - $tickets = $this->tickets( $query_params ); |
|
733 | - if ( ! empty( $tickets ) ) { |
|
734 | - foreach ( $tickets as $ticket ) { |
|
735 | - if ( $ticket instanceof EE_Ticket ) { |
|
732 | + $tickets = $this->tickets($query_params); |
|
733 | + if ( ! empty($tickets)) { |
|
734 | + foreach ($tickets as $ticket) { |
|
735 | + if ($ticket instanceof EE_Ticket) { |
|
736 | 736 | // get the actual amount of tickets that can be sold |
737 | - $qty = $ticket->qty( 'saleable' ); |
|
738 | - if ( $qty === EE_INF ) { |
|
737 | + $qty = $ticket->qty('saleable'); |
|
738 | + if ($qty === EE_INF) { |
|
739 | 739 | return EE_INF; |
740 | 740 | } |
741 | 741 | // no negative ticket quantities plz |
742 | - if ( $qty > 0 ) { |
|
742 | + if ($qty > 0) { |
|
743 | 743 | $sum += $qty; |
744 | 744 | } |
745 | 745 | } |
@@ -756,8 +756,8 @@ discard block |
||
756 | 756 | * @param array $query_params like EEM_Base::get_all's |
757 | 757 | * @return int |
758 | 758 | */ |
759 | - public function sum_tickets_initially_available( $query_params = array() ) { |
|
760 | - return $this->sum_related( 'Ticket', $query_params, 'TKT_qty' ); |
|
759 | + public function sum_tickets_initially_available($query_params = array()) { |
|
760 | + return $this->sum_related('Ticket', $query_params, 'TKT_qty'); |
|
761 | 761 | } |
762 | 762 | |
763 | 763 | |
@@ -769,7 +769,7 @@ discard block |
||
769 | 769 | * @return int |
770 | 770 | */ |
771 | 771 | public function total_tickets_available_at_this_datetime() { |
772 | - return $this->spaces_remaining( true ); |
|
772 | + return $this->spaces_remaining(true); |
|
773 | 773 | } |
774 | 774 | |
775 | 775 | |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * @return boolean |
781 | 781 | */ |
782 | 782 | public function is_upcoming() { |
783 | - return ( $this->get_raw( 'DTT_EVT_start' ) > time() ); |
|
783 | + return ($this->get_raw('DTT_EVT_start') > time()); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -790,7 +790,7 @@ discard block |
||
790 | 790 | * @return boolean |
791 | 791 | */ |
792 | 792 | public function is_active() { |
793 | - return ( $this->get_raw( 'DTT_EVT_start' ) < time() && $this->get_raw( 'DTT_EVT_end' ) > time() ); |
|
793 | + return ($this->get_raw('DTT_EVT_start') < time() && $this->get_raw('DTT_EVT_end') > time()); |
|
794 | 794 | } |
795 | 795 | |
796 | 796 | |
@@ -800,7 +800,7 @@ discard block |
||
800 | 800 | * @return boolean |
801 | 801 | */ |
802 | 802 | public function is_expired() { |
803 | - return ( $this->get_raw( 'DTT_EVT_end' ) < time() ); |
|
803 | + return ($this->get_raw('DTT_EVT_end') < time()); |
|
804 | 804 | } |
805 | 805 | |
806 | 806 | |
@@ -811,16 +811,16 @@ discard block |
||
811 | 811 | */ |
812 | 812 | public function get_active_status() { |
813 | 813 | $total_tickets_for_this_dtt = $this->total_tickets_available_at_this_datetime(); |
814 | - if ( $total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1 ) { |
|
814 | + if ($total_tickets_for_this_dtt !== FALSE && $total_tickets_for_this_dtt < 1) { |
|
815 | 815 | return EE_Datetime::sold_out; |
816 | 816 | } |
817 | - if ( $this->is_expired() ) { |
|
817 | + if ($this->is_expired()) { |
|
818 | 818 | return EE_Datetime::expired; |
819 | 819 | } |
820 | - if ( $this->is_upcoming() ) { |
|
820 | + if ($this->is_upcoming()) { |
|
821 | 821 | return EE_Datetime::upcoming; |
822 | 822 | } |
823 | - if ( $this->is_active() ) { |
|
823 | + if ($this->is_active()) { |
|
824 | 824 | return EE_Datetime::active; |
825 | 825 | } |
826 | 826 | return NULL; |
@@ -834,24 +834,24 @@ discard block |
||
834 | 834 | * @param boolean $use_dtt_name if TRUE then we'll use DTT->name() if its not empty. |
835 | 835 | * @return string |
836 | 836 | */ |
837 | - public function get_dtt_display_name( $use_dtt_name = FALSE ) { |
|
838 | - if ( $use_dtt_name ) { |
|
837 | + public function get_dtt_display_name($use_dtt_name = FALSE) { |
|
838 | + if ($use_dtt_name) { |
|
839 | 839 | $dtt_name = $this->name(); |
840 | - if ( !empty( $dtt_name ) ) { |
|
840 | + if ( ! empty($dtt_name)) { |
|
841 | 841 | return $dtt_name; |
842 | 842 | } |
843 | 843 | } |
844 | 844 | //first condition is to see if the months are different |
845 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
846 | - $display_date = $this->start_date( 'M j\, Y g:i a' ) . ' - ' . $this->end_date( 'M j\, Y g:i a' ); |
|
845 | + if (date('m', $this->get_raw('DTT_EVT_start')) != date('m', $this->get_raw('DTT_EVT_end'))) { |
|
846 | + $display_date = $this->start_date('M j\, Y g:i a').' - '.$this->end_date('M j\, Y g:i a'); |
|
847 | 847 | //next condition is if its the same month but different day |
848 | 848 | } |
849 | 849 | else { |
850 | - if ( date( 'm', $this->get_raw( 'DTT_EVT_start' ) ) == date( 'm', $this->get_raw( 'DTT_EVT_end' ) ) && date( 'd', $this->get_raw( 'DTT_EVT_start' ) ) != date( 'd', $this->get_raw( 'DTT_EVT_end' ) ) ) { |
|
851 | - $display_date = $this->start_date( 'M j\, g:i a' ) . ' - ' . $this->end_date( 'M j\, g:i a Y' ); |
|
850 | + if (date('m', $this->get_raw('DTT_EVT_start')) == date('m', $this->get_raw('DTT_EVT_end')) && date('d', $this->get_raw('DTT_EVT_start')) != date('d', $this->get_raw('DTT_EVT_end'))) { |
|
851 | + $display_date = $this->start_date('M j\, g:i a').' - '.$this->end_date('M j\, g:i a Y'); |
|
852 | 852 | } |
853 | 853 | else { |
854 | - $display_date = $this->start_date( 'F j\, Y' ) . ' @ ' . $this->start_date( 'g:i a' ) . ' - ' . $this->end_date( 'g:i a' ); |
|
854 | + $display_date = $this->start_date('F j\, Y').' @ '.$this->start_date('g:i a').' - '.$this->end_date('g:i a'); |
|
855 | 855 | } |
856 | 856 | } |
857 | 857 | return $display_date; |
@@ -865,8 +865,8 @@ discard block |
||
865 | 865 | *@param array $query_params see EEM_Base::get_all() |
866 | 866 | * @return EE_Ticket[] |
867 | 867 | */ |
868 | - public function tickets( $query_params = array() ) { |
|
869 | - return $this->get_many_related( 'Ticket', $query_params ); |
|
868 | + public function tickets($query_params = array()) { |
|
869 | + return $this->get_many_related('Ticket', $query_params); |
|
870 | 870 | } |
871 | 871 | |
872 | 872 | |
@@ -876,21 +876,21 @@ discard block |
||
876 | 876 | * @param array $query_params like EEM_Base::get_all's |
877 | 877 | * @return EE_Ticket[] |
878 | 878 | */ |
879 | - public function ticket_types_available_for_purchase( $query_params = array() ) { |
|
879 | + public function ticket_types_available_for_purchase($query_params = array()) { |
|
880 | 880 | // first check if datetime is valid |
881 | - if ( ! ( $this->is_upcoming() || $this->is_active() ) || $this->sold_out() ) { |
|
881 | + if ( ! ($this->is_upcoming() || $this->is_active()) || $this->sold_out()) { |
|
882 | 882 | return array(); |
883 | 883 | } |
884 | - if ( empty( $query_params ) ) { |
|
884 | + if (empty($query_params)) { |
|
885 | 885 | $query_params = array( |
886 | 886 | array( |
887 | - 'TKT_start_date' => array( '<=', EEM_Ticket::instance()->current_time_for_query( 'TKT_start_date' ) ), |
|
888 | - 'TKT_end_date' => array( '>=', EEM_Ticket::instance()->current_time_for_query( 'TKT_end_date' ) ), |
|
887 | + 'TKT_start_date' => array('<=', EEM_Ticket::instance()->current_time_for_query('TKT_start_date')), |
|
888 | + 'TKT_end_date' => array('>=', EEM_Ticket::instance()->current_time_for_query('TKT_end_date')), |
|
889 | 889 | 'TKT_deleted' => false |
890 | 890 | ) |
891 | 891 | ); |
892 | 892 | } |
893 | - return $this->tickets( $query_params ); |
|
893 | + return $this->tickets($query_params); |
|
894 | 894 | } |
895 | 895 | |
896 | 896 | |
@@ -900,7 +900,7 @@ discard block |
||
900 | 900 | * @return EE_Event |
901 | 901 | */ |
902 | 902 | public function event() { |
903 | - return $this->get_first_related( 'Event' ); |
|
903 | + return $this->get_first_related('Event'); |
|
904 | 904 | } |
905 | 905 | |
906 | 906 | |
@@ -912,13 +912,13 @@ discard block |
||
912 | 912 | */ |
913 | 913 | public function update_sold() { |
914 | 914 | $count_regs_for_this_datetime = EEM_Registration::instance()->count( |
915 | - array( array( |
|
915 | + array(array( |
|
916 | 916 | 'STS_ID' => EEM_Registration::status_id_approved, |
917 | 917 | 'REG_deleted' => 0, |
918 | 918 | 'Ticket.Datetime.DTT_ID' => $this->ID(), |
919 | - ) ) |
|
919 | + )) |
|
920 | 920 | ); |
921 | - $this->set( 'DTT_sold', $count_regs_for_this_datetime ); |
|
921 | + $this->set('DTT_sold', $count_regs_for_this_datetime); |
|
922 | 922 | $this->save(); |
923 | 923 | return $count_regs_for_this_datetime; |
924 | 924 | } |
@@ -1,6 +1,6 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
3 | - exit('NO direct script access allowed'); |
|
3 | + exit('NO direct script access allowed'); |
|
4 | 4 | } |
5 | 5 | |
6 | 6 | |
@@ -17,2573 +17,2573 @@ discard block |
||
17 | 17 | class Events_Admin_Page extends EE_Admin_Page_CPT |
18 | 18 | { |
19 | 19 | |
20 | - /** |
|
21 | - * This will hold the event object for event_details screen. |
|
22 | - * |
|
23 | - * @access protected |
|
24 | - * @var EE_Event $_event |
|
25 | - */ |
|
26 | - protected $_event; |
|
27 | - |
|
28 | - |
|
29 | - /** |
|
30 | - * This will hold the category object for category_details screen. |
|
31 | - * |
|
32 | - * @var stdClass $_category |
|
33 | - */ |
|
34 | - protected $_category; |
|
35 | - |
|
36 | - |
|
37 | - /** |
|
38 | - * This will hold the event model instance |
|
39 | - * |
|
40 | - * @var EEM_Event $_event_model |
|
41 | - */ |
|
42 | - protected $_event_model; |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * @var EE_Event |
|
48 | - */ |
|
49 | - protected $_cpt_model_obj = false; |
|
50 | - |
|
51 | - |
|
52 | - |
|
53 | - protected function _init_page_props() |
|
54 | - { |
|
55 | - $this->page_slug = EVENTS_PG_SLUG; |
|
56 | - $this->page_label = EVENTS_LABEL; |
|
57 | - $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
58 | - $this->_admin_base_path = EVENTS_ADMIN; |
|
59 | - $this->_cpt_model_names = array( |
|
60 | - 'create_new' => 'EEM_Event', |
|
61 | - 'edit' => 'EEM_Event', |
|
62 | - ); |
|
63 | - $this->_cpt_edit_routes = array( |
|
64 | - 'espresso_events' => 'edit', |
|
65 | - ); |
|
66 | - add_action( |
|
67 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
68 | - array($this, 'verify_event_edit') |
|
69 | - ); |
|
70 | - } |
|
71 | - |
|
72 | - |
|
73 | - |
|
74 | - protected function _ajax_hooks() |
|
75 | - { |
|
76 | - //todo: all hooks for events ajax goes in here. |
|
77 | - } |
|
78 | - |
|
79 | - |
|
80 | - |
|
81 | - protected function _define_page_props() |
|
82 | - { |
|
83 | - $this->_admin_page_title = EVENTS_LABEL; |
|
84 | - $this->_labels = array( |
|
85 | - 'buttons' => array( |
|
86 | - 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
87 | - 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
88 | - 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
89 | - 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
90 | - 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
91 | - 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
92 | - ), |
|
93 | - 'editor_title' => array( |
|
94 | - 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
95 | - ), |
|
96 | - 'publishbox' => array( |
|
97 | - 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
98 | - 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
99 | - 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
100 | - 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
101 | - 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
102 | - ), |
|
103 | - ); |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - |
|
108 | - protected function _set_page_routes() |
|
109 | - { |
|
110 | - //load formatter helper |
|
111 | - //load field generator helper |
|
112 | - //is there a evt_id in the request? |
|
113 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
114 | - ? $this->_req_data['EVT_ID'] : 0; |
|
115 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
116 | - $this->_page_routes = array( |
|
117 | - 'default' => array( |
|
118 | - 'func' => '_events_overview_list_table', |
|
119 | - 'capability' => 'ee_read_events', |
|
120 | - ), |
|
121 | - 'create_new' => array( |
|
122 | - 'func' => '_create_new_cpt_item', |
|
123 | - 'capability' => 'ee_edit_events', |
|
124 | - ), |
|
125 | - 'edit' => array( |
|
126 | - 'func' => '_edit_cpt_item', |
|
127 | - 'capability' => 'ee_edit_event', |
|
128 | - 'obj_id' => $evt_id, |
|
129 | - ), |
|
130 | - 'copy_event' => array( |
|
131 | - 'func' => '_copy_events', |
|
132 | - 'capability' => 'ee_edit_event', |
|
133 | - 'obj_id' => $evt_id, |
|
134 | - 'noheader' => true, |
|
135 | - ), |
|
136 | - 'trash_event' => array( |
|
137 | - 'func' => '_trash_or_restore_event', |
|
138 | - 'args' => array('event_status' => 'trash'), |
|
139 | - 'capability' => 'ee_delete_event', |
|
140 | - 'obj_id' => $evt_id, |
|
141 | - 'noheader' => true, |
|
142 | - ), |
|
143 | - 'trash_events' => array( |
|
144 | - 'func' => '_trash_or_restore_events', |
|
145 | - 'args' => array('event_status' => 'trash'), |
|
146 | - 'capability' => 'ee_delete_events', |
|
147 | - 'noheader' => true, |
|
148 | - ), |
|
149 | - 'restore_event' => array( |
|
150 | - 'func' => '_trash_or_restore_event', |
|
151 | - 'args' => array('event_status' => 'draft'), |
|
152 | - 'capability' => 'ee_delete_event', |
|
153 | - 'obj_id' => $evt_id, |
|
154 | - 'noheader' => true, |
|
155 | - ), |
|
156 | - 'restore_events' => array( |
|
157 | - 'func' => '_trash_or_restore_events', |
|
158 | - 'args' => array('event_status' => 'draft'), |
|
159 | - 'capability' => 'ee_delete_events', |
|
160 | - 'noheader' => true, |
|
161 | - ), |
|
162 | - 'delete_event' => array( |
|
163 | - 'func' => '_delete_event', |
|
164 | - 'capability' => 'ee_delete_event', |
|
165 | - 'obj_id' => $evt_id, |
|
166 | - 'noheader' => true, |
|
167 | - ), |
|
168 | - 'delete_events' => array( |
|
169 | - 'func' => '_delete_events', |
|
170 | - 'capability' => 'ee_delete_events', |
|
171 | - 'noheader' => true, |
|
172 | - ), |
|
173 | - 'view_report' => array( |
|
174 | - 'func' => '_view_report', |
|
175 | - 'capablity' => 'ee_edit_events', |
|
176 | - ), |
|
177 | - 'default_event_settings' => array( |
|
178 | - 'func' => '_default_event_settings', |
|
179 | - 'capability' => 'manage_options', |
|
180 | - ), |
|
181 | - 'update_default_event_settings' => array( |
|
182 | - 'func' => '_update_default_event_settings', |
|
183 | - 'capability' => 'manage_options', |
|
184 | - 'noheader' => true, |
|
185 | - ), |
|
186 | - 'template_settings' => array( |
|
187 | - 'func' => '_template_settings', |
|
188 | - 'capability' => 'manage_options', |
|
189 | - ), |
|
190 | - //event category tab related |
|
191 | - 'add_category' => array( |
|
192 | - 'func' => '_category_details', |
|
193 | - 'capability' => 'ee_edit_event_category', |
|
194 | - 'args' => array('add'), |
|
195 | - ), |
|
196 | - 'edit_category' => array( |
|
197 | - 'func' => '_category_details', |
|
198 | - 'capability' => 'ee_edit_event_category', |
|
199 | - 'args' => array('edit'), |
|
200 | - ), |
|
201 | - 'delete_categories' => array( |
|
202 | - 'func' => '_delete_categories', |
|
203 | - 'capability' => 'ee_delete_event_category', |
|
204 | - 'noheader' => true, |
|
205 | - ), |
|
206 | - 'delete_category' => array( |
|
207 | - 'func' => '_delete_categories', |
|
208 | - 'capability' => 'ee_delete_event_category', |
|
209 | - 'noheader' => true, |
|
210 | - ), |
|
211 | - 'insert_category' => array( |
|
212 | - 'func' => '_insert_or_update_category', |
|
213 | - 'args' => array('new_category' => true), |
|
214 | - 'capability' => 'ee_edit_event_category', |
|
215 | - 'noheader' => true, |
|
216 | - ), |
|
217 | - 'update_category' => array( |
|
218 | - 'func' => '_insert_or_update_category', |
|
219 | - 'args' => array('new_category' => false), |
|
220 | - 'capability' => 'ee_edit_event_category', |
|
221 | - 'noheader' => true, |
|
222 | - ), |
|
223 | - 'category_list' => array( |
|
224 | - 'func' => '_category_list_table', |
|
225 | - 'capability' => 'ee_manage_event_categories', |
|
226 | - ), |
|
227 | - ); |
|
228 | - } |
|
229 | - |
|
230 | - |
|
231 | - |
|
232 | - protected function _set_page_config() |
|
233 | - { |
|
234 | - $this->_page_config = array( |
|
235 | - 'default' => array( |
|
236 | - 'nav' => array( |
|
237 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
238 | - 'order' => 10, |
|
239 | - ), |
|
240 | - 'list_table' => 'Events_Admin_List_Table', |
|
241 | - 'help_tabs' => array( |
|
242 | - 'events_overview_help_tab' => array( |
|
243 | - 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
244 | - 'filename' => 'events_overview', |
|
245 | - ), |
|
246 | - 'events_overview_table_column_headings_help_tab' => array( |
|
247 | - 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
248 | - 'filename' => 'events_overview_table_column_headings', |
|
249 | - ), |
|
250 | - 'events_overview_filters_help_tab' => array( |
|
251 | - 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
252 | - 'filename' => 'events_overview_filters', |
|
253 | - ), |
|
254 | - 'events_overview_view_help_tab' => array( |
|
255 | - 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
256 | - 'filename' => 'events_overview_views', |
|
257 | - ), |
|
258 | - 'events_overview_other_help_tab' => array( |
|
259 | - 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
260 | - 'filename' => 'events_overview_other', |
|
261 | - ), |
|
262 | - ), |
|
263 | - 'help_tour' => array( |
|
264 | - 'Event_Overview_Help_Tour', |
|
265 | - //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
266 | - ), |
|
267 | - 'qtips' => array( |
|
268 | - 'EE_Event_List_Table_Tips', |
|
269 | - ), |
|
270 | - 'require_nonce' => false, |
|
271 | - ), |
|
272 | - 'create_new' => array( |
|
273 | - 'nav' => array( |
|
274 | - 'label' => esc_html__('Add Event', 'event_espresso'), |
|
275 | - 'order' => 5, |
|
276 | - 'persistent' => false, |
|
277 | - ), |
|
278 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
279 | - 'help_tabs' => array( |
|
280 | - 'event_editor_help_tab' => array( |
|
281 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
282 | - 'filename' => 'event_editor', |
|
283 | - ), |
|
284 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
285 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
286 | - 'filename' => 'event_editor_title_richtexteditor', |
|
287 | - ), |
|
288 | - 'event_editor_venue_details_help_tab' => array( |
|
289 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
290 | - 'filename' => 'event_editor_venue_details', |
|
291 | - ), |
|
292 | - 'event_editor_event_datetimes_help_tab' => array( |
|
293 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
294 | - 'filename' => 'event_editor_event_datetimes', |
|
295 | - ), |
|
296 | - 'event_editor_event_tickets_help_tab' => array( |
|
297 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
298 | - 'filename' => 'event_editor_event_tickets', |
|
299 | - ), |
|
300 | - 'event_editor_event_registration_options_help_tab' => array( |
|
301 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
302 | - 'filename' => 'event_editor_event_registration_options', |
|
303 | - ), |
|
304 | - 'event_editor_tags_categories_help_tab' => array( |
|
305 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
306 | - 'filename' => 'event_editor_tags_categories', |
|
307 | - ), |
|
308 | - 'event_editor_questions_registrants_help_tab' => array( |
|
309 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
310 | - 'filename' => 'event_editor_questions_registrants', |
|
311 | - ), |
|
312 | - 'event_editor_save_new_event_help_tab' => array( |
|
313 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
314 | - 'filename' => 'event_editor_save_new_event', |
|
315 | - ), |
|
316 | - 'event_editor_other_help_tab' => array( |
|
317 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
318 | - 'filename' => 'event_editor_other', |
|
319 | - ), |
|
320 | - ), |
|
321 | - 'help_tour' => array( |
|
322 | - 'Event_Editor_Help_Tour', |
|
323 | - ), |
|
324 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
325 | - 'require_nonce' => false, |
|
326 | - ), |
|
327 | - 'edit' => array( |
|
328 | - 'nav' => array( |
|
329 | - 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
330 | - 'order' => 5, |
|
331 | - 'persistent' => false, |
|
332 | - 'url' => isset($this->_req_data['post']) |
|
333 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
334 | - array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
335 | - $this->_current_page_view_url |
|
336 | - ) |
|
337 | - : $this->_admin_base_url, |
|
338 | - ), |
|
339 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
340 | - 'help_tabs' => array( |
|
341 | - 'event_editor_help_tab' => array( |
|
342 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
343 | - 'filename' => 'event_editor', |
|
344 | - ), |
|
345 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
346 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
347 | - 'filename' => 'event_editor_title_richtexteditor', |
|
348 | - ), |
|
349 | - 'event_editor_venue_details_help_tab' => array( |
|
350 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
351 | - 'filename' => 'event_editor_venue_details', |
|
352 | - ), |
|
353 | - 'event_editor_event_datetimes_help_tab' => array( |
|
354 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
355 | - 'filename' => 'event_editor_event_datetimes', |
|
356 | - ), |
|
357 | - 'event_editor_event_tickets_help_tab' => array( |
|
358 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
359 | - 'filename' => 'event_editor_event_tickets', |
|
360 | - ), |
|
361 | - 'event_editor_event_registration_options_help_tab' => array( |
|
362 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
363 | - 'filename' => 'event_editor_event_registration_options', |
|
364 | - ), |
|
365 | - 'event_editor_tags_categories_help_tab' => array( |
|
366 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
367 | - 'filename' => 'event_editor_tags_categories', |
|
368 | - ), |
|
369 | - 'event_editor_questions_registrants_help_tab' => array( |
|
370 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
371 | - 'filename' => 'event_editor_questions_registrants', |
|
372 | - ), |
|
373 | - 'event_editor_save_new_event_help_tab' => array( |
|
374 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
375 | - 'filename' => 'event_editor_save_new_event', |
|
376 | - ), |
|
377 | - 'event_editor_other_help_tab' => array( |
|
378 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
379 | - 'filename' => 'event_editor_other', |
|
380 | - ), |
|
381 | - ), |
|
382 | - /*'help_tour' => array( |
|
20 | + /** |
|
21 | + * This will hold the event object for event_details screen. |
|
22 | + * |
|
23 | + * @access protected |
|
24 | + * @var EE_Event $_event |
|
25 | + */ |
|
26 | + protected $_event; |
|
27 | + |
|
28 | + |
|
29 | + /** |
|
30 | + * This will hold the category object for category_details screen. |
|
31 | + * |
|
32 | + * @var stdClass $_category |
|
33 | + */ |
|
34 | + protected $_category; |
|
35 | + |
|
36 | + |
|
37 | + /** |
|
38 | + * This will hold the event model instance |
|
39 | + * |
|
40 | + * @var EEM_Event $_event_model |
|
41 | + */ |
|
42 | + protected $_event_model; |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * @var EE_Event |
|
48 | + */ |
|
49 | + protected $_cpt_model_obj = false; |
|
50 | + |
|
51 | + |
|
52 | + |
|
53 | + protected function _init_page_props() |
|
54 | + { |
|
55 | + $this->page_slug = EVENTS_PG_SLUG; |
|
56 | + $this->page_label = EVENTS_LABEL; |
|
57 | + $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
58 | + $this->_admin_base_path = EVENTS_ADMIN; |
|
59 | + $this->_cpt_model_names = array( |
|
60 | + 'create_new' => 'EEM_Event', |
|
61 | + 'edit' => 'EEM_Event', |
|
62 | + ); |
|
63 | + $this->_cpt_edit_routes = array( |
|
64 | + 'espresso_events' => 'edit', |
|
65 | + ); |
|
66 | + add_action( |
|
67 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
68 | + array($this, 'verify_event_edit') |
|
69 | + ); |
|
70 | + } |
|
71 | + |
|
72 | + |
|
73 | + |
|
74 | + protected function _ajax_hooks() |
|
75 | + { |
|
76 | + //todo: all hooks for events ajax goes in here. |
|
77 | + } |
|
78 | + |
|
79 | + |
|
80 | + |
|
81 | + protected function _define_page_props() |
|
82 | + { |
|
83 | + $this->_admin_page_title = EVENTS_LABEL; |
|
84 | + $this->_labels = array( |
|
85 | + 'buttons' => array( |
|
86 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
87 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
88 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
89 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
90 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
91 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
92 | + ), |
|
93 | + 'editor_title' => array( |
|
94 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
95 | + ), |
|
96 | + 'publishbox' => array( |
|
97 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
98 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
99 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
100 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
101 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
102 | + ), |
|
103 | + ); |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + |
|
108 | + protected function _set_page_routes() |
|
109 | + { |
|
110 | + //load formatter helper |
|
111 | + //load field generator helper |
|
112 | + //is there a evt_id in the request? |
|
113 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
114 | + ? $this->_req_data['EVT_ID'] : 0; |
|
115 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
116 | + $this->_page_routes = array( |
|
117 | + 'default' => array( |
|
118 | + 'func' => '_events_overview_list_table', |
|
119 | + 'capability' => 'ee_read_events', |
|
120 | + ), |
|
121 | + 'create_new' => array( |
|
122 | + 'func' => '_create_new_cpt_item', |
|
123 | + 'capability' => 'ee_edit_events', |
|
124 | + ), |
|
125 | + 'edit' => array( |
|
126 | + 'func' => '_edit_cpt_item', |
|
127 | + 'capability' => 'ee_edit_event', |
|
128 | + 'obj_id' => $evt_id, |
|
129 | + ), |
|
130 | + 'copy_event' => array( |
|
131 | + 'func' => '_copy_events', |
|
132 | + 'capability' => 'ee_edit_event', |
|
133 | + 'obj_id' => $evt_id, |
|
134 | + 'noheader' => true, |
|
135 | + ), |
|
136 | + 'trash_event' => array( |
|
137 | + 'func' => '_trash_or_restore_event', |
|
138 | + 'args' => array('event_status' => 'trash'), |
|
139 | + 'capability' => 'ee_delete_event', |
|
140 | + 'obj_id' => $evt_id, |
|
141 | + 'noheader' => true, |
|
142 | + ), |
|
143 | + 'trash_events' => array( |
|
144 | + 'func' => '_trash_or_restore_events', |
|
145 | + 'args' => array('event_status' => 'trash'), |
|
146 | + 'capability' => 'ee_delete_events', |
|
147 | + 'noheader' => true, |
|
148 | + ), |
|
149 | + 'restore_event' => array( |
|
150 | + 'func' => '_trash_or_restore_event', |
|
151 | + 'args' => array('event_status' => 'draft'), |
|
152 | + 'capability' => 'ee_delete_event', |
|
153 | + 'obj_id' => $evt_id, |
|
154 | + 'noheader' => true, |
|
155 | + ), |
|
156 | + 'restore_events' => array( |
|
157 | + 'func' => '_trash_or_restore_events', |
|
158 | + 'args' => array('event_status' => 'draft'), |
|
159 | + 'capability' => 'ee_delete_events', |
|
160 | + 'noheader' => true, |
|
161 | + ), |
|
162 | + 'delete_event' => array( |
|
163 | + 'func' => '_delete_event', |
|
164 | + 'capability' => 'ee_delete_event', |
|
165 | + 'obj_id' => $evt_id, |
|
166 | + 'noheader' => true, |
|
167 | + ), |
|
168 | + 'delete_events' => array( |
|
169 | + 'func' => '_delete_events', |
|
170 | + 'capability' => 'ee_delete_events', |
|
171 | + 'noheader' => true, |
|
172 | + ), |
|
173 | + 'view_report' => array( |
|
174 | + 'func' => '_view_report', |
|
175 | + 'capablity' => 'ee_edit_events', |
|
176 | + ), |
|
177 | + 'default_event_settings' => array( |
|
178 | + 'func' => '_default_event_settings', |
|
179 | + 'capability' => 'manage_options', |
|
180 | + ), |
|
181 | + 'update_default_event_settings' => array( |
|
182 | + 'func' => '_update_default_event_settings', |
|
183 | + 'capability' => 'manage_options', |
|
184 | + 'noheader' => true, |
|
185 | + ), |
|
186 | + 'template_settings' => array( |
|
187 | + 'func' => '_template_settings', |
|
188 | + 'capability' => 'manage_options', |
|
189 | + ), |
|
190 | + //event category tab related |
|
191 | + 'add_category' => array( |
|
192 | + 'func' => '_category_details', |
|
193 | + 'capability' => 'ee_edit_event_category', |
|
194 | + 'args' => array('add'), |
|
195 | + ), |
|
196 | + 'edit_category' => array( |
|
197 | + 'func' => '_category_details', |
|
198 | + 'capability' => 'ee_edit_event_category', |
|
199 | + 'args' => array('edit'), |
|
200 | + ), |
|
201 | + 'delete_categories' => array( |
|
202 | + 'func' => '_delete_categories', |
|
203 | + 'capability' => 'ee_delete_event_category', |
|
204 | + 'noheader' => true, |
|
205 | + ), |
|
206 | + 'delete_category' => array( |
|
207 | + 'func' => '_delete_categories', |
|
208 | + 'capability' => 'ee_delete_event_category', |
|
209 | + 'noheader' => true, |
|
210 | + ), |
|
211 | + 'insert_category' => array( |
|
212 | + 'func' => '_insert_or_update_category', |
|
213 | + 'args' => array('new_category' => true), |
|
214 | + 'capability' => 'ee_edit_event_category', |
|
215 | + 'noheader' => true, |
|
216 | + ), |
|
217 | + 'update_category' => array( |
|
218 | + 'func' => '_insert_or_update_category', |
|
219 | + 'args' => array('new_category' => false), |
|
220 | + 'capability' => 'ee_edit_event_category', |
|
221 | + 'noheader' => true, |
|
222 | + ), |
|
223 | + 'category_list' => array( |
|
224 | + 'func' => '_category_list_table', |
|
225 | + 'capability' => 'ee_manage_event_categories', |
|
226 | + ), |
|
227 | + ); |
|
228 | + } |
|
229 | + |
|
230 | + |
|
231 | + |
|
232 | + protected function _set_page_config() |
|
233 | + { |
|
234 | + $this->_page_config = array( |
|
235 | + 'default' => array( |
|
236 | + 'nav' => array( |
|
237 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
238 | + 'order' => 10, |
|
239 | + ), |
|
240 | + 'list_table' => 'Events_Admin_List_Table', |
|
241 | + 'help_tabs' => array( |
|
242 | + 'events_overview_help_tab' => array( |
|
243 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
244 | + 'filename' => 'events_overview', |
|
245 | + ), |
|
246 | + 'events_overview_table_column_headings_help_tab' => array( |
|
247 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
248 | + 'filename' => 'events_overview_table_column_headings', |
|
249 | + ), |
|
250 | + 'events_overview_filters_help_tab' => array( |
|
251 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
252 | + 'filename' => 'events_overview_filters', |
|
253 | + ), |
|
254 | + 'events_overview_view_help_tab' => array( |
|
255 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
256 | + 'filename' => 'events_overview_views', |
|
257 | + ), |
|
258 | + 'events_overview_other_help_tab' => array( |
|
259 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
260 | + 'filename' => 'events_overview_other', |
|
261 | + ), |
|
262 | + ), |
|
263 | + 'help_tour' => array( |
|
264 | + 'Event_Overview_Help_Tour', |
|
265 | + //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
266 | + ), |
|
267 | + 'qtips' => array( |
|
268 | + 'EE_Event_List_Table_Tips', |
|
269 | + ), |
|
270 | + 'require_nonce' => false, |
|
271 | + ), |
|
272 | + 'create_new' => array( |
|
273 | + 'nav' => array( |
|
274 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
275 | + 'order' => 5, |
|
276 | + 'persistent' => false, |
|
277 | + ), |
|
278 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
279 | + 'help_tabs' => array( |
|
280 | + 'event_editor_help_tab' => array( |
|
281 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
282 | + 'filename' => 'event_editor', |
|
283 | + ), |
|
284 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
285 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
286 | + 'filename' => 'event_editor_title_richtexteditor', |
|
287 | + ), |
|
288 | + 'event_editor_venue_details_help_tab' => array( |
|
289 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
290 | + 'filename' => 'event_editor_venue_details', |
|
291 | + ), |
|
292 | + 'event_editor_event_datetimes_help_tab' => array( |
|
293 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
294 | + 'filename' => 'event_editor_event_datetimes', |
|
295 | + ), |
|
296 | + 'event_editor_event_tickets_help_tab' => array( |
|
297 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
298 | + 'filename' => 'event_editor_event_tickets', |
|
299 | + ), |
|
300 | + 'event_editor_event_registration_options_help_tab' => array( |
|
301 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
302 | + 'filename' => 'event_editor_event_registration_options', |
|
303 | + ), |
|
304 | + 'event_editor_tags_categories_help_tab' => array( |
|
305 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
306 | + 'filename' => 'event_editor_tags_categories', |
|
307 | + ), |
|
308 | + 'event_editor_questions_registrants_help_tab' => array( |
|
309 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
310 | + 'filename' => 'event_editor_questions_registrants', |
|
311 | + ), |
|
312 | + 'event_editor_save_new_event_help_tab' => array( |
|
313 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
314 | + 'filename' => 'event_editor_save_new_event', |
|
315 | + ), |
|
316 | + 'event_editor_other_help_tab' => array( |
|
317 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
318 | + 'filename' => 'event_editor_other', |
|
319 | + ), |
|
320 | + ), |
|
321 | + 'help_tour' => array( |
|
322 | + 'Event_Editor_Help_Tour', |
|
323 | + ), |
|
324 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
325 | + 'require_nonce' => false, |
|
326 | + ), |
|
327 | + 'edit' => array( |
|
328 | + 'nav' => array( |
|
329 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
330 | + 'order' => 5, |
|
331 | + 'persistent' => false, |
|
332 | + 'url' => isset($this->_req_data['post']) |
|
333 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
334 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
335 | + $this->_current_page_view_url |
|
336 | + ) |
|
337 | + : $this->_admin_base_url, |
|
338 | + ), |
|
339 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
340 | + 'help_tabs' => array( |
|
341 | + 'event_editor_help_tab' => array( |
|
342 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
343 | + 'filename' => 'event_editor', |
|
344 | + ), |
|
345 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
346 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
347 | + 'filename' => 'event_editor_title_richtexteditor', |
|
348 | + ), |
|
349 | + 'event_editor_venue_details_help_tab' => array( |
|
350 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
351 | + 'filename' => 'event_editor_venue_details', |
|
352 | + ), |
|
353 | + 'event_editor_event_datetimes_help_tab' => array( |
|
354 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
355 | + 'filename' => 'event_editor_event_datetimes', |
|
356 | + ), |
|
357 | + 'event_editor_event_tickets_help_tab' => array( |
|
358 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
359 | + 'filename' => 'event_editor_event_tickets', |
|
360 | + ), |
|
361 | + 'event_editor_event_registration_options_help_tab' => array( |
|
362 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
363 | + 'filename' => 'event_editor_event_registration_options', |
|
364 | + ), |
|
365 | + 'event_editor_tags_categories_help_tab' => array( |
|
366 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
367 | + 'filename' => 'event_editor_tags_categories', |
|
368 | + ), |
|
369 | + 'event_editor_questions_registrants_help_tab' => array( |
|
370 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
371 | + 'filename' => 'event_editor_questions_registrants', |
|
372 | + ), |
|
373 | + 'event_editor_save_new_event_help_tab' => array( |
|
374 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
375 | + 'filename' => 'event_editor_save_new_event', |
|
376 | + ), |
|
377 | + 'event_editor_other_help_tab' => array( |
|
378 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
379 | + 'filename' => 'event_editor_other', |
|
380 | + ), |
|
381 | + ), |
|
382 | + /*'help_tour' => array( |
|
383 | 383 | 'Event_Edit_Help_Tour' |
384 | 384 | ),*/ |
385 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
386 | - 'require_nonce' => false, |
|
387 | - ), |
|
388 | - 'default_event_settings' => array( |
|
389 | - 'nav' => array( |
|
390 | - 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
391 | - 'order' => 40, |
|
392 | - ), |
|
393 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
394 | - 'labels' => array( |
|
395 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
396 | - ), |
|
397 | - 'help_tabs' => array( |
|
398 | - 'default_settings_help_tab' => array( |
|
399 | - 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
400 | - 'filename' => 'events_default_settings', |
|
401 | - ), |
|
402 | - 'default_settings_status_help_tab' => array( |
|
403 | - 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
404 | - 'filename' => 'events_default_settings_status', |
|
405 | - ), |
|
406 | - ), |
|
407 | - 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
408 | - 'require_nonce' => false, |
|
409 | - ), |
|
410 | - //template settings |
|
411 | - 'template_settings' => array( |
|
412 | - 'nav' => array( |
|
413 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
414 | - 'order' => 30, |
|
415 | - ), |
|
416 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
417 | - 'help_tabs' => array( |
|
418 | - 'general_settings_templates_help_tab' => array( |
|
419 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
420 | - 'filename' => 'general_settings_templates', |
|
421 | - ), |
|
422 | - ), |
|
423 | - 'help_tour' => array('Templates_Help_Tour'), |
|
424 | - 'require_nonce' => false, |
|
425 | - ), |
|
426 | - //event category stuff |
|
427 | - 'add_category' => array( |
|
428 | - 'nav' => array( |
|
429 | - 'label' => esc_html__('Add Category', 'event_espresso'), |
|
430 | - 'order' => 15, |
|
431 | - 'persistent' => false, |
|
432 | - ), |
|
433 | - 'help_tabs' => array( |
|
434 | - 'add_category_help_tab' => array( |
|
435 | - 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
436 | - 'filename' => 'events_add_category', |
|
437 | - ), |
|
438 | - ), |
|
439 | - 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
440 | - 'metaboxes' => array('_publish_post_box'), |
|
441 | - 'require_nonce' => false, |
|
442 | - ), |
|
443 | - 'edit_category' => array( |
|
444 | - 'nav' => array( |
|
445 | - 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
446 | - 'order' => 15, |
|
447 | - 'persistent' => false, |
|
448 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
449 | - ? add_query_arg( |
|
450 | - array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
451 | - $this->_current_page_view_url |
|
452 | - ) |
|
453 | - : $this->_admin_base_url, |
|
454 | - ), |
|
455 | - 'help_tabs' => array( |
|
456 | - 'edit_category_help_tab' => array( |
|
457 | - 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
458 | - 'filename' => 'events_edit_category', |
|
459 | - ), |
|
460 | - ), |
|
461 | - /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
462 | - 'metaboxes' => array('_publish_post_box'), |
|
463 | - 'require_nonce' => false, |
|
464 | - ), |
|
465 | - 'category_list' => array( |
|
466 | - 'nav' => array( |
|
467 | - 'label' => esc_html__('Categories', 'event_espresso'), |
|
468 | - 'order' => 20, |
|
469 | - ), |
|
470 | - 'list_table' => 'Event_Categories_Admin_List_Table', |
|
471 | - 'help_tabs' => array( |
|
472 | - 'events_categories_help_tab' => array( |
|
473 | - 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
474 | - 'filename' => 'events_categories', |
|
475 | - ), |
|
476 | - 'events_categories_table_column_headings_help_tab' => array( |
|
477 | - 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
478 | - 'filename' => 'events_categories_table_column_headings', |
|
479 | - ), |
|
480 | - 'events_categories_view_help_tab' => array( |
|
481 | - 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
482 | - 'filename' => 'events_categories_views', |
|
483 | - ), |
|
484 | - 'events_categories_other_help_tab' => array( |
|
485 | - 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
486 | - 'filename' => 'events_categories_other', |
|
487 | - ), |
|
488 | - ), |
|
489 | - 'help_tour' => array( |
|
490 | - 'Event_Categories_Help_Tour', |
|
491 | - ), |
|
492 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
493 | - 'require_nonce' => false, |
|
494 | - ), |
|
495 | - ); |
|
496 | - } |
|
497 | - |
|
498 | - |
|
499 | - |
|
500 | - protected function _add_screen_options() |
|
501 | - { |
|
502 | - //todo |
|
503 | - } |
|
504 | - |
|
505 | - |
|
506 | - |
|
507 | - protected function _add_screen_options_default() |
|
508 | - { |
|
509 | - $this->_per_page_screen_option(); |
|
510 | - } |
|
511 | - |
|
512 | - |
|
513 | - |
|
514 | - protected function _add_screen_options_category_list() |
|
515 | - { |
|
516 | - $page_title = $this->_admin_page_title; |
|
517 | - $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
518 | - $this->_per_page_screen_option(); |
|
519 | - $this->_admin_page_title = $page_title; |
|
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - |
|
524 | - protected function _add_feature_pointers() |
|
525 | - { |
|
526 | - //todo |
|
527 | - } |
|
528 | - |
|
529 | - |
|
530 | - |
|
531 | - public function load_scripts_styles() |
|
532 | - { |
|
533 | - wp_register_style( |
|
534 | - 'events-admin-css', |
|
535 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
536 | - array(), |
|
537 | - EVENT_ESPRESSO_VERSION |
|
538 | - ); |
|
539 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
540 | - wp_enqueue_style('events-admin-css'); |
|
541 | - wp_enqueue_style('ee-cat-admin'); |
|
542 | - //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
543 | - //registers for all views |
|
544 | - //scripts |
|
545 | - wp_register_script( |
|
546 | - 'event_editor_js', |
|
547 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
548 | - array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
549 | - EVENT_ESPRESSO_VERSION, |
|
550 | - true |
|
551 | - ); |
|
552 | - } |
|
553 | - |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * enqueuing scripts and styles specific to this view |
|
558 | - * |
|
559 | - * @return void |
|
560 | - */ |
|
561 | - public function load_scripts_styles_create_new() |
|
562 | - { |
|
563 | - $this->load_scripts_styles_edit(); |
|
564 | - } |
|
565 | - |
|
566 | - |
|
567 | - |
|
568 | - /** |
|
569 | - * enqueuing scripts and styles specific to this view |
|
570 | - * |
|
571 | - * @return void |
|
572 | - */ |
|
573 | - public function load_scripts_styles_edit() |
|
574 | - { |
|
575 | - //styles |
|
576 | - wp_enqueue_style('espresso-ui-theme'); |
|
577 | - wp_register_style( |
|
578 | - 'event-editor-css', |
|
579 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
580 | - array('ee-admin-css'), |
|
581 | - EVENT_ESPRESSO_VERSION |
|
582 | - ); |
|
583 | - wp_enqueue_style('event-editor-css'); |
|
584 | - //scripts |
|
585 | - wp_register_script( |
|
586 | - 'event-datetime-metabox', |
|
587 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
588 | - array('event_editor_js', 'ee-datepicker'), |
|
589 | - EVENT_ESPRESSO_VERSION |
|
590 | - ); |
|
591 | - wp_enqueue_script('event-datetime-metabox'); |
|
592 | - } |
|
593 | - |
|
594 | - |
|
595 | - |
|
596 | - public function load_scripts_styles_add_category() |
|
597 | - { |
|
598 | - $this->load_scripts_styles_edit_category(); |
|
599 | - } |
|
600 | - |
|
601 | - |
|
602 | - |
|
603 | - public function load_scripts_styles_edit_category() |
|
604 | - { |
|
605 | - } |
|
606 | - |
|
607 | - |
|
608 | - |
|
609 | - protected function _set_list_table_views_category_list() |
|
610 | - { |
|
611 | - $this->_views = array( |
|
612 | - 'all' => array( |
|
613 | - 'slug' => 'all', |
|
614 | - 'label' => esc_html__('All', 'event_espresso'), |
|
615 | - 'count' => 0, |
|
616 | - 'bulk_action' => array( |
|
617 | - 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
618 | - ), |
|
619 | - ), |
|
620 | - ); |
|
621 | - } |
|
622 | - |
|
623 | - |
|
624 | - |
|
625 | - public function admin_init() |
|
626 | - { |
|
627 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
628 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
629 | - 'event_espresso' |
|
630 | - ); |
|
631 | - } |
|
632 | - |
|
633 | - |
|
634 | - |
|
635 | - //nothing needed for events with these methods. |
|
636 | - public function admin_notices() |
|
637 | - { |
|
638 | - } |
|
639 | - |
|
640 | - |
|
641 | - |
|
642 | - public function admin_footer_scripts() |
|
643 | - { |
|
644 | - } |
|
645 | - |
|
646 | - |
|
647 | - |
|
648 | - /** |
|
649 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
650 | - * warning (via EE_Error::add_error()); |
|
651 | - * |
|
652 | - * @param EE_Event $event Event object |
|
653 | - * @access public |
|
654 | - * @return void |
|
655 | - */ |
|
656 | - public function verify_event_edit($event = null) |
|
657 | - { |
|
658 | - // no event? |
|
659 | - if (empty($event)) { |
|
660 | - // set event |
|
661 | - $event = $this->_cpt_model_obj; |
|
662 | - } |
|
663 | - // STILL no event? |
|
664 | - if (empty ($event)) { |
|
665 | - return; |
|
666 | - } |
|
667 | - $orig_status = $event->status(); |
|
668 | - // first check if event is active. |
|
669 | - if ( |
|
670 | - $orig_status === EEM_Event::cancelled |
|
671 | - || $orig_status === EEM_Event::postponed |
|
672 | - || $event->is_expired() |
|
673 | - || $event->is_inactive() |
|
674 | - ) { |
|
675 | - return; |
|
676 | - } |
|
677 | - //made it here so it IS active... next check that any of the tickets are sold. |
|
678 | - if ($event->is_sold_out(true)) { |
|
679 | - if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
680 | - EE_Error::add_attention( |
|
681 | - sprintf( |
|
682 | - esc_html__( |
|
683 | - '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.', |
|
684 | - 'event_espresso' |
|
685 | - ), |
|
686 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
687 | - ) |
|
688 | - ); |
|
689 | - } |
|
690 | - return; |
|
691 | - } else if ($orig_status === EEM_Event::sold_out) { |
|
692 | - EE_Error::add_attention( |
|
693 | - sprintf( |
|
694 | - esc_html__( |
|
695 | - '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.', |
|
696 | - 'event_espresso' |
|
697 | - ), |
|
698 | - EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
699 | - ) |
|
700 | - ); |
|
701 | - } |
|
702 | - //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
703 | - if ( ! $event->tickets_on_sale()) { |
|
704 | - return; |
|
705 | - } |
|
706 | - //made it here so show warning |
|
707 | - $this->_edit_event_warning(); |
|
708 | - } |
|
709 | - |
|
710 | - |
|
711 | - |
|
712 | - /** |
|
713 | - * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
714 | - * When needed, hook this into a EE_Error::add_error() notice. |
|
715 | - * |
|
716 | - * @access protected |
|
717 | - * @return void |
|
718 | - */ |
|
719 | - protected function _edit_event_warning() |
|
720 | - { |
|
721 | - // we don't want to add warnings during these requests |
|
722 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
723 | - return; |
|
724 | - } |
|
725 | - EE_Error::add_attention( |
|
726 | - esc_html__( |
|
727 | - 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
728 | - 'event_espresso' |
|
729 | - ) |
|
730 | - ); |
|
731 | - } |
|
732 | - |
|
733 | - |
|
734 | - |
|
735 | - /** |
|
736 | - * When a user is creating a new event, notify them if they haven't set their timezone. |
|
737 | - * Otherwise, do the normal logic |
|
738 | - * |
|
739 | - * @return string |
|
740 | - * @throws \EE_Error |
|
741 | - */ |
|
742 | - protected function _create_new_cpt_item() |
|
743 | - { |
|
744 | - $gmt_offset = get_option('gmt_offset'); |
|
745 | - //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
746 | - if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
747 | - EE_Error::add_attention( |
|
748 | - sprintf( |
|
749 | - __( |
|
750 | - 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.', |
|
751 | - 'event_espresso' |
|
752 | - ), |
|
753 | - '<a href="' . admin_url('options-general.php') . '">', |
|
754 | - '</a>' |
|
755 | - ), |
|
756 | - __FILE__, |
|
757 | - __FUNCTION__, |
|
758 | - __LINE__ |
|
759 | - ); |
|
760 | - } |
|
761 | - return parent::_create_new_cpt_item(); |
|
762 | - } |
|
763 | - |
|
764 | - |
|
765 | - |
|
766 | - protected function _set_list_table_views_default() |
|
767 | - { |
|
768 | - $this->_views = array( |
|
769 | - 'all' => array( |
|
770 | - 'slug' => 'all', |
|
771 | - 'label' => esc_html__('View All Events', 'event_espresso'), |
|
772 | - 'count' => 0, |
|
773 | - 'bulk_action' => array( |
|
774 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
775 | - ), |
|
776 | - ), |
|
777 | - 'draft' => array( |
|
778 | - 'slug' => 'draft', |
|
779 | - 'label' => esc_html__('Draft', 'event_espresso'), |
|
780 | - 'count' => 0, |
|
781 | - 'bulk_action' => array( |
|
782 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
783 | - ), |
|
784 | - ), |
|
785 | - ); |
|
786 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
787 | - $this->_views['trash'] = array( |
|
788 | - 'slug' => 'trash', |
|
789 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
790 | - 'count' => 0, |
|
791 | - 'bulk_action' => array( |
|
792 | - 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
793 | - 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
794 | - ), |
|
795 | - ); |
|
796 | - } |
|
797 | - } |
|
798 | - |
|
799 | - |
|
800 | - |
|
801 | - /** |
|
802 | - * @return array |
|
803 | - */ |
|
804 | - protected function _event_legend_items() |
|
805 | - { |
|
806 | - $items = array( |
|
807 | - 'view_details' => array( |
|
808 | - 'class' => 'dashicons dashicons-search', |
|
809 | - 'desc' => esc_html__('View Event', 'event_espresso'), |
|
810 | - ), |
|
811 | - 'edit_event' => array( |
|
812 | - 'class' => 'ee-icon ee-icon-calendar-edit', |
|
813 | - 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
814 | - ), |
|
815 | - 'view_attendees' => array( |
|
816 | - 'class' => 'dashicons dashicons-groups', |
|
817 | - 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
818 | - ), |
|
819 | - ); |
|
820 | - $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
821 | - $statuses = array( |
|
822 | - 'sold_out_status' => array( |
|
823 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
824 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
825 | - ), |
|
826 | - 'active_status' => array( |
|
827 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
828 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
829 | - ), |
|
830 | - 'upcoming_status' => array( |
|
831 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
832 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
833 | - ), |
|
834 | - 'postponed_status' => array( |
|
835 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
836 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
837 | - ), |
|
838 | - 'cancelled_status' => array( |
|
839 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
840 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
841 | - ), |
|
842 | - 'expired_status' => array( |
|
843 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
844 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
845 | - ), |
|
846 | - 'inactive_status' => array( |
|
847 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
848 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
849 | - ), |
|
850 | - ); |
|
851 | - $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
852 | - return array_merge($items, $statuses); |
|
853 | - } |
|
854 | - |
|
855 | - |
|
856 | - |
|
857 | - /** |
|
858 | - * _event_model |
|
859 | - * |
|
860 | - * @return EEM_Event |
|
861 | - */ |
|
862 | - private function _event_model() |
|
863 | - { |
|
864 | - if ( ! $this->_event_model instanceof EEM_Event) { |
|
865 | - $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
866 | - } |
|
867 | - return $this->_event_model; |
|
868 | - } |
|
869 | - |
|
870 | - |
|
871 | - |
|
872 | - /** |
|
873 | - * Adds extra buttons to the WP CPT permalink field row. |
|
874 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
875 | - * |
|
876 | - * @param string $return the current html |
|
877 | - * @param int $id the post id for the page |
|
878 | - * @param string $new_title What the title is |
|
879 | - * @param string $new_slug what the slug is |
|
880 | - * @return string The new html string for the permalink area |
|
881 | - */ |
|
882 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
883 | - { |
|
884 | - //make sure this is only when editing |
|
885 | - if ( ! empty($id)) { |
|
886 | - $post = get_post($id); |
|
887 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
888 | - . esc_html__('Shortcode', 'event_espresso') |
|
889 | - . '</a> '; |
|
890 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
891 | - . $post->ID |
|
892 | - . ']">'; |
|
893 | - } |
|
894 | - return $return; |
|
895 | - } |
|
896 | - |
|
897 | - |
|
898 | - |
|
899 | - /** |
|
900 | - * _events_overview_list_table |
|
901 | - * This contains the logic for showing the events_overview list |
|
902 | - * |
|
903 | - * @access protected |
|
904 | - * @return void |
|
905 | - * @throws \EE_Error |
|
906 | - */ |
|
907 | - protected function _events_overview_list_table() |
|
908 | - { |
|
909 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
910 | - $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
911 | - ? (array)$this->_template_args['after_list_table'] |
|
912 | - : array(); |
|
913 | - $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
914 | - . EEH_Template::get_button_or_link( |
|
915 | - get_post_type_archive_link('espresso_events'), |
|
916 | - esc_html__("View Event Archive Page", "event_espresso"), |
|
917 | - 'button' |
|
918 | - ); |
|
919 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
920 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
921 | - 'create_new', |
|
922 | - 'add', |
|
923 | - array(), |
|
924 | - 'add-new-h2' |
|
925 | - ); |
|
926 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
927 | - } |
|
928 | - |
|
929 | - |
|
930 | - |
|
931 | - /** |
|
932 | - * this allows for extra misc actions in the default WP publish box |
|
933 | - * |
|
934 | - * @return void |
|
935 | - */ |
|
936 | - public function extra_misc_actions_publish_box() |
|
937 | - { |
|
938 | - $this->_generate_publish_box_extra_content(); |
|
939 | - } |
|
940 | - |
|
941 | - |
|
942 | - |
|
943 | - /** |
|
944 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
945 | - * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
946 | - * data. |
|
947 | - * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
948 | - * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
949 | - * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
950 | - * you handle this accordingly. |
|
951 | - * |
|
952 | - * @access protected |
|
953 | - * @abstract |
|
954 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
955 | - * @param object $post The post object of the cpt that was saved. |
|
956 | - * @return void |
|
957 | - */ |
|
958 | - protected function _insert_update_cpt_item($post_id, $post) |
|
959 | - { |
|
960 | - if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
961 | - //get out we're not processing an event save. |
|
962 | - return; |
|
963 | - } |
|
964 | - $event_values = array( |
|
965 | - 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
966 | - 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
967 | - 'EVT_additional_limit' => min( |
|
968 | - apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
969 | - ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
970 | - ), |
|
971 | - 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
972 | - ? $this->_req_data['EVT_default_registration_status'] |
|
973 | - : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
974 | - 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
975 | - 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
976 | - 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
977 | - ? $this->_req_data['timezone_string'] : null, |
|
978 | - 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
979 | - ? $this->_req_data['externalURL'] : null, |
|
980 | - 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
981 | - ? $this->_req_data['event_phone'] : null, |
|
982 | - ); |
|
983 | - //update event |
|
984 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
985 | - //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! |
|
986 | - $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
987 | - $event = $this->_event_model()->get_one(array($get_one_where)); |
|
988 | - //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
989 | - $event_update_callbacks = apply_filters( |
|
990 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
991 | - array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
992 | - ); |
|
993 | - $att_success = true; |
|
994 | - foreach ($event_update_callbacks as $e_callback) { |
|
995 | - $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
996 | - $att_success = ! $att_success ? $att_success |
|
997 | - : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
998 | - } |
|
999 | - //any errors? |
|
1000 | - if ($success && false === $att_success) { |
|
1001 | - EE_Error::add_error( |
|
1002 | - esc_html__( |
|
1003 | - 'Event Details saved successfully but something went wrong with saving attachments.', |
|
1004 | - 'event_espresso' |
|
1005 | - ), |
|
1006 | - __FILE__, |
|
1007 | - __FUNCTION__, |
|
1008 | - __LINE__ |
|
1009 | - ); |
|
1010 | - } else if ($success === false) { |
|
1011 | - EE_Error::add_error( |
|
1012 | - esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
1013 | - __FILE__, |
|
1014 | - __FUNCTION__, |
|
1015 | - __LINE__ |
|
1016 | - ); |
|
1017 | - } |
|
1018 | - } |
|
1019 | - |
|
1020 | - |
|
1021 | - |
|
1022 | - /** |
|
1023 | - * @see parent::restore_item() |
|
1024 | - * @param int $post_id |
|
1025 | - * @param int $revision_id |
|
1026 | - */ |
|
1027 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
1028 | - { |
|
1029 | - //copy existing event meta to new post |
|
1030 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1031 | - if ($post_evt instanceof EE_Event) { |
|
1032 | - //meta revision restore |
|
1033 | - $post_evt->restore_revision($revision_id); |
|
1034 | - //related objs restore |
|
1035 | - $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1036 | - } |
|
1037 | - } |
|
1038 | - |
|
1039 | - |
|
1040 | - |
|
1041 | - /** |
|
1042 | - * Attach the venue to the Event |
|
1043 | - * |
|
1044 | - * @param \EE_Event $evtobj Event Object to add the venue to |
|
1045 | - * @param array $data The request data from the form |
|
1046 | - * @return bool Success or fail. |
|
1047 | - */ |
|
1048 | - protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1049 | - { |
|
1050 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1051 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1052 | - $rows_affected = null; |
|
1053 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1054 | - // very important. If we don't have a venue name... |
|
1055 | - // then we'll get out because not necessary to create empty venue |
|
1056 | - if (empty($data['venue_title'])) { |
|
1057 | - return false; |
|
1058 | - } |
|
1059 | - $venue_array = array( |
|
1060 | - 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1061 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1062 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1063 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1064 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1065 | - : null, |
|
1066 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1067 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1068 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1069 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1070 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1071 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1072 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1073 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1074 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1075 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1076 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1077 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1078 | - 'status' => 'publish', |
|
1079 | - ); |
|
1080 | - //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1081 | - if ( ! empty($venue_id)) { |
|
1082 | - $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1083 | - $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1084 | - //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. |
|
1085 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1086 | - return $rows_affected > 0 ? true : false; |
|
1087 | - } else { |
|
1088 | - //we insert the venue |
|
1089 | - $venue_id = $venue_model->insert($venue_array); |
|
1090 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1091 | - return ! empty($venue_id) ? true : false; |
|
1092 | - } |
|
1093 | - //when we have the ancestor come in it's already been handled by the revision save. |
|
1094 | - } |
|
1095 | - |
|
1096 | - |
|
1097 | - |
|
1098 | - /** |
|
1099 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1100 | - * |
|
1101 | - * @param EE_Event $evtobj The Event object we're attaching data to |
|
1102 | - * @param array $data The request data from the form |
|
1103 | - * @return array |
|
1104 | - */ |
|
1105 | - protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1106 | - { |
|
1107 | - $success = true; |
|
1108 | - $saved_dtt = null; |
|
1109 | - $saved_tickets = array(); |
|
1110 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1111 | - foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1112 | - //trim all values to ensure any excess whitespace is removed. |
|
1113 | - $dtt = array_map('trim', $dtt); |
|
1114 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1115 | - : $dtt['DTT_EVT_start']; |
|
1116 | - $datetime_values = array( |
|
1117 | - 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1118 | - 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1119 | - 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1120 | - 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1121 | - 'DTT_order' => $row, |
|
1122 | - ); |
|
1123 | - //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. |
|
1124 | - if ( ! empty($dtt['DTT_ID'])) { |
|
1125 | - $DTM = EE_Registry::instance() |
|
1126 | - ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1127 | - ->get_one_by_ID($dtt['DTT_ID']); |
|
1128 | - $DTM->set_date_format($incoming_date_formats[0]); |
|
1129 | - $DTM->set_time_format($incoming_date_formats[1]); |
|
1130 | - foreach ($datetime_values as $field => $value) { |
|
1131 | - $DTM->set($field, $value); |
|
1132 | - } |
|
1133 | - //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. |
|
1134 | - $saved_dtts[$DTM->ID()] = $DTM; |
|
1135 | - } else { |
|
1136 | - $DTM = EE_Registry::instance()->load_class( |
|
1137 | - 'Datetime', |
|
1138 | - array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1139 | - false, |
|
1140 | - false |
|
1141 | - ); |
|
1142 | - foreach ($datetime_values as $field => $value) { |
|
1143 | - $DTM->set($field, $value); |
|
1144 | - } |
|
1145 | - } |
|
1146 | - $DTM->save(); |
|
1147 | - $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1148 | - //load DTT helper |
|
1149 | - //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. |
|
1150 | - if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1151 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1152 | - $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1153 | - $DTT->save(); |
|
1154 | - } |
|
1155 | - //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. |
|
1156 | - $saved_dtt = $DTT; |
|
1157 | - $success = ! $success ? $success : $DTT; |
|
1158 | - //if ANY of these updates fail then we want the appropriate global error message. |
|
1159 | - // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1160 | - } |
|
1161 | - //no dtts get deleted so we don't do any of that logic here. |
|
1162 | - //update tickets next |
|
1163 | - $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1164 | - foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1165 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1166 | - $update_prices = false; |
|
1167 | - $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1168 | - ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1169 | - // trim inputs to ensure any excess whitespace is removed. |
|
1170 | - $tkt = array_map('trim', $tkt); |
|
1171 | - if (empty($tkt['TKT_start_date'])) { |
|
1172 | - //let's use now in the set timezone. |
|
1173 | - $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1174 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1175 | - } |
|
1176 | - if (empty($tkt['TKT_end_date'])) { |
|
1177 | - //use the start date of the first datetime |
|
1178 | - $dtt = $evtobj->first_datetime(); |
|
1179 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1180 | - $incoming_date_formats[0], |
|
1181 | - $incoming_date_formats[1] |
|
1182 | - ); |
|
1183 | - } |
|
1184 | - $TKT_values = array( |
|
1185 | - 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1186 | - 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1187 | - 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1188 | - 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1189 | - 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1190 | - 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1191 | - 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1192 | - 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1193 | - 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1194 | - 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1195 | - 'TKT_row' => $row, |
|
1196 | - 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1197 | - 'TKT_price' => $ticket_price, |
|
1198 | - ); |
|
1199 | - //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. |
|
1200 | - if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1201 | - $TKT_values['TKT_ID'] = 0; |
|
1202 | - $TKT_values['TKT_is_default'] = 0; |
|
1203 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1204 | - $update_prices = true; |
|
1205 | - } |
|
1206 | - //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1207 | - //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. |
|
1208 | - //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. |
|
1209 | - if ( ! empty($tkt['TKT_ID'])) { |
|
1210 | - $TKT = EE_Registry::instance() |
|
1211 | - ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1212 | - ->get_one_by_ID($tkt['TKT_ID']); |
|
1213 | - if ($TKT instanceof EE_Ticket) { |
|
1214 | - $ticket_sold = $TKT->count_related( |
|
1215 | - 'Registration', |
|
1216 | - array( |
|
1217 | - array( |
|
1218 | - 'STS_ID' => array( |
|
1219 | - 'NOT IN', |
|
1220 | - array(EEM_Registration::status_id_incomplete), |
|
1221 | - ), |
|
1222 | - ), |
|
1223 | - ) |
|
1224 | - ) > 0 ? true : false; |
|
1225 | - //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. |
|
1226 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1227 | - && ! $TKT->get( |
|
1228 | - 'TKT_deleted' |
|
1229 | - ) ? true : false; |
|
1230 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1231 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1232 | - //set new values |
|
1233 | - foreach ($TKT_values as $field => $value) { |
|
1234 | - if ($field == 'TKT_qty') { |
|
1235 | - $TKT->set_qty($value); |
|
1236 | - } else { |
|
1237 | - $TKT->set($field, $value); |
|
1238 | - } |
|
1239 | - } |
|
1240 | - //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1241 | - if ($create_new_TKT) { |
|
1242 | - //archive the old ticket first |
|
1243 | - $TKT->set('TKT_deleted', 1); |
|
1244 | - $TKT->save(); |
|
1245 | - //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1246 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1247 | - //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. |
|
1248 | - $TKT = clone $TKT; |
|
1249 | - $TKT->set('TKT_ID', 0); |
|
1250 | - $TKT->set('TKT_deleted', 0); |
|
1251 | - $TKT->set('TKT_price', $ticket_price); |
|
1252 | - $TKT->set('TKT_sold', 0); |
|
1253 | - //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1254 | - $update_prices = true; |
|
1255 | - } |
|
1256 | - //make sure price is set if it hasn't been already |
|
1257 | - $TKT->set('TKT_price', $ticket_price); |
|
1258 | - } |
|
1259 | - } else { |
|
1260 | - //no TKT_id so a new TKT |
|
1261 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1262 | - $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1263 | - if ($TKT instanceof EE_Ticket) { |
|
1264 | - //need to reset values to properly account for the date formats |
|
1265 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1266 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1267 | - $TKT->set_timezone($evtobj->get_timezone()); |
|
1268 | - //set new values |
|
1269 | - foreach ($TKT_values as $field => $value) { |
|
1270 | - if ($field == 'TKT_qty') { |
|
1271 | - $TKT->set_qty($value); |
|
1272 | - } else { |
|
1273 | - $TKT->set($field, $value); |
|
1274 | - } |
|
1275 | - } |
|
1276 | - $update_prices = true; |
|
1277 | - } |
|
1278 | - } |
|
1279 | - // cap ticket qty by datetime reg limits |
|
1280 | - $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1281 | - //update ticket. |
|
1282 | - $TKT->save(); |
|
1283 | - //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. |
|
1284 | - if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1285 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1286 | - $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1287 | - $TKT->save(); |
|
1288 | - } |
|
1289 | - //initially let's add the ticket to the dtt |
|
1290 | - $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1291 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1292 | - //add prices to ticket |
|
1293 | - $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1294 | - } |
|
1295 | - //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. |
|
1296 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1297 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1298 | - foreach ($tickets_removed as $id) { |
|
1299 | - $id = absint($id); |
|
1300 | - //get the ticket for this id |
|
1301 | - $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1302 | - //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) |
|
1303 | - $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1304 | - foreach ($dtts as $dtt) { |
|
1305 | - $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1306 | - } |
|
1307 | - //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)) |
|
1308 | - $tkt_to_remove->delete_related_permanently('Price'); |
|
1309 | - //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1310 | - $tkt_to_remove->delete_permanently(); |
|
1311 | - } |
|
1312 | - return array($saved_dtt, $saved_tickets); |
|
1313 | - } |
|
1314 | - |
|
1315 | - |
|
1316 | - |
|
1317 | - /** |
|
1318 | - * This attaches a list of given prices to a ticket. |
|
1319 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1320 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1321 | - * price info and prices are automatically "archived" via the ticket. |
|
1322 | - * |
|
1323 | - * @access private |
|
1324 | - * @param array $prices Array of prices from the form. |
|
1325 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1326 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1327 | - * @return void |
|
1328 | - */ |
|
1329 | - private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1330 | - { |
|
1331 | - foreach ($prices as $row => $prc) { |
|
1332 | - $PRC_values = array( |
|
1333 | - 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1334 | - 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1335 | - 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1336 | - 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1337 | - 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1338 | - 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1339 | - 'PRC_order' => $row, |
|
1340 | - ); |
|
1341 | - if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1342 | - $PRC_values['PRC_ID'] = 0; |
|
1343 | - $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1344 | - } else { |
|
1345 | - $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1346 | - //update this price with new values |
|
1347 | - foreach ($PRC_values as $field => $newprc) { |
|
1348 | - $PRC->set($field, $newprc); |
|
1349 | - } |
|
1350 | - $PRC->save(); |
|
1351 | - } |
|
1352 | - $ticket->_add_relation_to($PRC, 'Price'); |
|
1353 | - } |
|
1354 | - } |
|
1355 | - |
|
1356 | - |
|
1357 | - |
|
1358 | - /** |
|
1359 | - * Add in our autosave ajax handlers |
|
1360 | - * |
|
1361 | - * @return void |
|
1362 | - */ |
|
1363 | - protected function _ee_autosave_create_new() |
|
1364 | - { |
|
1365 | - // $this->_ee_autosave_edit(); |
|
1366 | - } |
|
1367 | - |
|
1368 | - |
|
1369 | - |
|
1370 | - protected function _ee_autosave_edit() |
|
1371 | - { |
|
1372 | - return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1373 | - } |
|
1374 | - |
|
1375 | - |
|
1376 | - |
|
1377 | - /** |
|
1378 | - * _generate_publish_box_extra_content |
|
1379 | - * |
|
1380 | - * @access private |
|
1381 | - * @return void |
|
1382 | - */ |
|
1383 | - private function _generate_publish_box_extra_content() |
|
1384 | - { |
|
1385 | - //load formatter helper |
|
1386 | - //args for getting related registrations |
|
1387 | - $approved_query_args = array( |
|
1388 | - array( |
|
1389 | - 'REG_deleted' => 0, |
|
1390 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
1391 | - ), |
|
1392 | - ); |
|
1393 | - $not_approved_query_args = array( |
|
1394 | - array( |
|
1395 | - 'REG_deleted' => 0, |
|
1396 | - 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1397 | - ), |
|
1398 | - ); |
|
1399 | - $pending_payment_query_args = array( |
|
1400 | - array( |
|
1401 | - 'REG_deleted' => 0, |
|
1402 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1403 | - ), |
|
1404 | - ); |
|
1405 | - // publish box |
|
1406 | - $publish_box_extra_args = array( |
|
1407 | - 'view_approved_reg_url' => add_query_arg( |
|
1408 | - array( |
|
1409 | - 'action' => 'default', |
|
1410 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1411 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1412 | - ), |
|
1413 | - REG_ADMIN_URL |
|
1414 | - ), |
|
1415 | - 'view_not_approved_reg_url' => add_query_arg( |
|
1416 | - array( |
|
1417 | - 'action' => 'default', |
|
1418 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1419 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1420 | - ), |
|
1421 | - REG_ADMIN_URL |
|
1422 | - ), |
|
1423 | - 'view_pending_payment_reg_url' => add_query_arg( |
|
1424 | - array( |
|
1425 | - 'action' => 'default', |
|
1426 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1427 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1428 | - ), |
|
1429 | - REG_ADMIN_URL |
|
1430 | - ), |
|
1431 | - 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1432 | - 'Registration', |
|
1433 | - $approved_query_args |
|
1434 | - ), |
|
1435 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1436 | - 'Registration', |
|
1437 | - $not_approved_query_args |
|
1438 | - ), |
|
1439 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1440 | - 'Registration', |
|
1441 | - $pending_payment_query_args |
|
1442 | - ), |
|
1443 | - 'misc_pub_section_class' => apply_filters( |
|
1444 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1445 | - 'misc-pub-section' |
|
1446 | - ), |
|
1447 | - //'email_attendees_url' => add_query_arg( |
|
1448 | - // array( |
|
1449 | - // 'event_admin_reports' => 'event_newsletter', |
|
1450 | - // 'event_id' => $this->_cpt_model_obj->id |
|
1451 | - // ), |
|
1452 | - // 'admin.php?page=espresso_registrations' |
|
1453 | - //), |
|
1454 | - ); |
|
1455 | - ob_start(); |
|
1456 | - do_action( |
|
1457 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1458 | - $this->_cpt_model_obj |
|
1459 | - ); |
|
1460 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1461 | - // load template |
|
1462 | - EEH_Template::display_template( |
|
1463 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1464 | - $publish_box_extra_args |
|
1465 | - ); |
|
1466 | - } |
|
1467 | - |
|
1468 | - |
|
1469 | - |
|
1470 | - /** |
|
1471 | - * This just returns whatever is set as the _event object property |
|
1472 | - * //todo this will become obsolete once the models are in place |
|
1473 | - * |
|
1474 | - * @return object |
|
1475 | - */ |
|
1476 | - public function get_event_object() |
|
1477 | - { |
|
1478 | - return $this->_cpt_model_obj; |
|
1479 | - } |
|
1480 | - |
|
1481 | - |
|
1482 | - |
|
1483 | - |
|
1484 | - /** METABOXES * */ |
|
1485 | - /** |
|
1486 | - * _register_event_editor_meta_boxes |
|
1487 | - * add all metaboxes related to the event_editor |
|
1488 | - * |
|
1489 | - * @return void |
|
1490 | - */ |
|
1491 | - protected function _register_event_editor_meta_boxes() |
|
1492 | - { |
|
1493 | - $this->verify_cpt_object(); |
|
1494 | - add_meta_box( |
|
1495 | - 'espresso_event_editor_tickets', |
|
1496 | - esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1497 | - array($this, 'ticket_metabox'), |
|
1498 | - $this->page_slug, |
|
1499 | - 'normal', |
|
1500 | - 'high' |
|
1501 | - ); |
|
1502 | - add_meta_box( |
|
1503 | - 'espresso_event_editor_event_options', |
|
1504 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
1505 | - array($this, 'registration_options_meta_box'), |
|
1506 | - $this->page_slug, |
|
1507 | - 'side', |
|
1508 | - 'default' |
|
1509 | - ); |
|
1510 | - // NOTE: if you're looking for other metaboxes in here, |
|
1511 | - // where a metabox has a related management page in the admin |
|
1512 | - // you will find it setup in the related management page's "_Hooks" file. |
|
1513 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1514 | - } |
|
1515 | - |
|
1516 | - |
|
1517 | - |
|
1518 | - public function ticket_metabox() |
|
1519 | - { |
|
1520 | - $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1521 | - //defaults for template args |
|
1522 | - $template_args = array( |
|
1523 | - 'existing_datetime_ids' => '', |
|
1524 | - 'event_datetime_help_link' => '', |
|
1525 | - 'ticket_options_help_link' => '', |
|
1526 | - 'time' => null, |
|
1527 | - 'ticket_rows' => '', |
|
1528 | - 'existing_ticket_ids' => '', |
|
1529 | - 'total_ticket_rows' => 1, |
|
1530 | - 'ticket_js_structure' => '', |
|
1531 | - 'trash_icon' => 'ee-lock-icon', |
|
1532 | - 'disabled' => '', |
|
1533 | - ); |
|
1534 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1535 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1536 | - /** |
|
1537 | - * 1. Start with retrieving Datetimes |
|
1538 | - * 2. Fore each datetime get related tickets |
|
1539 | - * 3. For each ticket get related prices |
|
1540 | - */ |
|
1541 | - $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1542 | - /** @type EE_Datetime $first_datetime */ |
|
1543 | - $first_datetime = reset($times); |
|
1544 | - //do we get related tickets? |
|
1545 | - if ($first_datetime instanceof EE_Datetime |
|
1546 | - && $first_datetime->ID() !== 0 |
|
1547 | - ) { |
|
1548 | - $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1549 | - $template_args['time'] = $first_datetime; |
|
1550 | - $related_tickets = $first_datetime->tickets( |
|
1551 | - array( |
|
1552 | - array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1553 | - 'default_where_conditions' => 'none', |
|
1554 | - ) |
|
1555 | - ); |
|
1556 | - if ( ! empty($related_tickets)) { |
|
1557 | - $template_args['total_ticket_rows'] = count($related_tickets); |
|
1558 | - $row = 0; |
|
1559 | - foreach ($related_tickets as $ticket) { |
|
1560 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1561 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1562 | - $row++; |
|
1563 | - } |
|
1564 | - } else { |
|
1565 | - $template_args['total_ticket_rows'] = 1; |
|
1566 | - /** @type EE_Ticket $ticket */ |
|
1567 | - $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1568 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1569 | - } |
|
1570 | - } else { |
|
1571 | - $template_args['time'] = $times[0]; |
|
1572 | - /** @type EE_Ticket $ticket */ |
|
1573 | - $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1574 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1575 | - // NOTE: we're just sending the first default row |
|
1576 | - // (decaf can't manage default tickets so this should be sufficient); |
|
1577 | - } |
|
1578 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1579 | - 'event_editor_event_datetimes_help_tab' |
|
1580 | - ); |
|
1581 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1582 | - $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1583 | - $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1584 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1585 | - EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1586 | - true |
|
1587 | - ); |
|
1588 | - $template = apply_filters( |
|
1589 | - 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1590 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1591 | - ); |
|
1592 | - EEH_Template::display_template($template, $template_args); |
|
1593 | - } |
|
1594 | - |
|
1595 | - |
|
1596 | - |
|
1597 | - /** |
|
1598 | - * Setup an individual ticket form for the decaf event editor page |
|
1599 | - * |
|
1600 | - * @access private |
|
1601 | - * @param EE_Ticket $ticket the ticket object |
|
1602 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1603 | - * @param int $row |
|
1604 | - * @return string generated html for the ticket row. |
|
1605 | - */ |
|
1606 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1607 | - { |
|
1608 | - $template_args = array( |
|
1609 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1610 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1611 | - : '', |
|
1612 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1613 | - 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1614 | - 'TKT_name' => $ticket->get('TKT_name'), |
|
1615 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1616 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1617 | - 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1618 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1619 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1620 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1621 | - 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1622 | - && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1623 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1624 | - 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1625 | - : ' disabled=disabled', |
|
1626 | - ); |
|
1627 | - $price = $ticket->ID() !== 0 |
|
1628 | - ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1629 | - : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1630 | - $price_args = array( |
|
1631 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1632 | - 'PRC_amount' => $price->get('PRC_amount'), |
|
1633 | - 'PRT_ID' => $price->get('PRT_ID'), |
|
1634 | - 'PRC_ID' => $price->get('PRC_ID'), |
|
1635 | - 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1636 | - ); |
|
1637 | - //make sure we have default start and end dates if skeleton |
|
1638 | - //handle rows that should NOT be empty |
|
1639 | - if (empty($template_args['TKT_start_date'])) { |
|
1640 | - //if empty then the start date will be now. |
|
1641 | - $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1642 | - } |
|
1643 | - if (empty($template_args['TKT_end_date'])) { |
|
1644 | - //get the earliest datetime (if present); |
|
1645 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1646 | - ? $this->_cpt_model_obj->get_first_related( |
|
1647 | - 'Datetime', |
|
1648 | - array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1649 | - ) |
|
1650 | - : null; |
|
1651 | - if ( ! empty($earliest_dtt)) { |
|
1652 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1653 | - } else { |
|
1654 | - $template_args['TKT_end_date'] = date( |
|
1655 | - 'Y-m-d h:i a', |
|
1656 | - mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1657 | - ); |
|
1658 | - } |
|
1659 | - } |
|
1660 | - $template_args = array_merge($template_args, $price_args); |
|
1661 | - $template = apply_filters( |
|
1662 | - 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1663 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1664 | - $ticket |
|
1665 | - ); |
|
1666 | - return EEH_Template::display_template($template, $template_args, true); |
|
1667 | - } |
|
1668 | - |
|
1669 | - |
|
1670 | - |
|
1671 | - public function registration_options_meta_box() |
|
1672 | - { |
|
1673 | - $yes_no_values = array( |
|
1674 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1675 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1676 | - ); |
|
1677 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1678 | - array( |
|
1679 | - EEM_Registration::status_id_cancelled, |
|
1680 | - EEM_Registration::status_id_declined, |
|
1681 | - EEM_Registration::status_id_incomplete, |
|
1682 | - ), |
|
1683 | - true |
|
1684 | - ); |
|
1685 | - //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1686 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
1687 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1688 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1689 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1690 | - 'default_reg_status', |
|
1691 | - $default_reg_status_values, |
|
1692 | - $this->_cpt_model_obj->default_registration_status() |
|
1693 | - ); |
|
1694 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1695 | - 'display_desc', |
|
1696 | - $yes_no_values, |
|
1697 | - $this->_cpt_model_obj->display_description() |
|
1698 | - ); |
|
1699 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1700 | - 'display_ticket_selector', |
|
1701 | - $yes_no_values, |
|
1702 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
1703 | - '', |
|
1704 | - '', |
|
1705 | - false |
|
1706 | - ); |
|
1707 | - $template_args['additional_registration_options'] = apply_filters( |
|
1708 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1709 | - '', |
|
1710 | - $template_args, |
|
1711 | - $yes_no_values, |
|
1712 | - $default_reg_status_values |
|
1713 | - ); |
|
1714 | - EEH_Template::display_template( |
|
1715 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1716 | - $template_args |
|
1717 | - ); |
|
1718 | - } |
|
1719 | - |
|
1720 | - |
|
1721 | - |
|
1722 | - /** |
|
1723 | - * _get_events() |
|
1724 | - * This method simply returns all the events (for the given _view and paging) |
|
1725 | - * |
|
1726 | - * @access public |
|
1727 | - * @param int $per_page count of items per page (20 default); |
|
1728 | - * @param int $current_page what is the current page being viewed. |
|
1729 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1730 | - * If FALSE then we return an array of event objects |
|
1731 | - * that match the given _view and paging parameters. |
|
1732 | - * @return array an array of event objects. |
|
1733 | - */ |
|
1734 | - public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1735 | - { |
|
1736 | - $EEME = $this->_event_model(); |
|
1737 | - $offset = ($current_page - 1) * $per_page; |
|
1738 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1739 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1740 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1741 | - if (isset($this->_req_data['month_range'])) { |
|
1742 | - $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1743 | - $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1744 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1745 | - } |
|
1746 | - $where = array(); |
|
1747 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1748 | - //determine what post_status our condition will have for the query. |
|
1749 | - switch ($status) { |
|
1750 | - case 'month' : |
|
1751 | - case 'today' : |
|
1752 | - case null : |
|
1753 | - case 'all' : |
|
1754 | - break; |
|
1755 | - case 'draft' : |
|
1756 | - $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1757 | - break; |
|
1758 | - default : |
|
1759 | - $where['status'] = $status; |
|
1760 | - } |
|
1761 | - //categories? |
|
1762 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1763 | - ? $this->_req_data['EVT_CAT'] : null; |
|
1764 | - if ( ! empty ($category)) { |
|
1765 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1766 | - $where['Term_Taxonomy.term_id'] = $category; |
|
1767 | - } |
|
1768 | - //date where conditions |
|
1769 | - $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1770 | - if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1771 | - $DateTime = new DateTime( |
|
1772 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1773 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1774 | - ); |
|
1775 | - $start = $DateTime->format(implode(' ', $start_formats)); |
|
1776 | - $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
1777 | - ->format('t'))->setTime(23, 59, 59) |
|
1778 | - ->format(implode(' ', $start_formats)); |
|
1779 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1780 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1781 | - $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1782 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1783 | - $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1784 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1785 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1786 | - $now = date('Y-m-01'); |
|
1787 | - $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1788 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1789 | - $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1790 | - ->setTime(23, 59, 59) |
|
1791 | - ->format(implode(' ', $start_formats)); |
|
1792 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1793 | - } |
|
1794 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1795 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1796 | - } else { |
|
1797 | - if ( ! isset($where['status'])) { |
|
1798 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1799 | - $where['OR'] = array( |
|
1800 | - 'status*restrict_private' => array('!=', 'private'), |
|
1801 | - 'AND' => array( |
|
1802 | - 'status*inclusive' => array('=', 'private'), |
|
1803 | - 'EVT_wp_user' => get_current_user_id(), |
|
1804 | - ), |
|
1805 | - ); |
|
1806 | - } |
|
1807 | - } |
|
1808 | - } |
|
1809 | - if (isset($this->_req_data['EVT_wp_user'])) { |
|
1810 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1811 | - && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1812 | - ) { |
|
1813 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1814 | - } |
|
1815 | - } |
|
1816 | - //search query handling |
|
1817 | - if (isset($this->_req_data['s'])) { |
|
1818 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1819 | - $where['OR'] = array( |
|
1820 | - 'EVT_name' => array('LIKE', $search_string), |
|
1821 | - 'EVT_desc' => array('LIKE', $search_string), |
|
1822 | - 'EVT_short_desc' => array('LIKE', $search_string), |
|
1823 | - ); |
|
1824 | - } |
|
1825 | - $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1826 | - $query_params = apply_filters( |
|
1827 | - 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1828 | - array( |
|
1829 | - $where, |
|
1830 | - 'limit' => $limit, |
|
1831 | - 'order_by' => $orderby, |
|
1832 | - 'order' => $order, |
|
1833 | - 'group_by' => 'EVT_ID', |
|
1834 | - ), |
|
1835 | - $this->_req_data |
|
1836 | - ); |
|
1837 | - //let's first check if we have special requests coming in. |
|
1838 | - if (isset($this->_req_data['active_status'])) { |
|
1839 | - switch ($this->_req_data['active_status']) { |
|
1840 | - case 'upcoming' : |
|
1841 | - return $EEME->get_upcoming_events($query_params, $count); |
|
1842 | - break; |
|
1843 | - case 'expired' : |
|
1844 | - return $EEME->get_expired_events($query_params, $count); |
|
1845 | - break; |
|
1846 | - case 'active' : |
|
1847 | - return $EEME->get_active_events($query_params, $count); |
|
1848 | - break; |
|
1849 | - case 'inactive' : |
|
1850 | - return $EEME->get_inactive_events($query_params, $count); |
|
1851 | - break; |
|
1852 | - } |
|
1853 | - } |
|
1854 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1855 | - return $events; |
|
1856 | - } |
|
1857 | - |
|
1858 | - |
|
1859 | - |
|
1860 | - /** |
|
1861 | - * handling for WordPress CPT actions (trash, restore, delete) |
|
1862 | - * |
|
1863 | - * @param string $post_id |
|
1864 | - */ |
|
1865 | - public function trash_cpt_item($post_id) |
|
1866 | - { |
|
1867 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1868 | - $this->_trash_or_restore_event('trash', false); |
|
1869 | - } |
|
1870 | - |
|
1871 | - |
|
1872 | - |
|
1873 | - /** |
|
1874 | - * @param string $post_id |
|
1875 | - */ |
|
1876 | - public function restore_cpt_item($post_id) |
|
1877 | - { |
|
1878 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1879 | - $this->_trash_or_restore_event('draft', false); |
|
1880 | - } |
|
1881 | - |
|
1882 | - |
|
1883 | - |
|
1884 | - /** |
|
1885 | - * @param string $post_id |
|
1886 | - */ |
|
1887 | - public function delete_cpt_item($post_id) |
|
1888 | - { |
|
1889 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1890 | - $this->_delete_event(false); |
|
1891 | - } |
|
1892 | - |
|
1893 | - |
|
1894 | - |
|
1895 | - /** |
|
1896 | - * _trash_or_restore_event |
|
1897 | - * |
|
1898 | - * @access protected |
|
1899 | - * @param string $event_status |
|
1900 | - * @param bool $redirect_after |
|
1901 | - */ |
|
1902 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1903 | - { |
|
1904 | - //determine the event id and set to array. |
|
1905 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1906 | - // loop thru events |
|
1907 | - if ($EVT_ID) { |
|
1908 | - // clean status |
|
1909 | - $event_status = sanitize_key($event_status); |
|
1910 | - // grab status |
|
1911 | - if ( ! empty($event_status)) { |
|
1912 | - $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1913 | - } else { |
|
1914 | - $success = false; |
|
1915 | - $msg = esc_html__( |
|
1916 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1917 | - 'event_espresso' |
|
1918 | - ); |
|
1919 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1920 | - } |
|
1921 | - } else { |
|
1922 | - $success = false; |
|
1923 | - $msg = esc_html__( |
|
1924 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1925 | - 'event_espresso' |
|
1926 | - ); |
|
1927 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1928 | - } |
|
1929 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1930 | - if ($redirect_after) { |
|
1931 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1932 | - } |
|
1933 | - } |
|
1934 | - |
|
1935 | - |
|
1936 | - |
|
1937 | - /** |
|
1938 | - * _trash_or_restore_events |
|
1939 | - * |
|
1940 | - * @access protected |
|
1941 | - * @param string $event_status |
|
1942 | - * @return void |
|
1943 | - */ |
|
1944 | - protected function _trash_or_restore_events($event_status = 'trash') |
|
1945 | - { |
|
1946 | - // clean status |
|
1947 | - $event_status = sanitize_key($event_status); |
|
1948 | - // grab status |
|
1949 | - if ( ! empty($event_status)) { |
|
1950 | - $success = true; |
|
1951 | - //determine the event id and set to array. |
|
1952 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1953 | - // loop thru events |
|
1954 | - foreach ($EVT_IDs as $EVT_ID) { |
|
1955 | - if ($EVT_ID = absint($EVT_ID)) { |
|
1956 | - $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1957 | - $success = $results !== false ? $success : false; |
|
1958 | - } else { |
|
1959 | - $msg = sprintf( |
|
1960 | - esc_html__( |
|
1961 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1962 | - 'event_espresso' |
|
1963 | - ), |
|
1964 | - $EVT_ID |
|
1965 | - ); |
|
1966 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1967 | - $success = false; |
|
1968 | - } |
|
1969 | - } |
|
1970 | - } else { |
|
1971 | - $success = false; |
|
1972 | - $msg = esc_html__( |
|
1973 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1974 | - 'event_espresso' |
|
1975 | - ); |
|
1976 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1977 | - } |
|
1978 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1979 | - $success = $success ? 2 : false; |
|
1980 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1981 | - $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1982 | - } |
|
1983 | - |
|
1984 | - |
|
1985 | - |
|
1986 | - /** |
|
1987 | - * _trash_or_restore_events |
|
1988 | - * |
|
1989 | - * @access private |
|
1990 | - * @param int $EVT_ID |
|
1991 | - * @param string $event_status |
|
1992 | - * @return bool |
|
1993 | - */ |
|
1994 | - private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1995 | - { |
|
1996 | - // grab event id |
|
1997 | - if ( ! $EVT_ID) { |
|
1998 | - $msg = esc_html__( |
|
1999 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2000 | - 'event_espresso' |
|
2001 | - ); |
|
2002 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2003 | - return false; |
|
2004 | - } |
|
2005 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2006 | - // clean status |
|
2007 | - $event_status = sanitize_key($event_status); |
|
2008 | - // grab status |
|
2009 | - if (empty($event_status)) { |
|
2010 | - $msg = esc_html__( |
|
2011 | - 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
2012 | - 'event_espresso' |
|
2013 | - ); |
|
2014 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2015 | - return false; |
|
2016 | - } |
|
2017 | - // was event trashed or restored ? |
|
2018 | - switch ($event_status) { |
|
2019 | - case 'draft' : |
|
2020 | - $action = 'restored from the trash'; |
|
2021 | - $hook = 'AHEE_event_restored_from_trash'; |
|
2022 | - break; |
|
2023 | - case 'trash' : |
|
2024 | - $action = 'moved to the trash'; |
|
2025 | - $hook = 'AHEE_event_moved_to_trash'; |
|
2026 | - break; |
|
2027 | - default : |
|
2028 | - $action = 'updated'; |
|
2029 | - $hook = false; |
|
2030 | - } |
|
2031 | - //use class to change status |
|
2032 | - $this->_cpt_model_obj->set_status($event_status); |
|
2033 | - $success = $this->_cpt_model_obj->save(); |
|
2034 | - if ($success === false) { |
|
2035 | - $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2036 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2037 | - return false; |
|
2038 | - } |
|
2039 | - if ($hook) { |
|
2040 | - do_action($hook); |
|
2041 | - } |
|
2042 | - return true; |
|
2043 | - } |
|
2044 | - |
|
2045 | - |
|
2046 | - |
|
2047 | - /** |
|
2048 | - * _delete_event |
|
2049 | - * |
|
2050 | - * @access protected |
|
2051 | - * @param bool $redirect_after |
|
2052 | - */ |
|
2053 | - protected function _delete_event($redirect_after = true) |
|
2054 | - { |
|
2055 | - //determine the event id and set to array. |
|
2056 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2057 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2058 | - // loop thru events |
|
2059 | - if ($EVT_ID) { |
|
2060 | - $success = $this->_permanently_delete_event($EVT_ID); |
|
2061 | - // get list of events with no prices |
|
2062 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2063 | - // remove this event from the list of events with no prices |
|
2064 | - if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2065 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2066 | - } |
|
2067 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2068 | - } else { |
|
2069 | - $success = false; |
|
2070 | - $msg = esc_html__( |
|
2071 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2072 | - 'event_espresso' |
|
2073 | - ); |
|
2074 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2075 | - } |
|
2076 | - if ($redirect_after) { |
|
2077 | - $this->_redirect_after_action( |
|
2078 | - $success, |
|
2079 | - 'Event', |
|
2080 | - 'deleted', |
|
2081 | - array('action' => 'default', 'status' => 'trash') |
|
2082 | - ); |
|
2083 | - } |
|
2084 | - } |
|
2085 | - |
|
2086 | - |
|
2087 | - |
|
2088 | - /** |
|
2089 | - * _delete_events |
|
2090 | - * |
|
2091 | - * @access protected |
|
2092 | - * @return void |
|
2093 | - */ |
|
2094 | - protected function _delete_events() |
|
2095 | - { |
|
2096 | - $success = true; |
|
2097 | - // get list of events with no prices |
|
2098 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2099 | - //determine the event id and set to array. |
|
2100 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2101 | - // loop thru events |
|
2102 | - foreach ($EVT_IDs as $EVT_ID) { |
|
2103 | - $EVT_ID = absint($EVT_ID); |
|
2104 | - if ($EVT_ID) { |
|
2105 | - $results = $this->_permanently_delete_event($EVT_ID); |
|
2106 | - $success = $results !== false ? $success : false; |
|
2107 | - // remove this event from the list of events with no prices |
|
2108 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2109 | - } else { |
|
2110 | - $success = false; |
|
2111 | - $msg = esc_html__( |
|
2112 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2113 | - 'event_espresso' |
|
2114 | - ); |
|
2115 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2116 | - } |
|
2117 | - } |
|
2118 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2119 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2120 | - $success = $success ? 2 : false; |
|
2121 | - $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2122 | - } |
|
2123 | - |
|
2124 | - |
|
2125 | - |
|
2126 | - /** |
|
2127 | - * _permanently_delete_event |
|
2128 | - * |
|
2129 | - * @access private |
|
2130 | - * @param int $EVT_ID |
|
2131 | - * @return bool |
|
2132 | - */ |
|
2133 | - private function _permanently_delete_event($EVT_ID = 0) |
|
2134 | - { |
|
2135 | - // grab event id |
|
2136 | - if ( ! $EVT_ID) { |
|
2137 | - $msg = esc_html__( |
|
2138 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2139 | - 'event_espresso' |
|
2140 | - ); |
|
2141 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2142 | - return false; |
|
2143 | - } |
|
2144 | - if ( |
|
2145 | - ! $this->_cpt_model_obj instanceof EE_Event |
|
2146 | - || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2147 | - ) { |
|
2148 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2149 | - } |
|
2150 | - if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2151 | - return false; |
|
2152 | - } |
|
2153 | - //need to delete related tickets and prices first. |
|
2154 | - $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2155 | - foreach ($datetimes as $datetime) { |
|
2156 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2157 | - $tickets = $datetime->get_many_related('Ticket'); |
|
2158 | - foreach ($tickets as $ticket) { |
|
2159 | - $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2160 | - $ticket->delete_related_permanently('Price'); |
|
2161 | - $ticket->delete_permanently(); |
|
2162 | - } |
|
2163 | - $datetime->delete(); |
|
2164 | - } |
|
2165 | - //what about related venues or terms? |
|
2166 | - $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2167 | - foreach ($venues as $venue) { |
|
2168 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2169 | - } |
|
2170 | - //any attached question groups? |
|
2171 | - $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2172 | - if ( ! empty($question_groups)) { |
|
2173 | - foreach ($question_groups as $question_group) { |
|
2174 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2175 | - } |
|
2176 | - } |
|
2177 | - //Message Template Groups |
|
2178 | - $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2179 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2180 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2181 | - foreach ($term_taxonomies as $term_taxonomy) { |
|
2182 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2183 | - } |
|
2184 | - $success = $this->_cpt_model_obj->delete_permanently(); |
|
2185 | - // did it all go as planned ? |
|
2186 | - if ($success) { |
|
2187 | - $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2188 | - EE_Error::add_success($msg); |
|
2189 | - } else { |
|
2190 | - $msg = sprintf( |
|
2191 | - esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2192 | - $EVT_ID |
|
2193 | - ); |
|
2194 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2195 | - return false; |
|
2196 | - } |
|
2197 | - do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2198 | - return true; |
|
2199 | - } |
|
2200 | - |
|
2201 | - |
|
2202 | - |
|
2203 | - /** |
|
2204 | - * get total number of events |
|
2205 | - * |
|
2206 | - * @access public |
|
2207 | - * @return int |
|
2208 | - */ |
|
2209 | - public function total_events() |
|
2210 | - { |
|
2211 | - $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2212 | - return $count; |
|
2213 | - } |
|
2214 | - |
|
2215 | - |
|
2216 | - |
|
2217 | - /** |
|
2218 | - * get total number of draft events |
|
2219 | - * |
|
2220 | - * @access public |
|
2221 | - * @return int |
|
2222 | - */ |
|
2223 | - public function total_events_draft() |
|
2224 | - { |
|
2225 | - $where = array( |
|
2226 | - 'status' => array('IN', array('draft', 'auto-draft')), |
|
2227 | - ); |
|
2228 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2229 | - return $count; |
|
2230 | - } |
|
2231 | - |
|
2232 | - |
|
2233 | - |
|
2234 | - /** |
|
2235 | - * get total number of trashed events |
|
2236 | - * |
|
2237 | - * @access public |
|
2238 | - * @return int |
|
2239 | - */ |
|
2240 | - public function total_trashed_events() |
|
2241 | - { |
|
2242 | - $where = array( |
|
2243 | - 'status' => 'trash', |
|
2244 | - ); |
|
2245 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2246 | - return $count; |
|
2247 | - } |
|
2248 | - |
|
2249 | - |
|
2250 | - |
|
2251 | - /** |
|
2252 | - * _default_event_settings |
|
2253 | - * This generates the Default Settings Tab |
|
2254 | - * |
|
2255 | - * @return void |
|
2256 | - */ |
|
2257 | - protected function _default_event_settings() |
|
2258 | - { |
|
2259 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
2260 | - $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2261 | - // exclude array |
|
2262 | - array( |
|
2263 | - EEM_Registration::status_id_cancelled, |
|
2264 | - EEM_Registration::status_id_declined, |
|
2265 | - EEM_Registration::status_id_incomplete, |
|
2266 | - EEM_Registration::status_id_wait_list, |
|
2267 | - ), |
|
2268 | - // translated |
|
2269 | - true |
|
2270 | - ); |
|
2271 | - $this->_template_args['default_reg_status'] = isset( |
|
2272 | - EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2273 | - ) |
|
2274 | - && array_key_exists( |
|
2275 | - EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2276 | - $this->_template_args['reg_status_array'] |
|
2277 | - ) |
|
2278 | - ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2279 | - : EEM_Registration::status_id_pending_payment; |
|
2280 | - $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2281 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2282 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2283 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2284 | - $this->_template_args, |
|
2285 | - true |
|
2286 | - ); |
|
2287 | - $this->display_admin_page_with_sidebar(); |
|
2288 | - } |
|
2289 | - |
|
2290 | - |
|
2291 | - |
|
2292 | - /** |
|
2293 | - * _update_default_event_settings |
|
2294 | - * |
|
2295 | - * @access protected |
|
2296 | - * @return void |
|
2297 | - */ |
|
2298 | - protected function _update_default_event_settings() |
|
2299 | - { |
|
2300 | - EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2301 | - ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2302 | - : EEM_Registration::status_id_pending_payment; |
|
2303 | - $what = 'Default Event Settings'; |
|
2304 | - $success = $this->_update_espresso_configuration( |
|
2305 | - $what, |
|
2306 | - EE_Config::instance(), |
|
2307 | - __FILE__, |
|
2308 | - __FUNCTION__, |
|
2309 | - __LINE__ |
|
2310 | - ); |
|
2311 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2312 | - } |
|
2313 | - |
|
2314 | - |
|
2315 | - |
|
2316 | - /************* Templates *************/ |
|
2317 | - protected function _template_settings() |
|
2318 | - { |
|
2319 | - $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2320 | - $this->_template_args['preview_img'] = '<img src="' |
|
2321 | - . EVENTS_ASSETS_URL |
|
2322 | - . DS |
|
2323 | - . 'images' |
|
2324 | - . DS |
|
2325 | - . 'caffeinated_template_features.jpg" alt="' |
|
2326 | - . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2327 | - . '" />'; |
|
2328 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2329 | - '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.', |
|
2330 | - 'event_espresso' |
|
2331 | - ) . '</strong>'; |
|
2332 | - $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2333 | - } |
|
2334 | - |
|
2335 | - |
|
2336 | - /** Event Category Stuff **/ |
|
2337 | - /** |
|
2338 | - * set the _category property with the category object for the loaded page. |
|
2339 | - * |
|
2340 | - * @access private |
|
2341 | - * @return void |
|
2342 | - */ |
|
2343 | - private function _set_category_object() |
|
2344 | - { |
|
2345 | - if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2346 | - return; |
|
2347 | - } //already have the category object so get out. |
|
2348 | - //set default category object |
|
2349 | - $this->_set_empty_category_object(); |
|
2350 | - //only set if we've got an id |
|
2351 | - if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2352 | - return; |
|
2353 | - } |
|
2354 | - $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2355 | - $term = get_term($category_id, 'espresso_event_categories'); |
|
2356 | - if ( ! empty($term)) { |
|
2357 | - $this->_category->category_name = $term->name; |
|
2358 | - $this->_category->category_identifier = $term->slug; |
|
2359 | - $this->_category->category_desc = $term->description; |
|
2360 | - $this->_category->id = $term->term_id; |
|
2361 | - $this->_category->parent = $term->parent; |
|
2362 | - } |
|
2363 | - } |
|
2364 | - |
|
2365 | - |
|
2366 | - |
|
2367 | - private function _set_empty_category_object() |
|
2368 | - { |
|
2369 | - $this->_category = new stdClass(); |
|
2370 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2371 | - $this->_category->id = $this->_category->parent = 0; |
|
2372 | - } |
|
2373 | - |
|
2374 | - |
|
2375 | - |
|
2376 | - protected function _category_list_table() |
|
2377 | - { |
|
2378 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2379 | - $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2380 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2381 | - 'add_category', |
|
2382 | - 'add_category', |
|
2383 | - array(), |
|
2384 | - 'add-new-h2' |
|
2385 | - ); |
|
2386 | - $this->display_admin_list_table_page_with_sidebar(); |
|
2387 | - } |
|
2388 | - |
|
2389 | - |
|
2390 | - |
|
2391 | - /** |
|
2392 | - * @param $view |
|
2393 | - */ |
|
2394 | - protected function _category_details($view) |
|
2395 | - { |
|
2396 | - //load formatter helper |
|
2397 | - //load field generator helper |
|
2398 | - $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2399 | - $this->_set_add_edit_form_tags($route); |
|
2400 | - $this->_set_category_object(); |
|
2401 | - $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2402 | - $delete_action = 'delete_category'; |
|
2403 | - //custom redirect |
|
2404 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2405 | - array('action' => 'category_list'), |
|
2406 | - $this->_admin_base_url |
|
2407 | - ); |
|
2408 | - $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2409 | - //take care of contents |
|
2410 | - $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2411 | - $this->display_admin_page_with_sidebar(); |
|
2412 | - } |
|
2413 | - |
|
2414 | - |
|
2415 | - |
|
2416 | - /** |
|
2417 | - * @return mixed |
|
2418 | - */ |
|
2419 | - protected function _category_details_content() |
|
2420 | - { |
|
2421 | - $editor_args['category_desc'] = array( |
|
2422 | - 'type' => 'wp_editor', |
|
2423 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2424 | - 'class' => 'my_editor_custom', |
|
2425 | - 'wpeditor_args' => array('media_buttons' => false), |
|
2426 | - ); |
|
2427 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2428 | - $all_terms = get_terms( |
|
2429 | - array('espresso_event_categories'), |
|
2430 | - array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2431 | - ); |
|
2432 | - //setup category select for term parents. |
|
2433 | - $category_select_values[] = array( |
|
2434 | - 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2435 | - 'id' => 0, |
|
2436 | - ); |
|
2437 | - foreach ($all_terms as $term) { |
|
2438 | - $category_select_values[] = array( |
|
2439 | - 'text' => $term->name, |
|
2440 | - 'id' => $term->term_id, |
|
2441 | - ); |
|
2442 | - } |
|
2443 | - $category_select = EEH_Form_Fields::select_input( |
|
2444 | - 'category_parent', |
|
2445 | - $category_select_values, |
|
2446 | - $this->_category->parent |
|
2447 | - ); |
|
2448 | - $template_args = array( |
|
2449 | - 'category' => $this->_category, |
|
2450 | - 'category_select' => $category_select, |
|
2451 | - 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2452 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2453 | - 'disable' => '', |
|
2454 | - 'disabled_message' => false, |
|
2455 | - ); |
|
2456 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2457 | - return EEH_Template::display_template($template, $template_args, true); |
|
2458 | - } |
|
2459 | - |
|
2460 | - |
|
2461 | - |
|
2462 | - protected function _delete_categories() |
|
2463 | - { |
|
2464 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2465 | - : (array)$this->_req_data['category_id']; |
|
2466 | - foreach ($cat_ids as $cat_id) { |
|
2467 | - $this->_delete_category($cat_id); |
|
2468 | - } |
|
2469 | - //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2470 | - $query_args = array( |
|
2471 | - 'action' => 'category_list', |
|
2472 | - ); |
|
2473 | - $this->_redirect_after_action(0, '', '', $query_args); |
|
2474 | - } |
|
2475 | - |
|
2476 | - |
|
2477 | - |
|
2478 | - /** |
|
2479 | - * @param $cat_id |
|
2480 | - */ |
|
2481 | - protected function _delete_category($cat_id) |
|
2482 | - { |
|
2483 | - $cat_id = absint($cat_id); |
|
2484 | - wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2485 | - } |
|
2486 | - |
|
2487 | - |
|
2488 | - |
|
2489 | - /** |
|
2490 | - * @param $new_category |
|
2491 | - */ |
|
2492 | - protected function _insert_or_update_category($new_category) |
|
2493 | - { |
|
2494 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2495 | - $success = 0; //we already have a success message so lets not send another. |
|
2496 | - if ($cat_id) { |
|
2497 | - $query_args = array( |
|
2498 | - 'action' => 'edit_category', |
|
2499 | - 'EVT_CAT_ID' => $cat_id, |
|
2500 | - ); |
|
2501 | - } else { |
|
2502 | - $query_args = array('action' => 'add_category'); |
|
2503 | - } |
|
2504 | - $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2505 | - } |
|
2506 | - |
|
2507 | - |
|
2508 | - |
|
2509 | - /** |
|
2510 | - * @param bool $update |
|
2511 | - * @return bool|mixed|string |
|
2512 | - */ |
|
2513 | - private function _insert_category($update = false) |
|
2514 | - { |
|
2515 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2516 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2517 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2518 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2519 | - if (empty($category_name)) { |
|
2520 | - $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2521 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2522 | - return false; |
|
2523 | - } |
|
2524 | - $term_args = array( |
|
2525 | - 'name' => $category_name, |
|
2526 | - 'description' => $category_desc, |
|
2527 | - 'parent' => $category_parent, |
|
2528 | - ); |
|
2529 | - //was the category_identifier input disabled? |
|
2530 | - if (isset($this->_req_data['category_identifier'])) { |
|
2531 | - $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2532 | - } |
|
2533 | - $insert_ids = $update |
|
2534 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2535 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2536 | - if ( ! is_array($insert_ids)) { |
|
2537 | - $msg = esc_html__( |
|
2538 | - 'An error occurred and the category has not been saved to the database.', |
|
2539 | - 'event_espresso' |
|
2540 | - ); |
|
2541 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2542 | - } else { |
|
2543 | - $cat_id = $insert_ids['term_id']; |
|
2544 | - $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2545 | - EE_Error::add_success($msg); |
|
2546 | - } |
|
2547 | - return $cat_id; |
|
2548 | - } |
|
2549 | - |
|
2550 | - |
|
2551 | - |
|
2552 | - /** |
|
2553 | - * @param int $per_page |
|
2554 | - * @param int $current_page |
|
2555 | - * @param bool $count |
|
2556 | - * @return \EE_Base_Class[]|int |
|
2557 | - */ |
|
2558 | - public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2559 | - { |
|
2560 | - //testing term stuff |
|
2561 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2562 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2563 | - $limit = ($current_page - 1) * $per_page; |
|
2564 | - $where = array('taxonomy' => 'espresso_event_categories'); |
|
2565 | - if (isset($this->_req_data['s'])) { |
|
2566 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2567 | - $where['OR'] = array( |
|
2568 | - 'Term.name' => array('LIKE', $sstr), |
|
2569 | - 'description' => array('LIKE', $sstr), |
|
2570 | - ); |
|
2571 | - } |
|
2572 | - $query_params = array( |
|
2573 | - $where, |
|
2574 | - 'order_by' => array($orderby => $order), |
|
2575 | - 'limit' => $limit . ',' . $per_page, |
|
2576 | - 'force_join' => array('Term'), |
|
2577 | - ); |
|
2578 | - $categories = $count |
|
2579 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2580 | - : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2581 | - return $categories; |
|
2582 | - } |
|
2583 | - |
|
2584 | - |
|
2585 | - |
|
2586 | - /* end category stuff */ |
|
2587 | - /**************/ |
|
385 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
386 | + 'require_nonce' => false, |
|
387 | + ), |
|
388 | + 'default_event_settings' => array( |
|
389 | + 'nav' => array( |
|
390 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
391 | + 'order' => 40, |
|
392 | + ), |
|
393 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
394 | + 'labels' => array( |
|
395 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
396 | + ), |
|
397 | + 'help_tabs' => array( |
|
398 | + 'default_settings_help_tab' => array( |
|
399 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
400 | + 'filename' => 'events_default_settings', |
|
401 | + ), |
|
402 | + 'default_settings_status_help_tab' => array( |
|
403 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
404 | + 'filename' => 'events_default_settings_status', |
|
405 | + ), |
|
406 | + ), |
|
407 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
408 | + 'require_nonce' => false, |
|
409 | + ), |
|
410 | + //template settings |
|
411 | + 'template_settings' => array( |
|
412 | + 'nav' => array( |
|
413 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
414 | + 'order' => 30, |
|
415 | + ), |
|
416 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
417 | + 'help_tabs' => array( |
|
418 | + 'general_settings_templates_help_tab' => array( |
|
419 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
420 | + 'filename' => 'general_settings_templates', |
|
421 | + ), |
|
422 | + ), |
|
423 | + 'help_tour' => array('Templates_Help_Tour'), |
|
424 | + 'require_nonce' => false, |
|
425 | + ), |
|
426 | + //event category stuff |
|
427 | + 'add_category' => array( |
|
428 | + 'nav' => array( |
|
429 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
430 | + 'order' => 15, |
|
431 | + 'persistent' => false, |
|
432 | + ), |
|
433 | + 'help_tabs' => array( |
|
434 | + 'add_category_help_tab' => array( |
|
435 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
436 | + 'filename' => 'events_add_category', |
|
437 | + ), |
|
438 | + ), |
|
439 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
440 | + 'metaboxes' => array('_publish_post_box'), |
|
441 | + 'require_nonce' => false, |
|
442 | + ), |
|
443 | + 'edit_category' => array( |
|
444 | + 'nav' => array( |
|
445 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
446 | + 'order' => 15, |
|
447 | + 'persistent' => false, |
|
448 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
449 | + ? add_query_arg( |
|
450 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
451 | + $this->_current_page_view_url |
|
452 | + ) |
|
453 | + : $this->_admin_base_url, |
|
454 | + ), |
|
455 | + 'help_tabs' => array( |
|
456 | + 'edit_category_help_tab' => array( |
|
457 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
458 | + 'filename' => 'events_edit_category', |
|
459 | + ), |
|
460 | + ), |
|
461 | + /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
462 | + 'metaboxes' => array('_publish_post_box'), |
|
463 | + 'require_nonce' => false, |
|
464 | + ), |
|
465 | + 'category_list' => array( |
|
466 | + 'nav' => array( |
|
467 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
468 | + 'order' => 20, |
|
469 | + ), |
|
470 | + 'list_table' => 'Event_Categories_Admin_List_Table', |
|
471 | + 'help_tabs' => array( |
|
472 | + 'events_categories_help_tab' => array( |
|
473 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
474 | + 'filename' => 'events_categories', |
|
475 | + ), |
|
476 | + 'events_categories_table_column_headings_help_tab' => array( |
|
477 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
478 | + 'filename' => 'events_categories_table_column_headings', |
|
479 | + ), |
|
480 | + 'events_categories_view_help_tab' => array( |
|
481 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
482 | + 'filename' => 'events_categories_views', |
|
483 | + ), |
|
484 | + 'events_categories_other_help_tab' => array( |
|
485 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
486 | + 'filename' => 'events_categories_other', |
|
487 | + ), |
|
488 | + ), |
|
489 | + 'help_tour' => array( |
|
490 | + 'Event_Categories_Help_Tour', |
|
491 | + ), |
|
492 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
493 | + 'require_nonce' => false, |
|
494 | + ), |
|
495 | + ); |
|
496 | + } |
|
497 | + |
|
498 | + |
|
499 | + |
|
500 | + protected function _add_screen_options() |
|
501 | + { |
|
502 | + //todo |
|
503 | + } |
|
504 | + |
|
505 | + |
|
506 | + |
|
507 | + protected function _add_screen_options_default() |
|
508 | + { |
|
509 | + $this->_per_page_screen_option(); |
|
510 | + } |
|
511 | + |
|
512 | + |
|
513 | + |
|
514 | + protected function _add_screen_options_category_list() |
|
515 | + { |
|
516 | + $page_title = $this->_admin_page_title; |
|
517 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
518 | + $this->_per_page_screen_option(); |
|
519 | + $this->_admin_page_title = $page_title; |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + |
|
524 | + protected function _add_feature_pointers() |
|
525 | + { |
|
526 | + //todo |
|
527 | + } |
|
528 | + |
|
529 | + |
|
530 | + |
|
531 | + public function load_scripts_styles() |
|
532 | + { |
|
533 | + wp_register_style( |
|
534 | + 'events-admin-css', |
|
535 | + EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
536 | + array(), |
|
537 | + EVENT_ESPRESSO_VERSION |
|
538 | + ); |
|
539 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
540 | + wp_enqueue_style('events-admin-css'); |
|
541 | + wp_enqueue_style('ee-cat-admin'); |
|
542 | + //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
543 | + //registers for all views |
|
544 | + //scripts |
|
545 | + wp_register_script( |
|
546 | + 'event_editor_js', |
|
547 | + EVENTS_ASSETS_URL . 'event_editor.js', |
|
548 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
549 | + EVENT_ESPRESSO_VERSION, |
|
550 | + true |
|
551 | + ); |
|
552 | + } |
|
553 | + |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * enqueuing scripts and styles specific to this view |
|
558 | + * |
|
559 | + * @return void |
|
560 | + */ |
|
561 | + public function load_scripts_styles_create_new() |
|
562 | + { |
|
563 | + $this->load_scripts_styles_edit(); |
|
564 | + } |
|
565 | + |
|
566 | + |
|
567 | + |
|
568 | + /** |
|
569 | + * enqueuing scripts and styles specific to this view |
|
570 | + * |
|
571 | + * @return void |
|
572 | + */ |
|
573 | + public function load_scripts_styles_edit() |
|
574 | + { |
|
575 | + //styles |
|
576 | + wp_enqueue_style('espresso-ui-theme'); |
|
577 | + wp_register_style( |
|
578 | + 'event-editor-css', |
|
579 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
580 | + array('ee-admin-css'), |
|
581 | + EVENT_ESPRESSO_VERSION |
|
582 | + ); |
|
583 | + wp_enqueue_style('event-editor-css'); |
|
584 | + //scripts |
|
585 | + wp_register_script( |
|
586 | + 'event-datetime-metabox', |
|
587 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
588 | + array('event_editor_js', 'ee-datepicker'), |
|
589 | + EVENT_ESPRESSO_VERSION |
|
590 | + ); |
|
591 | + wp_enqueue_script('event-datetime-metabox'); |
|
592 | + } |
|
593 | + |
|
594 | + |
|
595 | + |
|
596 | + public function load_scripts_styles_add_category() |
|
597 | + { |
|
598 | + $this->load_scripts_styles_edit_category(); |
|
599 | + } |
|
600 | + |
|
601 | + |
|
602 | + |
|
603 | + public function load_scripts_styles_edit_category() |
|
604 | + { |
|
605 | + } |
|
606 | + |
|
607 | + |
|
608 | + |
|
609 | + protected function _set_list_table_views_category_list() |
|
610 | + { |
|
611 | + $this->_views = array( |
|
612 | + 'all' => array( |
|
613 | + 'slug' => 'all', |
|
614 | + 'label' => esc_html__('All', 'event_espresso'), |
|
615 | + 'count' => 0, |
|
616 | + 'bulk_action' => array( |
|
617 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
618 | + ), |
|
619 | + ), |
|
620 | + ); |
|
621 | + } |
|
622 | + |
|
623 | + |
|
624 | + |
|
625 | + public function admin_init() |
|
626 | + { |
|
627 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
628 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
629 | + 'event_espresso' |
|
630 | + ); |
|
631 | + } |
|
632 | + |
|
633 | + |
|
634 | + |
|
635 | + //nothing needed for events with these methods. |
|
636 | + public function admin_notices() |
|
637 | + { |
|
638 | + } |
|
639 | + |
|
640 | + |
|
641 | + |
|
642 | + public function admin_footer_scripts() |
|
643 | + { |
|
644 | + } |
|
645 | + |
|
646 | + |
|
647 | + |
|
648 | + /** |
|
649 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
650 | + * warning (via EE_Error::add_error()); |
|
651 | + * |
|
652 | + * @param EE_Event $event Event object |
|
653 | + * @access public |
|
654 | + * @return void |
|
655 | + */ |
|
656 | + public function verify_event_edit($event = null) |
|
657 | + { |
|
658 | + // no event? |
|
659 | + if (empty($event)) { |
|
660 | + // set event |
|
661 | + $event = $this->_cpt_model_obj; |
|
662 | + } |
|
663 | + // STILL no event? |
|
664 | + if (empty ($event)) { |
|
665 | + return; |
|
666 | + } |
|
667 | + $orig_status = $event->status(); |
|
668 | + // first check if event is active. |
|
669 | + if ( |
|
670 | + $orig_status === EEM_Event::cancelled |
|
671 | + || $orig_status === EEM_Event::postponed |
|
672 | + || $event->is_expired() |
|
673 | + || $event->is_inactive() |
|
674 | + ) { |
|
675 | + return; |
|
676 | + } |
|
677 | + //made it here so it IS active... next check that any of the tickets are sold. |
|
678 | + if ($event->is_sold_out(true)) { |
|
679 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
680 | + EE_Error::add_attention( |
|
681 | + sprintf( |
|
682 | + esc_html__( |
|
683 | + '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.', |
|
684 | + 'event_espresso' |
|
685 | + ), |
|
686 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
687 | + ) |
|
688 | + ); |
|
689 | + } |
|
690 | + return; |
|
691 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
692 | + EE_Error::add_attention( |
|
693 | + sprintf( |
|
694 | + esc_html__( |
|
695 | + '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.', |
|
696 | + 'event_espresso' |
|
697 | + ), |
|
698 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
699 | + ) |
|
700 | + ); |
|
701 | + } |
|
702 | + //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
703 | + if ( ! $event->tickets_on_sale()) { |
|
704 | + return; |
|
705 | + } |
|
706 | + //made it here so show warning |
|
707 | + $this->_edit_event_warning(); |
|
708 | + } |
|
709 | + |
|
710 | + |
|
711 | + |
|
712 | + /** |
|
713 | + * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
714 | + * When needed, hook this into a EE_Error::add_error() notice. |
|
715 | + * |
|
716 | + * @access protected |
|
717 | + * @return void |
|
718 | + */ |
|
719 | + protected function _edit_event_warning() |
|
720 | + { |
|
721 | + // we don't want to add warnings during these requests |
|
722 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
723 | + return; |
|
724 | + } |
|
725 | + EE_Error::add_attention( |
|
726 | + esc_html__( |
|
727 | + 'Please be advised that this event has been published and is open for registrations on your website. If you update any registration-related details (i.e. custom questions, messages, tickets, datetimes, etc.) while a registration is in process, the registration process could be interrupted and result in errors for the person registering and potentially incorrect registration or transaction data inside Event Espresso. We recommend editing events during a period of slow traffic, or even temporarily changing the status of an event to "Draft" until your edits are complete.', |
|
728 | + 'event_espresso' |
|
729 | + ) |
|
730 | + ); |
|
731 | + } |
|
732 | + |
|
733 | + |
|
734 | + |
|
735 | + /** |
|
736 | + * When a user is creating a new event, notify them if they haven't set their timezone. |
|
737 | + * Otherwise, do the normal logic |
|
738 | + * |
|
739 | + * @return string |
|
740 | + * @throws \EE_Error |
|
741 | + */ |
|
742 | + protected function _create_new_cpt_item() |
|
743 | + { |
|
744 | + $gmt_offset = get_option('gmt_offset'); |
|
745 | + //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
746 | + if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
747 | + EE_Error::add_attention( |
|
748 | + sprintf( |
|
749 | + __( |
|
750 | + 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.', |
|
751 | + 'event_espresso' |
|
752 | + ), |
|
753 | + '<a href="' . admin_url('options-general.php') . '">', |
|
754 | + '</a>' |
|
755 | + ), |
|
756 | + __FILE__, |
|
757 | + __FUNCTION__, |
|
758 | + __LINE__ |
|
759 | + ); |
|
760 | + } |
|
761 | + return parent::_create_new_cpt_item(); |
|
762 | + } |
|
763 | + |
|
764 | + |
|
765 | + |
|
766 | + protected function _set_list_table_views_default() |
|
767 | + { |
|
768 | + $this->_views = array( |
|
769 | + 'all' => array( |
|
770 | + 'slug' => 'all', |
|
771 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
772 | + 'count' => 0, |
|
773 | + 'bulk_action' => array( |
|
774 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
775 | + ), |
|
776 | + ), |
|
777 | + 'draft' => array( |
|
778 | + 'slug' => 'draft', |
|
779 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
780 | + 'count' => 0, |
|
781 | + 'bulk_action' => array( |
|
782 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
783 | + ), |
|
784 | + ), |
|
785 | + ); |
|
786 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
787 | + $this->_views['trash'] = array( |
|
788 | + 'slug' => 'trash', |
|
789 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
790 | + 'count' => 0, |
|
791 | + 'bulk_action' => array( |
|
792 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
793 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
794 | + ), |
|
795 | + ); |
|
796 | + } |
|
797 | + } |
|
798 | + |
|
799 | + |
|
800 | + |
|
801 | + /** |
|
802 | + * @return array |
|
803 | + */ |
|
804 | + protected function _event_legend_items() |
|
805 | + { |
|
806 | + $items = array( |
|
807 | + 'view_details' => array( |
|
808 | + 'class' => 'dashicons dashicons-search', |
|
809 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
810 | + ), |
|
811 | + 'edit_event' => array( |
|
812 | + 'class' => 'ee-icon ee-icon-calendar-edit', |
|
813 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
814 | + ), |
|
815 | + 'view_attendees' => array( |
|
816 | + 'class' => 'dashicons dashicons-groups', |
|
817 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
818 | + ), |
|
819 | + ); |
|
820 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
821 | + $statuses = array( |
|
822 | + 'sold_out_status' => array( |
|
823 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
824 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
825 | + ), |
|
826 | + 'active_status' => array( |
|
827 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
828 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
829 | + ), |
|
830 | + 'upcoming_status' => array( |
|
831 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
832 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
833 | + ), |
|
834 | + 'postponed_status' => array( |
|
835 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
836 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
837 | + ), |
|
838 | + 'cancelled_status' => array( |
|
839 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
840 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
841 | + ), |
|
842 | + 'expired_status' => array( |
|
843 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
844 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
845 | + ), |
|
846 | + 'inactive_status' => array( |
|
847 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
848 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
849 | + ), |
|
850 | + ); |
|
851 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
852 | + return array_merge($items, $statuses); |
|
853 | + } |
|
854 | + |
|
855 | + |
|
856 | + |
|
857 | + /** |
|
858 | + * _event_model |
|
859 | + * |
|
860 | + * @return EEM_Event |
|
861 | + */ |
|
862 | + private function _event_model() |
|
863 | + { |
|
864 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
865 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
866 | + } |
|
867 | + return $this->_event_model; |
|
868 | + } |
|
869 | + |
|
870 | + |
|
871 | + |
|
872 | + /** |
|
873 | + * Adds extra buttons to the WP CPT permalink field row. |
|
874 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
875 | + * |
|
876 | + * @param string $return the current html |
|
877 | + * @param int $id the post id for the page |
|
878 | + * @param string $new_title What the title is |
|
879 | + * @param string $new_slug what the slug is |
|
880 | + * @return string The new html string for the permalink area |
|
881 | + */ |
|
882 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
883 | + { |
|
884 | + //make sure this is only when editing |
|
885 | + if ( ! empty($id)) { |
|
886 | + $post = get_post($id); |
|
887 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
888 | + . esc_html__('Shortcode', 'event_espresso') |
|
889 | + . '</a> '; |
|
890 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
891 | + . $post->ID |
|
892 | + . ']">'; |
|
893 | + } |
|
894 | + return $return; |
|
895 | + } |
|
896 | + |
|
897 | + |
|
898 | + |
|
899 | + /** |
|
900 | + * _events_overview_list_table |
|
901 | + * This contains the logic for showing the events_overview list |
|
902 | + * |
|
903 | + * @access protected |
|
904 | + * @return void |
|
905 | + * @throws \EE_Error |
|
906 | + */ |
|
907 | + protected function _events_overview_list_table() |
|
908 | + { |
|
909 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
910 | + $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
911 | + ? (array)$this->_template_args['after_list_table'] |
|
912 | + : array(); |
|
913 | + $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
914 | + . EEH_Template::get_button_or_link( |
|
915 | + get_post_type_archive_link('espresso_events'), |
|
916 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
917 | + 'button' |
|
918 | + ); |
|
919 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
920 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
921 | + 'create_new', |
|
922 | + 'add', |
|
923 | + array(), |
|
924 | + 'add-new-h2' |
|
925 | + ); |
|
926 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
927 | + } |
|
928 | + |
|
929 | + |
|
930 | + |
|
931 | + /** |
|
932 | + * this allows for extra misc actions in the default WP publish box |
|
933 | + * |
|
934 | + * @return void |
|
935 | + */ |
|
936 | + public function extra_misc_actions_publish_box() |
|
937 | + { |
|
938 | + $this->_generate_publish_box_extra_content(); |
|
939 | + } |
|
940 | + |
|
941 | + |
|
942 | + |
|
943 | + /** |
|
944 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
945 | + * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
946 | + * data. |
|
947 | + * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
948 | + * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
949 | + * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
950 | + * you handle this accordingly. |
|
951 | + * |
|
952 | + * @access protected |
|
953 | + * @abstract |
|
954 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
955 | + * @param object $post The post object of the cpt that was saved. |
|
956 | + * @return void |
|
957 | + */ |
|
958 | + protected function _insert_update_cpt_item($post_id, $post) |
|
959 | + { |
|
960 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
961 | + //get out we're not processing an event save. |
|
962 | + return; |
|
963 | + } |
|
964 | + $event_values = array( |
|
965 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
966 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
967 | + 'EVT_additional_limit' => min( |
|
968 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
969 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
970 | + ), |
|
971 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
972 | + ? $this->_req_data['EVT_default_registration_status'] |
|
973 | + : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
974 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
975 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
976 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
977 | + ? $this->_req_data['timezone_string'] : null, |
|
978 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
979 | + ? $this->_req_data['externalURL'] : null, |
|
980 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
981 | + ? $this->_req_data['event_phone'] : null, |
|
982 | + ); |
|
983 | + //update event |
|
984 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
985 | + //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! |
|
986 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
987 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
988 | + //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
989 | + $event_update_callbacks = apply_filters( |
|
990 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
991 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
992 | + ); |
|
993 | + $att_success = true; |
|
994 | + foreach ($event_update_callbacks as $e_callback) { |
|
995 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
996 | + $att_success = ! $att_success ? $att_success |
|
997 | + : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
998 | + } |
|
999 | + //any errors? |
|
1000 | + if ($success && false === $att_success) { |
|
1001 | + EE_Error::add_error( |
|
1002 | + esc_html__( |
|
1003 | + 'Event Details saved successfully but something went wrong with saving attachments.', |
|
1004 | + 'event_espresso' |
|
1005 | + ), |
|
1006 | + __FILE__, |
|
1007 | + __FUNCTION__, |
|
1008 | + __LINE__ |
|
1009 | + ); |
|
1010 | + } else if ($success === false) { |
|
1011 | + EE_Error::add_error( |
|
1012 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
1013 | + __FILE__, |
|
1014 | + __FUNCTION__, |
|
1015 | + __LINE__ |
|
1016 | + ); |
|
1017 | + } |
|
1018 | + } |
|
1019 | + |
|
1020 | + |
|
1021 | + |
|
1022 | + /** |
|
1023 | + * @see parent::restore_item() |
|
1024 | + * @param int $post_id |
|
1025 | + * @param int $revision_id |
|
1026 | + */ |
|
1027 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
1028 | + { |
|
1029 | + //copy existing event meta to new post |
|
1030 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1031 | + if ($post_evt instanceof EE_Event) { |
|
1032 | + //meta revision restore |
|
1033 | + $post_evt->restore_revision($revision_id); |
|
1034 | + //related objs restore |
|
1035 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1036 | + } |
|
1037 | + } |
|
1038 | + |
|
1039 | + |
|
1040 | + |
|
1041 | + /** |
|
1042 | + * Attach the venue to the Event |
|
1043 | + * |
|
1044 | + * @param \EE_Event $evtobj Event Object to add the venue to |
|
1045 | + * @param array $data The request data from the form |
|
1046 | + * @return bool Success or fail. |
|
1047 | + */ |
|
1048 | + protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1049 | + { |
|
1050 | + require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1051 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1052 | + $rows_affected = null; |
|
1053 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1054 | + // very important. If we don't have a venue name... |
|
1055 | + // then we'll get out because not necessary to create empty venue |
|
1056 | + if (empty($data['venue_title'])) { |
|
1057 | + return false; |
|
1058 | + } |
|
1059 | + $venue_array = array( |
|
1060 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1061 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1062 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1063 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1064 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1065 | + : null, |
|
1066 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1067 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1068 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1069 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1070 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1071 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1072 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1073 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1074 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1075 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1076 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1077 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1078 | + 'status' => 'publish', |
|
1079 | + ); |
|
1080 | + //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1081 | + if ( ! empty($venue_id)) { |
|
1082 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1083 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1084 | + //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. |
|
1085 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1086 | + return $rows_affected > 0 ? true : false; |
|
1087 | + } else { |
|
1088 | + //we insert the venue |
|
1089 | + $venue_id = $venue_model->insert($venue_array); |
|
1090 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1091 | + return ! empty($venue_id) ? true : false; |
|
1092 | + } |
|
1093 | + //when we have the ancestor come in it's already been handled by the revision save. |
|
1094 | + } |
|
1095 | + |
|
1096 | + |
|
1097 | + |
|
1098 | + /** |
|
1099 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1100 | + * |
|
1101 | + * @param EE_Event $evtobj The Event object we're attaching data to |
|
1102 | + * @param array $data The request data from the form |
|
1103 | + * @return array |
|
1104 | + */ |
|
1105 | + protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1106 | + { |
|
1107 | + $success = true; |
|
1108 | + $saved_dtt = null; |
|
1109 | + $saved_tickets = array(); |
|
1110 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1111 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1112 | + //trim all values to ensure any excess whitespace is removed. |
|
1113 | + $dtt = array_map('trim', $dtt); |
|
1114 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1115 | + : $dtt['DTT_EVT_start']; |
|
1116 | + $datetime_values = array( |
|
1117 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1118 | + 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1119 | + 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1120 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1121 | + 'DTT_order' => $row, |
|
1122 | + ); |
|
1123 | + //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. |
|
1124 | + if ( ! empty($dtt['DTT_ID'])) { |
|
1125 | + $DTM = EE_Registry::instance() |
|
1126 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1127 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
1128 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1129 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1130 | + foreach ($datetime_values as $field => $value) { |
|
1131 | + $DTM->set($field, $value); |
|
1132 | + } |
|
1133 | + //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. |
|
1134 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
1135 | + } else { |
|
1136 | + $DTM = EE_Registry::instance()->load_class( |
|
1137 | + 'Datetime', |
|
1138 | + array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1139 | + false, |
|
1140 | + false |
|
1141 | + ); |
|
1142 | + foreach ($datetime_values as $field => $value) { |
|
1143 | + $DTM->set($field, $value); |
|
1144 | + } |
|
1145 | + } |
|
1146 | + $DTM->save(); |
|
1147 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1148 | + //load DTT helper |
|
1149 | + //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. |
|
1150 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1151 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1152 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1153 | + $DTT->save(); |
|
1154 | + } |
|
1155 | + //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. |
|
1156 | + $saved_dtt = $DTT; |
|
1157 | + $success = ! $success ? $success : $DTT; |
|
1158 | + //if ANY of these updates fail then we want the appropriate global error message. |
|
1159 | + // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1160 | + } |
|
1161 | + //no dtts get deleted so we don't do any of that logic here. |
|
1162 | + //update tickets next |
|
1163 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1164 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1165 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1166 | + $update_prices = false; |
|
1167 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1168 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1169 | + // trim inputs to ensure any excess whitespace is removed. |
|
1170 | + $tkt = array_map('trim', $tkt); |
|
1171 | + if (empty($tkt['TKT_start_date'])) { |
|
1172 | + //let's use now in the set timezone. |
|
1173 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1174 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1175 | + } |
|
1176 | + if (empty($tkt['TKT_end_date'])) { |
|
1177 | + //use the start date of the first datetime |
|
1178 | + $dtt = $evtobj->first_datetime(); |
|
1179 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1180 | + $incoming_date_formats[0], |
|
1181 | + $incoming_date_formats[1] |
|
1182 | + ); |
|
1183 | + } |
|
1184 | + $TKT_values = array( |
|
1185 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1186 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1187 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1188 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1189 | + 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1190 | + 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1191 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1192 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1193 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1194 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1195 | + 'TKT_row' => $row, |
|
1196 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1197 | + 'TKT_price' => $ticket_price, |
|
1198 | + ); |
|
1199 | + //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. |
|
1200 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1201 | + $TKT_values['TKT_ID'] = 0; |
|
1202 | + $TKT_values['TKT_is_default'] = 0; |
|
1203 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1204 | + $update_prices = true; |
|
1205 | + } |
|
1206 | + //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1207 | + //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. |
|
1208 | + //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. |
|
1209 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1210 | + $TKT = EE_Registry::instance() |
|
1211 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1212 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
1213 | + if ($TKT instanceof EE_Ticket) { |
|
1214 | + $ticket_sold = $TKT->count_related( |
|
1215 | + 'Registration', |
|
1216 | + array( |
|
1217 | + array( |
|
1218 | + 'STS_ID' => array( |
|
1219 | + 'NOT IN', |
|
1220 | + array(EEM_Registration::status_id_incomplete), |
|
1221 | + ), |
|
1222 | + ), |
|
1223 | + ) |
|
1224 | + ) > 0 ? true : false; |
|
1225 | + //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. |
|
1226 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1227 | + && ! $TKT->get( |
|
1228 | + 'TKT_deleted' |
|
1229 | + ) ? true : false; |
|
1230 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1231 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1232 | + //set new values |
|
1233 | + foreach ($TKT_values as $field => $value) { |
|
1234 | + if ($field == 'TKT_qty') { |
|
1235 | + $TKT->set_qty($value); |
|
1236 | + } else { |
|
1237 | + $TKT->set($field, $value); |
|
1238 | + } |
|
1239 | + } |
|
1240 | + //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1241 | + if ($create_new_TKT) { |
|
1242 | + //archive the old ticket first |
|
1243 | + $TKT->set('TKT_deleted', 1); |
|
1244 | + $TKT->save(); |
|
1245 | + //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1246 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1247 | + //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. |
|
1248 | + $TKT = clone $TKT; |
|
1249 | + $TKT->set('TKT_ID', 0); |
|
1250 | + $TKT->set('TKT_deleted', 0); |
|
1251 | + $TKT->set('TKT_price', $ticket_price); |
|
1252 | + $TKT->set('TKT_sold', 0); |
|
1253 | + //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1254 | + $update_prices = true; |
|
1255 | + } |
|
1256 | + //make sure price is set if it hasn't been already |
|
1257 | + $TKT->set('TKT_price', $ticket_price); |
|
1258 | + } |
|
1259 | + } else { |
|
1260 | + //no TKT_id so a new TKT |
|
1261 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1262 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1263 | + if ($TKT instanceof EE_Ticket) { |
|
1264 | + //need to reset values to properly account for the date formats |
|
1265 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1266 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1267 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1268 | + //set new values |
|
1269 | + foreach ($TKT_values as $field => $value) { |
|
1270 | + if ($field == 'TKT_qty') { |
|
1271 | + $TKT->set_qty($value); |
|
1272 | + } else { |
|
1273 | + $TKT->set($field, $value); |
|
1274 | + } |
|
1275 | + } |
|
1276 | + $update_prices = true; |
|
1277 | + } |
|
1278 | + } |
|
1279 | + // cap ticket qty by datetime reg limits |
|
1280 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1281 | + //update ticket. |
|
1282 | + $TKT->save(); |
|
1283 | + //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. |
|
1284 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1285 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1286 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1287 | + $TKT->save(); |
|
1288 | + } |
|
1289 | + //initially let's add the ticket to the dtt |
|
1290 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1291 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1292 | + //add prices to ticket |
|
1293 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1294 | + } |
|
1295 | + //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. |
|
1296 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1297 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1298 | + foreach ($tickets_removed as $id) { |
|
1299 | + $id = absint($id); |
|
1300 | + //get the ticket for this id |
|
1301 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1302 | + //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) |
|
1303 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1304 | + foreach ($dtts as $dtt) { |
|
1305 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1306 | + } |
|
1307 | + //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)) |
|
1308 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
1309 | + //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1310 | + $tkt_to_remove->delete_permanently(); |
|
1311 | + } |
|
1312 | + return array($saved_dtt, $saved_tickets); |
|
1313 | + } |
|
1314 | + |
|
1315 | + |
|
1316 | + |
|
1317 | + /** |
|
1318 | + * This attaches a list of given prices to a ticket. |
|
1319 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1320 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1321 | + * price info and prices are automatically "archived" via the ticket. |
|
1322 | + * |
|
1323 | + * @access private |
|
1324 | + * @param array $prices Array of prices from the form. |
|
1325 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1326 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1327 | + * @return void |
|
1328 | + */ |
|
1329 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1330 | + { |
|
1331 | + foreach ($prices as $row => $prc) { |
|
1332 | + $PRC_values = array( |
|
1333 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1334 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1335 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1336 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1337 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1338 | + 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1339 | + 'PRC_order' => $row, |
|
1340 | + ); |
|
1341 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1342 | + $PRC_values['PRC_ID'] = 0; |
|
1343 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1344 | + } else { |
|
1345 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1346 | + //update this price with new values |
|
1347 | + foreach ($PRC_values as $field => $newprc) { |
|
1348 | + $PRC->set($field, $newprc); |
|
1349 | + } |
|
1350 | + $PRC->save(); |
|
1351 | + } |
|
1352 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1353 | + } |
|
1354 | + } |
|
1355 | + |
|
1356 | + |
|
1357 | + |
|
1358 | + /** |
|
1359 | + * Add in our autosave ajax handlers |
|
1360 | + * |
|
1361 | + * @return void |
|
1362 | + */ |
|
1363 | + protected function _ee_autosave_create_new() |
|
1364 | + { |
|
1365 | + // $this->_ee_autosave_edit(); |
|
1366 | + } |
|
1367 | + |
|
1368 | + |
|
1369 | + |
|
1370 | + protected function _ee_autosave_edit() |
|
1371 | + { |
|
1372 | + return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1373 | + } |
|
1374 | + |
|
1375 | + |
|
1376 | + |
|
1377 | + /** |
|
1378 | + * _generate_publish_box_extra_content |
|
1379 | + * |
|
1380 | + * @access private |
|
1381 | + * @return void |
|
1382 | + */ |
|
1383 | + private function _generate_publish_box_extra_content() |
|
1384 | + { |
|
1385 | + //load formatter helper |
|
1386 | + //args for getting related registrations |
|
1387 | + $approved_query_args = array( |
|
1388 | + array( |
|
1389 | + 'REG_deleted' => 0, |
|
1390 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
1391 | + ), |
|
1392 | + ); |
|
1393 | + $not_approved_query_args = array( |
|
1394 | + array( |
|
1395 | + 'REG_deleted' => 0, |
|
1396 | + 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1397 | + ), |
|
1398 | + ); |
|
1399 | + $pending_payment_query_args = array( |
|
1400 | + array( |
|
1401 | + 'REG_deleted' => 0, |
|
1402 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1403 | + ), |
|
1404 | + ); |
|
1405 | + // publish box |
|
1406 | + $publish_box_extra_args = array( |
|
1407 | + 'view_approved_reg_url' => add_query_arg( |
|
1408 | + array( |
|
1409 | + 'action' => 'default', |
|
1410 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1411 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1412 | + ), |
|
1413 | + REG_ADMIN_URL |
|
1414 | + ), |
|
1415 | + 'view_not_approved_reg_url' => add_query_arg( |
|
1416 | + array( |
|
1417 | + 'action' => 'default', |
|
1418 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1419 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1420 | + ), |
|
1421 | + REG_ADMIN_URL |
|
1422 | + ), |
|
1423 | + 'view_pending_payment_reg_url' => add_query_arg( |
|
1424 | + array( |
|
1425 | + 'action' => 'default', |
|
1426 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1427 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1428 | + ), |
|
1429 | + REG_ADMIN_URL |
|
1430 | + ), |
|
1431 | + 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1432 | + 'Registration', |
|
1433 | + $approved_query_args |
|
1434 | + ), |
|
1435 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1436 | + 'Registration', |
|
1437 | + $not_approved_query_args |
|
1438 | + ), |
|
1439 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1440 | + 'Registration', |
|
1441 | + $pending_payment_query_args |
|
1442 | + ), |
|
1443 | + 'misc_pub_section_class' => apply_filters( |
|
1444 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1445 | + 'misc-pub-section' |
|
1446 | + ), |
|
1447 | + //'email_attendees_url' => add_query_arg( |
|
1448 | + // array( |
|
1449 | + // 'event_admin_reports' => 'event_newsletter', |
|
1450 | + // 'event_id' => $this->_cpt_model_obj->id |
|
1451 | + // ), |
|
1452 | + // 'admin.php?page=espresso_registrations' |
|
1453 | + //), |
|
1454 | + ); |
|
1455 | + ob_start(); |
|
1456 | + do_action( |
|
1457 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1458 | + $this->_cpt_model_obj |
|
1459 | + ); |
|
1460 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1461 | + // load template |
|
1462 | + EEH_Template::display_template( |
|
1463 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1464 | + $publish_box_extra_args |
|
1465 | + ); |
|
1466 | + } |
|
1467 | + |
|
1468 | + |
|
1469 | + |
|
1470 | + /** |
|
1471 | + * This just returns whatever is set as the _event object property |
|
1472 | + * //todo this will become obsolete once the models are in place |
|
1473 | + * |
|
1474 | + * @return object |
|
1475 | + */ |
|
1476 | + public function get_event_object() |
|
1477 | + { |
|
1478 | + return $this->_cpt_model_obj; |
|
1479 | + } |
|
1480 | + |
|
1481 | + |
|
1482 | + |
|
1483 | + |
|
1484 | + /** METABOXES * */ |
|
1485 | + /** |
|
1486 | + * _register_event_editor_meta_boxes |
|
1487 | + * add all metaboxes related to the event_editor |
|
1488 | + * |
|
1489 | + * @return void |
|
1490 | + */ |
|
1491 | + protected function _register_event_editor_meta_boxes() |
|
1492 | + { |
|
1493 | + $this->verify_cpt_object(); |
|
1494 | + add_meta_box( |
|
1495 | + 'espresso_event_editor_tickets', |
|
1496 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1497 | + array($this, 'ticket_metabox'), |
|
1498 | + $this->page_slug, |
|
1499 | + 'normal', |
|
1500 | + 'high' |
|
1501 | + ); |
|
1502 | + add_meta_box( |
|
1503 | + 'espresso_event_editor_event_options', |
|
1504 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1505 | + array($this, 'registration_options_meta_box'), |
|
1506 | + $this->page_slug, |
|
1507 | + 'side', |
|
1508 | + 'default' |
|
1509 | + ); |
|
1510 | + // NOTE: if you're looking for other metaboxes in here, |
|
1511 | + // where a metabox has a related management page in the admin |
|
1512 | + // you will find it setup in the related management page's "_Hooks" file. |
|
1513 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1514 | + } |
|
1515 | + |
|
1516 | + |
|
1517 | + |
|
1518 | + public function ticket_metabox() |
|
1519 | + { |
|
1520 | + $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1521 | + //defaults for template args |
|
1522 | + $template_args = array( |
|
1523 | + 'existing_datetime_ids' => '', |
|
1524 | + 'event_datetime_help_link' => '', |
|
1525 | + 'ticket_options_help_link' => '', |
|
1526 | + 'time' => null, |
|
1527 | + 'ticket_rows' => '', |
|
1528 | + 'existing_ticket_ids' => '', |
|
1529 | + 'total_ticket_rows' => 1, |
|
1530 | + 'ticket_js_structure' => '', |
|
1531 | + 'trash_icon' => 'ee-lock-icon', |
|
1532 | + 'disabled' => '', |
|
1533 | + ); |
|
1534 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1535 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1536 | + /** |
|
1537 | + * 1. Start with retrieving Datetimes |
|
1538 | + * 2. Fore each datetime get related tickets |
|
1539 | + * 3. For each ticket get related prices |
|
1540 | + */ |
|
1541 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1542 | + /** @type EE_Datetime $first_datetime */ |
|
1543 | + $first_datetime = reset($times); |
|
1544 | + //do we get related tickets? |
|
1545 | + if ($first_datetime instanceof EE_Datetime |
|
1546 | + && $first_datetime->ID() !== 0 |
|
1547 | + ) { |
|
1548 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1549 | + $template_args['time'] = $first_datetime; |
|
1550 | + $related_tickets = $first_datetime->tickets( |
|
1551 | + array( |
|
1552 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1553 | + 'default_where_conditions' => 'none', |
|
1554 | + ) |
|
1555 | + ); |
|
1556 | + if ( ! empty($related_tickets)) { |
|
1557 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
1558 | + $row = 0; |
|
1559 | + foreach ($related_tickets as $ticket) { |
|
1560 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1561 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1562 | + $row++; |
|
1563 | + } |
|
1564 | + } else { |
|
1565 | + $template_args['total_ticket_rows'] = 1; |
|
1566 | + /** @type EE_Ticket $ticket */ |
|
1567 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1568 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1569 | + } |
|
1570 | + } else { |
|
1571 | + $template_args['time'] = $times[0]; |
|
1572 | + /** @type EE_Ticket $ticket */ |
|
1573 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1574 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1575 | + // NOTE: we're just sending the first default row |
|
1576 | + // (decaf can't manage default tickets so this should be sufficient); |
|
1577 | + } |
|
1578 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1579 | + 'event_editor_event_datetimes_help_tab' |
|
1580 | + ); |
|
1581 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1582 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1583 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1584 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1585 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1586 | + true |
|
1587 | + ); |
|
1588 | + $template = apply_filters( |
|
1589 | + 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1590 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1591 | + ); |
|
1592 | + EEH_Template::display_template($template, $template_args); |
|
1593 | + } |
|
1594 | + |
|
1595 | + |
|
1596 | + |
|
1597 | + /** |
|
1598 | + * Setup an individual ticket form for the decaf event editor page |
|
1599 | + * |
|
1600 | + * @access private |
|
1601 | + * @param EE_Ticket $ticket the ticket object |
|
1602 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1603 | + * @param int $row |
|
1604 | + * @return string generated html for the ticket row. |
|
1605 | + */ |
|
1606 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1607 | + { |
|
1608 | + $template_args = array( |
|
1609 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1610 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1611 | + : '', |
|
1612 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1613 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1614 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
1615 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1616 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1617 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1618 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1619 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1620 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1621 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1622 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1623 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1624 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1625 | + : ' disabled=disabled', |
|
1626 | + ); |
|
1627 | + $price = $ticket->ID() !== 0 |
|
1628 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1629 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1630 | + $price_args = array( |
|
1631 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1632 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
1633 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
1634 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
1635 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1636 | + ); |
|
1637 | + //make sure we have default start and end dates if skeleton |
|
1638 | + //handle rows that should NOT be empty |
|
1639 | + if (empty($template_args['TKT_start_date'])) { |
|
1640 | + //if empty then the start date will be now. |
|
1641 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1642 | + } |
|
1643 | + if (empty($template_args['TKT_end_date'])) { |
|
1644 | + //get the earliest datetime (if present); |
|
1645 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1646 | + ? $this->_cpt_model_obj->get_first_related( |
|
1647 | + 'Datetime', |
|
1648 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1649 | + ) |
|
1650 | + : null; |
|
1651 | + if ( ! empty($earliest_dtt)) { |
|
1652 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1653 | + } else { |
|
1654 | + $template_args['TKT_end_date'] = date( |
|
1655 | + 'Y-m-d h:i a', |
|
1656 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1657 | + ); |
|
1658 | + } |
|
1659 | + } |
|
1660 | + $template_args = array_merge($template_args, $price_args); |
|
1661 | + $template = apply_filters( |
|
1662 | + 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1663 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1664 | + $ticket |
|
1665 | + ); |
|
1666 | + return EEH_Template::display_template($template, $template_args, true); |
|
1667 | + } |
|
1668 | + |
|
1669 | + |
|
1670 | + |
|
1671 | + public function registration_options_meta_box() |
|
1672 | + { |
|
1673 | + $yes_no_values = array( |
|
1674 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1675 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1676 | + ); |
|
1677 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1678 | + array( |
|
1679 | + EEM_Registration::status_id_cancelled, |
|
1680 | + EEM_Registration::status_id_declined, |
|
1681 | + EEM_Registration::status_id_incomplete, |
|
1682 | + ), |
|
1683 | + true |
|
1684 | + ); |
|
1685 | + //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1686 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
1687 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1688 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1689 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1690 | + 'default_reg_status', |
|
1691 | + $default_reg_status_values, |
|
1692 | + $this->_cpt_model_obj->default_registration_status() |
|
1693 | + ); |
|
1694 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1695 | + 'display_desc', |
|
1696 | + $yes_no_values, |
|
1697 | + $this->_cpt_model_obj->display_description() |
|
1698 | + ); |
|
1699 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1700 | + 'display_ticket_selector', |
|
1701 | + $yes_no_values, |
|
1702 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
1703 | + '', |
|
1704 | + '', |
|
1705 | + false |
|
1706 | + ); |
|
1707 | + $template_args['additional_registration_options'] = apply_filters( |
|
1708 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1709 | + '', |
|
1710 | + $template_args, |
|
1711 | + $yes_no_values, |
|
1712 | + $default_reg_status_values |
|
1713 | + ); |
|
1714 | + EEH_Template::display_template( |
|
1715 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1716 | + $template_args |
|
1717 | + ); |
|
1718 | + } |
|
1719 | + |
|
1720 | + |
|
1721 | + |
|
1722 | + /** |
|
1723 | + * _get_events() |
|
1724 | + * This method simply returns all the events (for the given _view and paging) |
|
1725 | + * |
|
1726 | + * @access public |
|
1727 | + * @param int $per_page count of items per page (20 default); |
|
1728 | + * @param int $current_page what is the current page being viewed. |
|
1729 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1730 | + * If FALSE then we return an array of event objects |
|
1731 | + * that match the given _view and paging parameters. |
|
1732 | + * @return array an array of event objects. |
|
1733 | + */ |
|
1734 | + public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1735 | + { |
|
1736 | + $EEME = $this->_event_model(); |
|
1737 | + $offset = ($current_page - 1) * $per_page; |
|
1738 | + $limit = $count ? null : $offset . ',' . $per_page; |
|
1739 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1740 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1741 | + if (isset($this->_req_data['month_range'])) { |
|
1742 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1743 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1744 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1745 | + } |
|
1746 | + $where = array(); |
|
1747 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1748 | + //determine what post_status our condition will have for the query. |
|
1749 | + switch ($status) { |
|
1750 | + case 'month' : |
|
1751 | + case 'today' : |
|
1752 | + case null : |
|
1753 | + case 'all' : |
|
1754 | + break; |
|
1755 | + case 'draft' : |
|
1756 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1757 | + break; |
|
1758 | + default : |
|
1759 | + $where['status'] = $status; |
|
1760 | + } |
|
1761 | + //categories? |
|
1762 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1763 | + ? $this->_req_data['EVT_CAT'] : null; |
|
1764 | + if ( ! empty ($category)) { |
|
1765 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1766 | + $where['Term_Taxonomy.term_id'] = $category; |
|
1767 | + } |
|
1768 | + //date where conditions |
|
1769 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1770 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1771 | + $DateTime = new DateTime( |
|
1772 | + $year_r . '-' . $month_r . '-01 00:00:00', |
|
1773 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1774 | + ); |
|
1775 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1776 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
1777 | + ->format('t'))->setTime(23, 59, 59) |
|
1778 | + ->format(implode(' ', $start_formats)); |
|
1779 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1780 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1781 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1782 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1783 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1784 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1785 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1786 | + $now = date('Y-m-01'); |
|
1787 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1788 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1789 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1790 | + ->setTime(23, 59, 59) |
|
1791 | + ->format(implode(' ', $start_formats)); |
|
1792 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1793 | + } |
|
1794 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1795 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1796 | + } else { |
|
1797 | + if ( ! isset($where['status'])) { |
|
1798 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1799 | + $where['OR'] = array( |
|
1800 | + 'status*restrict_private' => array('!=', 'private'), |
|
1801 | + 'AND' => array( |
|
1802 | + 'status*inclusive' => array('=', 'private'), |
|
1803 | + 'EVT_wp_user' => get_current_user_id(), |
|
1804 | + ), |
|
1805 | + ); |
|
1806 | + } |
|
1807 | + } |
|
1808 | + } |
|
1809 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1810 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1811 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1812 | + ) { |
|
1813 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1814 | + } |
|
1815 | + } |
|
1816 | + //search query handling |
|
1817 | + if (isset($this->_req_data['s'])) { |
|
1818 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1819 | + $where['OR'] = array( |
|
1820 | + 'EVT_name' => array('LIKE', $search_string), |
|
1821 | + 'EVT_desc' => array('LIKE', $search_string), |
|
1822 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
1823 | + ); |
|
1824 | + } |
|
1825 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1826 | + $query_params = apply_filters( |
|
1827 | + 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1828 | + array( |
|
1829 | + $where, |
|
1830 | + 'limit' => $limit, |
|
1831 | + 'order_by' => $orderby, |
|
1832 | + 'order' => $order, |
|
1833 | + 'group_by' => 'EVT_ID', |
|
1834 | + ), |
|
1835 | + $this->_req_data |
|
1836 | + ); |
|
1837 | + //let's first check if we have special requests coming in. |
|
1838 | + if (isset($this->_req_data['active_status'])) { |
|
1839 | + switch ($this->_req_data['active_status']) { |
|
1840 | + case 'upcoming' : |
|
1841 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1842 | + break; |
|
1843 | + case 'expired' : |
|
1844 | + return $EEME->get_expired_events($query_params, $count); |
|
1845 | + break; |
|
1846 | + case 'active' : |
|
1847 | + return $EEME->get_active_events($query_params, $count); |
|
1848 | + break; |
|
1849 | + case 'inactive' : |
|
1850 | + return $EEME->get_inactive_events($query_params, $count); |
|
1851 | + break; |
|
1852 | + } |
|
1853 | + } |
|
1854 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1855 | + return $events; |
|
1856 | + } |
|
1857 | + |
|
1858 | + |
|
1859 | + |
|
1860 | + /** |
|
1861 | + * handling for WordPress CPT actions (trash, restore, delete) |
|
1862 | + * |
|
1863 | + * @param string $post_id |
|
1864 | + */ |
|
1865 | + public function trash_cpt_item($post_id) |
|
1866 | + { |
|
1867 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1868 | + $this->_trash_or_restore_event('trash', false); |
|
1869 | + } |
|
1870 | + |
|
1871 | + |
|
1872 | + |
|
1873 | + /** |
|
1874 | + * @param string $post_id |
|
1875 | + */ |
|
1876 | + public function restore_cpt_item($post_id) |
|
1877 | + { |
|
1878 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1879 | + $this->_trash_or_restore_event('draft', false); |
|
1880 | + } |
|
1881 | + |
|
1882 | + |
|
1883 | + |
|
1884 | + /** |
|
1885 | + * @param string $post_id |
|
1886 | + */ |
|
1887 | + public function delete_cpt_item($post_id) |
|
1888 | + { |
|
1889 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1890 | + $this->_delete_event(false); |
|
1891 | + } |
|
1892 | + |
|
1893 | + |
|
1894 | + |
|
1895 | + /** |
|
1896 | + * _trash_or_restore_event |
|
1897 | + * |
|
1898 | + * @access protected |
|
1899 | + * @param string $event_status |
|
1900 | + * @param bool $redirect_after |
|
1901 | + */ |
|
1902 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1903 | + { |
|
1904 | + //determine the event id and set to array. |
|
1905 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1906 | + // loop thru events |
|
1907 | + if ($EVT_ID) { |
|
1908 | + // clean status |
|
1909 | + $event_status = sanitize_key($event_status); |
|
1910 | + // grab status |
|
1911 | + if ( ! empty($event_status)) { |
|
1912 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1913 | + } else { |
|
1914 | + $success = false; |
|
1915 | + $msg = esc_html__( |
|
1916 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1917 | + 'event_espresso' |
|
1918 | + ); |
|
1919 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1920 | + } |
|
1921 | + } else { |
|
1922 | + $success = false; |
|
1923 | + $msg = esc_html__( |
|
1924 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1925 | + 'event_espresso' |
|
1926 | + ); |
|
1927 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1928 | + } |
|
1929 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1930 | + if ($redirect_after) { |
|
1931 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1932 | + } |
|
1933 | + } |
|
1934 | + |
|
1935 | + |
|
1936 | + |
|
1937 | + /** |
|
1938 | + * _trash_or_restore_events |
|
1939 | + * |
|
1940 | + * @access protected |
|
1941 | + * @param string $event_status |
|
1942 | + * @return void |
|
1943 | + */ |
|
1944 | + protected function _trash_or_restore_events($event_status = 'trash') |
|
1945 | + { |
|
1946 | + // clean status |
|
1947 | + $event_status = sanitize_key($event_status); |
|
1948 | + // grab status |
|
1949 | + if ( ! empty($event_status)) { |
|
1950 | + $success = true; |
|
1951 | + //determine the event id and set to array. |
|
1952 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1953 | + // loop thru events |
|
1954 | + foreach ($EVT_IDs as $EVT_ID) { |
|
1955 | + if ($EVT_ID = absint($EVT_ID)) { |
|
1956 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1957 | + $success = $results !== false ? $success : false; |
|
1958 | + } else { |
|
1959 | + $msg = sprintf( |
|
1960 | + esc_html__( |
|
1961 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1962 | + 'event_espresso' |
|
1963 | + ), |
|
1964 | + $EVT_ID |
|
1965 | + ); |
|
1966 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1967 | + $success = false; |
|
1968 | + } |
|
1969 | + } |
|
1970 | + } else { |
|
1971 | + $success = false; |
|
1972 | + $msg = esc_html__( |
|
1973 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1974 | + 'event_espresso' |
|
1975 | + ); |
|
1976 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1977 | + } |
|
1978 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1979 | + $success = $success ? 2 : false; |
|
1980 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1981 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1982 | + } |
|
1983 | + |
|
1984 | + |
|
1985 | + |
|
1986 | + /** |
|
1987 | + * _trash_or_restore_events |
|
1988 | + * |
|
1989 | + * @access private |
|
1990 | + * @param int $EVT_ID |
|
1991 | + * @param string $event_status |
|
1992 | + * @return bool |
|
1993 | + */ |
|
1994 | + private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1995 | + { |
|
1996 | + // grab event id |
|
1997 | + if ( ! $EVT_ID) { |
|
1998 | + $msg = esc_html__( |
|
1999 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2000 | + 'event_espresso' |
|
2001 | + ); |
|
2002 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2003 | + return false; |
|
2004 | + } |
|
2005 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2006 | + // clean status |
|
2007 | + $event_status = sanitize_key($event_status); |
|
2008 | + // grab status |
|
2009 | + if (empty($event_status)) { |
|
2010 | + $msg = esc_html__( |
|
2011 | + 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
2012 | + 'event_espresso' |
|
2013 | + ); |
|
2014 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2015 | + return false; |
|
2016 | + } |
|
2017 | + // was event trashed or restored ? |
|
2018 | + switch ($event_status) { |
|
2019 | + case 'draft' : |
|
2020 | + $action = 'restored from the trash'; |
|
2021 | + $hook = 'AHEE_event_restored_from_trash'; |
|
2022 | + break; |
|
2023 | + case 'trash' : |
|
2024 | + $action = 'moved to the trash'; |
|
2025 | + $hook = 'AHEE_event_moved_to_trash'; |
|
2026 | + break; |
|
2027 | + default : |
|
2028 | + $action = 'updated'; |
|
2029 | + $hook = false; |
|
2030 | + } |
|
2031 | + //use class to change status |
|
2032 | + $this->_cpt_model_obj->set_status($event_status); |
|
2033 | + $success = $this->_cpt_model_obj->save(); |
|
2034 | + if ($success === false) { |
|
2035 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2036 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2037 | + return false; |
|
2038 | + } |
|
2039 | + if ($hook) { |
|
2040 | + do_action($hook); |
|
2041 | + } |
|
2042 | + return true; |
|
2043 | + } |
|
2044 | + |
|
2045 | + |
|
2046 | + |
|
2047 | + /** |
|
2048 | + * _delete_event |
|
2049 | + * |
|
2050 | + * @access protected |
|
2051 | + * @param bool $redirect_after |
|
2052 | + */ |
|
2053 | + protected function _delete_event($redirect_after = true) |
|
2054 | + { |
|
2055 | + //determine the event id and set to array. |
|
2056 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2057 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2058 | + // loop thru events |
|
2059 | + if ($EVT_ID) { |
|
2060 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
2061 | + // get list of events with no prices |
|
2062 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2063 | + // remove this event from the list of events with no prices |
|
2064 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2065 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2066 | + } |
|
2067 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2068 | + } else { |
|
2069 | + $success = false; |
|
2070 | + $msg = esc_html__( |
|
2071 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2072 | + 'event_espresso' |
|
2073 | + ); |
|
2074 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2075 | + } |
|
2076 | + if ($redirect_after) { |
|
2077 | + $this->_redirect_after_action( |
|
2078 | + $success, |
|
2079 | + 'Event', |
|
2080 | + 'deleted', |
|
2081 | + array('action' => 'default', 'status' => 'trash') |
|
2082 | + ); |
|
2083 | + } |
|
2084 | + } |
|
2085 | + |
|
2086 | + |
|
2087 | + |
|
2088 | + /** |
|
2089 | + * _delete_events |
|
2090 | + * |
|
2091 | + * @access protected |
|
2092 | + * @return void |
|
2093 | + */ |
|
2094 | + protected function _delete_events() |
|
2095 | + { |
|
2096 | + $success = true; |
|
2097 | + // get list of events with no prices |
|
2098 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2099 | + //determine the event id and set to array. |
|
2100 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2101 | + // loop thru events |
|
2102 | + foreach ($EVT_IDs as $EVT_ID) { |
|
2103 | + $EVT_ID = absint($EVT_ID); |
|
2104 | + if ($EVT_ID) { |
|
2105 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
2106 | + $success = $results !== false ? $success : false; |
|
2107 | + // remove this event from the list of events with no prices |
|
2108 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2109 | + } else { |
|
2110 | + $success = false; |
|
2111 | + $msg = esc_html__( |
|
2112 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2113 | + 'event_espresso' |
|
2114 | + ); |
|
2115 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2116 | + } |
|
2117 | + } |
|
2118 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2119 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2120 | + $success = $success ? 2 : false; |
|
2121 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2122 | + } |
|
2123 | + |
|
2124 | + |
|
2125 | + |
|
2126 | + /** |
|
2127 | + * _permanently_delete_event |
|
2128 | + * |
|
2129 | + * @access private |
|
2130 | + * @param int $EVT_ID |
|
2131 | + * @return bool |
|
2132 | + */ |
|
2133 | + private function _permanently_delete_event($EVT_ID = 0) |
|
2134 | + { |
|
2135 | + // grab event id |
|
2136 | + if ( ! $EVT_ID) { |
|
2137 | + $msg = esc_html__( |
|
2138 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2139 | + 'event_espresso' |
|
2140 | + ); |
|
2141 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2142 | + return false; |
|
2143 | + } |
|
2144 | + if ( |
|
2145 | + ! $this->_cpt_model_obj instanceof EE_Event |
|
2146 | + || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2147 | + ) { |
|
2148 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2149 | + } |
|
2150 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2151 | + return false; |
|
2152 | + } |
|
2153 | + //need to delete related tickets and prices first. |
|
2154 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2155 | + foreach ($datetimes as $datetime) { |
|
2156 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2157 | + $tickets = $datetime->get_many_related('Ticket'); |
|
2158 | + foreach ($tickets as $ticket) { |
|
2159 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2160 | + $ticket->delete_related_permanently('Price'); |
|
2161 | + $ticket->delete_permanently(); |
|
2162 | + } |
|
2163 | + $datetime->delete(); |
|
2164 | + } |
|
2165 | + //what about related venues or terms? |
|
2166 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2167 | + foreach ($venues as $venue) { |
|
2168 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2169 | + } |
|
2170 | + //any attached question groups? |
|
2171 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2172 | + if ( ! empty($question_groups)) { |
|
2173 | + foreach ($question_groups as $question_group) { |
|
2174 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2175 | + } |
|
2176 | + } |
|
2177 | + //Message Template Groups |
|
2178 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2179 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2180 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2181 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
2182 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2183 | + } |
|
2184 | + $success = $this->_cpt_model_obj->delete_permanently(); |
|
2185 | + // did it all go as planned ? |
|
2186 | + if ($success) { |
|
2187 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2188 | + EE_Error::add_success($msg); |
|
2189 | + } else { |
|
2190 | + $msg = sprintf( |
|
2191 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2192 | + $EVT_ID |
|
2193 | + ); |
|
2194 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2195 | + return false; |
|
2196 | + } |
|
2197 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2198 | + return true; |
|
2199 | + } |
|
2200 | + |
|
2201 | + |
|
2202 | + |
|
2203 | + /** |
|
2204 | + * get total number of events |
|
2205 | + * |
|
2206 | + * @access public |
|
2207 | + * @return int |
|
2208 | + */ |
|
2209 | + public function total_events() |
|
2210 | + { |
|
2211 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2212 | + return $count; |
|
2213 | + } |
|
2214 | + |
|
2215 | + |
|
2216 | + |
|
2217 | + /** |
|
2218 | + * get total number of draft events |
|
2219 | + * |
|
2220 | + * @access public |
|
2221 | + * @return int |
|
2222 | + */ |
|
2223 | + public function total_events_draft() |
|
2224 | + { |
|
2225 | + $where = array( |
|
2226 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
2227 | + ); |
|
2228 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2229 | + return $count; |
|
2230 | + } |
|
2231 | + |
|
2232 | + |
|
2233 | + |
|
2234 | + /** |
|
2235 | + * get total number of trashed events |
|
2236 | + * |
|
2237 | + * @access public |
|
2238 | + * @return int |
|
2239 | + */ |
|
2240 | + public function total_trashed_events() |
|
2241 | + { |
|
2242 | + $where = array( |
|
2243 | + 'status' => 'trash', |
|
2244 | + ); |
|
2245 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2246 | + return $count; |
|
2247 | + } |
|
2248 | + |
|
2249 | + |
|
2250 | + |
|
2251 | + /** |
|
2252 | + * _default_event_settings |
|
2253 | + * This generates the Default Settings Tab |
|
2254 | + * |
|
2255 | + * @return void |
|
2256 | + */ |
|
2257 | + protected function _default_event_settings() |
|
2258 | + { |
|
2259 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
2260 | + $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2261 | + // exclude array |
|
2262 | + array( |
|
2263 | + EEM_Registration::status_id_cancelled, |
|
2264 | + EEM_Registration::status_id_declined, |
|
2265 | + EEM_Registration::status_id_incomplete, |
|
2266 | + EEM_Registration::status_id_wait_list, |
|
2267 | + ), |
|
2268 | + // translated |
|
2269 | + true |
|
2270 | + ); |
|
2271 | + $this->_template_args['default_reg_status'] = isset( |
|
2272 | + EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2273 | + ) |
|
2274 | + && array_key_exists( |
|
2275 | + EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2276 | + $this->_template_args['reg_status_array'] |
|
2277 | + ) |
|
2278 | + ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2279 | + : EEM_Registration::status_id_pending_payment; |
|
2280 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2281 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2282 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2283 | + EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2284 | + $this->_template_args, |
|
2285 | + true |
|
2286 | + ); |
|
2287 | + $this->display_admin_page_with_sidebar(); |
|
2288 | + } |
|
2289 | + |
|
2290 | + |
|
2291 | + |
|
2292 | + /** |
|
2293 | + * _update_default_event_settings |
|
2294 | + * |
|
2295 | + * @access protected |
|
2296 | + * @return void |
|
2297 | + */ |
|
2298 | + protected function _update_default_event_settings() |
|
2299 | + { |
|
2300 | + EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2301 | + ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2302 | + : EEM_Registration::status_id_pending_payment; |
|
2303 | + $what = 'Default Event Settings'; |
|
2304 | + $success = $this->_update_espresso_configuration( |
|
2305 | + $what, |
|
2306 | + EE_Config::instance(), |
|
2307 | + __FILE__, |
|
2308 | + __FUNCTION__, |
|
2309 | + __LINE__ |
|
2310 | + ); |
|
2311 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2312 | + } |
|
2313 | + |
|
2314 | + |
|
2315 | + |
|
2316 | + /************* Templates *************/ |
|
2317 | + protected function _template_settings() |
|
2318 | + { |
|
2319 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2320 | + $this->_template_args['preview_img'] = '<img src="' |
|
2321 | + . EVENTS_ASSETS_URL |
|
2322 | + . DS |
|
2323 | + . 'images' |
|
2324 | + . DS |
|
2325 | + . 'caffeinated_template_features.jpg" alt="' |
|
2326 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2327 | + . '" />'; |
|
2328 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2329 | + '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.', |
|
2330 | + 'event_espresso' |
|
2331 | + ) . '</strong>'; |
|
2332 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2333 | + } |
|
2334 | + |
|
2335 | + |
|
2336 | + /** Event Category Stuff **/ |
|
2337 | + /** |
|
2338 | + * set the _category property with the category object for the loaded page. |
|
2339 | + * |
|
2340 | + * @access private |
|
2341 | + * @return void |
|
2342 | + */ |
|
2343 | + private function _set_category_object() |
|
2344 | + { |
|
2345 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2346 | + return; |
|
2347 | + } //already have the category object so get out. |
|
2348 | + //set default category object |
|
2349 | + $this->_set_empty_category_object(); |
|
2350 | + //only set if we've got an id |
|
2351 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2352 | + return; |
|
2353 | + } |
|
2354 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2355 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2356 | + if ( ! empty($term)) { |
|
2357 | + $this->_category->category_name = $term->name; |
|
2358 | + $this->_category->category_identifier = $term->slug; |
|
2359 | + $this->_category->category_desc = $term->description; |
|
2360 | + $this->_category->id = $term->term_id; |
|
2361 | + $this->_category->parent = $term->parent; |
|
2362 | + } |
|
2363 | + } |
|
2364 | + |
|
2365 | + |
|
2366 | + |
|
2367 | + private function _set_empty_category_object() |
|
2368 | + { |
|
2369 | + $this->_category = new stdClass(); |
|
2370 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2371 | + $this->_category->id = $this->_category->parent = 0; |
|
2372 | + } |
|
2373 | + |
|
2374 | + |
|
2375 | + |
|
2376 | + protected function _category_list_table() |
|
2377 | + { |
|
2378 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2379 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2380 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2381 | + 'add_category', |
|
2382 | + 'add_category', |
|
2383 | + array(), |
|
2384 | + 'add-new-h2' |
|
2385 | + ); |
|
2386 | + $this->display_admin_list_table_page_with_sidebar(); |
|
2387 | + } |
|
2388 | + |
|
2389 | + |
|
2390 | + |
|
2391 | + /** |
|
2392 | + * @param $view |
|
2393 | + */ |
|
2394 | + protected function _category_details($view) |
|
2395 | + { |
|
2396 | + //load formatter helper |
|
2397 | + //load field generator helper |
|
2398 | + $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2399 | + $this->_set_add_edit_form_tags($route); |
|
2400 | + $this->_set_category_object(); |
|
2401 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2402 | + $delete_action = 'delete_category'; |
|
2403 | + //custom redirect |
|
2404 | + $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2405 | + array('action' => 'category_list'), |
|
2406 | + $this->_admin_base_url |
|
2407 | + ); |
|
2408 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2409 | + //take care of contents |
|
2410 | + $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2411 | + $this->display_admin_page_with_sidebar(); |
|
2412 | + } |
|
2413 | + |
|
2414 | + |
|
2415 | + |
|
2416 | + /** |
|
2417 | + * @return mixed |
|
2418 | + */ |
|
2419 | + protected function _category_details_content() |
|
2420 | + { |
|
2421 | + $editor_args['category_desc'] = array( |
|
2422 | + 'type' => 'wp_editor', |
|
2423 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2424 | + 'class' => 'my_editor_custom', |
|
2425 | + 'wpeditor_args' => array('media_buttons' => false), |
|
2426 | + ); |
|
2427 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2428 | + $all_terms = get_terms( |
|
2429 | + array('espresso_event_categories'), |
|
2430 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2431 | + ); |
|
2432 | + //setup category select for term parents. |
|
2433 | + $category_select_values[] = array( |
|
2434 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2435 | + 'id' => 0, |
|
2436 | + ); |
|
2437 | + foreach ($all_terms as $term) { |
|
2438 | + $category_select_values[] = array( |
|
2439 | + 'text' => $term->name, |
|
2440 | + 'id' => $term->term_id, |
|
2441 | + ); |
|
2442 | + } |
|
2443 | + $category_select = EEH_Form_Fields::select_input( |
|
2444 | + 'category_parent', |
|
2445 | + $category_select_values, |
|
2446 | + $this->_category->parent |
|
2447 | + ); |
|
2448 | + $template_args = array( |
|
2449 | + 'category' => $this->_category, |
|
2450 | + 'category_select' => $category_select, |
|
2451 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2452 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2453 | + 'disable' => '', |
|
2454 | + 'disabled_message' => false, |
|
2455 | + ); |
|
2456 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2457 | + return EEH_Template::display_template($template, $template_args, true); |
|
2458 | + } |
|
2459 | + |
|
2460 | + |
|
2461 | + |
|
2462 | + protected function _delete_categories() |
|
2463 | + { |
|
2464 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2465 | + : (array)$this->_req_data['category_id']; |
|
2466 | + foreach ($cat_ids as $cat_id) { |
|
2467 | + $this->_delete_category($cat_id); |
|
2468 | + } |
|
2469 | + //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2470 | + $query_args = array( |
|
2471 | + 'action' => 'category_list', |
|
2472 | + ); |
|
2473 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2474 | + } |
|
2475 | + |
|
2476 | + |
|
2477 | + |
|
2478 | + /** |
|
2479 | + * @param $cat_id |
|
2480 | + */ |
|
2481 | + protected function _delete_category($cat_id) |
|
2482 | + { |
|
2483 | + $cat_id = absint($cat_id); |
|
2484 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2485 | + } |
|
2486 | + |
|
2487 | + |
|
2488 | + |
|
2489 | + /** |
|
2490 | + * @param $new_category |
|
2491 | + */ |
|
2492 | + protected function _insert_or_update_category($new_category) |
|
2493 | + { |
|
2494 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2495 | + $success = 0; //we already have a success message so lets not send another. |
|
2496 | + if ($cat_id) { |
|
2497 | + $query_args = array( |
|
2498 | + 'action' => 'edit_category', |
|
2499 | + 'EVT_CAT_ID' => $cat_id, |
|
2500 | + ); |
|
2501 | + } else { |
|
2502 | + $query_args = array('action' => 'add_category'); |
|
2503 | + } |
|
2504 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2505 | + } |
|
2506 | + |
|
2507 | + |
|
2508 | + |
|
2509 | + /** |
|
2510 | + * @param bool $update |
|
2511 | + * @return bool|mixed|string |
|
2512 | + */ |
|
2513 | + private function _insert_category($update = false) |
|
2514 | + { |
|
2515 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2516 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2517 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2518 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2519 | + if (empty($category_name)) { |
|
2520 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2521 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2522 | + return false; |
|
2523 | + } |
|
2524 | + $term_args = array( |
|
2525 | + 'name' => $category_name, |
|
2526 | + 'description' => $category_desc, |
|
2527 | + 'parent' => $category_parent, |
|
2528 | + ); |
|
2529 | + //was the category_identifier input disabled? |
|
2530 | + if (isset($this->_req_data['category_identifier'])) { |
|
2531 | + $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2532 | + } |
|
2533 | + $insert_ids = $update |
|
2534 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2535 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2536 | + if ( ! is_array($insert_ids)) { |
|
2537 | + $msg = esc_html__( |
|
2538 | + 'An error occurred and the category has not been saved to the database.', |
|
2539 | + 'event_espresso' |
|
2540 | + ); |
|
2541 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2542 | + } else { |
|
2543 | + $cat_id = $insert_ids['term_id']; |
|
2544 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2545 | + EE_Error::add_success($msg); |
|
2546 | + } |
|
2547 | + return $cat_id; |
|
2548 | + } |
|
2549 | + |
|
2550 | + |
|
2551 | + |
|
2552 | + /** |
|
2553 | + * @param int $per_page |
|
2554 | + * @param int $current_page |
|
2555 | + * @param bool $count |
|
2556 | + * @return \EE_Base_Class[]|int |
|
2557 | + */ |
|
2558 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2559 | + { |
|
2560 | + //testing term stuff |
|
2561 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2562 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2563 | + $limit = ($current_page - 1) * $per_page; |
|
2564 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2565 | + if (isset($this->_req_data['s'])) { |
|
2566 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2567 | + $where['OR'] = array( |
|
2568 | + 'Term.name' => array('LIKE', $sstr), |
|
2569 | + 'description' => array('LIKE', $sstr), |
|
2570 | + ); |
|
2571 | + } |
|
2572 | + $query_params = array( |
|
2573 | + $where, |
|
2574 | + 'order_by' => array($orderby => $order), |
|
2575 | + 'limit' => $limit . ',' . $per_page, |
|
2576 | + 'force_join' => array('Term'), |
|
2577 | + ); |
|
2578 | + $categories = $count |
|
2579 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2580 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2581 | + return $categories; |
|
2582 | + } |
|
2583 | + |
|
2584 | + |
|
2585 | + |
|
2586 | + /* end category stuff */ |
|
2587 | + /**************/ |
|
2588 | 2588 | } |
2589 | 2589 | //end class Events_Admin_Page |
@@ -16,196 +16,196 @@ |
||
16 | 16 | abstract class TicketSelectorRow |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @var \EE_Ticket $ticket |
|
21 | - */ |
|
22 | - protected $ticket; |
|
23 | - |
|
24 | - /** |
|
25 | - * @var int $max_atndz |
|
26 | - */ |
|
27 | - protected $max_atndz; |
|
28 | - |
|
29 | - /** |
|
30 | - * @var string $date_format |
|
31 | - */ |
|
32 | - protected $date_format; |
|
33 | - |
|
34 | - /** |
|
35 | - * @var int $EVT_ID |
|
36 | - */ |
|
37 | - protected $EVT_ID; |
|
38 | - |
|
39 | - /** |
|
40 | - * @var string $ticket_status_display |
|
41 | - */ |
|
42 | - protected $ticket_status_display; |
|
43 | - |
|
44 | - |
|
45 | - |
|
46 | - /** |
|
47 | - * TicketDetails constructor. |
|
48 | - * |
|
49 | - * @param \EE_Ticket $ticket |
|
50 | - * @param int $max_atndz |
|
51 | - * @param string $date_format |
|
52 | - */ |
|
53 | - public function __construct( |
|
54 | - \EE_Ticket $ticket, |
|
55 | - $max_atndz, |
|
56 | - $date_format |
|
57 | - ) { |
|
58 | - $this->ticket = $ticket; |
|
59 | - $this->max_atndz = $max_atndz; |
|
60 | - $this->date_format = $date_format; |
|
61 | - $this->EVT_ID = $this->ticket->get_event_ID(); |
|
62 | - } |
|
63 | - |
|
64 | - |
|
65 | - |
|
66 | - /** |
|
67 | - * @return string |
|
68 | - */ |
|
69 | - public function getTicketStatusDisplay() |
|
70 | - { |
|
71 | - return $this->ticket_status_display; |
|
72 | - } |
|
73 | - |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * setTicketStatusDisplay |
|
78 | - * |
|
79 | - * @param string $tkt_status |
|
80 | - * @param string $ticket_status |
|
81 | - * @param int $remaining |
|
82 | - * @throws \EE_Error |
|
83 | - */ |
|
84 | - protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
|
85 | - $this->ticket_status_display = ''; |
|
86 | - // now depending on the ticket and other circumstances... |
|
87 | - if ($this->max_atndz === 0) { |
|
88 | - // registration is CLOSED because admin set max attendees to ZERO |
|
89 | - $this->ticket_status_display = $this->registrationClosed(); |
|
90 | - } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) { |
|
91 | - // SOLD OUT - no tickets remaining |
|
92 | - $this->ticket_status_display = $this->ticketsSoldOut(); |
|
93 | - } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) { |
|
94 | - // expired or archived ticket |
|
95 | - $this->ticket_status_display = $ticket_status; |
|
96 | - } else if ($tkt_status === \EE_Ticket::pending) { |
|
97 | - // ticket not on sale yet |
|
98 | - $this->ticket_status_display = $this->ticketsSalesPending(); |
|
99 | - } else if ($this->ticket->min() > $remaining) { |
|
100 | - // min qty purchasable is less than tickets available |
|
101 | - $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
102 | - } |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * registrationClosed |
|
109 | - */ |
|
110 | - protected function registrationClosed() |
|
111 | - { |
|
112 | - return \EEH_HTML::span( |
|
113 | - apply_filters( |
|
114 | - 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
115 | - __('Closed', 'event_espresso') |
|
116 | - ), |
|
117 | - '', 'sold-out' |
|
118 | - ); |
|
119 | - } |
|
120 | - |
|
121 | - |
|
122 | - |
|
123 | - /** |
|
124 | - * ticketsSoldOut |
|
125 | - */ |
|
126 | - protected function ticketsSoldOut() |
|
127 | - { |
|
128 | - return \EEH_HTML::span( |
|
129 | - apply_filters( |
|
130 | - 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
131 | - __('Sold Out', 'event_espresso') |
|
132 | - ), |
|
133 | - '', 'sold-out' |
|
134 | - ); |
|
135 | - } |
|
136 | - |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * ticketsSalesPending |
|
141 | - * |
|
142 | - * @throws \EE_Error |
|
143 | - */ |
|
144 | - protected function ticketsSalesPending() |
|
145 | - { |
|
146 | - return \EEH_HTML::span( |
|
147 | - \EEH_HTML::span( |
|
148 | - apply_filters( |
|
149 | - 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
150 | - __('Goes On Sale', 'event_espresso') |
|
151 | - ), |
|
152 | - '', 'ticket-pending' |
|
153 | - ) |
|
154 | - . \EEH_HTML::br() |
|
155 | - . \EEH_HTML::span( |
|
156 | - $this->ticket->get_i18n_datetime( |
|
157 | - 'TKT_start_date', |
|
158 | - apply_filters( |
|
159 | - 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
160 | - $this->date_format |
|
161 | - ) |
|
162 | - ), |
|
163 | - '', 'small-text' |
|
164 | - ), |
|
165 | - '', 'ticket-pending-pg' |
|
166 | - ); |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - |
|
171 | - /** |
|
172 | - * notEnoughTicketsAvailable |
|
173 | - */ |
|
174 | - protected function notEnoughTicketsAvailable() |
|
175 | - { |
|
176 | - return \EEH_HTML::div( |
|
177 | - \EEH_HTML::span( |
|
178 | - apply_filters( |
|
179 | - 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
180 | - __('Not Available', 'event_espresso') |
|
181 | - ), |
|
182 | - '', 'archived-ticket small-text' |
|
183 | - ) |
|
184 | - . \EEH_HTML::br(), |
|
185 | - '', 'archived-ticket-pg' |
|
186 | - ); |
|
187 | - } |
|
188 | - |
|
189 | - |
|
190 | - |
|
191 | - /** |
|
192 | - * getHiddenInputs |
|
193 | - * |
|
194 | - * @param string $anchor_id |
|
195 | - * @param int $row |
|
196 | - * @param int $max_atndz |
|
197 | - * @return string |
|
198 | - */ |
|
199 | - protected function getHiddenInputs($anchor_id, $row, $max_atndz) |
|
200 | - { |
|
201 | - $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
202 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->EVT_ID . '"'; |
|
203 | - $html .= ' value="' . \EEH_URL::current_url() . $anchor_id . '"/>'; |
|
204 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->EVT_ID . '" value="' . $row - 1 . '"/>'; |
|
205 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->EVT_ID . '" value="' . $max_atndz . '"/>'; |
|
206 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->EVT_ID . '"/>'; |
|
207 | - return $html; |
|
208 | - } |
|
19 | + /** |
|
20 | + * @var \EE_Ticket $ticket |
|
21 | + */ |
|
22 | + protected $ticket; |
|
23 | + |
|
24 | + /** |
|
25 | + * @var int $max_atndz |
|
26 | + */ |
|
27 | + protected $max_atndz; |
|
28 | + |
|
29 | + /** |
|
30 | + * @var string $date_format |
|
31 | + */ |
|
32 | + protected $date_format; |
|
33 | + |
|
34 | + /** |
|
35 | + * @var int $EVT_ID |
|
36 | + */ |
|
37 | + protected $EVT_ID; |
|
38 | + |
|
39 | + /** |
|
40 | + * @var string $ticket_status_display |
|
41 | + */ |
|
42 | + protected $ticket_status_display; |
|
43 | + |
|
44 | + |
|
45 | + |
|
46 | + /** |
|
47 | + * TicketDetails constructor. |
|
48 | + * |
|
49 | + * @param \EE_Ticket $ticket |
|
50 | + * @param int $max_atndz |
|
51 | + * @param string $date_format |
|
52 | + */ |
|
53 | + public function __construct( |
|
54 | + \EE_Ticket $ticket, |
|
55 | + $max_atndz, |
|
56 | + $date_format |
|
57 | + ) { |
|
58 | + $this->ticket = $ticket; |
|
59 | + $this->max_atndz = $max_atndz; |
|
60 | + $this->date_format = $date_format; |
|
61 | + $this->EVT_ID = $this->ticket->get_event_ID(); |
|
62 | + } |
|
63 | + |
|
64 | + |
|
65 | + |
|
66 | + /** |
|
67 | + * @return string |
|
68 | + */ |
|
69 | + public function getTicketStatusDisplay() |
|
70 | + { |
|
71 | + return $this->ticket_status_display; |
|
72 | + } |
|
73 | + |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * setTicketStatusDisplay |
|
78 | + * |
|
79 | + * @param string $tkt_status |
|
80 | + * @param string $ticket_status |
|
81 | + * @param int $remaining |
|
82 | + * @throws \EE_Error |
|
83 | + */ |
|
84 | + protected function setTicketStatusDisplay($tkt_status, $ticket_status, $remaining) { |
|
85 | + $this->ticket_status_display = ''; |
|
86 | + // now depending on the ticket and other circumstances... |
|
87 | + if ($this->max_atndz === 0) { |
|
88 | + // registration is CLOSED because admin set max attendees to ZERO |
|
89 | + $this->ticket_status_display = $this->registrationClosed(); |
|
90 | + } else if ($tkt_status === \EE_Ticket::sold_out || $remaining === 0) { |
|
91 | + // SOLD OUT - no tickets remaining |
|
92 | + $this->ticket_status_display = $this->ticketsSoldOut(); |
|
93 | + } else if ($tkt_status === \EE_Ticket::expired || $tkt_status === \EE_Ticket::archived) { |
|
94 | + // expired or archived ticket |
|
95 | + $this->ticket_status_display = $ticket_status; |
|
96 | + } else if ($tkt_status === \EE_Ticket::pending) { |
|
97 | + // ticket not on sale yet |
|
98 | + $this->ticket_status_display = $this->ticketsSalesPending(); |
|
99 | + } else if ($this->ticket->min() > $remaining) { |
|
100 | + // min qty purchasable is less than tickets available |
|
101 | + $this->ticket_status_display = $this->notEnoughTicketsAvailable(); |
|
102 | + } |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * registrationClosed |
|
109 | + */ |
|
110 | + protected function registrationClosed() |
|
111 | + { |
|
112 | + return \EEH_HTML::span( |
|
113 | + apply_filters( |
|
114 | + 'FHEE__ticket_selector_chart_template__ticket_closed_msg', |
|
115 | + __('Closed', 'event_espresso') |
|
116 | + ), |
|
117 | + '', 'sold-out' |
|
118 | + ); |
|
119 | + } |
|
120 | + |
|
121 | + |
|
122 | + |
|
123 | + /** |
|
124 | + * ticketsSoldOut |
|
125 | + */ |
|
126 | + protected function ticketsSoldOut() |
|
127 | + { |
|
128 | + return \EEH_HTML::span( |
|
129 | + apply_filters( |
|
130 | + 'FHEE__ticket_selector_chart_template__ticket_sold_out_msg', |
|
131 | + __('Sold Out', 'event_espresso') |
|
132 | + ), |
|
133 | + '', 'sold-out' |
|
134 | + ); |
|
135 | + } |
|
136 | + |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * ticketsSalesPending |
|
141 | + * |
|
142 | + * @throws \EE_Error |
|
143 | + */ |
|
144 | + protected function ticketsSalesPending() |
|
145 | + { |
|
146 | + return \EEH_HTML::span( |
|
147 | + \EEH_HTML::span( |
|
148 | + apply_filters( |
|
149 | + 'FHEE__ticket_selector_chart_template__ticket_goes_on_sale_msg', |
|
150 | + __('Goes On Sale', 'event_espresso') |
|
151 | + ), |
|
152 | + '', 'ticket-pending' |
|
153 | + ) |
|
154 | + . \EEH_HTML::br() |
|
155 | + . \EEH_HTML::span( |
|
156 | + $this->ticket->get_i18n_datetime( |
|
157 | + 'TKT_start_date', |
|
158 | + apply_filters( |
|
159 | + 'FHEE__EED_Ticket_Selector__display_goes_on_sale__date_format', |
|
160 | + $this->date_format |
|
161 | + ) |
|
162 | + ), |
|
163 | + '', 'small-text' |
|
164 | + ), |
|
165 | + '', 'ticket-pending-pg' |
|
166 | + ); |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + |
|
171 | + /** |
|
172 | + * notEnoughTicketsAvailable |
|
173 | + */ |
|
174 | + protected function notEnoughTicketsAvailable() |
|
175 | + { |
|
176 | + return \EEH_HTML::div( |
|
177 | + \EEH_HTML::span( |
|
178 | + apply_filters( |
|
179 | + 'FHEE__ticket_selector_chart_template__ticket_not_available_msg', |
|
180 | + __('Not Available', 'event_espresso') |
|
181 | + ), |
|
182 | + '', 'archived-ticket small-text' |
|
183 | + ) |
|
184 | + . \EEH_HTML::br(), |
|
185 | + '', 'archived-ticket-pg' |
|
186 | + ); |
|
187 | + } |
|
188 | + |
|
189 | + |
|
190 | + |
|
191 | + /** |
|
192 | + * getHiddenInputs |
|
193 | + * |
|
194 | + * @param string $anchor_id |
|
195 | + * @param int $row |
|
196 | + * @param int $max_atndz |
|
197 | + * @return string |
|
198 | + */ |
|
199 | + protected function getHiddenInputs($anchor_id, $row, $max_atndz) |
|
200 | + { |
|
201 | + $html = '<input type="hidden" name="noheader" value="true"/>'; |
|
202 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->EVT_ID . '"'; |
|
203 | + $html .= ' value="' . \EEH_URL::current_url() . $anchor_id . '"/>'; |
|
204 | + $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->EVT_ID . '" value="' . $row - 1 . '"/>'; |
|
205 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->EVT_ID . '" value="' . $max_atndz . '"/>'; |
|
206 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->EVT_ID . '"/>'; |
|
207 | + return $html; |
|
208 | + } |
|
209 | 209 | |
210 | 210 | |
211 | 211 |
@@ -199,11 +199,11 @@ |
||
199 | 199 | protected function getHiddenInputs($anchor_id, $row, $max_atndz) |
200 | 200 | { |
201 | 201 | $html = '<input type="hidden" name="noheader" value="true"/>'; |
202 | - $html .= '<input type="hidden" name="tkt-slctr-return-url-' . $this->EVT_ID . '"'; |
|
203 | - $html .= ' value="' . \EEH_URL::current_url() . $anchor_id . '"/>'; |
|
204 | - $html .= '<input type="hidden" name="tkt-slctr-rows-' . $this->EVT_ID . '" value="' . $row - 1 . '"/>'; |
|
205 | - $html .= '<input type="hidden" name="tkt-slctr-max-atndz-' . $this->EVT_ID . '" value="' . $max_atndz . '"/>'; |
|
206 | - $html .= '<input type="hidden" name="tkt-slctr-event-id" value="' . $this->EVT_ID . '"/>'; |
|
202 | + $html .= '<input type="hidden" name="tkt-slctr-return-url-'.$this->EVT_ID.'"'; |
|
203 | + $html .= ' value="'.\EEH_URL::current_url().$anchor_id.'"/>'; |
|
204 | + $html .= '<input type="hidden" name="tkt-slctr-rows-'.$this->EVT_ID.'" value="'.$row - 1.'"/>'; |
|
205 | + $html .= '<input type="hidden" name="tkt-slctr-max-atndz-'.$this->EVT_ID.'" value="'.$max_atndz.'"/>'; |
|
206 | + $html .= '<input type="hidden" name="tkt-slctr-event-id" value="'.$this->EVT_ID.'"/>'; |
|
207 | 207 | return $html; |
208 | 208 | } |
209 | 209 |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | <tr> |
29 | 29 | <th scope="col" class="ee-ticket-selector-ticket-details-th"> |
30 | 30 | <?php |
31 | - echo apply_filters( |
|
32 | - 'FHEE__ticket_selector_chart_template__table_header_available_tickets', |
|
33 | - esc_html(''), |
|
34 | - $EVT_ID |
|
35 | - ); |
|
36 | - ?> |
|
31 | + echo apply_filters( |
|
32 | + 'FHEE__ticket_selector_chart_template__table_header_available_tickets', |
|
33 | + esc_html(''), |
|
34 | + $EVT_ID |
|
35 | + ); |
|
36 | + ?> |
|
37 | 37 | </th> |
38 | 38 | <?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?> |
39 | 39 | <th scope="col" class="ee-ticket-selector-ticket-price-th cntr"> |
@@ -47,28 +47,28 @@ discard block |
||
47 | 47 | * @param int $EVT_ID The Event ID |
48 | 48 | */ |
49 | 49 | echo apply_filters( |
50 | - 'FHEE__ticket_selector_chart_template__table_header_price', |
|
51 | - esc_html__( 'Price', 'event_espresso' ), |
|
52 | - $EVT_ID |
|
53 | - ); |
|
50 | + 'FHEE__ticket_selector_chart_template__table_header_price', |
|
51 | + esc_html__( 'Price', 'event_espresso' ), |
|
52 | + $EVT_ID |
|
53 | + ); |
|
54 | 54 | ?> |
55 | 55 | </th> |
56 | 56 | <?php } ?> |
57 | 57 | <th scope="col" class="ee-ticket-selector-ticket-qty-th cntr"> |
58 | 58 | <?php |
59 | 59 | /** |
60 | - * Filters the text printed for the header of the quantity column in the ticket selector table |
|
61 | - * |
|
62 | - * @since 4.7.2 |
|
63 | - * |
|
64 | - * @param string 'Qty' The translatable text to display in the table header for the Quantity of tickets |
|
65 | - * @param int $EVT_ID The Event ID |
|
66 | - */ |
|
60 | + * Filters the text printed for the header of the quantity column in the ticket selector table |
|
61 | + * |
|
62 | + * @since 4.7.2 |
|
63 | + * |
|
64 | + * @param string 'Qty' The translatable text to display in the table header for the Quantity of tickets |
|
65 | + * @param int $EVT_ID The Event ID |
|
66 | + */ |
|
67 | 67 | echo apply_filters( |
68 | - 'FHEE__ticket_selector_chart_template__table_header_qty', |
|
69 | - esc_html__( 'Qty', 'event_espresso' ), |
|
70 | - $EVT_ID |
|
71 | - ); |
|
68 | + 'FHEE__ticket_selector_chart_template__table_header_qty', |
|
69 | + esc_html__( 'Qty', 'event_espresso' ), |
|
70 | + $EVT_ID |
|
71 | + ); |
|
72 | 72 | ?> |
73 | 73 | </th> |
74 | 74 | </tr> |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | if ( $max_atndz > 0 ) { |
99 | 99 | echo apply_filters( |
100 | 100 | 'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote', |
101 | - esc_html('') |
|
101 | + esc_html('') |
|
102 | 102 | ); |
103 | 103 | } |
104 | 104 | if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
@@ -20,7 +20,7 @@ discard block |
||
20 | 20 | ?> |
21 | 21 | <div id="tkt-slctr-tbl-wrap-dv-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl-wrap-dv"> |
22 | 22 | |
23 | - <?php do_action( 'AHEE__ticket_selector_chart__template__before_ticket_selector', $event ); ?> |
|
23 | + <?php do_action('AHEE__ticket_selector_chart__template__before_ticket_selector', $event); ?> |
|
24 | 24 | <?php echo $datetime_selector; ?> |
25 | 25 | |
26 | 26 | <table id="tkt-slctr-tbl-<?php echo $EVT_ID; ?>" class="tkt-slctr-tbl"> |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | ); |
36 | 36 | ?> |
37 | 37 | </th> |
38 | - <?php if ( apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE ) ) { ?> |
|
38 | + <?php if (apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', TRUE)) { ?> |
|
39 | 39 | <th scope="col" class="ee-ticket-selector-ticket-price-th cntr"> |
40 | 40 | <?php |
41 | 41 | /** |
@@ -48,7 +48,7 @@ discard block |
||
48 | 48 | */ |
49 | 49 | echo apply_filters( |
50 | 50 | 'FHEE__ticket_selector_chart_template__table_header_price', |
51 | - esc_html__( 'Price', 'event_espresso' ), |
|
51 | + esc_html__('Price', 'event_espresso'), |
|
52 | 52 | $EVT_ID |
53 | 53 | ); |
54 | 54 | ?> |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | */ |
67 | 67 | echo apply_filters( |
68 | 68 | 'FHEE__ticket_selector_chart_template__table_header_qty', |
69 | - esc_html__( 'Qty', 'event_espresso' ), |
|
69 | + esc_html__('Qty', 'event_espresso'), |
|
70 | 70 | $EVT_ID |
71 | 71 | ); |
72 | 72 | ?> |
@@ -74,34 +74,34 @@ discard block |
||
74 | 74 | </tr> |
75 | 75 | </thead> |
76 | 76 | <tbody> |
77 | - <?php echo $ticket_row_html;?> |
|
77 | + <?php echo $ticket_row_html; ?> |
|
78 | 78 | </tbody> |
79 | 79 | </table> |
80 | 80 | <?php |
81 | - if ( $taxable_tickets && apply_filters( 'FHEE__ticket_selector_chart_template__display_ticket_price_details', true ) ) { |
|
82 | - if ( $prices_displayed_including_taxes ) { |
|
83 | - $ticket_price_includes_taxes = esc_html__( '* price includes taxes', 'event_espresso' ); |
|
81 | + if ($taxable_tickets && apply_filters('FHEE__ticket_selector_chart_template__display_ticket_price_details', true)) { |
|
82 | + if ($prices_displayed_including_taxes) { |
|
83 | + $ticket_price_includes_taxes = esc_html__('* price includes taxes', 'event_espresso'); |
|
84 | 84 | } else { |
85 | - $ticket_price_includes_taxes = esc_html__( '* price does not include taxes', 'event_espresso' ); |
|
85 | + $ticket_price_includes_taxes = esc_html__('* price does not include taxes', 'event_espresso'); |
|
86 | 86 | } |
87 | - echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">' . $ticket_price_includes_taxes . '</p>'; |
|
87 | + echo '<p class="small-text lt-grey-text" style="text-align:right; margin: -1em 0 1em;">'.$ticket_price_includes_taxes.'</p>'; |
|
88 | 88 | } |
89 | 89 | ?> |
90 | 90 | |
91 | 91 | <input type="hidden" name="noheader" value="true" /> |
92 | - <input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::current_url() . $anchor_id; ?>" /> |
|
92 | + <input type="hidden" name="tkt-slctr-return-url-<?php echo $EVT_ID ?>" value="<?php echo EEH_URL::current_url().$anchor_id; ?>" /> |
|
93 | 93 | <input type="hidden" name="tkt-slctr-rows-<?php echo $EVT_ID; ?>" value="<?php echo $row - 1; ?>" /> |
94 | 94 | <input type="hidden" name="tkt-slctr-max-atndz-<?php echo $EVT_ID; ?>" value="<?php echo $max_atndz; ?>" /> |
95 | 95 | <input type="hidden" name="tkt-slctr-event-id" value="<?php echo $EVT_ID; ?>" /> |
96 | 96 | |
97 | 97 | <?php |
98 | -if ( $max_atndz > 0 ) { |
|
98 | +if ($max_atndz > 0) { |
|
99 | 99 | echo apply_filters( |
100 | 100 | 'FHEE__ticket_selector_chart_template__maximum_tickets_purchased_footnote', |
101 | 101 | esc_html('') |
102 | 102 | ); |
103 | 103 | } |
104 | -if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
105 | - add_filter( 'FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true' ); |
|
104 | +if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
105 | + add_filter('FHEE__EE_Ticket_Selector__no_ticket_selector_submit', '__return_true'); |
|
106 | 106 | } |
107 | -do_action( 'AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event ); |
|
108 | 107 | \ No newline at end of file |
108 | +do_action('AHEE__ticket_selector_chart__template__after_ticket_selector', $EVT_ID, $event); |
|
109 | 109 | \ No newline at end of file |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.27.rc.003'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.27.rc.003'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
@@ -22,38 +22,38 @@ discard block |
||
22 | 22 | <p><?php echo $ticket->description(); ?></p> |
23 | 23 | |
24 | 24 | <?php |
25 | - do_action( |
|
26 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
27 | - $ticket, |
|
28 | - $ticket_price, |
|
29 | - $display_ticket_price |
|
30 | - ); |
|
31 | - ?> |
|
25 | + do_action( |
|
26 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
27 | + $ticket, |
|
28 | + $ticket_price, |
|
29 | + $display_ticket_price |
|
30 | + ); |
|
31 | + ?> |
|
32 | 32 | |
33 | 33 | <section class="tckt-slctr-tkt-sale-dates-sctn"> |
34 | 34 | <h5><?php echo apply_filters( |
35 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
36 | - esc_html__( 'Sale Dates', 'event_espresso' ) |
|
37 | - ); ?> |
|
35 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
|
36 | + esc_html__( 'Sale Dates', 'event_espresso' ) |
|
37 | + ); ?> |
|
38 | 38 | </h5> |
39 | 39 | <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( |
40 | - 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
41 | - esc_html__( 'The dates when this option is available for purchase.', 'event_espresso' ) |
|
42 | - ); ?></span> |
|
40 | + 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
|
41 | + esc_html__( 'The dates when this option is available for purchase.', 'event_espresso' ) |
|
42 | + ); ?></span> |
|
43 | 43 | <br/> |
44 | 44 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
45 | - 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
46 | - esc_html__( 'Goes On Sale:', 'event_espresso' ) |
|
47 | - ); ?></span> |
|
45 | + 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
|
46 | + esc_html__( 'Goes On Sale:', 'event_espresso' ) |
|
47 | + ); ?></span> |
|
48 | 48 | <span class="dashicons dashicons-calendar"></span> |
49 | 49 | <?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format) . ' '; ?> |
50 | 50 | <span class="dashicons dashicons-clock"></span> |
51 | 51 | <?php echo $ticket->get_i18n_datetime('TKT_start_date',$time_format); ?> |
52 | 52 | <br/> |
53 | 53 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
54 | - 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
55 | - esc_html__( 'Sales End:', 'event_espresso' ) |
|
56 | - ); ?></span> |
|
54 | + 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
|
55 | + esc_html__( 'Sales End:', 'event_espresso' ) |
|
56 | + ); ?></span> |
|
57 | 57 | <span class="dashicons dashicons-calendar"></span> |
58 | 58 | <?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format) . ' '; ?> |
59 | 59 | <span class="dashicons dashicons-clock"></span> |
@@ -67,34 +67,34 @@ discard block |
||
67 | 67 | <?php if ( $ticket->min() && $ticket->max() ) { ?> |
68 | 68 | <section class="tckt-slctr-tkt-quantities-sctn"> |
69 | 69 | <h5><?php echo apply_filters( |
70 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
71 | - esc_html__( 'Purchasable Quantities', 'event_espresso' ) |
|
72 | - ); ?></h5> |
|
70 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
|
71 | + esc_html__( 'Purchasable Quantities', 'event_espresso' ) |
|
72 | + ); ?></h5> |
|
73 | 73 | <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( |
74 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
75 | - esc_html__( |
|
76 | - 'The number of tickets that can be purchased per transaction (if available).', |
|
77 | - 'event_espresso' |
|
78 | - ) |
|
79 | - ); ?></span><br/> |
|
74 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
|
75 | + esc_html__( |
|
76 | + 'The number of tickets that can be purchased per transaction (if available).', |
|
77 | + 'event_espresso' |
|
78 | + ) |
|
79 | + ); ?></span><br/> |
|
80 | 80 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
81 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
82 | - esc_html__( 'Minimum Qty:', 'event_espresso' ) |
|
83 | - ); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
|
81 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
|
82 | + esc_html__( 'Minimum Qty:', 'event_espresso' ) |
|
83 | + ); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
|
84 | 84 | <?php if ( $ticket->min() > $remaining ) { ?> <span |
85 | 85 | class="important-notice small-text"><?php echo apply_filters( |
86 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
87 | - esc_html__( |
|
88 | - 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
89 | - 'event_espresso' |
|
90 | - ) |
|
91 | - ); ?></span><?php } ?><br/> |
|
86 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
|
87 | + esc_html__( |
|
88 | + 'The Minimum Quantity purchasable for this ticket exceeds the number of spaces remaining', |
|
89 | + 'event_espresso' |
|
90 | + ) |
|
91 | + ); ?></span><?php } ?><br/> |
|
92 | 92 | <?php //$max = min( $max, $max_atndz );?> |
93 | 93 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
94 | - 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
95 | - esc_html__( 'Maximum Qty:', 'event_espresso' ) |
|
96 | - ); ?></span><?php echo $ticket->max() === EE_INF ? esc_html__( 'no limit', 'event_espresso' ) |
|
97 | - : max( $ticket->max(), 1 ); ?><br/> |
|
94 | + 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
|
95 | + esc_html__( 'Maximum Qty:', 'event_espresso' ) |
|
96 | + ); ?></span><?php echo $ticket->max() === EE_INF ? esc_html__( 'no limit', 'event_espresso' ) |
|
97 | + : max( $ticket->max(), 1 ); ?><br/> |
|
98 | 98 | </section> |
99 | 99 | <br/> |
100 | 100 | <?php } ?> |
@@ -102,43 +102,43 @@ discard block |
||
102 | 102 | <?php if ( ( ! defined( 'EE_DECAF' ) || EE_DECAF !== true ) && $ticket->uses() !== EE_INF ) { ?> |
103 | 103 | <section class="tckt-slctr-tkt-uses-sctn"> |
104 | 104 | <h5><?php echo apply_filters( |
105 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
106 | - esc_html__( 'Event Date Ticket Uses', 'event_espresso' ) |
|
107 | - ); ?></h5> |
|
105 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
|
106 | + esc_html__( 'Event Date Ticket Uses', 'event_espresso' ) |
|
107 | + ); ?></h5> |
|
108 | 108 | <span class="drk-grey-text small-text no-bold"> - <?php |
109 | - echo apply_filters( |
|
110 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
111 | - sprintf( |
|
112 | - esc_html__( |
|
113 | - 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
114 | - 'event_espresso' |
|
115 | - ), |
|
116 | - '<br/>', |
|
117 | - '<strong>', |
|
118 | - '</strong>' |
|
119 | - ) |
|
120 | - ); |
|
121 | - ?></span><br/> |
|
109 | + echo apply_filters( |
|
110 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_message', |
|
111 | + sprintf( |
|
112 | + esc_html__( |
|
113 | + 'The number of separate event datetimes (see table below) that this ticket can be used to gain admittance to.%1$s%2$sAdmission is always one person per ticket.%3$s', |
|
114 | + 'event_espresso' |
|
115 | + ), |
|
116 | + '<br/>', |
|
117 | + '<strong>', |
|
118 | + '</strong>' |
|
119 | + ) |
|
120 | + ); |
|
121 | + ?></span><br/> |
|
122 | 122 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
123 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
124 | - esc_html__( '# Datetimes:', 'event_espresso' ) |
|
125 | - ); ?></span><?php echo $ticket->uses(); ?><br/> |
|
123 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
|
124 | + esc_html__( '# Datetimes:', 'event_espresso' ) |
|
125 | + ); ?></span><?php echo $ticket->uses(); ?><br/> |
|
126 | 126 | </section> |
127 | 127 | <?php } ?> |
128 | 128 | |
129 | 129 | <?php |
130 | - $datetimes = $ticket->datetimes_ordered( $event_is_expired, false ); |
|
131 | - $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
132 | - if ( ! empty( $datetimes ) ) { ?> |
|
130 | + $datetimes = $ticket->datetimes_ordered( $event_is_expired, false ); |
|
131 | + $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
|
132 | + if ( ! empty( $datetimes ) ) { ?> |
|
133 | 133 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
134 | 134 | <h5><?php echo apply_filters( |
135 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
136 | - esc_html__( 'Access', 'event_espresso' ) |
|
137 | - ); ?></h5> |
|
135 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
|
136 | + esc_html__( 'Access', 'event_espresso' ) |
|
137 | + ); ?></h5> |
|
138 | 138 | <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( |
139 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
140 | - esc_html__( 'This option allows access to the following dates and times.', 'event_espresso' ) |
|
141 | - ); ?></span> |
|
139 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
|
140 | + esc_html__( 'This option allows access to the following dates and times.', 'event_espresso' ) |
|
141 | + ); ?></span> |
|
142 | 142 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
143 | 143 | <table class="tckt-slctr-tkt-details-tbl"> |
144 | 144 | <thead> |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | <th class="tckt-slctr-tkt-details-date-th"> |
147 | 147 | <span class="dashicons dashicons-calendar"></span><span |
148 | 148 | class="small-text"><?php echo apply_filters( |
149 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
150 | - esc_html__( 'Date ', 'event_espresso' ) |
|
151 | - ); ?></span> |
|
149 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
150 | + esc_html__( 'Date ', 'event_espresso' ) |
|
151 | + ); ?></span> |
|
152 | 152 | </th> |
153 | 153 | <th class="tckt-slctr-tkt-details-time-th <?php echo $chart_column_width; ?>"> |
154 | 154 | <span class="dashicons dashicons-clock"></span><span |
@@ -157,98 +157,98 @@ discard block |
||
157 | 157 | <?php if ( $show_ticket_sale_columns ) : ?> |
158 | 158 | <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr"> |
159 | 159 | <span class="smaller-text"><?php echo apply_filters( |
160 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
161 | - sprintf( esc_html__( 'Sold', 'event_espresso' ), '<br/>' ) |
|
162 | - ); ?></span> |
|
160 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
161 | + sprintf( esc_html__( 'Sold', 'event_espresso' ), '<br/>' ) |
|
162 | + ); ?></span> |
|
163 | 163 | </th> |
164 | 164 | <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr"> |
165 | 165 | <span class="smaller-text"><?php echo apply_filters( |
166 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
167 | - sprintf( esc_html__( 'Remaining', 'event_espresso' ), '<br/>' ) |
|
168 | - ); ?></span> |
|
166 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
167 | + sprintf( esc_html__( 'Remaining', 'event_espresso' ), '<br/>' ) |
|
168 | + ); ?></span> |
|
169 | 169 | </th> |
170 | 170 | <th |
171 | 171 | class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr"> |
172 | 172 | <span class="smaller-text"><?php echo apply_filters( |
173 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
174 | - sprintf( esc_html__( 'Total%sSold', 'event_espresso' ), '<br/>' ) |
|
175 | - ); ?></span> |
|
173 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
174 | + sprintf( esc_html__( 'Total%sSold', 'event_espresso' ), '<br/>' ) |
|
175 | + ); ?></span> |
|
176 | 176 | </th> |
177 | 177 | <th |
178 | 178 | class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr"> |
179 | 179 | <span class="smaller-text"><?php echo apply_filters( |
180 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
181 | - sprintf( esc_html__( 'Total Spaces%sLeft', 'event_espresso' ), '<br/>' ) |
|
182 | - ); ?></span> |
|
180 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
181 | + sprintf( esc_html__( 'Total Spaces%sLeft', 'event_espresso' ), '<br/>' ) |
|
182 | + ); ?></span> |
|
183 | 183 | </th> |
184 | 184 | <?php endif; //end $show_ticket_sale_columns conditional ?> |
185 | 185 | </tr> |
186 | 186 | </thead> |
187 | 187 | <tbody> |
188 | 188 | <?php |
189 | - foreach ( $datetimes as $datetime ) { |
|
190 | - if ( $datetime instanceof EE_Datetime ) { |
|
191 | - ?> |
|
189 | + foreach ( $datetimes as $datetime ) { |
|
190 | + if ( $datetime instanceof EE_Datetime ) { |
|
191 | + ?> |
|
192 | 192 | |
193 | 193 | <tr> |
194 | 194 | <td data-th="<?php echo apply_filters( |
195 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
196 | - esc_html__( 'Event Date ', 'event_espresso' ) |
|
197 | - ); ?>" class="small-text"> |
|
195 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
|
196 | + esc_html__( 'Event Date ', 'event_espresso' ) |
|
197 | + ); ?>" class="small-text"> |
|
198 | 198 | <?php $datetime_name = $datetime->name(); ?> |
199 | 199 | <?php echo ! empty( $datetime_name ) ? '<b>' |
200 | - . $datetime_name |
|
201 | - . '</b><br/>' : ''; ?> |
|
200 | + . $datetime_name |
|
201 | + . '</b><br/>' : ''; ?> |
|
202 | 202 | <?php echo $datetime->date_range( |
203 | - $date_format, |
|
204 | - esc_html__( ' to ', 'event_espresso' ) |
|
205 | - ); ?> |
|
203 | + $date_format, |
|
204 | + esc_html__( ' to ', 'event_espresso' ) |
|
205 | + ); ?> |
|
206 | 206 | </td> |
207 | 207 | <td data-th="<?php esc_html_e( 'Time ', 'event_espresso' ); ?>" |
208 | 208 | class="cntr small-text"> |
209 | 209 | <?php echo $datetime->time_range( |
210 | - $time_format, |
|
211 | - esc_html__( ' to ', 'event_espresso' ) |
|
212 | - ); ?> |
|
210 | + $time_format, |
|
211 | + esc_html__( ' to ', 'event_espresso' ) |
|
212 | + ); ?> |
|
213 | 213 | </td> |
214 | 214 | <?php if ( $show_ticket_sale_columns ) : ?> |
215 | 215 | <td data-th="<?php echo apply_filters( |
216 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
217 | - esc_html__( 'Sold', 'event_espresso' ) |
|
218 | - ); ?>" class="cntr small-text"> |
|
216 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
|
217 | + esc_html__( 'Sold', 'event_espresso' ) |
|
218 | + ); ?>" class="cntr small-text"> |
|
219 | 219 | <?php echo $ticket->sold(); ?> |
220 | 220 | </td> |
221 | 221 | <td data-th="<?php echo apply_filters( |
222 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
223 | - esc_html__( 'Remaining', 'event_espresso' ) |
|
224 | - ); ?>" class="cntr small-text"> |
|
222 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
|
223 | + esc_html__( 'Remaining', 'event_espresso' ) |
|
224 | + ); ?>" class="cntr small-text"> |
|
225 | 225 | <?php echo $remaining === EE_INF |
226 | - ? '<span class="smaller-text">' . esc_html__( |
|
227 | - 'unlimited ', |
|
228 | - 'event_espresso' |
|
229 | - ) . '</span>' : $remaining; ?> |
|
226 | + ? '<span class="smaller-text">' . esc_html__( |
|
227 | + 'unlimited ', |
|
228 | + 'event_espresso' |
|
229 | + ) . '</span>' : $remaining; ?> |
|
230 | 230 | </td> |
231 | 231 | <td data-th="<?php echo apply_filters( |
232 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
233 | - esc_html__( 'Total Sold', 'event_espresso' ) |
|
234 | - ); ?>" class="cntr small-text"> |
|
232 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
|
233 | + esc_html__( 'Total Sold', 'event_espresso' ) |
|
234 | + ); ?>" class="cntr small-text"> |
|
235 | 235 | <?php echo $datetime->sold(); ?> |
236 | 236 | </td> |
237 | 237 | <?php $tkts_left = $datetime->sold_out() |
238 | - ? '<span class="sold-out smaller-text">' . esc_html__( |
|
239 | - 'Sold Out', |
|
240 | - 'event_espresso' |
|
241 | - ) . '</span>' : $datetime->spaces_remaining(); ?> |
|
238 | + ? '<span class="sold-out smaller-text">' . esc_html__( |
|
239 | + 'Sold Out', |
|
240 | + 'event_espresso' |
|
241 | + ) . '</span>' : $datetime->spaces_remaining(); ?> |
|
242 | 242 | <td data-th="<?php echo apply_filters( |
243 | - 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
244 | - esc_html__( 'Total Spaces Left', 'event_espresso' ) |
|
245 | - ); ?>" class="cntr small-text"> |
|
243 | + 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
|
244 | + esc_html__( 'Total Spaces Left', 'event_espresso' ) |
|
245 | + ); ?>" class="cntr small-text"> |
|
246 | 246 | <?php echo $tkts_left === EE_INF ? '<span class="smaller-text">' |
247 | - . esc_html__( |
|
248 | - 'unlimited ', |
|
249 | - 'event_espresso' |
|
250 | - ) |
|
251 | - . '</span>' : $tkts_left; ?> |
|
247 | + . esc_html__( |
|
248 | + 'unlimited ', |
|
249 | + 'event_espresso' |
|
250 | + ) |
|
251 | + . '</span>' : $tkts_left; ?> |
|
252 | 252 | </td> |
253 | 253 | <?php endif; //end $show_ticket_sale_columns conditional ?> |
254 | 254 | </tr> |
@@ -12,13 +12,13 @@ discard block |
||
12 | 12 | /** @var string $price_breakdown_heading */ |
13 | 13 | /** @var \EventEspresso\modules\ticket_selector\TicketDetails $ticket_details */ |
14 | 14 | ?> |
15 | -<?php if ( $show_ticket_details ) : ?> |
|
15 | +<?php if ($show_ticket_details) : ?> |
|
16 | 16 | <tr class="tckt-slctr-tkt-details-tr <?php echo $ticket_details_row_class; ?>"> |
17 | 17 | <td class="tckt-slctr-tkt-details-td" colspan="<?php echo $cols; ?>"> |
18 | 18 | <div id="<?php echo $ticket_details_css_id; ?>-dv" class="tckt-slctr-tkt-details-dv" style="display: none;"> |
19 | 19 | |
20 | 20 | <section class="tckt-slctr-tkt-details-sctn"> |
21 | - <h3><?php echo esc_html__( 'Details', 'event_espresso' ); ?></h3> |
|
21 | + <h3><?php echo esc_html__('Details', 'event_espresso'); ?></h3> |
|
22 | 22 | <p><?php echo $ticket->description(); ?></p> |
23 | 23 | |
24 | 24 | <?php |
@@ -33,42 +33,42 @@ discard block |
||
33 | 33 | <section class="tckt-slctr-tkt-sale-dates-sctn"> |
34 | 34 | <h5><?php echo apply_filters( |
35 | 35 | 'FHEE__ticket_selector_chart_template__ticket_details_sales_date_heading', |
36 | - esc_html__( 'Sale Dates', 'event_espresso' ) |
|
36 | + esc_html__('Sale Dates', 'event_espresso') |
|
37 | 37 | ); ?> |
38 | 38 | </h5> |
39 | 39 | <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( |
40 | 40 | 'FHEE__ticket_selector_chart_template__ticket_details_dates_available_message', |
41 | - esc_html__( 'The dates when this option is available for purchase.', 'event_espresso' ) |
|
41 | + esc_html__('The dates when this option is available for purchase.', 'event_espresso') |
|
42 | 42 | ); ?></span> |
43 | 43 | <br/> |
44 | 44 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
45 | 45 | 'FHEE__ticket_selector_chart_template__ticket_details_goes_on_sale', |
46 | - esc_html__( 'Goes On Sale:', 'event_espresso' ) |
|
46 | + esc_html__('Goes On Sale:', 'event_espresso') |
|
47 | 47 | ); ?></span> |
48 | 48 | <span class="dashicons dashicons-calendar"></span> |
49 | - <?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format) . ' '; ?> |
|
49 | + <?php echo $ticket->get_i18n_datetime('TKT_start_date', $date_format).' '; ?> |
|
50 | 50 | <span class="dashicons dashicons-clock"></span> |
51 | - <?php echo $ticket->get_i18n_datetime('TKT_start_date',$time_format); ?> |
|
51 | + <?php echo $ticket->get_i18n_datetime('TKT_start_date', $time_format); ?> |
|
52 | 52 | <br/> |
53 | 53 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
54 | 54 | 'FHEE__ticket_selector_chart_template__ticket_details_sales_end', |
55 | - esc_html__( 'Sales End:', 'event_espresso' ) |
|
55 | + esc_html__('Sales End:', 'event_espresso') |
|
56 | 56 | ); ?></span> |
57 | 57 | <span class="dashicons dashicons-calendar"></span> |
58 | - <?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format) . ' '; ?> |
|
58 | + <?php echo $ticket->get_i18n_datetime('TKT_end_date', $date_format).' '; ?> |
|
59 | 59 | <span class="dashicons dashicons-clock"></span> |
60 | 60 | <?php echo $ticket->get_i18n_datetime('TKT_end_date', $time_format); ?> |
61 | 61 | <br/> |
62 | 62 | </section> |
63 | 63 | <br/> |
64 | 64 | |
65 | - <?php do_action( 'AHEE__ticket_selector_chart_template__after_ticket_date', $ticket ); ?> |
|
65 | + <?php do_action('AHEE__ticket_selector_chart_template__after_ticket_date', $ticket); ?> |
|
66 | 66 | |
67 | - <?php if ( $ticket->min() && $ticket->max() ) { ?> |
|
67 | + <?php if ($ticket->min() && $ticket->max()) { ?> |
|
68 | 68 | <section class="tckt-slctr-tkt-quantities-sctn"> |
69 | 69 | <h5><?php echo apply_filters( |
70 | 70 | 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_heading', |
71 | - esc_html__( 'Purchasable Quantities', 'event_espresso' ) |
|
71 | + esc_html__('Purchasable Quantities', 'event_espresso') |
|
72 | 72 | ); ?></h5> |
73 | 73 | <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( |
74 | 74 | 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_message', |
@@ -79,9 +79,9 @@ discard block |
||
79 | 79 | ); ?></span><br/> |
80 | 80 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
81 | 81 | 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty', |
82 | - esc_html__( 'Minimum Qty:', 'event_espresso' ) |
|
82 | + esc_html__('Minimum Qty:', 'event_espresso') |
|
83 | 83 | ); ?></span><?php echo $ticket->min() > 0 ? $ticket->min() : 0; ?> |
84 | - <?php if ( $ticket->min() > $remaining ) { ?> <span |
|
84 | + <?php if ($ticket->min() > $remaining) { ?> <span |
|
85 | 85 | class="important-notice small-text"><?php echo apply_filters( |
86 | 86 | 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_min_qty_message', |
87 | 87 | esc_html__( |
@@ -92,18 +92,18 @@ discard block |
||
92 | 92 | <?php //$max = min( $max, $max_atndz );?> |
93 | 93 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
94 | 94 | 'FHEE__ticket_selector_chart_template__ticket_details_purchasable_quantities_max_qty', |
95 | - esc_html__( 'Maximum Qty:', 'event_espresso' ) |
|
96 | - ); ?></span><?php echo $ticket->max() === EE_INF ? esc_html__( 'no limit', 'event_espresso' ) |
|
97 | - : max( $ticket->max(), 1 ); ?><br/> |
|
95 | + esc_html__('Maximum Qty:', 'event_espresso') |
|
96 | + ); ?></span><?php echo $ticket->max() === EE_INF ? esc_html__('no limit', 'event_espresso') |
|
97 | + : max($ticket->max(), 1); ?><br/> |
|
98 | 98 | </section> |
99 | 99 | <br/> |
100 | 100 | <?php } ?> |
101 | 101 | |
102 | - <?php if ( ( ! defined( 'EE_DECAF' ) || EE_DECAF !== true ) && $ticket->uses() !== EE_INF ) { ?> |
|
102 | + <?php if (( ! defined('EE_DECAF') || EE_DECAF !== true) && $ticket->uses() !== EE_INF) { ?> |
|
103 | 103 | <section class="tckt-slctr-tkt-uses-sctn"> |
104 | 104 | <h5><?php echo apply_filters( |
105 | 105 | 'FHEE__ticket_selector_chart_template__ticket_details_event_date_ticket_uses_heading', |
106 | - esc_html__( 'Event Date Ticket Uses', 'event_espresso' ) |
|
106 | + esc_html__('Event Date Ticket Uses', 'event_espresso') |
|
107 | 107 | ); ?></h5> |
108 | 108 | <span class="drk-grey-text small-text no-bold"> - <?php |
109 | 109 | echo apply_filters( |
@@ -121,23 +121,23 @@ discard block |
||
121 | 121 | ?></span><br/> |
122 | 122 | <span class="ticket-details-label-spn drk-grey-text"><?php echo apply_filters( |
123 | 123 | 'FHEE__ticket_selector_chart_template__ticket_details_event_date_number_datetimes', |
124 | - esc_html__( '# Datetimes:', 'event_espresso' ) |
|
124 | + esc_html__('# Datetimes:', 'event_espresso') |
|
125 | 125 | ); ?></span><?php echo $ticket->uses(); ?><br/> |
126 | 126 | </section> |
127 | 127 | <?php } ?> |
128 | 128 | |
129 | 129 | <?php |
130 | - $datetimes = $ticket->datetimes_ordered( $event_is_expired, false ); |
|
130 | + $datetimes = $ticket->datetimes_ordered($event_is_expired, false); |
|
131 | 131 | $chart_column_width = $show_ticket_sale_columns ? ' ee-fourth-width' : ' ee-half-width'; |
132 | - if ( ! empty( $datetimes ) ) { ?> |
|
132 | + if ( ! empty($datetimes)) { ?> |
|
133 | 133 | <section class="tckt-slctr-tkt-datetimes-sctn"> |
134 | 134 | <h5><?php echo apply_filters( |
135 | 135 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_heading', |
136 | - esc_html__( 'Access', 'event_espresso' ) |
|
136 | + esc_html__('Access', 'event_espresso') |
|
137 | 137 | ); ?></h5> |
138 | 138 | <span class="drk-grey-text small-text no-bold"> - <?php echo apply_filters( |
139 | 139 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_message', |
140 | - esc_html__( 'This option allows access to the following dates and times.', 'event_espresso' ) |
|
140 | + esc_html__('This option allows access to the following dates and times.', 'event_espresso') |
|
141 | 141 | ); ?></span> |
142 | 142 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
143 | 143 | <table class="tckt-slctr-tkt-details-tbl"> |
@@ -147,38 +147,38 @@ discard block |
||
147 | 147 | <span class="dashicons dashicons-calendar"></span><span |
148 | 148 | class="small-text"><?php echo apply_filters( |
149 | 149 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
150 | - esc_html__( 'Date ', 'event_espresso' ) |
|
150 | + esc_html__('Date ', 'event_espresso') |
|
151 | 151 | ); ?></span> |
152 | 152 | </th> |
153 | 153 | <th class="tckt-slctr-tkt-details-time-th <?php echo $chart_column_width; ?>"> |
154 | 154 | <span class="dashicons dashicons-clock"></span><span |
155 | - class="small-text"><?php esc_html_e( 'Time ', 'event_espresso' ); ?></span> |
|
155 | + class="small-text"><?php esc_html_e('Time ', 'event_espresso'); ?></span> |
|
156 | 156 | </th> |
157 | - <?php if ( $show_ticket_sale_columns ) : ?> |
|
157 | + <?php if ($show_ticket_sale_columns) : ?> |
|
158 | 158 | <th class="tckt-slctr-tkt-details-this-ticket-sold-th ee-fourth-width cntr"> |
159 | 159 | <span class="smaller-text"><?php echo apply_filters( |
160 | 160 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
161 | - sprintf( esc_html__( 'Sold', 'event_espresso' ), '<br/>' ) |
|
161 | + sprintf(esc_html__('Sold', 'event_espresso'), '<br/>') |
|
162 | 162 | ); ?></span> |
163 | 163 | </th> |
164 | 164 | <th class="tckt-slctr-tkt-details-this-ticket-left-th ee-fourth-width cntr"> |
165 | 165 | <span class="smaller-text"><?php echo apply_filters( |
166 | 166 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
167 | - sprintf( esc_html__( 'Remaining', 'event_espresso' ), '<br/>' ) |
|
167 | + sprintf(esc_html__('Remaining', 'event_espresso'), '<br/>') |
|
168 | 168 | ); ?></span> |
169 | 169 | </th> |
170 | 170 | <th |
171 | 171 | class="tckt-slctr-tkt-details-total-tickets-sold-th ee-fourth-width cntr"> |
172 | 172 | <span class="smaller-text"><?php echo apply_filters( |
173 | 173 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
174 | - sprintf( esc_html__( 'Total%sSold', 'event_espresso' ), '<br/>' ) |
|
174 | + sprintf(esc_html__('Total%sSold', 'event_espresso'), '<br/>') |
|
175 | 175 | ); ?></span> |
176 | 176 | </th> |
177 | 177 | <th |
178 | 178 | class="tckt-slctr-tkt-details-total-tickets-left-th ee-fourth-width cntr"> |
179 | 179 | <span class="smaller-text"><?php echo apply_filters( |
180 | 180 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
181 | - sprintf( esc_html__( 'Total Spaces%sLeft', 'event_espresso' ), '<br/>' ) |
|
181 | + sprintf(esc_html__('Total Spaces%sLeft', 'event_espresso'), '<br/>') |
|
182 | 182 | ); ?></span> |
183 | 183 | </th> |
184 | 184 | <?php endif; //end $show_ticket_sale_columns conditional ?> |
@@ -186,62 +186,62 @@ discard block |
||
186 | 186 | </thead> |
187 | 187 | <tbody> |
188 | 188 | <?php |
189 | - foreach ( $datetimes as $datetime ) { |
|
190 | - if ( $datetime instanceof EE_Datetime ) { |
|
189 | + foreach ($datetimes as $datetime) { |
|
190 | + if ($datetime instanceof EE_Datetime) { |
|
191 | 191 | ?> |
192 | 192 | |
193 | 193 | <tr> |
194 | 194 | <td data-th="<?php echo apply_filters( |
195 | 195 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_event_date', |
196 | - esc_html__( 'Event Date ', 'event_espresso' ) |
|
196 | + esc_html__('Event Date ', 'event_espresso') |
|
197 | 197 | ); ?>" class="small-text"> |
198 | 198 | <?php $datetime_name = $datetime->name(); ?> |
199 | - <?php echo ! empty( $datetime_name ) ? '<b>' |
|
199 | + <?php echo ! empty($datetime_name) ? '<b>' |
|
200 | 200 | . $datetime_name |
201 | 201 | . '</b><br/>' : ''; ?> |
202 | 202 | <?php echo $datetime->date_range( |
203 | 203 | $date_format, |
204 | - esc_html__( ' to ', 'event_espresso' ) |
|
204 | + esc_html__(' to ', 'event_espresso') |
|
205 | 205 | ); ?> |
206 | 206 | </td> |
207 | - <td data-th="<?php esc_html_e( 'Time ', 'event_espresso' ); ?>" |
|
207 | + <td data-th="<?php esc_html_e('Time ', 'event_espresso'); ?>" |
|
208 | 208 | class="cntr small-text"> |
209 | 209 | <?php echo $datetime->time_range( |
210 | 210 | $time_format, |
211 | - esc_html__( ' to ', 'event_espresso' ) |
|
211 | + esc_html__(' to ', 'event_espresso') |
|
212 | 212 | ); ?> |
213 | 213 | </td> |
214 | - <?php if ( $show_ticket_sale_columns ) : ?> |
|
214 | + <?php if ($show_ticket_sale_columns) : ?> |
|
215 | 215 | <td data-th="<?php echo apply_filters( |
216 | 216 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_sold', |
217 | - esc_html__( 'Sold', 'event_espresso' ) |
|
217 | + esc_html__('Sold', 'event_espresso') |
|
218 | 218 | ); ?>" class="cntr small-text"> |
219 | 219 | <?php echo $ticket->sold(); ?> |
220 | 220 | </td> |
221 | 221 | <td data-th="<?php echo apply_filters( |
222 | 222 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_this_ticket_left', |
223 | - esc_html__( 'Remaining', 'event_espresso' ) |
|
223 | + esc_html__('Remaining', 'event_espresso') |
|
224 | 224 | ); ?>" class="cntr small-text"> |
225 | 225 | <?php echo $remaining === EE_INF |
226 | - ? '<span class="smaller-text">' . esc_html__( |
|
226 | + ? '<span class="smaller-text">'.esc_html__( |
|
227 | 227 | 'unlimited ', |
228 | 228 | 'event_espresso' |
229 | - ) . '</span>' : $remaining; ?> |
|
229 | + ).'</span>' : $remaining; ?> |
|
230 | 230 | </td> |
231 | 231 | <td data-th="<?php echo apply_filters( |
232 | 232 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_sold', |
233 | - esc_html__( 'Total Sold', 'event_espresso' ) |
|
233 | + esc_html__('Total Sold', 'event_espresso') |
|
234 | 234 | ); ?>" class="cntr small-text"> |
235 | 235 | <?php echo $datetime->sold(); ?> |
236 | 236 | </td> |
237 | 237 | <?php $tkts_left = $datetime->sold_out() |
238 | - ? '<span class="sold-out smaller-text">' . esc_html__( |
|
238 | + ? '<span class="sold-out smaller-text">'.esc_html__( |
|
239 | 239 | 'Sold Out', |
240 | 240 | 'event_espresso' |
241 | - ) . '</span>' : $datetime->spaces_remaining(); ?> |
|
241 | + ).'</span>' : $datetime->spaces_remaining(); ?> |
|
242 | 242 | <td data-th="<?php echo apply_filters( |
243 | 243 | 'FHEE__ticket_selector_chart_template__ticket_details_event_access_table_total_ticket_left', |
244 | - esc_html__( 'Total Spaces Left', 'event_espresso' ) |
|
244 | + esc_html__('Total Spaces Left', 'event_espresso') |
|
245 | 245 | ); ?>" class="cntr small-text"> |
246 | 246 | <?php echo $tkts_left === EE_INF ? '<span class="smaller-text">' |
247 | 247 | . esc_html__( |
@@ -266,4 +266,4 @@ discard block |
||
266 | 266 | </div> |
267 | 267 | </td> |
268 | 268 | </tr> |
269 | -<?php endif; //end template_settings->show_ticket_details check?> |
|
270 | 269 | \ No newline at end of file |
270 | +<?php endif; //end template_settings->show_ticket_details check?> |
|
271 | 271 | \ No newline at end of file |
@@ -28,12 +28,12 @@ discard block |
||
28 | 28 | * @return void |
29 | 29 | */ |
30 | 30 | public static function set_hooks() { |
31 | - add_action( |
|
32 | - 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
33 | - array('EED_Ticket_Selector_Caff', 'ticket_price_details'), |
|
34 | - 10, |
|
35 | - 3 |
|
36 | - ); |
|
31 | + add_action( |
|
32 | + 'AHEE__ticket_selector_chart_template__ticket_details__after_description', |
|
33 | + array('EED_Ticket_Selector_Caff', 'ticket_price_details'), |
|
34 | + 10, |
|
35 | + 3 |
|
36 | + ); |
|
37 | 37 | } |
38 | 38 | |
39 | 39 | /** |
@@ -53,14 +53,14 @@ discard block |
||
53 | 53 | * @param \WP $WP |
54 | 54 | */ |
55 | 55 | public function run( $WP ) { |
56 | - $this->set_config(); |
|
56 | + $this->set_config(); |
|
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | 61 | |
62 | 62 | protected function set_config(){ |
63 | - $this->set_config_section( 'template_settings' ); |
|
63 | + $this->set_config_section( 'template_settings' ); |
|
64 | 64 | $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
65 | 65 | $this->set_config_name( 'EED_Ticket_Selector' ); |
66 | 66 | } |
@@ -109,27 +109,27 @@ discard block |
||
109 | 109 | |
110 | 110 | |
111 | 111 | |
112 | - /** |
|
113 | - * @return \EE_Form_Section_Proper |
|
114 | - * @throws \EE_Error |
|
115 | - */ |
|
116 | - public static function _ticket_selector_appearance_settings() { |
|
117 | - if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
118 | - \EED_Ticket_Selector::instance()->set_config(); |
|
119 | - \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
120 | - } |
|
121 | - // get option for whether to show datetime selector in TS |
|
122 | - $show_datetime_selector = \EE_Registry::instance() |
|
123 | - ->CFG |
|
124 | - ->template_settings |
|
125 | - ->EED_Ticket_Selector |
|
126 | - ->getShowDatetimeSelector(); |
|
127 | - // and option for how may datetimes must exist if display is conditional |
|
128 | - $datetime_selector_threshold = \EE_Registry::instance() |
|
129 | - ->CFG |
|
130 | - ->template_settings |
|
131 | - ->EED_Ticket_Selector |
|
132 | - ->getDatetimeSelectorThreshold(); |
|
112 | + /** |
|
113 | + * @return \EE_Form_Section_Proper |
|
114 | + * @throws \EE_Error |
|
115 | + */ |
|
116 | + public static function _ticket_selector_appearance_settings() { |
|
117 | + if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
118 | + \EED_Ticket_Selector::instance()->set_config(); |
|
119 | + \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
120 | + } |
|
121 | + // get option for whether to show datetime selector in TS |
|
122 | + $show_datetime_selector = \EE_Registry::instance() |
|
123 | + ->CFG |
|
124 | + ->template_settings |
|
125 | + ->EED_Ticket_Selector |
|
126 | + ->getShowDatetimeSelector(); |
|
127 | + // and option for how may datetimes must exist if display is conditional |
|
128 | + $datetime_selector_threshold = \EE_Registry::instance() |
|
129 | + ->CFG |
|
130 | + ->template_settings |
|
131 | + ->EED_Ticket_Selector |
|
132 | + ->getDatetimeSelectorThreshold(); |
|
133 | 133 | |
134 | 134 | return new EE_Form_Section_Proper( |
135 | 135 | array( |
@@ -171,19 +171,19 @@ discard block |
||
171 | 171 | ) |
172 | 172 | ), |
173 | 173 | 'show_datetime_selector' => new EE_Select_Input( |
174 | - \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false), |
|
174 | + \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false), |
|
175 | 175 | array( |
176 | 176 | 'html_label_text' => esc_html__( 'Show Date & Time Filter?', 'event_espresso' ), |
177 | 177 | 'html_help_text' => sprintf( |
178 | - esc_html__( |
|
179 | - 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
|
180 | - 'event_espresso' |
|
181 | - ), |
|
182 | - '<br>', |
|
183 | - '<strong>', |
|
184 | - '</strong>' |
|
185 | - |
|
186 | - ), |
|
178 | + esc_html__( |
|
179 | + 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
|
180 | + 'event_espresso' |
|
181 | + ), |
|
182 | + '<br>', |
|
183 | + '<strong>', |
|
184 | + '</strong>' |
|
185 | + |
|
186 | + ), |
|
187 | 187 | 'default' => ! empty( $show_datetime_selector ) |
188 | 188 | ? $show_datetime_selector |
189 | 189 | : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
@@ -191,13 +191,13 @@ discard block |
||
191 | 191 | ) |
192 | 192 | ), |
193 | 193 | 'datetime_selector_threshold' => new EE_Select_Input( |
194 | - array_combine($r = range(1, 10), $r), |
|
194 | + array_combine($r = range(1, 10), $r), |
|
195 | 195 | array( |
196 | 196 | 'html_label_text' => esc_html__( 'Date & Time Filter Threshold', 'event_espresso' ), |
197 | 197 | 'html_help_text' => esc_html__( |
198 | - 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
|
199 | - 'event_espresso' |
|
200 | - ), |
|
198 | + 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
|
199 | + 'event_espresso' |
|
200 | + ), |
|
201 | 201 | 'default' => ! empty( $datetime_selector_threshold ) |
202 | 202 | ? $datetime_selector_threshold |
203 | 203 | : 3, |
@@ -223,8 +223,8 @@ discard block |
||
223 | 223 | */ |
224 | 224 | public static function update_template_settings( EE_Template_Config $CFG, $REQ ) { |
225 | 225 | if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
226 | - \EED_Ticket_Selector::instance()->set_config(); |
|
227 | - $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
226 | + \EED_Ticket_Selector::instance()->set_config(); |
|
227 | + $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
228 | 228 | } |
229 | 229 | try { |
230 | 230 | $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
@@ -246,11 +246,11 @@ discard block |
||
246 | 246 | $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
247 | 247 | $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
248 | 248 | $CFG->EED_Ticket_Selector->setShowDatetimeSelector( |
249 | - $valid_data['appearance_settings']['show_datetime_selector'] |
|
250 | - ); |
|
249 | + $valid_data['appearance_settings']['show_datetime_selector'] |
|
250 | + ); |
|
251 | 251 | $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold( |
252 | - $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
253 | - ); |
|
252 | + $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
253 | + ); |
|
254 | 254 | } else { |
255 | 255 | if ( $ticket_selector_form->submission_error_message() !== '' ) { |
256 | 256 | EE_Error::add_error( $ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
@@ -267,17 +267,17 @@ discard block |
||
267 | 267 | |
268 | 268 | |
269 | 269 | |
270 | - /** |
|
271 | - * @param \EE_Ticket $ticket |
|
272 | - * @param int $ticket_price |
|
273 | - * @param bool $display_ticket_price |
|
274 | - */ |
|
275 | - public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false) |
|
276 | - { |
|
277 | - require( |
|
278 | - str_replace('\\', DS, plugin_dir_path(__FILE__)) |
|
279 | - . 'templates' . DS . 'ticket_selector_price_details.template.php' |
|
280 | - ); |
|
270 | + /** |
|
271 | + * @param \EE_Ticket $ticket |
|
272 | + * @param int $ticket_price |
|
273 | + * @param bool $display_ticket_price |
|
274 | + */ |
|
275 | + public static function ticket_price_details(EE_Ticket $ticket, $ticket_price = 0, $display_ticket_price = false) |
|
276 | + { |
|
277 | + require( |
|
278 | + str_replace('\\', DS, plugin_dir_path(__FILE__)) |
|
279 | + . 'templates' . DS . 'ticket_selector_price_details.template.php' |
|
280 | + ); |
|
281 | 281 | } |
282 | 282 | |
283 | 283 |
@@ -16,7 +16,7 @@ discard block |
||
16 | 16 | * @return EED_Ticket_Selector_Caff |
17 | 17 | */ |
18 | 18 | public static function instance() { |
19 | - return parent::get_instance( __CLASS__ ); |
|
19 | + return parent::get_instance(__CLASS__); |
|
20 | 20 | } |
21 | 21 | |
22 | 22 | |
@@ -43,26 +43,26 @@ discard block |
||
43 | 43 | * @return void |
44 | 44 | */ |
45 | 45 | public static function set_hooks_admin() { |
46 | - define( 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
47 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Ticket_Selector_Caff', 'template_settings_form' ), 10 ); |
|
48 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Ticket_Selector_Caff', 'update_template_settings' ), 10, 2 ); |
|
46 | + define('TICKET_SELECTOR_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
47 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Ticket_Selector_Caff', 'template_settings_form'), 10); |
|
48 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Ticket_Selector_Caff', 'update_template_settings'), 10, 2); |
|
49 | 49 | } |
50 | 50 | |
51 | 51 | |
52 | 52 | /** |
53 | 53 | * @param \WP $WP |
54 | 54 | */ |
55 | - public function run( $WP ) { |
|
55 | + public function run($WP) { |
|
56 | 56 | $this->set_config(); |
57 | 57 | } |
58 | 58 | |
59 | 59 | |
60 | 60 | |
61 | 61 | |
62 | - protected function set_config(){ |
|
63 | - $this->set_config_section( 'template_settings' ); |
|
64 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
65 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
62 | + protected function set_config() { |
|
63 | + $this->set_config_section('template_settings'); |
|
64 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
65 | + $this->set_config_name('EED_Ticket_Selector'); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
98 | 98 | array( |
99 | 99 | 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
100 | - EEH_HTML::br(2) . |
|
101 | - EEH_HTML::h2( esc_html__( 'Ticket Selector Template Settings', 'event_espresso' )) |
|
100 | + EEH_HTML::br(2). |
|
101 | + EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
|
102 | 102 | ), |
103 | 103 | 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings() |
104 | 104 | ) |
@@ -114,7 +114,7 @@ discard block |
||
114 | 114 | * @throws \EE_Error |
115 | 115 | */ |
116 | 116 | public static function _ticket_selector_appearance_settings() { |
117 | - if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
117 | + if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
118 | 118 | \EED_Ticket_Selector::instance()->set_config(); |
119 | 119 | \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
120 | 120 | } |
@@ -142,9 +142,9 @@ discard block |
||
142 | 142 | array( |
143 | 143 | 'show_ticket_details' => new EE_Yes_No_Input( |
144 | 144 | array( |
145 | - 'html_label_text' => esc_html__('Show Ticket Details?', 'event_espresso' ), |
|
146 | - 'html_help_text' => esc_html__( 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', 'event_espresso'), |
|
147 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details ) |
|
145 | + 'html_label_text' => esc_html__('Show Ticket Details?', 'event_espresso'), |
|
146 | + 'html_help_text' => esc_html__('This lets you choose whether the extra ticket details section is displayed with the ticket selector.', 'event_espresso'), |
|
147 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details) |
|
148 | 148 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details |
149 | 149 | : true, |
150 | 150 | 'display_html_label_text' => false |
@@ -152,9 +152,9 @@ discard block |
||
152 | 152 | ), |
153 | 153 | 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
154 | 154 | array( |
155 | - 'html_label_text' => esc_html__('Show Ticket Sale Info?', 'event_espresso' ), |
|
156 | - 'html_help_text' => esc_html__( 'This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', 'event_espresso'), |
|
157 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns ) |
|
155 | + 'html_label_text' => esc_html__('Show Ticket Sale Info?', 'event_espresso'), |
|
156 | + 'html_help_text' => esc_html__('This lets you indicate whether information about ticket sales is shown with ticket details in the ticket selector.', 'event_espresso'), |
|
157 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns) |
|
158 | 158 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns |
159 | 159 | : true, |
160 | 160 | 'display_html_label_text' => false |
@@ -162,9 +162,9 @@ discard block |
||
162 | 162 | ), |
163 | 163 | 'show_expired_tickets' => new EE_Yes_No_Input( |
164 | 164 | array( |
165 | - 'html_label_text' => esc_html__( 'Show Expired Tickets?', 'event_espresso' ), |
|
166 | - 'html_help_text' => esc_html__( 'Indicate whether to show expired tickets in the ticket selector', 'event_espresso' ), |
|
167 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) |
|
165 | + 'html_label_text' => esc_html__('Show Expired Tickets?', 'event_espresso'), |
|
166 | + 'html_help_text' => esc_html__('Indicate whether to show expired tickets in the ticket selector', 'event_espresso'), |
|
167 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) |
|
168 | 168 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets |
169 | 169 | : true, |
170 | 170 | 'display_html_label_text' => false |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | 'show_datetime_selector' => new EE_Select_Input( |
174 | 174 | \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false), |
175 | 175 | array( |
176 | - 'html_label_text' => esc_html__( 'Show Date & Time Filter?', 'event_espresso' ), |
|
176 | + 'html_label_text' => esc_html__('Show Date & Time Filter?', 'event_espresso'), |
|
177 | 177 | 'html_help_text' => sprintf( |
178 | 178 | esc_html__( |
179 | 179 | 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates and times for the available tickets. Ticket options can be unselected, which removes (hides) them from the list of tickets being displayed.%1$sOptions include:%1$s • %2$sdo not show date & time filter%3$s%1$s this option will NEVER display a date filter, regardless of how many dates exist.%1$s • %2$smaybe show date & time filter%3$s%1$s this option will conditionally display the date filter when the number of dates for the event matches the value set for "Date Filter Threshold".', |
@@ -184,7 +184,7 @@ discard block |
||
184 | 184 | '</strong>' |
185 | 185 | |
186 | 186 | ), |
187 | - 'default' => ! empty( $show_datetime_selector ) |
|
187 | + 'default' => ! empty($show_datetime_selector) |
|
188 | 188 | ? $show_datetime_selector |
189 | 189 | : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
190 | 190 | 'display_html_label_text' => false |
@@ -193,12 +193,12 @@ discard block |
||
193 | 193 | 'datetime_selector_threshold' => new EE_Select_Input( |
194 | 194 | array_combine($r = range(1, 10), $r), |
195 | 195 | array( |
196 | - 'html_label_text' => esc_html__( 'Date & Time Filter Threshold', 'event_espresso' ), |
|
196 | + 'html_label_text' => esc_html__('Date & Time Filter Threshold', 'event_espresso'), |
|
197 | 197 | 'html_help_text' => esc_html__( |
198 | 198 | 'The number of unique dates an event has to have before conditionally displaying a date & time filter', |
199 | 199 | 'event_espresso' |
200 | 200 | ), |
201 | - 'default' => ! empty( $datetime_selector_threshold ) |
|
201 | + 'default' => ! empty($datetime_selector_threshold) |
|
202 | 202 | ? $datetime_selector_threshold |
203 | 203 | : 3, |
204 | 204 | 'display_html_label_text' => false |
@@ -221,8 +221,8 @@ discard block |
||
221 | 221 | * @param array $REQ incoming request |
222 | 222 | * @return EE_Template_Config |
223 | 223 | */ |
224 | - public static function update_template_settings( EE_Template_Config $CFG, $REQ ) { |
|
225 | - if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
224 | + public static function update_template_settings(EE_Template_Config $CFG, $REQ) { |
|
225 | + if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
226 | 226 | \EED_Ticket_Selector::instance()->set_config(); |
227 | 227 | $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
228 | 228 | } |
@@ -230,13 +230,13 @@ discard block |
||
230 | 230 | $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
231 | 231 | |
232 | 232 | //check for form submission |
233 | - if ( $ticket_selector_form->was_submitted() ) { |
|
233 | + if ($ticket_selector_form->was_submitted()) { |
|
234 | 234 | |
235 | 235 | //capture form data |
236 | 236 | $ticket_selector_form->receive_form_submission(); |
237 | 237 | |
238 | 238 | //validate form data |
239 | - if ( $ticket_selector_form->is_valid() ) { |
|
239 | + if ($ticket_selector_form->is_valid()) { |
|
240 | 240 | |
241 | 241 | //grab validated data from form |
242 | 242 | $valid_data = $ticket_selector_form->valid_data(); |
@@ -252,13 +252,13 @@ discard block |
||
252 | 252 | $valid_data['appearance_settings']['datetime_selector_threshold'] |
253 | 253 | ); |
254 | 254 | } else { |
255 | - if ( $ticket_selector_form->submission_error_message() !== '' ) { |
|
256 | - EE_Error::add_error( $ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
255 | + if ($ticket_selector_form->submission_error_message() !== '') { |
|
256 | + EE_Error::add_error($ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
257 | 257 | } |
258 | 258 | } |
259 | 259 | |
260 | 260 | } |
261 | - } catch( EE_Error $e ) { |
|
261 | + } catch (EE_Error $e) { |
|
262 | 262 | $e->get_error(); |
263 | 263 | } |
264 | 264 | |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | { |
277 | 277 | require( |
278 | 278 | str_replace('\\', DS, plugin_dir_path(__FILE__)) |
279 | - . 'templates' . DS . 'ticket_selector_price_details.template.php' |
|
279 | + . 'templates'.DS.'ticket_selector_price_details.template.php' |
|
280 | 280 | ); |
281 | 281 | } |
282 | 282 |
@@ -7,7 +7,7 @@ discard block |
||
7 | 7 | if ($display_ticket_price) { ?> |
8 | 8 | <section class="tckt-slctr-tkt-price-sctn"> |
9 | 9 | <h5><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_price_breakdown_heading', |
10 | - esc_html__('Price', 'event_espresso')); ?></h5> |
|
10 | + esc_html__('Price', 'event_espresso')); ?></h5> |
|
11 | 11 | <div class="tckt-slctr-tkt-details-tbl-wrap-dv"> |
12 | 12 | <table class="tckt-slctr-tkt-details-tbl"> |
13 | 13 | <thead> |
@@ -30,12 +30,12 @@ discard block |
||
30 | 30 | class="jst-rght small-text"><?php echo $ticket->base_price()->pretty_price(); ?></td> |
31 | 31 | </tr> |
32 | 32 | <?php |
33 | - $running_total = $ticket->base_price()->amount(); |
|
34 | - } else { |
|
35 | - $running_total = 0; |
|
36 | - } |
|
37 | - // now add price modifiers |
|
38 | - foreach ($ticket->price_modifiers() as $price_mod) { ?> |
|
33 | + $running_total = $ticket->base_price()->amount(); |
|
34 | + } else { |
|
35 | + $running_total = 0; |
|
36 | + } |
|
37 | + // now add price modifiers |
|
38 | + foreach ($ticket->price_modifiers() as $price_mod) { ?> |
|
39 | 39 | <tr> |
40 | 40 | <td data-th="<?php esc_html_e('Name', 'event_espresso'); ?>" |
41 | 41 | class="jst-rght small-text"><?php echo $price_mod->name(); ?></td> |
@@ -45,16 +45,16 @@ discard block |
||
45 | 45 | % |
46 | 46 | </td> |
47 | 47 | <?php |
48 | - $new_sub_total = $running_total * ($price_mod->amount() / 100); |
|
49 | - $new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total; |
|
50 | - ?> |
|
48 | + $new_sub_total = $running_total * ($price_mod->amount() / 100); |
|
49 | + $new_sub_total = $price_mod->is_discount() ? $new_sub_total * -1 : $new_sub_total; |
|
50 | + ?> |
|
51 | 51 | <?php } else { ?> |
52 | 52 | <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 |
53 | - : $price_mod->amount(); ?> |
|
53 | + : $price_mod->amount(); ?> |
|
54 | 54 | <td data-th="<?php esc_html_e('Description', 'event_espresso'); ?>" |
55 | 55 | class="small-text"><?php echo $price_mod->desc(); ?></td> |
56 | 56 | <?php $new_sub_total = $price_mod->is_discount() ? $price_mod->amount() * -1 |
57 | - : $price_mod->amount(); ?> |
|
57 | + : $price_mod->amount(); ?> |
|
58 | 58 | <?php } ?> |
59 | 59 | <td data-th="<?php esc_html_e('Amount', 'event_espresso'); ?>" |
60 | 60 | class="jst-rght small-text"><?php echo EEH_Template::format_currency($new_sub_total); ?></td> |
@@ -65,7 +65,7 @@ discard block |
||
65 | 65 | <?php //$ticket_subtotal =$ticket->get_ticket_subtotal(); ?> |
66 | 66 | <tr> |
67 | 67 | <td colspan="2" class="jst-rght small-text sbttl"><b><?php esc_html_e('subtotal', |
68 | - 'event_espresso'); ?></b></td> |
|
68 | + 'event_espresso'); ?></b></td> |
|
69 | 69 | <td data-th="<?php esc_html_e('subtotal', 'event_espresso'); ?>" class="jst-rght small-text"> |
70 | 70 | <b><?php echo EEH_Template::format_currency($running_total); ?></b></td> |
71 | 71 | </tr> |
@@ -87,9 +87,9 @@ discard block |
||
87 | 87 | <tr> |
88 | 88 | <td colspan="2" class="jst-rght small-text ttl-lbl-td"> |
89 | 89 | <b><?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', |
90 | - esc_html__('Total', 'event_espresso')); ?></b></td> |
|
90 | + esc_html__('Total', 'event_espresso')); ?></b></td> |
|
91 | 91 | <td data-th="<?php echo apply_filters('FHEE__ticket_selector_chart_template__ticket_details_total_price', |
92 | - esc_html__('Total', 'event_espresso')); ?>" class="jst-rght small-text"> |
|
92 | + esc_html__('Total', 'event_espresso')); ?>" class="jst-rght small-text"> |
|
93 | 93 | <b><?php echo EEH_Template::format_currency($running_total); ?></b></td> |
94 | 94 | </tr> |
95 | 95 | </tbody> |