@@ -105,41 +105,41 @@ discard block |
||
105 | 105 | * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any incoming timezone data that gets saved). Note this just sends the timezone info to the date time model field objects. Default is NULL (and will be assumed using the set timezone in the 'timezone_string' wp option) |
106 | 106 | * @return \EEM_Line_Item |
107 | 107 | */ |
108 | - protected function __construct( $timezone ) { |
|
109 | - $this->singular_item = __('Line Item','event_espresso'); |
|
110 | - $this->plural_item = __('Line Items','event_espresso'); |
|
108 | + protected function __construct($timezone) { |
|
109 | + $this->singular_item = __('Line Item', 'event_espresso'); |
|
110 | + $this->plural_item = __('Line Items', 'event_espresso'); |
|
111 | 111 | |
112 | 112 | $this->_tables = array( |
113 | - 'Line_Item'=>new EE_Primary_Table('esp_line_item','LIN_ID') |
|
113 | + 'Line_Item'=>new EE_Primary_Table('esp_line_item', 'LIN_ID') |
|
114 | 114 | ); |
115 | - $line_items_can_be_for = apply_filters( 'FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket','Price', 'Event' ) ); |
|
115 | + $line_items_can_be_for = apply_filters('FHEE__EEM_Line_Item__line_items_can_be_for', array('Ticket', 'Price', 'Event')); |
|
116 | 116 | $this->_fields = array( |
117 | 117 | 'Line_Item' => array( |
118 | - 'LIN_ID' => new EE_Primary_Key_Int_Field( 'LIN_ID', __( "ID", "event_espresso" ) ), |
|
119 | - 'LIN_code' => new EE_Slug_Field( 'LIN_code', __( "Code for index into Cart", "event_espresso" ), TRUE ), |
|
120 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( 'TXN_ID', __( "Transaction ID", "event_espresso" ), TRUE, NULL, 'Transaction' ), |
|
121 | - 'LIN_name' => new EE_Full_HTML_Field( 'LIN_name', __( "Line Item Name", "event_espresso" ), FALSE, '' ), |
|
122 | - 'LIN_desc' => new EE_Full_HTML_Field( 'LIN_desc', __( "Line Item Description", "event_espresso" ), TRUE ), |
|
123 | - 'LIN_unit_price' => new EE_Money_Field( 'LIN_unit_price', __( "Unit Price", "event_espresso" ), FALSE, 0 ), |
|
124 | - 'LIN_percent' => new EE_Float_Field( 'LIN_percent', __( "Percent", "event_espresso" ), FALSE, 0 ), |
|
125 | - 'LIN_is_taxable' => new EE_Boolean_Field( 'LIN_is_taxable', __( "Taxable", "event_espresso" ), FALSE, FALSE ), |
|
126 | - 'LIN_order' => new EE_Integer_Field( 'LIN_order', __( "Order of Application towards total of parent", "event_espresso" ), FALSE, 1 ), |
|
127 | - 'LIN_total' => new EE_Money_Field( 'LIN_total', __( "Total (unit price x quantity)", "event_espresso" ), FALSE, 0 ), |
|
128 | - 'LIN_quantity' => new EE_Integer_Field( 'LIN_quantity', __( "Quantity", "event_espresso" ), TRUE, 1 ), |
|
129 | - 'LIN_parent' => new EE_Integer_Field( 'LIN_parent', __( "Parent ID (this item goes towards that Line Item's total)", "event_espresso" ), TRUE, NULL ), |
|
130 | - 'LIN_type' => new EE_Enum_Text_Field( 'LIN_type', __( "Type", "event_espresso" ), FALSE, 'line-item', array( |
|
118 | + 'LIN_ID' => new EE_Primary_Key_Int_Field('LIN_ID', __("ID", "event_espresso")), |
|
119 | + 'LIN_code' => new EE_Slug_Field('LIN_code', __("Code for index into Cart", "event_espresso"), TRUE), |
|
120 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field('TXN_ID', __("Transaction ID", "event_espresso"), TRUE, NULL, 'Transaction'), |
|
121 | + 'LIN_name' => new EE_Full_HTML_Field('LIN_name', __("Line Item Name", "event_espresso"), FALSE, ''), |
|
122 | + 'LIN_desc' => new EE_Full_HTML_Field('LIN_desc', __("Line Item Description", "event_espresso"), TRUE), |
|
123 | + 'LIN_unit_price' => new EE_Money_Field('LIN_unit_price', __("Unit Price", "event_espresso"), FALSE, 0), |
|
124 | + 'LIN_percent' => new EE_Float_Field('LIN_percent', __("Percent", "event_espresso"), FALSE, 0), |
|
125 | + 'LIN_is_taxable' => new EE_Boolean_Field('LIN_is_taxable', __("Taxable", "event_espresso"), FALSE, FALSE), |
|
126 | + 'LIN_order' => new EE_Integer_Field('LIN_order', __("Order of Application towards total of parent", "event_espresso"), FALSE, 1), |
|
127 | + 'LIN_total' => new EE_Money_Field('LIN_total', __("Total (unit price x quantity)", "event_espresso"), FALSE, 0), |
|
128 | + 'LIN_quantity' => new EE_Integer_Field('LIN_quantity', __("Quantity", "event_espresso"), TRUE, 1), |
|
129 | + 'LIN_parent' => new EE_Integer_Field('LIN_parent', __("Parent ID (this item goes towards that Line Item's total)", "event_espresso"), TRUE, NULL), |
|
130 | + 'LIN_type' => new EE_Enum_Text_Field('LIN_type', __("Type", "event_espresso"), FALSE, 'line-item', array( |
|
131 | 131 | self::type_line_item => __("Line Item", "event_espresso"), |
132 | 132 | self::type_sub_line_item => __("Sub-Item", "event_espresso"), |
133 | 133 | self::type_sub_total => __("Subtotal", "event_espresso"), |
134 | 134 | self::type_tax_sub_total => __("Tax Subtotal", "event_espresso"), |
135 | 135 | self::type_tax => __("Tax", "event_espresso"), |
136 | 136 | self::type_total => __("Total", "event_espresso"), |
137 | - self::type_cancellation => __( 'Cancellation', 'event_espresso' ) |
|
137 | + self::type_cancellation => __('Cancellation', 'event_espresso') |
|
138 | 138 | ) |
139 | 139 | ), |
140 | - 'OBJ_ID' => new EE_Foreign_Key_Int_Field( 'OBJ_ID', __( 'ID of Item purchased.', 'event_espresso' ), TRUE, NULL, $line_items_can_be_for ), |
|
141 | - 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field( 'OBJ_type', __( "Model Name this Line Item is for", "event_espresso" ), TRUE, NULL, $line_items_can_be_for ), |
|
142 | - 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created','event_espresso'), false, EE_Datetime_Field::now, $timezone ), |
|
140 | + 'OBJ_ID' => new EE_Foreign_Key_Int_Field('OBJ_ID', __('ID of Item purchased.', 'event_espresso'), TRUE, NULL, $line_items_can_be_for), |
|
141 | + 'OBJ_type' =>new EE_Any_Foreign_Model_Name_Field('OBJ_type', __("Model Name this Line Item is for", "event_espresso"), TRUE, NULL, $line_items_can_be_for), |
|
142 | + 'LIN_timestamp' => new EE_Datetime_Field('LIN_timestamp', __('When the line item was created', 'event_espresso'), false, EE_Datetime_Field::now, $timezone), |
|
143 | 143 | ) |
144 | 144 | ); |
145 | 145 | $this->_model_relations = array( |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | ); |
151 | 151 | $this->_model_chain_to_wp_user = 'Transaction.Registration.Event'; |
152 | 152 | $this->_caps_slug = 'transactions'; |
153 | - parent::__construct( $timezone ); |
|
153 | + parent::__construct($timezone); |
|
154 | 154 | } |
155 | 155 | |
156 | 156 | |
@@ -161,9 +161,9 @@ discard block |
||
161 | 161 | * @param EE_Transaction|int $transaction |
162 | 162 | * @return EE_Line_Item[] |
163 | 163 | */ |
164 | - public function get_all_of_type_for_transaction( $line_item_type, $transaction ){ |
|
165 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
166 | - return $this->get_all( array( array( |
|
164 | + public function get_all_of_type_for_transaction($line_item_type, $transaction) { |
|
165 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
166 | + return $this->get_all(array(array( |
|
167 | 167 | 'LIN_type' => $line_item_type, |
168 | 168 | 'TXN_ID' => $transaction |
169 | 169 | ))); |
@@ -177,14 +177,14 @@ discard block |
||
177 | 177 | * @param EE_Transaction|int $transaction |
178 | 178 | * @return EE_Line_Item[] |
179 | 179 | */ |
180 | - public function get_all_non_ticket_line_items_for_transaction( $transaction ) { |
|
181 | - $transaction = EEM_Transaction::instance()->ensure_is_ID( $transaction ); |
|
182 | - return $this->get_all( array( array( |
|
180 | + public function get_all_non_ticket_line_items_for_transaction($transaction) { |
|
181 | + $transaction = EEM_Transaction::instance()->ensure_is_ID($transaction); |
|
182 | + return $this->get_all(array(array( |
|
183 | 183 | 'LIN_type' => self::type_line_item, |
184 | 184 | 'TXN_ID' => $transaction, |
185 | 185 | 'OR' => array( |
186 | - 'OBJ_type*notticket' => array( '!=', 'Ticket'), |
|
187 | - 'OBJ_type*null' => array( 'IS_NULL' )) |
|
186 | + 'OBJ_type*notticket' => array('!=', 'Ticket'), |
|
187 | + 'OBJ_type*null' => array('IS_NULL')) |
|
188 | 188 | ))); |
189 | 189 | } |
190 | 190 | |
@@ -194,7 +194,7 @@ discard block |
||
194 | 194 | * because if there are spam bots afoot there will be LOTS of line items |
195 | 195 | * @return int count of how many deleted |
196 | 196 | */ |
197 | - public function delete_line_items_with_no_transaction(){ |
|
197 | + public function delete_line_items_with_no_transaction() { |
|
198 | 198 | /** @type WPDB $wpdb */ |
199 | 199 | global $wpdb; |
200 | 200 | $time_to_leave_alone = apply_filters( |
@@ -202,13 +202,13 @@ discard block |
||
202 | 202 | ); |
203 | 203 | $query = $wpdb->prepare( |
204 | 204 | 'DELETE li |
205 | - FROM ' . $this->table() . ' li |
|
206 | - LEFT JOIN ' . EEM_Transaction::instance()->table(). ' t ON li.TXN_ID = t.TXN_ID |
|
205 | + FROM ' . $this->table().' li |
|
206 | + LEFT JOIN ' . EEM_Transaction::instance()->table().' t ON li.TXN_ID = t.TXN_ID |
|
207 | 207 | WHERE t.TXN_ID IS NULL AND li.LIN_timestamp < %s', |
208 | 208 | // use GMT time because that's what TXN_timestamps are in |
209 | - date( 'Y-m-d H:i:s', time() - $time_to_leave_alone ) |
|
209 | + date('Y-m-d H:i:s', time() - $time_to_leave_alone) |
|
210 | 210 | ); |
211 | - return $wpdb->query( $query ); |
|
211 | + return $wpdb->query($query); |
|
212 | 212 | } |
213 | 213 | |
214 | 214 | |
@@ -221,10 +221,10 @@ discard block |
||
221 | 221 | * @param \EE_Base_Class $object |
222 | 222 | * @return EE_Line_Item[] |
223 | 223 | */ |
224 | - public function get_line_item_for_transaction_object( $TXN_ID, EE_Base_Class $object ){ |
|
225 | - return $this->get_all( array( array( |
|
224 | + public function get_line_item_for_transaction_object($TXN_ID, EE_Base_Class $object) { |
|
225 | + return $this->get_all(array(array( |
|
226 | 226 | 'TXN_ID' => $TXN_ID, |
227 | - 'OBJ_type' => str_replace( 'EE_', '', get_class( $object )), |
|
227 | + 'OBJ_type' => str_replace('EE_', '', get_class($object)), |
|
228 | 228 | 'OBJ_ID' => $object->ID() |
229 | 229 | ))); |
230 | 230 | } |
@@ -240,16 +240,16 @@ discard block |
||
240 | 240 | * @param array $OBJ_IDs |
241 | 241 | * @return EE_Line_Item[] |
242 | 242 | */ |
243 | - public function get_object_line_items_for_transaction( $TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array() ){ |
|
243 | + public function get_object_line_items_for_transaction($TXN_ID, $OBJ_type = 'Event', $OBJ_IDs = array()) { |
|
244 | 244 | $query_params = array( |
245 | 245 | 'OBJ_type' => $OBJ_type, |
246 | 246 | // if incoming $OBJ_IDs is an array, then make sure it is formatted correctly for the query |
247 | - 'OBJ_ID' => is_array( $OBJ_IDs ) && ! isset( $OBJ_IDs['IN'] ) ? array( 'IN', $OBJ_IDs ) : $OBJ_IDs |
|
247 | + 'OBJ_ID' => is_array($OBJ_IDs) && ! isset($OBJ_IDs['IN']) ? array('IN', $OBJ_IDs) : $OBJ_IDs |
|
248 | 248 | ); |
249 | - if ( $TXN_ID ) { |
|
249 | + if ($TXN_ID) { |
|
250 | 250 | $query_params['TXN_ID'] = $TXN_ID; |
251 | 251 | } |
252 | - return $this->get_all( array( $query_params )); |
|
252 | + return $this->get_all(array($query_params)); |
|
253 | 253 | } |
254 | 254 | |
255 | 255 | |
@@ -260,13 +260,13 @@ discard block |
||
260 | 260 | * @param EE_Transaction $transaction |
261 | 261 | * @return EE_Line_Item[] |
262 | 262 | */ |
263 | - public function get_all_ticket_line_items_for_transaction( EE_Transaction $transaction ) { |
|
264 | - return $this->get_all( array( |
|
263 | + public function get_all_ticket_line_items_for_transaction(EE_Transaction $transaction) { |
|
264 | + return $this->get_all(array( |
|
265 | 265 | array( |
266 | 266 | 'TXN_ID' => $transaction->ID(), |
267 | 267 | 'OBJ_type' => 'Ticket', |
268 | 268 | ) |
269 | - ) ); |
|
269 | + )); |
|
270 | 270 | } |
271 | 271 | |
272 | 272 | |
@@ -278,14 +278,14 @@ discard block |
||
278 | 278 | * @param int $TKT_ID |
279 | 279 | * @return \EE_Line_Item |
280 | 280 | */ |
281 | - public function get_ticket_line_item_for_transaction( $TXN_ID, $TKT_ID ) { |
|
282 | - return $this->get_one( array( |
|
281 | + public function get_ticket_line_item_for_transaction($TXN_ID, $TKT_ID) { |
|
282 | + return $this->get_one(array( |
|
283 | 283 | array( |
284 | - 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID( $TXN_ID ), |
|
284 | + 'TXN_ID' => EEM_Transaction::instance()->ensure_is_ID($TXN_ID), |
|
285 | 285 | 'OBJ_ID' => $TKT_ID, |
286 | 286 | 'OBJ_type' => 'Ticket', |
287 | 287 | ) |
288 | - ) ); |
|
288 | + )); |
|
289 | 289 | } |
290 | 290 | |
291 | 291 | |
@@ -300,8 +300,8 @@ discard block |
||
300 | 300 | * @param EE_Promotion $promotion |
301 | 301 | * @return EE_Line_Item |
302 | 302 | */ |
303 | - public function get_existing_promotion_line_item( EE_Line_Item $parent_line_item, EE_Promotion $promotion ) { |
|
304 | - return $this->get_one( array( |
|
303 | + public function get_existing_promotion_line_item(EE_Line_Item $parent_line_item, EE_Promotion $promotion) { |
|
304 | + return $this->get_one(array( |
|
305 | 305 | array( |
306 | 306 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
307 | 307 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -322,8 +322,8 @@ discard block |
||
322 | 322 | * @param EE_Line_Item $parent_line_item |
323 | 323 | * @return EE_Line_Item[] |
324 | 324 | */ |
325 | - public function get_all_promotion_line_items( EE_Line_Item $parent_line_item ) { |
|
326 | - return $this->get_all( array( |
|
325 | + public function get_all_promotion_line_items(EE_Line_Item $parent_line_item) { |
|
326 | + return $this->get_all(array( |
|
327 | 327 | array( |
328 | 328 | 'TXN_ID' => $parent_line_item->TXN_ID(), |
329 | 329 | 'LIN_parent' => $parent_line_item->ID(), |
@@ -340,8 +340,8 @@ discard block |
||
340 | 340 | * @param EE_Registration $registration |
341 | 341 | * @return EE_Line_ITem |
342 | 342 | */ |
343 | - public function get_line_item_for_registration( EE_Registration $registration ) { |
|
344 | - return $this->get_one( $this->line_item_for_registration_query_params( $registration )); |
|
343 | + public function get_line_item_for_registration(EE_Registration $registration) { |
|
344 | + return $this->get_one($this->line_item_for_registration_query_params($registration)); |
|
345 | 345 | } |
346 | 346 | |
347 | 347 | /** |
@@ -350,14 +350,14 @@ discard block |
||
350 | 350 | * @param array $original_query_params any extra query params you'd like to be merged with |
351 | 351 | * @return array like EEM_Base::get_all()'s $query_params |
352 | 352 | */ |
353 | - public function line_item_for_registration_query_params( EE_Registration $registration, $original_query_params = array() ) { |
|
354 | - return array_replace_recursive( $original_query_params, array( |
|
353 | + public function line_item_for_registration_query_params(EE_Registration $registration, $original_query_params = array()) { |
|
354 | + return array_replace_recursive($original_query_params, array( |
|
355 | 355 | array( |
356 | 356 | 'OBJ_ID' => $registration->ticket_ID(), |
357 | 357 | 'OBJ_type' => 'Ticket', |
358 | 358 | 'TXN_ID' => $registration->transaction_ID() |
359 | 359 | ) |
360 | - ) ); |
|
360 | + )); |
|
361 | 361 | } |
362 | 362 | |
363 | 363 |
@@ -362,62 +362,62 @@ |
||
362 | 362 | |
363 | 363 | |
364 | 364 | |
365 | - /** |
|
366 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
367 | - * @throws \EE_Error |
|
368 | - */ |
|
369 | - public function get_total_line_items_with_no_transaction() |
|
370 | - { |
|
371 | - return $this->get_total_line_items_for_carts(); |
|
372 | - } |
|
373 | - |
|
374 | - |
|
375 | - |
|
376 | - /** |
|
377 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
378 | - * @throws \EE_Error |
|
379 | - */ |
|
380 | - public function get_total_line_items_for_active_carts() |
|
381 | - { |
|
382 | - return $this->get_total_line_items_for_carts(false); |
|
383 | - } |
|
384 | - |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
389 | - * @throws \EE_Error |
|
390 | - */ |
|
391 | - public function get_total_line_items_for_expired_carts() |
|
392 | - { |
|
393 | - return $this->get_total_line_items_for_carts(true); |
|
394 | - } |
|
395 | - |
|
396 | - |
|
397 | - |
|
398 | - /** |
|
399 | - * Returns an array of grand total line items where the TXN_ID is 0. |
|
400 | - * If $expired is set to true, then only line items for expired sessions will be returned. |
|
401 | - * If $expired is set to false, then only line items for active sessions will be returned. |
|
402 | - * |
|
403 | - * @param bool|null $expired |
|
404 | - * @return EE_Base_Class[]|EE_Line_Item[] |
|
405 | - * @throws \EE_Error |
|
406 | - */ |
|
407 | - private function get_total_line_items_for_carts($expired = null) |
|
408 | - { |
|
409 | - $where_params = array( |
|
410 | - 'TXN_ID' => 0, |
|
411 | - 'LIN_type' => 'total', |
|
412 | - ); |
|
413 | - if ($expired !== null) { |
|
414 | - $where_params['LIN_timestamp'] = array( |
|
415 | - $expired ? '<=' : '>', |
|
416 | - time() - EE_Registry::instance()->SSN->lifespan(), |
|
417 | - ); |
|
418 | - } |
|
419 | - return $this->get_all(array($where_params)); |
|
420 | - } |
|
365 | + /** |
|
366 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
367 | + * @throws \EE_Error |
|
368 | + */ |
|
369 | + public function get_total_line_items_with_no_transaction() |
|
370 | + { |
|
371 | + return $this->get_total_line_items_for_carts(); |
|
372 | + } |
|
373 | + |
|
374 | + |
|
375 | + |
|
376 | + /** |
|
377 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
378 | + * @throws \EE_Error |
|
379 | + */ |
|
380 | + public function get_total_line_items_for_active_carts() |
|
381 | + { |
|
382 | + return $this->get_total_line_items_for_carts(false); |
|
383 | + } |
|
384 | + |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
389 | + * @throws \EE_Error |
|
390 | + */ |
|
391 | + public function get_total_line_items_for_expired_carts() |
|
392 | + { |
|
393 | + return $this->get_total_line_items_for_carts(true); |
|
394 | + } |
|
395 | + |
|
396 | + |
|
397 | + |
|
398 | + /** |
|
399 | + * Returns an array of grand total line items where the TXN_ID is 0. |
|
400 | + * If $expired is set to true, then only line items for expired sessions will be returned. |
|
401 | + * If $expired is set to false, then only line items for active sessions will be returned. |
|
402 | + * |
|
403 | + * @param bool|null $expired |
|
404 | + * @return EE_Base_Class[]|EE_Line_Item[] |
|
405 | + * @throws \EE_Error |
|
406 | + */ |
|
407 | + private function get_total_line_items_for_carts($expired = null) |
|
408 | + { |
|
409 | + $where_params = array( |
|
410 | + 'TXN_ID' => 0, |
|
411 | + 'LIN_type' => 'total', |
|
412 | + ); |
|
413 | + if ($expired !== null) { |
|
414 | + $where_params['LIN_timestamp'] = array( |
|
415 | + $expired ? '<=' : '>', |
|
416 | + time() - EE_Registry::instance()->SSN->lifespan(), |
|
417 | + ); |
|
418 | + } |
|
419 | + return $this->get_all(array($where_params)); |
|
420 | + } |
|
421 | 421 | |
422 | 422 | |
423 | 423 |
@@ -249,7 +249,7 @@ discard block |
||
249 | 249 | |
250 | 250 | /** |
251 | 251 | * @access public |
252 | - * @return string |
|
252 | + * @return boolean |
|
253 | 253 | */ |
254 | 254 | public static function is_iframe() { |
255 | 255 | return \EED_Events_Archive::$iframe; |
@@ -722,7 +722,7 @@ discard block |
||
722 | 722 | * display_description |
723 | 723 | * |
724 | 724 | * @access public |
725 | - * @param $value |
|
725 | + * @param integer $value |
|
726 | 726 | * @return bool |
727 | 727 | */ |
728 | 728 | public static function display_description( $value ) { |
@@ -37,19 +37,19 @@ discard block |
||
37 | 37 | */ |
38 | 38 | protected static $using_get_the_excerpt = false; |
39 | 39 | |
40 | - /** |
|
41 | - * Used to flag when the event list is being called from an external iframe. |
|
42 | - * |
|
43 | - * @var bool $iframe |
|
44 | - */ |
|
45 | - protected static $iframe = false; |
|
46 | - |
|
47 | - /** |
|
40 | + /** |
|
41 | + * Used to flag when the event list is being called from an external iframe. |
|
42 | + * |
|
43 | + * @var bool $iframe |
|
44 | + */ |
|
45 | + protected static $iframe = false; |
|
46 | + |
|
47 | + /** |
|
48 | 48 | * @var \EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton $_iframe_embed_button |
49 | 49 | */ |
50 | 50 | private static $_iframe_embed_button; |
51 | 51 | |
52 | - /** |
|
52 | + /** |
|
53 | 53 | * @type EE_Template_Part_Manager $template_parts |
54 | 54 | */ |
55 | 55 | protected $template_parts; |
@@ -233,36 +233,36 @@ discard block |
||
233 | 233 | |
234 | 234 | |
235 | 235 | |
236 | - /** |
|
237 | - * @access public |
|
238 | - * @return void |
|
239 | - * @throws \EE_Error |
|
240 | - * @throws \DomainException |
|
241 | - */ |
|
236 | + /** |
|
237 | + * @access public |
|
238 | + * @return void |
|
239 | + * @throws \EE_Error |
|
240 | + * @throws \DomainException |
|
241 | + */ |
|
242 | 242 | public function event_list_iframe() { |
243 | - \EED_Events_Archive::$iframe = true; |
|
243 | + \EED_Events_Archive::$iframe = true; |
|
244 | 244 | $event_list_iframe = new EventsArchiveIframe( $this ); |
245 | 245 | $event_list_iframe->display(); |
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | 249 | |
250 | - /** |
|
251 | - * @access public |
|
252 | - * @return string |
|
253 | - */ |
|
250 | + /** |
|
251 | + * @access public |
|
252 | + * @return string |
|
253 | + */ |
|
254 | 254 | public static function is_iframe() { |
255 | - return \EED_Events_Archive::$iframe; |
|
255 | + return \EED_Events_Archive::$iframe; |
|
256 | 256 | } |
257 | 257 | |
258 | 258 | |
259 | 259 | |
260 | - /** |
|
261 | - * @access public |
|
262 | - * @return string |
|
263 | - */ |
|
260 | + /** |
|
261 | + * @access public |
|
262 | + * @return string |
|
263 | + */ |
|
264 | 264 | public static function link_target() { |
265 | - return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
265 | + return \EED_Events_Archive::$iframe ? ' target="_blank"' : ''; |
|
266 | 266 | } |
267 | 267 | |
268 | 268 | |
@@ -600,7 +600,7 @@ discard block |
||
600 | 600 | * @return void |
601 | 601 | */ |
602 | 602 | public function load_event_list_assets() { |
603 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
603 | + do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
604 | 604 | add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
605 | 605 | add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
606 | 606 | add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
@@ -3,7 +3,7 @@ discard block |
||
3 | 3 | use EventEspresso\core\libraries\iframe_display\EventListIframeEmbedButton; |
4 | 4 | use EventEspresso\modules\events_archive\EventsArchiveIframe; |
5 | 5 | |
6 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
6 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) exit('No direct script access allowed'); |
|
7 | 7 | /** |
8 | 8 | * Event Espresso |
9 | 9 | * |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return EED_Events_Archive |
61 | 61 | */ |
62 | 62 | public static function instance() { |
63 | - return parent::get_instance( __CLASS__ ); |
|
63 | + return parent::get_instance(__CLASS__); |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | |
@@ -72,10 +72,10 @@ discard block |
||
72 | 72 | * @return void |
73 | 73 | */ |
74 | 74 | public static function set_hooks() { |
75 | - EE_Config::register_route( EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run' ); |
|
76 | - EE_Config::register_route( 'event_list', 'Events_Archive', 'event_list' ); |
|
77 | - EE_Config::register_route( 'iframe', 'Events_Archive', 'event_list_iframe', 'event_list' ); |
|
78 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
75 | + EE_Config::register_route(EE_Registry::instance()->CFG->core->event_cpt_slug, 'Events_Archive', 'run'); |
|
76 | + EE_Config::register_route('event_list', 'Events_Archive', 'event_list'); |
|
77 | + EE_Config::register_route('iframe', 'Events_Archive', 'event_list_iframe', 'event_list'); |
|
78 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | /** |
@@ -85,12 +85,12 @@ discard block |
||
85 | 85 | * @return void |
86 | 86 | */ |
87 | 87 | public static function set_hooks_admin() { |
88 | - add_action( 'wp_loaded', array( 'EED_Events_Archive', 'set_definitions' ), 2 ); |
|
88 | + add_action('wp_loaded', array('EED_Events_Archive', 'set_definitions'), 2); |
|
89 | 89 | // hook into the end of the \EE_Admin_Page::_load_page_dependencies() |
90 | 90 | // to load assets for "espresso_events" page on the "default" route (action) |
91 | 91 | add_action( |
92 | 92 | 'FHEE__EE_Admin_Page___load_page_dependencies__after_load__espresso_events__default', |
93 | - array( 'EED_Events_Archive', 'event_list_iframe_embed_button' ), |
|
93 | + array('EED_Events_Archive', 'event_list_iframe_embed_button'), |
|
94 | 94 | 10 |
95 | 95 | ); |
96 | 96 | } |
@@ -105,8 +105,8 @@ discard block |
||
105 | 105 | * @return void |
106 | 106 | */ |
107 | 107 | public static function set_definitions() { |
108 | - define( 'EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url( __FILE__ ) . 'assets' . DS ); |
|
109 | - define( 'EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace( '\\', DS, plugin_dir_path( __FILE__ )) . 'templates' . DS ); |
|
108 | + define('EVENTS_ARCHIVE_ASSETS_URL', plugin_dir_url(__FILE__).'assets'.DS); |
|
109 | + define('EVENTS_ARCHIVE_TEMPLATES_PATH', str_replace('\\', DS, plugin_dir_path(__FILE__)).'templates'.DS); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | |
@@ -114,10 +114,10 @@ discard block |
||
114 | 114 | /** |
115 | 115 | * set up EE_Events_Archive_Config |
116 | 116 | */ |
117 | - protected function set_config(){ |
|
118 | - $this->set_config_section( 'template_settings' ); |
|
119 | - $this->set_config_class( 'EE_Events_Archive_Config' ); |
|
120 | - $this->set_config_name( 'EED_Events_Archive' ); |
|
117 | + protected function set_config() { |
|
118 | + $this->set_config_section('template_settings'); |
|
119 | + $this->set_config_class('EE_Events_Archive_Config'); |
|
120 | + $this->set_config_name('EED_Events_Archive'); |
|
121 | 121 | } |
122 | 122 | |
123 | 123 | |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | * @return EventListIframeEmbedButton |
127 | 127 | */ |
128 | 128 | public static function get_iframe_embed_button() { |
129 | - if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton ) { |
|
129 | + if ( ! self::$_iframe_embed_button instanceof EventListIframeEmbedButton) { |
|
130 | 130 | self::$_iframe_embed_button = new EventListIframeEmbedButton(); |
131 | 131 | } |
132 | 132 | return self::$_iframe_embed_button; |
@@ -152,35 +152,35 @@ discard block |
||
152 | 152 | * @param \EE_Events_Archive_Config $config |
153 | 153 | * @return \EE_Template_Part_Manager |
154 | 154 | */ |
155 | - public function initialize_template_parts( EE_Events_Archive_Config $config = null ) { |
|
155 | + public function initialize_template_parts(EE_Events_Archive_Config $config = null) { |
|
156 | 156 | $config = $config instanceof EE_Events_Archive_Config ? $config : $this->config(); |
157 | 157 | EEH_Autoloader::instance()->register_template_part_autoloaders(); |
158 | 158 | $template_parts = new EE_Template_Part_Manager(); |
159 | 159 | $template_parts->add_template_part( |
160 | 160 | 'tickets', |
161 | - __( 'Ticket Selector', 'event_espresso' ), |
|
161 | + __('Ticket Selector', 'event_espresso'), |
|
162 | 162 | 'content-espresso_events-tickets.php', |
163 | 163 | $config->display_order_tickets |
164 | 164 | ); |
165 | 165 | $template_parts->add_template_part( |
166 | 166 | 'datetimes', |
167 | - __( 'Dates and Times', 'event_espresso' ), |
|
167 | + __('Dates and Times', 'event_espresso'), |
|
168 | 168 | 'content-espresso_events-datetimes.php', |
169 | 169 | $config->display_order_datetimes |
170 | 170 | ); |
171 | 171 | $template_parts->add_template_part( |
172 | 172 | 'event', |
173 | - __( 'Event Description', 'event_espresso' ), |
|
173 | + __('Event Description', 'event_espresso'), |
|
174 | 174 | 'content-espresso_events-details.php', |
175 | 175 | $config->display_order_event |
176 | 176 | ); |
177 | 177 | $template_parts->add_template_part( |
178 | 178 | 'venue', |
179 | - __( 'Venue Information', 'event_espresso' ), |
|
179 | + __('Venue Information', 'event_espresso'), |
|
180 | 180 | 'content-espresso_events-venues.php', |
181 | 181 | $config->display_order_venue |
182 | 182 | ); |
183 | - do_action( 'AHEE__EED_Event_Archive__initialize_template_parts', $template_parts ); |
|
183 | + do_action('AHEE__EED_Event_Archive__initialize_template_parts', $template_parts); |
|
184 | 184 | return $template_parts; |
185 | 185 | } |
186 | 186 | |
@@ -193,8 +193,8 @@ discard block |
||
193 | 193 | * @param WP $WP |
194 | 194 | * @return void |
195 | 195 | */ |
196 | - public function run( $WP ) { |
|
197 | - do_action( 'AHEE__EED_Events_Archive__before_run' ); |
|
196 | + public function run($WP) { |
|
197 | + do_action('AHEE__EED_Events_Archive__before_run'); |
|
198 | 198 | // ensure valid EE_Events_Archive_Config() object exists |
199 | 199 | $this->set_config(); |
200 | 200 | /** @type EE_Events_Archive_Config $config */ |
@@ -206,14 +206,14 @@ discard block |
||
206 | 206 | EEH_Event_Query::add_query_filters(); |
207 | 207 | // set params that will get used by the filters |
208 | 208 | EEH_Event_Query::set_query_params( |
209 | - '', // month |
|
210 | - '', // category |
|
211 | - $config->display_expired_events, // show_expired |
|
212 | - 'start_date', // orderby |
|
209 | + '', // month |
|
210 | + '', // category |
|
211 | + $config->display_expired_events, // show_expired |
|
212 | + 'start_date', // orderby |
|
213 | 213 | 'ASC' // sort |
214 | 214 | ); |
215 | 215 | // check what template is loaded |
216 | - add_filter( 'template_include', array( $this, 'template_include' ), 999, 1 ); |
|
216 | + add_filter('template_include', array($this, 'template_include'), 999, 1); |
|
217 | 217 | } |
218 | 218 | |
219 | 219 | |
@@ -241,7 +241,7 @@ discard block |
||
241 | 241 | */ |
242 | 242 | public function event_list_iframe() { |
243 | 243 | \EED_Events_Archive::$iframe = true; |
244 | - $event_list_iframe = new EventsArchiveIframe( $this ); |
|
244 | + $event_list_iframe = new EventsArchiveIframe($this); |
|
245 | 245 | $event_list_iframe->display(); |
246 | 246 | } |
247 | 247 | |
@@ -279,32 +279,32 @@ discard block |
||
279 | 279 | * @param string $template |
280 | 280 | * @return string |
281 | 281 | */ |
282 | - public function template_include( $template = '' ) { |
|
282 | + public function template_include($template = '') { |
|
283 | 283 | // don't add content filter for dedicated EE child themes or private posts |
284 | - if ( ! EEH_Template::is_espresso_theme() ) { |
|
284 | + if ( ! EEH_Template::is_espresso_theme()) { |
|
285 | 285 | /** @type EE_Events_Archive_Config $config */ |
286 | 286 | $config = $this->config(); |
287 | 287 | // add status banner ? |
288 | - if ( $config->display_status_banner ) { |
|
289 | - add_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100, 2 ); |
|
288 | + if ($config->display_status_banner) { |
|
289 | + add_filter('the_title', array('EED_Events_Archive', 'the_title'), 100, 2); |
|
290 | 290 | } |
291 | 291 | // if NOT a custom template |
292 | 292 | if ( |
293 | - EE_Registry::instance()->load_core( 'Front_Controller', array(), false, true )->get_selected_template() != 'archive-espresso_events.php' |
|
294 | - || apply_filters( 'FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', FALSE ) |
|
293 | + EE_Registry::instance()->load_core('Front_Controller', array(), false, true)->get_selected_template() != 'archive-espresso_events.php' |
|
294 | + || apply_filters('FHEE__EED_Event_Archive__template_include__allow_custom_selected_template', FALSE) |
|
295 | 295 | ) { |
296 | 296 | // don't display entry meta because the existing theme will take care of that |
297 | - add_filter( 'FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true' ); |
|
297 | + add_filter('FHEE__EED_Events_Archive__template_include__events_list_active', '__return_true'); |
|
298 | 298 | // load functions.php file for the theme (loaded by WP if using child theme) |
299 | 299 | EEH_Template::load_espresso_theme_functions(); |
300 | 300 | // because we don't know if the theme is using the_excerpt() |
301 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
301 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
302 | 302 | // or the_content |
303 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
303 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
304 | 304 | // and just in case they are running get_the_excerpt() which DESTROYS things |
305 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
305 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
306 | 306 | // don't display entry meta because the existing theme will take care of that |
307 | - add_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
307 | + add_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
308 | 308 | } |
309 | 309 | } |
310 | 310 | return $template; |
@@ -319,17 +319,17 @@ discard block |
||
319 | 319 | * @param string $excerpt |
320 | 320 | * @return string |
321 | 321 | */ |
322 | - public static function get_the_excerpt( $excerpt = '' ) { |
|
323 | - if ( post_password_required() ) { |
|
322 | + public static function get_the_excerpt($excerpt = '') { |
|
323 | + if (post_password_required()) { |
|
324 | 324 | return $excerpt; |
325 | 325 | } |
326 | - if ( apply_filters( 'FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false ) ) { |
|
327 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
328 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
329 | - $excerpt = EED_Events_Archive::event_details( $excerpt ); |
|
326 | + if (apply_filters('FHEE__EED_Events_Archive__get_the_excerpt__theme_uses_get_the_excerpt', false)) { |
|
327 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
328 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
329 | + $excerpt = EED_Events_Archive::event_details($excerpt); |
|
330 | 330 | } else { |
331 | 331 | EED_Events_Archive::$using_get_the_excerpt = true; |
332 | - add_filter( 'wp_trim_excerpt', array( 'EED_Events_Archive', 'end_get_the_excerpt' ), 999, 1 ); |
|
332 | + add_filter('wp_trim_excerpt', array('EED_Events_Archive', 'end_get_the_excerpt'), 999, 1); |
|
333 | 333 | } |
334 | 334 | return $excerpt; |
335 | 335 | } |
@@ -343,7 +343,7 @@ discard block |
||
343 | 343 | * @param string $text |
344 | 344 | * @return string |
345 | 345 | */ |
346 | - public static function end_get_the_excerpt( $text = '' ) { |
|
346 | + public static function end_get_the_excerpt($text = '') { |
|
347 | 347 | EED_Events_Archive::$using_get_the_excerpt = false; |
348 | 348 | return $text; |
349 | 349 | } |
@@ -358,10 +358,10 @@ discard block |
||
358 | 358 | * @param string $id |
359 | 359 | * @return string |
360 | 360 | */ |
361 | - public static function the_title( $title = '', $id = '' ) { |
|
361 | + public static function the_title($title = '', $id = '') { |
|
362 | 362 | global $post; |
363 | - if ( $post instanceof WP_Post ) { |
|
364 | - return in_the_loop() && $post->ID == $id ? espresso_event_status_banner( $post->ID ) . $title : $title; |
|
363 | + if ($post instanceof WP_Post) { |
|
364 | + return in_the_loop() && $post->ID == $id ? espresso_event_status_banner($post->ID).$title : $title; |
|
365 | 365 | } |
366 | 366 | return $title; |
367 | 367 | } |
@@ -375,7 +375,7 @@ discard block |
||
375 | 375 | * @param string $content |
376 | 376 | * @return string |
377 | 377 | */ |
378 | - public static function event_details( $content ) { |
|
378 | + public static function event_details($content) { |
|
379 | 379 | global $post; |
380 | 380 | static $current_post_ID = 0; |
381 | 381 | if ( |
@@ -384,8 +384,8 @@ discard block |
||
384 | 384 | && ! EED_Events_Archive::$using_get_the_excerpt |
385 | 385 | && ! post_password_required() |
386 | 386 | && ( |
387 | - apply_filters( 'FHEE__EES_Espresso_Events__process_shortcode__true', false ) |
|
388 | - || ! apply_filters( 'FHEE__content_espresso_events__template_loaded', false ) |
|
387 | + apply_filters('FHEE__EES_Espresso_Events__process_shortcode__true', false) |
|
388 | + || ! apply_filters('FHEE__content_espresso_events__template_loaded', false) |
|
389 | 389 | ) |
390 | 390 | ) { |
391 | 391 | // Set current post ID to prevent showing content twice, but only if headers have definitely been sent. |
@@ -394,8 +394,8 @@ discard block |
||
394 | 394 | // We want to allow those plugins to still do their thing and have access to our content, but depending on |
395 | 395 | // how your event content is being displayed (shortcode, CPT route, etc), this filter can get applied twice, |
396 | 396 | // so the following allows this filter to be applied multiple times, but only once for real |
397 | - $current_post_ID = did_action( 'loop_start' ) ? $post->ID : 0; |
|
398 | - if ( EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order ) { |
|
397 | + $current_post_ID = did_action('loop_start') ? $post->ID : 0; |
|
398 | + if (EE_Registry::instance()->CFG->template_settings->EED_Events_Archive->use_sortable_display_order) { |
|
399 | 399 | $content = \EED_Events_Archive::use_sortable_display_order(); |
400 | 400 | } else { |
401 | 401 | $content = \EED_Events_Archive::use_filterable_display_order(); |
@@ -414,20 +414,20 @@ discard block |
||
414 | 414 | */ |
415 | 415 | protected static function use_sortable_display_order() { |
416 | 416 | // no further password checks required atm |
417 | - add_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
417 | + add_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
418 | 418 | // we need to first remove this callback from being applied to the_content() or the_excerpt() (otherwise it will recurse and blow up the interweb) |
419 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
420 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
421 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
419 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
420 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
421 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
422 | 422 | // now add additional content depending on whether event is using the_excerpt() or the_content() |
423 | 423 | EED_Events_Archive::instance()->template_parts = EED_Events_Archive::instance()->initialize_template_parts(); |
424 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
425 | - $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters( $content ); |
|
424 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
425 | + $content = EED_Events_Archive::instance()->template_parts->apply_template_part_filters($content); |
|
426 | 426 | // re-add our main filters (or else the next event won't have them) |
427 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
428 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
429 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
430 | - remove_filter( 'FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true' ); |
|
427 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
428 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
429 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
430 | + remove_filter('FHEE__EED_Events_Archive__event_details__no_post_password_required', '__return_true'); |
|
431 | 431 | return $content; |
432 | 432 | } |
433 | 433 | |
@@ -442,22 +442,22 @@ discard block |
||
442 | 442 | protected static function use_filterable_display_order() { |
443 | 443 | // we need to first remove this callback from being applied to the_content() |
444 | 444 | // (otherwise it will recurse and blow up the interweb) |
445 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
446 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
447 | - remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
|
445 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
446 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
447 | + remove_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1); |
|
448 | 448 | //now add additional content depending on whether event is using the_excerpt() or the_content() |
449 | 449 | EED_Events_Archive::_add_additional_excerpt_filters(); |
450 | 450 | EED_Events_Archive::_add_additional_content_filters(); |
451 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters' ); |
|
451 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_add_filters'); |
|
452 | 452 | // now load our template |
453 | - $content = EEH_Template::locate_template( 'content-espresso_events-details.php' ); |
|
453 | + $content = EEH_Template::locate_template('content-espresso_events-details.php'); |
|
454 | 454 | // re-add our main filters (or else the next event won't have them) |
455 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
456 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100, 1 ); |
|
457 | - add_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1, 1 ); |
|
455 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
456 | + add_filter('the_content', array('EED_Events_Archive', 'event_details'), 100, 1); |
|
457 | + add_filter('get_the_excerpt', array('EED_Events_Archive', 'get_the_excerpt'), 1, 1); |
|
458 | 458 | // but remove the other filters so that they don't get applied to the next post |
459 | 459 | EED_Events_Archive::_remove_additional_events_archive_filters(); |
460 | - do_action( 'AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters' ); |
|
460 | + do_action('AHEE__EED_Events_Archive__use_filterable_display_order__after_remove_filters'); |
|
461 | 461 | // we're not returning the $content directly because the template we are loading uses the_content (or the_excerpt) |
462 | 462 | //return ! empty( $template ) ? $template : $content; |
463 | 463 | return $content; |
@@ -472,11 +472,11 @@ discard block |
||
472 | 472 | * @param string $content |
473 | 473 | * @return string |
474 | 474 | */ |
475 | - public static function event_datetimes( $content ) { |
|
476 | - if ( post_password_required() ) { |
|
475 | + public static function event_datetimes($content) { |
|
476 | + if (post_password_required()) { |
|
477 | 477 | return $content; |
478 | 478 | } |
479 | - return EEH_Template::locate_template( 'content-espresso_events-datetimes.php' ) . $content; |
|
479 | + return EEH_Template::locate_template('content-espresso_events-datetimes.php').$content; |
|
480 | 480 | } |
481 | 481 | |
482 | 482 | /** |
@@ -486,11 +486,11 @@ discard block |
||
486 | 486 | * @param string $content |
487 | 487 | * @return string |
488 | 488 | */ |
489 | - public static function event_tickets( $content ) { |
|
490 | - if ( post_password_required() ) { |
|
489 | + public static function event_tickets($content) { |
|
490 | + if (post_password_required()) { |
|
491 | 491 | return $content; |
492 | 492 | } |
493 | - return EEH_Template::locate_template( 'content-espresso_events-tickets.php' ) . $content; |
|
493 | + return EEH_Template::locate_template('content-espresso_events-tickets.php').$content; |
|
494 | 494 | } |
495 | 495 | |
496 | 496 | |
@@ -502,8 +502,8 @@ discard block |
||
502 | 502 | * @param string $content |
503 | 503 | * @return string |
504 | 504 | */ |
505 | - public static function event_venue( $content ) { |
|
506 | - return EED_Events_Archive::event_venues( $content ); |
|
505 | + public static function event_venue($content) { |
|
506 | + return EED_Events_Archive::event_venues($content); |
|
507 | 507 | } |
508 | 508 | |
509 | 509 | /** |
@@ -513,11 +513,11 @@ discard block |
||
513 | 513 | * @param string $content |
514 | 514 | * @return string |
515 | 515 | */ |
516 | - public static function event_venues( $content ) { |
|
517 | - if ( post_password_required() ) { |
|
516 | + public static function event_venues($content) { |
|
517 | + if (post_password_required()) { |
|
518 | 518 | return $content; |
519 | 519 | } |
520 | - return $content . EEH_Template::locate_template( 'content-espresso_events-venues.php' ); |
|
520 | + return $content.EEH_Template::locate_template('content-espresso_events-venues.php'); |
|
521 | 521 | } |
522 | 522 | |
523 | 523 | |
@@ -529,9 +529,9 @@ discard block |
||
529 | 529 | * @return void |
530 | 530 | */ |
531 | 531 | private static function _add_additional_excerpt_filters() { |
532 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
|
533 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
|
534 | - add_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
|
532 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110, 1); |
|
533 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120, 1); |
|
534 | + add_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130, 1); |
|
535 | 535 | } |
536 | 536 | |
537 | 537 | |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | * @return void |
544 | 544 | */ |
545 | 545 | private static function _add_additional_content_filters() { |
546 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110, 1 ); |
|
547 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120, 1 ); |
|
548 | - add_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130, 1 ); |
|
546 | + add_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110, 1); |
|
547 | + add_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120, 1); |
|
548 | + add_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130, 1); |
|
549 | 549 | } |
550 | 550 | |
551 | 551 | |
@@ -557,12 +557,12 @@ discard block |
||
557 | 557 | * @return void |
558 | 558 | */ |
559 | 559 | private static function _remove_additional_events_archive_filters() { |
560 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
561 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
562 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
563 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
564 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
565 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
560 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
561 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120); |
|
562 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130); |
|
563 | + remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
564 | + remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120); |
|
565 | + remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130); |
|
566 | 566 | } |
567 | 567 | |
568 | 568 | |
@@ -575,17 +575,17 @@ discard block |
||
575 | 575 | */ |
576 | 576 | public static function remove_all_events_archive_filters() { |
577 | 577 | //remove_filter( 'get_the_excerpt', array( 'EED_Events_Archive', 'get_the_excerpt' ), 1 ); |
578 | - remove_filter( 'the_title', array( 'EED_Events_Archive', 'the_title' ), 100 ); |
|
579 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
580 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
581 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
582 | - remove_filter( 'the_excerpt', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
583 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_details' ), 100 ); |
|
584 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_datetimes' ), 110 ); |
|
585 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_tickets' ), 120 ); |
|
586 | - remove_filter( 'the_content', array( 'EED_Events_Archive', 'event_venues' ), 130 ); |
|
578 | + remove_filter('the_title', array('EED_Events_Archive', 'the_title'), 100); |
|
579 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_details'), 100); |
|
580 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
581 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_tickets'), 120); |
|
582 | + remove_filter('the_excerpt', array('EED_Events_Archive', 'event_venues'), 130); |
|
583 | + remove_filter('the_content', array('EED_Events_Archive', 'event_details'), 100); |
|
584 | + remove_filter('the_content', array('EED_Events_Archive', 'event_datetimes'), 110); |
|
585 | + remove_filter('the_content', array('EED_Events_Archive', 'event_tickets'), 120); |
|
586 | + remove_filter('the_content', array('EED_Events_Archive', 'event_venues'), 130); |
|
587 | 587 | // don't display entry meta because the existing theme will take care of that |
588 | - remove_filter( 'FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false' ); |
|
588 | + remove_filter('FHEE__content_espresso_events_details_template__display_entry_meta', '__return_false'); |
|
589 | 589 | } |
590 | 590 | |
591 | 591 | |
@@ -600,12 +600,12 @@ discard block |
||
600 | 600 | * @return void |
601 | 601 | */ |
602 | 602 | public function load_event_list_assets() { |
603 | - do_action( 'AHEE__EED_Events_Archive__before_load_assets' ); |
|
604 | - add_filter( 'FHEE_load_EE_Session', '__return_true' ); |
|
605 | - add_filter( 'FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true' ); |
|
606 | - add_action('wp_enqueue_scripts', array( $this, 'wp_enqueue_scripts' ), 10 ); |
|
607 | - if ( EE_Registry::instance()->CFG->map_settings->use_google_maps ) { |
|
608 | - add_action('wp_enqueue_scripts', array( 'EEH_Maps', 'espresso_google_map_js' ), 11 ); |
|
603 | + do_action('AHEE__EED_Events_Archive__before_load_assets'); |
|
604 | + add_filter('FHEE_load_EE_Session', '__return_true'); |
|
605 | + add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true'); |
|
606 | + add_action('wp_enqueue_scripts', array($this, 'wp_enqueue_scripts'), 10); |
|
607 | + if (EE_Registry::instance()->CFG->map_settings->use_google_maps) { |
|
608 | + add_action('wp_enqueue_scripts', array('EEH_Maps', 'espresso_google_map_js'), 11); |
|
609 | 609 | } |
610 | 610 | } |
611 | 611 | |
@@ -622,13 +622,13 @@ discard block |
||
622 | 622 | */ |
623 | 623 | public function wp_enqueue_scripts() { |
624 | 624 | // get some style |
625 | - if ( apply_filters( 'FHEE_enable_default_espresso_css', FALSE ) ) { |
|
625 | + if (apply_filters('FHEE_enable_default_espresso_css', FALSE)) { |
|
626 | 626 | // first check uploads folder |
627 | - if ( EEH_File::is_readable( get_stylesheet_directory() . $this->theme . DS . 'style.css' )) { |
|
628 | - wp_register_style( $this->theme, get_stylesheet_directory_uri() . $this->theme . DS . 'style.css', array( 'dashicons', 'espresso_default' )); |
|
627 | + if (EEH_File::is_readable(get_stylesheet_directory().$this->theme.DS.'style.css')) { |
|
628 | + wp_register_style($this->theme, get_stylesheet_directory_uri().$this->theme.DS.'style.css', array('dashicons', 'espresso_default')); |
|
629 | 629 | } else { |
630 | 630 | } |
631 | - wp_enqueue_style( $this->theme ); |
|
631 | + wp_enqueue_style($this->theme); |
|
632 | 632 | |
633 | 633 | } |
634 | 634 | } |
@@ -646,8 +646,8 @@ discard block |
||
646 | 646 | */ |
647 | 647 | public static function template_settings_form() { |
648 | 648 | $template_settings = EE_Registry::instance()->CFG->template_settings; |
649 | - $template_settings->EED_Events_Archive = isset( $template_settings->EED_Events_Archive ) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
650 | - $template_settings->EED_Events_Archive = apply_filters( 'FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive ); |
|
649 | + $template_settings->EED_Events_Archive = isset($template_settings->EED_Events_Archive) ? $template_settings->EED_Events_Archive : new EE_Events_Archive_Config(); |
|
650 | + $template_settings->EED_Events_Archive = apply_filters('FHEE__EED_Events_Archive__template_settings_form__event_list_config', $template_settings->EED_Events_Archive); |
|
651 | 651 | $events_archive_settings = array( |
652 | 652 | 'display_status_banner' => 0, |
653 | 653 | 'display_description' => 1, |
@@ -656,8 +656,8 @@ discard block |
||
656 | 656 | 'display_venue' => 0, |
657 | 657 | 'display_expired_events' => 0 |
658 | 658 | ); |
659 | - $events_archive_settings = array_merge( $events_archive_settings, (array)$template_settings->EED_Events_Archive ); |
|
660 | - EEH_Template::display_template( EVENTS_ARCHIVE_TEMPLATES_PATH . 'admin-event-list-settings.template.php', $events_archive_settings ); |
|
659 | + $events_archive_settings = array_merge($events_archive_settings, (array) $template_settings->EED_Events_Archive); |
|
660 | + EEH_Template::display_template(EVENTS_ARCHIVE_TEMPLATES_PATH.'admin-event-list-settings.template.php', $events_archive_settings); |
|
661 | 661 | } |
662 | 662 | |
663 | 663 | |
@@ -673,16 +673,16 @@ discard block |
||
673 | 673 | * @param EE_Request_Handler $REQ |
674 | 674 | * @return EE_Template_Config |
675 | 675 | */ |
676 | - public static function update_template_settings( $CFG, $REQ ) { |
|
676 | + public static function update_template_settings($CFG, $REQ) { |
|
677 | 677 | $CFG->EED_Events_Archive = new EE_Events_Archive_Config(); |
678 | 678 | // unless we are resetting the config... |
679 | - if ( ! isset( $REQ['EED_Events_Archive_reset_event_list_settings'] ) || absint( $REQ['EED_Events_Archive_reset_event_list_settings'] ) !== 1 ) { |
|
680 | - $CFG->EED_Events_Archive->display_status_banner = isset( $REQ['EED_Events_Archive_display_status_banner'] ) ? absint( $REQ['EED_Events_Archive_display_status_banner'] ) : 0; |
|
681 | - $CFG->EED_Events_Archive->display_description = isset( $REQ['EED_Events_Archive_display_description'] ) ? absint( $REQ['EED_Events_Archive_display_description'] ) : 1; |
|
682 | - $CFG->EED_Events_Archive->display_ticket_selector = isset( $REQ['EED_Events_Archive_display_ticket_selector'] ) ? absint( $REQ['EED_Events_Archive_display_ticket_selector'] ) : 0; |
|
683 | - $CFG->EED_Events_Archive->display_datetimes = isset( $REQ['EED_Events_Archive_display_datetimes'] ) ? absint( $REQ['EED_Events_Archive_display_datetimes'] ) : 1; |
|
684 | - $CFG->EED_Events_Archive->display_venue = isset( $REQ['EED_Events_Archive_display_venue'] ) ? absint( $REQ['EED_Events_Archive_display_venue'] ) : 0; |
|
685 | - $CFG->EED_Events_Archive->display_expired_events = isset( $REQ['EED_Events_Archive_display_expired_events'] ) ? absint( $REQ['EED_Events_Archive_display_expired_events'] ) : 0; } |
|
679 | + if ( ! isset($REQ['EED_Events_Archive_reset_event_list_settings']) || absint($REQ['EED_Events_Archive_reset_event_list_settings']) !== 1) { |
|
680 | + $CFG->EED_Events_Archive->display_status_banner = isset($REQ['EED_Events_Archive_display_status_banner']) ? absint($REQ['EED_Events_Archive_display_status_banner']) : 0; |
|
681 | + $CFG->EED_Events_Archive->display_description = isset($REQ['EED_Events_Archive_display_description']) ? absint($REQ['EED_Events_Archive_display_description']) : 1; |
|
682 | + $CFG->EED_Events_Archive->display_ticket_selector = isset($REQ['EED_Events_Archive_display_ticket_selector']) ? absint($REQ['EED_Events_Archive_display_ticket_selector']) : 0; |
|
683 | + $CFG->EED_Events_Archive->display_datetimes = isset($REQ['EED_Events_Archive_display_datetimes']) ? absint($REQ['EED_Events_Archive_display_datetimes']) : 1; |
|
684 | + $CFG->EED_Events_Archive->display_venue = isset($REQ['EED_Events_Archive_display_venue']) ? absint($REQ['EED_Events_Archive_display_venue']) : 0; |
|
685 | + $CFG->EED_Events_Archive->display_expired_events = isset($REQ['EED_Events_Archive_display_expired_events']) ? absint($REQ['EED_Events_Archive_display_expired_events']) : 0; } |
|
686 | 686 | return $CFG; |
687 | 687 | } |
688 | 688 | |
@@ -695,10 +695,10 @@ discard block |
||
695 | 695 | * @param string $extra_class |
696 | 696 | * @return string |
697 | 697 | */ |
698 | - public static function event_list_css( $extra_class = '' ) { |
|
699 | - $event_list_css = ! empty( $extra_class ) ? array( $extra_class ) : array(); |
|
698 | + public static function event_list_css($extra_class = '') { |
|
699 | + $event_list_css = ! empty($extra_class) ? array($extra_class) : array(); |
|
700 | 700 | $event_list_css[] = 'espresso-event-list-event'; |
701 | - return implode( ' ', $event_list_css ); |
|
701 | + return implode(' ', $event_list_css); |
|
702 | 702 | } |
703 | 703 | |
704 | 704 | |
@@ -725,9 +725,9 @@ discard block |
||
725 | 725 | * @param $value |
726 | 726 | * @return bool |
727 | 727 | */ |
728 | - public static function display_description( $value ) { |
|
728 | + public static function display_description($value) { |
|
729 | 729 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
730 | - $display_description= isset( $config->display_description ) ? $config->display_description : 1; |
|
730 | + $display_description = isset($config->display_description) ? $config->display_description : 1; |
|
731 | 731 | return $display_description === $value ? TRUE : FALSE; |
732 | 732 | } |
733 | 733 | |
@@ -740,7 +740,7 @@ discard block |
||
740 | 740 | */ |
741 | 741 | public static function display_ticket_selector() { |
742 | 742 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
743 | - return isset( $config->display_ticket_selector ) && $config->display_ticket_selector ? TRUE : FALSE; |
|
743 | + return isset($config->display_ticket_selector) && $config->display_ticket_selector ? TRUE : FALSE; |
|
744 | 744 | } |
745 | 745 | |
746 | 746 | |
@@ -753,7 +753,7 @@ discard block |
||
753 | 753 | */ |
754 | 754 | public static function display_venue() { |
755 | 755 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
756 | - return isset( $config->display_venue ) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
756 | + return isset($config->display_venue) && $config->display_venue && EEH_Venue_View::venue_name() ? TRUE : FALSE; |
|
757 | 757 | } |
758 | 758 | |
759 | 759 | |
@@ -765,7 +765,7 @@ discard block |
||
765 | 765 | */ |
766 | 766 | public static function display_datetimes() { |
767 | 767 | $config = EE_Registry::instance()->CFG->template_settings->EED_Events_Archive; |
768 | - return isset( $config->display_datetimes ) && $config->display_datetimes ? TRUE : FALSE; |
|
768 | + return isset($config->display_datetimes) && $config->display_datetimes ? TRUE : FALSE; |
|
769 | 769 | } |
770 | 770 | |
771 | 771 | |
@@ -780,7 +780,7 @@ discard block |
||
780 | 780 | * @return string |
781 | 781 | */ |
782 | 782 | public static function event_list_title() { |
783 | - return apply_filters( 'FHEE__archive_espresso_events_template__upcoming_events_h1', __( 'Upcoming Events', 'event_espresso' )); |
|
783 | + return apply_filters('FHEE__archive_espresso_events_template__upcoming_events_h1', __('Upcoming Events', 'event_espresso')); |
|
784 | 784 | } |
785 | 785 | |
786 | 786 | |
@@ -789,11 +789,11 @@ discard block |
||
789 | 789 | /** |
790 | 790 | * @since 4.4.0 |
791 | 791 | */ |
792 | - public static function _doing_it_wrong_notice( $function = '' ) { |
|
792 | + public static function _doing_it_wrong_notice($function = '') { |
|
793 | 793 | EE_Error::doing_it_wrong( |
794 | 794 | __FUNCTION__, |
795 | 795 | sprintf( |
796 | - __( 'EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso' ), |
|
796 | + __('EED_Events_Archive::%1$s was moved to EEH_Event_Query::%1$s:%2$sPlease update your existing code because the method it calls will be removed in version %3$s', 'event_espresso'), |
|
797 | 797 | $function, |
798 | 798 | '<br />', |
799 | 799 | '4.6.0' |
@@ -815,89 +815,89 @@ discard block |
||
815 | 815 | * @deprecated |
816 | 816 | * @since 4.4.0 |
817 | 817 | */ |
818 | - public function posts_fields( $SQL, WP_Query $wp_query ) { |
|
819 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
820 | - return EEH_Event_Query::posts_fields( $SQL, $wp_query ); |
|
818 | + public function posts_fields($SQL, WP_Query $wp_query) { |
|
819 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
820 | + return EEH_Event_Query::posts_fields($SQL, $wp_query); |
|
821 | 821 | } |
822 | 822 | /** |
823 | 823 | * @deprecated |
824 | 824 | * @since 4.4.0 |
825 | 825 | */ |
826 | - public static function posts_fields_sql_for_orderby( $orderby_params = array() ) { |
|
827 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
828 | - return EEH_Event_Query::posts_fields_sql_for_orderby( $orderby_params ); |
|
826 | + public static function posts_fields_sql_for_orderby($orderby_params = array()) { |
|
827 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
828 | + return EEH_Event_Query::posts_fields_sql_for_orderby($orderby_params); |
|
829 | 829 | } |
830 | 830 | /** |
831 | 831 | * @deprecated |
832 | 832 | * @since 4.4.0 |
833 | 833 | */ |
834 | - public function posts_join( $SQL, WP_Query $wp_query ) { |
|
835 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
836 | - return EEH_Event_Query::posts_join( $SQL, $wp_query ); |
|
834 | + public function posts_join($SQL, WP_Query $wp_query) { |
|
835 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
836 | + return EEH_Event_Query::posts_join($SQL, $wp_query); |
|
837 | 837 | } |
838 | 838 | /** |
839 | 839 | * @deprecated |
840 | 840 | * @since 4.4.0 |
841 | 841 | */ |
842 | - public static function posts_join_sql_for_terms( $join_terms = NULL ) { |
|
843 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
844 | - return EEH_Event_Query::posts_join_sql_for_terms( $join_terms ); |
|
842 | + public static function posts_join_sql_for_terms($join_terms = NULL) { |
|
843 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
844 | + return EEH_Event_Query::posts_join_sql_for_terms($join_terms); |
|
845 | 845 | } |
846 | 846 | /** |
847 | 847 | * @deprecated |
848 | 848 | * @since 4.4.0 |
849 | 849 | */ |
850 | - public static function posts_join_for_orderby( $orderby_params = array() ) { |
|
851 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
852 | - return EEH_Event_Query::posts_join_for_orderby( $orderby_params ); |
|
850 | + public static function posts_join_for_orderby($orderby_params = array()) { |
|
851 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
852 | + return EEH_Event_Query::posts_join_for_orderby($orderby_params); |
|
853 | 853 | } |
854 | 854 | /** |
855 | 855 | * @deprecated |
856 | 856 | * @since 4.4.0 |
857 | 857 | */ |
858 | - public function posts_where( $SQL, WP_Query $wp_query ) { |
|
859 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
860 | - return EEH_Event_Query::posts_where( $SQL, $wp_query ); |
|
858 | + public function posts_where($SQL, WP_Query $wp_query) { |
|
859 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
860 | + return EEH_Event_Query::posts_where($SQL, $wp_query); |
|
861 | 861 | } |
862 | 862 | /** |
863 | 863 | * @deprecated |
864 | 864 | * @since 4.4.0 |
865 | 865 | */ |
866 | - public static function posts_where_sql_for_show_expired( $show_expired = FALSE ) { |
|
867 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
868 | - return EEH_Event_Query::posts_where_sql_for_show_expired( $show_expired ); |
|
866 | + public static function posts_where_sql_for_show_expired($show_expired = FALSE) { |
|
867 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
868 | + return EEH_Event_Query::posts_where_sql_for_show_expired($show_expired); |
|
869 | 869 | } |
870 | 870 | /** |
871 | 871 | * @deprecated |
872 | 872 | * @since 4.4.0 |
873 | 873 | */ |
874 | - public static function posts_where_sql_for_event_category_slug( $event_category_slug = NULL ) { |
|
875 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
876 | - return EEH_Event_Query::posts_where_sql_for_event_category_slug( $event_category_slug ); |
|
874 | + public static function posts_where_sql_for_event_category_slug($event_category_slug = NULL) { |
|
875 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
876 | + return EEH_Event_Query::posts_where_sql_for_event_category_slug($event_category_slug); |
|
877 | 877 | } |
878 | 878 | /** |
879 | 879 | * @deprecated |
880 | 880 | * @since 4.4.0 |
881 | 881 | */ |
882 | - public static function posts_where_sql_for_event_list_month( $month = NULL ) { |
|
883 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
884 | - return EEH_Event_Query::posts_where_sql_for_event_list_month( $month ); |
|
882 | + public static function posts_where_sql_for_event_list_month($month = NULL) { |
|
883 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
884 | + return EEH_Event_Query::posts_where_sql_for_event_list_month($month); |
|
885 | 885 | } |
886 | 886 | /** |
887 | 887 | * @deprecated |
888 | 888 | * @since 4.4.0 |
889 | 889 | */ |
890 | - public function posts_orderby( $SQL, WP_Query $wp_query ) { |
|
891 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
892 | - return EEH_Event_Query::posts_orderby( $SQL, $wp_query ); |
|
890 | + public function posts_orderby($SQL, WP_Query $wp_query) { |
|
891 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
892 | + return EEH_Event_Query::posts_orderby($SQL, $wp_query); |
|
893 | 893 | } |
894 | 894 | /** |
895 | 895 | * @deprecated |
896 | 896 | * @since 4.4.0 |
897 | 897 | */ |
898 | - public static function posts_orderby_sql( $orderby_params = array(), $sort = 'ASC' ) { |
|
899 | - EED_Events_Archive::_doing_it_wrong_notice( __FUNCTION__ ); |
|
900 | - return EEH_Event_Query::posts_orderby_sql( $orderby_params, $sort ); |
|
898 | + public static function posts_orderby_sql($orderby_params = array(), $sort = 'ASC') { |
|
899 | + EED_Events_Archive::_doing_it_wrong_notice(__FUNCTION__); |
|
900 | + return EEH_Event_Query::posts_orderby_sql($orderby_params, $sort); |
|
901 | 901 | } |
902 | 902 | |
903 | 903 | |
@@ -928,8 +928,8 @@ discard block |
||
928 | 928 | * @param string $extra_class |
929 | 929 | * @return string |
930 | 930 | */ |
931 | -function espresso_event_list_css( $extra_class = '' ) { |
|
932 | - return EED_Events_Archive::event_list_css( $extra_class ); |
|
931 | +function espresso_event_list_css($extra_class = '') { |
|
932 | + return EED_Events_Archive::event_list_css($extra_class); |
|
933 | 933 | } |
934 | 934 | |
935 | 935 | /** |
@@ -943,14 +943,14 @@ discard block |
||
943 | 943 | * @return bool |
944 | 944 | */ |
945 | 945 | function espresso_display_full_description_in_event_list() { |
946 | - return EED_Events_Archive::display_description( 2 ); |
|
946 | + return EED_Events_Archive::display_description(2); |
|
947 | 947 | } |
948 | 948 | |
949 | 949 | /** |
950 | 950 | * @return bool |
951 | 951 | */ |
952 | 952 | function espresso_display_excerpt_in_event_list() { |
953 | - return EED_Events_Archive::display_description( 1 ); |
|
953 | + return EED_Events_Archive::display_description(1); |
|
954 | 954 | } |
955 | 955 | |
956 | 956 | /** |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | namespace EventEspresso\modules\ticket_selector; |
3 | 3 | |
4 | 4 | if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
5 | - exit( 'No direct script access allowed' ); |
|
5 | + exit( 'No direct script access allowed' ); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -19,678 +19,678 @@ discard block |
||
19 | 19 | class DisplayTicketSelector |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * event that ticket selector is being generated for |
|
24 | - * |
|
25 | - * @access protected |
|
26 | - * @var \EE_Event $event |
|
27 | - */ |
|
28 | - protected $event; |
|
29 | - |
|
30 | - /** |
|
31 | - * Used to flag when the ticket selector is being called from an external iframe. |
|
32 | - * |
|
33 | - * @var bool $iframe |
|
34 | - */ |
|
35 | - protected $iframe = false; |
|
36 | - |
|
37 | - /** |
|
38 | - * max attendees that can register for event at one time |
|
39 | - * |
|
40 | - * @var int $max_attendees |
|
41 | - */ |
|
42 | - private $max_attendees = EE_INF; |
|
43 | - |
|
44 | - /** |
|
45 | - *@var string $date_format |
|
46 | - */ |
|
47 | - private $date_format = ''; |
|
48 | - |
|
49 | - /** |
|
50 | - *@var string $time_format |
|
51 | - */ |
|
52 | - private $time_format = ''; |
|
53 | - |
|
54 | - |
|
55 | - |
|
56 | - /** |
|
57 | - * DisplayTicketSelector constructor. |
|
58 | - */ |
|
59 | - public function __construct() |
|
60 | - { |
|
61 | - $this->date_format = apply_filters( |
|
62 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
63 | - get_option('date_format') |
|
64 | - ); |
|
65 | - $this->time_format = apply_filters( |
|
66 | - 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
67 | - get_option('time_format') |
|
68 | - ); |
|
69 | - } |
|
70 | - |
|
71 | - |
|
72 | - |
|
73 | - /** |
|
74 | - * @param boolean $iframe |
|
75 | - */ |
|
76 | - public function setIframe( $iframe = true ) |
|
77 | - { |
|
78 | - $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
79 | - } |
|
80 | - |
|
81 | - |
|
82 | - |
|
83 | - /** |
|
84 | - * finds and sets the \EE_Event object for use throughout class |
|
85 | - * |
|
86 | - * @param mixed $event |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - protected function setEvent( $event = null ) |
|
90 | - { |
|
91 | - if ( $event === null ) { |
|
92 | - global $post; |
|
93 | - $event = $post; |
|
94 | - } |
|
95 | - if ( $event instanceof \EE_Event ) { |
|
96 | - $this->event = $event; |
|
97 | - } else if ( $event instanceof \WP_Post ) { |
|
98 | - if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
99 | - $this->event = $event->EE_Event; |
|
100 | - } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | - $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
102 | - $this->event = $event->EE_Event; |
|
103 | - } |
|
104 | - } else { |
|
105 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | - $dev_msg = $user_msg . __( |
|
107 | - 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
108 | - 'event_espresso' |
|
109 | - ); |
|
110 | - \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | - return false; |
|
112 | - } |
|
113 | - return true; |
|
114 | - } |
|
115 | - |
|
116 | - |
|
117 | - |
|
118 | - /** |
|
119 | - * @return int |
|
120 | - */ |
|
121 | - public function getMaxAttendees() |
|
122 | - { |
|
123 | - return $this->max_attendees; |
|
124 | - } |
|
125 | - |
|
126 | - |
|
127 | - |
|
128 | - /** |
|
129 | - * @param int $max_attendees |
|
130 | - */ |
|
131 | - public function setMaxAttendees($max_attendees) |
|
132 | - { |
|
133 | - $this->max_attendees = absint( |
|
134 | - apply_filters( |
|
135 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
136 | - $max_attendees |
|
137 | - ) |
|
138 | - ); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * creates buttons for selecting number of attendees for an event |
|
145 | - * |
|
146 | - * @param \WP_Post|int $event |
|
147 | - * @param bool $view_details |
|
148 | - * @return string |
|
149 | - * @throws \EE_Error |
|
150 | - */ |
|
151 | - public function display( $event = null, $view_details = false ) |
|
152 | - { |
|
153 | - // reset filter for displaying submit button |
|
154 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
155 | - // poke and prod incoming event till it tells us what it is |
|
156 | - if ( ! $this->setEvent( $event ) ) { |
|
157 | - return false; |
|
158 | - } |
|
159 | - // begin gathering template arguments by getting event status |
|
160 | - $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | - if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
162 | - return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
163 | - } |
|
164 | - // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
165 | - $this->setMaxAttendees($this->event->additional_limit()); |
|
166 | - if ($this->getMaxAttendees() < 1) { |
|
167 | - return $this->ticketSalesClosedMessage(); |
|
168 | - } |
|
169 | - // is the event expired ? |
|
170 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
171 | - if ( $template_args[ 'event_is_expired' ] ) { |
|
172 | - return $this->expiredEventMessage(); |
|
173 | - } |
|
174 | - // get all tickets for this event ordered by the datetime |
|
175 | - $tickets = $this->getTickets(); |
|
176 | - if (count($tickets) < 1) { |
|
177 | - return $this->noTicketAvailableMessage(); |
|
178 | - } |
|
179 | - if (\EED_Events_Archive::is_iframe()){ |
|
180 | - $this->setIframe(); |
|
181 | - } |
|
182 | - // redirecting to another site for registration ?? |
|
183 | - $external_url = (string) $this->event->external_url(); |
|
184 | - // if redirecting to another site for registration, then we don't load the TS |
|
185 | - $ticket_selector = $external_url |
|
186 | - ? $this->externalEventRegistration() |
|
187 | - : $this->loadTicketSelector($tickets,$template_args); |
|
188 | - // now set up the form (but not for the admin) |
|
189 | - $ticket_selector = ! is_admin() |
|
190 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
191 | - : $ticket_selector; |
|
192 | - // submit button and form close tag |
|
193 | - $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
|
194 | - return $ticket_selector; |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - |
|
199 | - /** |
|
200 | - * displayTicketSelector |
|
201 | - * examines the event properties and determines whether a Ticket Selector should be displayed |
|
202 | - * |
|
203 | - * @param \WP_Post|int $event |
|
204 | - * @param string $_event_active_status |
|
205 | - * @param bool $view_details |
|
206 | - * @return bool |
|
207 | - * @throws \EE_Error |
|
208 | - */ |
|
209 | - protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
210 | - { |
|
211 | - $event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event; |
|
212 | - return ! is_admin() |
|
213 | - && ( |
|
214 | - ! $this->event->display_ticket_selector() |
|
215 | - || $view_details |
|
216 | - || post_password_required($event_post) |
|
217 | - || ( |
|
218 | - $_event_active_status !== \EE_Datetime::active |
|
219 | - && $_event_active_status !== \EE_Datetime::upcoming |
|
220 | - && $_event_active_status !== \EE_Datetime::sold_out |
|
221 | - && ! ( |
|
222 | - $_event_active_status === \EE_Datetime::inactive |
|
223 | - && is_user_logged_in() |
|
224 | - ) |
|
225 | - ) |
|
226 | - ); |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - |
|
231 | - /** |
|
232 | - * noTicketAvailableMessage |
|
233 | - * notice displayed if event is expired |
|
234 | - * |
|
235 | - * @return string |
|
236 | - * @throws \EE_Error |
|
237 | - */ |
|
238 | - protected function expiredEventMessage() |
|
239 | - { |
|
240 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
241 | - 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
242 | - 'event_espresso' |
|
243 | - ) . '</span></div>'; |
|
244 | - } |
|
245 | - |
|
246 | - |
|
247 | - |
|
248 | - /** |
|
249 | - * noTicketAvailableMessage |
|
250 | - * notice displayed if event has no more tickets available |
|
251 | - * |
|
252 | - * @return string |
|
253 | - * @throws \EE_Error |
|
254 | - */ |
|
255 | - protected function noTicketAvailableMessage() |
|
256 | - { |
|
257 | - $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
258 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
259 | - $no_ticket_available_msg .= sprintf( |
|
260 | - esc_html__( |
|
261 | - '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
262 | - 'event_espresso' |
|
263 | - ), |
|
264 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
265 | - '</b><br />', |
|
266 | - '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
267 | - '</a></span></div>' |
|
268 | - ); |
|
269 | - } |
|
270 | - return ' |
|
22 | + /** |
|
23 | + * event that ticket selector is being generated for |
|
24 | + * |
|
25 | + * @access protected |
|
26 | + * @var \EE_Event $event |
|
27 | + */ |
|
28 | + protected $event; |
|
29 | + |
|
30 | + /** |
|
31 | + * Used to flag when the ticket selector is being called from an external iframe. |
|
32 | + * |
|
33 | + * @var bool $iframe |
|
34 | + */ |
|
35 | + protected $iframe = false; |
|
36 | + |
|
37 | + /** |
|
38 | + * max attendees that can register for event at one time |
|
39 | + * |
|
40 | + * @var int $max_attendees |
|
41 | + */ |
|
42 | + private $max_attendees = EE_INF; |
|
43 | + |
|
44 | + /** |
|
45 | + *@var string $date_format |
|
46 | + */ |
|
47 | + private $date_format = ''; |
|
48 | + |
|
49 | + /** |
|
50 | + *@var string $time_format |
|
51 | + */ |
|
52 | + private $time_format = ''; |
|
53 | + |
|
54 | + |
|
55 | + |
|
56 | + /** |
|
57 | + * DisplayTicketSelector constructor. |
|
58 | + */ |
|
59 | + public function __construct() |
|
60 | + { |
|
61 | + $this->date_format = apply_filters( |
|
62 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__date_format', |
|
63 | + get_option('date_format') |
|
64 | + ); |
|
65 | + $this->time_format = apply_filters( |
|
66 | + 'FHEE__EED_Ticket_Selector__display_ticket_selector__time_format', |
|
67 | + get_option('time_format') |
|
68 | + ); |
|
69 | + } |
|
70 | + |
|
71 | + |
|
72 | + |
|
73 | + /** |
|
74 | + * @param boolean $iframe |
|
75 | + */ |
|
76 | + public function setIframe( $iframe = true ) |
|
77 | + { |
|
78 | + $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
79 | + } |
|
80 | + |
|
81 | + |
|
82 | + |
|
83 | + /** |
|
84 | + * finds and sets the \EE_Event object for use throughout class |
|
85 | + * |
|
86 | + * @param mixed $event |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + protected function setEvent( $event = null ) |
|
90 | + { |
|
91 | + if ( $event === null ) { |
|
92 | + global $post; |
|
93 | + $event = $post; |
|
94 | + } |
|
95 | + if ( $event instanceof \EE_Event ) { |
|
96 | + $this->event = $event; |
|
97 | + } else if ( $event instanceof \WP_Post ) { |
|
98 | + if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
99 | + $this->event = $event->EE_Event; |
|
100 | + } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | + $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
102 | + $this->event = $event->EE_Event; |
|
103 | + } |
|
104 | + } else { |
|
105 | + $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | + $dev_msg = $user_msg . __( |
|
107 | + 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
|
108 | + 'event_espresso' |
|
109 | + ); |
|
110 | + \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
111 | + return false; |
|
112 | + } |
|
113 | + return true; |
|
114 | + } |
|
115 | + |
|
116 | + |
|
117 | + |
|
118 | + /** |
|
119 | + * @return int |
|
120 | + */ |
|
121 | + public function getMaxAttendees() |
|
122 | + { |
|
123 | + return $this->max_attendees; |
|
124 | + } |
|
125 | + |
|
126 | + |
|
127 | + |
|
128 | + /** |
|
129 | + * @param int $max_attendees |
|
130 | + */ |
|
131 | + public function setMaxAttendees($max_attendees) |
|
132 | + { |
|
133 | + $this->max_attendees = absint( |
|
134 | + apply_filters( |
|
135 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector__max_tickets', |
|
136 | + $max_attendees |
|
137 | + ) |
|
138 | + ); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * creates buttons for selecting number of attendees for an event |
|
145 | + * |
|
146 | + * @param \WP_Post|int $event |
|
147 | + * @param bool $view_details |
|
148 | + * @return string |
|
149 | + * @throws \EE_Error |
|
150 | + */ |
|
151 | + public function display( $event = null, $view_details = false ) |
|
152 | + { |
|
153 | + // reset filter for displaying submit button |
|
154 | + remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
155 | + // poke and prod incoming event till it tells us what it is |
|
156 | + if ( ! $this->setEvent( $event ) ) { |
|
157 | + return false; |
|
158 | + } |
|
159 | + // begin gathering template arguments by getting event status |
|
160 | + $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | + if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
162 | + return ! is_single() ? $this->displayViewDetailsButton() : ''; |
|
163 | + } |
|
164 | + // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
|
165 | + $this->setMaxAttendees($this->event->additional_limit()); |
|
166 | + if ($this->getMaxAttendees() < 1) { |
|
167 | + return $this->ticketSalesClosedMessage(); |
|
168 | + } |
|
169 | + // is the event expired ? |
|
170 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
171 | + if ( $template_args[ 'event_is_expired' ] ) { |
|
172 | + return $this->expiredEventMessage(); |
|
173 | + } |
|
174 | + // get all tickets for this event ordered by the datetime |
|
175 | + $tickets = $this->getTickets(); |
|
176 | + if (count($tickets) < 1) { |
|
177 | + return $this->noTicketAvailableMessage(); |
|
178 | + } |
|
179 | + if (\EED_Events_Archive::is_iframe()){ |
|
180 | + $this->setIframe(); |
|
181 | + } |
|
182 | + // redirecting to another site for registration ?? |
|
183 | + $external_url = (string) $this->event->external_url(); |
|
184 | + // if redirecting to another site for registration, then we don't load the TS |
|
185 | + $ticket_selector = $external_url |
|
186 | + ? $this->externalEventRegistration() |
|
187 | + : $this->loadTicketSelector($tickets,$template_args); |
|
188 | + // now set up the form (but not for the admin) |
|
189 | + $ticket_selector = ! is_admin() |
|
190 | + ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
191 | + : $ticket_selector; |
|
192 | + // submit button and form close tag |
|
193 | + $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
|
194 | + return $ticket_selector; |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + |
|
199 | + /** |
|
200 | + * displayTicketSelector |
|
201 | + * examines the event properties and determines whether a Ticket Selector should be displayed |
|
202 | + * |
|
203 | + * @param \WP_Post|int $event |
|
204 | + * @param string $_event_active_status |
|
205 | + * @param bool $view_details |
|
206 | + * @return bool |
|
207 | + * @throws \EE_Error |
|
208 | + */ |
|
209 | + protected function activeEventAndShowTicketSelector($event, $_event_active_status, $view_details) |
|
210 | + { |
|
211 | + $event_post = $this->event instanceof \EE_Event ? $this->event->ID() : $event; |
|
212 | + return ! is_admin() |
|
213 | + && ( |
|
214 | + ! $this->event->display_ticket_selector() |
|
215 | + || $view_details |
|
216 | + || post_password_required($event_post) |
|
217 | + || ( |
|
218 | + $_event_active_status !== \EE_Datetime::active |
|
219 | + && $_event_active_status !== \EE_Datetime::upcoming |
|
220 | + && $_event_active_status !== \EE_Datetime::sold_out |
|
221 | + && ! ( |
|
222 | + $_event_active_status === \EE_Datetime::inactive |
|
223 | + && is_user_logged_in() |
|
224 | + ) |
|
225 | + ) |
|
226 | + ); |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + |
|
231 | + /** |
|
232 | + * noTicketAvailableMessage |
|
233 | + * notice displayed if event is expired |
|
234 | + * |
|
235 | + * @return string |
|
236 | + * @throws \EE_Error |
|
237 | + */ |
|
238 | + protected function expiredEventMessage() |
|
239 | + { |
|
240 | + return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
241 | + 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
|
242 | + 'event_espresso' |
|
243 | + ) . '</span></div>'; |
|
244 | + } |
|
245 | + |
|
246 | + |
|
247 | + |
|
248 | + /** |
|
249 | + * noTicketAvailableMessage |
|
250 | + * notice displayed if event has no more tickets available |
|
251 | + * |
|
252 | + * @return string |
|
253 | + * @throws \EE_Error |
|
254 | + */ |
|
255 | + protected function noTicketAvailableMessage() |
|
256 | + { |
|
257 | + $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
258 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
259 | + $no_ticket_available_msg .= sprintf( |
|
260 | + esc_html__( |
|
261 | + '%1$sNote to Event Admin:%2$sNo tickets were found for this event. This effectively turns off ticket sales. Please ensure that at least one ticket is available for if you want people to be able to register.%3$s(click to edit this event)%4$s', |
|
262 | + 'event_espresso' |
|
263 | + ), |
|
264 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
265 | + '</b><br />', |
|
266 | + '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
267 | + '</a></span></div>' |
|
268 | + ); |
|
269 | + } |
|
270 | + return ' |
|
271 | 271 | <div class="ee-event-expired-notice"> |
272 | 272 | <span class="important-notice">' . $no_ticket_available_msg . '</span> |
273 | 273 | </div>'; |
274 | - } |
|
275 | - |
|
276 | - |
|
277 | - |
|
278 | - /** |
|
279 | - * ticketSalesClosed |
|
280 | - * notice displayed if event ticket sales are turned off |
|
281 | - * |
|
282 | - * @return string |
|
283 | - * @throws \EE_Error |
|
284 | - */ |
|
285 | - protected function ticketSalesClosedMessage() |
|
286 | - { |
|
287 | - $sales_closed_msg = esc_html__( |
|
288 | - 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
289 | - 'event_espresso' |
|
290 | - ); |
|
291 | - if (current_user_can('edit_post', $this->event->ID())) { |
|
292 | - $sales_closed_msg .= sprintf( |
|
293 | - esc_html__( |
|
294 | - '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
295 | - 'event_espresso' |
|
296 | - ), |
|
297 | - '<div class="ee-attention" style="text-align: left;"><b>', |
|
298 | - '</b><br />', |
|
299 | - '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
300 | - '</a></span></div>' |
|
301 | - ); |
|
302 | - } |
|
303 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
304 | - } |
|
305 | - |
|
306 | - |
|
307 | - |
|
308 | - /** |
|
309 | - * getTickets |
|
310 | - * |
|
311 | - * @return \EE_Base_Class[]|\EE_Ticket[] |
|
312 | - * @throws \EE_Error |
|
313 | - */ |
|
314 | - protected function getTickets() |
|
315 | - { |
|
316 | - $ticket_query_args = array( |
|
317 | - array('Datetime.EVT_ID' => $this->event->ID()), |
|
318 | - 'order_by' => array( |
|
319 | - 'TKT_order' => 'ASC', |
|
320 | - 'TKT_required' => 'DESC', |
|
321 | - 'TKT_start_date' => 'ASC', |
|
322 | - 'TKT_end_date' => 'ASC', |
|
323 | - 'Datetime.DTT_EVT_start' => 'DESC', |
|
324 | - ), |
|
325 | - ); |
|
326 | - if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
327 | - //use the correct applicable time query depending on what version of core is being run. |
|
328 | - $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
329 | - ? time() |
|
330 | - : current_time('timestamp'); |
|
331 | - $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
332 | - } |
|
333 | - return \EEM_Ticket::instance()->get_all($ticket_query_args); |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * loadTicketSelector |
|
340 | - * begins to assemble template arguments |
|
341 | - * and decides whether to load a "simple" ticket selector, or the standard |
|
342 | - * |
|
343 | - * @param \EE_Ticket[] $tickets |
|
344 | - * @param array $template_args |
|
345 | - * @return string |
|
346 | - * @throws \EE_Error |
|
347 | - */ |
|
348 | - protected function loadTicketSelector(array $tickets, array $template_args) |
|
349 | - { |
|
350 | - $template_args['event'] = $this->event; |
|
351 | - $template_args['EVT_ID'] = $this->event->ID(); |
|
352 | - $template_args['event_is_expired'] = $this->event->is_expired(); |
|
353 | - $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
354 | - $template_args['date_format'] = $this->date_format; |
|
355 | - $template_args['time_format'] = $this->time_format; |
|
356 | - /** |
|
357 | - * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
358 | - * |
|
359 | - * @since 4.9.13 |
|
360 | - * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
361 | - * @param int $EVT_ID The Event ID |
|
362 | - */ |
|
363 | - $template_args['anchor_id'] = apply_filters( |
|
364 | - 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
365 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
366 | - $this->event->ID() |
|
367 | - ); |
|
368 | - $template_args['tickets'] = $tickets; |
|
369 | - $template_args['ticket_count'] = count($tickets); |
|
370 | - $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
371 | - return $ticket_selector instanceof TicketSelectorSimple |
|
372 | - ? $ticket_selector |
|
373 | - : new TicketSelectorStandard( |
|
374 | - $this->event, |
|
375 | - $tickets, |
|
376 | - $this->getMaxAttendees(), |
|
377 | - $template_args, |
|
378 | - $this->date_format, |
|
379 | - $this->time_format |
|
380 | - ); |
|
381 | - } |
|
382 | - |
|
383 | - |
|
384 | - |
|
385 | - /** |
|
386 | - * simpleTicketSelector |
|
387 | - * there's one ticket, and max attendees is set to one, |
|
388 | - * so if the event is free, then this is a "simple" ticket selector |
|
389 | - * a.k.a. "Dude Where's my Ticket Selector?" |
|
390 | - * |
|
391 | - * @param \EE_Ticket[] $tickets |
|
392 | - * @param array $template_args |
|
393 | - * @return string |
|
394 | - * @throws \EE_Error |
|
395 | - */ |
|
396 | - protected function simpleTicketSelector($tickets, array $template_args) |
|
397 | - { |
|
398 | - // if there is only ONE ticket with a max qty of ONE |
|
399 | - if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
400 | - return ''; |
|
401 | - } |
|
402 | - /** @var \EE_Ticket $ticket */ |
|
403 | - $ticket = reset($tickets); |
|
404 | - // if the ticket is free... then not much need for the ticket selector |
|
405 | - if ( |
|
406 | - apply_filters( |
|
407 | - 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
408 | - $ticket->is_free(), |
|
409 | - $this->event->ID() |
|
410 | - ) |
|
411 | - ) { |
|
412 | - return new TicketSelectorSimple( |
|
413 | - $this->event, |
|
414 | - $ticket, |
|
415 | - $this->getMaxAttendees(), |
|
416 | - $template_args |
|
417 | - ); |
|
418 | - } |
|
419 | - return ''; |
|
420 | - } |
|
421 | - |
|
422 | - |
|
423 | - |
|
424 | - /** |
|
425 | - * externalEventRegistration |
|
426 | - * |
|
427 | - * @return string |
|
428 | - */ |
|
429 | - public function externalEventRegistration() |
|
430 | - { |
|
431 | - // if not we still need to trigger the display of the submit button |
|
432 | - add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
433 | - //display notice to admin that registration is external |
|
434 | - return is_admin() |
|
435 | - ? esc_html__( |
|
436 | - 'Registration is at an external URL for this event.', |
|
437 | - 'event_espresso' |
|
438 | - ) |
|
439 | - : ''; |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * formOpen |
|
446 | - * |
|
447 | - * @param int $ID |
|
448 | - * @param string $external_url |
|
449 | - * @return string |
|
450 | - */ |
|
451 | - public function formOpen( $ID = 0, $external_url = '' ) |
|
452 | - { |
|
453 | - // if redirecting, we don't need any anything else |
|
454 | - if ( $external_url ) { |
|
455 | - $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
456 | - // open link in new window ? |
|
457 | - $html .= apply_filters( |
|
458 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
459 | - \EED_Events_Archive::is_iframe() |
|
460 | - ) |
|
461 | - ? ' target="_blank"' |
|
462 | - : ''; |
|
463 | - $html .= '>'; |
|
464 | - $query_args = \EEH_URL::get_query_string( $external_url ); |
|
465 | - foreach ( (array)$query_args as $query_arg => $value ) { |
|
466 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
467 | - } |
|
468 | - return $html; |
|
469 | - } |
|
470 | - // if there is no submit button, then don't start building a form |
|
471 | - // because the "View Details" button will build its own form |
|
472 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
473 | - return ''; |
|
474 | - } |
|
475 | - $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
476 | - if ( ! $checkout_url ) { |
|
477 | - \EE_Error::add_error( |
|
478 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
479 | - __FILE__, |
|
480 | - __FUNCTION__, |
|
481 | - __LINE__ |
|
482 | - ); |
|
483 | - } |
|
484 | - // set no cache headers and constants |
|
485 | - \EE_System::do_not_cache(); |
|
486 | - $extra_params = $this->iframe ? ' target="_blank"' : ''; |
|
487 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
488 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
489 | - $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
490 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
491 | - return $html; |
|
492 | - } |
|
493 | - |
|
494 | - |
|
495 | - |
|
496 | - /** |
|
497 | - * displaySubmitButton |
|
498 | - * |
|
499 | - * @param string $external_url |
|
500 | - * @return string |
|
501 | - * @throws \EE_Error |
|
502 | - */ |
|
503 | - public function displaySubmitButton($external_url = '') |
|
504 | - { |
|
505 | - $html = ''; |
|
506 | - if ( ! is_admin()) { |
|
507 | - // standard TS displayed with submit button, ie: "Register Now" |
|
508 | - if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
509 | - $html .= $this->displayRegisterNowButton(); |
|
510 | - $html .= empty($external_url) |
|
511 | - ? $this->ticketSelectorEndDiv() |
|
512 | - : $this->clearTicketSelector(); |
|
513 | - $html .= '<br/>' . $this->formClose(); |
|
514 | - } else if ($this->getMaxAttendees() === 1) { |
|
515 | - // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
516 | - if ($this->event->is_sold_out()) { |
|
517 | - // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
518 | - $html .= apply_filters( |
|
519 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
520 | - sprintf( |
|
521 | - __( |
|
522 | - '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
523 | - 'event_espresso' |
|
524 | - ), |
|
525 | - '<p class="no-ticket-selector-msg clear-float">', |
|
526 | - $this->event->name(), |
|
527 | - '</p>', |
|
528 | - '<br />' |
|
529 | - ), |
|
530 | - $this->event |
|
531 | - ); |
|
532 | - if ( |
|
533 | - apply_filters( |
|
534 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
535 | - false, |
|
536 | - $this->event |
|
537 | - ) |
|
538 | - ) { |
|
539 | - $html .= $this->displayRegisterNowButton(); |
|
540 | - } |
|
541 | - // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
542 | - $html .= $this->ticketSelectorEndDiv(); |
|
543 | - } else if ( |
|
544 | - apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
545 | - && ! is_single() |
|
546 | - ) { |
|
547 | - // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
548 | - // but no tickets are available, so display event's "View Details" button. |
|
549 | - // it is being viewed via somewhere other than a single post |
|
550 | - $html .= $this->displayViewDetailsButton(true); |
|
551 | - } |
|
552 | - } else if (is_archive()) { |
|
553 | - // event list, no tickets available so display event's "View Details" button |
|
554 | - $html .= $this->ticketSelectorEndDiv(); |
|
555 | - $html .= $this->displayViewDetailsButton(); |
|
556 | - } else { |
|
557 | - if ( |
|
558 | - apply_filters( |
|
559 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
560 | - false, |
|
561 | - $this->event |
|
562 | - ) |
|
563 | - ) { |
|
564 | - $html .= $this->displayRegisterNowButton(); |
|
565 | - } |
|
566 | - // no submit or view details button, and no additional content |
|
567 | - $html .= $this->ticketSelectorEndDiv(); |
|
568 | - } |
|
569 | - if ( ! $this->iframe && ! is_archive()) { |
|
570 | - $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
571 | - } |
|
572 | - } |
|
573 | - return $html; |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - |
|
578 | - /** |
|
579 | - * @return string |
|
580 | - * @throws \EE_Error |
|
581 | - */ |
|
582 | - public function displayRegisterNowButton() |
|
583 | - { |
|
584 | - $btn_text = apply_filters( |
|
585 | - 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
586 | - __('Register Now', 'event_espresso'), |
|
587 | - $this->event |
|
588 | - ); |
|
589 | - $external_url = $this->event->external_url(); |
|
590 | - $html = \EEH_HTML::div( |
|
591 | - '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
592 | - ); |
|
593 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
594 | - $html .= ' class="ticket-selector-submit-btn '; |
|
595 | - $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
596 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
597 | - $html .= \EEH_HTML::divx(); |
|
598 | - $html .= apply_filters( |
|
599 | - 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
600 | - '', |
|
601 | - $this->event |
|
602 | - ); |
|
603 | - return $html; |
|
604 | - } |
|
605 | - |
|
606 | - |
|
607 | - /** |
|
608 | - * displayViewDetailsButton |
|
609 | - * |
|
610 | - * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
611 | - * (ie: $_max_atndz === 1) where there are no available tickets, |
|
612 | - * either because they are sold out, expired, or not yet on sale. |
|
613 | - * In this case, we need to close the form BEFORE adding any closing divs |
|
614 | - * @return string |
|
615 | - * @throws \EE_Error |
|
616 | - */ |
|
617 | - public function displayViewDetailsButton( $DWMTS = false ) |
|
618 | - { |
|
619 | - if ( ! $this->event->get_permalink() ) { |
|
620 | - \EE_Error::add_error( |
|
621 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
622 | - __FILE__, __FUNCTION__, __LINE__ |
|
623 | - ); |
|
624 | - } |
|
625 | - $view_details_btn = '<form method="POST" action="'; |
|
626 | - $view_details_btn .= apply_filters( |
|
627 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
628 | - $this->event->get_permalink(), |
|
629 | - $this->event |
|
630 | - ); |
|
631 | - $view_details_btn .= '"'; |
|
632 | - // open link in new window ? |
|
633 | - $view_details_btn .= apply_filters( |
|
634 | - 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank', |
|
635 | - \EED_Events_Archive::is_iframe() |
|
636 | - ) |
|
637 | - ? ' target="_blank"' |
|
638 | - : ''; |
|
639 | - $view_details_btn .='>'; |
|
640 | - $btn_text = apply_filters( |
|
641 | - 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
642 | - esc_html__('View Details', 'event_espresso'), |
|
643 | - $this->event |
|
644 | - ); |
|
645 | - $view_details_btn .= '<input id="ticket-selector-submit-' |
|
646 | - . $this->event->ID() |
|
647 | - . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
648 | - . $btn_text |
|
649 | - . '" />'; |
|
650 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
651 | - if ($DWMTS) { |
|
652 | - $view_details_btn .= $this->formClose(); |
|
653 | - $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
654 | - $view_details_btn .= '<br/>'; |
|
655 | - } else { |
|
656 | - $view_details_btn .= $this->clearTicketSelector(); |
|
657 | - $view_details_btn .= '<br/>'; |
|
658 | - $view_details_btn .= $this->formClose(); |
|
659 | - } |
|
660 | - return $view_details_btn; |
|
661 | - } |
|
662 | - |
|
663 | - |
|
664 | - |
|
665 | - /** |
|
666 | - * @return string |
|
667 | - */ |
|
668 | - public function ticketSelectorEndDiv() |
|
669 | - { |
|
670 | - return '<div class="clear"></div></div>'; |
|
671 | - } |
|
672 | - |
|
673 | - |
|
674 | - |
|
675 | - /** |
|
676 | - * @return string |
|
677 | - */ |
|
678 | - public function clearTicketSelector() |
|
679 | - { |
|
680 | - // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
681 | - return '<div class="clear"></div>'; |
|
682 | - } |
|
683 | - |
|
684 | - |
|
685 | - |
|
686 | - /** |
|
687 | - * @access public |
|
688 | - * @return string |
|
689 | - */ |
|
690 | - public function formClose() |
|
691 | - { |
|
692 | - return '</form>'; |
|
693 | - } |
|
274 | + } |
|
275 | + |
|
276 | + |
|
277 | + |
|
278 | + /** |
|
279 | + * ticketSalesClosed |
|
280 | + * notice displayed if event ticket sales are turned off |
|
281 | + * |
|
282 | + * @return string |
|
283 | + * @throws \EE_Error |
|
284 | + */ |
|
285 | + protected function ticketSalesClosedMessage() |
|
286 | + { |
|
287 | + $sales_closed_msg = esc_html__( |
|
288 | + 'We\'re sorry, but ticket sales have been closed at this time. Please check back again later.', |
|
289 | + 'event_espresso' |
|
290 | + ); |
|
291 | + if (current_user_can('edit_post', $this->event->ID())) { |
|
292 | + $sales_closed_msg .= sprintf( |
|
293 | + esc_html__( |
|
294 | + '%sNote to Event Admin:%sThe "Maximum number of tickets allowed per order for this event" in the Event Registration Options has been set to "0". This effectively turns off ticket sales. %s(click to edit this event)%s', |
|
295 | + 'event_espresso' |
|
296 | + ), |
|
297 | + '<div class="ee-attention" style="text-align: left;"><b>', |
|
298 | + '</b><br />', |
|
299 | + '<span class="edit-link"><a class="post-edit-link" href="'.get_edit_post_link($this->event->ID()).'">', |
|
300 | + '</a></span></div>' |
|
301 | + ); |
|
302 | + } |
|
303 | + return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
304 | + } |
|
305 | + |
|
306 | + |
|
307 | + |
|
308 | + /** |
|
309 | + * getTickets |
|
310 | + * |
|
311 | + * @return \EE_Base_Class[]|\EE_Ticket[] |
|
312 | + * @throws \EE_Error |
|
313 | + */ |
|
314 | + protected function getTickets() |
|
315 | + { |
|
316 | + $ticket_query_args = array( |
|
317 | + array('Datetime.EVT_ID' => $this->event->ID()), |
|
318 | + 'order_by' => array( |
|
319 | + 'TKT_order' => 'ASC', |
|
320 | + 'TKT_required' => 'DESC', |
|
321 | + 'TKT_start_date' => 'ASC', |
|
322 | + 'TKT_end_date' => 'ASC', |
|
323 | + 'Datetime.DTT_EVT_start' => 'DESC', |
|
324 | + ), |
|
325 | + ); |
|
326 | + if ( ! \EE_Registry::instance()->CFG->template_settings->EED_Ticket_Selector->show_expired_tickets) { |
|
327 | + //use the correct applicable time query depending on what version of core is being run. |
|
328 | + $current_time = method_exists('EEM_Datetime', 'current_time_for_query') |
|
329 | + ? time() |
|
330 | + : current_time('timestamp'); |
|
331 | + $ticket_query_args[0]['TKT_end_date'] = array('>', $current_time); |
|
332 | + } |
|
333 | + return \EEM_Ticket::instance()->get_all($ticket_query_args); |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * loadTicketSelector |
|
340 | + * begins to assemble template arguments |
|
341 | + * and decides whether to load a "simple" ticket selector, or the standard |
|
342 | + * |
|
343 | + * @param \EE_Ticket[] $tickets |
|
344 | + * @param array $template_args |
|
345 | + * @return string |
|
346 | + * @throws \EE_Error |
|
347 | + */ |
|
348 | + protected function loadTicketSelector(array $tickets, array $template_args) |
|
349 | + { |
|
350 | + $template_args['event'] = $this->event; |
|
351 | + $template_args['EVT_ID'] = $this->event->ID(); |
|
352 | + $template_args['event_is_expired'] = $this->event->is_expired(); |
|
353 | + $template_args['max_atndz'] = $this->getMaxAttendees(); |
|
354 | + $template_args['date_format'] = $this->date_format; |
|
355 | + $template_args['time_format'] = $this->time_format; |
|
356 | + /** |
|
357 | + * Filters the anchor ID used when redirecting to the Ticket Selector if no quantity selected |
|
358 | + * |
|
359 | + * @since 4.9.13 |
|
360 | + * @param string '#tkt-slctr-tbl-' . $EVT_ID The html ID to anchor to |
|
361 | + * @param int $EVT_ID The Event ID |
|
362 | + */ |
|
363 | + $template_args['anchor_id'] = apply_filters( |
|
364 | + 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
|
365 | + '#tkt-slctr-tbl-' . $this->event->ID(), |
|
366 | + $this->event->ID() |
|
367 | + ); |
|
368 | + $template_args['tickets'] = $tickets; |
|
369 | + $template_args['ticket_count'] = count($tickets); |
|
370 | + $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
371 | + return $ticket_selector instanceof TicketSelectorSimple |
|
372 | + ? $ticket_selector |
|
373 | + : new TicketSelectorStandard( |
|
374 | + $this->event, |
|
375 | + $tickets, |
|
376 | + $this->getMaxAttendees(), |
|
377 | + $template_args, |
|
378 | + $this->date_format, |
|
379 | + $this->time_format |
|
380 | + ); |
|
381 | + } |
|
382 | + |
|
383 | + |
|
384 | + |
|
385 | + /** |
|
386 | + * simpleTicketSelector |
|
387 | + * there's one ticket, and max attendees is set to one, |
|
388 | + * so if the event is free, then this is a "simple" ticket selector |
|
389 | + * a.k.a. "Dude Where's my Ticket Selector?" |
|
390 | + * |
|
391 | + * @param \EE_Ticket[] $tickets |
|
392 | + * @param array $template_args |
|
393 | + * @return string |
|
394 | + * @throws \EE_Error |
|
395 | + */ |
|
396 | + protected function simpleTicketSelector($tickets, array $template_args) |
|
397 | + { |
|
398 | + // if there is only ONE ticket with a max qty of ONE |
|
399 | + if (count($tickets) > 1 || $this->getMaxAttendees() !== 1) { |
|
400 | + return ''; |
|
401 | + } |
|
402 | + /** @var \EE_Ticket $ticket */ |
|
403 | + $ticket = reset($tickets); |
|
404 | + // if the ticket is free... then not much need for the ticket selector |
|
405 | + if ( |
|
406 | + apply_filters( |
|
407 | + 'FHEE__ticket_selector_chart_template__hide_ticket_selector', |
|
408 | + $ticket->is_free(), |
|
409 | + $this->event->ID() |
|
410 | + ) |
|
411 | + ) { |
|
412 | + return new TicketSelectorSimple( |
|
413 | + $this->event, |
|
414 | + $ticket, |
|
415 | + $this->getMaxAttendees(), |
|
416 | + $template_args |
|
417 | + ); |
|
418 | + } |
|
419 | + return ''; |
|
420 | + } |
|
421 | + |
|
422 | + |
|
423 | + |
|
424 | + /** |
|
425 | + * externalEventRegistration |
|
426 | + * |
|
427 | + * @return string |
|
428 | + */ |
|
429 | + public function externalEventRegistration() |
|
430 | + { |
|
431 | + // if not we still need to trigger the display of the submit button |
|
432 | + add_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
433 | + //display notice to admin that registration is external |
|
434 | + return is_admin() |
|
435 | + ? esc_html__( |
|
436 | + 'Registration is at an external URL for this event.', |
|
437 | + 'event_espresso' |
|
438 | + ) |
|
439 | + : ''; |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * formOpen |
|
446 | + * |
|
447 | + * @param int $ID |
|
448 | + * @param string $external_url |
|
449 | + * @return string |
|
450 | + */ |
|
451 | + public function formOpen( $ID = 0, $external_url = '' ) |
|
452 | + { |
|
453 | + // if redirecting, we don't need any anything else |
|
454 | + if ( $external_url ) { |
|
455 | + $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
456 | + // open link in new window ? |
|
457 | + $html .= apply_filters( |
|
458 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
|
459 | + \EED_Events_Archive::is_iframe() |
|
460 | + ) |
|
461 | + ? ' target="_blank"' |
|
462 | + : ''; |
|
463 | + $html .= '>'; |
|
464 | + $query_args = \EEH_URL::get_query_string( $external_url ); |
|
465 | + foreach ( (array)$query_args as $query_arg => $value ) { |
|
466 | + $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
467 | + } |
|
468 | + return $html; |
|
469 | + } |
|
470 | + // if there is no submit button, then don't start building a form |
|
471 | + // because the "View Details" button will build its own form |
|
472 | + if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
473 | + return ''; |
|
474 | + } |
|
475 | + $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
476 | + if ( ! $checkout_url ) { |
|
477 | + \EE_Error::add_error( |
|
478 | + esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
479 | + __FILE__, |
|
480 | + __FUNCTION__, |
|
481 | + __LINE__ |
|
482 | + ); |
|
483 | + } |
|
484 | + // set no cache headers and constants |
|
485 | + \EE_System::do_not_cache(); |
|
486 | + $extra_params = $this->iframe ? ' target="_blank"' : ''; |
|
487 | + $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
488 | + $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
489 | + $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
|
490 | + $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
491 | + return $html; |
|
492 | + } |
|
493 | + |
|
494 | + |
|
495 | + |
|
496 | + /** |
|
497 | + * displaySubmitButton |
|
498 | + * |
|
499 | + * @param string $external_url |
|
500 | + * @return string |
|
501 | + * @throws \EE_Error |
|
502 | + */ |
|
503 | + public function displaySubmitButton($external_url = '') |
|
504 | + { |
|
505 | + $html = ''; |
|
506 | + if ( ! is_admin()) { |
|
507 | + // standard TS displayed with submit button, ie: "Register Now" |
|
508 | + if (apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
509 | + $html .= $this->displayRegisterNowButton(); |
|
510 | + $html .= empty($external_url) |
|
511 | + ? $this->ticketSelectorEndDiv() |
|
512 | + : $this->clearTicketSelector(); |
|
513 | + $html .= '<br/>' . $this->formClose(); |
|
514 | + } else if ($this->getMaxAttendees() === 1) { |
|
515 | + // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
|
516 | + if ($this->event->is_sold_out()) { |
|
517 | + // then instead of a View Details or Submit button, just display a "Sold Out" message |
|
518 | + $html .= apply_filters( |
|
519 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__sold_out_msg', |
|
520 | + sprintf( |
|
521 | + __( |
|
522 | + '%1$s"%2$s" is currently sold out.%4$sPlease check back again later, as spots may become available.%3$s', |
|
523 | + 'event_espresso' |
|
524 | + ), |
|
525 | + '<p class="no-ticket-selector-msg clear-float">', |
|
526 | + $this->event->name(), |
|
527 | + '</p>', |
|
528 | + '<br />' |
|
529 | + ), |
|
530 | + $this->event |
|
531 | + ); |
|
532 | + if ( |
|
533 | + apply_filters( |
|
534 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
535 | + false, |
|
536 | + $this->event |
|
537 | + ) |
|
538 | + ) { |
|
539 | + $html .= $this->displayRegisterNowButton(); |
|
540 | + } |
|
541 | + // sold out DWMTS event, no TS, no submit or view details button, but has additional content |
|
542 | + $html .= $this->ticketSelectorEndDiv(); |
|
543 | + } else if ( |
|
544 | + apply_filters('FHEE__EE_Ticket_Selector__hide_ticket_selector', false) |
|
545 | + && ! is_single() |
|
546 | + ) { |
|
547 | + // this is a "Dude Where's my Ticket Selector?" (DWMTS) type event, |
|
548 | + // but no tickets are available, so display event's "View Details" button. |
|
549 | + // it is being viewed via somewhere other than a single post |
|
550 | + $html .= $this->displayViewDetailsButton(true); |
|
551 | + } |
|
552 | + } else if (is_archive()) { |
|
553 | + // event list, no tickets available so display event's "View Details" button |
|
554 | + $html .= $this->ticketSelectorEndDiv(); |
|
555 | + $html .= $this->displayViewDetailsButton(); |
|
556 | + } else { |
|
557 | + if ( |
|
558 | + apply_filters( |
|
559 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__no_tickets_but_display_register_now_button', |
|
560 | + false, |
|
561 | + $this->event |
|
562 | + ) |
|
563 | + ) { |
|
564 | + $html .= $this->displayRegisterNowButton(); |
|
565 | + } |
|
566 | + // no submit or view details button, and no additional content |
|
567 | + $html .= $this->ticketSelectorEndDiv(); |
|
568 | + } |
|
569 | + if ( ! $this->iframe && ! is_archive()) { |
|
570 | + $html .= \EEH_Template::powered_by_event_espresso('', '', array('utm_content' => 'ticket_selector')); |
|
571 | + } |
|
572 | + } |
|
573 | + return $html; |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + |
|
578 | + /** |
|
579 | + * @return string |
|
580 | + * @throws \EE_Error |
|
581 | + */ |
|
582 | + public function displayRegisterNowButton() |
|
583 | + { |
|
584 | + $btn_text = apply_filters( |
|
585 | + 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit__btn_text', |
|
586 | + __('Register Now', 'event_espresso'), |
|
587 | + $this->event |
|
588 | + ); |
|
589 | + $external_url = $this->event->external_url(); |
|
590 | + $html = \EEH_HTML::div( |
|
591 | + '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
592 | + ); |
|
593 | + $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
594 | + $html .= ' class="ticket-selector-submit-btn '; |
|
595 | + $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
|
596 | + $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
597 | + $html .= \EEH_HTML::divx(); |
|
598 | + $html .= apply_filters( |
|
599 | + 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
|
600 | + '', |
|
601 | + $this->event |
|
602 | + ); |
|
603 | + return $html; |
|
604 | + } |
|
605 | + |
|
606 | + |
|
607 | + /** |
|
608 | + * displayViewDetailsButton |
|
609 | + * |
|
610 | + * @param bool $DWMTS indicates a "Dude Where's my Ticket Selector?" (DWMTS) type event |
|
611 | + * (ie: $_max_atndz === 1) where there are no available tickets, |
|
612 | + * either because they are sold out, expired, or not yet on sale. |
|
613 | + * In this case, we need to close the form BEFORE adding any closing divs |
|
614 | + * @return string |
|
615 | + * @throws \EE_Error |
|
616 | + */ |
|
617 | + public function displayViewDetailsButton( $DWMTS = false ) |
|
618 | + { |
|
619 | + if ( ! $this->event->get_permalink() ) { |
|
620 | + \EE_Error::add_error( |
|
621 | + esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
622 | + __FILE__, __FUNCTION__, __LINE__ |
|
623 | + ); |
|
624 | + } |
|
625 | + $view_details_btn = '<form method="POST" action="'; |
|
626 | + $view_details_btn .= apply_filters( |
|
627 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_url', |
|
628 | + $this->event->get_permalink(), |
|
629 | + $this->event |
|
630 | + ); |
|
631 | + $view_details_btn .= '"'; |
|
632 | + // open link in new window ? |
|
633 | + $view_details_btn .= apply_filters( |
|
634 | + 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__displayViewDetailsButton__url_target_blank', |
|
635 | + \EED_Events_Archive::is_iframe() |
|
636 | + ) |
|
637 | + ? ' target="_blank"' |
|
638 | + : ''; |
|
639 | + $view_details_btn .='>'; |
|
640 | + $btn_text = apply_filters( |
|
641 | + 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
|
642 | + esc_html__('View Details', 'event_espresso'), |
|
643 | + $this->event |
|
644 | + ); |
|
645 | + $view_details_btn .= '<input id="ticket-selector-submit-' |
|
646 | + . $this->event->ID() |
|
647 | + . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
|
648 | + . $btn_text |
|
649 | + . '" />'; |
|
650 | + $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
651 | + if ($DWMTS) { |
|
652 | + $view_details_btn .= $this->formClose(); |
|
653 | + $view_details_btn .= $this->ticketSelectorEndDiv(); |
|
654 | + $view_details_btn .= '<br/>'; |
|
655 | + } else { |
|
656 | + $view_details_btn .= $this->clearTicketSelector(); |
|
657 | + $view_details_btn .= '<br/>'; |
|
658 | + $view_details_btn .= $this->formClose(); |
|
659 | + } |
|
660 | + return $view_details_btn; |
|
661 | + } |
|
662 | + |
|
663 | + |
|
664 | + |
|
665 | + /** |
|
666 | + * @return string |
|
667 | + */ |
|
668 | + public function ticketSelectorEndDiv() |
|
669 | + { |
|
670 | + return '<div class="clear"></div></div>'; |
|
671 | + } |
|
672 | + |
|
673 | + |
|
674 | + |
|
675 | + /** |
|
676 | + * @return string |
|
677 | + */ |
|
678 | + public function clearTicketSelector() |
|
679 | + { |
|
680 | + // standard TS displayed, appears after a "Register Now" or "view Details" button |
|
681 | + return '<div class="clear"></div>'; |
|
682 | + } |
|
683 | + |
|
684 | + |
|
685 | + |
|
686 | + /** |
|
687 | + * @access public |
|
688 | + * @return string |
|
689 | + */ |
|
690 | + public function formClose() |
|
691 | + { |
|
692 | + return '</form>'; |
|
693 | + } |
|
694 | 694 | |
695 | 695 | |
696 | 696 |
@@ -1,8 +1,8 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\modules\ticket_selector; |
3 | 3 | |
4 | -if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) { |
|
5 | - exit( 'No direct script access allowed' ); |
|
4 | +if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -73,9 +73,9 @@ discard block |
||
73 | 73 | /** |
74 | 74 | * @param boolean $iframe |
75 | 75 | */ |
76 | - public function setIframe( $iframe = true ) |
|
76 | + public function setIframe($iframe = true) |
|
77 | 77 | { |
78 | - $this->iframe = filter_var( $iframe, FILTER_VALIDATE_BOOLEAN ); |
|
78 | + $this->iframe = filter_var($iframe, FILTER_VALIDATE_BOOLEAN); |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | |
@@ -86,28 +86,28 @@ discard block |
||
86 | 86 | * @param mixed $event |
87 | 87 | * @return bool |
88 | 88 | */ |
89 | - protected function setEvent( $event = null ) |
|
89 | + protected function setEvent($event = null) |
|
90 | 90 | { |
91 | - if ( $event === null ) { |
|
91 | + if ($event === null) { |
|
92 | 92 | global $post; |
93 | 93 | $event = $post; |
94 | 94 | } |
95 | - if ( $event instanceof \EE_Event ) { |
|
95 | + if ($event instanceof \EE_Event) { |
|
96 | 96 | $this->event = $event; |
97 | - } else if ( $event instanceof \WP_Post ) { |
|
98 | - if ( isset( $event->EE_Event ) && $event->EE_Event instanceof \EE_Event ) { |
|
97 | + } else if ($event instanceof \WP_Post) { |
|
98 | + if (isset($event->EE_Event) && $event->EE_Event instanceof \EE_Event) { |
|
99 | 99 | $this->event = $event->EE_Event; |
100 | - } else if ( $event->post_type === 'espresso_events' ) { |
|
101 | - $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object( $event ); |
|
100 | + } else if ($event->post_type === 'espresso_events') { |
|
101 | + $event->EE_Event = \EEM_Event::instance()->instantiate_class_from_post_object($event); |
|
102 | 102 | $this->event = $event->EE_Event; |
103 | 103 | } |
104 | 104 | } else { |
105 | - $user_msg = __( 'No Event object or an invalid Event object was supplied.', 'event_espresso' ); |
|
106 | - $dev_msg = $user_msg . __( |
|
105 | + $user_msg = __('No Event object or an invalid Event object was supplied.', 'event_espresso'); |
|
106 | + $dev_msg = $user_msg.__( |
|
107 | 107 | 'In order to generate a ticket selector, please ensure you are passing either an EE_Event object or a WP_Post object of the post type "espresso_event" to the EE_Ticket_Selector class constructor.', |
108 | 108 | 'event_espresso' |
109 | 109 | ); |
110 | - \EE_Error::add_error( $user_msg . '||' . $dev_msg, __FILE__, __FUNCTION__, __LINE__ ); |
|
110 | + \EE_Error::add_error($user_msg.'||'.$dev_msg, __FILE__, __FUNCTION__, __LINE__); |
|
111 | 111 | return false; |
112 | 112 | } |
113 | 113 | return true; |
@@ -148,17 +148,17 @@ discard block |
||
148 | 148 | * @return string |
149 | 149 | * @throws \EE_Error |
150 | 150 | */ |
151 | - public function display( $event = null, $view_details = false ) |
|
151 | + public function display($event = null, $view_details = false) |
|
152 | 152 | { |
153 | 153 | // reset filter for displaying submit button |
154 | - remove_filter( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true' ); |
|
154 | + remove_filter('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', '__return_true'); |
|
155 | 155 | // poke and prod incoming event till it tells us what it is |
156 | - if ( ! $this->setEvent( $event ) ) { |
|
156 | + if ( ! $this->setEvent($event)) { |
|
157 | 157 | return false; |
158 | 158 | } |
159 | 159 | // begin gathering template arguments by getting event status |
160 | - $template_args = array( 'event_status' => $this->event->get_active_status() ); |
|
161 | - if ( $this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details) ) { |
|
160 | + $template_args = array('event_status' => $this->event->get_active_status()); |
|
161 | + if ($this->activeEventAndShowTicketSelector($event, $template_args['event_status'], $view_details)) { |
|
162 | 162 | return ! is_single() ? $this->displayViewDetailsButton() : ''; |
163 | 163 | } |
164 | 164 | // filter the maximum qty that can appear in the Ticket Selector qty dropdowns |
@@ -168,7 +168,7 @@ discard block |
||
168 | 168 | } |
169 | 169 | // is the event expired ? |
170 | 170 | $template_args['event_is_expired'] = $this->event->is_expired(); |
171 | - if ( $template_args[ 'event_is_expired' ] ) { |
|
171 | + if ($template_args['event_is_expired']) { |
|
172 | 172 | return $this->expiredEventMessage(); |
173 | 173 | } |
174 | 174 | // get all tickets for this event ordered by the datetime |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | if (count($tickets) < 1) { |
177 | 177 | return $this->noTicketAvailableMessage(); |
178 | 178 | } |
179 | - if (\EED_Events_Archive::is_iframe()){ |
|
179 | + if (\EED_Events_Archive::is_iframe()) { |
|
180 | 180 | $this->setIframe(); |
181 | 181 | } |
182 | 182 | // redirecting to another site for registration ?? |
@@ -184,10 +184,10 @@ discard block |
||
184 | 184 | // if redirecting to another site for registration, then we don't load the TS |
185 | 185 | $ticket_selector = $external_url |
186 | 186 | ? $this->externalEventRegistration() |
187 | - : $this->loadTicketSelector($tickets,$template_args); |
|
187 | + : $this->loadTicketSelector($tickets, $template_args); |
|
188 | 188 | // now set up the form (but not for the admin) |
189 | 189 | $ticket_selector = ! is_admin() |
190 | - ? $this->formOpen($this->event->ID(), $external_url) . $ticket_selector |
|
190 | + ? $this->formOpen($this->event->ID(), $external_url).$ticket_selector |
|
191 | 191 | : $ticket_selector; |
192 | 192 | // submit button and form close tag |
193 | 193 | $ticket_selector .= ! is_admin() ? $this->displaySubmitButton($external_url) : ''; |
@@ -237,10 +237,10 @@ discard block |
||
237 | 237 | */ |
238 | 238 | protected function expiredEventMessage() |
239 | 239 | { |
240 | - return '<div class="ee-event-expired-notice"><span class="important-notice">' . esc_html__( |
|
240 | + return '<div class="ee-event-expired-notice"><span class="important-notice">'.esc_html__( |
|
241 | 241 | 'We\'re sorry, but all tickets sales have ended because the event is expired.', |
242 | 242 | 'event_espresso' |
243 | - ) . '</span></div>'; |
|
243 | + ).'</span></div>'; |
|
244 | 244 | } |
245 | 245 | |
246 | 246 | |
@@ -254,7 +254,7 @@ discard block |
||
254 | 254 | */ |
255 | 255 | protected function noTicketAvailableMessage() |
256 | 256 | { |
257 | - $no_ticket_available_msg = esc_html__( 'We\'re sorry, but all ticket sales have ended.', 'event_espresso' ); |
|
257 | + $no_ticket_available_msg = esc_html__('We\'re sorry, but all ticket sales have ended.', 'event_espresso'); |
|
258 | 258 | if (current_user_can('edit_post', $this->event->ID())) { |
259 | 259 | $no_ticket_available_msg .= sprintf( |
260 | 260 | esc_html__( |
@@ -269,7 +269,7 @@ discard block |
||
269 | 269 | } |
270 | 270 | return ' |
271 | 271 | <div class="ee-event-expired-notice"> |
272 | - <span class="important-notice">' . $no_ticket_available_msg . '</span> |
|
272 | + <span class="important-notice">' . $no_ticket_available_msg.'</span> |
|
273 | 273 | </div>'; |
274 | 274 | } |
275 | 275 | |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | '</a></span></div>' |
301 | 301 | ); |
302 | 302 | } |
303 | - return '<p><span class="important-notice">' . $sales_closed_msg . '</span></p>'; |
|
303 | + return '<p><span class="important-notice">'.$sales_closed_msg.'</span></p>'; |
|
304 | 304 | } |
305 | 305 | |
306 | 306 | |
@@ -362,12 +362,12 @@ discard block |
||
362 | 362 | */ |
363 | 363 | $template_args['anchor_id'] = apply_filters( |
364 | 364 | 'FHEE__EE_Ticket_Selector__redirect_anchor_id', |
365 | - '#tkt-slctr-tbl-' . $this->event->ID(), |
|
365 | + '#tkt-slctr-tbl-'.$this->event->ID(), |
|
366 | 366 | $this->event->ID() |
367 | 367 | ); |
368 | 368 | $template_args['tickets'] = $tickets; |
369 | 369 | $template_args['ticket_count'] = count($tickets); |
370 | - $ticket_selector = $this->simpleTicketSelector( $tickets, $template_args); |
|
370 | + $ticket_selector = $this->simpleTicketSelector($tickets, $template_args); |
|
371 | 371 | return $ticket_selector instanceof TicketSelectorSimple |
372 | 372 | ? $ticket_selector |
373 | 373 | : new TicketSelectorStandard( |
@@ -448,11 +448,11 @@ discard block |
||
448 | 448 | * @param string $external_url |
449 | 449 | * @return string |
450 | 450 | */ |
451 | - public function formOpen( $ID = 0, $external_url = '' ) |
|
451 | + public function formOpen($ID = 0, $external_url = '') |
|
452 | 452 | { |
453 | 453 | // if redirecting, we don't need any anything else |
454 | - if ( $external_url ) { |
|
455 | - $html = '<form method="GET" action="' . \EEH_URL::refactor_url($external_url) . '"'; |
|
454 | + if ($external_url) { |
|
455 | + $html = '<form method="GET" action="'.\EEH_URL::refactor_url($external_url).'"'; |
|
456 | 456 | // open link in new window ? |
457 | 457 | $html .= apply_filters( |
458 | 458 | 'FHEE__EventEspresso_modules_ticket_selector_DisplayTicketSelector__formOpen__external_url_target_blank', |
@@ -461,21 +461,21 @@ discard block |
||
461 | 461 | ? ' target="_blank"' |
462 | 462 | : ''; |
463 | 463 | $html .= '>'; |
464 | - $query_args = \EEH_URL::get_query_string( $external_url ); |
|
465 | - foreach ( (array)$query_args as $query_arg => $value ) { |
|
466 | - $html .= '<input type="hidden" name="' . $query_arg . '" value="' . $value . '">'; |
|
464 | + $query_args = \EEH_URL::get_query_string($external_url); |
|
465 | + foreach ((array) $query_args as $query_arg => $value) { |
|
466 | + $html .= '<input type="hidden" name="'.$query_arg.'" value="'.$value.'">'; |
|
467 | 467 | } |
468 | 468 | return $html; |
469 | 469 | } |
470 | 470 | // if there is no submit button, then don't start building a form |
471 | 471 | // because the "View Details" button will build its own form |
472 | - if ( ! apply_filters( 'FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false ) ) { |
|
472 | + if ( ! apply_filters('FHEE__EE_Ticket_Selector__display_ticket_selector_submit', false)) { |
|
473 | 473 | return ''; |
474 | 474 | } |
475 | - $checkout_url = \EEH_Event_View::event_link_url( $ID ); |
|
476 | - if ( ! $checkout_url ) { |
|
475 | + $checkout_url = \EEH_Event_View::event_link_url($ID); |
|
476 | + if ( ! $checkout_url) { |
|
477 | 477 | \EE_Error::add_error( |
478 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
478 | + esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
479 | 479 | __FILE__, |
480 | 480 | __FUNCTION__, |
481 | 481 | __LINE__ |
@@ -484,10 +484,10 @@ discard block |
||
484 | 484 | // set no cache headers and constants |
485 | 485 | \EE_System::do_not_cache(); |
486 | 486 | $extra_params = $this->iframe ? ' target="_blank"' : ''; |
487 | - $html = '<form method="POST" action="' . $checkout_url . '"' . $extra_params . '>'; |
|
488 | - $html .= wp_nonce_field( 'process_ticket_selections', 'process_ticket_selections_nonce_' . $ID, true, false ); |
|
487 | + $html = '<form method="POST" action="'.$checkout_url.'"'.$extra_params.'>'; |
|
488 | + $html .= wp_nonce_field('process_ticket_selections', 'process_ticket_selections_nonce_'.$ID, true, false); |
|
489 | 489 | $html .= '<input type="hidden" name="ee" value="process_ticket_selections">'; |
490 | - $html = apply_filters( 'FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event ); |
|
490 | + $html = apply_filters('FHEE__EE_Ticket_Selector__ticket_selector_form_open__html', $html, $this->event); |
|
491 | 491 | return $html; |
492 | 492 | } |
493 | 493 | |
@@ -510,7 +510,7 @@ discard block |
||
510 | 510 | $html .= empty($external_url) |
511 | 511 | ? $this->ticketSelectorEndDiv() |
512 | 512 | : $this->clearTicketSelector(); |
513 | - $html .= '<br/>' . $this->formClose(); |
|
513 | + $html .= '<br/>'.$this->formClose(); |
|
514 | 514 | } else if ($this->getMaxAttendees() === 1) { |
515 | 515 | // its a "Dude Where's my Ticket Selector?" (DWMTS) type event (ie: $_max_atndz === 1) |
516 | 516 | if ($this->event->is_sold_out()) { |
@@ -588,12 +588,12 @@ discard block |
||
588 | 588 | ); |
589 | 589 | $external_url = $this->event->external_url(); |
590 | 590 | $html = \EEH_HTML::div( |
591 | - '', 'ticket-selector-submit-' . $this->event->ID() . '-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
591 | + '', 'ticket-selector-submit-'.$this->event->ID().'-btn-wrap', 'ticket-selector-submit-btn-wrap' |
|
592 | 592 | ); |
593 | - $html .= '<input id="ticket-selector-submit-' . $this->event->ID() . '-btn"'; |
|
593 | + $html .= '<input id="ticket-selector-submit-'.$this->event->ID().'-btn"'; |
|
594 | 594 | $html .= ' class="ticket-selector-submit-btn '; |
595 | 595 | $html .= empty($external_url) ? 'ticket-selector-submit-ajax"' : '"'; |
596 | - $html .= ' type="submit" value="' . $btn_text . '" />'; |
|
596 | + $html .= ' type="submit" value="'.$btn_text.'" />'; |
|
597 | 597 | $html .= \EEH_HTML::divx(); |
598 | 598 | $html .= apply_filters( |
599 | 599 | 'FHEE__EE_Ticket_Selector__after_ticket_selector_submit', |
@@ -614,11 +614,11 @@ discard block |
||
614 | 614 | * @return string |
615 | 615 | * @throws \EE_Error |
616 | 616 | */ |
617 | - public function displayViewDetailsButton( $DWMTS = false ) |
|
617 | + public function displayViewDetailsButton($DWMTS = false) |
|
618 | 618 | { |
619 | - if ( ! $this->event->get_permalink() ) { |
|
619 | + if ( ! $this->event->get_permalink()) { |
|
620 | 620 | \EE_Error::add_error( |
621 | - esc_html__( 'The URL for the Event Details page could not be retrieved.', 'event_espresso' ), |
|
621 | + esc_html__('The URL for the Event Details page could not be retrieved.', 'event_espresso'), |
|
622 | 622 | __FILE__, __FUNCTION__, __LINE__ |
623 | 623 | ); |
624 | 624 | } |
@@ -636,7 +636,7 @@ discard block |
||
636 | 636 | ) |
637 | 637 | ? ' target="_blank"' |
638 | 638 | : ''; |
639 | - $view_details_btn .='>'; |
|
639 | + $view_details_btn .= '>'; |
|
640 | 640 | $btn_text = apply_filters( |
641 | 641 | 'FHEE__EE_Ticket_Selector__display_view_details_btn__btn_text', |
642 | 642 | esc_html__('View Details', 'event_espresso'), |
@@ -647,7 +647,7 @@ discard block |
||
647 | 647 | . '-btn" class="ticket-selector-submit-btn view-details-btn" type="submit" value="' |
648 | 648 | . $btn_text |
649 | 649 | . '" />'; |
650 | - $view_details_btn .= apply_filters( 'FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event ); |
|
650 | + $view_details_btn .= apply_filters('FHEE__EE_Ticket_Selector__after_view_details_btn', '', $this->event); |
|
651 | 651 | if ($DWMTS) { |
652 | 652 | $view_details_btn .= $this->formClose(); |
653 | 653 | $view_details_btn .= $this->ticketSelectorEndDiv(); |
@@ -15,21 +15,21 @@ discard block |
||
15 | 15 | class EventListIframeEmbedButton extends IframeEmbedButton |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * EventListIframeEmbedButton constructor. |
|
20 | - */ |
|
21 | - public function __construct() |
|
22 | - { |
|
23 | - parent::__construct( |
|
24 | - esc_html__( 'Upcoming Event List', 'event_espresso' ), |
|
25 | - 'event_list' |
|
26 | - ); |
|
27 | - } |
|
18 | + /** |
|
19 | + * EventListIframeEmbedButton constructor. |
|
20 | + */ |
|
21 | + public function __construct() |
|
22 | + { |
|
23 | + parent::__construct( |
|
24 | + esc_html__( 'Upcoming Event List', 'event_espresso' ), |
|
25 | + 'event_list' |
|
26 | + ); |
|
27 | + } |
|
28 | 28 | |
29 | 29 | |
30 | 30 | |
31 | 31 | public function addEmbedButton() { |
32 | - add_filter( |
|
32 | + add_filter( |
|
33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
34 | 34 | array( $this, 'addEventListIframeEmbedButtonSection' ) |
35 | 35 | ); |
@@ -49,18 +49,18 @@ discard block |
||
49 | 49 | * @param array $after_list_table |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
53 | - { |
|
54 | - return \EEH_Array::insert_into_array( |
|
55 | - $after_list_table, |
|
56 | - array( |
|
57 | - 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
58 | - array( 'event_list' => $this->embedButtonHtml() ) |
|
59 | - ) |
|
60 | - ), |
|
61 | - 'legend' |
|
62 | - ); |
|
63 | - } |
|
52 | + public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
53 | + { |
|
54 | + return \EEH_Array::insert_into_array( |
|
55 | + $after_list_table, |
|
56 | + array( |
|
57 | + 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
|
58 | + array( 'event_list' => $this->embedButtonHtml() ) |
|
59 | + ) |
|
60 | + ), |
|
61 | + 'legend' |
|
62 | + ); |
|
63 | + } |
|
64 | 64 | |
65 | 65 | |
66 | 66 |
@@ -1,7 +1,7 @@ discard block |
||
1 | 1 | <?php |
2 | 2 | namespace EventEspresso\core\libraries\iframe_display; |
3 | 3 | |
4 | -defined( 'ABSPATH' ) || exit; |
|
4 | +defined('ABSPATH') || exit; |
|
5 | 5 | |
6 | 6 | |
7 | 7 | |
@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | public function __construct() |
22 | 22 | { |
23 | 23 | parent::__construct( |
24 | - esc_html__( 'Upcoming Event List', 'event_espresso' ), |
|
24 | + esc_html__('Upcoming Event List', 'event_espresso'), |
|
25 | 25 | 'event_list' |
26 | 26 | ); |
27 | 27 | } |
@@ -31,11 +31,11 @@ discard block |
||
31 | 31 | public function addEmbedButton() { |
32 | 32 | add_filter( |
33 | 33 | 'FHEE__EE_Admin_Page___display_admin_list_table_page__after_list_table__template_args_array', |
34 | - array( $this, 'addEventListIframeEmbedButtonSection' ) |
|
34 | + array($this, 'addEventListIframeEmbedButtonSection') |
|
35 | 35 | ); |
36 | 36 | add_action( |
37 | 37 | 'admin_enqueue_scripts', |
38 | - array( $this, 'embedButtonAssets' ), |
|
38 | + array($this, 'embedButtonAssets'), |
|
39 | 39 | 10 |
40 | 40 | ); |
41 | 41 | } |
@@ -49,13 +49,13 @@ discard block |
||
49 | 49 | * @param array $after_list_table |
50 | 50 | * @return array |
51 | 51 | */ |
52 | - public function addEventListIframeEmbedButtonSection( array $after_list_table ) |
|
52 | + public function addEventListIframeEmbedButtonSection(array $after_list_table) |
|
53 | 53 | { |
54 | 54 | return \EEH_Array::insert_into_array( |
55 | 55 | $after_list_table, |
56 | 56 | array( |
57 | 57 | 'iframe_embed_buttons' => $this->addIframeEmbedButtonsSection( |
58 | - array( 'event_list' => $this->embedButtonHtml() ) |
|
58 | + array('event_list' => $this->embedButtonHtml()) |
|
59 | 59 | ) |
60 | 60 | ), |
61 | 61 | 'legend' |
@@ -1,5 +1,5 @@ discard block |
||
1 | 1 | <?php if ( ! defined('ABSPATH')) { |
2 | - exit('No direct script access allowed'); |
|
2 | + exit('No direct script access allowed'); |
|
3 | 3 | } |
4 | 4 | /* |
5 | 5 | Plugin Name: Event Espresso |
@@ -40,243 +40,243 @@ discard block |
||
40 | 40 | * @since 4.0 |
41 | 41 | */ |
42 | 42 | if (function_exists('espresso_version')) { |
43 | - /** |
|
44 | - * espresso_duplicate_plugin_error |
|
45 | - * displays if more than one version of EE is activated at the same time |
|
46 | - */ |
|
47 | - function espresso_duplicate_plugin_error() |
|
48 | - { |
|
49 | - ?> |
|
43 | + /** |
|
44 | + * espresso_duplicate_plugin_error |
|
45 | + * displays if more than one version of EE is activated at the same time |
|
46 | + */ |
|
47 | + function espresso_duplicate_plugin_error() |
|
48 | + { |
|
49 | + ?> |
|
50 | 50 | <div class="error"> |
51 | 51 | <p> |
52 | 52 | <?php echo esc_html__( |
53 | - 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | - 'event_espresso' |
|
55 | - ); ?> |
|
53 | + 'Can not run multiple versions of Event Espresso! One version has been automatically deactivated. Please verify that you have the correct version you want still active.', |
|
54 | + 'event_espresso' |
|
55 | + ); ?> |
|
56 | 56 | </p> |
57 | 57 | </div> |
58 | 58 | <?php |
59 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | - } |
|
59 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
60 | + } |
|
61 | 61 | |
62 | - add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
62 | + add_action('admin_notices', 'espresso_duplicate_plugin_error', 1); |
|
63 | 63 | } else { |
64 | - define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | - if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | - /** |
|
67 | - * espresso_minimum_php_version_error |
|
68 | - * |
|
69 | - * @return void |
|
70 | - */ |
|
71 | - function espresso_minimum_php_version_error() |
|
72 | - { |
|
73 | - ?> |
|
64 | + define('EE_MIN_PHP_VER_REQUIRED', '5.3.9'); |
|
65 | + if ( ! version_compare(PHP_VERSION, EE_MIN_PHP_VER_REQUIRED, '>=')) { |
|
66 | + /** |
|
67 | + * espresso_minimum_php_version_error |
|
68 | + * |
|
69 | + * @return void |
|
70 | + */ |
|
71 | + function espresso_minimum_php_version_error() |
|
72 | + { |
|
73 | + ?> |
|
74 | 74 | <div class="error"> |
75 | 75 | <p> |
76 | 76 | <?php |
77 | - printf( |
|
78 | - esc_html__( |
|
79 | - 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | - 'event_espresso' |
|
81 | - ), |
|
82 | - EE_MIN_PHP_VER_REQUIRED, |
|
83 | - PHP_VERSION, |
|
84 | - '<br/>', |
|
85 | - '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | - ); |
|
87 | - ?> |
|
77 | + printf( |
|
78 | + esc_html__( |
|
79 | + 'We\'re sorry, but Event Espresso requires PHP version %1$s or greater in order to operate. You are currently running version %2$s.%3$sIn order to update your version of PHP, you will need to contact your current hosting provider.%3$sFor information on stable PHP versions, please go to %4$s.', |
|
80 | + 'event_espresso' |
|
81 | + ), |
|
82 | + EE_MIN_PHP_VER_REQUIRED, |
|
83 | + PHP_VERSION, |
|
84 | + '<br/>', |
|
85 | + '<a href="http://php.net/downloads.php">http://php.net/downloads.php</a>' |
|
86 | + ); |
|
87 | + ?> |
|
88 | 88 | </p> |
89 | 89 | </div> |
90 | 90 | <?php |
91 | - espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | - } |
|
91 | + espresso_deactivate_plugin(plugin_basename(__FILE__)); |
|
92 | + } |
|
93 | 93 | |
94 | - add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | - } else { |
|
96 | - /** |
|
97 | - * espresso_version |
|
98 | - * Returns the plugin version |
|
99 | - * |
|
100 | - * @return string |
|
101 | - */ |
|
102 | - function espresso_version() |
|
103 | - { |
|
104 | - return apply_filters('FHEE__espresso__espresso_version', '4.9.32.rc.026'); |
|
105 | - } |
|
94 | + add_action('admin_notices', 'espresso_minimum_php_version_error', 1); |
|
95 | + } else { |
|
96 | + /** |
|
97 | + * espresso_version |
|
98 | + * Returns the plugin version |
|
99 | + * |
|
100 | + * @return string |
|
101 | + */ |
|
102 | + function espresso_version() |
|
103 | + { |
|
104 | + return apply_filters('FHEE__espresso__espresso_version', '4.9.32.rc.026'); |
|
105 | + } |
|
106 | 106 | |
107 | - // define versions |
|
108 | - define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | - define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | - define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | - define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | - define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | - //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | - if ( ! defined('DS')) { |
|
115 | - define('DS', '/'); |
|
116 | - } |
|
117 | - if ( ! defined('PS')) { |
|
118 | - define('PS', PATH_SEPARATOR); |
|
119 | - } |
|
120 | - if ( ! defined('SP')) { |
|
121 | - define('SP', ' '); |
|
122 | - } |
|
123 | - if ( ! defined('EENL')) { |
|
124 | - define('EENL', "\n"); |
|
125 | - } |
|
126 | - define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | - // define the plugin directory and URL |
|
128 | - define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | - define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | - define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | - // main root folder paths |
|
132 | - define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | - define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | - define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | - define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | - define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | - define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | - define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | - define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | - // core system paths |
|
141 | - define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | - define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | - define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | - define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | - define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | - define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | - define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | - define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | - define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | - define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | - define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | - define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | - // gateways |
|
154 | - define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | - define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | - // asset URL paths |
|
157 | - define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | - define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | - define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | - define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | - define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | - define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | - // define upload paths |
|
164 | - $uploads = wp_upload_dir(); |
|
165 | - // define the uploads directory and URL |
|
166 | - define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | - define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | - // define the templates directory and URL |
|
169 | - define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | - define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | - // define the gateway directory and URL |
|
172 | - define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | - define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | - // languages folder/path |
|
175 | - define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | - define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | - //check for dompdf fonts in uploads |
|
178 | - if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | - define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | - } |
|
181 | - //ajax constants |
|
182 | - define( |
|
183 | - 'EE_FRONT_AJAX', |
|
184 | - isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | - ); |
|
186 | - define( |
|
187 | - 'EE_ADMIN_AJAX', |
|
188 | - isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | - ); |
|
190 | - //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | - //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | - //want to change its default value! or find when -1 means infinity |
|
193 | - define('EE_INF_IN_DB', -1); |
|
194 | - define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | - define('EE_DEBUG', false); |
|
196 | - // for older WP versions |
|
197 | - if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | - define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | - } |
|
200 | - /** |
|
201 | - * espresso_plugin_activation |
|
202 | - * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | - */ |
|
204 | - function espresso_plugin_activation() |
|
205 | - { |
|
206 | - update_option('ee_espresso_activation', true); |
|
207 | - } |
|
107 | + // define versions |
|
108 | + define('EVENT_ESPRESSO_VERSION', espresso_version()); |
|
109 | + define('EE_MIN_WP_VER_REQUIRED', '4.1'); |
|
110 | + define('EE_MIN_WP_VER_RECOMMENDED', '4.4.2'); |
|
111 | + define('EE_MIN_PHP_VER_RECOMMENDED', '5.4.44'); |
|
112 | + define('EVENT_ESPRESSO_MAIN_FILE', __FILE__); |
|
113 | + //used to be DIRECTORY_SEPARATOR, but that caused issues on windows |
|
114 | + if ( ! defined('DS')) { |
|
115 | + define('DS', '/'); |
|
116 | + } |
|
117 | + if ( ! defined('PS')) { |
|
118 | + define('PS', PATH_SEPARATOR); |
|
119 | + } |
|
120 | + if ( ! defined('SP')) { |
|
121 | + define('SP', ' '); |
|
122 | + } |
|
123 | + if ( ! defined('EENL')) { |
|
124 | + define('EENL', "\n"); |
|
125 | + } |
|
126 | + define('EE_SUPPORT_EMAIL', '[email protected]'); |
|
127 | + // define the plugin directory and URL |
|
128 | + define('EE_PLUGIN_BASENAME', plugin_basename(EVENT_ESPRESSO_MAIN_FILE)); |
|
129 | + define('EE_PLUGIN_DIR_PATH', plugin_dir_path(EVENT_ESPRESSO_MAIN_FILE)); |
|
130 | + define('EE_PLUGIN_DIR_URL', plugin_dir_url(EVENT_ESPRESSO_MAIN_FILE)); |
|
131 | + // main root folder paths |
|
132 | + define('EE_ADMIN_PAGES', EE_PLUGIN_DIR_PATH . 'admin_pages' . DS); |
|
133 | + define('EE_CORE', EE_PLUGIN_DIR_PATH . 'core' . DS); |
|
134 | + define('EE_MODULES', EE_PLUGIN_DIR_PATH . 'modules' . DS); |
|
135 | + define('EE_PUBLIC', EE_PLUGIN_DIR_PATH . 'public' . DS); |
|
136 | + define('EE_SHORTCODES', EE_PLUGIN_DIR_PATH . 'shortcodes' . DS); |
|
137 | + define('EE_WIDGETS', EE_PLUGIN_DIR_PATH . 'widgets' . DS); |
|
138 | + define('EE_PAYMENT_METHODS', EE_PLUGIN_DIR_PATH . 'payment_methods' . DS); |
|
139 | + define('EE_CAFF_PATH', EE_PLUGIN_DIR_PATH . 'caffeinated' . DS); |
|
140 | + // core system paths |
|
141 | + define('EE_ADMIN', EE_CORE . 'admin' . DS); |
|
142 | + define('EE_CPTS', EE_CORE . 'CPTs' . DS); |
|
143 | + define('EE_CLASSES', EE_CORE . 'db_classes' . DS); |
|
144 | + define('EE_INTERFACES', EE_CORE . 'interfaces' . DS); |
|
145 | + define('EE_BUSINESS', EE_CORE . 'business' . DS); |
|
146 | + define('EE_MODELS', EE_CORE . 'db_models' . DS); |
|
147 | + define('EE_HELPERS', EE_CORE . 'helpers' . DS); |
|
148 | + define('EE_LIBRARIES', EE_CORE . 'libraries' . DS); |
|
149 | + define('EE_TEMPLATES', EE_CORE . 'templates' . DS); |
|
150 | + define('EE_THIRD_PARTY', EE_CORE . 'third_party_libs' . DS); |
|
151 | + define('EE_GLOBAL_ASSETS', EE_TEMPLATES . 'global_assets' . DS); |
|
152 | + define('EE_FORM_SECTIONS', EE_LIBRARIES . 'form_sections' . DS); |
|
153 | + // gateways |
|
154 | + define('EE_GATEWAYS', EE_MODULES . 'gateways' . DS); |
|
155 | + define('EE_GATEWAYS_URL', EE_PLUGIN_DIR_URL . 'modules' . DS . 'gateways' . DS); |
|
156 | + // asset URL paths |
|
157 | + define('EE_TEMPLATES_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'templates' . DS); |
|
158 | + define('EE_GLOBAL_ASSETS_URL', EE_TEMPLATES_URL . 'global_assets' . DS); |
|
159 | + define('EE_IMAGES_URL', EE_GLOBAL_ASSETS_URL . 'images' . DS); |
|
160 | + define('EE_THIRD_PARTY_URL', EE_PLUGIN_DIR_URL . 'core' . DS . 'third_party_libs' . DS); |
|
161 | + define('EE_HELPERS_ASSETS', EE_PLUGIN_DIR_URL . 'core/helpers/assets/'); |
|
162 | + define('EE_LIBRARIES_URL', EE_PLUGIN_DIR_URL . 'core/libraries/'); |
|
163 | + // define upload paths |
|
164 | + $uploads = wp_upload_dir(); |
|
165 | + // define the uploads directory and URL |
|
166 | + define('EVENT_ESPRESSO_UPLOAD_DIR', $uploads['basedir'] . DS . 'espresso' . DS); |
|
167 | + define('EVENT_ESPRESSO_UPLOAD_URL', $uploads['baseurl'] . DS . 'espresso' . DS); |
|
168 | + // define the templates directory and URL |
|
169 | + define('EVENT_ESPRESSO_TEMPLATE_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'templates' . DS); |
|
170 | + define('EVENT_ESPRESSO_TEMPLATE_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'templates' . DS); |
|
171 | + // define the gateway directory and URL |
|
172 | + define('EVENT_ESPRESSO_GATEWAY_DIR', $uploads['basedir'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
173 | + define('EVENT_ESPRESSO_GATEWAY_URL', $uploads['baseurl'] . DS . 'espresso' . DS . 'gateways' . DS); |
|
174 | + // languages folder/path |
|
175 | + define('EE_LANGUAGES_SAFE_LOC', '..' . DS . 'uploads' . DS . 'espresso' . DS . 'languages' . DS); |
|
176 | + define('EE_LANGUAGES_SAFE_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'languages' . DS); |
|
177 | + //check for dompdf fonts in uploads |
|
178 | + if (file_exists(EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS)) { |
|
179 | + define('DOMPDF_FONT_DIR', EVENT_ESPRESSO_UPLOAD_DIR . 'fonts' . DS); |
|
180 | + } |
|
181 | + //ajax constants |
|
182 | + define( |
|
183 | + 'EE_FRONT_AJAX', |
|
184 | + isset($_REQUEST['ee_front_ajax']) || isset($_REQUEST['data']['ee_front_ajax']) ? true : false |
|
185 | + ); |
|
186 | + define( |
|
187 | + 'EE_ADMIN_AJAX', |
|
188 | + isset($_REQUEST['ee_admin_ajax']) || isset($_REQUEST['data']['ee_admin_ajax']) ? true : false |
|
189 | + ); |
|
190 | + //just a handy constant occasionally needed for finding values representing infinity in the DB |
|
191 | + //you're better to use this than its straight value (currently -1) in case you ever |
|
192 | + //want to change its default value! or find when -1 means infinity |
|
193 | + define('EE_INF_IN_DB', -1); |
|
194 | + define('EE_INF', INF > (float)PHP_INT_MAX ? INF : PHP_INT_MAX); |
|
195 | + define('EE_DEBUG', false); |
|
196 | + // for older WP versions |
|
197 | + if ( ! defined('MONTH_IN_SECONDS')) { |
|
198 | + define('MONTH_IN_SECONDS', DAY_IN_SECONDS * 30); |
|
199 | + } |
|
200 | + /** |
|
201 | + * espresso_plugin_activation |
|
202 | + * adds a wp-option to indicate that EE has been activated via the WP admin plugins page |
|
203 | + */ |
|
204 | + function espresso_plugin_activation() |
|
205 | + { |
|
206 | + update_option('ee_espresso_activation', true); |
|
207 | + } |
|
208 | 208 | |
209 | - register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | - /** |
|
211 | - * espresso_load_error_handling |
|
212 | - * this function loads EE's class for handling exceptions and errors |
|
213 | - */ |
|
214 | - function espresso_load_error_handling() |
|
215 | - { |
|
216 | - // load debugging tools |
|
217 | - if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | - require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | - EEH_Debug_Tools::instance(); |
|
220 | - } |
|
221 | - // load error handling |
|
222 | - if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | - require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | - } else { |
|
225 | - wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | - } |
|
227 | - } |
|
209 | + register_activation_hook(EVENT_ESPRESSO_MAIN_FILE, 'espresso_plugin_activation'); |
|
210 | + /** |
|
211 | + * espresso_load_error_handling |
|
212 | + * this function loads EE's class for handling exceptions and errors |
|
213 | + */ |
|
214 | + function espresso_load_error_handling() |
|
215 | + { |
|
216 | + // load debugging tools |
|
217 | + if (WP_DEBUG === true && is_readable(EE_HELPERS . 'EEH_Debug_Tools.helper.php')) { |
|
218 | + require_once(EE_HELPERS . 'EEH_Debug_Tools.helper.php'); |
|
219 | + EEH_Debug_Tools::instance(); |
|
220 | + } |
|
221 | + // load error handling |
|
222 | + if (is_readable(EE_CORE . 'EE_Error.core.php')) { |
|
223 | + require_once(EE_CORE . 'EE_Error.core.php'); |
|
224 | + } else { |
|
225 | + wp_die(esc_html__('The EE_Error core class could not be loaded.', 'event_espresso')); |
|
226 | + } |
|
227 | + } |
|
228 | 228 | |
229 | - /** |
|
230 | - * espresso_load_required |
|
231 | - * given a class name and path, this function will load that file or throw an exception |
|
232 | - * |
|
233 | - * @param string $classname |
|
234 | - * @param string $full_path_to_file |
|
235 | - * @throws EE_Error |
|
236 | - */ |
|
237 | - function espresso_load_required($classname, $full_path_to_file) |
|
238 | - { |
|
239 | - static $error_handling_loaded = false; |
|
240 | - if ( ! $error_handling_loaded) { |
|
241 | - espresso_load_error_handling(); |
|
242 | - $error_handling_loaded = true; |
|
243 | - } |
|
244 | - if (is_readable($full_path_to_file)) { |
|
245 | - require_once($full_path_to_file); |
|
246 | - } else { |
|
247 | - throw new EE_Error ( |
|
248 | - sprintf( |
|
249 | - esc_html__( |
|
250 | - 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | - 'event_espresso' |
|
252 | - ), |
|
253 | - $classname |
|
254 | - ) |
|
255 | - ); |
|
256 | - } |
|
257 | - } |
|
229 | + /** |
|
230 | + * espresso_load_required |
|
231 | + * given a class name and path, this function will load that file or throw an exception |
|
232 | + * |
|
233 | + * @param string $classname |
|
234 | + * @param string $full_path_to_file |
|
235 | + * @throws EE_Error |
|
236 | + */ |
|
237 | + function espresso_load_required($classname, $full_path_to_file) |
|
238 | + { |
|
239 | + static $error_handling_loaded = false; |
|
240 | + if ( ! $error_handling_loaded) { |
|
241 | + espresso_load_error_handling(); |
|
242 | + $error_handling_loaded = true; |
|
243 | + } |
|
244 | + if (is_readable($full_path_to_file)) { |
|
245 | + require_once($full_path_to_file); |
|
246 | + } else { |
|
247 | + throw new EE_Error ( |
|
248 | + sprintf( |
|
249 | + esc_html__( |
|
250 | + 'The %s class file could not be located or is not readable due to file permissions.', |
|
251 | + 'event_espresso' |
|
252 | + ), |
|
253 | + $classname |
|
254 | + ) |
|
255 | + ); |
|
256 | + } |
|
257 | + } |
|
258 | 258 | |
259 | - espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | - espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | - espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | - new EE_Bootstrap(); |
|
263 | - } |
|
259 | + espresso_load_required('EEH_Base', EE_CORE . 'helpers' . DS . 'EEH_Base.helper.php'); |
|
260 | + espresso_load_required('EEH_File', EE_CORE . 'helpers' . DS . 'EEH_File.helper.php'); |
|
261 | + espresso_load_required('EE_Bootstrap', EE_CORE . 'EE_Bootstrap.core.php'); |
|
262 | + new EE_Bootstrap(); |
|
263 | + } |
|
264 | 264 | } |
265 | 265 | if ( ! function_exists('espresso_deactivate_plugin')) { |
266 | - /** |
|
267 | - * deactivate_plugin |
|
268 | - * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | - * |
|
270 | - * @access public |
|
271 | - * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | - * @return void |
|
273 | - */ |
|
274 | - function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | - { |
|
276 | - if ( ! function_exists('deactivate_plugins')) { |
|
277 | - require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | - } |
|
279 | - unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | - deactivate_plugins($plugin_basename); |
|
281 | - } |
|
266 | + /** |
|
267 | + * deactivate_plugin |
|
268 | + * usage: espresso_deactivate_plugin( plugin_basename( __FILE__ )); |
|
269 | + * |
|
270 | + * @access public |
|
271 | + * @param string $plugin_basename - the results of plugin_basename( __FILE__ ) for the plugin's main file |
|
272 | + * @return void |
|
273 | + */ |
|
274 | + function espresso_deactivate_plugin($plugin_basename = '') |
|
275 | + { |
|
276 | + if ( ! function_exists('deactivate_plugins')) { |
|
277 | + require_once(ABSPATH . 'wp-admin/includes/plugin.php'); |
|
278 | + } |
|
279 | + unset($_GET['activate'], $_REQUEST['activate']); |
|
280 | + deactivate_plugins($plugin_basename); |
|
281 | + } |
|
282 | 282 | } |
283 | 283 | \ No newline at end of file |
@@ -172,7 +172,7 @@ discard block |
||
172 | 172 | * Sets quantity |
173 | 173 | * @param int $quantity |
174 | 174 | */ |
175 | - public function set_quantity( $quantity ) { |
|
175 | + public function set_quantity( $quantity ) { |
|
176 | 176 | $this->set( 'LIN_quantity', max( $quantity, 0 ) ); |
177 | 177 | } |
178 | 178 | |
@@ -212,25 +212,25 @@ discard block |
||
212 | 212 | * Gets item_type |
213 | 213 | * @return string |
214 | 214 | */ |
215 | - public function OBJ_type_i18n() { |
|
216 | - $obj_type = $this->OBJ_type(); |
|
217 | - switch ($obj_type) { |
|
218 | - case 'Event': |
|
219 | - $obj_type = __('Event', 'event_espresso'); |
|
220 | - break; |
|
221 | - case 'Price': |
|
222 | - $obj_type = __('Price', 'event_espresso'); |
|
223 | - break; |
|
224 | - case 'Promotion': |
|
225 | - $obj_type = __('Promotion', 'event_espresso'); |
|
226 | - break; |
|
227 | - case 'Ticket': |
|
228 | - $obj_type = __('Ticket', 'event_espresso'); |
|
229 | - break; |
|
230 | - case 'Transaction': |
|
231 | - $obj_type = __('Transaction', 'event_espresso'); |
|
232 | - break; |
|
233 | - } |
|
215 | + public function OBJ_type_i18n() { |
|
216 | + $obj_type = $this->OBJ_type(); |
|
217 | + switch ($obj_type) { |
|
218 | + case 'Event': |
|
219 | + $obj_type = __('Event', 'event_espresso'); |
|
220 | + break; |
|
221 | + case 'Price': |
|
222 | + $obj_type = __('Price', 'event_espresso'); |
|
223 | + break; |
|
224 | + case 'Promotion': |
|
225 | + $obj_type = __('Promotion', 'event_espresso'); |
|
226 | + break; |
|
227 | + case 'Ticket': |
|
228 | + $obj_type = __('Ticket', 'event_espresso'); |
|
229 | + break; |
|
230 | + case 'Transaction': |
|
231 | + $obj_type = __('Transaction', 'event_espresso'); |
|
232 | + break; |
|
233 | + } |
|
234 | 234 | return apply_filters('FHEE__EE_Line_Item__OBJ_type_i18n', $obj_type, $this); |
235 | 235 | } |
236 | 236 | |
@@ -1244,48 +1244,48 @@ discard block |
||
1244 | 1244 | |
1245 | 1245 | |
1246 | 1246 | |
1247 | - /** |
|
1248 | - * @param bool $raw |
|
1249 | - * @return int |
|
1250 | - * @throws \EE_Error |
|
1251 | - */ |
|
1252 | - public function timestamp($raw = false) |
|
1253 | - { |
|
1254 | - return $raw ? $this->get_raw('LIN_timestamp') : $this->get('LIN_timestamp'); |
|
1255 | - } |
|
1247 | + /** |
|
1248 | + * @param bool $raw |
|
1249 | + * @return int |
|
1250 | + * @throws \EE_Error |
|
1251 | + */ |
|
1252 | + public function timestamp($raw = false) |
|
1253 | + { |
|
1254 | + return $raw ? $this->get_raw('LIN_timestamp') : $this->get('LIN_timestamp'); |
|
1255 | + } |
|
1256 | 1256 | |
1257 | 1257 | |
1258 | 1258 | |
1259 | 1259 | |
1260 | - /************************* DEPRECATED *************************/ |
|
1260 | + /************************* DEPRECATED *************************/ |
|
1261 | 1261 | |
1262 | 1262 | |
1263 | 1263 | |
1264 | - /** |
|
1265 | - * @deprecated 4.6.0 |
|
1266 | - * @param string $type one of the constants on EEM_Line_Item |
|
1267 | - * @return EE_Line_Item[] |
|
1268 | - */ |
|
1269 | - protected function _get_descendants_of_type($type) |
|
1270 | - { |
|
1271 | - EE_Error::doing_it_wrong('EE_Line_Item::_get_descendants_of_type()', |
|
1272 | - __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0'); |
|
1273 | - return EEH_Line_Item::get_descendants_of_type($this, $type); |
|
1274 | - } |
|
1264 | + /** |
|
1265 | + * @deprecated 4.6.0 |
|
1266 | + * @param string $type one of the constants on EEM_Line_Item |
|
1267 | + * @return EE_Line_Item[] |
|
1268 | + */ |
|
1269 | + protected function _get_descendants_of_type($type) |
|
1270 | + { |
|
1271 | + EE_Error::doing_it_wrong('EE_Line_Item::_get_descendants_of_type()', |
|
1272 | + __('Method replaced with EEH_Line_Item::get_descendants_of_type()', 'event_espresso'), '4.6.0'); |
|
1273 | + return EEH_Line_Item::get_descendants_of_type($this, $type); |
|
1274 | + } |
|
1275 | 1275 | |
1276 | 1276 | |
1277 | 1277 | |
1278 | - /** |
|
1279 | - * @deprecated 4.6.0 |
|
1280 | - * @param string $type like one of the EEM_Line_Item::type_* |
|
1281 | - * @return EE_Line_Item |
|
1282 | - */ |
|
1283 | - public function get_nearest_descendant_of_type($type) |
|
1284 | - { |
|
1285 | - EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', |
|
1286 | - __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0'); |
|
1287 | - return EEH_Line_Item::get_nearest_descendant_of_type($this, $type); |
|
1288 | - } |
|
1278 | + /** |
|
1279 | + * @deprecated 4.6.0 |
|
1280 | + * @param string $type like one of the EEM_Line_Item::type_* |
|
1281 | + * @return EE_Line_Item |
|
1282 | + */ |
|
1283 | + public function get_nearest_descendant_of_type($type) |
|
1284 | + { |
|
1285 | + EE_Error::doing_it_wrong('EE_Line_Item::get_nearest_descendant_of_type()', |
|
1286 | + __('Method replaced with EEH_Line_Item::get_nearest_descendant_of_type()', 'event_espresso'), '4.6.0'); |
|
1287 | + return EEH_Line_Item::get_nearest_descendant_of_type($this, $type); |
|
1288 | + } |
|
1289 | 1289 | |
1290 | 1290 | |
1291 | 1291 |
@@ -2,7 +2,7 @@ discard block |
||
2 | 2 | use EventEspresso\core\exceptions\UnexpectedEntityException; |
3 | 3 | |
4 | 4 | if ( ! defined('EVENT_ESPRESSO_VERSION')) { |
5 | - exit('No direct script access allowed'); |
|
5 | + exit('No direct script access allowed'); |
|
6 | 6 | } |
7 | 7 | |
8 | 8 | |
@@ -21,920 +21,920 @@ discard block |
||
21 | 21 | class EED_Ticket_Sales_Monitor extends EED_Module |
22 | 22 | { |
23 | 23 | |
24 | - const debug = false; // true false |
|
25 | - |
|
26 | - /** |
|
27 | - * an array of raw ticket data from EED_Ticket_Selector |
|
28 | - * |
|
29 | - * @var array $ticket_selections |
|
30 | - */ |
|
31 | - protected $ticket_selections = array(); |
|
32 | - |
|
33 | - /** |
|
34 | - * the raw ticket data from EED_Ticket_Selector is organized in rows |
|
35 | - * according to how they are displayed in the actual Ticket_Selector |
|
36 | - * this tracks the current row being processed |
|
37 | - * |
|
38 | - * @var int $current_row |
|
39 | - */ |
|
40 | - protected $current_row = 0; |
|
41 | - |
|
42 | - /** |
|
43 | - * an array for tracking names of tickets that have sold out |
|
44 | - * |
|
45 | - * @var array $sold_out_tickets |
|
46 | - */ |
|
47 | - protected $sold_out_tickets = array(); |
|
48 | - |
|
49 | - /** |
|
50 | - * an array for tracking names of tickets that have had their quantities reduced |
|
51 | - * |
|
52 | - * @var array $decremented_tickets |
|
53 | - */ |
|
54 | - protected $decremented_tickets = array(); |
|
55 | - |
|
56 | - |
|
57 | - |
|
58 | - /** |
|
59 | - * set_hooks - for hooking into EE Core, other modules, etc |
|
60 | - * |
|
61 | - * @access public |
|
62 | - * @return void |
|
63 | - */ |
|
64 | - public static function set_hooks() |
|
65 | - { |
|
66 | - // release tickets for expired carts |
|
67 | - add_action('EED_Ticket_Selector__process_ticket_selections__before', |
|
68 | - array('EED_Ticket_Sales_Monitor', 'release_tickets_for_expired_carts'), |
|
69 | - 1 |
|
70 | - ); |
|
71 | - // check ticket reserves AFTER MER does it's check (hence priority 20) |
|
72 | - add_filter('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', |
|
73 | - array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'), |
|
74 | - 20, 3 |
|
75 | - ); |
|
76 | - // add notices for sold out tickets |
|
77 | - add_action('AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
78 | - array('EED_Ticket_Sales_Monitor', 'post_notices'), |
|
79 | - 10 |
|
80 | - ); |
|
81 | - // handle ticket quantities adjusted in cart |
|
82 | - //add_action( |
|
83 | - // 'FHEE__EED_Multi_Event_Registration__adjust_line_item_quantity__line_item_quantity_updated', |
|
84 | - // array( 'EED_Ticket_Sales_Monitor', 'ticket_quantity_updated' ), |
|
85 | - // 10, 2 |
|
86 | - //); |
|
87 | - // handle tickets deleted from cart |
|
88 | - add_action( |
|
89 | - 'FHEE__EED_Multi_Event_Registration__delete_ticket__ticket_removed_from_cart', |
|
90 | - array('EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart'), |
|
91 | - 10, 2 |
|
92 | - ); |
|
93 | - // handle emptied carts |
|
94 | - add_action( |
|
95 | - 'AHEE__EE_Session__reset_cart__before_reset', |
|
96 | - array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
97 | - 10, 1 |
|
98 | - ); |
|
99 | - add_action( |
|
100 | - 'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart', |
|
101 | - array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
102 | - 10, 1 |
|
103 | - ); |
|
104 | - // handle cancelled registrations |
|
105 | - add_action( |
|
106 | - 'AHEE__EE_Session__reset_checkout__before_reset', |
|
107 | - array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'), |
|
108 | - 10, 1 |
|
109 | - ); |
|
110 | - // cron tasks |
|
111 | - add_action( |
|
112 | - 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction', |
|
113 | - array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
114 | - 10, 1 |
|
115 | - ); |
|
116 | - add_action( |
|
117 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
|
118 | - array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
119 | - 10, 1 |
|
120 | - ); |
|
121 | - add_action( |
|
122 | - 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
|
123 | - array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'), |
|
124 | - 10, 1 |
|
125 | - ); |
|
126 | - } |
|
127 | - |
|
128 | - |
|
129 | - |
|
130 | - /** |
|
131 | - * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
132 | - * |
|
133 | - * @access public |
|
134 | - * @return void |
|
135 | - */ |
|
136 | - public static function set_hooks_admin() |
|
137 | - { |
|
138 | - EED_Ticket_Sales_Monitor::set_hooks(); |
|
139 | - } |
|
140 | - |
|
141 | - |
|
142 | - |
|
143 | - /** |
|
144 | - * @return EED_Ticket_Sales_Monitor|EED_Module |
|
145 | - */ |
|
146 | - public static function instance() |
|
147 | - { |
|
148 | - return parent::get_instance(__CLASS__); |
|
149 | - } |
|
150 | - |
|
151 | - |
|
152 | - |
|
153 | - /** |
|
154 | - * run |
|
155 | - * |
|
156 | - * @access public |
|
157 | - * @param WP_Query $WP_Query |
|
158 | - * @return void |
|
159 | - */ |
|
160 | - public function run($WP_Query) |
|
161 | - { |
|
162 | - } |
|
163 | - |
|
164 | - |
|
165 | - |
|
166 | - /********************************** PRE_TICKET_SALES **********************************/ |
|
167 | - |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * Retrieves grand totals from the line items that have no TXN ID |
|
172 | - * and timestamps less than the current time minus the session lifespan. |
|
173 | - * These are carts that have been abandoned before the "registrant" even attempted to checkout. |
|
174 | - * We're going to release the tickets for these line items before attempting to add more to the cart. |
|
175 | - * |
|
176 | - * @return void |
|
177 | - * @throws \EE_Error |
|
178 | - */ |
|
179 | - public static function release_tickets_for_expired_carts() |
|
180 | - { |
|
181 | - $expired_ticket_IDs = array(); |
|
182 | - $valid_ticket_line_items = array(); |
|
183 | - $total_line_items = EEM_Line_Item::instance()->get_total_line_items_with_no_transaction(); |
|
184 | - if(empty($total_line_items)){ |
|
185 | - return; |
|
186 | - } |
|
187 | - $expired = current_time('timestamp') - EE_Registry::instance()->SSN->lifespan(); |
|
188 | - foreach ($total_line_items as $total_line_item) { |
|
189 | - /** @var EE_Line_Item $total_line_item */ |
|
190 | - $ticket_line_items = EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total($total_line_item); |
|
191 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
192 | - if(! $ticket_line_item instanceof EE_Line_Item) { |
|
193 | - continue; |
|
194 | - } |
|
195 | - if ($total_line_item->timestamp(true) <= $expired ) { |
|
196 | - $expired_ticket_IDs[$ticket_line_item->OBJ_ID()] = $ticket_line_item->OBJ_ID(); |
|
197 | - } else { |
|
198 | - $valid_ticket_line_items[$ticket_line_item->OBJ_ID()] = $ticket_line_item; |
|
199 | - } |
|
200 | - } |
|
201 | - } |
|
202 | - EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
|
203 | - \EEM_Ticket::instance()->get_tickets_with_IDs($expired_ticket_IDs), |
|
204 | - $valid_ticket_line_items |
|
205 | - ); |
|
206 | - } |
|
207 | - |
|
208 | - |
|
209 | - |
|
210 | - /********************************** VALIDATE_TICKET_SALE **********************************/ |
|
211 | - |
|
212 | - |
|
213 | - |
|
214 | - /** |
|
215 | - * validate_ticket_sales |
|
216 | - * callback for 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data' |
|
217 | - * |
|
218 | - * @access public |
|
219 | - * @param int $qty |
|
220 | - * @param \EE_Ticket $ticket |
|
221 | - * @return bool |
|
222 | - * @throws UnexpectedEntityException |
|
223 | - * @throws EE_Error |
|
224 | - */ |
|
225 | - public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket) |
|
226 | - { |
|
227 | - $qty = absint($qty); |
|
228 | - if ($qty > 0) { |
|
229 | - $qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty); |
|
230 | - } |
|
231 | - if (self::debug) { |
|
232 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '()'; |
|
233 | - echo '<br /><br /><b> RETURNED QTY: ' . $qty . '</b>'; |
|
234 | - } |
|
235 | - return $qty; |
|
236 | - } |
|
237 | - |
|
238 | - |
|
239 | - |
|
240 | - /** |
|
241 | - * _validate_ticket_sale |
|
242 | - * checks whether an individual ticket is available for purchase based on datetime, and ticket details |
|
243 | - * |
|
244 | - * @access protected |
|
245 | - * @param \EE_Ticket $ticket |
|
246 | - * @param int $qty |
|
247 | - * @return int |
|
248 | - * @throws UnexpectedEntityException |
|
249 | - * @throws EE_Error |
|
250 | - */ |
|
251 | - protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1) |
|
252 | - { |
|
253 | - if (self::debug) { |
|
254 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
255 | - } |
|
256 | - if ( ! $ticket instanceof EE_Ticket) { |
|
257 | - return 0; |
|
258 | - } |
|
259 | - if (self::debug) { |
|
260 | - echo '<br /><b> . ticket->ID: ' . $ticket->ID() . '</b>'; |
|
261 | - echo '<br /> . original ticket->reserved: ' . $ticket->reserved(); |
|
262 | - } |
|
263 | - $ticket->refresh_from_db(); |
|
264 | - // first let's determine the ticket availability based on sales |
|
265 | - $available = $ticket->qty('saleable'); |
|
266 | - if (self::debug) { |
|
267 | - echo '<br /> . . . ticket->qty: ' . $ticket->qty(); |
|
268 | - echo '<br /> . . . ticket->sold: ' . $ticket->sold(); |
|
269 | - echo '<br /> . . . ticket->reserved: ' . $ticket->reserved(); |
|
270 | - echo '<br /> . . . ticket->qty(saleable): ' . $ticket->qty('saleable'); |
|
271 | - echo '<br /> . . . available: ' . $available; |
|
272 | - } |
|
273 | - if ($available < 1) { |
|
274 | - $this->_ticket_sold_out($ticket); |
|
275 | - return 0; |
|
276 | - } |
|
277 | - if (self::debug) { |
|
278 | - echo '<br /> . . . qty: ' . $qty; |
|
279 | - } |
|
280 | - if ($available < $qty) { |
|
281 | - $qty = $available; |
|
282 | - if (self::debug) { |
|
283 | - echo '<br /> . . . QTY ADJUSTED: ' . $qty; |
|
284 | - } |
|
285 | - $this->_ticket_quantity_decremented($ticket); |
|
286 | - } |
|
287 | - $this->_reserve_ticket($ticket, $qty); |
|
288 | - return $qty; |
|
289 | - } |
|
290 | - |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * _reserve_ticket |
|
295 | - * increments ticket reserved based on quantity passed |
|
296 | - * |
|
297 | - * @access protected |
|
298 | - * @param \EE_Ticket $ticket |
|
299 | - * @param int $quantity |
|
300 | - * @return bool |
|
301 | - * @throws EE_Error |
|
302 | - */ |
|
303 | - protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1) |
|
304 | - { |
|
305 | - if (self::debug) { |
|
306 | - echo '<br /><br /> . . . INCREASE RESERVED: ' . $quantity; |
|
307 | - } |
|
308 | - $ticket->increase_reserved($quantity); |
|
309 | - return $ticket->save(); |
|
310 | - } |
|
311 | - |
|
312 | - |
|
313 | - |
|
314 | - /** |
|
315 | - * _release_reserved_ticket |
|
316 | - * |
|
317 | - * @access protected |
|
318 | - * @param EE_Ticket $ticket |
|
319 | - * @param int $quantity |
|
320 | - * @return bool |
|
321 | - * @throws EE_Error |
|
322 | - */ |
|
323 | - protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1) |
|
324 | - { |
|
325 | - if (self::debug) { |
|
326 | - echo '<br /> . . . ticket->ID: ' . $ticket->ID(); |
|
327 | - echo '<br /> . . . ticket->reserved: ' . $ticket->reserved(); |
|
328 | - } |
|
329 | - $ticket->decrease_reserved($quantity); |
|
330 | - if (self::debug) { |
|
331 | - echo '<br /> . . . ticket->reserved: ' . $ticket->reserved(); |
|
332 | - } |
|
333 | - return $ticket->save() ? 1 : 0; |
|
334 | - } |
|
335 | - |
|
336 | - |
|
337 | - |
|
338 | - /** |
|
339 | - * _ticket_sold_out |
|
340 | - * removes quantities within the ticket selector based on zero ticket availability |
|
341 | - * |
|
342 | - * @access protected |
|
343 | - * @param \EE_Ticket $ticket |
|
344 | - * @return void |
|
345 | - * @throws UnexpectedEntityException |
|
346 | - * @throws EE_Error |
|
347 | - */ |
|
348 | - protected function _ticket_sold_out(EE_Ticket $ticket) |
|
349 | - { |
|
350 | - if (self::debug) { |
|
351 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
352 | - echo '<br /> . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
353 | - } |
|
354 | - $this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
355 | - } |
|
356 | - |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * _ticket_quantity_decremented |
|
361 | - * adjusts quantities within the ticket selector based on decreased ticket availability |
|
362 | - * |
|
363 | - * @access protected |
|
364 | - * @param \EE_Ticket $ticket |
|
365 | - * @return void |
|
366 | - * @throws UnexpectedEntityException |
|
367 | - * @throws EE_Error |
|
368 | - */ |
|
369 | - protected function _ticket_quantity_decremented(EE_Ticket $ticket) |
|
370 | - { |
|
371 | - if (self::debug) { |
|
372 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
373 | - echo '<br /> . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
374 | - } |
|
375 | - $this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
376 | - } |
|
377 | - |
|
378 | - |
|
379 | - |
|
380 | - /** |
|
381 | - * _get_ticket_and_event_name |
|
382 | - * builds string out of ticket and event name |
|
383 | - * |
|
384 | - * @access protected |
|
385 | - * @param \EE_Ticket $ticket |
|
386 | - * @return string |
|
387 | - * @throws UnexpectedEntityException |
|
388 | - * @throws EE_Error |
|
389 | - */ |
|
390 | - protected function _get_ticket_and_event_name(EE_Ticket $ticket) |
|
391 | - { |
|
392 | - $event = $ticket->get_related_event(); |
|
393 | - if ($event instanceof EE_Event) { |
|
394 | - $ticket_name = sprintf( |
|
395 | - _x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'), |
|
396 | - $ticket->name(), |
|
397 | - $event->name() |
|
398 | - ); |
|
399 | - } else { |
|
400 | - $ticket_name = $ticket->name(); |
|
401 | - } |
|
402 | - return $ticket_name; |
|
403 | - } |
|
404 | - |
|
405 | - |
|
406 | - |
|
407 | - /********************************** EVENT CART **********************************/ |
|
408 | - |
|
409 | - |
|
410 | - |
|
411 | - /** |
|
412 | - * ticket_quantity_updated |
|
413 | - * releases or reserves ticket(s) based on quantity passed |
|
414 | - * |
|
415 | - * @access public |
|
416 | - * @param EE_Line_Item $line_item |
|
417 | - * @param int $quantity |
|
418 | - * @return void |
|
419 | - * @throws EE_Error |
|
420 | - */ |
|
421 | - public static function ticket_quantity_updated(EE_Line_Item $line_item, $quantity = 1) |
|
422 | - { |
|
423 | - $ticket = EEM_Ticket::instance()->get_one_by_ID(absint($line_item->OBJ_ID())); |
|
424 | - if ($ticket instanceof EE_Ticket) { |
|
425 | - if ($quantity > 0) { |
|
426 | - EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity); |
|
427 | - } else { |
|
428 | - EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
429 | - } |
|
430 | - } |
|
431 | - } |
|
432 | - |
|
433 | - |
|
434 | - |
|
435 | - /** |
|
436 | - * ticket_removed_from_cart |
|
437 | - * releases reserved ticket(s) based on quantity passed |
|
438 | - * |
|
439 | - * @access public |
|
440 | - * @param EE_Ticket $ticket |
|
441 | - * @param int $quantity |
|
442 | - * @return void |
|
443 | - * @throws EE_Error |
|
444 | - */ |
|
445 | - public static function ticket_removed_from_cart(EE_Ticket $ticket, $quantity = 1) |
|
446 | - { |
|
447 | - EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
448 | - } |
|
449 | - |
|
450 | - |
|
451 | - |
|
452 | - /********************************** POST_NOTICES **********************************/ |
|
453 | - |
|
454 | - |
|
455 | - |
|
456 | - /** |
|
457 | - * post_notices |
|
458 | - * |
|
459 | - * @access public |
|
460 | - * @return void |
|
461 | - * @throws EE_Error |
|
462 | - */ |
|
463 | - public static function post_notices() |
|
464 | - { |
|
465 | - EED_Ticket_Sales_Monitor::instance()->_post_notices(); |
|
466 | - } |
|
467 | - |
|
468 | - |
|
469 | - |
|
470 | - /** |
|
471 | - * _post_notices |
|
472 | - * |
|
473 | - * @access protected |
|
474 | - * @return void |
|
475 | - * @throws EE_Error |
|
476 | - */ |
|
477 | - protected function _post_notices() |
|
478 | - { |
|
479 | - if (self::debug) { |
|
480 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
481 | - } |
|
482 | - $refresh_msg = ''; |
|
483 | - $none_added_msg = ''; |
|
484 | - if (defined('DOING_AJAX') && DOING_AJAX) { |
|
485 | - $refresh_msg = __('Please refresh the page to view updated ticket quantities.', |
|
486 | - 'event_espresso'); |
|
487 | - $none_added_msg = __('No tickets were added for the event.', 'event_espresso'); |
|
488 | - } |
|
489 | - if ( ! empty($this->sold_out_tickets)) { |
|
490 | - EE_Error::add_attention( |
|
491 | - sprintf( |
|
492 | - apply_filters( |
|
493 | - 'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice', |
|
494 | - __('We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s', |
|
495 | - 'event_espresso') |
|
496 | - ), |
|
497 | - '<br />', |
|
498 | - implode('<br />', $this->sold_out_tickets), |
|
499 | - $none_added_msg, |
|
500 | - $refresh_msg |
|
501 | - ) |
|
502 | - ); |
|
503 | - // alter code flow in the Ticket Selector for better UX |
|
504 | - add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true'); |
|
505 | - add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false'); |
|
506 | - $this->sold_out_tickets = array(); |
|
507 | - // and reset the cart |
|
508 | - EED_Ticket_Sales_Monitor::session_cart_reset(EE_Registry::instance()->SSN); |
|
509 | - } |
|
510 | - if ( ! empty($this->decremented_tickets)) { |
|
511 | - EE_Error::add_attention( |
|
512 | - sprintf( |
|
513 | - apply_filters( |
|
514 | - 'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice', |
|
515 | - __('We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s', |
|
516 | - 'event_espresso') |
|
517 | - ), |
|
518 | - '<br />', |
|
519 | - implode('<br />', $this->decremented_tickets), |
|
520 | - $none_added_msg, |
|
521 | - $refresh_msg |
|
522 | - ) |
|
523 | - ); |
|
524 | - $this->decremented_tickets = array(); |
|
525 | - } |
|
526 | - } |
|
527 | - |
|
528 | - |
|
529 | - |
|
530 | - /********************************** RELEASE_ALL_RESERVED_TICKETS_FOR_TRANSACTION **********************************/ |
|
531 | - |
|
532 | - |
|
533 | - |
|
534 | - /** |
|
535 | - * _release_all_reserved_tickets_for_transaction |
|
536 | - * releases reserved tickets for all registrations of an EE_Transaction |
|
537 | - * by default, will NOT release tickets for finalized transactions |
|
538 | - * |
|
539 | - * @access protected |
|
540 | - * @param EE_Transaction $transaction |
|
541 | - * @return int |
|
542 | - * @throws EE_Error |
|
543 | - */ |
|
544 | - protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction) |
|
545 | - { |
|
546 | - if (self::debug) { |
|
547 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
548 | - echo '<br /> . transaction->ID: ' . $transaction->ID(); |
|
549 | - } |
|
550 | - // check if 'finalize_registration' step has been completed... |
|
551 | - $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
552 | - if (self::debug) { |
|
553 | - // DEBUG LOG |
|
554 | - EEH_Debug_Tools::log( |
|
555 | - __CLASS__, __FUNCTION__, __LINE__, |
|
556 | - array('finalized' => $finalized), |
|
557 | - false, 'EE_Transaction: ' . $transaction->ID() |
|
558 | - ); |
|
559 | - } |
|
560 | - // how many tickets were released |
|
561 | - $count = 0; |
|
562 | - if (self::debug) { |
|
563 | - echo '<br /> . . . finalized: ' . $finalized; |
|
564 | - } |
|
565 | - $release_tickets_with_TXN_status = array( |
|
566 | - EEM_Transaction::failed_status_code, |
|
567 | - EEM_Transaction::abandoned_status_code, |
|
568 | - EEM_Transaction::incomplete_status_code, |
|
569 | - ); |
|
570 | - // if the session is getting cleared BEFORE the TXN has been finalized |
|
571 | - if ( ! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) { |
|
572 | - // let's cancel any reserved tickets |
|
573 | - $registrations = $transaction->registrations(); |
|
574 | - if ( ! empty($registrations)) { |
|
575 | - foreach ($registrations as $registration) { |
|
576 | - if ($registration instanceof EE_Registration) { |
|
577 | - $count += $this->_release_reserved_ticket_for_registration($registration, $transaction); |
|
578 | - } |
|
579 | - } |
|
580 | - } |
|
581 | - } |
|
582 | - return $count; |
|
583 | - } |
|
584 | - |
|
585 | - |
|
586 | - |
|
587 | - /** |
|
588 | - * _release_reserved_ticket_for_registration |
|
589 | - * releases reserved tickets for an EE_Registration |
|
590 | - * by default, will NOT release tickets for APPROVED registrations |
|
591 | - * |
|
592 | - * @access protected |
|
593 | - * @param EE_Registration $registration |
|
594 | - * @param EE_Transaction $transaction |
|
595 | - * @return int |
|
596 | - * @throws EE_Error |
|
597 | - */ |
|
598 | - protected function _release_reserved_ticket_for_registration( |
|
599 | - EE_Registration $registration, |
|
600 | - EE_Transaction $transaction |
|
601 | - ) { |
|
602 | - $STS_ID = $transaction->status_ID(); |
|
603 | - if (self::debug) { |
|
604 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
605 | - echo '<br /> . . registration->ID: ' . $registration->ID(); |
|
606 | - echo '<br /> . . registration->status_ID: ' . $registration->status_ID(); |
|
607 | - echo '<br /> . . transaction->status_ID(): ' . $STS_ID; |
|
608 | - } |
|
609 | - if ( |
|
610 | - // release Tickets for Failed Transactions and Abandoned Transactions |
|
611 | - $STS_ID === EEM_Transaction::failed_status_code |
|
612 | - || $STS_ID === EEM_Transaction::abandoned_status_code |
|
613 | - || ( |
|
614 | - // also release Tickets for Incomplete Transactions, but ONLY if the Registrations are NOT Approved |
|
615 | - $STS_ID === EEM_Transaction::incomplete_status_code |
|
616 | - && $registration->status_ID() !== EEM_Registration::status_id_approved |
|
617 | - ) |
|
618 | - ) { |
|
619 | - $ticket = $registration->ticket(); |
|
620 | - if ($ticket instanceof EE_Ticket) { |
|
621 | - return $this->_release_reserved_ticket($ticket); |
|
622 | - } |
|
623 | - } |
|
624 | - return 0; |
|
625 | - } |
|
626 | - |
|
627 | - |
|
628 | - |
|
629 | - /********************************** SESSION_CART_RESET **********************************/ |
|
630 | - |
|
631 | - |
|
632 | - |
|
633 | - /** |
|
634 | - * session_cart_reset |
|
635 | - * callback hooked into 'AHEE__EE_Session__reset_cart__before_reset' |
|
636 | - * |
|
637 | - * @access public |
|
638 | - * @param EE_Session $session |
|
639 | - * @return void |
|
640 | - * @throws EE_Error |
|
641 | - */ |
|
642 | - public static function session_cart_reset(EE_Session $session) |
|
643 | - { |
|
644 | - if (self::debug) { |
|
645 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
646 | - } |
|
647 | - $cart = $session->cart(); |
|
648 | - if ($cart instanceof EE_Cart) { |
|
649 | - if (self::debug) { |
|
650 | - echo '<br /><br /> cart instance of EE_Cart: '; |
|
651 | - } |
|
652 | - EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart); |
|
653 | - } else { |
|
654 | - if (self::debug) { |
|
655 | - echo '<br /><br /> invalid EE_Cart: '; |
|
656 | - var_dump($cart); |
|
657 | - } |
|
658 | - } |
|
659 | - } |
|
660 | - |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * _session_cart_reset |
|
665 | - * releases reserved tickets in the EE_Cart |
|
666 | - * |
|
667 | - * @access protected |
|
668 | - * @param EE_Cart $cart |
|
669 | - * @return void |
|
670 | - * @throws EE_Error |
|
671 | - */ |
|
672 | - protected function _session_cart_reset(EE_Cart $cart) |
|
673 | - { |
|
674 | - if (self::debug) { |
|
675 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
676 | - } |
|
677 | - EE_Registry::instance()->load_helper('Line_Item'); |
|
678 | - $ticket_line_items = $cart->get_tickets(); |
|
679 | - if (empty($ticket_line_items)) { |
|
680 | - return; |
|
681 | - } |
|
682 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
683 | - if (self::debug) { |
|
684 | - echo '<br /> . ticket_line_item->ID(): ' . $ticket_line_item->ID(); |
|
685 | - } |
|
686 | - if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() === 'Ticket') { |
|
687 | - if (self::debug) { |
|
688 | - echo '<br /> . . ticket_line_item->OBJ_ID(): ' . $ticket_line_item->OBJ_ID(); |
|
689 | - } |
|
690 | - $ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID()); |
|
691 | - if ($ticket instanceof EE_Ticket) { |
|
692 | - if (self::debug) { |
|
693 | - echo '<br /> . . ticket->ID(): ' . $ticket->ID(); |
|
694 | - echo '<br /> . . ticket_line_item->quantity(): ' . $ticket_line_item->quantity(); |
|
695 | - } |
|
696 | - $this->_release_reserved_ticket($ticket, $ticket_line_item->quantity()); |
|
697 | - } |
|
698 | - } |
|
699 | - } |
|
700 | - if (self::debug) { |
|
701 | - echo '<br /><br /> RESET COMPLETED '; |
|
702 | - } |
|
703 | - } |
|
704 | - |
|
705 | - |
|
706 | - |
|
707 | - /********************************** SESSION_CHECKOUT_RESET **********************************/ |
|
708 | - |
|
709 | - |
|
710 | - |
|
711 | - /** |
|
712 | - * session_checkout_reset |
|
713 | - * callback hooked into 'AHEE__EE_Session__reset_checkout__before_reset' |
|
714 | - * |
|
715 | - * @access public |
|
716 | - * @param EE_Session $session |
|
717 | - * @return void |
|
718 | - * @throws EE_Error |
|
719 | - */ |
|
720 | - public static function session_checkout_reset(EE_Session $session) |
|
721 | - { |
|
722 | - $checkout = $session->checkout(); |
|
723 | - if ($checkout instanceof EE_Checkout) { |
|
724 | - EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout); |
|
725 | - } |
|
726 | - } |
|
727 | - |
|
728 | - |
|
729 | - |
|
730 | - /** |
|
731 | - * _session_checkout_reset |
|
732 | - * releases reserved tickets for the EE_Checkout->transaction |
|
733 | - * |
|
734 | - * @access protected |
|
735 | - * @param EE_Checkout $checkout |
|
736 | - * @return void |
|
737 | - * @throws EE_Error |
|
738 | - */ |
|
739 | - protected function _session_checkout_reset(EE_Checkout $checkout) |
|
740 | - { |
|
741 | - if (self::debug) { |
|
742 | - echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
743 | - } |
|
744 | - // we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit |
|
745 | - if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) { |
|
746 | - return; |
|
747 | - } |
|
748 | - $this->_release_all_reserved_tickets_for_transaction($checkout->transaction); |
|
749 | - } |
|
750 | - |
|
751 | - |
|
752 | - |
|
753 | - /********************************** SESSION_EXPIRED_RESET **********************************/ |
|
754 | - |
|
755 | - |
|
756 | - |
|
757 | - /** |
|
758 | - * session_expired_reset |
|
759 | - * |
|
760 | - * @access public |
|
761 | - * @param EE_Session $session |
|
762 | - * @return void |
|
763 | - */ |
|
764 | - public static function session_expired_reset(EE_Session $session) |
|
765 | - { |
|
766 | - } |
|
767 | - |
|
768 | - |
|
769 | - |
|
770 | - /********************************** PROCESS_ABANDONED_TRANSACTIONS **********************************/ |
|
771 | - |
|
772 | - |
|
773 | - |
|
774 | - /** |
|
775 | - * process_abandoned_transactions |
|
776 | - * releases reserved tickets for all registrations of an ABANDONED EE_Transaction |
|
777 | - * by default, will NOT release tickets for free transactions, or any that have received a payment |
|
778 | - * |
|
779 | - * @access public |
|
780 | - * @param EE_Transaction $transaction |
|
781 | - * @return void |
|
782 | - * @throws EE_Error |
|
783 | - */ |
|
784 | - public static function process_abandoned_transactions(EE_Transaction $transaction) |
|
785 | - { |
|
786 | - // is this TXN free or has any money been paid towards this TXN? If so, then leave it alone |
|
787 | - if ($transaction->is_free() || $transaction->paid() > 0) { |
|
788 | - if (self::debug) { |
|
789 | - // DEBUG LOG |
|
790 | - EEH_Debug_Tools::log( |
|
791 | - __CLASS__, __FUNCTION__, __LINE__, |
|
792 | - array($transaction), |
|
793 | - false, 'EE_Transaction: ' . $transaction->ID() |
|
794 | - ); |
|
795 | - } |
|
796 | - return; |
|
797 | - } |
|
798 | - // have their been any successful payments made ? |
|
799 | - $payments = $transaction->payments(); |
|
800 | - foreach ($payments as $payment) { |
|
801 | - if ($payment instanceof EE_Payment && $payment->status() === EEM_Payment::status_id_approved) { |
|
802 | - if (self::debug) { |
|
803 | - // DEBUG LOG |
|
804 | - EEH_Debug_Tools::log( |
|
805 | - __CLASS__, __FUNCTION__, __LINE__, |
|
806 | - array($payment), |
|
807 | - false, 'EE_Transaction: ' . $transaction->ID() |
|
808 | - ); |
|
809 | - } |
|
810 | - return; |
|
811 | - } |
|
812 | - } |
|
813 | - // since you haven't even attempted to pay for your ticket... |
|
814 | - EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
815 | - } |
|
816 | - |
|
817 | - |
|
818 | - |
|
819 | - /********************************** PROCESS_FAILED_TRANSACTIONS **********************************/ |
|
820 | - |
|
821 | - |
|
822 | - |
|
823 | - /** |
|
824 | - * process_abandoned_transactions |
|
825 | - * releases reserved tickets for absolutely ALL registrations of a FAILED EE_Transaction |
|
826 | - * |
|
827 | - * @access public |
|
828 | - * @param EE_Transaction $transaction |
|
829 | - * @return void |
|
830 | - * @throws EE_Error |
|
831 | - */ |
|
832 | - public static function process_failed_transactions(EE_Transaction $transaction) |
|
833 | - { |
|
834 | - // since you haven't even attempted to pay for your ticket... |
|
835 | - EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
836 | - } |
|
837 | - |
|
838 | - |
|
839 | - |
|
840 | - /********************************** RESET RESERVATION COUNTS *********************************/ |
|
841 | - |
|
842 | - |
|
843 | - |
|
844 | - /** |
|
845 | - * Resets all ticket and datetime reserved counts to zero |
|
846 | - * Tickets that are currently associated with a Transaction that is in progress |
|
847 | - * |
|
848 | - * @throws \EE_Error |
|
849 | - * @throws \DomainException |
|
850 | - */ |
|
851 | - public static function reset_reservation_counts() |
|
852 | - { |
|
853 | - /** @var EE_Line_Item[] $valid_reserved_tickets */ |
|
854 | - $valid_reserved_tickets = array(); |
|
855 | - $transactions_in_progress = EEM_Transaction::instance()->get_transactions_in_progress(); |
|
856 | - foreach ($transactions_in_progress as $transaction_in_progress) { |
|
857 | - // if this TXN has been fully completed, then skip it |
|
858 | - if ($transaction_in_progress->reg_step_completed('finalize_registration')) { |
|
859 | - continue; |
|
860 | - } |
|
861 | - /** @var EE_Transaction $transaction_in_progress */ |
|
862 | - $total_line_item = $transaction_in_progress->total_line_item(); |
|
863 | - // $transaction_in_progress->line |
|
864 | - if (! $total_line_item instanceof EE_Line_Item) { |
|
865 | - throw new DomainException( |
|
866 | - esc_html__('Transaction does not have a valid Total Line Item associated with it.', 'event_espresso') |
|
867 | - ); |
|
868 | - } |
|
869 | - $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total( |
|
870 | - $total_line_item |
|
871 | - ); |
|
872 | - } |
|
873 | - $total_line_items = EEM_Line_Item::instance()->get_total_line_items_for_active_carts(); |
|
874 | - foreach ($total_line_items as $total_line_item) { |
|
875 | - $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total( |
|
876 | - $total_line_item |
|
877 | - ); |
|
878 | - } |
|
879 | - return EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
|
880 | - EEM_Ticket::instance()->get_tickets_with_reservations(), |
|
881 | - $valid_reserved_tickets |
|
882 | - ); |
|
883 | - } |
|
884 | - |
|
885 | - |
|
886 | - |
|
887 | - /** |
|
888 | - * @param EE_Line_Item $total_line_item |
|
889 | - * @return EE_Line_Item[] |
|
890 | - */ |
|
891 | - private static function get_ticket_line_items_for_grand_total(EE_Line_Item $total_line_item) |
|
892 | - { |
|
893 | - /** @var EE_Line_Item[] $valid_reserved_tickets */ |
|
894 | - $valid_reserved_tickets = array(); |
|
895 | - $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
896 | - foreach ($ticket_line_items as $ticket_line_item) { |
|
897 | - if ($ticket_line_item instanceof EE_Line_Item) { |
|
898 | - $valid_reserved_tickets[] = $ticket_line_item; |
|
899 | - } |
|
900 | - } |
|
901 | - return $valid_reserved_tickets; |
|
902 | - } |
|
903 | - |
|
904 | - |
|
905 | - |
|
906 | - /** |
|
907 | - * @param EE_Ticket[] $tickets_with_reservations |
|
908 | - * @param EE_Line_Item[] $valid_reserved_ticket_line_items |
|
909 | - * @return int |
|
910 | - * @throws \EE_Error |
|
911 | - */ |
|
912 | - private static function release_reservations_for_tickets( |
|
913 | - array $tickets_with_reservations, |
|
914 | - $valid_reserved_ticket_line_items = array() |
|
915 | - ) { |
|
916 | - $total_tickets_released = 0; |
|
917 | - foreach ($tickets_with_reservations as $ticket_with_reservations) { |
|
918 | - if (! $ticket_with_reservations instanceof EE_Ticket) { |
|
919 | - continue; |
|
920 | - } |
|
921 | - $reserved_qty = $ticket_with_reservations->reserved(); |
|
922 | - foreach ($valid_reserved_ticket_line_items as $valid_reserved_ticket_line_item) { |
|
923 | - if ( |
|
924 | - $valid_reserved_ticket_line_item instanceof EE_Line_Item |
|
925 | - && $valid_reserved_ticket_line_item->OBJ_ID() === $ticket_with_reservations->ID() |
|
926 | - ) { |
|
927 | - $reserved_qty -= $valid_reserved_ticket_line_item->quantity(); |
|
928 | - } |
|
929 | - } |
|
930 | - if ($reserved_qty > 0) { |
|
931 | - $ticket_with_reservations->decrease_reserved($reserved_qty); |
|
932 | - $ticket_with_reservations->save(); |
|
933 | - $total_tickets_released += $reserved_qty; |
|
934 | - } |
|
935 | - } |
|
936 | - return $total_tickets_released; |
|
937 | - } |
|
24 | + const debug = false; // true false |
|
25 | + |
|
26 | + /** |
|
27 | + * an array of raw ticket data from EED_Ticket_Selector |
|
28 | + * |
|
29 | + * @var array $ticket_selections |
|
30 | + */ |
|
31 | + protected $ticket_selections = array(); |
|
32 | + |
|
33 | + /** |
|
34 | + * the raw ticket data from EED_Ticket_Selector is organized in rows |
|
35 | + * according to how they are displayed in the actual Ticket_Selector |
|
36 | + * this tracks the current row being processed |
|
37 | + * |
|
38 | + * @var int $current_row |
|
39 | + */ |
|
40 | + protected $current_row = 0; |
|
41 | + |
|
42 | + /** |
|
43 | + * an array for tracking names of tickets that have sold out |
|
44 | + * |
|
45 | + * @var array $sold_out_tickets |
|
46 | + */ |
|
47 | + protected $sold_out_tickets = array(); |
|
48 | + |
|
49 | + /** |
|
50 | + * an array for tracking names of tickets that have had their quantities reduced |
|
51 | + * |
|
52 | + * @var array $decremented_tickets |
|
53 | + */ |
|
54 | + protected $decremented_tickets = array(); |
|
55 | + |
|
56 | + |
|
57 | + |
|
58 | + /** |
|
59 | + * set_hooks - for hooking into EE Core, other modules, etc |
|
60 | + * |
|
61 | + * @access public |
|
62 | + * @return void |
|
63 | + */ |
|
64 | + public static function set_hooks() |
|
65 | + { |
|
66 | + // release tickets for expired carts |
|
67 | + add_action('EED_Ticket_Selector__process_ticket_selections__before', |
|
68 | + array('EED_Ticket_Sales_Monitor', 'release_tickets_for_expired_carts'), |
|
69 | + 1 |
|
70 | + ); |
|
71 | + // check ticket reserves AFTER MER does it's check (hence priority 20) |
|
72 | + add_filter('FHEE__EE_Ticket_Selector___add_ticket_to_cart__ticket_qty', |
|
73 | + array('EED_Ticket_Sales_Monitor', 'validate_ticket_sale'), |
|
74 | + 20, 3 |
|
75 | + ); |
|
76 | + // add notices for sold out tickets |
|
77 | + add_action('AHEE__EE_Ticket_Selector__process_ticket_selections__after_tickets_added_to_cart', |
|
78 | + array('EED_Ticket_Sales_Monitor', 'post_notices'), |
|
79 | + 10 |
|
80 | + ); |
|
81 | + // handle ticket quantities adjusted in cart |
|
82 | + //add_action( |
|
83 | + // 'FHEE__EED_Multi_Event_Registration__adjust_line_item_quantity__line_item_quantity_updated', |
|
84 | + // array( 'EED_Ticket_Sales_Monitor', 'ticket_quantity_updated' ), |
|
85 | + // 10, 2 |
|
86 | + //); |
|
87 | + // handle tickets deleted from cart |
|
88 | + add_action( |
|
89 | + 'FHEE__EED_Multi_Event_Registration__delete_ticket__ticket_removed_from_cart', |
|
90 | + array('EED_Ticket_Sales_Monitor', 'ticket_removed_from_cart'), |
|
91 | + 10, 2 |
|
92 | + ); |
|
93 | + // handle emptied carts |
|
94 | + add_action( |
|
95 | + 'AHEE__EE_Session__reset_cart__before_reset', |
|
96 | + array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
97 | + 10, 1 |
|
98 | + ); |
|
99 | + add_action( |
|
100 | + 'AHEE__EED_Multi_Event_Registration__empty_event_cart__before_delete_cart', |
|
101 | + array('EED_Ticket_Sales_Monitor', 'session_cart_reset'), |
|
102 | + 10, 1 |
|
103 | + ); |
|
104 | + // handle cancelled registrations |
|
105 | + add_action( |
|
106 | + 'AHEE__EE_Session__reset_checkout__before_reset', |
|
107 | + array('EED_Ticket_Sales_Monitor', 'session_checkout_reset'), |
|
108 | + 10, 1 |
|
109 | + ); |
|
110 | + // cron tasks |
|
111 | + add_action( |
|
112 | + 'AHEE__EE_Cron_Tasks__finalize_abandoned_transactions__abandoned_transaction', |
|
113 | + array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
114 | + 10, 1 |
|
115 | + ); |
|
116 | + add_action( |
|
117 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__incomplete_transaction', |
|
118 | + array('EED_Ticket_Sales_Monitor', 'process_abandoned_transactions'), |
|
119 | + 10, 1 |
|
120 | + ); |
|
121 | + add_action( |
|
122 | + 'AHEE__EE_Cron_Tasks__process_expired_transactions__failed_transaction', |
|
123 | + array('EED_Ticket_Sales_Monitor', 'process_failed_transactions'), |
|
124 | + 10, 1 |
|
125 | + ); |
|
126 | + } |
|
127 | + |
|
128 | + |
|
129 | + |
|
130 | + /** |
|
131 | + * set_hooks_admin - for hooking into EE Admin Core, other modules, etc |
|
132 | + * |
|
133 | + * @access public |
|
134 | + * @return void |
|
135 | + */ |
|
136 | + public static function set_hooks_admin() |
|
137 | + { |
|
138 | + EED_Ticket_Sales_Monitor::set_hooks(); |
|
139 | + } |
|
140 | + |
|
141 | + |
|
142 | + |
|
143 | + /** |
|
144 | + * @return EED_Ticket_Sales_Monitor|EED_Module |
|
145 | + */ |
|
146 | + public static function instance() |
|
147 | + { |
|
148 | + return parent::get_instance(__CLASS__); |
|
149 | + } |
|
150 | + |
|
151 | + |
|
152 | + |
|
153 | + /** |
|
154 | + * run |
|
155 | + * |
|
156 | + * @access public |
|
157 | + * @param WP_Query $WP_Query |
|
158 | + * @return void |
|
159 | + */ |
|
160 | + public function run($WP_Query) |
|
161 | + { |
|
162 | + } |
|
163 | + |
|
164 | + |
|
165 | + |
|
166 | + /********************************** PRE_TICKET_SALES **********************************/ |
|
167 | + |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * Retrieves grand totals from the line items that have no TXN ID |
|
172 | + * and timestamps less than the current time minus the session lifespan. |
|
173 | + * These are carts that have been abandoned before the "registrant" even attempted to checkout. |
|
174 | + * We're going to release the tickets for these line items before attempting to add more to the cart. |
|
175 | + * |
|
176 | + * @return void |
|
177 | + * @throws \EE_Error |
|
178 | + */ |
|
179 | + public static function release_tickets_for_expired_carts() |
|
180 | + { |
|
181 | + $expired_ticket_IDs = array(); |
|
182 | + $valid_ticket_line_items = array(); |
|
183 | + $total_line_items = EEM_Line_Item::instance()->get_total_line_items_with_no_transaction(); |
|
184 | + if(empty($total_line_items)){ |
|
185 | + return; |
|
186 | + } |
|
187 | + $expired = current_time('timestamp') - EE_Registry::instance()->SSN->lifespan(); |
|
188 | + foreach ($total_line_items as $total_line_item) { |
|
189 | + /** @var EE_Line_Item $total_line_item */ |
|
190 | + $ticket_line_items = EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total($total_line_item); |
|
191 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
192 | + if(! $ticket_line_item instanceof EE_Line_Item) { |
|
193 | + continue; |
|
194 | + } |
|
195 | + if ($total_line_item->timestamp(true) <= $expired ) { |
|
196 | + $expired_ticket_IDs[$ticket_line_item->OBJ_ID()] = $ticket_line_item->OBJ_ID(); |
|
197 | + } else { |
|
198 | + $valid_ticket_line_items[$ticket_line_item->OBJ_ID()] = $ticket_line_item; |
|
199 | + } |
|
200 | + } |
|
201 | + } |
|
202 | + EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
|
203 | + \EEM_Ticket::instance()->get_tickets_with_IDs($expired_ticket_IDs), |
|
204 | + $valid_ticket_line_items |
|
205 | + ); |
|
206 | + } |
|
207 | + |
|
208 | + |
|
209 | + |
|
210 | + /********************************** VALIDATE_TICKET_SALE **********************************/ |
|
211 | + |
|
212 | + |
|
213 | + |
|
214 | + /** |
|
215 | + * validate_ticket_sales |
|
216 | + * callback for 'FHEE__EED_Ticket_Selector__process_ticket_selections__valid_post_data' |
|
217 | + * |
|
218 | + * @access public |
|
219 | + * @param int $qty |
|
220 | + * @param \EE_Ticket $ticket |
|
221 | + * @return bool |
|
222 | + * @throws UnexpectedEntityException |
|
223 | + * @throws EE_Error |
|
224 | + */ |
|
225 | + public static function validate_ticket_sale($qty = 1, EE_Ticket $ticket) |
|
226 | + { |
|
227 | + $qty = absint($qty); |
|
228 | + if ($qty > 0) { |
|
229 | + $qty = EED_Ticket_Sales_Monitor::instance()->_validate_ticket_sale($ticket, $qty); |
|
230 | + } |
|
231 | + if (self::debug) { |
|
232 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '()'; |
|
233 | + echo '<br /><br /><b> RETURNED QTY: ' . $qty . '</b>'; |
|
234 | + } |
|
235 | + return $qty; |
|
236 | + } |
|
237 | + |
|
238 | + |
|
239 | + |
|
240 | + /** |
|
241 | + * _validate_ticket_sale |
|
242 | + * checks whether an individual ticket is available for purchase based on datetime, and ticket details |
|
243 | + * |
|
244 | + * @access protected |
|
245 | + * @param \EE_Ticket $ticket |
|
246 | + * @param int $qty |
|
247 | + * @return int |
|
248 | + * @throws UnexpectedEntityException |
|
249 | + * @throws EE_Error |
|
250 | + */ |
|
251 | + protected function _validate_ticket_sale(EE_Ticket $ticket, $qty = 1) |
|
252 | + { |
|
253 | + if (self::debug) { |
|
254 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
255 | + } |
|
256 | + if ( ! $ticket instanceof EE_Ticket) { |
|
257 | + return 0; |
|
258 | + } |
|
259 | + if (self::debug) { |
|
260 | + echo '<br /><b> . ticket->ID: ' . $ticket->ID() . '</b>'; |
|
261 | + echo '<br /> . original ticket->reserved: ' . $ticket->reserved(); |
|
262 | + } |
|
263 | + $ticket->refresh_from_db(); |
|
264 | + // first let's determine the ticket availability based on sales |
|
265 | + $available = $ticket->qty('saleable'); |
|
266 | + if (self::debug) { |
|
267 | + echo '<br /> . . . ticket->qty: ' . $ticket->qty(); |
|
268 | + echo '<br /> . . . ticket->sold: ' . $ticket->sold(); |
|
269 | + echo '<br /> . . . ticket->reserved: ' . $ticket->reserved(); |
|
270 | + echo '<br /> . . . ticket->qty(saleable): ' . $ticket->qty('saleable'); |
|
271 | + echo '<br /> . . . available: ' . $available; |
|
272 | + } |
|
273 | + if ($available < 1) { |
|
274 | + $this->_ticket_sold_out($ticket); |
|
275 | + return 0; |
|
276 | + } |
|
277 | + if (self::debug) { |
|
278 | + echo '<br /> . . . qty: ' . $qty; |
|
279 | + } |
|
280 | + if ($available < $qty) { |
|
281 | + $qty = $available; |
|
282 | + if (self::debug) { |
|
283 | + echo '<br /> . . . QTY ADJUSTED: ' . $qty; |
|
284 | + } |
|
285 | + $this->_ticket_quantity_decremented($ticket); |
|
286 | + } |
|
287 | + $this->_reserve_ticket($ticket, $qty); |
|
288 | + return $qty; |
|
289 | + } |
|
290 | + |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * _reserve_ticket |
|
295 | + * increments ticket reserved based on quantity passed |
|
296 | + * |
|
297 | + * @access protected |
|
298 | + * @param \EE_Ticket $ticket |
|
299 | + * @param int $quantity |
|
300 | + * @return bool |
|
301 | + * @throws EE_Error |
|
302 | + */ |
|
303 | + protected function _reserve_ticket(EE_Ticket $ticket, $quantity = 1) |
|
304 | + { |
|
305 | + if (self::debug) { |
|
306 | + echo '<br /><br /> . . . INCREASE RESERVED: ' . $quantity; |
|
307 | + } |
|
308 | + $ticket->increase_reserved($quantity); |
|
309 | + return $ticket->save(); |
|
310 | + } |
|
311 | + |
|
312 | + |
|
313 | + |
|
314 | + /** |
|
315 | + * _release_reserved_ticket |
|
316 | + * |
|
317 | + * @access protected |
|
318 | + * @param EE_Ticket $ticket |
|
319 | + * @param int $quantity |
|
320 | + * @return bool |
|
321 | + * @throws EE_Error |
|
322 | + */ |
|
323 | + protected function _release_reserved_ticket(EE_Ticket $ticket, $quantity = 1) |
|
324 | + { |
|
325 | + if (self::debug) { |
|
326 | + echo '<br /> . . . ticket->ID: ' . $ticket->ID(); |
|
327 | + echo '<br /> . . . ticket->reserved: ' . $ticket->reserved(); |
|
328 | + } |
|
329 | + $ticket->decrease_reserved($quantity); |
|
330 | + if (self::debug) { |
|
331 | + echo '<br /> . . . ticket->reserved: ' . $ticket->reserved(); |
|
332 | + } |
|
333 | + return $ticket->save() ? 1 : 0; |
|
334 | + } |
|
335 | + |
|
336 | + |
|
337 | + |
|
338 | + /** |
|
339 | + * _ticket_sold_out |
|
340 | + * removes quantities within the ticket selector based on zero ticket availability |
|
341 | + * |
|
342 | + * @access protected |
|
343 | + * @param \EE_Ticket $ticket |
|
344 | + * @return void |
|
345 | + * @throws UnexpectedEntityException |
|
346 | + * @throws EE_Error |
|
347 | + */ |
|
348 | + protected function _ticket_sold_out(EE_Ticket $ticket) |
|
349 | + { |
|
350 | + if (self::debug) { |
|
351 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
352 | + echo '<br /> . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
353 | + } |
|
354 | + $this->sold_out_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
355 | + } |
|
356 | + |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * _ticket_quantity_decremented |
|
361 | + * adjusts quantities within the ticket selector based on decreased ticket availability |
|
362 | + * |
|
363 | + * @access protected |
|
364 | + * @param \EE_Ticket $ticket |
|
365 | + * @return void |
|
366 | + * @throws UnexpectedEntityException |
|
367 | + * @throws EE_Error |
|
368 | + */ |
|
369 | + protected function _ticket_quantity_decremented(EE_Ticket $ticket) |
|
370 | + { |
|
371 | + if (self::debug) { |
|
372 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
373 | + echo '<br /> . . ticket->name: ' . $this->_get_ticket_and_event_name($ticket); |
|
374 | + } |
|
375 | + $this->decremented_tickets[] = $this->_get_ticket_and_event_name($ticket); |
|
376 | + } |
|
377 | + |
|
378 | + |
|
379 | + |
|
380 | + /** |
|
381 | + * _get_ticket_and_event_name |
|
382 | + * builds string out of ticket and event name |
|
383 | + * |
|
384 | + * @access protected |
|
385 | + * @param \EE_Ticket $ticket |
|
386 | + * @return string |
|
387 | + * @throws UnexpectedEntityException |
|
388 | + * @throws EE_Error |
|
389 | + */ |
|
390 | + protected function _get_ticket_and_event_name(EE_Ticket $ticket) |
|
391 | + { |
|
392 | + $event = $ticket->get_related_event(); |
|
393 | + if ($event instanceof EE_Event) { |
|
394 | + $ticket_name = sprintf( |
|
395 | + _x('%1$s for %2$s', 'ticket name for event name', 'event_espresso'), |
|
396 | + $ticket->name(), |
|
397 | + $event->name() |
|
398 | + ); |
|
399 | + } else { |
|
400 | + $ticket_name = $ticket->name(); |
|
401 | + } |
|
402 | + return $ticket_name; |
|
403 | + } |
|
404 | + |
|
405 | + |
|
406 | + |
|
407 | + /********************************** EVENT CART **********************************/ |
|
408 | + |
|
409 | + |
|
410 | + |
|
411 | + /** |
|
412 | + * ticket_quantity_updated |
|
413 | + * releases or reserves ticket(s) based on quantity passed |
|
414 | + * |
|
415 | + * @access public |
|
416 | + * @param EE_Line_Item $line_item |
|
417 | + * @param int $quantity |
|
418 | + * @return void |
|
419 | + * @throws EE_Error |
|
420 | + */ |
|
421 | + public static function ticket_quantity_updated(EE_Line_Item $line_item, $quantity = 1) |
|
422 | + { |
|
423 | + $ticket = EEM_Ticket::instance()->get_one_by_ID(absint($line_item->OBJ_ID())); |
|
424 | + if ($ticket instanceof EE_Ticket) { |
|
425 | + if ($quantity > 0) { |
|
426 | + EED_Ticket_Sales_Monitor::instance()->_reserve_ticket($ticket, $quantity); |
|
427 | + } else { |
|
428 | + EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
429 | + } |
|
430 | + } |
|
431 | + } |
|
432 | + |
|
433 | + |
|
434 | + |
|
435 | + /** |
|
436 | + * ticket_removed_from_cart |
|
437 | + * releases reserved ticket(s) based on quantity passed |
|
438 | + * |
|
439 | + * @access public |
|
440 | + * @param EE_Ticket $ticket |
|
441 | + * @param int $quantity |
|
442 | + * @return void |
|
443 | + * @throws EE_Error |
|
444 | + */ |
|
445 | + public static function ticket_removed_from_cart(EE_Ticket $ticket, $quantity = 1) |
|
446 | + { |
|
447 | + EED_Ticket_Sales_Monitor::instance()->_release_reserved_ticket($ticket, $quantity); |
|
448 | + } |
|
449 | + |
|
450 | + |
|
451 | + |
|
452 | + /********************************** POST_NOTICES **********************************/ |
|
453 | + |
|
454 | + |
|
455 | + |
|
456 | + /** |
|
457 | + * post_notices |
|
458 | + * |
|
459 | + * @access public |
|
460 | + * @return void |
|
461 | + * @throws EE_Error |
|
462 | + */ |
|
463 | + public static function post_notices() |
|
464 | + { |
|
465 | + EED_Ticket_Sales_Monitor::instance()->_post_notices(); |
|
466 | + } |
|
467 | + |
|
468 | + |
|
469 | + |
|
470 | + /** |
|
471 | + * _post_notices |
|
472 | + * |
|
473 | + * @access protected |
|
474 | + * @return void |
|
475 | + * @throws EE_Error |
|
476 | + */ |
|
477 | + protected function _post_notices() |
|
478 | + { |
|
479 | + if (self::debug) { |
|
480 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
481 | + } |
|
482 | + $refresh_msg = ''; |
|
483 | + $none_added_msg = ''; |
|
484 | + if (defined('DOING_AJAX') && DOING_AJAX) { |
|
485 | + $refresh_msg = __('Please refresh the page to view updated ticket quantities.', |
|
486 | + 'event_espresso'); |
|
487 | + $none_added_msg = __('No tickets were added for the event.', 'event_espresso'); |
|
488 | + } |
|
489 | + if ( ! empty($this->sold_out_tickets)) { |
|
490 | + EE_Error::add_attention( |
|
491 | + sprintf( |
|
492 | + apply_filters( |
|
493 | + 'FHEE__EED_Ticket_Sales_Monitor___post_notices__sold_out_tickets_notice', |
|
494 | + __('We\'re sorry...%1$sThe following items have sold out since you first viewed this page, and can no longer be registered for:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s', |
|
495 | + 'event_espresso') |
|
496 | + ), |
|
497 | + '<br />', |
|
498 | + implode('<br />', $this->sold_out_tickets), |
|
499 | + $none_added_msg, |
|
500 | + $refresh_msg |
|
501 | + ) |
|
502 | + ); |
|
503 | + // alter code flow in the Ticket Selector for better UX |
|
504 | + add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__tckts_slctd', '__return_true'); |
|
505 | + add_filter('FHEE__EED_Ticket_Selector__process_ticket_selections__success', '__return_false'); |
|
506 | + $this->sold_out_tickets = array(); |
|
507 | + // and reset the cart |
|
508 | + EED_Ticket_Sales_Monitor::session_cart_reset(EE_Registry::instance()->SSN); |
|
509 | + } |
|
510 | + if ( ! empty($this->decremented_tickets)) { |
|
511 | + EE_Error::add_attention( |
|
512 | + sprintf( |
|
513 | + apply_filters( |
|
514 | + 'FHEE__EED_Ticket_Sales_Monitor___ticket_quantity_decremented__notice', |
|
515 | + __('We\'re sorry...%1$sDue to sales that have occurred since you first viewed the last page, the following items have had their quantities adjusted to match the current available amount:%1$s%1$s%2$s%1$s%1$sPlease note that availability can change at any time due to cancellations, so please check back again later if registration for this event(s) is important to you.%1$s%1$s%3$s%1$s%4$s%1$s', |
|
516 | + 'event_espresso') |
|
517 | + ), |
|
518 | + '<br />', |
|
519 | + implode('<br />', $this->decremented_tickets), |
|
520 | + $none_added_msg, |
|
521 | + $refresh_msg |
|
522 | + ) |
|
523 | + ); |
|
524 | + $this->decremented_tickets = array(); |
|
525 | + } |
|
526 | + } |
|
527 | + |
|
528 | + |
|
529 | + |
|
530 | + /********************************** RELEASE_ALL_RESERVED_TICKETS_FOR_TRANSACTION **********************************/ |
|
531 | + |
|
532 | + |
|
533 | + |
|
534 | + /** |
|
535 | + * _release_all_reserved_tickets_for_transaction |
|
536 | + * releases reserved tickets for all registrations of an EE_Transaction |
|
537 | + * by default, will NOT release tickets for finalized transactions |
|
538 | + * |
|
539 | + * @access protected |
|
540 | + * @param EE_Transaction $transaction |
|
541 | + * @return int |
|
542 | + * @throws EE_Error |
|
543 | + */ |
|
544 | + protected function _release_all_reserved_tickets_for_transaction(EE_Transaction $transaction) |
|
545 | + { |
|
546 | + if (self::debug) { |
|
547 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
548 | + echo '<br /> . transaction->ID: ' . $transaction->ID(); |
|
549 | + } |
|
550 | + // check if 'finalize_registration' step has been completed... |
|
551 | + $finalized = $transaction->reg_step_completed('finalize_registration'); |
|
552 | + if (self::debug) { |
|
553 | + // DEBUG LOG |
|
554 | + EEH_Debug_Tools::log( |
|
555 | + __CLASS__, __FUNCTION__, __LINE__, |
|
556 | + array('finalized' => $finalized), |
|
557 | + false, 'EE_Transaction: ' . $transaction->ID() |
|
558 | + ); |
|
559 | + } |
|
560 | + // how many tickets were released |
|
561 | + $count = 0; |
|
562 | + if (self::debug) { |
|
563 | + echo '<br /> . . . finalized: ' . $finalized; |
|
564 | + } |
|
565 | + $release_tickets_with_TXN_status = array( |
|
566 | + EEM_Transaction::failed_status_code, |
|
567 | + EEM_Transaction::abandoned_status_code, |
|
568 | + EEM_Transaction::incomplete_status_code, |
|
569 | + ); |
|
570 | + // if the session is getting cleared BEFORE the TXN has been finalized |
|
571 | + if ( ! $finalized || in_array($transaction->status_ID(), $release_tickets_with_TXN_status, true)) { |
|
572 | + // let's cancel any reserved tickets |
|
573 | + $registrations = $transaction->registrations(); |
|
574 | + if ( ! empty($registrations)) { |
|
575 | + foreach ($registrations as $registration) { |
|
576 | + if ($registration instanceof EE_Registration) { |
|
577 | + $count += $this->_release_reserved_ticket_for_registration($registration, $transaction); |
|
578 | + } |
|
579 | + } |
|
580 | + } |
|
581 | + } |
|
582 | + return $count; |
|
583 | + } |
|
584 | + |
|
585 | + |
|
586 | + |
|
587 | + /** |
|
588 | + * _release_reserved_ticket_for_registration |
|
589 | + * releases reserved tickets for an EE_Registration |
|
590 | + * by default, will NOT release tickets for APPROVED registrations |
|
591 | + * |
|
592 | + * @access protected |
|
593 | + * @param EE_Registration $registration |
|
594 | + * @param EE_Transaction $transaction |
|
595 | + * @return int |
|
596 | + * @throws EE_Error |
|
597 | + */ |
|
598 | + protected function _release_reserved_ticket_for_registration( |
|
599 | + EE_Registration $registration, |
|
600 | + EE_Transaction $transaction |
|
601 | + ) { |
|
602 | + $STS_ID = $transaction->status_ID(); |
|
603 | + if (self::debug) { |
|
604 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
605 | + echo '<br /> . . registration->ID: ' . $registration->ID(); |
|
606 | + echo '<br /> . . registration->status_ID: ' . $registration->status_ID(); |
|
607 | + echo '<br /> . . transaction->status_ID(): ' . $STS_ID; |
|
608 | + } |
|
609 | + if ( |
|
610 | + // release Tickets for Failed Transactions and Abandoned Transactions |
|
611 | + $STS_ID === EEM_Transaction::failed_status_code |
|
612 | + || $STS_ID === EEM_Transaction::abandoned_status_code |
|
613 | + || ( |
|
614 | + // also release Tickets for Incomplete Transactions, but ONLY if the Registrations are NOT Approved |
|
615 | + $STS_ID === EEM_Transaction::incomplete_status_code |
|
616 | + && $registration->status_ID() !== EEM_Registration::status_id_approved |
|
617 | + ) |
|
618 | + ) { |
|
619 | + $ticket = $registration->ticket(); |
|
620 | + if ($ticket instanceof EE_Ticket) { |
|
621 | + return $this->_release_reserved_ticket($ticket); |
|
622 | + } |
|
623 | + } |
|
624 | + return 0; |
|
625 | + } |
|
626 | + |
|
627 | + |
|
628 | + |
|
629 | + /********************************** SESSION_CART_RESET **********************************/ |
|
630 | + |
|
631 | + |
|
632 | + |
|
633 | + /** |
|
634 | + * session_cart_reset |
|
635 | + * callback hooked into 'AHEE__EE_Session__reset_cart__before_reset' |
|
636 | + * |
|
637 | + * @access public |
|
638 | + * @param EE_Session $session |
|
639 | + * @return void |
|
640 | + * @throws EE_Error |
|
641 | + */ |
|
642 | + public static function session_cart_reset(EE_Session $session) |
|
643 | + { |
|
644 | + if (self::debug) { |
|
645 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
646 | + } |
|
647 | + $cart = $session->cart(); |
|
648 | + if ($cart instanceof EE_Cart) { |
|
649 | + if (self::debug) { |
|
650 | + echo '<br /><br /> cart instance of EE_Cart: '; |
|
651 | + } |
|
652 | + EED_Ticket_Sales_Monitor::instance()->_session_cart_reset($cart); |
|
653 | + } else { |
|
654 | + if (self::debug) { |
|
655 | + echo '<br /><br /> invalid EE_Cart: '; |
|
656 | + var_dump($cart); |
|
657 | + } |
|
658 | + } |
|
659 | + } |
|
660 | + |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * _session_cart_reset |
|
665 | + * releases reserved tickets in the EE_Cart |
|
666 | + * |
|
667 | + * @access protected |
|
668 | + * @param EE_Cart $cart |
|
669 | + * @return void |
|
670 | + * @throws EE_Error |
|
671 | + */ |
|
672 | + protected function _session_cart_reset(EE_Cart $cart) |
|
673 | + { |
|
674 | + if (self::debug) { |
|
675 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
676 | + } |
|
677 | + EE_Registry::instance()->load_helper('Line_Item'); |
|
678 | + $ticket_line_items = $cart->get_tickets(); |
|
679 | + if (empty($ticket_line_items)) { |
|
680 | + return; |
|
681 | + } |
|
682 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
683 | + if (self::debug) { |
|
684 | + echo '<br /> . ticket_line_item->ID(): ' . $ticket_line_item->ID(); |
|
685 | + } |
|
686 | + if ($ticket_line_item instanceof EE_Line_Item && $ticket_line_item->OBJ_type() === 'Ticket') { |
|
687 | + if (self::debug) { |
|
688 | + echo '<br /> . . ticket_line_item->OBJ_ID(): ' . $ticket_line_item->OBJ_ID(); |
|
689 | + } |
|
690 | + $ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID()); |
|
691 | + if ($ticket instanceof EE_Ticket) { |
|
692 | + if (self::debug) { |
|
693 | + echo '<br /> . . ticket->ID(): ' . $ticket->ID(); |
|
694 | + echo '<br /> . . ticket_line_item->quantity(): ' . $ticket_line_item->quantity(); |
|
695 | + } |
|
696 | + $this->_release_reserved_ticket($ticket, $ticket_line_item->quantity()); |
|
697 | + } |
|
698 | + } |
|
699 | + } |
|
700 | + if (self::debug) { |
|
701 | + echo '<br /><br /> RESET COMPLETED '; |
|
702 | + } |
|
703 | + } |
|
704 | + |
|
705 | + |
|
706 | + |
|
707 | + /********************************** SESSION_CHECKOUT_RESET **********************************/ |
|
708 | + |
|
709 | + |
|
710 | + |
|
711 | + /** |
|
712 | + * session_checkout_reset |
|
713 | + * callback hooked into 'AHEE__EE_Session__reset_checkout__before_reset' |
|
714 | + * |
|
715 | + * @access public |
|
716 | + * @param EE_Session $session |
|
717 | + * @return void |
|
718 | + * @throws EE_Error |
|
719 | + */ |
|
720 | + public static function session_checkout_reset(EE_Session $session) |
|
721 | + { |
|
722 | + $checkout = $session->checkout(); |
|
723 | + if ($checkout instanceof EE_Checkout) { |
|
724 | + EED_Ticket_Sales_Monitor::instance()->_session_checkout_reset($checkout); |
|
725 | + } |
|
726 | + } |
|
727 | + |
|
728 | + |
|
729 | + |
|
730 | + /** |
|
731 | + * _session_checkout_reset |
|
732 | + * releases reserved tickets for the EE_Checkout->transaction |
|
733 | + * |
|
734 | + * @access protected |
|
735 | + * @param EE_Checkout $checkout |
|
736 | + * @return void |
|
737 | + * @throws EE_Error |
|
738 | + */ |
|
739 | + protected function _session_checkout_reset(EE_Checkout $checkout) |
|
740 | + { |
|
741 | + if (self::debug) { |
|
742 | + echo '<br /><br /> ' . __LINE__ . ') ' . __METHOD__ . '() '; |
|
743 | + } |
|
744 | + // we want to release the each registration's reserved tickets if the session was cleared, but not if this is a revisit |
|
745 | + if ($checkout->revisit || ! $checkout->transaction instanceof EE_Transaction) { |
|
746 | + return; |
|
747 | + } |
|
748 | + $this->_release_all_reserved_tickets_for_transaction($checkout->transaction); |
|
749 | + } |
|
750 | + |
|
751 | + |
|
752 | + |
|
753 | + /********************************** SESSION_EXPIRED_RESET **********************************/ |
|
754 | + |
|
755 | + |
|
756 | + |
|
757 | + /** |
|
758 | + * session_expired_reset |
|
759 | + * |
|
760 | + * @access public |
|
761 | + * @param EE_Session $session |
|
762 | + * @return void |
|
763 | + */ |
|
764 | + public static function session_expired_reset(EE_Session $session) |
|
765 | + { |
|
766 | + } |
|
767 | + |
|
768 | + |
|
769 | + |
|
770 | + /********************************** PROCESS_ABANDONED_TRANSACTIONS **********************************/ |
|
771 | + |
|
772 | + |
|
773 | + |
|
774 | + /** |
|
775 | + * process_abandoned_transactions |
|
776 | + * releases reserved tickets for all registrations of an ABANDONED EE_Transaction |
|
777 | + * by default, will NOT release tickets for free transactions, or any that have received a payment |
|
778 | + * |
|
779 | + * @access public |
|
780 | + * @param EE_Transaction $transaction |
|
781 | + * @return void |
|
782 | + * @throws EE_Error |
|
783 | + */ |
|
784 | + public static function process_abandoned_transactions(EE_Transaction $transaction) |
|
785 | + { |
|
786 | + // is this TXN free or has any money been paid towards this TXN? If so, then leave it alone |
|
787 | + if ($transaction->is_free() || $transaction->paid() > 0) { |
|
788 | + if (self::debug) { |
|
789 | + // DEBUG LOG |
|
790 | + EEH_Debug_Tools::log( |
|
791 | + __CLASS__, __FUNCTION__, __LINE__, |
|
792 | + array($transaction), |
|
793 | + false, 'EE_Transaction: ' . $transaction->ID() |
|
794 | + ); |
|
795 | + } |
|
796 | + return; |
|
797 | + } |
|
798 | + // have their been any successful payments made ? |
|
799 | + $payments = $transaction->payments(); |
|
800 | + foreach ($payments as $payment) { |
|
801 | + if ($payment instanceof EE_Payment && $payment->status() === EEM_Payment::status_id_approved) { |
|
802 | + if (self::debug) { |
|
803 | + // DEBUG LOG |
|
804 | + EEH_Debug_Tools::log( |
|
805 | + __CLASS__, __FUNCTION__, __LINE__, |
|
806 | + array($payment), |
|
807 | + false, 'EE_Transaction: ' . $transaction->ID() |
|
808 | + ); |
|
809 | + } |
|
810 | + return; |
|
811 | + } |
|
812 | + } |
|
813 | + // since you haven't even attempted to pay for your ticket... |
|
814 | + EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
815 | + } |
|
816 | + |
|
817 | + |
|
818 | + |
|
819 | + /********************************** PROCESS_FAILED_TRANSACTIONS **********************************/ |
|
820 | + |
|
821 | + |
|
822 | + |
|
823 | + /** |
|
824 | + * process_abandoned_transactions |
|
825 | + * releases reserved tickets for absolutely ALL registrations of a FAILED EE_Transaction |
|
826 | + * |
|
827 | + * @access public |
|
828 | + * @param EE_Transaction $transaction |
|
829 | + * @return void |
|
830 | + * @throws EE_Error |
|
831 | + */ |
|
832 | + public static function process_failed_transactions(EE_Transaction $transaction) |
|
833 | + { |
|
834 | + // since you haven't even attempted to pay for your ticket... |
|
835 | + EED_Ticket_Sales_Monitor::instance()->_release_all_reserved_tickets_for_transaction($transaction); |
|
836 | + } |
|
837 | + |
|
838 | + |
|
839 | + |
|
840 | + /********************************** RESET RESERVATION COUNTS *********************************/ |
|
841 | + |
|
842 | + |
|
843 | + |
|
844 | + /** |
|
845 | + * Resets all ticket and datetime reserved counts to zero |
|
846 | + * Tickets that are currently associated with a Transaction that is in progress |
|
847 | + * |
|
848 | + * @throws \EE_Error |
|
849 | + * @throws \DomainException |
|
850 | + */ |
|
851 | + public static function reset_reservation_counts() |
|
852 | + { |
|
853 | + /** @var EE_Line_Item[] $valid_reserved_tickets */ |
|
854 | + $valid_reserved_tickets = array(); |
|
855 | + $transactions_in_progress = EEM_Transaction::instance()->get_transactions_in_progress(); |
|
856 | + foreach ($transactions_in_progress as $transaction_in_progress) { |
|
857 | + // if this TXN has been fully completed, then skip it |
|
858 | + if ($transaction_in_progress->reg_step_completed('finalize_registration')) { |
|
859 | + continue; |
|
860 | + } |
|
861 | + /** @var EE_Transaction $transaction_in_progress */ |
|
862 | + $total_line_item = $transaction_in_progress->total_line_item(); |
|
863 | + // $transaction_in_progress->line |
|
864 | + if (! $total_line_item instanceof EE_Line_Item) { |
|
865 | + throw new DomainException( |
|
866 | + esc_html__('Transaction does not have a valid Total Line Item associated with it.', 'event_espresso') |
|
867 | + ); |
|
868 | + } |
|
869 | + $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total( |
|
870 | + $total_line_item |
|
871 | + ); |
|
872 | + } |
|
873 | + $total_line_items = EEM_Line_Item::instance()->get_total_line_items_for_active_carts(); |
|
874 | + foreach ($total_line_items as $total_line_item) { |
|
875 | + $valid_reserved_tickets += EED_Ticket_Sales_Monitor::get_ticket_line_items_for_grand_total( |
|
876 | + $total_line_item |
|
877 | + ); |
|
878 | + } |
|
879 | + return EED_Ticket_Sales_Monitor::release_reservations_for_tickets( |
|
880 | + EEM_Ticket::instance()->get_tickets_with_reservations(), |
|
881 | + $valid_reserved_tickets |
|
882 | + ); |
|
883 | + } |
|
884 | + |
|
885 | + |
|
886 | + |
|
887 | + /** |
|
888 | + * @param EE_Line_Item $total_line_item |
|
889 | + * @return EE_Line_Item[] |
|
890 | + */ |
|
891 | + private static function get_ticket_line_items_for_grand_total(EE_Line_Item $total_line_item) |
|
892 | + { |
|
893 | + /** @var EE_Line_Item[] $valid_reserved_tickets */ |
|
894 | + $valid_reserved_tickets = array(); |
|
895 | + $ticket_line_items = EEH_Line_Item::get_ticket_line_items($total_line_item); |
|
896 | + foreach ($ticket_line_items as $ticket_line_item) { |
|
897 | + if ($ticket_line_item instanceof EE_Line_Item) { |
|
898 | + $valid_reserved_tickets[] = $ticket_line_item; |
|
899 | + } |
|
900 | + } |
|
901 | + return $valid_reserved_tickets; |
|
902 | + } |
|
903 | + |
|
904 | + |
|
905 | + |
|
906 | + /** |
|
907 | + * @param EE_Ticket[] $tickets_with_reservations |
|
908 | + * @param EE_Line_Item[] $valid_reserved_ticket_line_items |
|
909 | + * @return int |
|
910 | + * @throws \EE_Error |
|
911 | + */ |
|
912 | + private static function release_reservations_for_tickets( |
|
913 | + array $tickets_with_reservations, |
|
914 | + $valid_reserved_ticket_line_items = array() |
|
915 | + ) { |
|
916 | + $total_tickets_released = 0; |
|
917 | + foreach ($tickets_with_reservations as $ticket_with_reservations) { |
|
918 | + if (! $ticket_with_reservations instanceof EE_Ticket) { |
|
919 | + continue; |
|
920 | + } |
|
921 | + $reserved_qty = $ticket_with_reservations->reserved(); |
|
922 | + foreach ($valid_reserved_ticket_line_items as $valid_reserved_ticket_line_item) { |
|
923 | + if ( |
|
924 | + $valid_reserved_ticket_line_item instanceof EE_Line_Item |
|
925 | + && $valid_reserved_ticket_line_item->OBJ_ID() === $ticket_with_reservations->ID() |
|
926 | + ) { |
|
927 | + $reserved_qty -= $valid_reserved_ticket_line_item->quantity(); |
|
928 | + } |
|
929 | + } |
|
930 | + if ($reserved_qty > 0) { |
|
931 | + $ticket_with_reservations->decrease_reserved($reserved_qty); |
|
932 | + $ticket_with_reservations->save(); |
|
933 | + $total_tickets_released += $reserved_qty; |
|
934 | + } |
|
935 | + } |
|
936 | + return $total_tickets_released; |
|
937 | + } |
|
938 | 938 | |
939 | 939 | } |
940 | 940 | // End of file EED_Ticket_Sales_Monitor.module.php |