@@ -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 | |
@@ -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,91 +2953,91 @@ 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 datetime selector', 'event_espresso' |
|
2999 | - ), |
|
3000 | - \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3001 | - 'Maybe show datetime selector', '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 | - ) |
|
3017 | - ? $show_datetime_selector |
|
3018 | - : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3019 | - } |
|
3020 | 2983 | |
3021 | 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 datetime selector', 'event_espresso' |
|
2999 | + ), |
|
3000 | + \EE_Ticket_Selector_Config::MAYBE_SHOW_DATETIME_SELECTOR => esc_html__( |
|
3001 | + 'Maybe show datetime selector', 'event_espresso' |
|
3002 | + ), |
|
3003 | + ); |
|
3004 | + } |
|
3022 | 3005 | |
3023 | - /** |
|
3024 | - * @return int |
|
3025 | - */ |
|
3026 | - public function getDatetimeSelectorThreshold() |
|
3027 | - { |
|
3028 | - return $this->datetime_selector_threshold; |
|
3029 | - } |
|
3030 | 3006 | |
3031 | 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 | + ) |
|
3017 | + ? $show_datetime_selector |
|
3018 | + : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR; |
|
3019 | + } |
|
3032 | 3020 | |
3033 | - /** |
|
3034 | - * @param int $datetime_selector_threshold |
|
3035 | - */ |
|
3036 | - public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3037 | - { |
|
3038 | - $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3039 | - $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3040 | - } |
|
3021 | + |
|
3022 | + |
|
3023 | + /** |
|
3024 | + * @return int |
|
3025 | + */ |
|
3026 | + public function getDatetimeSelectorThreshold() |
|
3027 | + { |
|
3028 | + return $this->datetime_selector_threshold; |
|
3029 | + } |
|
3030 | + |
|
3031 | + |
|
3032 | + |
|
3033 | + /** |
|
3034 | + * @param int $datetime_selector_threshold |
|
3035 | + */ |
|
3036 | + public function setDatetimeSelectorThreshold($datetime_selector_threshold) |
|
3037 | + { |
|
3038 | + $datetime_selector_threshold = absint($datetime_selector_threshold); |
|
3039 | + $this->datetime_selector_threshold = $datetime_selector_threshold ? $datetime_selector_threshold : 3; |
|
3040 | + } |
|
3041 | 3041 | |
3042 | 3042 | |
3043 | 3043 | } |
@@ -3100,8 +3100,8 @@ discard block |
||
3100 | 3100 | */ |
3101 | 3101 | public function max_input_vars_limit_check( $input_count = 0 ) { |
3102 | 3102 | if ( ! empty( $this->php->max_input_vars ) |
3103 | - && ( $input_count >= $this->php->max_input_vars ) |
|
3104 | - && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 ) |
|
3103 | + && ( $input_count >= $this->php->max_input_vars ) |
|
3104 | + && ( PHP_MAJOR_VERSION >= 5 && PHP_MINOR_VERSION >= 3 && PHP_RELEASE_VERSION >= 9 ) |
|
3105 | 3105 | ) { |
3106 | 3106 | return sprintf( |
3107 | 3107 | __( |
@@ -3145,22 +3145,22 @@ discard block |
||
3145 | 3145 | class EE_Tax_Config extends EE_Config_Base |
3146 | 3146 | { |
3147 | 3147 | |
3148 | - /* |
|
3148 | + /* |
|
3149 | 3149 | * flag to indicate whether or not to display ticket prices with the taxes included |
3150 | 3150 | * |
3151 | 3151 | * @var boolean $prices_displayed_including_taxes |
3152 | 3152 | */ |
3153 | - public $prices_displayed_including_taxes; |
|
3153 | + public $prices_displayed_including_taxes; |
|
3154 | 3154 | |
3155 | 3155 | |
3156 | 3156 | |
3157 | - /** |
|
3158 | - * class constructor |
|
3159 | - */ |
|
3160 | - public function __construct() |
|
3161 | - { |
|
3162 | - $this->prices_displayed_including_taxes = true; |
|
3163 | - } |
|
3157 | + /** |
|
3158 | + * class constructor |
|
3159 | + */ |
|
3160 | + public function __construct() |
|
3161 | + { |
|
3162 | + $this->prices_displayed_including_taxes = true; |
|
3163 | + } |
|
3164 | 3164 | } |
3165 | 3165 | |
3166 | 3166 |
@@ -47,14 +47,14 @@ discard block |
||
47 | 47 | * @param \WP $WP |
48 | 48 | */ |
49 | 49 | public function run( $WP ) { |
50 | - $this->set_config(); |
|
50 | + $this->set_config(); |
|
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | 56 | protected function set_config(){ |
57 | - $this->set_config_section( 'template_settings' ); |
|
57 | + $this->set_config_section( 'template_settings' ); |
|
58 | 58 | $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
59 | 59 | $this->set_config_name( 'EED_Ticket_Selector' ); |
60 | 60 | } |
@@ -103,27 +103,27 @@ discard block |
||
103 | 103 | |
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * @return \EE_Form_Section_Proper |
|
108 | - * @throws \EE_Error |
|
109 | - */ |
|
110 | - public static function _ticket_selector_appearance_settings() { |
|
111 | - if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
112 | - \EED_Ticket_Selector::instance()->set_config(); |
|
113 | - \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
114 | - } |
|
115 | - // get option for whether to show datetime selector in TS |
|
116 | - $show_datetime_selector = \EE_Registry::instance() |
|
117 | - ->CFG |
|
118 | - ->template_settings |
|
119 | - ->EED_Ticket_Selector |
|
120 | - ->getShowDatetimeSelector(); |
|
121 | - // and option for how may datetimes must exist if display is conditional |
|
122 | - $datetime_selector_threshold = \EE_Registry::instance() |
|
123 | - ->CFG |
|
124 | - ->template_settings |
|
125 | - ->EED_Ticket_Selector |
|
126 | - ->getDatetimeSelectorThreshold(); |
|
106 | + /** |
|
107 | + * @return \EE_Form_Section_Proper |
|
108 | + * @throws \EE_Error |
|
109 | + */ |
|
110 | + public static function _ticket_selector_appearance_settings() { |
|
111 | + if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
112 | + \EED_Ticket_Selector::instance()->set_config(); |
|
113 | + \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
114 | + } |
|
115 | + // get option for whether to show datetime selector in TS |
|
116 | + $show_datetime_selector = \EE_Registry::instance() |
|
117 | + ->CFG |
|
118 | + ->template_settings |
|
119 | + ->EED_Ticket_Selector |
|
120 | + ->getShowDatetimeSelector(); |
|
121 | + // and option for how may datetimes must exist if display is conditional |
|
122 | + $datetime_selector_threshold = \EE_Registry::instance() |
|
123 | + ->CFG |
|
124 | + ->template_settings |
|
125 | + ->EED_Ticket_Selector |
|
126 | + ->getDatetimeSelectorThreshold(); |
|
127 | 127 | |
128 | 128 | return new EE_Form_Section_Proper( |
129 | 129 | array( |
@@ -165,16 +165,16 @@ discard block |
||
165 | 165 | ) |
166 | 166 | ), |
167 | 167 | 'show_datetime_selector' => new EE_Select_Input( |
168 | - \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false), |
|
168 | + \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false), |
|
169 | 169 | array( |
170 | 170 | 'html_label_text' => esc_html__( 'Show Datetime Selector?', 'event_espresso' ), |
171 | 171 | 'html_help_text' => sprintf( |
172 | - esc_html__( |
|
173 | - 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates for the available tickets. Ticket options will then be hidden until a date is selected, and then only tickets for that date are shown.%1$sOptions include:%1$s • do not show datetime selector%1$s this option will NEVER display a datetime selector, regardless of how many datetimes exist.%1$s • maybe show datetime selector%1$s this option will conditionally display a datetime selector when the number of datetimes for the event matches the value set for "Datetime Selector Threshold".', |
|
174 | - 'event_espresso' |
|
175 | - ), |
|
176 | - '<br>' |
|
177 | - ), |
|
172 | + esc_html__( |
|
173 | + 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates for the available tickets. Ticket options will then be hidden until a date is selected, and then only tickets for that date are shown.%1$sOptions include:%1$s • do not show datetime selector%1$s this option will NEVER display a datetime selector, regardless of how many datetimes exist.%1$s • maybe show datetime selector%1$s this option will conditionally display a datetime selector when the number of datetimes for the event matches the value set for "Datetime Selector Threshold".', |
|
174 | + 'event_espresso' |
|
175 | + ), |
|
176 | + '<br>' |
|
177 | + ), |
|
178 | 178 | 'default' => ! empty( $show_datetime_selector ) |
179 | 179 | ? $show_datetime_selector |
180 | 180 | : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
@@ -182,13 +182,13 @@ discard block |
||
182 | 182 | ) |
183 | 183 | ), |
184 | 184 | 'datetime_selector_threshold' => new EE_Select_Input( |
185 | - range(0,10), |
|
185 | + range(0,10), |
|
186 | 186 | array( |
187 | 187 | 'html_label_text' => esc_html__( 'Datetime Selector Threshold', 'event_espresso' ), |
188 | 188 | 'html_help_text' => esc_html__( |
189 | - 'The number of datetimes an event has to have before conditionally displaying a datetime selector', |
|
190 | - 'event_espresso' |
|
191 | - ), |
|
189 | + 'The number of datetimes an event has to have before conditionally displaying a datetime selector', |
|
190 | + 'event_espresso' |
|
191 | + ), |
|
192 | 192 | 'default' => ! empty( $datetime_selector_threshold ) |
193 | 193 | ? $datetime_selector_threshold |
194 | 194 | : 3, |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | */ |
215 | 215 | public static function update_template_settings( EE_Template_Config $CFG, $REQ ) { |
216 | 216 | if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
217 | - \EED_Ticket_Selector::instance()->set_config(); |
|
218 | - $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
217 | + \EED_Ticket_Selector::instance()->set_config(); |
|
218 | + $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
219 | 219 | } |
220 | 220 | try { |
221 | 221 | $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
@@ -237,11 +237,11 @@ discard block |
||
237 | 237 | $CFG->EED_Ticket_Selector->show_ticket_details = $valid_data['appearance_settings']['show_ticket_details']; |
238 | 238 | $CFG->EED_Ticket_Selector->show_expired_tickets = $valid_data['appearance_settings']['show_expired_tickets']; |
239 | 239 | $CFG->EED_Ticket_Selector->setShowDatetimeSelector( |
240 | - $valid_data['appearance_settings']['show_datetime_selector'] |
|
241 | - ); |
|
240 | + $valid_data['appearance_settings']['show_datetime_selector'] |
|
241 | + ); |
|
242 | 242 | $CFG->EED_Ticket_Selector->setDatetimeSelectorThreshold( |
243 | - $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
244 | - ); |
|
243 | + $valid_data['appearance_settings']['datetime_selector_threshold'] |
|
244 | + ); |
|
245 | 245 | } else { |
246 | 246 | if ( $ticket_selector_form->submission_error_message() !== '' ) { |
247 | 247 | EE_Error::add_error( $ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
@@ -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 | |
@@ -37,26 +37,26 @@ discard block |
||
37 | 37 | * @return void |
38 | 38 | */ |
39 | 39 | public static function set_hooks_admin() { |
40 | - define( 'TICKET_SELECTOR_CAFF_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
41 | - add_action( 'AHEE__template_settings__template__before_settings_form', array( 'EED_Ticket_Selector_Caff', 'template_settings_form' ), 10 ); |
|
42 | - add_filter( 'FHEE__General_Settings_Admin_Page__update_template_settings__data', array( 'EED_Ticket_Selector_Caff', 'update_template_settings' ), 10, 2 ); |
|
40 | + define('TICKET_SELECTOR_CAFF_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
41 | + add_action('AHEE__template_settings__template__before_settings_form', array('EED_Ticket_Selector_Caff', 'template_settings_form'), 10); |
|
42 | + add_filter('FHEE__General_Settings_Admin_Page__update_template_settings__data', array('EED_Ticket_Selector_Caff', 'update_template_settings'), 10, 2); |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | |
46 | 46 | /** |
47 | 47 | * @param \WP $WP |
48 | 48 | */ |
49 | - public function run( $WP ) { |
|
49 | + public function run($WP) { |
|
50 | 50 | $this->set_config(); |
51 | 51 | } |
52 | 52 | |
53 | 53 | |
54 | 54 | |
55 | 55 | |
56 | - protected function set_config(){ |
|
57 | - $this->set_config_section( 'template_settings' ); |
|
58 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
59 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
56 | + protected function set_config() { |
|
57 | + $this->set_config_section('template_settings'); |
|
58 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
59 | + $this->set_config_name('EED_Ticket_Selector'); |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
@@ -91,8 +91,8 @@ discard block |
||
91 | 91 | 'FHEE__EED_Ticket_Selector_Caff___ticket_selector_settings_form__form_subsections', |
92 | 92 | array( |
93 | 93 | 'appearance_settings_hdr' => new EE_Form_Section_HTML( |
94 | - EEH_HTML::br(2) . |
|
95 | - EEH_HTML::h2( esc_html__( 'Ticket Selector Template Settings', 'event_espresso' )) |
|
94 | + EEH_HTML::br(2). |
|
95 | + EEH_HTML::h2(esc_html__('Ticket Selector Template Settings', 'event_espresso')) |
|
96 | 96 | ), |
97 | 97 | 'appearance_settings' => EED_Ticket_Selector_Caff::_ticket_selector_appearance_settings() |
98 | 98 | ) |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | * @throws \EE_Error |
109 | 109 | */ |
110 | 110 | public static function _ticket_selector_appearance_settings() { |
111 | - if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
111 | + if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
112 | 112 | \EED_Ticket_Selector::instance()->set_config(); |
113 | 113 | \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
114 | 114 | } |
@@ -136,9 +136,9 @@ discard block |
||
136 | 136 | array( |
137 | 137 | 'show_ticket_details' => new EE_Yes_No_Input( |
138 | 138 | array( |
139 | - 'html_label_text' => esc_html__('Show Ticket Details?', 'event_espresso' ), |
|
140 | - 'html_help_text' => esc_html__( 'This lets you choose whether the extra ticket details section is displayed with the ticket selector.', 'event_espresso'), |
|
141 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details ) |
|
139 | + 'html_label_text' => esc_html__('Show Ticket Details?', 'event_espresso'), |
|
140 | + 'html_help_text' => esc_html__('This lets you choose whether the extra ticket details section is displayed with the ticket selector.', 'event_espresso'), |
|
141 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details) |
|
142 | 142 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_details |
143 | 143 | : true, |
144 | 144 | 'display_html_label_text' => false |
@@ -146,9 +146,9 @@ discard block |
||
146 | 146 | ), |
147 | 147 | 'show_ticket_sale_columns' => new EE_Yes_No_Input( |
148 | 148 | array( |
149 | - 'html_label_text' => esc_html__('Show Ticket Sale Info?', 'event_espresso' ), |
|
150 | - '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'), |
|
151 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns ) |
|
149 | + 'html_label_text' => esc_html__('Show Ticket Sale Info?', 'event_espresso'), |
|
150 | + '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'), |
|
151 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns) |
|
152 | 152 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_ticket_sale_columns |
153 | 153 | : true, |
154 | 154 | 'display_html_label_text' => false |
@@ -156,9 +156,9 @@ discard block |
||
156 | 156 | ), |
157 | 157 | 'show_expired_tickets' => new EE_Yes_No_Input( |
158 | 158 | array( |
159 | - 'html_label_text' => esc_html__( 'Show Expired Tickets?', 'event_espresso' ), |
|
160 | - 'html_help_text' => esc_html__( 'Indicate whether to show expired tickets in the ticket selector', 'event_espresso' ), |
|
161 | - 'default' => isset( EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets ) |
|
159 | + 'html_label_text' => esc_html__('Show Expired Tickets?', 'event_espresso'), |
|
160 | + 'html_help_text' => esc_html__('Indicate whether to show expired tickets in the ticket selector', 'event_espresso'), |
|
161 | + 'default' => isset(EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) |
|
162 | 162 | ? EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets |
163 | 163 | : true, |
164 | 164 | 'display_html_label_text' => false |
@@ -167,7 +167,7 @@ discard block |
||
167 | 167 | 'show_datetime_selector' => new EE_Select_Input( |
168 | 168 | \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->getShowDatetimeSelectorOptions(false), |
169 | 169 | array( |
170 | - 'html_label_text' => esc_html__( 'Show Datetime Selector?', 'event_espresso' ), |
|
170 | + 'html_label_text' => esc_html__('Show Datetime Selector?', 'event_espresso'), |
|
171 | 171 | 'html_help_text' => sprintf( |
172 | 172 | esc_html__( |
173 | 173 | 'Indicates whether or not to display a dropdown select box above each ticket selector that displays dates for the available tickets. Ticket options will then be hidden until a date is selected, and then only tickets for that date are shown.%1$sOptions include:%1$s • do not show datetime selector%1$s this option will NEVER display a datetime selector, regardless of how many datetimes exist.%1$s • maybe show datetime selector%1$s this option will conditionally display a datetime selector when the number of datetimes for the event matches the value set for "Datetime Selector Threshold".', |
@@ -175,21 +175,21 @@ discard block |
||
175 | 175 | ), |
176 | 176 | '<br>' |
177 | 177 | ), |
178 | - 'default' => ! empty( $show_datetime_selector ) |
|
178 | + 'default' => ! empty($show_datetime_selector) |
|
179 | 179 | ? $show_datetime_selector |
180 | 180 | : \EE_Ticket_Selector_Config::DO_NOT_SHOW_DATETIME_SELECTOR, |
181 | 181 | 'display_html_label_text' => false |
182 | 182 | ) |
183 | 183 | ), |
184 | 184 | 'datetime_selector_threshold' => new EE_Select_Input( |
185 | - range(0,10), |
|
185 | + range(0, 10), |
|
186 | 186 | array( |
187 | - 'html_label_text' => esc_html__( 'Datetime Selector Threshold', 'event_espresso' ), |
|
187 | + 'html_label_text' => esc_html__('Datetime Selector Threshold', 'event_espresso'), |
|
188 | 188 | 'html_help_text' => esc_html__( |
189 | 189 | 'The number of datetimes an event has to have before conditionally displaying a datetime selector', |
190 | 190 | 'event_espresso' |
191 | 191 | ), |
192 | - 'default' => ! empty( $datetime_selector_threshold ) |
|
192 | + 'default' => ! empty($datetime_selector_threshold) |
|
193 | 193 | ? $datetime_selector_threshold |
194 | 194 | : 3, |
195 | 195 | 'display_html_label_text' => false |
@@ -212,8 +212,8 @@ discard block |
||
212 | 212 | * @param array $REQ incoming request |
213 | 213 | * @return EE_Template_Config |
214 | 214 | */ |
215 | - public static function update_template_settings( EE_Template_Config $CFG, $REQ ) { |
|
216 | - if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
215 | + public static function update_template_settings(EE_Template_Config $CFG, $REQ) { |
|
216 | + if ( ! $CFG->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
217 | 217 | \EED_Ticket_Selector::instance()->set_config(); |
218 | 218 | $CFG->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
219 | 219 | } |
@@ -221,13 +221,13 @@ discard block |
||
221 | 221 | $ticket_selector_form = EED_Ticket_Selector_Caff::_ticket_selector_settings_form(); |
222 | 222 | |
223 | 223 | //check for form submission |
224 | - if ( $ticket_selector_form->was_submitted() ) { |
|
224 | + if ($ticket_selector_form->was_submitted()) { |
|
225 | 225 | |
226 | 226 | //capture form data |
227 | 227 | $ticket_selector_form->receive_form_submission(); |
228 | 228 | |
229 | 229 | //validate form data |
230 | - if ( $ticket_selector_form->is_valid() ) { |
|
230 | + if ($ticket_selector_form->is_valid()) { |
|
231 | 231 | |
232 | 232 | //grab validated data from form |
233 | 233 | $valid_data = $ticket_selector_form->valid_data(); |
@@ -243,13 +243,13 @@ discard block |
||
243 | 243 | $valid_data['appearance_settings']['datetime_selector_threshold'] |
244 | 244 | ); |
245 | 245 | } else { |
246 | - if ( $ticket_selector_form->submission_error_message() !== '' ) { |
|
247 | - EE_Error::add_error( $ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__ ); |
|
246 | + if ($ticket_selector_form->submission_error_message() !== '') { |
|
247 | + EE_Error::add_error($ticket_selector_form->submission_error_message(), __FILE__, __FUNCTION__, __LINE__); |
|
248 | 248 | } |
249 | 249 | } |
250 | 250 | |
251 | 251 | } |
252 | - } catch( EE_Error $e ) { |
|
252 | + } catch (EE_Error $e) { |
|
253 | 253 | $e->get_error(); |
254 | 254 | } |
255 | 255 |
@@ -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,2571 +17,2571 @@ 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 | - * @var EE_Event |
|
47 | - */ |
|
48 | - protected $_cpt_model_obj = false; |
|
49 | - |
|
50 | - |
|
51 | - |
|
52 | - protected function _init_page_props() |
|
53 | - { |
|
54 | - $this->page_slug = EVENTS_PG_SLUG; |
|
55 | - $this->page_label = EVENTS_LABEL; |
|
56 | - $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
57 | - $this->_admin_base_path = EVENTS_ADMIN; |
|
58 | - $this->_cpt_model_names = array( |
|
59 | - 'create_new' => 'EEM_Event', |
|
60 | - 'edit' => 'EEM_Event', |
|
61 | - ); |
|
62 | - $this->_cpt_edit_routes = array( |
|
63 | - 'espresso_events' => 'edit', |
|
64 | - ); |
|
65 | - add_action( |
|
66 | - 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
67 | - array($this, 'verify_event_edit') |
|
68 | - ); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - protected function _ajax_hooks() |
|
74 | - { |
|
75 | - //todo: all hooks for events ajax goes in here. |
|
76 | - } |
|
77 | - |
|
78 | - |
|
79 | - |
|
80 | - protected function _define_page_props() |
|
81 | - { |
|
82 | - $this->_admin_page_title = EVENTS_LABEL; |
|
83 | - $this->_labels = array( |
|
84 | - 'buttons' => array( |
|
85 | - 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
86 | - 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
87 | - 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
88 | - 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
89 | - 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
90 | - 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
91 | - ), |
|
92 | - 'editor_title' => array( |
|
93 | - 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
94 | - ), |
|
95 | - 'publishbox' => array( |
|
96 | - 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
97 | - 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
98 | - 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
99 | - 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
100 | - 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
101 | - ), |
|
102 | - ); |
|
103 | - } |
|
104 | - |
|
105 | - |
|
106 | - |
|
107 | - protected function _set_page_routes() |
|
108 | - { |
|
109 | - //load formatter helper |
|
110 | - //load field generator helper |
|
111 | - //is there a evt_id in the request? |
|
112 | - $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
113 | - ? $this->_req_data['EVT_ID'] : 0; |
|
114 | - $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
115 | - $this->_page_routes = array( |
|
116 | - 'default' => array( |
|
117 | - 'func' => '_events_overview_list_table', |
|
118 | - 'capability' => 'ee_read_events', |
|
119 | - ), |
|
120 | - 'create_new' => array( |
|
121 | - 'func' => '_create_new_cpt_item', |
|
122 | - 'capability' => 'ee_edit_events', |
|
123 | - ), |
|
124 | - 'edit' => array( |
|
125 | - 'func' => '_edit_cpt_item', |
|
126 | - 'capability' => 'ee_edit_event', |
|
127 | - 'obj_id' => $evt_id, |
|
128 | - ), |
|
129 | - 'copy_event' => array( |
|
130 | - 'func' => '_copy_events', |
|
131 | - 'capability' => 'ee_edit_event', |
|
132 | - 'obj_id' => $evt_id, |
|
133 | - 'noheader' => true, |
|
134 | - ), |
|
135 | - 'trash_event' => array( |
|
136 | - 'func' => '_trash_or_restore_event', |
|
137 | - 'args' => array('event_status' => 'trash'), |
|
138 | - 'capability' => 'ee_delete_event', |
|
139 | - 'obj_id' => $evt_id, |
|
140 | - 'noheader' => true, |
|
141 | - ), |
|
142 | - 'trash_events' => array( |
|
143 | - 'func' => '_trash_or_restore_events', |
|
144 | - 'args' => array('event_status' => 'trash'), |
|
145 | - 'capability' => 'ee_delete_events', |
|
146 | - 'noheader' => true, |
|
147 | - ), |
|
148 | - 'restore_event' => array( |
|
149 | - 'func' => '_trash_or_restore_event', |
|
150 | - 'args' => array('event_status' => 'draft'), |
|
151 | - 'capability' => 'ee_delete_event', |
|
152 | - 'obj_id' => $evt_id, |
|
153 | - 'noheader' => true, |
|
154 | - ), |
|
155 | - 'restore_events' => array( |
|
156 | - 'func' => '_trash_or_restore_events', |
|
157 | - 'args' => array('event_status' => 'draft'), |
|
158 | - 'capability' => 'ee_delete_events', |
|
159 | - 'noheader' => true, |
|
160 | - ), |
|
161 | - 'delete_event' => array( |
|
162 | - 'func' => '_delete_event', |
|
163 | - 'capability' => 'ee_delete_event', |
|
164 | - 'obj_id' => $evt_id, |
|
165 | - 'noheader' => true, |
|
166 | - ), |
|
167 | - 'delete_events' => array( |
|
168 | - 'func' => '_delete_events', |
|
169 | - 'capability' => 'ee_delete_events', |
|
170 | - 'noheader' => true, |
|
171 | - ), |
|
172 | - 'view_report' => array( |
|
173 | - 'func' => '_view_report', |
|
174 | - 'capablity' => 'ee_edit_events', |
|
175 | - ), |
|
176 | - 'default_event_settings' => array( |
|
177 | - 'func' => '_default_event_settings', |
|
178 | - 'capability' => 'manage_options', |
|
179 | - ), |
|
180 | - 'update_default_event_settings' => array( |
|
181 | - 'func' => '_update_default_event_settings', |
|
182 | - 'capability' => 'manage_options', |
|
183 | - 'noheader' => true, |
|
184 | - ), |
|
185 | - 'template_settings' => array( |
|
186 | - 'func' => '_template_settings', |
|
187 | - 'capability' => 'manage_options', |
|
188 | - ), |
|
189 | - //event category tab related |
|
190 | - 'add_category' => array( |
|
191 | - 'func' => '_category_details', |
|
192 | - 'capability' => 'ee_edit_event_category', |
|
193 | - 'args' => array('add'), |
|
194 | - ), |
|
195 | - 'edit_category' => array( |
|
196 | - 'func' => '_category_details', |
|
197 | - 'capability' => 'ee_edit_event_category', |
|
198 | - 'args' => array('edit'), |
|
199 | - ), |
|
200 | - 'delete_categories' => array( |
|
201 | - 'func' => '_delete_categories', |
|
202 | - 'capability' => 'ee_delete_event_category', |
|
203 | - 'noheader' => true, |
|
204 | - ), |
|
205 | - 'delete_category' => array( |
|
206 | - 'func' => '_delete_categories', |
|
207 | - 'capability' => 'ee_delete_event_category', |
|
208 | - 'noheader' => true, |
|
209 | - ), |
|
210 | - 'insert_category' => array( |
|
211 | - 'func' => '_insert_or_update_category', |
|
212 | - 'args' => array('new_category' => true), |
|
213 | - 'capability' => 'ee_edit_event_category', |
|
214 | - 'noheader' => true, |
|
215 | - ), |
|
216 | - 'update_category' => array( |
|
217 | - 'func' => '_insert_or_update_category', |
|
218 | - 'args' => array('new_category' => false), |
|
219 | - 'capability' => 'ee_edit_event_category', |
|
220 | - 'noheader' => true, |
|
221 | - ), |
|
222 | - 'category_list' => array( |
|
223 | - 'func' => '_category_list_table', |
|
224 | - 'capability' => 'ee_manage_event_categories', |
|
225 | - ), |
|
226 | - ); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - |
|
231 | - protected function _set_page_config() |
|
232 | - { |
|
233 | - $this->_page_config = array( |
|
234 | - 'default' => array( |
|
235 | - 'nav' => array( |
|
236 | - 'label' => esc_html__('Overview', 'event_espresso'), |
|
237 | - 'order' => 10, |
|
238 | - ), |
|
239 | - 'list_table' => 'Events_Admin_List_Table', |
|
240 | - 'help_tabs' => array( |
|
241 | - 'events_overview_help_tab' => array( |
|
242 | - 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
243 | - 'filename' => 'events_overview', |
|
244 | - ), |
|
245 | - 'events_overview_table_column_headings_help_tab' => array( |
|
246 | - 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
247 | - 'filename' => 'events_overview_table_column_headings', |
|
248 | - ), |
|
249 | - 'events_overview_filters_help_tab' => array( |
|
250 | - 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
251 | - 'filename' => 'events_overview_filters', |
|
252 | - ), |
|
253 | - 'events_overview_view_help_tab' => array( |
|
254 | - 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
255 | - 'filename' => 'events_overview_views', |
|
256 | - ), |
|
257 | - 'events_overview_other_help_tab' => array( |
|
258 | - 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
259 | - 'filename' => 'events_overview_other', |
|
260 | - ), |
|
261 | - ), |
|
262 | - 'help_tour' => array( |
|
263 | - 'Event_Overview_Help_Tour', |
|
264 | - //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
265 | - ), |
|
266 | - 'qtips' => array( |
|
267 | - 'EE_Event_List_Table_Tips', |
|
268 | - ), |
|
269 | - 'require_nonce' => false, |
|
270 | - ), |
|
271 | - 'create_new' => array( |
|
272 | - 'nav' => array( |
|
273 | - 'label' => esc_html__('Add Event', 'event_espresso'), |
|
274 | - 'order' => 5, |
|
275 | - 'persistent' => false, |
|
276 | - ), |
|
277 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
278 | - 'help_tabs' => array( |
|
279 | - 'event_editor_help_tab' => array( |
|
280 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
281 | - 'filename' => 'event_editor', |
|
282 | - ), |
|
283 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
284 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
285 | - 'filename' => 'event_editor_title_richtexteditor', |
|
286 | - ), |
|
287 | - 'event_editor_venue_details_help_tab' => array( |
|
288 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
289 | - 'filename' => 'event_editor_venue_details', |
|
290 | - ), |
|
291 | - 'event_editor_event_datetimes_help_tab' => array( |
|
292 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
293 | - 'filename' => 'event_editor_event_datetimes', |
|
294 | - ), |
|
295 | - 'event_editor_event_tickets_help_tab' => array( |
|
296 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
297 | - 'filename' => 'event_editor_event_tickets', |
|
298 | - ), |
|
299 | - 'event_editor_event_registration_options_help_tab' => array( |
|
300 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
301 | - 'filename' => 'event_editor_event_registration_options', |
|
302 | - ), |
|
303 | - 'event_editor_tags_categories_help_tab' => array( |
|
304 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
305 | - 'filename' => 'event_editor_tags_categories', |
|
306 | - ), |
|
307 | - 'event_editor_questions_registrants_help_tab' => array( |
|
308 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
309 | - 'filename' => 'event_editor_questions_registrants', |
|
310 | - ), |
|
311 | - 'event_editor_save_new_event_help_tab' => array( |
|
312 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
313 | - 'filename' => 'event_editor_save_new_event', |
|
314 | - ), |
|
315 | - 'event_editor_other_help_tab' => array( |
|
316 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
317 | - 'filename' => 'event_editor_other', |
|
318 | - ), |
|
319 | - ), |
|
320 | - 'help_tour' => array( |
|
321 | - 'Event_Editor_Help_Tour', |
|
322 | - ), |
|
323 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | - 'require_nonce' => false, |
|
325 | - ), |
|
326 | - 'edit' => array( |
|
327 | - 'nav' => array( |
|
328 | - 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
329 | - 'order' => 5, |
|
330 | - 'persistent' => false, |
|
331 | - 'url' => isset($this->_req_data['post']) |
|
332 | - ? EE_Admin_Page::add_query_args_and_nonce( |
|
333 | - array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
334 | - $this->_current_page_view_url |
|
335 | - ) |
|
336 | - : $this->_admin_base_url, |
|
337 | - ), |
|
338 | - 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
339 | - 'help_tabs' => array( |
|
340 | - 'event_editor_help_tab' => array( |
|
341 | - 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
342 | - 'filename' => 'event_editor', |
|
343 | - ), |
|
344 | - 'event_editor_title_richtexteditor_help_tab' => array( |
|
345 | - 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
346 | - 'filename' => 'event_editor_title_richtexteditor', |
|
347 | - ), |
|
348 | - 'event_editor_venue_details_help_tab' => array( |
|
349 | - 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
350 | - 'filename' => 'event_editor_venue_details', |
|
351 | - ), |
|
352 | - 'event_editor_event_datetimes_help_tab' => array( |
|
353 | - 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
354 | - 'filename' => 'event_editor_event_datetimes', |
|
355 | - ), |
|
356 | - 'event_editor_event_tickets_help_tab' => array( |
|
357 | - 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
358 | - 'filename' => 'event_editor_event_tickets', |
|
359 | - ), |
|
360 | - 'event_editor_event_registration_options_help_tab' => array( |
|
361 | - 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
362 | - 'filename' => 'event_editor_event_registration_options', |
|
363 | - ), |
|
364 | - 'event_editor_tags_categories_help_tab' => array( |
|
365 | - 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
366 | - 'filename' => 'event_editor_tags_categories', |
|
367 | - ), |
|
368 | - 'event_editor_questions_registrants_help_tab' => array( |
|
369 | - 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
370 | - 'filename' => 'event_editor_questions_registrants', |
|
371 | - ), |
|
372 | - 'event_editor_save_new_event_help_tab' => array( |
|
373 | - 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
374 | - 'filename' => 'event_editor_save_new_event', |
|
375 | - ), |
|
376 | - 'event_editor_other_help_tab' => array( |
|
377 | - 'title' => esc_html__('Event Other', 'event_espresso'), |
|
378 | - 'filename' => 'event_editor_other', |
|
379 | - ), |
|
380 | - ), |
|
381 | - /*'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 | + * @var EE_Event |
|
47 | + */ |
|
48 | + protected $_cpt_model_obj = false; |
|
49 | + |
|
50 | + |
|
51 | + |
|
52 | + protected function _init_page_props() |
|
53 | + { |
|
54 | + $this->page_slug = EVENTS_PG_SLUG; |
|
55 | + $this->page_label = EVENTS_LABEL; |
|
56 | + $this->_admin_base_url = EVENTS_ADMIN_URL; |
|
57 | + $this->_admin_base_path = EVENTS_ADMIN; |
|
58 | + $this->_cpt_model_names = array( |
|
59 | + 'create_new' => 'EEM_Event', |
|
60 | + 'edit' => 'EEM_Event', |
|
61 | + ); |
|
62 | + $this->_cpt_edit_routes = array( |
|
63 | + 'espresso_events' => 'edit', |
|
64 | + ); |
|
65 | + add_action( |
|
66 | + 'AHEE__EE_Admin_Page_CPT__set_model_object__after_set_object', |
|
67 | + array($this, 'verify_event_edit') |
|
68 | + ); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + protected function _ajax_hooks() |
|
74 | + { |
|
75 | + //todo: all hooks for events ajax goes in here. |
|
76 | + } |
|
77 | + |
|
78 | + |
|
79 | + |
|
80 | + protected function _define_page_props() |
|
81 | + { |
|
82 | + $this->_admin_page_title = EVENTS_LABEL; |
|
83 | + $this->_labels = array( |
|
84 | + 'buttons' => array( |
|
85 | + 'add' => esc_html__('Add New Event', 'event_espresso'), |
|
86 | + 'edit' => esc_html__('Edit Event', 'event_espresso'), |
|
87 | + 'delete' => esc_html__('Delete Event', 'event_espresso'), |
|
88 | + 'add_category' => esc_html__('Add New Category', 'event_espresso'), |
|
89 | + 'edit_category' => esc_html__('Edit Category', 'event_espresso'), |
|
90 | + 'delete_category' => esc_html__('Delete Category', 'event_espresso'), |
|
91 | + ), |
|
92 | + 'editor_title' => array( |
|
93 | + 'espresso_events' => esc_html__('Enter event title here', 'event_espresso'), |
|
94 | + ), |
|
95 | + 'publishbox' => array( |
|
96 | + 'create_new' => esc_html__('Save New Event', 'event_espresso'), |
|
97 | + 'edit' => esc_html__('Update Event', 'event_espresso'), |
|
98 | + 'add_category' => esc_html__('Save New Category', 'event_espresso'), |
|
99 | + 'edit_category' => esc_html__('Update Category', 'event_espresso'), |
|
100 | + 'template_settings' => esc_html__('Update Settings', 'event_espresso'), |
|
101 | + ), |
|
102 | + ); |
|
103 | + } |
|
104 | + |
|
105 | + |
|
106 | + |
|
107 | + protected function _set_page_routes() |
|
108 | + { |
|
109 | + //load formatter helper |
|
110 | + //load field generator helper |
|
111 | + //is there a evt_id in the request? |
|
112 | + $evt_id = ! empty($this->_req_data['EVT_ID']) && ! is_array($this->_req_data['EVT_ID']) |
|
113 | + ? $this->_req_data['EVT_ID'] : 0; |
|
114 | + $evt_id = ! empty($this->_req_data['post']) ? $this->_req_data['post'] : $evt_id; |
|
115 | + $this->_page_routes = array( |
|
116 | + 'default' => array( |
|
117 | + 'func' => '_events_overview_list_table', |
|
118 | + 'capability' => 'ee_read_events', |
|
119 | + ), |
|
120 | + 'create_new' => array( |
|
121 | + 'func' => '_create_new_cpt_item', |
|
122 | + 'capability' => 'ee_edit_events', |
|
123 | + ), |
|
124 | + 'edit' => array( |
|
125 | + 'func' => '_edit_cpt_item', |
|
126 | + 'capability' => 'ee_edit_event', |
|
127 | + 'obj_id' => $evt_id, |
|
128 | + ), |
|
129 | + 'copy_event' => array( |
|
130 | + 'func' => '_copy_events', |
|
131 | + 'capability' => 'ee_edit_event', |
|
132 | + 'obj_id' => $evt_id, |
|
133 | + 'noheader' => true, |
|
134 | + ), |
|
135 | + 'trash_event' => array( |
|
136 | + 'func' => '_trash_or_restore_event', |
|
137 | + 'args' => array('event_status' => 'trash'), |
|
138 | + 'capability' => 'ee_delete_event', |
|
139 | + 'obj_id' => $evt_id, |
|
140 | + 'noheader' => true, |
|
141 | + ), |
|
142 | + 'trash_events' => array( |
|
143 | + 'func' => '_trash_or_restore_events', |
|
144 | + 'args' => array('event_status' => 'trash'), |
|
145 | + 'capability' => 'ee_delete_events', |
|
146 | + 'noheader' => true, |
|
147 | + ), |
|
148 | + 'restore_event' => array( |
|
149 | + 'func' => '_trash_or_restore_event', |
|
150 | + 'args' => array('event_status' => 'draft'), |
|
151 | + 'capability' => 'ee_delete_event', |
|
152 | + 'obj_id' => $evt_id, |
|
153 | + 'noheader' => true, |
|
154 | + ), |
|
155 | + 'restore_events' => array( |
|
156 | + 'func' => '_trash_or_restore_events', |
|
157 | + 'args' => array('event_status' => 'draft'), |
|
158 | + 'capability' => 'ee_delete_events', |
|
159 | + 'noheader' => true, |
|
160 | + ), |
|
161 | + 'delete_event' => array( |
|
162 | + 'func' => '_delete_event', |
|
163 | + 'capability' => 'ee_delete_event', |
|
164 | + 'obj_id' => $evt_id, |
|
165 | + 'noheader' => true, |
|
166 | + ), |
|
167 | + 'delete_events' => array( |
|
168 | + 'func' => '_delete_events', |
|
169 | + 'capability' => 'ee_delete_events', |
|
170 | + 'noheader' => true, |
|
171 | + ), |
|
172 | + 'view_report' => array( |
|
173 | + 'func' => '_view_report', |
|
174 | + 'capablity' => 'ee_edit_events', |
|
175 | + ), |
|
176 | + 'default_event_settings' => array( |
|
177 | + 'func' => '_default_event_settings', |
|
178 | + 'capability' => 'manage_options', |
|
179 | + ), |
|
180 | + 'update_default_event_settings' => array( |
|
181 | + 'func' => '_update_default_event_settings', |
|
182 | + 'capability' => 'manage_options', |
|
183 | + 'noheader' => true, |
|
184 | + ), |
|
185 | + 'template_settings' => array( |
|
186 | + 'func' => '_template_settings', |
|
187 | + 'capability' => 'manage_options', |
|
188 | + ), |
|
189 | + //event category tab related |
|
190 | + 'add_category' => array( |
|
191 | + 'func' => '_category_details', |
|
192 | + 'capability' => 'ee_edit_event_category', |
|
193 | + 'args' => array('add'), |
|
194 | + ), |
|
195 | + 'edit_category' => array( |
|
196 | + 'func' => '_category_details', |
|
197 | + 'capability' => 'ee_edit_event_category', |
|
198 | + 'args' => array('edit'), |
|
199 | + ), |
|
200 | + 'delete_categories' => array( |
|
201 | + 'func' => '_delete_categories', |
|
202 | + 'capability' => 'ee_delete_event_category', |
|
203 | + 'noheader' => true, |
|
204 | + ), |
|
205 | + 'delete_category' => array( |
|
206 | + 'func' => '_delete_categories', |
|
207 | + 'capability' => 'ee_delete_event_category', |
|
208 | + 'noheader' => true, |
|
209 | + ), |
|
210 | + 'insert_category' => array( |
|
211 | + 'func' => '_insert_or_update_category', |
|
212 | + 'args' => array('new_category' => true), |
|
213 | + 'capability' => 'ee_edit_event_category', |
|
214 | + 'noheader' => true, |
|
215 | + ), |
|
216 | + 'update_category' => array( |
|
217 | + 'func' => '_insert_or_update_category', |
|
218 | + 'args' => array('new_category' => false), |
|
219 | + 'capability' => 'ee_edit_event_category', |
|
220 | + 'noheader' => true, |
|
221 | + ), |
|
222 | + 'category_list' => array( |
|
223 | + 'func' => '_category_list_table', |
|
224 | + 'capability' => 'ee_manage_event_categories', |
|
225 | + ), |
|
226 | + ); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + |
|
231 | + protected function _set_page_config() |
|
232 | + { |
|
233 | + $this->_page_config = array( |
|
234 | + 'default' => array( |
|
235 | + 'nav' => array( |
|
236 | + 'label' => esc_html__('Overview', 'event_espresso'), |
|
237 | + 'order' => 10, |
|
238 | + ), |
|
239 | + 'list_table' => 'Events_Admin_List_Table', |
|
240 | + 'help_tabs' => array( |
|
241 | + 'events_overview_help_tab' => array( |
|
242 | + 'title' => esc_html__('Events Overview', 'event_espresso'), |
|
243 | + 'filename' => 'events_overview', |
|
244 | + ), |
|
245 | + 'events_overview_table_column_headings_help_tab' => array( |
|
246 | + 'title' => esc_html__('Events Overview Table Column Headings', 'event_espresso'), |
|
247 | + 'filename' => 'events_overview_table_column_headings', |
|
248 | + ), |
|
249 | + 'events_overview_filters_help_tab' => array( |
|
250 | + 'title' => esc_html__('Events Overview Filters', 'event_espresso'), |
|
251 | + 'filename' => 'events_overview_filters', |
|
252 | + ), |
|
253 | + 'events_overview_view_help_tab' => array( |
|
254 | + 'title' => esc_html__('Events Overview Views', 'event_espresso'), |
|
255 | + 'filename' => 'events_overview_views', |
|
256 | + ), |
|
257 | + 'events_overview_other_help_tab' => array( |
|
258 | + 'title' => esc_html__('Events Overview Other', 'event_espresso'), |
|
259 | + 'filename' => 'events_overview_other', |
|
260 | + ), |
|
261 | + ), |
|
262 | + 'help_tour' => array( |
|
263 | + 'Event_Overview_Help_Tour', |
|
264 | + //'New_Features_Test_Help_Tour' for testing multiple help tour |
|
265 | + ), |
|
266 | + 'qtips' => array( |
|
267 | + 'EE_Event_List_Table_Tips', |
|
268 | + ), |
|
269 | + 'require_nonce' => false, |
|
270 | + ), |
|
271 | + 'create_new' => array( |
|
272 | + 'nav' => array( |
|
273 | + 'label' => esc_html__('Add Event', 'event_espresso'), |
|
274 | + 'order' => 5, |
|
275 | + 'persistent' => false, |
|
276 | + ), |
|
277 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
278 | + 'help_tabs' => array( |
|
279 | + 'event_editor_help_tab' => array( |
|
280 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
281 | + 'filename' => 'event_editor', |
|
282 | + ), |
|
283 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
284 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
285 | + 'filename' => 'event_editor_title_richtexteditor', |
|
286 | + ), |
|
287 | + 'event_editor_venue_details_help_tab' => array( |
|
288 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
289 | + 'filename' => 'event_editor_venue_details', |
|
290 | + ), |
|
291 | + 'event_editor_event_datetimes_help_tab' => array( |
|
292 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
293 | + 'filename' => 'event_editor_event_datetimes', |
|
294 | + ), |
|
295 | + 'event_editor_event_tickets_help_tab' => array( |
|
296 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
297 | + 'filename' => 'event_editor_event_tickets', |
|
298 | + ), |
|
299 | + 'event_editor_event_registration_options_help_tab' => array( |
|
300 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
301 | + 'filename' => 'event_editor_event_registration_options', |
|
302 | + ), |
|
303 | + 'event_editor_tags_categories_help_tab' => array( |
|
304 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
305 | + 'filename' => 'event_editor_tags_categories', |
|
306 | + ), |
|
307 | + 'event_editor_questions_registrants_help_tab' => array( |
|
308 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
309 | + 'filename' => 'event_editor_questions_registrants', |
|
310 | + ), |
|
311 | + 'event_editor_save_new_event_help_tab' => array( |
|
312 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
313 | + 'filename' => 'event_editor_save_new_event', |
|
314 | + ), |
|
315 | + 'event_editor_other_help_tab' => array( |
|
316 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
317 | + 'filename' => 'event_editor_other', |
|
318 | + ), |
|
319 | + ), |
|
320 | + 'help_tour' => array( |
|
321 | + 'Event_Editor_Help_Tour', |
|
322 | + ), |
|
323 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
324 | + 'require_nonce' => false, |
|
325 | + ), |
|
326 | + 'edit' => array( |
|
327 | + 'nav' => array( |
|
328 | + 'label' => esc_html__('Edit Event', 'event_espresso'), |
|
329 | + 'order' => 5, |
|
330 | + 'persistent' => false, |
|
331 | + 'url' => isset($this->_req_data['post']) |
|
332 | + ? EE_Admin_Page::add_query_args_and_nonce( |
|
333 | + array('post' => $this->_req_data['post'], 'action' => 'edit'), |
|
334 | + $this->_current_page_view_url |
|
335 | + ) |
|
336 | + : $this->_admin_base_url, |
|
337 | + ), |
|
338 | + 'metaboxes' => array('_register_event_editor_meta_boxes'), |
|
339 | + 'help_tabs' => array( |
|
340 | + 'event_editor_help_tab' => array( |
|
341 | + 'title' => esc_html__('Event Editor', 'event_espresso'), |
|
342 | + 'filename' => 'event_editor', |
|
343 | + ), |
|
344 | + 'event_editor_title_richtexteditor_help_tab' => array( |
|
345 | + 'title' => esc_html__('Event Title & Rich Text Editor', 'event_espresso'), |
|
346 | + 'filename' => 'event_editor_title_richtexteditor', |
|
347 | + ), |
|
348 | + 'event_editor_venue_details_help_tab' => array( |
|
349 | + 'title' => esc_html__('Event Venue Details', 'event_espresso'), |
|
350 | + 'filename' => 'event_editor_venue_details', |
|
351 | + ), |
|
352 | + 'event_editor_event_datetimes_help_tab' => array( |
|
353 | + 'title' => esc_html__('Event Datetimes', 'event_espresso'), |
|
354 | + 'filename' => 'event_editor_event_datetimes', |
|
355 | + ), |
|
356 | + 'event_editor_event_tickets_help_tab' => array( |
|
357 | + 'title' => esc_html__('Event Tickets', 'event_espresso'), |
|
358 | + 'filename' => 'event_editor_event_tickets', |
|
359 | + ), |
|
360 | + 'event_editor_event_registration_options_help_tab' => array( |
|
361 | + 'title' => esc_html__('Event Registration Options', 'event_espresso'), |
|
362 | + 'filename' => 'event_editor_event_registration_options', |
|
363 | + ), |
|
364 | + 'event_editor_tags_categories_help_tab' => array( |
|
365 | + 'title' => esc_html__('Event Tags & Categories', 'event_espresso'), |
|
366 | + 'filename' => 'event_editor_tags_categories', |
|
367 | + ), |
|
368 | + 'event_editor_questions_registrants_help_tab' => array( |
|
369 | + 'title' => esc_html__('Questions for Registrants', 'event_espresso'), |
|
370 | + 'filename' => 'event_editor_questions_registrants', |
|
371 | + ), |
|
372 | + 'event_editor_save_new_event_help_tab' => array( |
|
373 | + 'title' => esc_html__('Save New Event', 'event_espresso'), |
|
374 | + 'filename' => 'event_editor_save_new_event', |
|
375 | + ), |
|
376 | + 'event_editor_other_help_tab' => array( |
|
377 | + 'title' => esc_html__('Event Other', 'event_espresso'), |
|
378 | + 'filename' => 'event_editor_other', |
|
379 | + ), |
|
380 | + ), |
|
381 | + /*'help_tour' => array( |
|
382 | 382 | 'Event_Edit_Help_Tour' |
383 | 383 | ),*/ |
384 | - 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
385 | - 'require_nonce' => false, |
|
386 | - ), |
|
387 | - 'default_event_settings' => array( |
|
388 | - 'nav' => array( |
|
389 | - 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
390 | - 'order' => 40, |
|
391 | - ), |
|
392 | - 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
393 | - 'labels' => array( |
|
394 | - 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
395 | - ), |
|
396 | - 'help_tabs' => array( |
|
397 | - 'default_settings_help_tab' => array( |
|
398 | - 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
399 | - 'filename' => 'events_default_settings', |
|
400 | - ), |
|
401 | - 'default_settings_status_help_tab' => array( |
|
402 | - 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
403 | - 'filename' => 'events_default_settings_status', |
|
404 | - ), |
|
405 | - ), |
|
406 | - 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
407 | - 'require_nonce' => false, |
|
408 | - ), |
|
409 | - //template settings |
|
410 | - 'template_settings' => array( |
|
411 | - 'nav' => array( |
|
412 | - 'label' => esc_html__('Templates', 'event_espresso'), |
|
413 | - 'order' => 30, |
|
414 | - ), |
|
415 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
416 | - 'help_tabs' => array( |
|
417 | - 'general_settings_templates_help_tab' => array( |
|
418 | - 'title' => esc_html__('Templates', 'event_espresso'), |
|
419 | - 'filename' => 'general_settings_templates', |
|
420 | - ), |
|
421 | - ), |
|
422 | - 'help_tour' => array('Templates_Help_Tour'), |
|
423 | - 'require_nonce' => false, |
|
424 | - ), |
|
425 | - //event category stuff |
|
426 | - 'add_category' => array( |
|
427 | - 'nav' => array( |
|
428 | - 'label' => esc_html__('Add Category', 'event_espresso'), |
|
429 | - 'order' => 15, |
|
430 | - 'persistent' => false, |
|
431 | - ), |
|
432 | - 'help_tabs' => array( |
|
433 | - 'add_category_help_tab' => array( |
|
434 | - 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
435 | - 'filename' => 'events_add_category', |
|
436 | - ), |
|
437 | - ), |
|
438 | - 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
439 | - 'metaboxes' => array('_publish_post_box'), |
|
440 | - 'require_nonce' => false, |
|
441 | - ), |
|
442 | - 'edit_category' => array( |
|
443 | - 'nav' => array( |
|
444 | - 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
445 | - 'order' => 15, |
|
446 | - 'persistent' => false, |
|
447 | - 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
448 | - ? add_query_arg( |
|
449 | - array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
450 | - $this->_current_page_view_url |
|
451 | - ) |
|
452 | - : $this->_admin_base_url, |
|
453 | - ), |
|
454 | - 'help_tabs' => array( |
|
455 | - 'edit_category_help_tab' => array( |
|
456 | - 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
457 | - 'filename' => 'events_edit_category', |
|
458 | - ), |
|
459 | - ), |
|
460 | - /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
461 | - 'metaboxes' => array('_publish_post_box'), |
|
462 | - 'require_nonce' => false, |
|
463 | - ), |
|
464 | - 'category_list' => array( |
|
465 | - 'nav' => array( |
|
466 | - 'label' => esc_html__('Categories', 'event_espresso'), |
|
467 | - 'order' => 20, |
|
468 | - ), |
|
469 | - 'list_table' => 'Event_Categories_Admin_List_Table', |
|
470 | - 'help_tabs' => array( |
|
471 | - 'events_categories_help_tab' => array( |
|
472 | - 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
473 | - 'filename' => 'events_categories', |
|
474 | - ), |
|
475 | - 'events_categories_table_column_headings_help_tab' => array( |
|
476 | - 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
477 | - 'filename' => 'events_categories_table_column_headings', |
|
478 | - ), |
|
479 | - 'events_categories_view_help_tab' => array( |
|
480 | - 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
481 | - 'filename' => 'events_categories_views', |
|
482 | - ), |
|
483 | - 'events_categories_other_help_tab' => array( |
|
484 | - 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
485 | - 'filename' => 'events_categories_other', |
|
486 | - ), |
|
487 | - ), |
|
488 | - 'help_tour' => array( |
|
489 | - 'Event_Categories_Help_Tour', |
|
490 | - ), |
|
491 | - 'metaboxes' => $this->_default_espresso_metaboxes, |
|
492 | - 'require_nonce' => false, |
|
493 | - ), |
|
494 | - ); |
|
495 | - } |
|
496 | - |
|
497 | - |
|
498 | - |
|
499 | - protected function _add_screen_options() |
|
500 | - { |
|
501 | - //todo |
|
502 | - } |
|
503 | - |
|
504 | - |
|
505 | - |
|
506 | - protected function _add_screen_options_default() |
|
507 | - { |
|
508 | - $this->_per_page_screen_option(); |
|
509 | - } |
|
510 | - |
|
511 | - |
|
512 | - |
|
513 | - protected function _add_screen_options_category_list() |
|
514 | - { |
|
515 | - $page_title = $this->_admin_page_title; |
|
516 | - $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
517 | - $this->_per_page_screen_option(); |
|
518 | - $this->_admin_page_title = $page_title; |
|
519 | - } |
|
520 | - |
|
521 | - |
|
522 | - |
|
523 | - protected function _add_feature_pointers() |
|
524 | - { |
|
525 | - //todo |
|
526 | - } |
|
527 | - |
|
528 | - |
|
529 | - |
|
530 | - public function load_scripts_styles() |
|
531 | - { |
|
532 | - wp_register_style( |
|
533 | - 'events-admin-css', |
|
534 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
535 | - array(), |
|
536 | - EVENT_ESPRESSO_VERSION |
|
537 | - ); |
|
538 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
539 | - wp_enqueue_style('events-admin-css'); |
|
540 | - wp_enqueue_style('ee-cat-admin'); |
|
541 | - //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
542 | - //registers for all views |
|
543 | - //scripts |
|
544 | - wp_register_script( |
|
545 | - 'event_editor_js', |
|
546 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
547 | - array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
548 | - EVENT_ESPRESSO_VERSION, |
|
549 | - true |
|
550 | - ); |
|
551 | - } |
|
552 | - |
|
553 | - |
|
554 | - |
|
555 | - /** |
|
556 | - * enqueuing scripts and styles specific to this view |
|
557 | - * |
|
558 | - * @return void |
|
559 | - */ |
|
560 | - public function load_scripts_styles_create_new() |
|
561 | - { |
|
562 | - $this->load_scripts_styles_edit(); |
|
563 | - } |
|
564 | - |
|
565 | - |
|
566 | - |
|
567 | - /** |
|
568 | - * enqueuing scripts and styles specific to this view |
|
569 | - * |
|
570 | - * @return void |
|
571 | - */ |
|
572 | - public function load_scripts_styles_edit() |
|
573 | - { |
|
574 | - //styles |
|
575 | - wp_enqueue_style('espresso-ui-theme'); |
|
576 | - wp_register_style( |
|
577 | - 'event-editor-css', |
|
578 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
579 | - array('ee-admin-css'), |
|
580 | - EVENT_ESPRESSO_VERSION |
|
581 | - ); |
|
582 | - wp_enqueue_style('event-editor-css'); |
|
583 | - //scripts |
|
584 | - wp_register_script( |
|
585 | - 'event-datetime-metabox', |
|
586 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
587 | - array('event_editor_js', 'ee-datepicker'), |
|
588 | - EVENT_ESPRESSO_VERSION |
|
589 | - ); |
|
590 | - wp_enqueue_script('event-datetime-metabox'); |
|
591 | - } |
|
592 | - |
|
593 | - |
|
594 | - |
|
595 | - public function load_scripts_styles_add_category() |
|
596 | - { |
|
597 | - $this->load_scripts_styles_edit_category(); |
|
598 | - } |
|
599 | - |
|
600 | - |
|
601 | - |
|
602 | - public function load_scripts_styles_edit_category() |
|
603 | - { |
|
604 | - } |
|
605 | - |
|
606 | - |
|
607 | - |
|
608 | - protected function _set_list_table_views_category_list() |
|
609 | - { |
|
610 | - $this->_views = array( |
|
611 | - 'all' => array( |
|
612 | - 'slug' => 'all', |
|
613 | - 'label' => esc_html__('All', 'event_espresso'), |
|
614 | - 'count' => 0, |
|
615 | - 'bulk_action' => array( |
|
616 | - 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
617 | - ), |
|
618 | - ), |
|
619 | - ); |
|
620 | - } |
|
621 | - |
|
622 | - |
|
623 | - |
|
624 | - public function admin_init() |
|
625 | - { |
|
626 | - EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
627 | - 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
628 | - 'event_espresso' |
|
629 | - ); |
|
630 | - } |
|
631 | - |
|
632 | - |
|
633 | - |
|
634 | - //nothing needed for events with these methods. |
|
635 | - public function admin_notices() |
|
636 | - { |
|
637 | - } |
|
638 | - |
|
639 | - |
|
640 | - |
|
641 | - public function admin_footer_scripts() |
|
642 | - { |
|
643 | - } |
|
644 | - |
|
645 | - |
|
646 | - |
|
647 | - /** |
|
648 | - * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
649 | - * warning (via EE_Error::add_error()); |
|
650 | - * |
|
651 | - * @param EE_Event $event Event object |
|
652 | - * @access public |
|
653 | - * @return void |
|
654 | - */ |
|
655 | - public function verify_event_edit($event = null) |
|
656 | - { |
|
657 | - // no event? |
|
658 | - if (empty($event)) { |
|
659 | - // set event |
|
660 | - $event = $this->_cpt_model_obj; |
|
661 | - } |
|
662 | - // STILL no event? |
|
663 | - if (empty ($event)) { |
|
664 | - return; |
|
665 | - } |
|
666 | - $orig_status = $event->status(); |
|
667 | - // first check if event is active. |
|
668 | - if ( |
|
669 | - $orig_status === EEM_Event::cancelled |
|
670 | - || $orig_status === EEM_Event::postponed |
|
671 | - || $event->is_expired() |
|
672 | - || $event->is_inactive() |
|
673 | - ) { |
|
674 | - return; |
|
675 | - } |
|
676 | - //made it here so it IS active... next check that any of the tickets are sold. |
|
677 | - if ($event->is_sold_out(true)) { |
|
678 | - if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
679 | - EE_Error::add_attention( |
|
680 | - sprintf( |
|
681 | - esc_html__( |
|
682 | - '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.', |
|
683 | - 'event_espresso' |
|
684 | - ), |
|
685 | - EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
686 | - ) |
|
687 | - ); |
|
688 | - } |
|
689 | - return; |
|
690 | - } else if ($orig_status === EEM_Event::sold_out) { |
|
691 | - EE_Error::add_attention( |
|
692 | - sprintf( |
|
693 | - esc_html__( |
|
694 | - '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.', |
|
695 | - 'event_espresso' |
|
696 | - ), |
|
697 | - EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
698 | - ) |
|
699 | - ); |
|
700 | - } |
|
701 | - //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
702 | - if ( ! $event->tickets_on_sale()) { |
|
703 | - return; |
|
704 | - } |
|
705 | - //made it here so show warning |
|
706 | - $this->_edit_event_warning(); |
|
707 | - } |
|
708 | - |
|
709 | - |
|
710 | - |
|
711 | - /** |
|
712 | - * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
713 | - * When needed, hook this into a EE_Error::add_error() notice. |
|
714 | - * |
|
715 | - * @access protected |
|
716 | - * @return void |
|
717 | - */ |
|
718 | - protected function _edit_event_warning() |
|
719 | - { |
|
720 | - // we don't want to add warnings during these requests |
|
721 | - if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
722 | - return; |
|
723 | - } |
|
724 | - EE_Error::add_attention( |
|
725 | - esc_html__( |
|
726 | - '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.', |
|
727 | - 'event_espresso' |
|
728 | - ) |
|
729 | - ); |
|
730 | - } |
|
731 | - |
|
732 | - |
|
733 | - |
|
734 | - /** |
|
735 | - * When a user is creating a new event, notify them if they haven't set their timezone. |
|
736 | - * Otherwise, do the normal logic |
|
737 | - * |
|
738 | - * @return string |
|
739 | - */ |
|
740 | - protected function _create_new_cpt_item() |
|
741 | - { |
|
742 | - $gmt_offset = get_option('gmt_offset'); |
|
743 | - //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
744 | - if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
745 | - EE_Error::add_attention( |
|
746 | - sprintf( |
|
747 | - __( |
|
748 | - 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
384 | + 'qtips' => array('EE_Event_Editor_Decaf_Tips'), |
|
385 | + 'require_nonce' => false, |
|
386 | + ), |
|
387 | + 'default_event_settings' => array( |
|
388 | + 'nav' => array( |
|
389 | + 'label' => esc_html__('Default Settings', 'event_espresso'), |
|
390 | + 'order' => 40, |
|
391 | + ), |
|
392 | + 'metaboxes' => array_merge($this->_default_espresso_metaboxes, array('_publish_post_box')), |
|
393 | + 'labels' => array( |
|
394 | + 'publishbox' => esc_html__('Update Settings', 'event_espresso'), |
|
395 | + ), |
|
396 | + 'help_tabs' => array( |
|
397 | + 'default_settings_help_tab' => array( |
|
398 | + 'title' => esc_html__('Default Event Settings', 'event_espresso'), |
|
399 | + 'filename' => 'events_default_settings', |
|
400 | + ), |
|
401 | + 'default_settings_status_help_tab' => array( |
|
402 | + 'title' => esc_html__('Default Registration Status', 'event_espresso'), |
|
403 | + 'filename' => 'events_default_settings_status', |
|
404 | + ), |
|
405 | + ), |
|
406 | + 'help_tour' => array('Event_Default_Settings_Help_Tour'), |
|
407 | + 'require_nonce' => false, |
|
408 | + ), |
|
409 | + //template settings |
|
410 | + 'template_settings' => array( |
|
411 | + 'nav' => array( |
|
412 | + 'label' => esc_html__('Templates', 'event_espresso'), |
|
413 | + 'order' => 30, |
|
414 | + ), |
|
415 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
416 | + 'help_tabs' => array( |
|
417 | + 'general_settings_templates_help_tab' => array( |
|
418 | + 'title' => esc_html__('Templates', 'event_espresso'), |
|
419 | + 'filename' => 'general_settings_templates', |
|
420 | + ), |
|
421 | + ), |
|
422 | + 'help_tour' => array('Templates_Help_Tour'), |
|
423 | + 'require_nonce' => false, |
|
424 | + ), |
|
425 | + //event category stuff |
|
426 | + 'add_category' => array( |
|
427 | + 'nav' => array( |
|
428 | + 'label' => esc_html__('Add Category', 'event_espresso'), |
|
429 | + 'order' => 15, |
|
430 | + 'persistent' => false, |
|
431 | + ), |
|
432 | + 'help_tabs' => array( |
|
433 | + 'add_category_help_tab' => array( |
|
434 | + 'title' => esc_html__('Add New Event Category', 'event_espresso'), |
|
435 | + 'filename' => 'events_add_category', |
|
436 | + ), |
|
437 | + ), |
|
438 | + 'help_tour' => array('Event_Add_Category_Help_Tour'), |
|
439 | + 'metaboxes' => array('_publish_post_box'), |
|
440 | + 'require_nonce' => false, |
|
441 | + ), |
|
442 | + 'edit_category' => array( |
|
443 | + 'nav' => array( |
|
444 | + 'label' => esc_html__('Edit Category', 'event_espresso'), |
|
445 | + 'order' => 15, |
|
446 | + 'persistent' => false, |
|
447 | + 'url' => isset($this->_req_data['EVT_CAT_ID']) |
|
448 | + ? add_query_arg( |
|
449 | + array('EVT_CAT_ID' => $this->_req_data['EVT_CAT_ID']), |
|
450 | + $this->_current_page_view_url |
|
451 | + ) |
|
452 | + : $this->_admin_base_url, |
|
453 | + ), |
|
454 | + 'help_tabs' => array( |
|
455 | + 'edit_category_help_tab' => array( |
|
456 | + 'title' => esc_html__('Edit Event Category', 'event_espresso'), |
|
457 | + 'filename' => 'events_edit_category', |
|
458 | + ), |
|
459 | + ), |
|
460 | + /*'help_tour' => array('Event_Edit_Category_Help_Tour'),*/ |
|
461 | + 'metaboxes' => array('_publish_post_box'), |
|
462 | + 'require_nonce' => false, |
|
463 | + ), |
|
464 | + 'category_list' => array( |
|
465 | + 'nav' => array( |
|
466 | + 'label' => esc_html__('Categories', 'event_espresso'), |
|
467 | + 'order' => 20, |
|
468 | + ), |
|
469 | + 'list_table' => 'Event_Categories_Admin_List_Table', |
|
470 | + 'help_tabs' => array( |
|
471 | + 'events_categories_help_tab' => array( |
|
472 | + 'title' => esc_html__('Event Categories', 'event_espresso'), |
|
473 | + 'filename' => 'events_categories', |
|
474 | + ), |
|
475 | + 'events_categories_table_column_headings_help_tab' => array( |
|
476 | + 'title' => esc_html__('Event Categories Table Column Headings', 'event_espresso'), |
|
477 | + 'filename' => 'events_categories_table_column_headings', |
|
478 | + ), |
|
479 | + 'events_categories_view_help_tab' => array( |
|
480 | + 'title' => esc_html__('Event Categories Views', 'event_espresso'), |
|
481 | + 'filename' => 'events_categories_views', |
|
482 | + ), |
|
483 | + 'events_categories_other_help_tab' => array( |
|
484 | + 'title' => esc_html__('Event Categories Other', 'event_espresso'), |
|
485 | + 'filename' => 'events_categories_other', |
|
486 | + ), |
|
487 | + ), |
|
488 | + 'help_tour' => array( |
|
489 | + 'Event_Categories_Help_Tour', |
|
490 | + ), |
|
491 | + 'metaboxes' => $this->_default_espresso_metaboxes, |
|
492 | + 'require_nonce' => false, |
|
493 | + ), |
|
494 | + ); |
|
495 | + } |
|
496 | + |
|
497 | + |
|
498 | + |
|
499 | + protected function _add_screen_options() |
|
500 | + { |
|
501 | + //todo |
|
502 | + } |
|
503 | + |
|
504 | + |
|
505 | + |
|
506 | + protected function _add_screen_options_default() |
|
507 | + { |
|
508 | + $this->_per_page_screen_option(); |
|
509 | + } |
|
510 | + |
|
511 | + |
|
512 | + |
|
513 | + protected function _add_screen_options_category_list() |
|
514 | + { |
|
515 | + $page_title = $this->_admin_page_title; |
|
516 | + $this->_admin_page_title = esc_html__('Categories', 'event_espresso'); |
|
517 | + $this->_per_page_screen_option(); |
|
518 | + $this->_admin_page_title = $page_title; |
|
519 | + } |
|
520 | + |
|
521 | + |
|
522 | + |
|
523 | + protected function _add_feature_pointers() |
|
524 | + { |
|
525 | + //todo |
|
526 | + } |
|
527 | + |
|
528 | + |
|
529 | + |
|
530 | + public function load_scripts_styles() |
|
531 | + { |
|
532 | + wp_register_style( |
|
533 | + 'events-admin-css', |
|
534 | + EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
535 | + array(), |
|
536 | + EVENT_ESPRESSO_VERSION |
|
537 | + ); |
|
538 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
539 | + wp_enqueue_style('events-admin-css'); |
|
540 | + wp_enqueue_style('ee-cat-admin'); |
|
541 | + //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
|
542 | + //registers for all views |
|
543 | + //scripts |
|
544 | + wp_register_script( |
|
545 | + 'event_editor_js', |
|
546 | + EVENTS_ASSETS_URL . 'event_editor.js', |
|
547 | + array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
|
548 | + EVENT_ESPRESSO_VERSION, |
|
549 | + true |
|
550 | + ); |
|
551 | + } |
|
552 | + |
|
553 | + |
|
554 | + |
|
555 | + /** |
|
556 | + * enqueuing scripts and styles specific to this view |
|
557 | + * |
|
558 | + * @return void |
|
559 | + */ |
|
560 | + public function load_scripts_styles_create_new() |
|
561 | + { |
|
562 | + $this->load_scripts_styles_edit(); |
|
563 | + } |
|
564 | + |
|
565 | + |
|
566 | + |
|
567 | + /** |
|
568 | + * enqueuing scripts and styles specific to this view |
|
569 | + * |
|
570 | + * @return void |
|
571 | + */ |
|
572 | + public function load_scripts_styles_edit() |
|
573 | + { |
|
574 | + //styles |
|
575 | + wp_enqueue_style('espresso-ui-theme'); |
|
576 | + wp_register_style( |
|
577 | + 'event-editor-css', |
|
578 | + EVENTS_ASSETS_URL . 'event-editor.css', |
|
579 | + array('ee-admin-css'), |
|
580 | + EVENT_ESPRESSO_VERSION |
|
581 | + ); |
|
582 | + wp_enqueue_style('event-editor-css'); |
|
583 | + //scripts |
|
584 | + wp_register_script( |
|
585 | + 'event-datetime-metabox', |
|
586 | + EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
587 | + array('event_editor_js', 'ee-datepicker'), |
|
588 | + EVENT_ESPRESSO_VERSION |
|
589 | + ); |
|
590 | + wp_enqueue_script('event-datetime-metabox'); |
|
591 | + } |
|
592 | + |
|
593 | + |
|
594 | + |
|
595 | + public function load_scripts_styles_add_category() |
|
596 | + { |
|
597 | + $this->load_scripts_styles_edit_category(); |
|
598 | + } |
|
599 | + |
|
600 | + |
|
601 | + |
|
602 | + public function load_scripts_styles_edit_category() |
|
603 | + { |
|
604 | + } |
|
605 | + |
|
606 | + |
|
607 | + |
|
608 | + protected function _set_list_table_views_category_list() |
|
609 | + { |
|
610 | + $this->_views = array( |
|
611 | + 'all' => array( |
|
612 | + 'slug' => 'all', |
|
613 | + 'label' => esc_html__('All', 'event_espresso'), |
|
614 | + 'count' => 0, |
|
615 | + 'bulk_action' => array( |
|
616 | + 'delete_categories' => esc_html__('Delete Permanently', 'event_espresso'), |
|
617 | + ), |
|
618 | + ), |
|
619 | + ); |
|
620 | + } |
|
621 | + |
|
622 | + |
|
623 | + |
|
624 | + public function admin_init() |
|
625 | + { |
|
626 | + EE_Registry::$i18n_js_strings['image_confirm'] = esc_html__( |
|
627 | + 'Do you really want to delete this image? Please remember to update your event to complete the removal.', |
|
628 | + 'event_espresso' |
|
629 | + ); |
|
630 | + } |
|
631 | + |
|
632 | + |
|
633 | + |
|
634 | + //nothing needed for events with these methods. |
|
635 | + public function admin_notices() |
|
636 | + { |
|
637 | + } |
|
638 | + |
|
639 | + |
|
640 | + |
|
641 | + public function admin_footer_scripts() |
|
642 | + { |
|
643 | + } |
|
644 | + |
|
645 | + |
|
646 | + |
|
647 | + /** |
|
648 | + * Call this function to verify if an event is public and has tickets for sale. If it does, then we need to show a |
|
649 | + * warning (via EE_Error::add_error()); |
|
650 | + * |
|
651 | + * @param EE_Event $event Event object |
|
652 | + * @access public |
|
653 | + * @return void |
|
654 | + */ |
|
655 | + public function verify_event_edit($event = null) |
|
656 | + { |
|
657 | + // no event? |
|
658 | + if (empty($event)) { |
|
659 | + // set event |
|
660 | + $event = $this->_cpt_model_obj; |
|
661 | + } |
|
662 | + // STILL no event? |
|
663 | + if (empty ($event)) { |
|
664 | + return; |
|
665 | + } |
|
666 | + $orig_status = $event->status(); |
|
667 | + // first check if event is active. |
|
668 | + if ( |
|
669 | + $orig_status === EEM_Event::cancelled |
|
670 | + || $orig_status === EEM_Event::postponed |
|
671 | + || $event->is_expired() |
|
672 | + || $event->is_inactive() |
|
673 | + ) { |
|
674 | + return; |
|
675 | + } |
|
676 | + //made it here so it IS active... next check that any of the tickets are sold. |
|
677 | + if ($event->is_sold_out(true)) { |
|
678 | + if ($orig_status !== EEM_Event::sold_out && $event->status() !== $orig_status) { |
|
679 | + EE_Error::add_attention( |
|
680 | + sprintf( |
|
681 | + esc_html__( |
|
682 | + '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.', |
|
683 | + 'event_espresso' |
|
684 | + ), |
|
685 | + EEH_Template::pretty_status(EEM_Event::sold_out, false, 'sentence') |
|
686 | + ) |
|
687 | + ); |
|
688 | + } |
|
689 | + return; |
|
690 | + } else if ($orig_status === EEM_Event::sold_out) { |
|
691 | + EE_Error::add_attention( |
|
692 | + sprintf( |
|
693 | + esc_html__( |
|
694 | + '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.', |
|
695 | + 'event_espresso' |
|
696 | + ), |
|
697 | + EEH_Template::pretty_status($event->status(), false, 'sentence') |
|
698 | + ) |
|
699 | + ); |
|
700 | + } |
|
701 | + //now we need to determine if the event has any tickets on sale. If not then we dont' show the error |
|
702 | + if ( ! $event->tickets_on_sale()) { |
|
703 | + return; |
|
704 | + } |
|
705 | + //made it here so show warning |
|
706 | + $this->_edit_event_warning(); |
|
707 | + } |
|
708 | + |
|
709 | + |
|
710 | + |
|
711 | + /** |
|
712 | + * This is the text used for when an event is being edited that is public and has tickets for sale. |
|
713 | + * When needed, hook this into a EE_Error::add_error() notice. |
|
714 | + * |
|
715 | + * @access protected |
|
716 | + * @return void |
|
717 | + */ |
|
718 | + protected function _edit_event_warning() |
|
719 | + { |
|
720 | + // we don't want to add warnings during these requests |
|
721 | + if (isset($this->_req_data['action']) && $this->_req_data['action'] === 'editpost') { |
|
722 | + return; |
|
723 | + } |
|
724 | + EE_Error::add_attention( |
|
725 | + esc_html__( |
|
726 | + '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.', |
|
727 | + 'event_espresso' |
|
728 | + ) |
|
729 | + ); |
|
730 | + } |
|
731 | + |
|
732 | + |
|
733 | + |
|
734 | + /** |
|
735 | + * When a user is creating a new event, notify them if they haven't set their timezone. |
|
736 | + * Otherwise, do the normal logic |
|
737 | + * |
|
738 | + * @return string |
|
739 | + */ |
|
740 | + protected function _create_new_cpt_item() |
|
741 | + { |
|
742 | + $gmt_offset = get_option('gmt_offset'); |
|
743 | + //only nag them about setting their timezone if it's their first event, and they haven't already done it |
|
744 | + if ($gmt_offset === '0' && ! EEM_Event::instance()->exists(array())) { |
|
745 | + EE_Error::add_attention( |
|
746 | + sprintf( |
|
747 | + __( |
|
748 | + 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
|
749 | 749 | or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.' |
750 | - ), |
|
751 | - '<a href="' . admin_url('options-general.php') . '">', |
|
752 | - '</a>' |
|
753 | - ), |
|
754 | - __FILE__, |
|
755 | - __FUNCTION__, |
|
756 | - __LINE__ |
|
757 | - ); |
|
758 | - } |
|
759 | - return parent::_create_new_cpt_item(); |
|
760 | - } |
|
761 | - |
|
762 | - |
|
763 | - |
|
764 | - protected function _set_list_table_views_default() |
|
765 | - { |
|
766 | - $this->_views = array( |
|
767 | - 'all' => array( |
|
768 | - 'slug' => 'all', |
|
769 | - 'label' => esc_html__('View All Events', 'event_espresso'), |
|
770 | - 'count' => 0, |
|
771 | - 'bulk_action' => array( |
|
772 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
773 | - ), |
|
774 | - ), |
|
775 | - 'draft' => array( |
|
776 | - 'slug' => 'draft', |
|
777 | - 'label' => esc_html__('Draft', 'event_espresso'), |
|
778 | - 'count' => 0, |
|
779 | - 'bulk_action' => array( |
|
780 | - 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
781 | - ), |
|
782 | - ), |
|
783 | - ); |
|
784 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
785 | - $this->_views['trash'] = array( |
|
786 | - 'slug' => 'trash', |
|
787 | - 'label' => esc_html__('Trash', 'event_espresso'), |
|
788 | - 'count' => 0, |
|
789 | - 'bulk_action' => array( |
|
790 | - 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
791 | - 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
792 | - ), |
|
793 | - ); |
|
794 | - } |
|
795 | - } |
|
796 | - |
|
797 | - |
|
798 | - |
|
799 | - /** |
|
800 | - * @return array |
|
801 | - */ |
|
802 | - protected function _event_legend_items() |
|
803 | - { |
|
804 | - $items = array( |
|
805 | - 'view_details' => array( |
|
806 | - 'class' => 'dashicons dashicons-search', |
|
807 | - 'desc' => esc_html__('View Event', 'event_espresso'), |
|
808 | - ), |
|
809 | - 'edit_event' => array( |
|
810 | - 'class' => 'ee-icon ee-icon-calendar-edit', |
|
811 | - 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
812 | - ), |
|
813 | - 'view_attendees' => array( |
|
814 | - 'class' => 'dashicons dashicons-groups', |
|
815 | - 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
816 | - ), |
|
817 | - ); |
|
818 | - $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
819 | - $statuses = array( |
|
820 | - 'sold_out_status' => array( |
|
821 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
822 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
823 | - ), |
|
824 | - 'active_status' => array( |
|
825 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
826 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
827 | - ), |
|
828 | - 'upcoming_status' => array( |
|
829 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
830 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
831 | - ), |
|
832 | - 'postponed_status' => array( |
|
833 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
834 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
835 | - ), |
|
836 | - 'cancelled_status' => array( |
|
837 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
838 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
839 | - ), |
|
840 | - 'expired_status' => array( |
|
841 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
842 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
843 | - ), |
|
844 | - 'inactive_status' => array( |
|
845 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
846 | - 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
847 | - ), |
|
848 | - ); |
|
849 | - $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
850 | - return array_merge($items, $statuses); |
|
851 | - } |
|
852 | - |
|
853 | - |
|
854 | - |
|
855 | - /** |
|
856 | - * _event_model |
|
857 | - * |
|
858 | - * @return EEM_Event |
|
859 | - */ |
|
860 | - private function _event_model() |
|
861 | - { |
|
862 | - if ( ! $this->_event_model instanceof EEM_Event) { |
|
863 | - $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
864 | - } |
|
865 | - return $this->_event_model; |
|
866 | - } |
|
867 | - |
|
868 | - |
|
869 | - |
|
870 | - /** |
|
871 | - * Adds extra buttons to the WP CPT permalink field row. |
|
872 | - * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
873 | - * |
|
874 | - * @param string $return the current html |
|
875 | - * @param int $id the post id for the page |
|
876 | - * @param string $new_title What the title is |
|
877 | - * @param string $new_slug what the slug is |
|
878 | - * @return string The new html string for the permalink area |
|
879 | - */ |
|
880 | - public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
881 | - { |
|
882 | - //make sure this is only when editing |
|
883 | - if ( ! empty($id)) { |
|
884 | - $post = get_post($id); |
|
885 | - $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
886 | - . esc_html__('Shortcode', 'event_espresso') |
|
887 | - . '</a> '; |
|
888 | - $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
889 | - . $post->ID |
|
890 | - . ']">'; |
|
891 | - } |
|
892 | - return $return; |
|
893 | - } |
|
894 | - |
|
895 | - |
|
896 | - |
|
897 | - /** |
|
898 | - * _events_overview_list_table |
|
899 | - * This contains the logic for showing the events_overview list |
|
900 | - * |
|
901 | - * @access protected |
|
902 | - * @return void |
|
903 | - * @throws \EE_Error |
|
904 | - */ |
|
905 | - protected function _events_overview_list_table() |
|
906 | - { |
|
907 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
908 | - $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
909 | - ? (array)$this->_template_args['after_list_table'] |
|
910 | - : array(); |
|
911 | - $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
912 | - . EEH_Template::get_button_or_link( |
|
913 | - get_post_type_archive_link('espresso_events'), |
|
914 | - esc_html__("View Event Archive Page", "event_espresso"), |
|
915 | - 'button' |
|
916 | - ); |
|
917 | - $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
918 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
919 | - 'create_new', |
|
920 | - 'add', |
|
921 | - array(), |
|
922 | - 'add-new-h2' |
|
923 | - ); |
|
924 | - $this->display_admin_list_table_page_with_no_sidebar(); |
|
925 | - } |
|
926 | - |
|
927 | - |
|
928 | - |
|
929 | - /** |
|
930 | - * this allows for extra misc actions in the default WP publish box |
|
931 | - * |
|
932 | - * @return void |
|
933 | - */ |
|
934 | - public function extra_misc_actions_publish_box() |
|
935 | - { |
|
936 | - $this->_generate_publish_box_extra_content(); |
|
937 | - } |
|
938 | - |
|
939 | - |
|
940 | - |
|
941 | - /** |
|
942 | - * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
943 | - * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
944 | - * data. |
|
945 | - * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
946 | - * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
947 | - * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
948 | - * you handle this accordingly. |
|
949 | - * |
|
950 | - * @access protected |
|
951 | - * @abstract |
|
952 | - * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
953 | - * @param object $post The post object of the cpt that was saved. |
|
954 | - * @return void |
|
955 | - */ |
|
956 | - protected function _insert_update_cpt_item($post_id, $post) |
|
957 | - { |
|
958 | - if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
959 | - //get out we're not processing an event save. |
|
960 | - return; |
|
961 | - } |
|
962 | - $event_values = array( |
|
963 | - 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
964 | - 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
965 | - 'EVT_additional_limit' => min( |
|
966 | - apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
967 | - ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
968 | - ), |
|
969 | - 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
970 | - ? $this->_req_data['EVT_default_registration_status'] |
|
971 | - : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
972 | - 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
973 | - 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
974 | - 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
975 | - ? $this->_req_data['timezone_string'] : null, |
|
976 | - 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
977 | - ? $this->_req_data['externalURL'] : null, |
|
978 | - 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
979 | - ? $this->_req_data['event_phone'] : null, |
|
980 | - ); |
|
981 | - //update event |
|
982 | - $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
983 | - //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! |
|
984 | - $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
985 | - $event = $this->_event_model()->get_one(array($get_one_where)); |
|
986 | - //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
987 | - $event_update_callbacks = apply_filters( |
|
988 | - 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
989 | - array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
990 | - ); |
|
991 | - $att_success = true; |
|
992 | - foreach ($event_update_callbacks as $e_callback) { |
|
993 | - $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
994 | - $att_success = ! $att_success ? $att_success |
|
995 | - : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
996 | - } |
|
997 | - //any errors? |
|
998 | - if ($success && false === $att_success) { |
|
999 | - EE_Error::add_error( |
|
1000 | - esc_html__( |
|
1001 | - 'Event Details saved successfully but something went wrong with saving attachments.', |
|
1002 | - 'event_espresso' |
|
1003 | - ), |
|
1004 | - __FILE__, |
|
1005 | - __FUNCTION__, |
|
1006 | - __LINE__ |
|
1007 | - ); |
|
1008 | - } else if ($success === false) { |
|
1009 | - EE_Error::add_error( |
|
1010 | - esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
1011 | - __FILE__, |
|
1012 | - __FUNCTION__, |
|
1013 | - __LINE__ |
|
1014 | - ); |
|
1015 | - } |
|
1016 | - } |
|
1017 | - |
|
1018 | - |
|
1019 | - |
|
1020 | - /** |
|
1021 | - * @see parent::restore_item() |
|
1022 | - * @param int $post_id |
|
1023 | - * @param int $revision_id |
|
1024 | - */ |
|
1025 | - protected function _restore_cpt_item($post_id, $revision_id) |
|
1026 | - { |
|
1027 | - //copy existing event meta to new post |
|
1028 | - $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1029 | - if ($post_evt instanceof EE_Event) { |
|
1030 | - //meta revision restore |
|
1031 | - $post_evt->restore_revision($revision_id); |
|
1032 | - //related objs restore |
|
1033 | - $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1034 | - } |
|
1035 | - } |
|
1036 | - |
|
1037 | - |
|
1038 | - |
|
1039 | - /** |
|
1040 | - * Attach the venue to the Event |
|
1041 | - * |
|
1042 | - * @param \EE_Event $evtobj Event Object to add the venue to |
|
1043 | - * @param array $data The request data from the form |
|
1044 | - * @return bool Success or fail. |
|
1045 | - */ |
|
1046 | - protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1047 | - { |
|
1048 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1049 | - $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1050 | - $rows_affected = null; |
|
1051 | - $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1052 | - // very important. If we don't have a venue name... |
|
1053 | - // then we'll get out because not necessary to create empty venue |
|
1054 | - if (empty($data['venue_title'])) { |
|
1055 | - return false; |
|
1056 | - } |
|
1057 | - $venue_array = array( |
|
1058 | - 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1059 | - 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1060 | - 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1061 | - 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1062 | - 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1063 | - : null, |
|
1064 | - 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1065 | - 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1066 | - 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1067 | - 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1068 | - 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1069 | - 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1070 | - 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1071 | - 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1072 | - 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1073 | - 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1074 | - 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1075 | - 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1076 | - 'status' => 'publish', |
|
1077 | - ); |
|
1078 | - //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1079 | - if ( ! empty($venue_id)) { |
|
1080 | - $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1081 | - $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1082 | - //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. |
|
1083 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1084 | - return $rows_affected > 0 ? true : false; |
|
1085 | - } else { |
|
1086 | - //we insert the venue |
|
1087 | - $venue_id = $venue_model->insert($venue_array); |
|
1088 | - $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1089 | - return ! empty($venue_id) ? true : false; |
|
1090 | - } |
|
1091 | - //when we have the ancestor come in it's already been handled by the revision save. |
|
1092 | - } |
|
1093 | - |
|
1094 | - |
|
1095 | - |
|
1096 | - /** |
|
1097 | - * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1098 | - * |
|
1099 | - * @param EE_Event $evtobj The Event object we're attaching data to |
|
1100 | - * @param array $data The request data from the form |
|
1101 | - * @return array |
|
1102 | - */ |
|
1103 | - protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1104 | - { |
|
1105 | - $success = true; |
|
1106 | - $saved_dtt = null; |
|
1107 | - $saved_tickets = array(); |
|
1108 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1109 | - foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1110 | - //trim all values to ensure any excess whitespace is removed. |
|
1111 | - $dtt = array_map('trim', $dtt); |
|
1112 | - $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1113 | - : $dtt['DTT_EVT_start']; |
|
1114 | - $datetime_values = array( |
|
1115 | - 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1116 | - 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1117 | - 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1118 | - 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1119 | - 'DTT_order' => $row, |
|
1120 | - ); |
|
1121 | - //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. |
|
1122 | - if ( ! empty($dtt['DTT_ID'])) { |
|
1123 | - $DTM = EE_Registry::instance() |
|
1124 | - ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1125 | - ->get_one_by_ID($dtt['DTT_ID']); |
|
1126 | - $DTM->set_date_format($incoming_date_formats[0]); |
|
1127 | - $DTM->set_time_format($incoming_date_formats[1]); |
|
1128 | - foreach ($datetime_values as $field => $value) { |
|
1129 | - $DTM->set($field, $value); |
|
1130 | - } |
|
1131 | - //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. |
|
1132 | - $saved_dtts[$DTM->ID()] = $DTM; |
|
1133 | - } else { |
|
1134 | - $DTM = EE_Registry::instance()->load_class( |
|
1135 | - 'Datetime', |
|
1136 | - array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1137 | - false, |
|
1138 | - false |
|
1139 | - ); |
|
1140 | - foreach ($datetime_values as $field => $value) { |
|
1141 | - $DTM->set($field, $value); |
|
1142 | - } |
|
1143 | - } |
|
1144 | - $DTM->save(); |
|
1145 | - $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1146 | - //load DTT helper |
|
1147 | - //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. |
|
1148 | - if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1149 | - $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1150 | - $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1151 | - $DTT->save(); |
|
1152 | - } |
|
1153 | - //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. |
|
1154 | - $saved_dtt = $DTT; |
|
1155 | - $success = ! $success ? $success : $DTT; |
|
1156 | - //if ANY of these updates fail then we want the appropriate global error message. |
|
1157 | - // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1158 | - } |
|
1159 | - //no dtts get deleted so we don't do any of that logic here. |
|
1160 | - //update tickets next |
|
1161 | - $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1162 | - foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1163 | - $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1164 | - $update_prices = false; |
|
1165 | - $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1166 | - ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1167 | - // trim inputs to ensure any excess whitespace is removed. |
|
1168 | - $tkt = array_map('trim', $tkt); |
|
1169 | - if (empty($tkt['TKT_start_date'])) { |
|
1170 | - //let's use now in the set timezone. |
|
1171 | - $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1172 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1173 | - } |
|
1174 | - if (empty($tkt['TKT_end_date'])) { |
|
1175 | - //use the start date of the first datetime |
|
1176 | - $dtt = $evtobj->first_datetime(); |
|
1177 | - $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1178 | - $incoming_date_formats[0], |
|
1179 | - $incoming_date_formats[1] |
|
1180 | - ); |
|
1181 | - } |
|
1182 | - $TKT_values = array( |
|
1183 | - 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1184 | - 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1185 | - 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1186 | - 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1187 | - 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1188 | - 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1189 | - 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1190 | - 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1191 | - 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1192 | - 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1193 | - 'TKT_row' => $row, |
|
1194 | - 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1195 | - 'TKT_price' => $ticket_price, |
|
1196 | - ); |
|
1197 | - //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. |
|
1198 | - if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1199 | - $TKT_values['TKT_ID'] = 0; |
|
1200 | - $TKT_values['TKT_is_default'] = 0; |
|
1201 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1202 | - $update_prices = true; |
|
1203 | - } |
|
1204 | - //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1205 | - //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. |
|
1206 | - //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. |
|
1207 | - if ( ! empty($tkt['TKT_ID'])) { |
|
1208 | - $TKT = EE_Registry::instance() |
|
1209 | - ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1210 | - ->get_one_by_ID($tkt['TKT_ID']); |
|
1211 | - if ($TKT instanceof EE_Ticket) { |
|
1212 | - $ticket_sold = $TKT->count_related( |
|
1213 | - 'Registration', |
|
1214 | - array( |
|
1215 | - array( |
|
1216 | - 'STS_ID' => array( |
|
1217 | - 'NOT IN', |
|
1218 | - array(EEM_Registration::status_id_incomplete), |
|
1219 | - ), |
|
1220 | - ), |
|
1221 | - ) |
|
1222 | - ) > 0 ? true : false; |
|
1223 | - //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. |
|
1224 | - $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1225 | - && ! $TKT->get( |
|
1226 | - 'TKT_deleted' |
|
1227 | - ) ? true : false; |
|
1228 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1229 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1230 | - //set new values |
|
1231 | - foreach ($TKT_values as $field => $value) { |
|
1232 | - if ($field == 'TKT_qty') { |
|
1233 | - $TKT->set_qty($value); |
|
1234 | - } else { |
|
1235 | - $TKT->set($field, $value); |
|
1236 | - } |
|
1237 | - } |
|
1238 | - //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1239 | - if ($create_new_TKT) { |
|
1240 | - //archive the old ticket first |
|
1241 | - $TKT->set('TKT_deleted', 1); |
|
1242 | - $TKT->save(); |
|
1243 | - //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1244 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1245 | - //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. |
|
1246 | - $TKT = clone $TKT; |
|
1247 | - $TKT->set('TKT_ID', 0); |
|
1248 | - $TKT->set('TKT_deleted', 0); |
|
1249 | - $TKT->set('TKT_price', $ticket_price); |
|
1250 | - $TKT->set('TKT_sold', 0); |
|
1251 | - //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1252 | - $update_prices = true; |
|
1253 | - } |
|
1254 | - //make sure price is set if it hasn't been already |
|
1255 | - $TKT->set('TKT_price', $ticket_price); |
|
1256 | - } |
|
1257 | - } else { |
|
1258 | - //no TKT_id so a new TKT |
|
1259 | - $TKT_values['TKT_price'] = $ticket_price; |
|
1260 | - $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1261 | - if ($TKT instanceof EE_Ticket) { |
|
1262 | - //need to reset values to properly account for the date formats |
|
1263 | - $TKT->set_date_format($incoming_date_formats[0]); |
|
1264 | - $TKT->set_time_format($incoming_date_formats[1]); |
|
1265 | - $TKT->set_timezone($evtobj->get_timezone()); |
|
1266 | - //set new values |
|
1267 | - foreach ($TKT_values as $field => $value) { |
|
1268 | - if ($field == 'TKT_qty') { |
|
1269 | - $TKT->set_qty($value); |
|
1270 | - } else { |
|
1271 | - $TKT->set($field, $value); |
|
1272 | - } |
|
1273 | - } |
|
1274 | - $update_prices = true; |
|
1275 | - } |
|
1276 | - } |
|
1277 | - // cap ticket qty by datetime reg limits |
|
1278 | - $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1279 | - //update ticket. |
|
1280 | - $TKT->save(); |
|
1281 | - //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. |
|
1282 | - if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1283 | - $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1284 | - $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1285 | - $TKT->save(); |
|
1286 | - } |
|
1287 | - //initially let's add the ticket to the dtt |
|
1288 | - $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1289 | - $saved_tickets[$TKT->ID()] = $TKT; |
|
1290 | - //add prices to ticket |
|
1291 | - $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1292 | - } |
|
1293 | - //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. |
|
1294 | - $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1295 | - $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1296 | - foreach ($tickets_removed as $id) { |
|
1297 | - $id = absint($id); |
|
1298 | - //get the ticket for this id |
|
1299 | - $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1300 | - //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) |
|
1301 | - $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1302 | - foreach ($dtts as $dtt) { |
|
1303 | - $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1304 | - } |
|
1305 | - //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)) |
|
1306 | - $tkt_to_remove->delete_related_permanently('Price'); |
|
1307 | - //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1308 | - $tkt_to_remove->delete_permanently(); |
|
1309 | - } |
|
1310 | - return array($saved_dtt, $saved_tickets); |
|
1311 | - } |
|
1312 | - |
|
1313 | - |
|
1314 | - |
|
1315 | - /** |
|
1316 | - * This attaches a list of given prices to a ticket. |
|
1317 | - * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1318 | - * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1319 | - * price info and prices are automatically "archived" via the ticket. |
|
1320 | - * |
|
1321 | - * @access private |
|
1322 | - * @param array $prices Array of prices from the form. |
|
1323 | - * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1324 | - * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1325 | - * @return void |
|
1326 | - */ |
|
1327 | - private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1328 | - { |
|
1329 | - foreach ($prices as $row => $prc) { |
|
1330 | - $PRC_values = array( |
|
1331 | - 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1332 | - 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1333 | - 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1334 | - 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1335 | - 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1336 | - 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1337 | - 'PRC_order' => $row, |
|
1338 | - ); |
|
1339 | - if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1340 | - $PRC_values['PRC_ID'] = 0; |
|
1341 | - $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1342 | - } else { |
|
1343 | - $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1344 | - //update this price with new values |
|
1345 | - foreach ($PRC_values as $field => $newprc) { |
|
1346 | - $PRC->set($field, $newprc); |
|
1347 | - } |
|
1348 | - $PRC->save(); |
|
1349 | - } |
|
1350 | - $ticket->_add_relation_to($PRC, 'Price'); |
|
1351 | - } |
|
1352 | - } |
|
1353 | - |
|
1354 | - |
|
1355 | - |
|
1356 | - /** |
|
1357 | - * Add in our autosave ajax handlers |
|
1358 | - * |
|
1359 | - * @return void |
|
1360 | - */ |
|
1361 | - protected function _ee_autosave_create_new() |
|
1362 | - { |
|
1363 | - // $this->_ee_autosave_edit(); |
|
1364 | - } |
|
1365 | - |
|
1366 | - |
|
1367 | - |
|
1368 | - protected function _ee_autosave_edit() |
|
1369 | - { |
|
1370 | - return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1371 | - } |
|
1372 | - |
|
1373 | - |
|
1374 | - |
|
1375 | - /** |
|
1376 | - * _generate_publish_box_extra_content |
|
1377 | - * |
|
1378 | - * @access private |
|
1379 | - * @return void |
|
1380 | - */ |
|
1381 | - private function _generate_publish_box_extra_content() |
|
1382 | - { |
|
1383 | - //load formatter helper |
|
1384 | - //args for getting related registrations |
|
1385 | - $approved_query_args = array( |
|
1386 | - array( |
|
1387 | - 'REG_deleted' => 0, |
|
1388 | - 'STS_ID' => EEM_Registration::status_id_approved, |
|
1389 | - ), |
|
1390 | - ); |
|
1391 | - $not_approved_query_args = array( |
|
1392 | - array( |
|
1393 | - 'REG_deleted' => 0, |
|
1394 | - 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1395 | - ), |
|
1396 | - ); |
|
1397 | - $pending_payment_query_args = array( |
|
1398 | - array( |
|
1399 | - 'REG_deleted' => 0, |
|
1400 | - 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1401 | - ), |
|
1402 | - ); |
|
1403 | - // publish box |
|
1404 | - $publish_box_extra_args = array( |
|
1405 | - 'view_approved_reg_url' => add_query_arg( |
|
1406 | - array( |
|
1407 | - 'action' => 'default', |
|
1408 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1409 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
1410 | - ), |
|
1411 | - REG_ADMIN_URL |
|
1412 | - ), |
|
1413 | - 'view_not_approved_reg_url' => add_query_arg( |
|
1414 | - array( |
|
1415 | - 'action' => 'default', |
|
1416 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1417 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1418 | - ), |
|
1419 | - REG_ADMIN_URL |
|
1420 | - ), |
|
1421 | - 'view_pending_payment_reg_url' => add_query_arg( |
|
1422 | - array( |
|
1423 | - 'action' => 'default', |
|
1424 | - 'event_id' => $this->_cpt_model_obj->ID(), |
|
1425 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1426 | - ), |
|
1427 | - REG_ADMIN_URL |
|
1428 | - ), |
|
1429 | - 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1430 | - 'Registration', |
|
1431 | - $approved_query_args |
|
1432 | - ), |
|
1433 | - 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1434 | - 'Registration', |
|
1435 | - $not_approved_query_args |
|
1436 | - ), |
|
1437 | - 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1438 | - 'Registration', |
|
1439 | - $pending_payment_query_args |
|
1440 | - ), |
|
1441 | - 'misc_pub_section_class' => apply_filters( |
|
1442 | - 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1443 | - 'misc-pub-section' |
|
1444 | - ), |
|
1445 | - //'email_attendees_url' => add_query_arg( |
|
1446 | - // array( |
|
1447 | - // 'event_admin_reports' => 'event_newsletter', |
|
1448 | - // 'event_id' => $this->_cpt_model_obj->id |
|
1449 | - // ), |
|
1450 | - // 'admin.php?page=espresso_registrations' |
|
1451 | - //), |
|
1452 | - ); |
|
1453 | - ob_start(); |
|
1454 | - do_action( |
|
1455 | - 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1456 | - $this->_cpt_model_obj |
|
1457 | - ); |
|
1458 | - $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1459 | - // load template |
|
1460 | - EEH_Template::display_template( |
|
1461 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1462 | - $publish_box_extra_args |
|
1463 | - ); |
|
1464 | - } |
|
1465 | - |
|
1466 | - |
|
1467 | - |
|
1468 | - /** |
|
1469 | - * This just returns whatever is set as the _event object property |
|
1470 | - * //todo this will become obsolete once the models are in place |
|
1471 | - * |
|
1472 | - * @return object |
|
1473 | - */ |
|
1474 | - public function get_event_object() |
|
1475 | - { |
|
1476 | - return $this->_cpt_model_obj; |
|
1477 | - } |
|
1478 | - |
|
1479 | - |
|
1480 | - |
|
1481 | - |
|
1482 | - /** METABOXES * */ |
|
1483 | - /** |
|
1484 | - * _register_event_editor_meta_boxes |
|
1485 | - * add all metaboxes related to the event_editor |
|
1486 | - * |
|
1487 | - * @return void |
|
1488 | - */ |
|
1489 | - protected function _register_event_editor_meta_boxes() |
|
1490 | - { |
|
1491 | - $this->verify_cpt_object(); |
|
1492 | - add_meta_box( |
|
1493 | - 'espresso_event_editor_tickets', |
|
1494 | - esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1495 | - array($this, 'ticket_metabox'), |
|
1496 | - $this->page_slug, |
|
1497 | - 'normal', |
|
1498 | - 'high' |
|
1499 | - ); |
|
1500 | - add_meta_box( |
|
1501 | - 'espresso_event_editor_event_options', |
|
1502 | - esc_html__('Event Registration Options', 'event_espresso'), |
|
1503 | - array($this, 'registration_options_meta_box'), |
|
1504 | - $this->page_slug, |
|
1505 | - 'side', |
|
1506 | - 'default' |
|
1507 | - ); |
|
1508 | - // NOTE: if you're looking for other metaboxes in here, |
|
1509 | - // where a metabox has a related management page in the admin |
|
1510 | - // you will find it setup in the related management page's "_Hooks" file. |
|
1511 | - // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1512 | - } |
|
1513 | - |
|
1514 | - |
|
1515 | - |
|
1516 | - public function ticket_metabox() |
|
1517 | - { |
|
1518 | - $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1519 | - //defaults for template args |
|
1520 | - $template_args = array( |
|
1521 | - 'existing_datetime_ids' => '', |
|
1522 | - 'event_datetime_help_link' => '', |
|
1523 | - 'ticket_options_help_link' => '', |
|
1524 | - 'time' => null, |
|
1525 | - 'ticket_rows' => '', |
|
1526 | - 'existing_ticket_ids' => '', |
|
1527 | - 'total_ticket_rows' => 1, |
|
1528 | - 'ticket_js_structure' => '', |
|
1529 | - 'trash_icon' => 'ee-lock-icon', |
|
1530 | - 'disabled' => '', |
|
1531 | - ); |
|
1532 | - $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1533 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1534 | - /** |
|
1535 | - * 1. Start with retrieving Datetimes |
|
1536 | - * 2. Fore each datetime get related tickets |
|
1537 | - * 3. For each ticket get related prices |
|
1538 | - */ |
|
1539 | - $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1540 | - /** @type EE_Datetime $first_datetime */ |
|
1541 | - $first_datetime = reset($times); |
|
1542 | - //do we get related tickets? |
|
1543 | - if ($first_datetime instanceof EE_Datetime |
|
1544 | - && $first_datetime->ID() !== 0 |
|
1545 | - ) { |
|
1546 | - $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1547 | - $template_args['time'] = $first_datetime; |
|
1548 | - $related_tickets = $first_datetime->tickets( |
|
1549 | - array( |
|
1550 | - array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1551 | - 'default_where_conditions' => 'none', |
|
1552 | - ) |
|
1553 | - ); |
|
1554 | - if ( ! empty($related_tickets)) { |
|
1555 | - $template_args['total_ticket_rows'] = count($related_tickets); |
|
1556 | - $row = 0; |
|
1557 | - foreach ($related_tickets as $ticket) { |
|
1558 | - $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1559 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1560 | - $row++; |
|
1561 | - } |
|
1562 | - } else { |
|
1563 | - $template_args['total_ticket_rows'] = 1; |
|
1564 | - /** @type EE_Ticket $ticket */ |
|
1565 | - $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1566 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1567 | - } |
|
1568 | - } else { |
|
1569 | - $template_args['time'] = $times[0]; |
|
1570 | - /** @type EE_Ticket $ticket */ |
|
1571 | - $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1572 | - $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1573 | - // NOTE: we're just sending the first default row |
|
1574 | - // (decaf can't manage default tickets so this should be sufficient); |
|
1575 | - } |
|
1576 | - $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1577 | - 'event_editor_event_datetimes_help_tab' |
|
1578 | - ); |
|
1579 | - $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1580 | - $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1581 | - $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1582 | - $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1583 | - EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1584 | - true |
|
1585 | - ); |
|
1586 | - $template = apply_filters( |
|
1587 | - 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1588 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1589 | - ); |
|
1590 | - EEH_Template::display_template($template, $template_args); |
|
1591 | - } |
|
1592 | - |
|
1593 | - |
|
1594 | - |
|
1595 | - /** |
|
1596 | - * Setup an individual ticket form for the decaf event editor page |
|
1597 | - * |
|
1598 | - * @access private |
|
1599 | - * @param EE_Ticket $ticket the ticket object |
|
1600 | - * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1601 | - * @param int $row |
|
1602 | - * @return string generated html for the ticket row. |
|
1603 | - */ |
|
1604 | - private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1605 | - { |
|
1606 | - $template_args = array( |
|
1607 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1608 | - 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1609 | - : '', |
|
1610 | - 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1611 | - 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1612 | - 'TKT_name' => $ticket->get('TKT_name'), |
|
1613 | - 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1614 | - 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1615 | - 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1616 | - 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1617 | - 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1618 | - 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1619 | - 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1620 | - && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1621 | - ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1622 | - 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1623 | - : ' disabled=disabled', |
|
1624 | - ); |
|
1625 | - $price = $ticket->ID() !== 0 |
|
1626 | - ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1627 | - : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1628 | - $price_args = array( |
|
1629 | - 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1630 | - 'PRC_amount' => $price->get('PRC_amount'), |
|
1631 | - 'PRT_ID' => $price->get('PRT_ID'), |
|
1632 | - 'PRC_ID' => $price->get('PRC_ID'), |
|
1633 | - 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1634 | - ); |
|
1635 | - //make sure we have default start and end dates if skeleton |
|
1636 | - //handle rows that should NOT be empty |
|
1637 | - if (empty($template_args['TKT_start_date'])) { |
|
1638 | - //if empty then the start date will be now. |
|
1639 | - $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1640 | - } |
|
1641 | - if (empty($template_args['TKT_end_date'])) { |
|
1642 | - //get the earliest datetime (if present); |
|
1643 | - $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1644 | - ? $this->_cpt_model_obj->get_first_related( |
|
1645 | - 'Datetime', |
|
1646 | - array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1647 | - ) |
|
1648 | - : null; |
|
1649 | - if ( ! empty($earliest_dtt)) { |
|
1650 | - $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1651 | - } else { |
|
1652 | - $template_args['TKT_end_date'] = date( |
|
1653 | - 'Y-m-d h:i a', |
|
1654 | - mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1655 | - ); |
|
1656 | - } |
|
1657 | - } |
|
1658 | - $template_args = array_merge($template_args, $price_args); |
|
1659 | - $template = apply_filters( |
|
1660 | - 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1661 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1662 | - $ticket |
|
1663 | - ); |
|
1664 | - return EEH_Template::display_template($template, $template_args, true); |
|
1665 | - } |
|
1666 | - |
|
1667 | - |
|
1668 | - |
|
1669 | - public function registration_options_meta_box() |
|
1670 | - { |
|
1671 | - $yes_no_values = array( |
|
1672 | - array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1673 | - array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1674 | - ); |
|
1675 | - $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1676 | - array( |
|
1677 | - EEM_Registration::status_id_cancelled, |
|
1678 | - EEM_Registration::status_id_declined, |
|
1679 | - EEM_Registration::status_id_incomplete, |
|
1680 | - ), |
|
1681 | - true |
|
1682 | - ); |
|
1683 | - //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1684 | - $template_args['_event'] = $this->_cpt_model_obj; |
|
1685 | - $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1686 | - $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1687 | - $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1688 | - 'default_reg_status', |
|
1689 | - $default_reg_status_values, |
|
1690 | - $this->_cpt_model_obj->default_registration_status() |
|
1691 | - ); |
|
1692 | - $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1693 | - 'display_desc', |
|
1694 | - $yes_no_values, |
|
1695 | - $this->_cpt_model_obj->display_description() |
|
1696 | - ); |
|
1697 | - $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1698 | - 'display_ticket_selector', |
|
1699 | - $yes_no_values, |
|
1700 | - $this->_cpt_model_obj->display_ticket_selector(), |
|
1701 | - '', |
|
1702 | - '', |
|
1703 | - false |
|
1704 | - ); |
|
1705 | - $template_args['additional_registration_options'] = apply_filters( |
|
1706 | - 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1707 | - '', |
|
1708 | - $template_args, |
|
1709 | - $yes_no_values, |
|
1710 | - $default_reg_status_values |
|
1711 | - ); |
|
1712 | - EEH_Template::display_template( |
|
1713 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1714 | - $template_args |
|
1715 | - ); |
|
1716 | - } |
|
1717 | - |
|
1718 | - |
|
1719 | - |
|
1720 | - /** |
|
1721 | - * _get_events() |
|
1722 | - * This method simply returns all the events (for the given _view and paging) |
|
1723 | - * |
|
1724 | - * @access public |
|
1725 | - * @param int $per_page count of items per page (20 default); |
|
1726 | - * @param int $current_page what is the current page being viewed. |
|
1727 | - * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1728 | - * If FALSE then we return an array of event objects |
|
1729 | - * that match the given _view and paging parameters. |
|
1730 | - * @return array an array of event objects. |
|
1731 | - */ |
|
1732 | - public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1733 | - { |
|
1734 | - $EEME = $this->_event_model(); |
|
1735 | - $offset = ($current_page - 1) * $per_page; |
|
1736 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1737 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1738 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1739 | - if (isset($this->_req_data['month_range'])) { |
|
1740 | - $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1741 | - $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1742 | - $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1743 | - } |
|
1744 | - $where = array(); |
|
1745 | - $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1746 | - //determine what post_status our condition will have for the query. |
|
1747 | - switch ($status) { |
|
1748 | - case 'month' : |
|
1749 | - case 'today' : |
|
1750 | - case null : |
|
1751 | - case 'all' : |
|
1752 | - break; |
|
1753 | - case 'draft' : |
|
1754 | - $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1755 | - break; |
|
1756 | - default : |
|
1757 | - $where['status'] = $status; |
|
1758 | - } |
|
1759 | - //categories? |
|
1760 | - $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1761 | - ? $this->_req_data['EVT_CAT'] : null; |
|
1762 | - if ( ! empty ($category)) { |
|
1763 | - $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1764 | - $where['Term_Taxonomy.term_id'] = $category; |
|
1765 | - } |
|
1766 | - //date where conditions |
|
1767 | - $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1768 | - if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1769 | - $DateTime = new DateTime( |
|
1770 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1771 | - new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1772 | - ); |
|
1773 | - $start = $DateTime->format(implode(' ', $start_formats)); |
|
1774 | - $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
1775 | - ->format('t'))->setTime(23, 59, 59) |
|
1776 | - ->format(implode(' ', $start_formats)); |
|
1777 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1778 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1779 | - $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1780 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1781 | - $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1782 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1783 | - } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1784 | - $now = date('Y-m-01'); |
|
1785 | - $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1786 | - $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1787 | - $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1788 | - ->setTime(23, 59, 59) |
|
1789 | - ->format(implode(' ', $start_formats)); |
|
1790 | - $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1791 | - } |
|
1792 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1793 | - $where['EVT_wp_user'] = get_current_user_id(); |
|
1794 | - } else { |
|
1795 | - if ( ! isset($where['status'])) { |
|
1796 | - if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1797 | - $where['OR'] = array( |
|
1798 | - 'status*restrict_private' => array('!=', 'private'), |
|
1799 | - 'AND' => array( |
|
1800 | - 'status*inclusive' => array('=', 'private'), |
|
1801 | - 'EVT_wp_user' => get_current_user_id(), |
|
1802 | - ), |
|
1803 | - ); |
|
1804 | - } |
|
1805 | - } |
|
1806 | - } |
|
1807 | - if (isset($this->_req_data['EVT_wp_user'])) { |
|
1808 | - if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1809 | - && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1810 | - ) { |
|
1811 | - $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1812 | - } |
|
1813 | - } |
|
1814 | - //search query handling |
|
1815 | - if (isset($this->_req_data['s'])) { |
|
1816 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1817 | - $where['OR'] = array( |
|
1818 | - 'EVT_name' => array('LIKE', $search_string), |
|
1819 | - 'EVT_desc' => array('LIKE', $search_string), |
|
1820 | - 'EVT_short_desc' => array('LIKE', $search_string), |
|
1821 | - ); |
|
1822 | - } |
|
1823 | - $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1824 | - $query_params = apply_filters( |
|
1825 | - 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1826 | - array( |
|
1827 | - $where, |
|
1828 | - 'limit' => $limit, |
|
1829 | - 'order_by' => $orderby, |
|
1830 | - 'order' => $order, |
|
1831 | - 'group_by' => 'EVT_ID', |
|
1832 | - ), |
|
1833 | - $this->_req_data |
|
1834 | - ); |
|
1835 | - //let's first check if we have special requests coming in. |
|
1836 | - if (isset($this->_req_data['active_status'])) { |
|
1837 | - switch ($this->_req_data['active_status']) { |
|
1838 | - case 'upcoming' : |
|
1839 | - return $EEME->get_upcoming_events($query_params, $count); |
|
1840 | - break; |
|
1841 | - case 'expired' : |
|
1842 | - return $EEME->get_expired_events($query_params, $count); |
|
1843 | - break; |
|
1844 | - case 'active' : |
|
1845 | - return $EEME->get_active_events($query_params, $count); |
|
1846 | - break; |
|
1847 | - case 'inactive' : |
|
1848 | - return $EEME->get_inactive_events($query_params, $count); |
|
1849 | - break; |
|
1850 | - } |
|
1851 | - } |
|
1852 | - $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1853 | - return $events; |
|
1854 | - } |
|
1855 | - |
|
1856 | - |
|
1857 | - |
|
1858 | - /** |
|
1859 | - * handling for WordPress CPT actions (trash, restore, delete) |
|
1860 | - * |
|
1861 | - * @param string $post_id |
|
1862 | - */ |
|
1863 | - public function trash_cpt_item($post_id) |
|
1864 | - { |
|
1865 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1866 | - $this->_trash_or_restore_event('trash', false); |
|
1867 | - } |
|
1868 | - |
|
1869 | - |
|
1870 | - |
|
1871 | - /** |
|
1872 | - * @param string $post_id |
|
1873 | - */ |
|
1874 | - public function restore_cpt_item($post_id) |
|
1875 | - { |
|
1876 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1877 | - $this->_trash_or_restore_event('draft', false); |
|
1878 | - } |
|
1879 | - |
|
1880 | - |
|
1881 | - |
|
1882 | - /** |
|
1883 | - * @param string $post_id |
|
1884 | - */ |
|
1885 | - public function delete_cpt_item($post_id) |
|
1886 | - { |
|
1887 | - $this->_req_data['EVT_ID'] = $post_id; |
|
1888 | - $this->_delete_event(false); |
|
1889 | - } |
|
1890 | - |
|
1891 | - |
|
1892 | - |
|
1893 | - /** |
|
1894 | - * _trash_or_restore_event |
|
1895 | - * |
|
1896 | - * @access protected |
|
1897 | - * @param string $event_status |
|
1898 | - * @param bool $redirect_after |
|
1899 | - */ |
|
1900 | - protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1901 | - { |
|
1902 | - //determine the event id and set to array. |
|
1903 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1904 | - // loop thru events |
|
1905 | - if ($EVT_ID) { |
|
1906 | - // clean status |
|
1907 | - $event_status = sanitize_key($event_status); |
|
1908 | - // grab status |
|
1909 | - if ( ! empty($event_status)) { |
|
1910 | - $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1911 | - } else { |
|
1912 | - $success = false; |
|
1913 | - $msg = esc_html__( |
|
1914 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1915 | - 'event_espresso' |
|
1916 | - ); |
|
1917 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1918 | - } |
|
1919 | - } else { |
|
1920 | - $success = false; |
|
1921 | - $msg = esc_html__( |
|
1922 | - 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1923 | - 'event_espresso' |
|
1924 | - ); |
|
1925 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1926 | - } |
|
1927 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1928 | - if ($redirect_after) { |
|
1929 | - $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1930 | - } |
|
1931 | - } |
|
1932 | - |
|
1933 | - |
|
1934 | - |
|
1935 | - /** |
|
1936 | - * _trash_or_restore_events |
|
1937 | - * |
|
1938 | - * @access protected |
|
1939 | - * @param string $event_status |
|
1940 | - * @return void |
|
1941 | - */ |
|
1942 | - protected function _trash_or_restore_events($event_status = 'trash') |
|
1943 | - { |
|
1944 | - // clean status |
|
1945 | - $event_status = sanitize_key($event_status); |
|
1946 | - // grab status |
|
1947 | - if ( ! empty($event_status)) { |
|
1948 | - $success = true; |
|
1949 | - //determine the event id and set to array. |
|
1950 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1951 | - // loop thru events |
|
1952 | - foreach ($EVT_IDs as $EVT_ID) { |
|
1953 | - if ($EVT_ID = absint($EVT_ID)) { |
|
1954 | - $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1955 | - $success = $results !== false ? $success : false; |
|
1956 | - } else { |
|
1957 | - $msg = sprintf( |
|
1958 | - esc_html__( |
|
1959 | - 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1960 | - 'event_espresso' |
|
1961 | - ), |
|
1962 | - $EVT_ID |
|
1963 | - ); |
|
1964 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1965 | - $success = false; |
|
1966 | - } |
|
1967 | - } |
|
1968 | - } else { |
|
1969 | - $success = false; |
|
1970 | - $msg = esc_html__( |
|
1971 | - 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1972 | - 'event_espresso' |
|
1973 | - ); |
|
1974 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1975 | - } |
|
1976 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1977 | - $success = $success ? 2 : false; |
|
1978 | - $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1979 | - $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1980 | - } |
|
1981 | - |
|
1982 | - |
|
1983 | - |
|
1984 | - /** |
|
1985 | - * _trash_or_restore_events |
|
1986 | - * |
|
1987 | - * @access private |
|
1988 | - * @param int $EVT_ID |
|
1989 | - * @param string $event_status |
|
1990 | - * @return bool |
|
1991 | - */ |
|
1992 | - private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1993 | - { |
|
1994 | - // grab event id |
|
1995 | - if ( ! $EVT_ID) { |
|
1996 | - $msg = esc_html__( |
|
1997 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
1998 | - 'event_espresso' |
|
1999 | - ); |
|
2000 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2001 | - return false; |
|
2002 | - } |
|
2003 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2004 | - // clean status |
|
2005 | - $event_status = sanitize_key($event_status); |
|
2006 | - // grab status |
|
2007 | - if (empty($event_status)) { |
|
2008 | - $msg = esc_html__( |
|
2009 | - 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
2010 | - 'event_espresso' |
|
2011 | - ); |
|
2012 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2013 | - return false; |
|
2014 | - } |
|
2015 | - // was event trashed or restored ? |
|
2016 | - switch ($event_status) { |
|
2017 | - case 'draft' : |
|
2018 | - $action = 'restored from the trash'; |
|
2019 | - $hook = 'AHEE_event_restored_from_trash'; |
|
2020 | - break; |
|
2021 | - case 'trash' : |
|
2022 | - $action = 'moved to the trash'; |
|
2023 | - $hook = 'AHEE_event_moved_to_trash'; |
|
2024 | - break; |
|
2025 | - default : |
|
2026 | - $action = 'updated'; |
|
2027 | - $hook = false; |
|
2028 | - } |
|
2029 | - //use class to change status |
|
2030 | - $this->_cpt_model_obj->set_status($event_status); |
|
2031 | - $success = $this->_cpt_model_obj->save(); |
|
2032 | - if ($success === false) { |
|
2033 | - $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2034 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2035 | - return false; |
|
2036 | - } |
|
2037 | - if ($hook) { |
|
2038 | - do_action($hook); |
|
2039 | - } |
|
2040 | - return true; |
|
2041 | - } |
|
2042 | - |
|
2043 | - |
|
2044 | - |
|
2045 | - /** |
|
2046 | - * _delete_event |
|
2047 | - * |
|
2048 | - * @access protected |
|
2049 | - * @param bool $redirect_after |
|
2050 | - */ |
|
2051 | - protected function _delete_event($redirect_after = true) |
|
2052 | - { |
|
2053 | - //determine the event id and set to array. |
|
2054 | - $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2055 | - $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2056 | - // loop thru events |
|
2057 | - if ($EVT_ID) { |
|
2058 | - $success = $this->_permanently_delete_event($EVT_ID); |
|
2059 | - // get list of events with no prices |
|
2060 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2061 | - // remove this event from the list of events with no prices |
|
2062 | - if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2063 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2064 | - } |
|
2065 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2066 | - } else { |
|
2067 | - $success = false; |
|
2068 | - $msg = esc_html__( |
|
2069 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2070 | - 'event_espresso' |
|
2071 | - ); |
|
2072 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2073 | - } |
|
2074 | - if ($redirect_after) { |
|
2075 | - $this->_redirect_after_action( |
|
2076 | - $success, |
|
2077 | - 'Event', |
|
2078 | - 'deleted', |
|
2079 | - array('action' => 'default', 'status' => 'trash') |
|
2080 | - ); |
|
2081 | - } |
|
2082 | - } |
|
2083 | - |
|
2084 | - |
|
2085 | - |
|
2086 | - /** |
|
2087 | - * _delete_events |
|
2088 | - * |
|
2089 | - * @access protected |
|
2090 | - * @return void |
|
2091 | - */ |
|
2092 | - protected function _delete_events() |
|
2093 | - { |
|
2094 | - $success = true; |
|
2095 | - // get list of events with no prices |
|
2096 | - $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2097 | - //determine the event id and set to array. |
|
2098 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2099 | - // loop thru events |
|
2100 | - foreach ($EVT_IDs as $EVT_ID) { |
|
2101 | - $EVT_ID = absint($EVT_ID); |
|
2102 | - if ($EVT_ID) { |
|
2103 | - $results = $this->_permanently_delete_event($EVT_ID); |
|
2104 | - $success = $results !== false ? $success : false; |
|
2105 | - // remove this event from the list of events with no prices |
|
2106 | - unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2107 | - } else { |
|
2108 | - $success = false; |
|
2109 | - $msg = esc_html__( |
|
2110 | - 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2111 | - 'event_espresso' |
|
2112 | - ); |
|
2113 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2114 | - } |
|
2115 | - } |
|
2116 | - update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2117 | - // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2118 | - $success = $success ? 2 : false; |
|
2119 | - $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2120 | - } |
|
2121 | - |
|
2122 | - |
|
2123 | - |
|
2124 | - /** |
|
2125 | - * _permanently_delete_event |
|
2126 | - * |
|
2127 | - * @access private |
|
2128 | - * @param int $EVT_ID |
|
2129 | - * @return bool |
|
2130 | - */ |
|
2131 | - private function _permanently_delete_event($EVT_ID = 0) |
|
2132 | - { |
|
2133 | - // grab event id |
|
2134 | - if ( ! $EVT_ID) { |
|
2135 | - $msg = esc_html__( |
|
2136 | - 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2137 | - 'event_espresso' |
|
2138 | - ); |
|
2139 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2140 | - return false; |
|
2141 | - } |
|
2142 | - if ( |
|
2143 | - ! $this->_cpt_model_obj instanceof EE_Event |
|
2144 | - || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2145 | - ) { |
|
2146 | - $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2147 | - } |
|
2148 | - if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2149 | - return false; |
|
2150 | - } |
|
2151 | - //need to delete related tickets and prices first. |
|
2152 | - $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2153 | - foreach ($datetimes as $datetime) { |
|
2154 | - $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2155 | - $tickets = $datetime->get_many_related('Ticket'); |
|
2156 | - foreach ($tickets as $ticket) { |
|
2157 | - $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2158 | - $ticket->delete_related_permanently('Price'); |
|
2159 | - $ticket->delete_permanently(); |
|
2160 | - } |
|
2161 | - $datetime->delete(); |
|
2162 | - } |
|
2163 | - //what about related venues or terms? |
|
2164 | - $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2165 | - foreach ($venues as $venue) { |
|
2166 | - $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2167 | - } |
|
2168 | - //any attached question groups? |
|
2169 | - $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2170 | - if ( ! empty($question_groups)) { |
|
2171 | - foreach ($question_groups as $question_group) { |
|
2172 | - $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2173 | - } |
|
2174 | - } |
|
2175 | - //Message Template Groups |
|
2176 | - $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2177 | - /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2178 | - $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2179 | - foreach ($term_taxonomies as $term_taxonomy) { |
|
2180 | - $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2181 | - } |
|
2182 | - $success = $this->_cpt_model_obj->delete_permanently(); |
|
2183 | - // did it all go as planned ? |
|
2184 | - if ($success) { |
|
2185 | - $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2186 | - EE_Error::add_success($msg); |
|
2187 | - } else { |
|
2188 | - $msg = sprintf( |
|
2189 | - esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2190 | - $EVT_ID |
|
2191 | - ); |
|
2192 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2193 | - return false; |
|
2194 | - } |
|
2195 | - do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2196 | - return true; |
|
2197 | - } |
|
2198 | - |
|
2199 | - |
|
2200 | - |
|
2201 | - /** |
|
2202 | - * get total number of events |
|
2203 | - * |
|
2204 | - * @access public |
|
2205 | - * @return int |
|
2206 | - */ |
|
2207 | - public function total_events() |
|
2208 | - { |
|
2209 | - $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2210 | - return $count; |
|
2211 | - } |
|
2212 | - |
|
2213 | - |
|
2214 | - |
|
2215 | - /** |
|
2216 | - * get total number of draft events |
|
2217 | - * |
|
2218 | - * @access public |
|
2219 | - * @return int |
|
2220 | - */ |
|
2221 | - public function total_events_draft() |
|
2222 | - { |
|
2223 | - $where = array( |
|
2224 | - 'status' => array('IN', array('draft', 'auto-draft')), |
|
2225 | - ); |
|
2226 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2227 | - return $count; |
|
2228 | - } |
|
2229 | - |
|
2230 | - |
|
2231 | - |
|
2232 | - /** |
|
2233 | - * get total number of trashed events |
|
2234 | - * |
|
2235 | - * @access public |
|
2236 | - * @return int |
|
2237 | - */ |
|
2238 | - public function total_trashed_events() |
|
2239 | - { |
|
2240 | - $where = array( |
|
2241 | - 'status' => 'trash', |
|
2242 | - ); |
|
2243 | - $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2244 | - return $count; |
|
2245 | - } |
|
2246 | - |
|
2247 | - |
|
2248 | - |
|
2249 | - /** |
|
2250 | - * _default_event_settings |
|
2251 | - * This generates the Default Settings Tab |
|
2252 | - * |
|
2253 | - * @return void |
|
2254 | - */ |
|
2255 | - protected function _default_event_settings() |
|
2256 | - { |
|
2257 | - $this->_template_args['values'] = $this->_yes_no_values; |
|
2258 | - $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2259 | - // exclude array |
|
2260 | - array( |
|
2261 | - EEM_Registration::status_id_cancelled, |
|
2262 | - EEM_Registration::status_id_declined, |
|
2263 | - EEM_Registration::status_id_incomplete, |
|
2264 | - EEM_Registration::status_id_wait_list, |
|
2265 | - ), |
|
2266 | - // translated |
|
2267 | - true |
|
2268 | - ); |
|
2269 | - $this->_template_args['default_reg_status'] = isset( |
|
2270 | - EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2271 | - ) |
|
2272 | - && in_array( |
|
2273 | - EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2274 | - $this->_template_args['reg_status_array'] |
|
2275 | - ) |
|
2276 | - ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2277 | - : EEM_Registration::status_id_pending_payment; |
|
2278 | - $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2279 | - $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2280 | - $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2281 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2282 | - $this->_template_args, |
|
2283 | - true |
|
2284 | - ); |
|
2285 | - $this->display_admin_page_with_sidebar(); |
|
2286 | - } |
|
2287 | - |
|
2288 | - |
|
2289 | - |
|
2290 | - /** |
|
2291 | - * _update_default_event_settings |
|
2292 | - * |
|
2293 | - * @access protected |
|
2294 | - * @return void |
|
2295 | - */ |
|
2296 | - protected function _update_default_event_settings() |
|
2297 | - { |
|
2298 | - EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2299 | - ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2300 | - : EEM_Registration::status_id_pending_payment; |
|
2301 | - $what = 'Default Event Settings'; |
|
2302 | - $success = $this->_update_espresso_configuration( |
|
2303 | - $what, |
|
2304 | - EE_Config::instance(), |
|
2305 | - __FILE__, |
|
2306 | - __FUNCTION__, |
|
2307 | - __LINE__ |
|
2308 | - ); |
|
2309 | - $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2310 | - } |
|
2311 | - |
|
2312 | - |
|
2313 | - |
|
2314 | - /************* Templates *************/ |
|
2315 | - protected function _template_settings() |
|
2316 | - { |
|
2317 | - $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2318 | - $this->_template_args['preview_img'] = '<img src="' |
|
2319 | - . EVENTS_ASSETS_URL |
|
2320 | - . DS |
|
2321 | - . 'images' |
|
2322 | - . DS |
|
2323 | - . 'caffeinated_template_features.jpg" alt="' |
|
2324 | - . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2325 | - . '" />'; |
|
2326 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2327 | - '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.', |
|
2328 | - 'event_espresso' |
|
2329 | - ) . '</strong>'; |
|
2330 | - $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2331 | - } |
|
2332 | - |
|
2333 | - |
|
2334 | - /** Event Category Stuff **/ |
|
2335 | - /** |
|
2336 | - * set the _category property with the category object for the loaded page. |
|
2337 | - * |
|
2338 | - * @access private |
|
2339 | - * @return void |
|
2340 | - */ |
|
2341 | - private function _set_category_object() |
|
2342 | - { |
|
2343 | - if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2344 | - return; |
|
2345 | - } //already have the category object so get out. |
|
2346 | - //set default category object |
|
2347 | - $this->_set_empty_category_object(); |
|
2348 | - //only set if we've got an id |
|
2349 | - if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2350 | - return; |
|
2351 | - } |
|
2352 | - $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2353 | - $term = get_term($category_id, 'espresso_event_categories'); |
|
2354 | - if ( ! empty($term)) { |
|
2355 | - $this->_category->category_name = $term->name; |
|
2356 | - $this->_category->category_identifier = $term->slug; |
|
2357 | - $this->_category->category_desc = $term->description; |
|
2358 | - $this->_category->id = $term->term_id; |
|
2359 | - $this->_category->parent = $term->parent; |
|
2360 | - } |
|
2361 | - } |
|
2362 | - |
|
2363 | - |
|
2364 | - |
|
2365 | - private function _set_empty_category_object() |
|
2366 | - { |
|
2367 | - $this->_category = new stdClass(); |
|
2368 | - $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2369 | - $this->_category->id = $this->_category->parent = 0; |
|
2370 | - } |
|
2371 | - |
|
2372 | - |
|
2373 | - |
|
2374 | - protected function _category_list_table() |
|
2375 | - { |
|
2376 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2377 | - $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2378 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2379 | - 'add_category', |
|
2380 | - 'add_category', |
|
2381 | - array(), |
|
2382 | - 'add-new-h2' |
|
2383 | - ); |
|
2384 | - $this->display_admin_list_table_page_with_sidebar(); |
|
2385 | - } |
|
2386 | - |
|
2387 | - |
|
2388 | - |
|
2389 | - /** |
|
2390 | - * @param $view |
|
2391 | - */ |
|
2392 | - protected function _category_details($view) |
|
2393 | - { |
|
2394 | - //load formatter helper |
|
2395 | - //load field generator helper |
|
2396 | - $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2397 | - $this->_set_add_edit_form_tags($route); |
|
2398 | - $this->_set_category_object(); |
|
2399 | - $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2400 | - $delete_action = 'delete_category'; |
|
2401 | - //custom redirect |
|
2402 | - $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2403 | - array('action' => 'category_list'), |
|
2404 | - $this->_admin_base_url |
|
2405 | - ); |
|
2406 | - $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2407 | - //take care of contents |
|
2408 | - $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2409 | - $this->display_admin_page_with_sidebar(); |
|
2410 | - } |
|
2411 | - |
|
2412 | - |
|
2413 | - |
|
2414 | - /** |
|
2415 | - * @return mixed |
|
2416 | - */ |
|
2417 | - protected function _category_details_content() |
|
2418 | - { |
|
2419 | - $editor_args['category_desc'] = array( |
|
2420 | - 'type' => 'wp_editor', |
|
2421 | - 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2422 | - 'class' => 'my_editor_custom', |
|
2423 | - 'wpeditor_args' => array('media_buttons' => false), |
|
2424 | - ); |
|
2425 | - $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2426 | - $all_terms = get_terms( |
|
2427 | - array('espresso_event_categories'), |
|
2428 | - array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2429 | - ); |
|
2430 | - //setup category select for term parents. |
|
2431 | - $category_select_values[] = array( |
|
2432 | - 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2433 | - 'id' => 0, |
|
2434 | - ); |
|
2435 | - foreach ($all_terms as $term) { |
|
2436 | - $category_select_values[] = array( |
|
2437 | - 'text' => $term->name, |
|
2438 | - 'id' => $term->term_id, |
|
2439 | - ); |
|
2440 | - } |
|
2441 | - $category_select = EEH_Form_Fields::select_input( |
|
2442 | - 'category_parent', |
|
2443 | - $category_select_values, |
|
2444 | - $this->_category->parent |
|
2445 | - ); |
|
2446 | - $template_args = array( |
|
2447 | - 'category' => $this->_category, |
|
2448 | - 'category_select' => $category_select, |
|
2449 | - 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2450 | - 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2451 | - 'disable' => '', |
|
2452 | - 'disabled_message' => false, |
|
2453 | - ); |
|
2454 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2455 | - return EEH_Template::display_template($template, $template_args, true); |
|
2456 | - } |
|
2457 | - |
|
2458 | - |
|
2459 | - |
|
2460 | - protected function _delete_categories() |
|
2461 | - { |
|
2462 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2463 | - : (array)$this->_req_data['category_id']; |
|
2464 | - foreach ($cat_ids as $cat_id) { |
|
2465 | - $this->_delete_category($cat_id); |
|
2466 | - } |
|
2467 | - //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2468 | - $query_args = array( |
|
2469 | - 'action' => 'category_list', |
|
2470 | - ); |
|
2471 | - $this->_redirect_after_action(0, '', '', $query_args); |
|
2472 | - } |
|
2473 | - |
|
2474 | - |
|
2475 | - |
|
2476 | - /** |
|
2477 | - * @param $cat_id |
|
2478 | - */ |
|
2479 | - protected function _delete_category($cat_id) |
|
2480 | - { |
|
2481 | - $cat_id = absint($cat_id); |
|
2482 | - wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2483 | - } |
|
2484 | - |
|
2485 | - |
|
2486 | - |
|
2487 | - /** |
|
2488 | - * @param $new_category |
|
2489 | - */ |
|
2490 | - protected function _insert_or_update_category($new_category) |
|
2491 | - { |
|
2492 | - $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2493 | - $success = 0; //we already have a success message so lets not send another. |
|
2494 | - if ($cat_id) { |
|
2495 | - $query_args = array( |
|
2496 | - 'action' => 'edit_category', |
|
2497 | - 'EVT_CAT_ID' => $cat_id, |
|
2498 | - ); |
|
2499 | - } else { |
|
2500 | - $query_args = array('action' => 'add_category'); |
|
2501 | - } |
|
2502 | - $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2503 | - } |
|
2504 | - |
|
2505 | - |
|
2506 | - |
|
2507 | - /** |
|
2508 | - * @param bool $update |
|
2509 | - * @return bool|mixed|string |
|
2510 | - */ |
|
2511 | - private function _insert_category($update = false) |
|
2512 | - { |
|
2513 | - $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2514 | - $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2515 | - $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2516 | - $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2517 | - if (empty($category_name)) { |
|
2518 | - $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2519 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2520 | - return false; |
|
2521 | - } |
|
2522 | - $term_args = array( |
|
2523 | - 'name' => $category_name, |
|
2524 | - 'description' => $category_desc, |
|
2525 | - 'parent' => $category_parent, |
|
2526 | - ); |
|
2527 | - //was the category_identifier input disabled? |
|
2528 | - if (isset($this->_req_data['category_identifier'])) { |
|
2529 | - $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2530 | - } |
|
2531 | - $insert_ids = $update |
|
2532 | - ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2533 | - : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2534 | - if ( ! is_array($insert_ids)) { |
|
2535 | - $msg = esc_html__( |
|
2536 | - 'An error occurred and the category has not been saved to the database.', |
|
2537 | - 'event_espresso' |
|
2538 | - ); |
|
2539 | - EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2540 | - } else { |
|
2541 | - $cat_id = $insert_ids['term_id']; |
|
2542 | - $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2543 | - EE_Error::add_success($msg); |
|
2544 | - } |
|
2545 | - return $cat_id; |
|
2546 | - } |
|
2547 | - |
|
2548 | - |
|
2549 | - |
|
2550 | - /** |
|
2551 | - * @param int $per_page |
|
2552 | - * @param int $current_page |
|
2553 | - * @param bool $count |
|
2554 | - * @return \EE_Base_Class[]|int |
|
2555 | - */ |
|
2556 | - public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2557 | - { |
|
2558 | - //testing term stuff |
|
2559 | - $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2560 | - $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2561 | - $limit = ($current_page - 1) * $per_page; |
|
2562 | - $where = array('taxonomy' => 'espresso_event_categories'); |
|
2563 | - if (isset($this->_req_data['s'])) { |
|
2564 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2565 | - $where['OR'] = array( |
|
2566 | - 'Term.name' => array('LIKE', $sstr), |
|
2567 | - 'description' => array('LIKE', $sstr), |
|
2568 | - ); |
|
2569 | - } |
|
2570 | - $query_params = array( |
|
2571 | - $where, |
|
2572 | - 'order_by' => array($orderby => $order), |
|
2573 | - 'limit' => $limit . ',' . $per_page, |
|
2574 | - 'force_join' => array('Term'), |
|
2575 | - ); |
|
2576 | - $categories = $count |
|
2577 | - ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2578 | - : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2579 | - return $categories; |
|
2580 | - } |
|
2581 | - |
|
2582 | - |
|
2583 | - |
|
2584 | - /* end category stuff */ |
|
2585 | - /**************/ |
|
750 | + ), |
|
751 | + '<a href="' . admin_url('options-general.php') . '">', |
|
752 | + '</a>' |
|
753 | + ), |
|
754 | + __FILE__, |
|
755 | + __FUNCTION__, |
|
756 | + __LINE__ |
|
757 | + ); |
|
758 | + } |
|
759 | + return parent::_create_new_cpt_item(); |
|
760 | + } |
|
761 | + |
|
762 | + |
|
763 | + |
|
764 | + protected function _set_list_table_views_default() |
|
765 | + { |
|
766 | + $this->_views = array( |
|
767 | + 'all' => array( |
|
768 | + 'slug' => 'all', |
|
769 | + 'label' => esc_html__('View All Events', 'event_espresso'), |
|
770 | + 'count' => 0, |
|
771 | + 'bulk_action' => array( |
|
772 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
773 | + ), |
|
774 | + ), |
|
775 | + 'draft' => array( |
|
776 | + 'slug' => 'draft', |
|
777 | + 'label' => esc_html__('Draft', 'event_espresso'), |
|
778 | + 'count' => 0, |
|
779 | + 'bulk_action' => array( |
|
780 | + 'trash_events' => esc_html__('Move to Trash', 'event_espresso'), |
|
781 | + ), |
|
782 | + ), |
|
783 | + ); |
|
784 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_events', 'espresso_events_trash_events')) { |
|
785 | + $this->_views['trash'] = array( |
|
786 | + 'slug' => 'trash', |
|
787 | + 'label' => esc_html__('Trash', 'event_espresso'), |
|
788 | + 'count' => 0, |
|
789 | + 'bulk_action' => array( |
|
790 | + 'restore_events' => esc_html__('Restore From Trash', 'event_espresso'), |
|
791 | + 'delete_events' => esc_html__('Delete Permanently', 'event_espresso'), |
|
792 | + ), |
|
793 | + ); |
|
794 | + } |
|
795 | + } |
|
796 | + |
|
797 | + |
|
798 | + |
|
799 | + /** |
|
800 | + * @return array |
|
801 | + */ |
|
802 | + protected function _event_legend_items() |
|
803 | + { |
|
804 | + $items = array( |
|
805 | + 'view_details' => array( |
|
806 | + 'class' => 'dashicons dashicons-search', |
|
807 | + 'desc' => esc_html__('View Event', 'event_espresso'), |
|
808 | + ), |
|
809 | + 'edit_event' => array( |
|
810 | + 'class' => 'ee-icon ee-icon-calendar-edit', |
|
811 | + 'desc' => esc_html__('Edit Event Details', 'event_espresso'), |
|
812 | + ), |
|
813 | + 'view_attendees' => array( |
|
814 | + 'class' => 'dashicons dashicons-groups', |
|
815 | + 'desc' => esc_html__('View Registrations for Event', 'event_espresso'), |
|
816 | + ), |
|
817 | + ); |
|
818 | + $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
|
819 | + $statuses = array( |
|
820 | + 'sold_out_status' => array( |
|
821 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
822 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
|
823 | + ), |
|
824 | + 'active_status' => array( |
|
825 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
826 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
|
827 | + ), |
|
828 | + 'upcoming_status' => array( |
|
829 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
830 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
|
831 | + ), |
|
832 | + 'postponed_status' => array( |
|
833 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
834 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
|
835 | + ), |
|
836 | + 'cancelled_status' => array( |
|
837 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
838 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
|
839 | + ), |
|
840 | + 'expired_status' => array( |
|
841 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
842 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
|
843 | + ), |
|
844 | + 'inactive_status' => array( |
|
845 | + 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
846 | + 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
|
847 | + ), |
|
848 | + ); |
|
849 | + $statuses = apply_filters('FHEE__Events_Admin_Page__event_legend_items__statuses', $statuses); |
|
850 | + return array_merge($items, $statuses); |
|
851 | + } |
|
852 | + |
|
853 | + |
|
854 | + |
|
855 | + /** |
|
856 | + * _event_model |
|
857 | + * |
|
858 | + * @return EEM_Event |
|
859 | + */ |
|
860 | + private function _event_model() |
|
861 | + { |
|
862 | + if ( ! $this->_event_model instanceof EEM_Event) { |
|
863 | + $this->_event_model = EE_Registry::instance()->load_model('Event'); |
|
864 | + } |
|
865 | + return $this->_event_model; |
|
866 | + } |
|
867 | + |
|
868 | + |
|
869 | + |
|
870 | + /** |
|
871 | + * Adds extra buttons to the WP CPT permalink field row. |
|
872 | + * Method is called from parent and is hooked into the wp 'get_sample_permalink_html' filter. |
|
873 | + * |
|
874 | + * @param string $return the current html |
|
875 | + * @param int $id the post id for the page |
|
876 | + * @param string $new_title What the title is |
|
877 | + * @param string $new_slug what the slug is |
|
878 | + * @return string The new html string for the permalink area |
|
879 | + */ |
|
880 | + public function extra_permalink_field_buttons($return, $id, $new_title, $new_slug) |
|
881 | + { |
|
882 | + //make sure this is only when editing |
|
883 | + if ( ! empty($id)) { |
|
884 | + $post = get_post($id); |
|
885 | + $return .= '<a class="button button-small" onclick="prompt(\'Shortcode:\', jQuery(\'#shortcode\').val()); return false;" href="#" tabindex="-1">' |
|
886 | + . esc_html__('Shortcode', 'event_espresso') |
|
887 | + . '</a> '; |
|
888 | + $return .= '<input id="shortcode" type="hidden" value="[ESPRESSO_TICKET_SELECTOR event_id=' |
|
889 | + . $post->ID |
|
890 | + . ']">'; |
|
891 | + } |
|
892 | + return $return; |
|
893 | + } |
|
894 | + |
|
895 | + |
|
896 | + |
|
897 | + /** |
|
898 | + * _events_overview_list_table |
|
899 | + * This contains the logic for showing the events_overview list |
|
900 | + * |
|
901 | + * @access protected |
|
902 | + * @return void |
|
903 | + * @throws \EE_Error |
|
904 | + */ |
|
905 | + protected function _events_overview_list_table() |
|
906 | + { |
|
907 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
908 | + $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
|
909 | + ? (array)$this->_template_args['after_list_table'] |
|
910 | + : array(); |
|
911 | + $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
|
912 | + . EEH_Template::get_button_or_link( |
|
913 | + get_post_type_archive_link('espresso_events'), |
|
914 | + esc_html__("View Event Archive Page", "event_espresso"), |
|
915 | + 'button' |
|
916 | + ); |
|
917 | + $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
|
918 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
919 | + 'create_new', |
|
920 | + 'add', |
|
921 | + array(), |
|
922 | + 'add-new-h2' |
|
923 | + ); |
|
924 | + $this->display_admin_list_table_page_with_no_sidebar(); |
|
925 | + } |
|
926 | + |
|
927 | + |
|
928 | + |
|
929 | + /** |
|
930 | + * this allows for extra misc actions in the default WP publish box |
|
931 | + * |
|
932 | + * @return void |
|
933 | + */ |
|
934 | + public function extra_misc_actions_publish_box() |
|
935 | + { |
|
936 | + $this->_generate_publish_box_extra_content(); |
|
937 | + } |
|
938 | + |
|
939 | + |
|
940 | + |
|
941 | + /** |
|
942 | + * This is hooked into the WordPress do_action('save_post') hook and runs after the custom post type has been |
|
943 | + * saved. Child classes are required to declare this method. Typically you would use this to save any additional |
|
944 | + * data. |
|
945 | + * Keep in mind also that "save_post" runs on EVERY post update to the database. |
|
946 | + * ALSO very important. When a post transitions from scheduled to published, the save_post action is fired but you |
|
947 | + * will NOT have any _POST data containing any extra info you may have from other meta saves. So MAKE sure that |
|
948 | + * you handle this accordingly. |
|
949 | + * |
|
950 | + * @access protected |
|
951 | + * @abstract |
|
952 | + * @param string $post_id The ID of the cpt that was saved (so you can link relationally) |
|
953 | + * @param object $post The post object of the cpt that was saved. |
|
954 | + * @return void |
|
955 | + */ |
|
956 | + protected function _insert_update_cpt_item($post_id, $post) |
|
957 | + { |
|
958 | + if ($post instanceof WP_Post && $post->post_type !== 'espresso_events') { |
|
959 | + //get out we're not processing an event save. |
|
960 | + return; |
|
961 | + } |
|
962 | + $event_values = array( |
|
963 | + 'EVT_display_desc' => ! empty($this->_req_data['display_desc']) ? 1 : 0, |
|
964 | + 'EVT_display_ticket_selector' => ! empty($this->_req_data['display_ticket_selector']) ? 1 : 0, |
|
965 | + 'EVT_additional_limit' => min( |
|
966 | + apply_filters('FHEE__EE_Events_Admin__insert_update_cpt_item__EVT_additional_limit_max', 255), |
|
967 | + ! empty($this->_req_data['additional_limit']) ? $this->_req_data['additional_limit'] : null |
|
968 | + ), |
|
969 | + 'EVT_default_registration_status' => ! empty($this->_req_data['EVT_default_registration_status']) |
|
970 | + ? $this->_req_data['EVT_default_registration_status'] |
|
971 | + : EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
972 | + 'EVT_member_only' => ! empty($this->_req_data['member_only']) ? 1 : 0, |
|
973 | + 'EVT_allow_overflow' => ! empty($this->_req_data['EVT_allow_overflow']) ? 1 : 0, |
|
974 | + 'EVT_timezone_string' => ! empty($this->_req_data['timezone_string']) |
|
975 | + ? $this->_req_data['timezone_string'] : null, |
|
976 | + 'EVT_external_URL' => ! empty($this->_req_data['externalURL']) |
|
977 | + ? $this->_req_data['externalURL'] : null, |
|
978 | + 'EVT_phone' => ! empty($this->_req_data['event_phone']) |
|
979 | + ? $this->_req_data['event_phone'] : null, |
|
980 | + ); |
|
981 | + //update event |
|
982 | + $success = $this->_event_model()->update_by_ID($event_values, $post_id); |
|
983 | + //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! |
|
984 | + $get_one_where = array($this->_event_model()->primary_key_name() => $post_id, 'status' => $post->post_status); |
|
985 | + $event = $this->_event_model()->get_one(array($get_one_where)); |
|
986 | + //the following are default callbacks for event attachment updates that can be overridden by caffeinated functionality and/or addons. |
|
987 | + $event_update_callbacks = apply_filters( |
|
988 | + 'FHEE__Events_Admin_Page___insert_update_cpt_item__event_update_callbacks', |
|
989 | + array(array($this, '_default_venue_update'), array($this, '_default_tickets_update')) |
|
990 | + ); |
|
991 | + $att_success = true; |
|
992 | + foreach ($event_update_callbacks as $e_callback) { |
|
993 | + $_succ = call_user_func_array($e_callback, array($event, $this->_req_data)); |
|
994 | + $att_success = ! $att_success ? $att_success |
|
995 | + : $_succ; //if ANY of these updates fail then we want the appropriate global error message |
|
996 | + } |
|
997 | + //any errors? |
|
998 | + if ($success && false === $att_success) { |
|
999 | + EE_Error::add_error( |
|
1000 | + esc_html__( |
|
1001 | + 'Event Details saved successfully but something went wrong with saving attachments.', |
|
1002 | + 'event_espresso' |
|
1003 | + ), |
|
1004 | + __FILE__, |
|
1005 | + __FUNCTION__, |
|
1006 | + __LINE__ |
|
1007 | + ); |
|
1008 | + } else if ($success === false) { |
|
1009 | + EE_Error::add_error( |
|
1010 | + esc_html__('Event Details did not save successfully.', 'event_espresso'), |
|
1011 | + __FILE__, |
|
1012 | + __FUNCTION__, |
|
1013 | + __LINE__ |
|
1014 | + ); |
|
1015 | + } |
|
1016 | + } |
|
1017 | + |
|
1018 | + |
|
1019 | + |
|
1020 | + /** |
|
1021 | + * @see parent::restore_item() |
|
1022 | + * @param int $post_id |
|
1023 | + * @param int $revision_id |
|
1024 | + */ |
|
1025 | + protected function _restore_cpt_item($post_id, $revision_id) |
|
1026 | + { |
|
1027 | + //copy existing event meta to new post |
|
1028 | + $post_evt = $this->_event_model()->get_one_by_ID($post_id); |
|
1029 | + if ($post_evt instanceof EE_Event) { |
|
1030 | + //meta revision restore |
|
1031 | + $post_evt->restore_revision($revision_id); |
|
1032 | + //related objs restore |
|
1033 | + $post_evt->restore_revision($revision_id, array('Venue', 'Datetime', 'Price')); |
|
1034 | + } |
|
1035 | + } |
|
1036 | + |
|
1037 | + |
|
1038 | + |
|
1039 | + /** |
|
1040 | + * Attach the venue to the Event |
|
1041 | + * |
|
1042 | + * @param \EE_Event $evtobj Event Object to add the venue to |
|
1043 | + * @param array $data The request data from the form |
|
1044 | + * @return bool Success or fail. |
|
1045 | + */ |
|
1046 | + protected function _default_venue_update(\EE_Event $evtobj, $data) |
|
1047 | + { |
|
1048 | + require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1049 | + $venue_model = EE_Registry::instance()->load_model('Venue'); |
|
1050 | + $rows_affected = null; |
|
1051 | + $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
|
1052 | + // very important. If we don't have a venue name... |
|
1053 | + // then we'll get out because not necessary to create empty venue |
|
1054 | + if (empty($data['venue_title'])) { |
|
1055 | + return false; |
|
1056 | + } |
|
1057 | + $venue_array = array( |
|
1058 | + 'VNU_wp_user' => $evtobj->get('EVT_wp_user'), |
|
1059 | + 'VNU_name' => ! empty($data['venue_title']) ? $data['venue_title'] : null, |
|
1060 | + 'VNU_desc' => ! empty($data['venue_description']) ? $data['venue_description'] : null, |
|
1061 | + 'VNU_identifier' => ! empty($data['venue_identifier']) ? $data['venue_identifier'] : null, |
|
1062 | + 'VNU_short_desc' => ! empty($data['venue_short_description']) ? $data['venue_short_description'] |
|
1063 | + : null, |
|
1064 | + 'VNU_address' => ! empty($data['address']) ? $data['address'] : null, |
|
1065 | + 'VNU_address2' => ! empty($data['address2']) ? $data['address2'] : null, |
|
1066 | + 'VNU_city' => ! empty($data['city']) ? $data['city'] : null, |
|
1067 | + 'STA_ID' => ! empty($data['state']) ? $data['state'] : null, |
|
1068 | + 'CNT_ISO' => ! empty($data['countries']) ? $data['countries'] : null, |
|
1069 | + 'VNU_zip' => ! empty($data['zip']) ? $data['zip'] : null, |
|
1070 | + 'VNU_phone' => ! empty($data['venue_phone']) ? $data['venue_phone'] : null, |
|
1071 | + 'VNU_capacity' => ! empty($data['venue_capacity']) ? $data['venue_capacity'] : null, |
|
1072 | + 'VNU_url' => ! empty($data['venue_url']) ? $data['venue_url'] : null, |
|
1073 | + 'VNU_virtual_phone' => ! empty($data['virtual_phone']) ? $data['virtual_phone'] : null, |
|
1074 | + 'VNU_virtual_url' => ! empty($data['virtual_url']) ? $data['virtual_url'] : null, |
|
1075 | + 'VNU_enable_for_gmap' => isset($data['enable_for_gmap']) ? 1 : 0, |
|
1076 | + 'status' => 'publish', |
|
1077 | + ); |
|
1078 | + //if we've got the venue_id then we're just updating the existing venue so let's do that and then get out. |
|
1079 | + if ( ! empty($venue_id)) { |
|
1080 | + $update_where = array($venue_model->primary_key_name() => $venue_id); |
|
1081 | + $rows_affected = $venue_model->update($venue_array, array($update_where)); |
|
1082 | + //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. |
|
1083 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1084 | + return $rows_affected > 0 ? true : false; |
|
1085 | + } else { |
|
1086 | + //we insert the venue |
|
1087 | + $venue_id = $venue_model->insert($venue_array); |
|
1088 | + $evtobj->_add_relation_to($venue_id, 'Venue'); |
|
1089 | + return ! empty($venue_id) ? true : false; |
|
1090 | + } |
|
1091 | + //when we have the ancestor come in it's already been handled by the revision save. |
|
1092 | + } |
|
1093 | + |
|
1094 | + |
|
1095 | + |
|
1096 | + /** |
|
1097 | + * Handles saving everything related to Tickets (datetimes, tickets, prices) |
|
1098 | + * |
|
1099 | + * @param EE_Event $evtobj The Event object we're attaching data to |
|
1100 | + * @param array $data The request data from the form |
|
1101 | + * @return array |
|
1102 | + */ |
|
1103 | + protected function _default_tickets_update(EE_Event $evtobj, $data) |
|
1104 | + { |
|
1105 | + $success = true; |
|
1106 | + $saved_dtt = null; |
|
1107 | + $saved_tickets = array(); |
|
1108 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1109 | + foreach ($data['edit_event_datetimes'] as $row => $dtt) { |
|
1110 | + //trim all values to ensure any excess whitespace is removed. |
|
1111 | + $dtt = array_map('trim', $dtt); |
|
1112 | + $dtt['DTT_EVT_end'] = isset($dtt['DTT_EVT_end']) && ! empty($dtt['DTT_EVT_end']) ? $dtt['DTT_EVT_end'] |
|
1113 | + : $dtt['DTT_EVT_start']; |
|
1114 | + $datetime_values = array( |
|
1115 | + 'DTT_ID' => ! empty($dtt['DTT_ID']) ? $dtt['DTT_ID'] : null, |
|
1116 | + 'DTT_EVT_start' => $dtt['DTT_EVT_start'], |
|
1117 | + 'DTT_EVT_end' => $dtt['DTT_EVT_end'], |
|
1118 | + 'DTT_reg_limit' => empty($dtt['DTT_reg_limit']) ? EE_INF : $dtt['DTT_reg_limit'], |
|
1119 | + 'DTT_order' => $row, |
|
1120 | + ); |
|
1121 | + //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. |
|
1122 | + if ( ! empty($dtt['DTT_ID'])) { |
|
1123 | + $DTM = EE_Registry::instance() |
|
1124 | + ->load_model('Datetime', array($evtobj->get_timezone())) |
|
1125 | + ->get_one_by_ID($dtt['DTT_ID']); |
|
1126 | + $DTM->set_date_format($incoming_date_formats[0]); |
|
1127 | + $DTM->set_time_format($incoming_date_formats[1]); |
|
1128 | + foreach ($datetime_values as $field => $value) { |
|
1129 | + $DTM->set($field, $value); |
|
1130 | + } |
|
1131 | + //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. |
|
1132 | + $saved_dtts[$DTM->ID()] = $DTM; |
|
1133 | + } else { |
|
1134 | + $DTM = EE_Registry::instance()->load_class( |
|
1135 | + 'Datetime', |
|
1136 | + array($datetime_values, $evtobj->get_timezone(), $incoming_date_formats), |
|
1137 | + false, |
|
1138 | + false |
|
1139 | + ); |
|
1140 | + foreach ($datetime_values as $field => $value) { |
|
1141 | + $DTM->set($field, $value); |
|
1142 | + } |
|
1143 | + } |
|
1144 | + $DTM->save(); |
|
1145 | + $DTT = $evtobj->_add_relation_to($DTM, 'Datetime'); |
|
1146 | + //load DTT helper |
|
1147 | + //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. |
|
1148 | + if ($DTT->get_raw('DTT_EVT_start') > $DTT->get_raw('DTT_EVT_end')) { |
|
1149 | + $DTT->set('DTT_EVT_end', $DTT->get('DTT_EVT_start')); |
|
1150 | + $DTT = EEH_DTT_Helper::date_time_add($DTT, 'DTT_EVT_end', 'days'); |
|
1151 | + $DTT->save(); |
|
1152 | + } |
|
1153 | + //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. |
|
1154 | + $saved_dtt = $DTT; |
|
1155 | + $success = ! $success ? $success : $DTT; |
|
1156 | + //if ANY of these updates fail then we want the appropriate global error message. |
|
1157 | + // //todo this is actually sucky we need a better error message but this is what it is for now. |
|
1158 | + } |
|
1159 | + //no dtts get deleted so we don't do any of that logic here. |
|
1160 | + //update tickets next |
|
1161 | + $old_tickets = isset($data['ticket_IDs']) ? explode(',', $data['ticket_IDs']) : array(); |
|
1162 | + foreach ($data['edit_tickets'] as $row => $tkt) { |
|
1163 | + $incoming_date_formats = array('Y-m-d', 'h:i a'); |
|
1164 | + $update_prices = false; |
|
1165 | + $ticket_price = isset($data['edit_prices'][$row][1]['PRC_amount']) |
|
1166 | + ? $data['edit_prices'][$row][1]['PRC_amount'] : 0; |
|
1167 | + // trim inputs to ensure any excess whitespace is removed. |
|
1168 | + $tkt = array_map('trim', $tkt); |
|
1169 | + if (empty($tkt['TKT_start_date'])) { |
|
1170 | + //let's use now in the set timezone. |
|
1171 | + $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
|
1172 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1173 | + } |
|
1174 | + if (empty($tkt['TKT_end_date'])) { |
|
1175 | + //use the start date of the first datetime |
|
1176 | + $dtt = $evtobj->first_datetime(); |
|
1177 | + $tkt['TKT_end_date'] = $dtt->start_date_and_time( |
|
1178 | + $incoming_date_formats[0], |
|
1179 | + $incoming_date_formats[1] |
|
1180 | + ); |
|
1181 | + } |
|
1182 | + $TKT_values = array( |
|
1183 | + 'TKT_ID' => ! empty($tkt['TKT_ID']) ? $tkt['TKT_ID'] : null, |
|
1184 | + 'TTM_ID' => ! empty($tkt['TTM_ID']) ? $tkt['TTM_ID'] : 0, |
|
1185 | + 'TKT_name' => ! empty($tkt['TKT_name']) ? $tkt['TKT_name'] : '', |
|
1186 | + 'TKT_description' => ! empty($tkt['TKT_description']) ? $tkt['TKT_description'] : '', |
|
1187 | + 'TKT_start_date' => $tkt['TKT_start_date'], |
|
1188 | + 'TKT_end_date' => $tkt['TKT_end_date'], |
|
1189 | + 'TKT_qty' => ! isset($tkt['TKT_qty']) || $tkt['TKT_qty'] === '' ? EE_INF : $tkt['TKT_qty'], |
|
1190 | + 'TKT_uses' => ! isset($tkt['TKT_uses']) || $tkt['TKT_uses'] === '' ? EE_INF : $tkt['TKT_uses'], |
|
1191 | + 'TKT_min' => empty($tkt['TKT_min']) ? 0 : $tkt['TKT_min'], |
|
1192 | + 'TKT_max' => empty($tkt['TKT_max']) ? EE_INF : $tkt['TKT_max'], |
|
1193 | + 'TKT_row' => $row, |
|
1194 | + 'TKT_order' => isset($tkt['TKT_order']) ? $tkt['TKT_order'] : $row, |
|
1195 | + 'TKT_price' => $ticket_price, |
|
1196 | + ); |
|
1197 | + //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. |
|
1198 | + if (isset($tkt['TKT_is_default']) && $tkt['TKT_is_default']) { |
|
1199 | + $TKT_values['TKT_ID'] = 0; |
|
1200 | + $TKT_values['TKT_is_default'] = 0; |
|
1201 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1202 | + $update_prices = true; |
|
1203 | + } |
|
1204 | + //if we have a TKT_ID then we need to get that existing TKT_obj and update it |
|
1205 | + //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. |
|
1206 | + //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. |
|
1207 | + if ( ! empty($tkt['TKT_ID'])) { |
|
1208 | + $TKT = EE_Registry::instance() |
|
1209 | + ->load_model('Ticket', array($evtobj->get_timezone())) |
|
1210 | + ->get_one_by_ID($tkt['TKT_ID']); |
|
1211 | + if ($TKT instanceof EE_Ticket) { |
|
1212 | + $ticket_sold = $TKT->count_related( |
|
1213 | + 'Registration', |
|
1214 | + array( |
|
1215 | + array( |
|
1216 | + 'STS_ID' => array( |
|
1217 | + 'NOT IN', |
|
1218 | + array(EEM_Registration::status_id_incomplete), |
|
1219 | + ), |
|
1220 | + ), |
|
1221 | + ) |
|
1222 | + ) > 0 ? true : false; |
|
1223 | + //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. |
|
1224 | + $create_new_TKT = $ticket_sold && $ticket_price != $TKT->get('TKT_price') |
|
1225 | + && ! $TKT->get( |
|
1226 | + 'TKT_deleted' |
|
1227 | + ) ? true : false; |
|
1228 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1229 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1230 | + //set new values |
|
1231 | + foreach ($TKT_values as $field => $value) { |
|
1232 | + if ($field == 'TKT_qty') { |
|
1233 | + $TKT->set_qty($value); |
|
1234 | + } else { |
|
1235 | + $TKT->set($field, $value); |
|
1236 | + } |
|
1237 | + } |
|
1238 | + //if $create_new_TKT is false then we can safely update the existing ticket. Otherwise we have to create a new ticket. |
|
1239 | + if ($create_new_TKT) { |
|
1240 | + //archive the old ticket first |
|
1241 | + $TKT->set('TKT_deleted', 1); |
|
1242 | + $TKT->save(); |
|
1243 | + //make sure this ticket is still recorded in our saved_tkts so we don't run it through the regular trash routine. |
|
1244 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1245 | + //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. |
|
1246 | + $TKT = clone $TKT; |
|
1247 | + $TKT->set('TKT_ID', 0); |
|
1248 | + $TKT->set('TKT_deleted', 0); |
|
1249 | + $TKT->set('TKT_price', $ticket_price); |
|
1250 | + $TKT->set('TKT_sold', 0); |
|
1251 | + //now we need to make sure that $new prices are created as well and attached to new ticket. |
|
1252 | + $update_prices = true; |
|
1253 | + } |
|
1254 | + //make sure price is set if it hasn't been already |
|
1255 | + $TKT->set('TKT_price', $ticket_price); |
|
1256 | + } |
|
1257 | + } else { |
|
1258 | + //no TKT_id so a new TKT |
|
1259 | + $TKT_values['TKT_price'] = $ticket_price; |
|
1260 | + $TKT = EE_Registry::instance()->load_class('Ticket', array($TKT_values), false, false); |
|
1261 | + if ($TKT instanceof EE_Ticket) { |
|
1262 | + //need to reset values to properly account for the date formats |
|
1263 | + $TKT->set_date_format($incoming_date_formats[0]); |
|
1264 | + $TKT->set_time_format($incoming_date_formats[1]); |
|
1265 | + $TKT->set_timezone($evtobj->get_timezone()); |
|
1266 | + //set new values |
|
1267 | + foreach ($TKT_values as $field => $value) { |
|
1268 | + if ($field == 'TKT_qty') { |
|
1269 | + $TKT->set_qty($value); |
|
1270 | + } else { |
|
1271 | + $TKT->set($field, $value); |
|
1272 | + } |
|
1273 | + } |
|
1274 | + $update_prices = true; |
|
1275 | + } |
|
1276 | + } |
|
1277 | + // cap ticket qty by datetime reg limits |
|
1278 | + $TKT->set_qty(min($TKT->qty(), $TKT->qty('reg_limit'))); |
|
1279 | + //update ticket. |
|
1280 | + $TKT->save(); |
|
1281 | + //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. |
|
1282 | + if ($TKT->get_raw('TKT_start_date') > $TKT->get_raw('TKT_end_date')) { |
|
1283 | + $TKT->set('TKT_end_date', $TKT->get('TKT_start_date')); |
|
1284 | + $TKT = EEH_DTT_Helper::date_time_add($TKT, 'TKT_end_date', 'days'); |
|
1285 | + $TKT->save(); |
|
1286 | + } |
|
1287 | + //initially let's add the ticket to the dtt |
|
1288 | + $saved_dtt->_add_relation_to($TKT, 'Ticket'); |
|
1289 | + $saved_tickets[$TKT->ID()] = $TKT; |
|
1290 | + //add prices to ticket |
|
1291 | + $this->_add_prices_to_ticket($data['edit_prices'][$row], $TKT, $update_prices); |
|
1292 | + } |
|
1293 | + //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. |
|
1294 | + $old_tickets = isset($old_tickets[0]) && $old_tickets[0] == '' ? array() : $old_tickets; |
|
1295 | + $tickets_removed = array_diff($old_tickets, array_keys($saved_tickets)); |
|
1296 | + foreach ($tickets_removed as $id) { |
|
1297 | + $id = absint($id); |
|
1298 | + //get the ticket for this id |
|
1299 | + $tkt_to_remove = EE_Registry::instance()->load_model('Ticket')->get_one_by_ID($id); |
|
1300 | + //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) |
|
1301 | + $dtts = $tkt_to_remove->get_many_related('Datetime'); |
|
1302 | + foreach ($dtts as $dtt) { |
|
1303 | + $tkt_to_remove->_remove_relation_to($dtt, 'Datetime'); |
|
1304 | + } |
|
1305 | + //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)) |
|
1306 | + $tkt_to_remove->delete_related_permanently('Price'); |
|
1307 | + //finally let's delete this ticket (which should not be blocked at this point b/c we've removed all our relationships) |
|
1308 | + $tkt_to_remove->delete_permanently(); |
|
1309 | + } |
|
1310 | + return array($saved_dtt, $saved_tickets); |
|
1311 | + } |
|
1312 | + |
|
1313 | + |
|
1314 | + |
|
1315 | + /** |
|
1316 | + * This attaches a list of given prices to a ticket. |
|
1317 | + * Note we dont' have to worry about ever removing relationships (or archiving prices) because if there is a change |
|
1318 | + * in price information on a ticket, a new ticket is created anyways so the archived ticket will retain the old |
|
1319 | + * price info and prices are automatically "archived" via the ticket. |
|
1320 | + * |
|
1321 | + * @access private |
|
1322 | + * @param array $prices Array of prices from the form. |
|
1323 | + * @param EE_Ticket $ticket EE_Ticket object that prices are being attached to. |
|
1324 | + * @param bool $new_prices Whether attach existing incoming prices or create new ones. |
|
1325 | + * @return void |
|
1326 | + */ |
|
1327 | + private function _add_prices_to_ticket($prices, EE_Ticket $ticket, $new_prices = false) |
|
1328 | + { |
|
1329 | + foreach ($prices as $row => $prc) { |
|
1330 | + $PRC_values = array( |
|
1331 | + 'PRC_ID' => ! empty($prc['PRC_ID']) ? $prc['PRC_ID'] : null, |
|
1332 | + 'PRT_ID' => ! empty($prc['PRT_ID']) ? $prc['PRT_ID'] : null, |
|
1333 | + 'PRC_amount' => ! empty($prc['PRC_amount']) ? $prc['PRC_amount'] : 0, |
|
1334 | + 'PRC_name' => ! empty($prc['PRC_name']) ? $prc['PRC_name'] : '', |
|
1335 | + 'PRC_desc' => ! empty($prc['PRC_desc']) ? $prc['PRC_desc'] : '', |
|
1336 | + 'PRC_is_default' => 0, //make sure prices are NOT set as default from this context |
|
1337 | + 'PRC_order' => $row, |
|
1338 | + ); |
|
1339 | + if ($new_prices || empty($PRC_values['PRC_ID'])) { |
|
1340 | + $PRC_values['PRC_ID'] = 0; |
|
1341 | + $PRC = EE_Registry::instance()->load_class('Price', array($PRC_values), false, false); |
|
1342 | + } else { |
|
1343 | + $PRC = EE_Registry::instance()->load_model('Price')->get_one_by_ID($prc['PRC_ID']); |
|
1344 | + //update this price with new values |
|
1345 | + foreach ($PRC_values as $field => $newprc) { |
|
1346 | + $PRC->set($field, $newprc); |
|
1347 | + } |
|
1348 | + $PRC->save(); |
|
1349 | + } |
|
1350 | + $ticket->_add_relation_to($PRC, 'Price'); |
|
1351 | + } |
|
1352 | + } |
|
1353 | + |
|
1354 | + |
|
1355 | + |
|
1356 | + /** |
|
1357 | + * Add in our autosave ajax handlers |
|
1358 | + * |
|
1359 | + * @return void |
|
1360 | + */ |
|
1361 | + protected function _ee_autosave_create_new() |
|
1362 | + { |
|
1363 | + // $this->_ee_autosave_edit(); |
|
1364 | + } |
|
1365 | + |
|
1366 | + |
|
1367 | + |
|
1368 | + protected function _ee_autosave_edit() |
|
1369 | + { |
|
1370 | + return; //TEMPORARILY EXITING CAUSE THIS IS A TODO |
|
1371 | + } |
|
1372 | + |
|
1373 | + |
|
1374 | + |
|
1375 | + /** |
|
1376 | + * _generate_publish_box_extra_content |
|
1377 | + * |
|
1378 | + * @access private |
|
1379 | + * @return void |
|
1380 | + */ |
|
1381 | + private function _generate_publish_box_extra_content() |
|
1382 | + { |
|
1383 | + //load formatter helper |
|
1384 | + //args for getting related registrations |
|
1385 | + $approved_query_args = array( |
|
1386 | + array( |
|
1387 | + 'REG_deleted' => 0, |
|
1388 | + 'STS_ID' => EEM_Registration::status_id_approved, |
|
1389 | + ), |
|
1390 | + ); |
|
1391 | + $not_approved_query_args = array( |
|
1392 | + array( |
|
1393 | + 'REG_deleted' => 0, |
|
1394 | + 'STS_ID' => EEM_Registration::status_id_not_approved, |
|
1395 | + ), |
|
1396 | + ); |
|
1397 | + $pending_payment_query_args = array( |
|
1398 | + array( |
|
1399 | + 'REG_deleted' => 0, |
|
1400 | + 'STS_ID' => EEM_Registration::status_id_pending_payment, |
|
1401 | + ), |
|
1402 | + ); |
|
1403 | + // publish box |
|
1404 | + $publish_box_extra_args = array( |
|
1405 | + 'view_approved_reg_url' => add_query_arg( |
|
1406 | + array( |
|
1407 | + 'action' => 'default', |
|
1408 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1409 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
1410 | + ), |
|
1411 | + REG_ADMIN_URL |
|
1412 | + ), |
|
1413 | + 'view_not_approved_reg_url' => add_query_arg( |
|
1414 | + array( |
|
1415 | + 'action' => 'default', |
|
1416 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1417 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
1418 | + ), |
|
1419 | + REG_ADMIN_URL |
|
1420 | + ), |
|
1421 | + 'view_pending_payment_reg_url' => add_query_arg( |
|
1422 | + array( |
|
1423 | + 'action' => 'default', |
|
1424 | + 'event_id' => $this->_cpt_model_obj->ID(), |
|
1425 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
1426 | + ), |
|
1427 | + REG_ADMIN_URL |
|
1428 | + ), |
|
1429 | + 'approved_regs' => $this->_cpt_model_obj->count_related( |
|
1430 | + 'Registration', |
|
1431 | + $approved_query_args |
|
1432 | + ), |
|
1433 | + 'not_approved_regs' => $this->_cpt_model_obj->count_related( |
|
1434 | + 'Registration', |
|
1435 | + $not_approved_query_args |
|
1436 | + ), |
|
1437 | + 'pending_payment_regs' => $this->_cpt_model_obj->count_related( |
|
1438 | + 'Registration', |
|
1439 | + $pending_payment_query_args |
|
1440 | + ), |
|
1441 | + 'misc_pub_section_class' => apply_filters( |
|
1442 | + 'FHEE_Events_Admin_Page___generate_publish_box_extra_content__misc_pub_section_class', |
|
1443 | + 'misc-pub-section' |
|
1444 | + ), |
|
1445 | + //'email_attendees_url' => add_query_arg( |
|
1446 | + // array( |
|
1447 | + // 'event_admin_reports' => 'event_newsletter', |
|
1448 | + // 'event_id' => $this->_cpt_model_obj->id |
|
1449 | + // ), |
|
1450 | + // 'admin.php?page=espresso_registrations' |
|
1451 | + //), |
|
1452 | + ); |
|
1453 | + ob_start(); |
|
1454 | + do_action( |
|
1455 | + 'AHEE__Events_Admin_Page___generate_publish_box_extra_content__event_editor_overview_add', |
|
1456 | + $this->_cpt_model_obj |
|
1457 | + ); |
|
1458 | + $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
|
1459 | + // load template |
|
1460 | + EEH_Template::display_template( |
|
1461 | + EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1462 | + $publish_box_extra_args |
|
1463 | + ); |
|
1464 | + } |
|
1465 | + |
|
1466 | + |
|
1467 | + |
|
1468 | + /** |
|
1469 | + * This just returns whatever is set as the _event object property |
|
1470 | + * //todo this will become obsolete once the models are in place |
|
1471 | + * |
|
1472 | + * @return object |
|
1473 | + */ |
|
1474 | + public function get_event_object() |
|
1475 | + { |
|
1476 | + return $this->_cpt_model_obj; |
|
1477 | + } |
|
1478 | + |
|
1479 | + |
|
1480 | + |
|
1481 | + |
|
1482 | + /** METABOXES * */ |
|
1483 | + /** |
|
1484 | + * _register_event_editor_meta_boxes |
|
1485 | + * add all metaboxes related to the event_editor |
|
1486 | + * |
|
1487 | + * @return void |
|
1488 | + */ |
|
1489 | + protected function _register_event_editor_meta_boxes() |
|
1490 | + { |
|
1491 | + $this->verify_cpt_object(); |
|
1492 | + add_meta_box( |
|
1493 | + 'espresso_event_editor_tickets', |
|
1494 | + esc_html__('Event Datetime & Ticket', 'event_espresso'), |
|
1495 | + array($this, 'ticket_metabox'), |
|
1496 | + $this->page_slug, |
|
1497 | + 'normal', |
|
1498 | + 'high' |
|
1499 | + ); |
|
1500 | + add_meta_box( |
|
1501 | + 'espresso_event_editor_event_options', |
|
1502 | + esc_html__('Event Registration Options', 'event_espresso'), |
|
1503 | + array($this, 'registration_options_meta_box'), |
|
1504 | + $this->page_slug, |
|
1505 | + 'side', |
|
1506 | + 'default' |
|
1507 | + ); |
|
1508 | + // NOTE: if you're looking for other metaboxes in here, |
|
1509 | + // where a metabox has a related management page in the admin |
|
1510 | + // you will find it setup in the related management page's "_Hooks" file. |
|
1511 | + // i.e. messages metabox is found in "espresso_events_Messages_Hooks.class.php". |
|
1512 | + } |
|
1513 | + |
|
1514 | + |
|
1515 | + |
|
1516 | + public function ticket_metabox() |
|
1517 | + { |
|
1518 | + $existing_datetime_ids = $existing_ticket_ids = array(); |
|
1519 | + //defaults for template args |
|
1520 | + $template_args = array( |
|
1521 | + 'existing_datetime_ids' => '', |
|
1522 | + 'event_datetime_help_link' => '', |
|
1523 | + 'ticket_options_help_link' => '', |
|
1524 | + 'time' => null, |
|
1525 | + 'ticket_rows' => '', |
|
1526 | + 'existing_ticket_ids' => '', |
|
1527 | + 'total_ticket_rows' => 1, |
|
1528 | + 'ticket_js_structure' => '', |
|
1529 | + 'trash_icon' => 'ee-lock-icon', |
|
1530 | + 'disabled' => '', |
|
1531 | + ); |
|
1532 | + $event_id = is_object($this->_cpt_model_obj) ? $this->_cpt_model_obj->ID() : null; |
|
1533 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
1534 | + /** |
|
1535 | + * 1. Start with retrieving Datetimes |
|
1536 | + * 2. Fore each datetime get related tickets |
|
1537 | + * 3. For each ticket get related prices |
|
1538 | + */ |
|
1539 | + $times = EE_Registry::instance()->load_model('Datetime')->get_all_event_dates($event_id); |
|
1540 | + /** @type EE_Datetime $first_datetime */ |
|
1541 | + $first_datetime = reset($times); |
|
1542 | + //do we get related tickets? |
|
1543 | + if ($first_datetime instanceof EE_Datetime |
|
1544 | + && $first_datetime->ID() !== 0 |
|
1545 | + ) { |
|
1546 | + $existing_datetime_ids[] = $first_datetime->get('DTT_ID'); |
|
1547 | + $template_args['time'] = $first_datetime; |
|
1548 | + $related_tickets = $first_datetime->tickets( |
|
1549 | + array( |
|
1550 | + array('OR' => array('TKT_deleted' => 1, 'TKT_deleted*' => 0)), |
|
1551 | + 'default_where_conditions' => 'none', |
|
1552 | + ) |
|
1553 | + ); |
|
1554 | + if ( ! empty($related_tickets)) { |
|
1555 | + $template_args['total_ticket_rows'] = count($related_tickets); |
|
1556 | + $row = 0; |
|
1557 | + foreach ($related_tickets as $ticket) { |
|
1558 | + $existing_ticket_ids[] = $ticket->get('TKT_ID'); |
|
1559 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket, false, $row); |
|
1560 | + $row++; |
|
1561 | + } |
|
1562 | + } else { |
|
1563 | + $template_args['total_ticket_rows'] = 1; |
|
1564 | + /** @type EE_Ticket $ticket */ |
|
1565 | + $ticket = EE_Registry::instance()->load_model('Ticket')->create_default_object(); |
|
1566 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket); |
|
1567 | + } |
|
1568 | + } else { |
|
1569 | + $template_args['time'] = $times[0]; |
|
1570 | + /** @type EE_Ticket $ticket */ |
|
1571 | + $ticket = EE_Registry::instance()->load_model('Ticket')->get_all_default_tickets(); |
|
1572 | + $template_args['ticket_rows'] .= $this->_get_ticket_row($ticket[1]); |
|
1573 | + // NOTE: we're just sending the first default row |
|
1574 | + // (decaf can't manage default tickets so this should be sufficient); |
|
1575 | + } |
|
1576 | + $template_args['event_datetime_help_link'] = $this->_get_help_tab_link( |
|
1577 | + 'event_editor_event_datetimes_help_tab' |
|
1578 | + ); |
|
1579 | + $template_args['ticket_options_help_link'] = $this->_get_help_tab_link('ticket_options_info'); |
|
1580 | + $template_args['existing_datetime_ids'] = implode(',', $existing_datetime_ids); |
|
1581 | + $template_args['existing_ticket_ids'] = implode(',', $existing_ticket_ids); |
|
1582 | + $template_args['ticket_js_structure'] = $this->_get_ticket_row( |
|
1583 | + EE_Registry::instance()->load_model('Ticket')->create_default_object(), |
|
1584 | + true |
|
1585 | + ); |
|
1586 | + $template = apply_filters( |
|
1587 | + 'FHEE__Events_Admin_Page__ticket_metabox__template', |
|
1588 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1589 | + ); |
|
1590 | + EEH_Template::display_template($template, $template_args); |
|
1591 | + } |
|
1592 | + |
|
1593 | + |
|
1594 | + |
|
1595 | + /** |
|
1596 | + * Setup an individual ticket form for the decaf event editor page |
|
1597 | + * |
|
1598 | + * @access private |
|
1599 | + * @param EE_Ticket $ticket the ticket object |
|
1600 | + * @param boolean $skeleton whether we're generating a skeleton for js manipulation |
|
1601 | + * @param int $row |
|
1602 | + * @return string generated html for the ticket row. |
|
1603 | + */ |
|
1604 | + private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
|
1605 | + { |
|
1606 | + $template_args = array( |
|
1607 | + 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1608 | + 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
|
1609 | + : '', |
|
1610 | + 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
|
1611 | + 'TKT_ID' => $ticket->get('TKT_ID'), |
|
1612 | + 'TKT_name' => $ticket->get('TKT_name'), |
|
1613 | + 'TKT_start_date' => $skeleton ? '' : $ticket->get_date('TKT_start_date', 'Y-m-d h:i a'), |
|
1614 | + 'TKT_end_date' => $skeleton ? '' : $ticket->get_date('TKT_end_date', 'Y-m-d h:i a'), |
|
1615 | + 'TKT_is_default' => $ticket->get('TKT_is_default'), |
|
1616 | + 'TKT_qty' => $ticket->get_pretty('TKT_qty', 'input'), |
|
1617 | + 'edit_ticketrow_name' => $skeleton ? 'TICKETNAMEATTR' : 'edit_tickets', |
|
1618 | + 'TKT_sold' => $skeleton ? 0 : $ticket->get('TKT_sold'), |
|
1619 | + 'trash_icon' => ($skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted'))) |
|
1620 | + && ( ! empty($ticket) && $ticket->get('TKT_sold') === 0) |
|
1621 | + ? 'trash-icon dashicons dashicons-post-trash clickable' : 'ee-lock-icon', |
|
1622 | + 'disabled' => $skeleton || ( ! empty($ticket) && ! $ticket->get('TKT_deleted')) ? '' |
|
1623 | + : ' disabled=disabled', |
|
1624 | + ); |
|
1625 | + $price = $ticket->ID() !== 0 |
|
1626 | + ? $ticket->get_first_related('Price', array('default_where_conditions' => 'none')) |
|
1627 | + : EE_Registry::instance()->load_model('Price')->create_default_object(); |
|
1628 | + $price_args = array( |
|
1629 | + 'price_currency_symbol' => EE_Registry::instance()->CFG->currency->sign, |
|
1630 | + 'PRC_amount' => $price->get('PRC_amount'), |
|
1631 | + 'PRT_ID' => $price->get('PRT_ID'), |
|
1632 | + 'PRC_ID' => $price->get('PRC_ID'), |
|
1633 | + 'PRC_is_default' => $price->get('PRC_is_default'), |
|
1634 | + ); |
|
1635 | + //make sure we have default start and end dates if skeleton |
|
1636 | + //handle rows that should NOT be empty |
|
1637 | + if (empty($template_args['TKT_start_date'])) { |
|
1638 | + //if empty then the start date will be now. |
|
1639 | + $template_args['TKT_start_date'] = date('Y-m-d h:i a', current_time('timestamp')); |
|
1640 | + } |
|
1641 | + if (empty($template_args['TKT_end_date'])) { |
|
1642 | + //get the earliest datetime (if present); |
|
1643 | + $earliest_dtt = $this->_cpt_model_obj->ID() > 0 |
|
1644 | + ? $this->_cpt_model_obj->get_first_related( |
|
1645 | + 'Datetime', |
|
1646 | + array('order_by' => array('DTT_EVT_start' => 'ASC')) |
|
1647 | + ) |
|
1648 | + : null; |
|
1649 | + if ( ! empty($earliest_dtt)) { |
|
1650 | + $template_args['TKT_end_date'] = $earliest_dtt->get_datetime('DTT_EVT_start', 'Y-m-d', 'h:i a'); |
|
1651 | + } else { |
|
1652 | + $template_args['TKT_end_date'] = date( |
|
1653 | + 'Y-m-d h:i a', |
|
1654 | + mktime(0, 0, 0, date("m"), date("d") + 7, date("Y")) |
|
1655 | + ); |
|
1656 | + } |
|
1657 | + } |
|
1658 | + $template_args = array_merge($template_args, $price_args); |
|
1659 | + $template = apply_filters( |
|
1660 | + 'FHEE__Events_Admin_Page__get_ticket_row__template', |
|
1661 | + EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1662 | + $ticket |
|
1663 | + ); |
|
1664 | + return EEH_Template::display_template($template, $template_args, true); |
|
1665 | + } |
|
1666 | + |
|
1667 | + |
|
1668 | + |
|
1669 | + public function registration_options_meta_box() |
|
1670 | + { |
|
1671 | + $yes_no_values = array( |
|
1672 | + array('id' => true, 'text' => esc_html__('Yes', 'event_espresso')), |
|
1673 | + array('id' => false, 'text' => esc_html__('No', 'event_espresso')), |
|
1674 | + ); |
|
1675 | + $default_reg_status_values = EEM_Registration::reg_status_array( |
|
1676 | + array( |
|
1677 | + EEM_Registration::status_id_cancelled, |
|
1678 | + EEM_Registration::status_id_declined, |
|
1679 | + EEM_Registration::status_id_incomplete, |
|
1680 | + ), |
|
1681 | + true |
|
1682 | + ); |
|
1683 | + //$template_args['is_active_select'] = EEH_Form_Fields::select_input('is_active', $yes_no_values, $this->_cpt_model_obj->is_active()); |
|
1684 | + $template_args['_event'] = $this->_cpt_model_obj; |
|
1685 | + $template_args['active_status'] = $this->_cpt_model_obj->pretty_active_status(false); |
|
1686 | + $template_args['additional_limit'] = $this->_cpt_model_obj->additional_limit(); |
|
1687 | + $template_args['default_registration_status'] = EEH_Form_Fields::select_input( |
|
1688 | + 'default_reg_status', |
|
1689 | + $default_reg_status_values, |
|
1690 | + $this->_cpt_model_obj->default_registration_status() |
|
1691 | + ); |
|
1692 | + $template_args['display_description'] = EEH_Form_Fields::select_input( |
|
1693 | + 'display_desc', |
|
1694 | + $yes_no_values, |
|
1695 | + $this->_cpt_model_obj->display_description() |
|
1696 | + ); |
|
1697 | + $template_args['display_ticket_selector'] = EEH_Form_Fields::select_input( |
|
1698 | + 'display_ticket_selector', |
|
1699 | + $yes_no_values, |
|
1700 | + $this->_cpt_model_obj->display_ticket_selector(), |
|
1701 | + '', |
|
1702 | + '', |
|
1703 | + false |
|
1704 | + ); |
|
1705 | + $template_args['additional_registration_options'] = apply_filters( |
|
1706 | + 'FHEE__Events_Admin_Page__registration_options_meta_box__additional_registration_options', |
|
1707 | + '', |
|
1708 | + $template_args, |
|
1709 | + $yes_no_values, |
|
1710 | + $default_reg_status_values |
|
1711 | + ); |
|
1712 | + EEH_Template::display_template( |
|
1713 | + EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1714 | + $template_args |
|
1715 | + ); |
|
1716 | + } |
|
1717 | + |
|
1718 | + |
|
1719 | + |
|
1720 | + /** |
|
1721 | + * _get_events() |
|
1722 | + * This method simply returns all the events (for the given _view and paging) |
|
1723 | + * |
|
1724 | + * @access public |
|
1725 | + * @param int $per_page count of items per page (20 default); |
|
1726 | + * @param int $current_page what is the current page being viewed. |
|
1727 | + * @param bool $count if TRUE then we just return a count of ALL events matching the given _view. |
|
1728 | + * If FALSE then we return an array of event objects |
|
1729 | + * that match the given _view and paging parameters. |
|
1730 | + * @return array an array of event objects. |
|
1731 | + */ |
|
1732 | + public function get_events($per_page = 10, $current_page = 1, $count = false) |
|
1733 | + { |
|
1734 | + $EEME = $this->_event_model(); |
|
1735 | + $offset = ($current_page - 1) * $per_page; |
|
1736 | + $limit = $count ? null : $offset . ',' . $per_page; |
|
1737 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
|
1738 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
|
1739 | + if (isset($this->_req_data['month_range'])) { |
|
1740 | + $pieces = explode(' ', $this->_req_data['month_range'], 3); |
|
1741 | + $month_r = ! empty($pieces[0]) ? date('m', strtotime($pieces[0])) : ''; |
|
1742 | + $year_r = ! empty($pieces[1]) ? $pieces[1] : ''; |
|
1743 | + } |
|
1744 | + $where = array(); |
|
1745 | + $status = isset($this->_req_data['status']) ? $this->_req_data['status'] : null; |
|
1746 | + //determine what post_status our condition will have for the query. |
|
1747 | + switch ($status) { |
|
1748 | + case 'month' : |
|
1749 | + case 'today' : |
|
1750 | + case null : |
|
1751 | + case 'all' : |
|
1752 | + break; |
|
1753 | + case 'draft' : |
|
1754 | + $where['status'] = array('IN', array('draft', 'auto-draft')); |
|
1755 | + break; |
|
1756 | + default : |
|
1757 | + $where['status'] = $status; |
|
1758 | + } |
|
1759 | + //categories? |
|
1760 | + $category = isset($this->_req_data['EVT_CAT']) && $this->_req_data['EVT_CAT'] > 0 |
|
1761 | + ? $this->_req_data['EVT_CAT'] : null; |
|
1762 | + if ( ! empty ($category)) { |
|
1763 | + $where['Term_Taxonomy.taxonomy'] = 'espresso_event_categories'; |
|
1764 | + $where['Term_Taxonomy.term_id'] = $category; |
|
1765 | + } |
|
1766 | + //date where conditions |
|
1767 | + $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
|
1768 | + if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
|
1769 | + $DateTime = new DateTime( |
|
1770 | + $year_r . '-' . $month_r . '-01 00:00:00', |
|
1771 | + new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
|
1772 | + ); |
|
1773 | + $start = $DateTime->format(implode(' ', $start_formats)); |
|
1774 | + $end = $DateTime->setDate($year_r, $month_r, $DateTime |
|
1775 | + ->format('t'))->setTime(23, 59, 59) |
|
1776 | + ->format(implode(' ', $start_formats)); |
|
1777 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1778 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'today') { |
|
1779 | + $DateTime = new DateTime('now', new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1780 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1781 | + $end = $DateTime->setTime(23, 59, 59)->format(implode(' ', $start_formats)); |
|
1782 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1783 | + } else if (isset($this->_req_data['status']) && $this->_req_data['status'] == 'month') { |
|
1784 | + $now = date('Y-m-01'); |
|
1785 | + $DateTime = new DateTime($now, new DateTimeZone(EEM_Event::instance()->get_timezone())); |
|
1786 | + $start = $DateTime->setTime(0, 0, 0)->format(implode(' ', $start_formats)); |
|
1787 | + $end = $DateTime->setDate(date('Y'), date('m'), $DateTime->format('t')) |
|
1788 | + ->setTime(23, 59, 59) |
|
1789 | + ->format(implode(' ', $start_formats)); |
|
1790 | + $where['Datetime.DTT_EVT_start'] = array('BETWEEN', array($start, $end)); |
|
1791 | + } |
|
1792 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events')) { |
|
1793 | + $where['EVT_wp_user'] = get_current_user_id(); |
|
1794 | + } else { |
|
1795 | + if ( ! isset($where['status'])) { |
|
1796 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_private_events', 'get_events')) { |
|
1797 | + $where['OR'] = array( |
|
1798 | + 'status*restrict_private' => array('!=', 'private'), |
|
1799 | + 'AND' => array( |
|
1800 | + 'status*inclusive' => array('=', 'private'), |
|
1801 | + 'EVT_wp_user' => get_current_user_id(), |
|
1802 | + ), |
|
1803 | + ); |
|
1804 | + } |
|
1805 | + } |
|
1806 | + } |
|
1807 | + if (isset($this->_req_data['EVT_wp_user'])) { |
|
1808 | + if ($this->_req_data['EVT_wp_user'] != get_current_user_id() |
|
1809 | + && EE_Registry::instance()->CAP->current_user_can('ee_read_others_events', 'get_events') |
|
1810 | + ) { |
|
1811 | + $where['EVT_wp_user'] = $this->_req_data['EVT_wp_user']; |
|
1812 | + } |
|
1813 | + } |
|
1814 | + //search query handling |
|
1815 | + if (isset($this->_req_data['s'])) { |
|
1816 | + $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1817 | + $where['OR'] = array( |
|
1818 | + 'EVT_name' => array('LIKE', $search_string), |
|
1819 | + 'EVT_desc' => array('LIKE', $search_string), |
|
1820 | + 'EVT_short_desc' => array('LIKE', $search_string), |
|
1821 | + ); |
|
1822 | + } |
|
1823 | + $where = apply_filters('FHEE__Events_Admin_Page__get_events__where', $where, $this->_req_data); |
|
1824 | + $query_params = apply_filters( |
|
1825 | + 'FHEE__Events_Admin_Page__get_events__query_params', |
|
1826 | + array( |
|
1827 | + $where, |
|
1828 | + 'limit' => $limit, |
|
1829 | + 'order_by' => $orderby, |
|
1830 | + 'order' => $order, |
|
1831 | + 'group_by' => 'EVT_ID', |
|
1832 | + ), |
|
1833 | + $this->_req_data |
|
1834 | + ); |
|
1835 | + //let's first check if we have special requests coming in. |
|
1836 | + if (isset($this->_req_data['active_status'])) { |
|
1837 | + switch ($this->_req_data['active_status']) { |
|
1838 | + case 'upcoming' : |
|
1839 | + return $EEME->get_upcoming_events($query_params, $count); |
|
1840 | + break; |
|
1841 | + case 'expired' : |
|
1842 | + return $EEME->get_expired_events($query_params, $count); |
|
1843 | + break; |
|
1844 | + case 'active' : |
|
1845 | + return $EEME->get_active_events($query_params, $count); |
|
1846 | + break; |
|
1847 | + case 'inactive' : |
|
1848 | + return $EEME->get_inactive_events($query_params, $count); |
|
1849 | + break; |
|
1850 | + } |
|
1851 | + } |
|
1852 | + $events = $count ? $EEME->count(array($where), 'EVT_ID', true) : $EEME->get_all($query_params); |
|
1853 | + return $events; |
|
1854 | + } |
|
1855 | + |
|
1856 | + |
|
1857 | + |
|
1858 | + /** |
|
1859 | + * handling for WordPress CPT actions (trash, restore, delete) |
|
1860 | + * |
|
1861 | + * @param string $post_id |
|
1862 | + */ |
|
1863 | + public function trash_cpt_item($post_id) |
|
1864 | + { |
|
1865 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1866 | + $this->_trash_or_restore_event('trash', false); |
|
1867 | + } |
|
1868 | + |
|
1869 | + |
|
1870 | + |
|
1871 | + /** |
|
1872 | + * @param string $post_id |
|
1873 | + */ |
|
1874 | + public function restore_cpt_item($post_id) |
|
1875 | + { |
|
1876 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1877 | + $this->_trash_or_restore_event('draft', false); |
|
1878 | + } |
|
1879 | + |
|
1880 | + |
|
1881 | + |
|
1882 | + /** |
|
1883 | + * @param string $post_id |
|
1884 | + */ |
|
1885 | + public function delete_cpt_item($post_id) |
|
1886 | + { |
|
1887 | + $this->_req_data['EVT_ID'] = $post_id; |
|
1888 | + $this->_delete_event(false); |
|
1889 | + } |
|
1890 | + |
|
1891 | + |
|
1892 | + |
|
1893 | + /** |
|
1894 | + * _trash_or_restore_event |
|
1895 | + * |
|
1896 | + * @access protected |
|
1897 | + * @param string $event_status |
|
1898 | + * @param bool $redirect_after |
|
1899 | + */ |
|
1900 | + protected function _trash_or_restore_event($event_status = 'trash', $redirect_after = true) |
|
1901 | + { |
|
1902 | + //determine the event id and set to array. |
|
1903 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : false; |
|
1904 | + // loop thru events |
|
1905 | + if ($EVT_ID) { |
|
1906 | + // clean status |
|
1907 | + $event_status = sanitize_key($event_status); |
|
1908 | + // grab status |
|
1909 | + if ( ! empty($event_status)) { |
|
1910 | + $success = $this->_change_event_status($EVT_ID, $event_status); |
|
1911 | + } else { |
|
1912 | + $success = false; |
|
1913 | + $msg = esc_html__( |
|
1914 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1915 | + 'event_espresso' |
|
1916 | + ); |
|
1917 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1918 | + } |
|
1919 | + } else { |
|
1920 | + $success = false; |
|
1921 | + $msg = esc_html__( |
|
1922 | + 'An error occurred. The event could not be moved to the trash because a valid event ID was not not supplied.', |
|
1923 | + 'event_espresso' |
|
1924 | + ); |
|
1925 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1926 | + } |
|
1927 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1928 | + if ($redirect_after) { |
|
1929 | + $this->_redirect_after_action($success, 'Event', $action, array('action' => 'default')); |
|
1930 | + } |
|
1931 | + } |
|
1932 | + |
|
1933 | + |
|
1934 | + |
|
1935 | + /** |
|
1936 | + * _trash_or_restore_events |
|
1937 | + * |
|
1938 | + * @access protected |
|
1939 | + * @param string $event_status |
|
1940 | + * @return void |
|
1941 | + */ |
|
1942 | + protected function _trash_or_restore_events($event_status = 'trash') |
|
1943 | + { |
|
1944 | + // clean status |
|
1945 | + $event_status = sanitize_key($event_status); |
|
1946 | + // grab status |
|
1947 | + if ( ! empty($event_status)) { |
|
1948 | + $success = true; |
|
1949 | + //determine the event id and set to array. |
|
1950 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1951 | + // loop thru events |
|
1952 | + foreach ($EVT_IDs as $EVT_ID) { |
|
1953 | + if ($EVT_ID = absint($EVT_ID)) { |
|
1954 | + $results = $this->_change_event_status($EVT_ID, $event_status); |
|
1955 | + $success = $results !== false ? $success : false; |
|
1956 | + } else { |
|
1957 | + $msg = sprintf( |
|
1958 | + esc_html__( |
|
1959 | + 'An error occurred. Event #%d could not be moved to the trash because a valid event ID was not not supplied.', |
|
1960 | + 'event_espresso' |
|
1961 | + ), |
|
1962 | + $EVT_ID |
|
1963 | + ); |
|
1964 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1965 | + $success = false; |
|
1966 | + } |
|
1967 | + } |
|
1968 | + } else { |
|
1969 | + $success = false; |
|
1970 | + $msg = esc_html__( |
|
1971 | + 'An error occurred. The event could not be moved to the trash because a valid event status was not not supplied.', |
|
1972 | + 'event_espresso' |
|
1973 | + ); |
|
1974 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
1975 | + } |
|
1976 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
1977 | + $success = $success ? 2 : false; |
|
1978 | + $action = $event_status == 'trash' ? 'moved to the trash' : 'restored from the trash'; |
|
1979 | + $this->_redirect_after_action($success, 'Events', $action, array('action' => 'default')); |
|
1980 | + } |
|
1981 | + |
|
1982 | + |
|
1983 | + |
|
1984 | + /** |
|
1985 | + * _trash_or_restore_events |
|
1986 | + * |
|
1987 | + * @access private |
|
1988 | + * @param int $EVT_ID |
|
1989 | + * @param string $event_status |
|
1990 | + * @return bool |
|
1991 | + */ |
|
1992 | + private function _change_event_status($EVT_ID = 0, $event_status = '') |
|
1993 | + { |
|
1994 | + // grab event id |
|
1995 | + if ( ! $EVT_ID) { |
|
1996 | + $msg = esc_html__( |
|
1997 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
1998 | + 'event_espresso' |
|
1999 | + ); |
|
2000 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2001 | + return false; |
|
2002 | + } |
|
2003 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2004 | + // clean status |
|
2005 | + $event_status = sanitize_key($event_status); |
|
2006 | + // grab status |
|
2007 | + if (empty($event_status)) { |
|
2008 | + $msg = esc_html__( |
|
2009 | + 'An error occurred. No Event Status or an invalid Event Status was received.', |
|
2010 | + 'event_espresso' |
|
2011 | + ); |
|
2012 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2013 | + return false; |
|
2014 | + } |
|
2015 | + // was event trashed or restored ? |
|
2016 | + switch ($event_status) { |
|
2017 | + case 'draft' : |
|
2018 | + $action = 'restored from the trash'; |
|
2019 | + $hook = 'AHEE_event_restored_from_trash'; |
|
2020 | + break; |
|
2021 | + case 'trash' : |
|
2022 | + $action = 'moved to the trash'; |
|
2023 | + $hook = 'AHEE_event_moved_to_trash'; |
|
2024 | + break; |
|
2025 | + default : |
|
2026 | + $action = 'updated'; |
|
2027 | + $hook = false; |
|
2028 | + } |
|
2029 | + //use class to change status |
|
2030 | + $this->_cpt_model_obj->set_status($event_status); |
|
2031 | + $success = $this->_cpt_model_obj->save(); |
|
2032 | + if ($success === false) { |
|
2033 | + $msg = sprintf(esc_html__('An error occurred. The event could not be %s.', 'event_espresso'), $action); |
|
2034 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2035 | + return false; |
|
2036 | + } |
|
2037 | + if ($hook) { |
|
2038 | + do_action($hook); |
|
2039 | + } |
|
2040 | + return true; |
|
2041 | + } |
|
2042 | + |
|
2043 | + |
|
2044 | + |
|
2045 | + /** |
|
2046 | + * _delete_event |
|
2047 | + * |
|
2048 | + * @access protected |
|
2049 | + * @param bool $redirect_after |
|
2050 | + */ |
|
2051 | + protected function _delete_event($redirect_after = true) |
|
2052 | + { |
|
2053 | + //determine the event id and set to array. |
|
2054 | + $EVT_ID = isset($this->_req_data['EVT_ID']) ? absint($this->_req_data['EVT_ID']) : null; |
|
2055 | + $EVT_ID = isset($this->_req_data['post']) ? absint($this->_req_data['post']) : $EVT_ID; |
|
2056 | + // loop thru events |
|
2057 | + if ($EVT_ID) { |
|
2058 | + $success = $this->_permanently_delete_event($EVT_ID); |
|
2059 | + // get list of events with no prices |
|
2060 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2061 | + // remove this event from the list of events with no prices |
|
2062 | + if (isset($espresso_no_ticket_prices[$EVT_ID])) { |
|
2063 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2064 | + } |
|
2065 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2066 | + } else { |
|
2067 | + $success = false; |
|
2068 | + $msg = esc_html__( |
|
2069 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2070 | + 'event_espresso' |
|
2071 | + ); |
|
2072 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2073 | + } |
|
2074 | + if ($redirect_after) { |
|
2075 | + $this->_redirect_after_action( |
|
2076 | + $success, |
|
2077 | + 'Event', |
|
2078 | + 'deleted', |
|
2079 | + array('action' => 'default', 'status' => 'trash') |
|
2080 | + ); |
|
2081 | + } |
|
2082 | + } |
|
2083 | + |
|
2084 | + |
|
2085 | + |
|
2086 | + /** |
|
2087 | + * _delete_events |
|
2088 | + * |
|
2089 | + * @access protected |
|
2090 | + * @return void |
|
2091 | + */ |
|
2092 | + protected function _delete_events() |
|
2093 | + { |
|
2094 | + $success = true; |
|
2095 | + // get list of events with no prices |
|
2096 | + $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
|
2097 | + //determine the event id and set to array. |
|
2098 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2099 | + // loop thru events |
|
2100 | + foreach ($EVT_IDs as $EVT_ID) { |
|
2101 | + $EVT_ID = absint($EVT_ID); |
|
2102 | + if ($EVT_ID) { |
|
2103 | + $results = $this->_permanently_delete_event($EVT_ID); |
|
2104 | + $success = $results !== false ? $success : false; |
|
2105 | + // remove this event from the list of events with no prices |
|
2106 | + unset($espresso_no_ticket_prices[$EVT_ID]); |
|
2107 | + } else { |
|
2108 | + $success = false; |
|
2109 | + $msg = esc_html__( |
|
2110 | + 'An error occurred. An event could not be deleted because a valid event ID was not not supplied.', |
|
2111 | + 'event_espresso' |
|
2112 | + ); |
|
2113 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2114 | + } |
|
2115 | + } |
|
2116 | + update_option('ee_no_ticket_prices', $espresso_no_ticket_prices); |
|
2117 | + // in order to force a pluralized result message we need to send back a success status greater than 1 |
|
2118 | + $success = $success ? 2 : false; |
|
2119 | + $this->_redirect_after_action($success, 'Events', 'deleted', array('action' => 'default')); |
|
2120 | + } |
|
2121 | + |
|
2122 | + |
|
2123 | + |
|
2124 | + /** |
|
2125 | + * _permanently_delete_event |
|
2126 | + * |
|
2127 | + * @access private |
|
2128 | + * @param int $EVT_ID |
|
2129 | + * @return bool |
|
2130 | + */ |
|
2131 | + private function _permanently_delete_event($EVT_ID = 0) |
|
2132 | + { |
|
2133 | + // grab event id |
|
2134 | + if ( ! $EVT_ID) { |
|
2135 | + $msg = esc_html__( |
|
2136 | + 'An error occurred. No Event ID or an invalid Event ID was received.', |
|
2137 | + 'event_espresso' |
|
2138 | + ); |
|
2139 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2140 | + return false; |
|
2141 | + } |
|
2142 | + if ( |
|
2143 | + ! $this->_cpt_model_obj instanceof EE_Event |
|
2144 | + || $this->_cpt_model_obj->ID() !== $EVT_ID |
|
2145 | + ) { |
|
2146 | + $this->_cpt_model_obj = EEM_Event::instance()->get_one_by_ID($EVT_ID); |
|
2147 | + } |
|
2148 | + if ( ! $this->_cpt_model_obj instanceof EE_Event) { |
|
2149 | + return false; |
|
2150 | + } |
|
2151 | + //need to delete related tickets and prices first. |
|
2152 | + $datetimes = $this->_cpt_model_obj->get_many_related('Datetime'); |
|
2153 | + foreach ($datetimes as $datetime) { |
|
2154 | + $this->_cpt_model_obj->_remove_relation_to($datetime, 'Datetime'); |
|
2155 | + $tickets = $datetime->get_many_related('Ticket'); |
|
2156 | + foreach ($tickets as $ticket) { |
|
2157 | + $ticket->_remove_relation_to($datetime, 'Datetime'); |
|
2158 | + $ticket->delete_related_permanently('Price'); |
|
2159 | + $ticket->delete_permanently(); |
|
2160 | + } |
|
2161 | + $datetime->delete(); |
|
2162 | + } |
|
2163 | + //what about related venues or terms? |
|
2164 | + $venues = $this->_cpt_model_obj->get_many_related('Venue'); |
|
2165 | + foreach ($venues as $venue) { |
|
2166 | + $this->_cpt_model_obj->_remove_relation_to($venue, 'Venue'); |
|
2167 | + } |
|
2168 | + //any attached question groups? |
|
2169 | + $question_groups = $this->_cpt_model_obj->get_many_related('Question_Group'); |
|
2170 | + if ( ! empty($question_groups)) { |
|
2171 | + foreach ($question_groups as $question_group) { |
|
2172 | + $this->_cpt_model_obj->_remove_relation_to($question_group, 'Question_Group'); |
|
2173 | + } |
|
2174 | + } |
|
2175 | + //Message Template Groups |
|
2176 | + $this->_cpt_model_obj->_remove_relations('Message_Template_Group'); |
|
2177 | + /** @type EE_Term_Taxonomy[] $term_taxonomies */ |
|
2178 | + $term_taxonomies = $this->_cpt_model_obj->term_taxonomies(); |
|
2179 | + foreach ($term_taxonomies as $term_taxonomy) { |
|
2180 | + $this->_cpt_model_obj->remove_relation_to_term_taxonomy($term_taxonomy); |
|
2181 | + } |
|
2182 | + $success = $this->_cpt_model_obj->delete_permanently(); |
|
2183 | + // did it all go as planned ? |
|
2184 | + if ($success) { |
|
2185 | + $msg = sprintf(esc_html__('Event ID # %d has been deleted.', 'event_espresso'), $EVT_ID); |
|
2186 | + EE_Error::add_success($msg); |
|
2187 | + } else { |
|
2188 | + $msg = sprintf( |
|
2189 | + esc_html__('An error occurred. Event ID # %d could not be deleted.', 'event_espresso'), |
|
2190 | + $EVT_ID |
|
2191 | + ); |
|
2192 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2193 | + return false; |
|
2194 | + } |
|
2195 | + do_action('AHEE__Events_Admin_Page___permanently_delete_event__after_event_deleted', $EVT_ID); |
|
2196 | + return true; |
|
2197 | + } |
|
2198 | + |
|
2199 | + |
|
2200 | + |
|
2201 | + /** |
|
2202 | + * get total number of events |
|
2203 | + * |
|
2204 | + * @access public |
|
2205 | + * @return int |
|
2206 | + */ |
|
2207 | + public function total_events() |
|
2208 | + { |
|
2209 | + $count = EEM_Event::instance()->count(array('caps' => 'read_admin'), 'EVT_ID', true); |
|
2210 | + return $count; |
|
2211 | + } |
|
2212 | + |
|
2213 | + |
|
2214 | + |
|
2215 | + /** |
|
2216 | + * get total number of draft events |
|
2217 | + * |
|
2218 | + * @access public |
|
2219 | + * @return int |
|
2220 | + */ |
|
2221 | + public function total_events_draft() |
|
2222 | + { |
|
2223 | + $where = array( |
|
2224 | + 'status' => array('IN', array('draft', 'auto-draft')), |
|
2225 | + ); |
|
2226 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2227 | + return $count; |
|
2228 | + } |
|
2229 | + |
|
2230 | + |
|
2231 | + |
|
2232 | + /** |
|
2233 | + * get total number of trashed events |
|
2234 | + * |
|
2235 | + * @access public |
|
2236 | + * @return int |
|
2237 | + */ |
|
2238 | + public function total_trashed_events() |
|
2239 | + { |
|
2240 | + $where = array( |
|
2241 | + 'status' => 'trash', |
|
2242 | + ); |
|
2243 | + $count = EEM_Event::instance()->count(array($where, 'caps' => 'read_admin'), 'EVT_ID', true); |
|
2244 | + return $count; |
|
2245 | + } |
|
2246 | + |
|
2247 | + |
|
2248 | + |
|
2249 | + /** |
|
2250 | + * _default_event_settings |
|
2251 | + * This generates the Default Settings Tab |
|
2252 | + * |
|
2253 | + * @return void |
|
2254 | + */ |
|
2255 | + protected function _default_event_settings() |
|
2256 | + { |
|
2257 | + $this->_template_args['values'] = $this->_yes_no_values; |
|
2258 | + $this->_template_args['reg_status_array'] = EEM_Registration::reg_status_array( |
|
2259 | + // exclude array |
|
2260 | + array( |
|
2261 | + EEM_Registration::status_id_cancelled, |
|
2262 | + EEM_Registration::status_id_declined, |
|
2263 | + EEM_Registration::status_id_incomplete, |
|
2264 | + EEM_Registration::status_id_wait_list, |
|
2265 | + ), |
|
2266 | + // translated |
|
2267 | + true |
|
2268 | + ); |
|
2269 | + $this->_template_args['default_reg_status'] = isset( |
|
2270 | + EE_Registry::instance()->CFG->registration->default_STS_ID |
|
2271 | + ) |
|
2272 | + && in_array( |
|
2273 | + EE_Registry::instance()->CFG->registration->default_STS_ID, |
|
2274 | + $this->_template_args['reg_status_array'] |
|
2275 | + ) |
|
2276 | + ? sanitize_text_field(EE_Registry::instance()->CFG->registration->default_STS_ID) |
|
2277 | + : EEM_Registration::status_id_pending_payment; |
|
2278 | + $this->_set_add_edit_form_tags('update_default_event_settings'); |
|
2279 | + $this->_set_publish_post_box_vars(null, false, false, null, false); |
|
2280 | + $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
|
2281 | + EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2282 | + $this->_template_args, |
|
2283 | + true |
|
2284 | + ); |
|
2285 | + $this->display_admin_page_with_sidebar(); |
|
2286 | + } |
|
2287 | + |
|
2288 | + |
|
2289 | + |
|
2290 | + /** |
|
2291 | + * _update_default_event_settings |
|
2292 | + * |
|
2293 | + * @access protected |
|
2294 | + * @return void |
|
2295 | + */ |
|
2296 | + protected function _update_default_event_settings() |
|
2297 | + { |
|
2298 | + EE_Config::instance()->registration->default_STS_ID = isset($this->_req_data['default_reg_status']) |
|
2299 | + ? sanitize_text_field($this->_req_data['default_reg_status']) |
|
2300 | + : EEM_Registration::status_id_pending_payment; |
|
2301 | + $what = 'Default Event Settings'; |
|
2302 | + $success = $this->_update_espresso_configuration( |
|
2303 | + $what, |
|
2304 | + EE_Config::instance(), |
|
2305 | + __FILE__, |
|
2306 | + __FUNCTION__, |
|
2307 | + __LINE__ |
|
2308 | + ); |
|
2309 | + $this->_redirect_after_action($success, $what, 'updated', array('action' => 'default_event_settings')); |
|
2310 | + } |
|
2311 | + |
|
2312 | + |
|
2313 | + |
|
2314 | + /************* Templates *************/ |
|
2315 | + protected function _template_settings() |
|
2316 | + { |
|
2317 | + $this->_admin_page_title = esc_html__('Template Settings (Preview)', 'event_espresso'); |
|
2318 | + $this->_template_args['preview_img'] = '<img src="' |
|
2319 | + . EVENTS_ASSETS_URL |
|
2320 | + . DS |
|
2321 | + . 'images' |
|
2322 | + . DS |
|
2323 | + . 'caffeinated_template_features.jpg" alt="' |
|
2324 | + . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
|
2325 | + . '" />'; |
|
2326 | + $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2327 | + '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.', |
|
2328 | + 'event_espresso' |
|
2329 | + ) . '</strong>'; |
|
2330 | + $this->display_admin_caf_preview_page('template_settings_tab'); |
|
2331 | + } |
|
2332 | + |
|
2333 | + |
|
2334 | + /** Event Category Stuff **/ |
|
2335 | + /** |
|
2336 | + * set the _category property with the category object for the loaded page. |
|
2337 | + * |
|
2338 | + * @access private |
|
2339 | + * @return void |
|
2340 | + */ |
|
2341 | + private function _set_category_object() |
|
2342 | + { |
|
2343 | + if (isset($this->_category->id) && ! empty($this->_category->id)) { |
|
2344 | + return; |
|
2345 | + } //already have the category object so get out. |
|
2346 | + //set default category object |
|
2347 | + $this->_set_empty_category_object(); |
|
2348 | + //only set if we've got an id |
|
2349 | + if ( ! isset($this->_req_data['EVT_CAT_ID'])) { |
|
2350 | + return; |
|
2351 | + } |
|
2352 | + $category_id = absint($this->_req_data['EVT_CAT_ID']); |
|
2353 | + $term = get_term($category_id, 'espresso_event_categories'); |
|
2354 | + if ( ! empty($term)) { |
|
2355 | + $this->_category->category_name = $term->name; |
|
2356 | + $this->_category->category_identifier = $term->slug; |
|
2357 | + $this->_category->category_desc = $term->description; |
|
2358 | + $this->_category->id = $term->term_id; |
|
2359 | + $this->_category->parent = $term->parent; |
|
2360 | + } |
|
2361 | + } |
|
2362 | + |
|
2363 | + |
|
2364 | + |
|
2365 | + private function _set_empty_category_object() |
|
2366 | + { |
|
2367 | + $this->_category = new stdClass(); |
|
2368 | + $this->_category->category_name = $this->_category->category_identifier = $this->_category->category_desc = ''; |
|
2369 | + $this->_category->id = $this->_category->parent = 0; |
|
2370 | + } |
|
2371 | + |
|
2372 | + |
|
2373 | + |
|
2374 | + protected function _category_list_table() |
|
2375 | + { |
|
2376 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
2377 | + $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
|
2378 | + $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2379 | + 'add_category', |
|
2380 | + 'add_category', |
|
2381 | + array(), |
|
2382 | + 'add-new-h2' |
|
2383 | + ); |
|
2384 | + $this->display_admin_list_table_page_with_sidebar(); |
|
2385 | + } |
|
2386 | + |
|
2387 | + |
|
2388 | + |
|
2389 | + /** |
|
2390 | + * @param $view |
|
2391 | + */ |
|
2392 | + protected function _category_details($view) |
|
2393 | + { |
|
2394 | + //load formatter helper |
|
2395 | + //load field generator helper |
|
2396 | + $route = $view == 'edit' ? 'update_category' : 'insert_category'; |
|
2397 | + $this->_set_add_edit_form_tags($route); |
|
2398 | + $this->_set_category_object(); |
|
2399 | + $id = ! empty($this->_category->id) ? $this->_category->id : ''; |
|
2400 | + $delete_action = 'delete_category'; |
|
2401 | + //custom redirect |
|
2402 | + $redirect = EE_Admin_Page::add_query_args_and_nonce( |
|
2403 | + array('action' => 'category_list'), |
|
2404 | + $this->_admin_base_url |
|
2405 | + ); |
|
2406 | + $this->_set_publish_post_box_vars('EVT_CAT_ID', $id, $delete_action, $redirect); |
|
2407 | + //take care of contents |
|
2408 | + $this->_template_args['admin_page_content'] = $this->_category_details_content(); |
|
2409 | + $this->display_admin_page_with_sidebar(); |
|
2410 | + } |
|
2411 | + |
|
2412 | + |
|
2413 | + |
|
2414 | + /** |
|
2415 | + * @return mixed |
|
2416 | + */ |
|
2417 | + protected function _category_details_content() |
|
2418 | + { |
|
2419 | + $editor_args['category_desc'] = array( |
|
2420 | + 'type' => 'wp_editor', |
|
2421 | + 'value' => EEH_Formatter::admin_format_content($this->_category->category_desc), |
|
2422 | + 'class' => 'my_editor_custom', |
|
2423 | + 'wpeditor_args' => array('media_buttons' => false), |
|
2424 | + ); |
|
2425 | + $_wp_editor = $this->_generate_admin_form_fields($editor_args, 'array'); |
|
2426 | + $all_terms = get_terms( |
|
2427 | + array('espresso_event_categories'), |
|
2428 | + array('hide_empty' => 0, 'exclude' => array($this->_category->id)) |
|
2429 | + ); |
|
2430 | + //setup category select for term parents. |
|
2431 | + $category_select_values[] = array( |
|
2432 | + 'text' => esc_html__('No Parent', 'event_espresso'), |
|
2433 | + 'id' => 0, |
|
2434 | + ); |
|
2435 | + foreach ($all_terms as $term) { |
|
2436 | + $category_select_values[] = array( |
|
2437 | + 'text' => $term->name, |
|
2438 | + 'id' => $term->term_id, |
|
2439 | + ); |
|
2440 | + } |
|
2441 | + $category_select = EEH_Form_Fields::select_input( |
|
2442 | + 'category_parent', |
|
2443 | + $category_select_values, |
|
2444 | + $this->_category->parent |
|
2445 | + ); |
|
2446 | + $template_args = array( |
|
2447 | + 'category' => $this->_category, |
|
2448 | + 'category_select' => $category_select, |
|
2449 | + 'unique_id_info_help_link' => $this->_get_help_tab_link('unique_id_info'), |
|
2450 | + 'category_desc_editor' => $_wp_editor['category_desc']['field'], |
|
2451 | + 'disable' => '', |
|
2452 | + 'disabled_message' => false, |
|
2453 | + ); |
|
2454 | + $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2455 | + return EEH_Template::display_template($template, $template_args, true); |
|
2456 | + } |
|
2457 | + |
|
2458 | + |
|
2459 | + |
|
2460 | + protected function _delete_categories() |
|
2461 | + { |
|
2462 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2463 | + : (array)$this->_req_data['category_id']; |
|
2464 | + foreach ($cat_ids as $cat_id) { |
|
2465 | + $this->_delete_category($cat_id); |
|
2466 | + } |
|
2467 | + //doesn't matter what page we're coming from... we're going to the same place after delete. |
|
2468 | + $query_args = array( |
|
2469 | + 'action' => 'category_list', |
|
2470 | + ); |
|
2471 | + $this->_redirect_after_action(0, '', '', $query_args); |
|
2472 | + } |
|
2473 | + |
|
2474 | + |
|
2475 | + |
|
2476 | + /** |
|
2477 | + * @param $cat_id |
|
2478 | + */ |
|
2479 | + protected function _delete_category($cat_id) |
|
2480 | + { |
|
2481 | + $cat_id = absint($cat_id); |
|
2482 | + wp_delete_term($cat_id, 'espresso_event_categories'); |
|
2483 | + } |
|
2484 | + |
|
2485 | + |
|
2486 | + |
|
2487 | + /** |
|
2488 | + * @param $new_category |
|
2489 | + */ |
|
2490 | + protected function _insert_or_update_category($new_category) |
|
2491 | + { |
|
2492 | + $cat_id = $new_category ? $this->_insert_category() : $this->_insert_category(true); |
|
2493 | + $success = 0; //we already have a success message so lets not send another. |
|
2494 | + if ($cat_id) { |
|
2495 | + $query_args = array( |
|
2496 | + 'action' => 'edit_category', |
|
2497 | + 'EVT_CAT_ID' => $cat_id, |
|
2498 | + ); |
|
2499 | + } else { |
|
2500 | + $query_args = array('action' => 'add_category'); |
|
2501 | + } |
|
2502 | + $this->_redirect_after_action($success, '', '', $query_args, true); |
|
2503 | + } |
|
2504 | + |
|
2505 | + |
|
2506 | + |
|
2507 | + /** |
|
2508 | + * @param bool $update |
|
2509 | + * @return bool|mixed|string |
|
2510 | + */ |
|
2511 | + private function _insert_category($update = false) |
|
2512 | + { |
|
2513 | + $cat_id = $update ? $this->_req_data['EVT_CAT_ID'] : ''; |
|
2514 | + $category_name = isset($this->_req_data['category_name']) ? $this->_req_data['category_name'] : ''; |
|
2515 | + $category_desc = isset($this->_req_data['category_desc']) ? $this->_req_data['category_desc'] : ''; |
|
2516 | + $category_parent = isset($this->_req_data['category_parent']) ? $this->_req_data['category_parent'] : 0; |
|
2517 | + if (empty($category_name)) { |
|
2518 | + $msg = esc_html__('You must add a name for the category.', 'event_espresso'); |
|
2519 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2520 | + return false; |
|
2521 | + } |
|
2522 | + $term_args = array( |
|
2523 | + 'name' => $category_name, |
|
2524 | + 'description' => $category_desc, |
|
2525 | + 'parent' => $category_parent, |
|
2526 | + ); |
|
2527 | + //was the category_identifier input disabled? |
|
2528 | + if (isset($this->_req_data['category_identifier'])) { |
|
2529 | + $term_args['slug'] = $this->_req_data['category_identifier']; |
|
2530 | + } |
|
2531 | + $insert_ids = $update |
|
2532 | + ? wp_update_term($cat_id, 'espresso_event_categories', $term_args) |
|
2533 | + : wp_insert_term($category_name, 'espresso_event_categories', $term_args); |
|
2534 | + if ( ! is_array($insert_ids)) { |
|
2535 | + $msg = esc_html__( |
|
2536 | + 'An error occurred and the category has not been saved to the database.', |
|
2537 | + 'event_espresso' |
|
2538 | + ); |
|
2539 | + EE_Error::add_error($msg, __FILE__, __FUNCTION__, __LINE__); |
|
2540 | + } else { |
|
2541 | + $cat_id = $insert_ids['term_id']; |
|
2542 | + $msg = sprintf(esc_html__('The category %s was successfully saved', 'event_espresso'), $category_name); |
|
2543 | + EE_Error::add_success($msg); |
|
2544 | + } |
|
2545 | + return $cat_id; |
|
2546 | + } |
|
2547 | + |
|
2548 | + |
|
2549 | + |
|
2550 | + /** |
|
2551 | + * @param int $per_page |
|
2552 | + * @param int $current_page |
|
2553 | + * @param bool $count |
|
2554 | + * @return \EE_Base_Class[]|int |
|
2555 | + */ |
|
2556 | + public function get_categories($per_page = 10, $current_page = 1, $count = false) |
|
2557 | + { |
|
2558 | + //testing term stuff |
|
2559 | + $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'Term.term_id'; |
|
2560 | + $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : 'DESC'; |
|
2561 | + $limit = ($current_page - 1) * $per_page; |
|
2562 | + $where = array('taxonomy' => 'espresso_event_categories'); |
|
2563 | + if (isset($this->_req_data['s'])) { |
|
2564 | + $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2565 | + $where['OR'] = array( |
|
2566 | + 'Term.name' => array('LIKE', $sstr), |
|
2567 | + 'description' => array('LIKE', $sstr), |
|
2568 | + ); |
|
2569 | + } |
|
2570 | + $query_params = array( |
|
2571 | + $where, |
|
2572 | + 'order_by' => array($orderby => $order), |
|
2573 | + 'limit' => $limit . ',' . $per_page, |
|
2574 | + 'force_join' => array('Term'), |
|
2575 | + ); |
|
2576 | + $categories = $count |
|
2577 | + ? EEM_Term_Taxonomy::instance()->count($query_params, 'term_id') |
|
2578 | + : EEM_Term_Taxonomy::instance()->get_all($query_params); |
|
2579 | + return $categories; |
|
2580 | + } |
|
2581 | + |
|
2582 | + |
|
2583 | + |
|
2584 | + /* end category stuff */ |
|
2585 | + /**************/ |
|
2586 | 2586 | } |
2587 | 2587 | //end class Events_Admin_Page |
@@ -531,11 +531,11 @@ discard block |
||
531 | 531 | { |
532 | 532 | wp_register_style( |
533 | 533 | 'events-admin-css', |
534 | - EVENTS_ASSETS_URL . 'events-admin-page.css', |
|
534 | + EVENTS_ASSETS_URL.'events-admin-page.css', |
|
535 | 535 | array(), |
536 | 536 | EVENT_ESPRESSO_VERSION |
537 | 537 | ); |
538 | - wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL . 'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
538 | + wp_register_style('ee-cat-admin', EVENTS_ASSETS_URL.'ee-cat-admin.css', array(), EVENT_ESPRESSO_VERSION); |
|
539 | 539 | wp_enqueue_style('events-admin-css'); |
540 | 540 | wp_enqueue_style('ee-cat-admin'); |
541 | 541 | //todo note: we also need to load_scripts_styles per view (i.e. default/view_report/event_details |
@@ -543,7 +543,7 @@ discard block |
||
543 | 543 | //scripts |
544 | 544 | wp_register_script( |
545 | 545 | 'event_editor_js', |
546 | - EVENTS_ASSETS_URL . 'event_editor.js', |
|
546 | + EVENTS_ASSETS_URL.'event_editor.js', |
|
547 | 547 | array('ee_admin_js', 'jquery-ui-slider', 'jquery-ui-timepicker-addon'), |
548 | 548 | EVENT_ESPRESSO_VERSION, |
549 | 549 | true |
@@ -575,7 +575,7 @@ discard block |
||
575 | 575 | wp_enqueue_style('espresso-ui-theme'); |
576 | 576 | wp_register_style( |
577 | 577 | 'event-editor-css', |
578 | - EVENTS_ASSETS_URL . 'event-editor.css', |
|
578 | + EVENTS_ASSETS_URL.'event-editor.css', |
|
579 | 579 | array('ee-admin-css'), |
580 | 580 | EVENT_ESPRESSO_VERSION |
581 | 581 | ); |
@@ -583,7 +583,7 @@ discard block |
||
583 | 583 | //scripts |
584 | 584 | wp_register_script( |
585 | 585 | 'event-datetime-metabox', |
586 | - EVENTS_ASSETS_URL . 'event-datetime-metabox.js', |
|
586 | + EVENTS_ASSETS_URL.'event-datetime-metabox.js', |
|
587 | 587 | array('event_editor_js', 'ee-datepicker'), |
588 | 588 | EVENT_ESPRESSO_VERSION |
589 | 589 | ); |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | 'Your website\'s timezone is currently set to UTC + 0. We recommend updating your timezone to a city |
749 | 749 | or region near you before you create an event. Your timezone can be updated through the %1$sGeneral Settings%2$s page.' |
750 | 750 | ), |
751 | - '<a href="' . admin_url('options-general.php') . '">', |
|
751 | + '<a href="'.admin_url('options-general.php').'">', |
|
752 | 752 | '</a>' |
753 | 753 | ), |
754 | 754 | __FILE__, |
@@ -818,31 +818,31 @@ discard block |
||
818 | 818 | $items = apply_filters('FHEE__Events_Admin_Page___event_legend_items__items', $items); |
819 | 819 | $statuses = array( |
820 | 820 | 'sold_out_status' => array( |
821 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::sold_out, |
|
821 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::sold_out, |
|
822 | 822 | 'desc' => EEH_Template::pretty_status(EE_Datetime::sold_out, false, 'sentence'), |
823 | 823 | ), |
824 | 824 | 'active_status' => array( |
825 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::active, |
|
825 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::active, |
|
826 | 826 | 'desc' => EEH_Template::pretty_status(EE_Datetime::active, false, 'sentence'), |
827 | 827 | ), |
828 | 828 | 'upcoming_status' => array( |
829 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::upcoming, |
|
829 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::upcoming, |
|
830 | 830 | 'desc' => EEH_Template::pretty_status(EE_Datetime::upcoming, false, 'sentence'), |
831 | 831 | ), |
832 | 832 | 'postponed_status' => array( |
833 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::postponed, |
|
833 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::postponed, |
|
834 | 834 | 'desc' => EEH_Template::pretty_status(EE_Datetime::postponed, false, 'sentence'), |
835 | 835 | ), |
836 | 836 | 'cancelled_status' => array( |
837 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::cancelled, |
|
837 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::cancelled, |
|
838 | 838 | 'desc' => EEH_Template::pretty_status(EE_Datetime::cancelled, false, 'sentence'), |
839 | 839 | ), |
840 | 840 | 'expired_status' => array( |
841 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::expired, |
|
841 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::expired, |
|
842 | 842 | 'desc' => EEH_Template::pretty_status(EE_Datetime::expired, false, 'sentence'), |
843 | 843 | ), |
844 | 844 | 'inactive_status' => array( |
845 | - 'class' => 'ee-status-legend ee-status-legend-' . EE_Datetime::inactive, |
|
845 | + 'class' => 'ee-status-legend ee-status-legend-'.EE_Datetime::inactive, |
|
846 | 846 | 'desc' => EEH_Template::pretty_status(EE_Datetime::inactive, false, 'sentence'), |
847 | 847 | ), |
848 | 848 | ); |
@@ -906,7 +906,7 @@ discard block |
||
906 | 906 | { |
907 | 907 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
908 | 908 | $this->_template_args['after_list_table'] = ! empty($this->_template_args['after_list_table']) |
909 | - ? (array)$this->_template_args['after_list_table'] |
|
909 | + ? (array) $this->_template_args['after_list_table'] |
|
910 | 910 | : array(); |
911 | 911 | $this->_template_args['after_list_table']['view_event_list_button'] = EEH_HTML::br() |
912 | 912 | . EEH_Template::get_button_or_link( |
@@ -915,7 +915,7 @@ discard block |
||
915 | 915 | 'button' |
916 | 916 | ); |
917 | 917 | $this->_template_args['after_list_table']['legend'] = $this->_display_legend($this->_event_legend_items()); |
918 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
918 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
919 | 919 | 'create_new', |
920 | 920 | 'add', |
921 | 921 | array(), |
@@ -1045,7 +1045,7 @@ discard block |
||
1045 | 1045 | */ |
1046 | 1046 | protected function _default_venue_update(\EE_Event $evtobj, $data) |
1047 | 1047 | { |
1048 | - require_once(EE_MODELS . 'EEM_Venue.model.php'); |
|
1048 | + require_once(EE_MODELS.'EEM_Venue.model.php'); |
|
1049 | 1049 | $venue_model = EE_Registry::instance()->load_model('Venue'); |
1050 | 1050 | $rows_affected = null; |
1051 | 1051 | $venue_id = ! empty($data['venue_id']) ? $data['venue_id'] : null; |
@@ -1169,7 +1169,7 @@ discard block |
||
1169 | 1169 | if (empty($tkt['TKT_start_date'])) { |
1170 | 1170 | //let's use now in the set timezone. |
1171 | 1171 | $now = new DateTime('now', new DateTimeZone($evtobj->get_timezone())); |
1172 | - $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0] . ' ' . $incoming_date_formats[1]); |
|
1172 | + $tkt['TKT_start_date'] = $now->format($incoming_date_formats[0].' '.$incoming_date_formats[1]); |
|
1173 | 1173 | } |
1174 | 1174 | if (empty($tkt['TKT_end_date'])) { |
1175 | 1175 | //use the start date of the first datetime |
@@ -1458,7 +1458,7 @@ discard block |
||
1458 | 1458 | $publish_box_extra_args['event_editor_overview_add'] = ob_get_clean(); |
1459 | 1459 | // load template |
1460 | 1460 | EEH_Template::display_template( |
1461 | - EVENTS_TEMPLATE_PATH . 'event_publish_box_extras.template.php', |
|
1461 | + EVENTS_TEMPLATE_PATH.'event_publish_box_extras.template.php', |
|
1462 | 1462 | $publish_box_extra_args |
1463 | 1463 | ); |
1464 | 1464 | } |
@@ -1585,7 +1585,7 @@ discard block |
||
1585 | 1585 | ); |
1586 | 1586 | $template = apply_filters( |
1587 | 1587 | 'FHEE__Events_Admin_Page__ticket_metabox__template', |
1588 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_main.template.php' |
|
1588 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_main.template.php' |
|
1589 | 1589 | ); |
1590 | 1590 | EEH_Template::display_template($template, $template_args); |
1591 | 1591 | } |
@@ -1604,7 +1604,7 @@ discard block |
||
1604 | 1604 | private function _get_ticket_row($ticket, $skeleton = false, $row = 0) |
1605 | 1605 | { |
1606 | 1606 | $template_args = array( |
1607 | - 'tkt_status_class' => ' tkt-status-' . $ticket->ticket_status(), |
|
1607 | + 'tkt_status_class' => ' tkt-status-'.$ticket->ticket_status(), |
|
1608 | 1608 | 'tkt_archive_class' => $ticket->ticket_status() === EE_Ticket::archived && ! $skeleton ? ' tkt-archived' |
1609 | 1609 | : '', |
1610 | 1610 | 'ticketrow' => $skeleton ? 'TICKETNUM' : $row, |
@@ -1658,7 +1658,7 @@ discard block |
||
1658 | 1658 | $template_args = array_merge($template_args, $price_args); |
1659 | 1659 | $template = apply_filters( |
1660 | 1660 | 'FHEE__Events_Admin_Page__get_ticket_row__template', |
1661 | - EVENTS_TEMPLATE_PATH . 'event_tickets_metabox_ticket_row.template.php', |
|
1661 | + EVENTS_TEMPLATE_PATH.'event_tickets_metabox_ticket_row.template.php', |
|
1662 | 1662 | $ticket |
1663 | 1663 | ); |
1664 | 1664 | return EEH_Template::display_template($template, $template_args, true); |
@@ -1710,7 +1710,7 @@ discard block |
||
1710 | 1710 | $default_reg_status_values |
1711 | 1711 | ); |
1712 | 1712 | EEH_Template::display_template( |
1713 | - EVENTS_TEMPLATE_PATH . 'event_registration_options.template.php', |
|
1713 | + EVENTS_TEMPLATE_PATH.'event_registration_options.template.php', |
|
1714 | 1714 | $template_args |
1715 | 1715 | ); |
1716 | 1716 | } |
@@ -1733,7 +1733,7 @@ discard block |
||
1733 | 1733 | { |
1734 | 1734 | $EEME = $this->_event_model(); |
1735 | 1735 | $offset = ($current_page - 1) * $per_page; |
1736 | - $limit = $count ? null : $offset . ',' . $per_page; |
|
1736 | + $limit = $count ? null : $offset.','.$per_page; |
|
1737 | 1737 | $orderby = isset($this->_req_data['orderby']) ? $this->_req_data['orderby'] : 'EVT_ID'; |
1738 | 1738 | $order = isset($this->_req_data['order']) ? $this->_req_data['order'] : "DESC"; |
1739 | 1739 | if (isset($this->_req_data['month_range'])) { |
@@ -1767,7 +1767,7 @@ discard block |
||
1767 | 1767 | $start_formats = EEM_Datetime::instance()->get_formats_for('DTT_EVT_start'); |
1768 | 1768 | if (isset($this->_req_data['month_range']) && $this->_req_data['month_range'] != '') { |
1769 | 1769 | $DateTime = new DateTime( |
1770 | - $year_r . '-' . $month_r . '-01 00:00:00', |
|
1770 | + $year_r.'-'.$month_r.'-01 00:00:00', |
|
1771 | 1771 | new DateTimeZone(EEM_Datetime::instance()->get_timezone()) |
1772 | 1772 | ); |
1773 | 1773 | $start = $DateTime->format(implode(' ', $start_formats)); |
@@ -1813,7 +1813,7 @@ discard block |
||
1813 | 1813 | } |
1814 | 1814 | //search query handling |
1815 | 1815 | if (isset($this->_req_data['s'])) { |
1816 | - $search_string = '%' . $this->_req_data['s'] . '%'; |
|
1816 | + $search_string = '%'.$this->_req_data['s'].'%'; |
|
1817 | 1817 | $where['OR'] = array( |
1818 | 1818 | 'EVT_name' => array('LIKE', $search_string), |
1819 | 1819 | 'EVT_desc' => array('LIKE', $search_string), |
@@ -1947,7 +1947,7 @@ discard block |
||
1947 | 1947 | if ( ! empty($event_status)) { |
1948 | 1948 | $success = true; |
1949 | 1949 | //determine the event id and set to array. |
1950 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
1950 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
1951 | 1951 | // loop thru events |
1952 | 1952 | foreach ($EVT_IDs as $EVT_ID) { |
1953 | 1953 | if ($EVT_ID = absint($EVT_ID)) { |
@@ -2095,7 +2095,7 @@ discard block |
||
2095 | 2095 | // get list of events with no prices |
2096 | 2096 | $espresso_no_ticket_prices = get_option('ee_no_ticket_prices', array()); |
2097 | 2097 | //determine the event id and set to array. |
2098 | - $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array)$this->_req_data['EVT_IDs'] : array(); |
|
2098 | + $EVT_IDs = isset($this->_req_data['EVT_IDs']) ? (array) $this->_req_data['EVT_IDs'] : array(); |
|
2099 | 2099 | // loop thru events |
2100 | 2100 | foreach ($EVT_IDs as $EVT_ID) { |
2101 | 2101 | $EVT_ID = absint($EVT_ID); |
@@ -2278,7 +2278,7 @@ discard block |
||
2278 | 2278 | $this->_set_add_edit_form_tags('update_default_event_settings'); |
2279 | 2279 | $this->_set_publish_post_box_vars(null, false, false, null, false); |
2280 | 2280 | $this->_template_args['admin_page_content'] = EEH_Template::display_template( |
2281 | - EVENTS_TEMPLATE_PATH . 'event_settings.template.php', |
|
2281 | + EVENTS_TEMPLATE_PATH.'event_settings.template.php', |
|
2282 | 2282 | $this->_template_args, |
2283 | 2283 | true |
2284 | 2284 | ); |
@@ -2323,10 +2323,10 @@ discard block |
||
2323 | 2323 | . 'caffeinated_template_features.jpg" alt="' |
2324 | 2324 | . esc_attr__('Template Settings Preview screenshot', 'event_espresso') |
2325 | 2325 | . '" />'; |
2326 | - $this->_template_args['preview_text'] = '<strong>' . esc_html__( |
|
2326 | + $this->_template_args['preview_text'] = '<strong>'.esc_html__( |
|
2327 | 2327 | '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.', |
2328 | 2328 | 'event_espresso' |
2329 | - ) . '</strong>'; |
|
2329 | + ).'</strong>'; |
|
2330 | 2330 | $this->display_admin_caf_preview_page('template_settings_tab'); |
2331 | 2331 | } |
2332 | 2332 | |
@@ -2375,7 +2375,7 @@ discard block |
||
2375 | 2375 | { |
2376 | 2376 | do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
2377 | 2377 | $this->_search_btn_label = esc_html__('Categories', 'event_espresso'); |
2378 | - $this->_admin_page_title .= ' ' . $this->get_action_link_or_button( |
|
2378 | + $this->_admin_page_title .= ' '.$this->get_action_link_or_button( |
|
2379 | 2379 | 'add_category', |
2380 | 2380 | 'add_category', |
2381 | 2381 | array(), |
@@ -2451,7 +2451,7 @@ discard block |
||
2451 | 2451 | 'disable' => '', |
2452 | 2452 | 'disabled_message' => false, |
2453 | 2453 | ); |
2454 | - $template = EVENTS_TEMPLATE_PATH . 'event_category_details.template.php'; |
|
2454 | + $template = EVENTS_TEMPLATE_PATH.'event_category_details.template.php'; |
|
2455 | 2455 | return EEH_Template::display_template($template, $template_args, true); |
2456 | 2456 | } |
2457 | 2457 | |
@@ -2459,8 +2459,8 @@ discard block |
||
2459 | 2459 | |
2460 | 2460 | protected function _delete_categories() |
2461 | 2461 | { |
2462 | - $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array)$this->_req_data['EVT_CAT_ID'] |
|
2463 | - : (array)$this->_req_data['category_id']; |
|
2462 | + $cat_ids = isset($this->_req_data['EVT_CAT_ID']) ? (array) $this->_req_data['EVT_CAT_ID'] |
|
2463 | + : (array) $this->_req_data['category_id']; |
|
2464 | 2464 | foreach ($cat_ids as $cat_id) { |
2465 | 2465 | $this->_delete_category($cat_id); |
2466 | 2466 | } |
@@ -2561,7 +2561,7 @@ discard block |
||
2561 | 2561 | $limit = ($current_page - 1) * $per_page; |
2562 | 2562 | $where = array('taxonomy' => 'espresso_event_categories'); |
2563 | 2563 | if (isset($this->_req_data['s'])) { |
2564 | - $sstr = '%' . $this->_req_data['s'] . '%'; |
|
2564 | + $sstr = '%'.$this->_req_data['s'].'%'; |
|
2565 | 2565 | $where['OR'] = array( |
2566 | 2566 | 'Term.name' => array('LIKE', $sstr), |
2567 | 2567 | 'description' => array('LIKE', $sstr), |
@@ -2570,7 +2570,7 @@ discard block |
||
2570 | 2570 | $query_params = array( |
2571 | 2571 | $where, |
2572 | 2572 | 'order_by' => array($orderby => $order), |
2573 | - 'limit' => $limit . ',' . $per_page, |
|
2573 | + 'limit' => $limit.','.$per_page, |
|
2574 | 2574 | 'force_join' => array('Term'), |
2575 | 2575 | ); |
2576 | 2576 | $categories = $count |
@@ -22,15 +22,15 @@ discard block |
||
22 | 22 | */ |
23 | 23 | class EED_Ticket_Selector extends EED_Module { |
24 | 24 | |
25 | - /** |
|
26 | - * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
|
27 | - */ |
|
28 | - private static $ticket_selector; |
|
25 | + /** |
|
26 | + * @var EventEspresso\modules\ticket_selector\DisplayTicketSelector $ticket_selector |
|
27 | + */ |
|
28 | + private static $ticket_selector; |
|
29 | 29 | |
30 | - /** |
|
31 | - * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
|
32 | - */ |
|
33 | - private static $iframe_embed_button; |
|
30 | + /** |
|
31 | + * @var EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton $iframe_embed_button |
|
32 | + */ |
|
33 | + private static $iframe_embed_button; |
|
34 | 34 | |
35 | 35 | |
36 | 36 | |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ), |
83 | 83 | 10 |
84 | 84 | ); |
85 | - } |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | 88 | |
@@ -99,23 +99,23 @@ discard block |
||
99 | 99 | //if config is not set, initialize |
100 | 100 | //If config is not set, set it. |
101 | 101 | if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
102 | - \EED_Ticket_Selector::instance()->set_config(); |
|
103 | - \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
102 | + \EED_Ticket_Selector::instance()->set_config(); |
|
103 | + \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
|
104 | 104 | } |
105 | 105 | } |
106 | 106 | |
107 | 107 | |
108 | 108 | |
109 | 109 | /** |
110 | - * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
|
111 | - */ |
|
112 | - public static function ticketSelector() |
|
113 | - { |
|
114 | - if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
115 | - EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(); |
|
116 | - } |
|
117 | - return EED_Ticket_Selector::$ticket_selector; |
|
118 | - } |
|
110 | + * @return \EventEspresso\modules\ticket_selector\DisplayTicketSelector |
|
111 | + */ |
|
112 | + public static function ticketSelector() |
|
113 | + { |
|
114 | + if ( ! EED_Ticket_Selector::$ticket_selector instanceof DisplayTicketSelector) { |
|
115 | + EED_Ticket_Selector::$ticket_selector = new DisplayTicketSelector(); |
|
116 | + } |
|
117 | + return EED_Ticket_Selector::$ticket_selector; |
|
118 | + } |
|
119 | 119 | |
120 | 120 | |
121 | 121 | /** |
@@ -168,15 +168,15 @@ discard block |
||
168 | 168 | |
169 | 169 | |
170 | 170 | |
171 | - /** |
|
172 | - * creates buttons for selecting number of attendees for an event |
|
173 | - * |
|
174 | - * @access public |
|
175 | - * @param WP_Post|int $event |
|
176 | - * @param bool $view_details |
|
177 | - * @return string |
|
178 | - * @throws \EE_Error |
|
179 | - */ |
|
171 | + /** |
|
172 | + * creates buttons for selecting number of attendees for an event |
|
173 | + * |
|
174 | + * @access public |
|
175 | + * @param WP_Post|int $event |
|
176 | + * @param bool $view_details |
|
177 | + * @return string |
|
178 | + * @throws \EE_Error |
|
179 | + */ |
|
180 | 180 | public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
181 | 181 | return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details ); |
182 | 182 | } |
@@ -199,11 +199,11 @@ discard block |
||
199 | 199 | |
200 | 200 | |
201 | 201 | /** |
202 | - * load js |
|
203 | - * |
|
204 | - * @access public |
|
205 | - * @return void |
|
206 | - */ |
|
202 | + * load js |
|
203 | + * |
|
204 | + * @access public |
|
205 | + * @return void |
|
206 | + */ |
|
207 | 207 | public static function load_tckt_slctr_assets() { |
208 | 208 | if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
209 | 209 | // add some style |
@@ -221,129 +221,129 @@ discard block |
||
221 | 221 | |
222 | 222 | |
223 | 223 | |
224 | - /** |
|
225 | - * @deprecated |
|
226 | - * @return string |
|
227 | - * @throws \EE_Error |
|
228 | - */ |
|
229 | - public static function display_view_details_btn() |
|
230 | - { |
|
231 | - // todo add doing_it_wrong() notice during next major version |
|
232 | - return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
233 | - } |
|
234 | - |
|
235 | - |
|
236 | - |
|
237 | - /** |
|
238 | - * @deprecated |
|
239 | - * @return string |
|
240 | - * @throws \EE_Error |
|
241 | - */ |
|
242 | - public static function display_ticket_selector_submit() |
|
243 | - { |
|
244 | - // todo add doing_it_wrong() notice during next major version |
|
245 | - return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
246 | - } |
|
247 | - |
|
248 | - |
|
249 | - |
|
250 | - /** |
|
251 | - * @deprecated |
|
252 | - * @param string $permalink_string |
|
253 | - * @param int $id |
|
254 | - * @param string $new_title |
|
255 | - * @param string $new_slug |
|
256 | - * @return string |
|
257 | - */ |
|
258 | - public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
259 | - { |
|
260 | - // todo add doing_it_wrong() notice during next major version |
|
261 | - if ( |
|
262 | - \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
263 | - && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
264 | - ) { |
|
265 | - $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
266 | - $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
267 | - } |
|
268 | - return ''; |
|
269 | - } |
|
270 | - |
|
271 | - |
|
272 | - |
|
273 | - /** |
|
274 | - * @deprecated |
|
275 | - * @param int $ID |
|
276 | - * @param string $external_url |
|
277 | - * @return string |
|
278 | - */ |
|
279 | - public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
280 | - { |
|
281 | - // todo add doing_it_wrong() notice during next major version |
|
282 | - return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
283 | - } |
|
284 | - |
|
285 | - |
|
286 | - |
|
287 | - /** |
|
288 | - * @deprecated |
|
289 | - * @return string |
|
290 | - */ |
|
291 | - public static function ticket_selector_form_close() |
|
292 | - { |
|
293 | - // todo add doing_it_wrong() notice during next major version |
|
294 | - return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
295 | - } |
|
296 | - |
|
297 | - |
|
298 | - |
|
299 | - /** |
|
300 | - * @deprecated |
|
301 | - * @return string |
|
302 | - */ |
|
303 | - public static function no_tkt_slctr_end_dv() |
|
304 | - { |
|
305 | - // todo add doing_it_wrong() notice during next major version |
|
306 | - return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
307 | - } |
|
308 | - |
|
309 | - |
|
310 | - |
|
311 | - /** |
|
312 | - * @deprecated 4.9.13 |
|
313 | - * @return string |
|
314 | - */ |
|
315 | - public static function tkt_slctr_end_dv() |
|
316 | - { |
|
317 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
318 | - } |
|
319 | - |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * @deprecated |
|
324 | - * @return string |
|
325 | - */ |
|
326 | - public static function clear_tkt_slctr() |
|
327 | - { |
|
328 | - return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
329 | - } |
|
330 | - |
|
331 | - |
|
332 | - |
|
333 | - /** |
|
334 | - * @deprecated |
|
335 | - */ |
|
336 | - public static function load_tckt_slctr_assets_admin() |
|
337 | - { |
|
338 | - // todo add doing_it_wrong() notice during next major version |
|
339 | - if ( |
|
340 | - \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
341 | - && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
342 | - ) { |
|
343 | - $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
344 | - $iframe_embed_button->embedButtonAssets(); |
|
345 | - } |
|
346 | - } |
|
224 | + /** |
|
225 | + * @deprecated |
|
226 | + * @return string |
|
227 | + * @throws \EE_Error |
|
228 | + */ |
|
229 | + public static function display_view_details_btn() |
|
230 | + { |
|
231 | + // todo add doing_it_wrong() notice during next major version |
|
232 | + return EED_Ticket_Selector::ticketSelector()->displayViewDetailsButton(); |
|
233 | + } |
|
234 | + |
|
235 | + |
|
236 | + |
|
237 | + /** |
|
238 | + * @deprecated |
|
239 | + * @return string |
|
240 | + * @throws \EE_Error |
|
241 | + */ |
|
242 | + public static function display_ticket_selector_submit() |
|
243 | + { |
|
244 | + // todo add doing_it_wrong() notice during next major version |
|
245 | + return EED_Ticket_Selector::ticketSelector()->displaySubmitButton(); |
|
246 | + } |
|
247 | + |
|
248 | + |
|
249 | + |
|
250 | + /** |
|
251 | + * @deprecated |
|
252 | + * @param string $permalink_string |
|
253 | + * @param int $id |
|
254 | + * @param string $new_title |
|
255 | + * @param string $new_slug |
|
256 | + * @return string |
|
257 | + */ |
|
258 | + public static function iframe_code_button($permalink_string, $id, $new_title = '', $new_slug = '') |
|
259 | + { |
|
260 | + // todo add doing_it_wrong() notice during next major version |
|
261 | + if ( |
|
262 | + \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
263 | + && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
264 | + ) { |
|
265 | + $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
266 | + $iframe_embed_button->addEventEditorIframeEmbedButton(); |
|
267 | + } |
|
268 | + return ''; |
|
269 | + } |
|
270 | + |
|
271 | + |
|
272 | + |
|
273 | + /** |
|
274 | + * @deprecated |
|
275 | + * @param int $ID |
|
276 | + * @param string $external_url |
|
277 | + * @return string |
|
278 | + */ |
|
279 | + public static function ticket_selector_form_open($ID = 0, $external_url = '') |
|
280 | + { |
|
281 | + // todo add doing_it_wrong() notice during next major version |
|
282 | + return EED_Ticket_Selector::ticketSelector()->formOpen($ID, $external_url); |
|
283 | + } |
|
284 | + |
|
285 | + |
|
286 | + |
|
287 | + /** |
|
288 | + * @deprecated |
|
289 | + * @return string |
|
290 | + */ |
|
291 | + public static function ticket_selector_form_close() |
|
292 | + { |
|
293 | + // todo add doing_it_wrong() notice during next major version |
|
294 | + return EED_Ticket_Selector::ticketSelector()->formClose(); |
|
295 | + } |
|
296 | + |
|
297 | + |
|
298 | + |
|
299 | + /** |
|
300 | + * @deprecated |
|
301 | + * @return string |
|
302 | + */ |
|
303 | + public static function no_tkt_slctr_end_dv() |
|
304 | + { |
|
305 | + // todo add doing_it_wrong() notice during next major version |
|
306 | + return EED_Ticket_Selector::ticketSelector()->ticketSelectorEndDiv(); |
|
307 | + } |
|
308 | + |
|
309 | + |
|
310 | + |
|
311 | + /** |
|
312 | + * @deprecated 4.9.13 |
|
313 | + * @return string |
|
314 | + */ |
|
315 | + public static function tkt_slctr_end_dv() |
|
316 | + { |
|
317 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
318 | + } |
|
319 | + |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * @deprecated |
|
324 | + * @return string |
|
325 | + */ |
|
326 | + public static function clear_tkt_slctr() |
|
327 | + { |
|
328 | + return EED_Ticket_Selector::ticketSelector()->clearTicketSelector(); |
|
329 | + } |
|
330 | + |
|
331 | + |
|
332 | + |
|
333 | + /** |
|
334 | + * @deprecated |
|
335 | + */ |
|
336 | + public static function load_tckt_slctr_assets_admin() |
|
337 | + { |
|
338 | + // todo add doing_it_wrong() notice during next major version |
|
339 | + if ( |
|
340 | + \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
341 | + && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
342 | + ) { |
|
343 | + $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
|
344 | + $iframe_embed_button->embedButtonAssets(); |
|
345 | + } |
|
346 | + } |
|
347 | 347 | |
348 | 348 | |
349 | 349 | } |
@@ -3,8 +3,8 @@ discard block |
||
3 | 3 | use EventEspresso\modules\ticket_selector\TicketSelectorIframe; |
4 | 4 | use EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
7 | - exit( 'No direct script access allowed' ); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
7 | + exit('No direct script access allowed'); |
|
8 | 8 | } |
9 | 9 | |
10 | 10 | |
@@ -38,15 +38,15 @@ discard block |
||
38 | 38 | * @return EED_Ticket_Selector |
39 | 39 | */ |
40 | 40 | public static function instance() { |
41 | - return parent::get_instance( __CLASS__ ); |
|
41 | + return parent::get_instance(__CLASS__); |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | |
45 | 45 | |
46 | - protected function set_config(){ |
|
47 | - $this->set_config_section( 'template_settings' ); |
|
48 | - $this->set_config_class( 'EE_Ticket_Selector_Config' ); |
|
49 | - $this->set_config_name( 'EED_Ticket_Selector' ); |
|
46 | + protected function set_config() { |
|
47 | + $this->set_config_section('template_settings'); |
|
48 | + $this->set_config_class('EE_Ticket_Selector_Config'); |
|
49 | + $this->set_config_name('EED_Ticket_Selector'); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | public static function set_hooks() { |
61 | 61 | // routing |
62 | - EE_Config::register_route( 'iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector' ); |
|
63 | - EE_Config::register_route( 'process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections' ); |
|
64 | - add_action( 'wp_loaded', array( 'EED_Ticket_Selector', 'set_definitions' ), 2 ); |
|
65 | - add_action( 'AHEE_event_details_header_bottom', array( 'EED_Ticket_Selector', 'display_ticket_selector' ), 10, 1 ); |
|
66 | - add_action( 'wp_enqueue_scripts', array( 'EED_Ticket_Selector', 'load_tckt_slctr_assets' ), 10 ); |
|
62 | + EE_Config::register_route('iframe', 'EED_Ticket_Selector', 'ticket_selector_iframe', 'ticket_selector'); |
|
63 | + EE_Config::register_route('process_ticket_selections', 'EED_Ticket_Selector', 'process_ticket_selections'); |
|
64 | + add_action('wp_loaded', array('EED_Ticket_Selector', 'set_definitions'), 2); |
|
65 | + add_action('AHEE_event_details_header_bottom', array('EED_Ticket_Selector', 'display_ticket_selector'), 10, 1); |
|
66 | + add_action('wp_enqueue_scripts', array('EED_Ticket_Selector', 'load_tckt_slctr_assets'), 10); |
|
67 | 67 | } |
68 | 68 | |
69 | 69 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | // to load assets for "espresso_events" page on the "edit" route (action) |
80 | 80 | add_action( |
81 | 81 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__edit', |
82 | - array( 'EED_Ticket_Selector', 'ticket_selector_iframe_embed_button' ), |
|
82 | + array('EED_Ticket_Selector', 'ticket_selector_iframe_embed_button'), |
|
83 | 83 | 10 |
84 | 84 | ); |
85 | 85 | } |
@@ -93,12 +93,12 @@ discard block |
||
93 | 93 | * @return void |
94 | 94 | */ |
95 | 95 | public static function set_definitions() { |
96 | - define( 'TICKET_SELECTOR_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
97 | - define( 'TICKET_SELECTOR_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
96 | + define('TICKET_SELECTOR_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
97 | + define('TICKET_SELECTOR_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
98 | 98 | |
99 | 99 | //if config is not set, initialize |
100 | 100 | //If config is not set, set it. |
101 | - if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config ) { |
|
101 | + if ( ! EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector instanceof EE_Ticket_Selector_Config) { |
|
102 | 102 | \EED_Ticket_Selector::instance()->set_config(); |
103 | 103 | \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector = \EED_Ticket_Selector::instance()->config(); |
104 | 104 | } |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | * @param WP $WP |
126 | 126 | * @return void |
127 | 127 | */ |
128 | - public function run( $WP ) {} |
|
128 | + public function run($WP) {} |
|
129 | 129 | |
130 | 130 | |
131 | 131 | |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | * @return \EventEspresso\modules\ticket_selector\TicketSelectorIframeEmbedButton |
134 | 134 | */ |
135 | 135 | public static function getIframeEmbedButton() { |
136 | - if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton ) { |
|
136 | + if ( ! self::$iframe_embed_button instanceof TicketSelectorIframeEmbedButton) { |
|
137 | 137 | self::$iframe_embed_button = new TicketSelectorIframeEmbedButton(); |
138 | 138 | } |
139 | 139 | return self::$iframe_embed_button; |
@@ -177,8 +177,8 @@ discard block |
||
177 | 177 | * @return string |
178 | 178 | * @throws \EE_Error |
179 | 179 | */ |
180 | - public static function display_ticket_selector( $event = NULL, $view_details = FALSE ) { |
|
181 | - return EED_Ticket_Selector::ticketSelector()->display( $event, $view_details ); |
|
180 | + public static function display_ticket_selector($event = NULL, $view_details = FALSE) { |
|
181 | + return EED_Ticket_Selector::ticketSelector()->display($event, $view_details); |
|
182 | 182 | } |
183 | 183 | |
184 | 184 | |
@@ -205,12 +205,12 @@ discard block |
||
205 | 205 | * @return void |
206 | 206 | */ |
207 | 207 | public static function load_tckt_slctr_assets() { |
208 | - if ( apply_filters( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE ) ) { |
|
208 | + if (apply_filters('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', FALSE)) { |
|
209 | 209 | // add some style |
210 | - wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.css'); |
|
210 | + wp_register_style('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.css'); |
|
211 | 211 | wp_enqueue_style('ticket_selector'); |
212 | 212 | // make it dance |
213 | - wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL . 'ticket_selector.js', array('espresso_core'), '', TRUE); |
|
213 | + wp_register_script('ticket_selector', TICKET_SELECTOR_ASSETS_URL.'ticket_selector.js', array('espresso_core'), '', TRUE); |
|
214 | 214 | wp_enqueue_script('ticket_selector'); |
215 | 215 | } |
216 | 216 | } |
@@ -337,8 +337,8 @@ discard block |
||
337 | 337 | { |
338 | 338 | // todo add doing_it_wrong() notice during next major version |
339 | 339 | if ( |
340 | - \EE_Registry::instance()->REQ->get( 'page' ) === 'espresso_events' |
|
341 | - && \EE_Registry::instance()->REQ->get( 'action' ) === 'edit' |
|
340 | + \EE_Registry::instance()->REQ->get('page') === 'espresso_events' |
|
341 | + && \EE_Registry::instance()->REQ->get('action') === 'edit' |
|
342 | 342 | ) { |
343 | 343 | $iframe_embed_button = \EED_Ticket_Selector::getIframeEmbedButton(); |
344 | 344 | $iframe_embed_button->embedButtonAssets(); |