@@ -467,7 +467,7 @@ |
||
467 | 467 | * @param int $ATT_ID |
468 | 468 | * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the |
469 | 469 | * attendee number is required |
470 | - * @return mixed array on success, FALSE on fail |
|
470 | + * @return null|EE_Base_Class array on success, FALSE on fail |
|
471 | 471 | * @throws EE_Error |
472 | 472 | */ |
473 | 473 | public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) |
@@ -1,5 +1,4 @@ |
||
1 | 1 | <?php |
2 | -use EventEspresso\core\exceptions\InvalidIdentifierException; |
|
3 | 2 | use EventEspresso\core\exceptions\InvalidStatusException; |
4 | 3 | use EventEspresso\core\services\database\TableAnalysis; |
5 | 4 |
@@ -14,817 +14,817 @@ discard block |
||
14 | 14 | class EEM_Registration extends EEM_Soft_Delete_Base |
15 | 15 | { |
16 | 16 | |
17 | - /** |
|
18 | - * @var EEM_Registration $_instance |
|
19 | - */ |
|
20 | - protected static $_instance; |
|
21 | - |
|
22 | - /** |
|
23 | - * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values |
|
24 | - * are status codes (eg, approved, cancelled, etc) |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - private static $_reg_status; |
|
29 | - |
|
30 | - /** |
|
31 | - * The value of REG_count for a primary registrant |
|
32 | - */ |
|
33 | - const PRIMARY_REGISTRANT_COUNT = 1; |
|
34 | - |
|
35 | - /** |
|
36 | - * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration. |
|
37 | - * Initial status for registrations when they are first created |
|
38 | - * Payments are NOT allowed. |
|
39 | - * Automatically toggled to whatever the default Event registration status is upon completion of the attendee |
|
40 | - * information reg step NO space reserved. Registration is NOT active |
|
41 | - */ |
|
42 | - const status_id_incomplete = 'RIC'; |
|
43 | - |
|
44 | - /** |
|
45 | - * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration. |
|
46 | - * Payments are NOT allowed. |
|
47 | - * Event Admin must manually toggle STS_ID for it to change |
|
48 | - * No space reserved. |
|
49 | - * Registration is active |
|
50 | - */ |
|
51 | - const status_id_not_approved = 'RNA'; |
|
52 | - |
|
53 | - /** |
|
54 | - * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT . |
|
55 | - * Payments are allowed. |
|
56 | - * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
57 | - * No space reserved. |
|
58 | - * Registration is active |
|
59 | - */ |
|
60 | - const status_id_pending_payment = 'RPP'; |
|
61 | - |
|
62 | - /** |
|
63 | - * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST . |
|
64 | - * Payments are allowed. |
|
65 | - * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
66 | - * No space reserved. |
|
67 | - * Registration is active |
|
68 | - */ |
|
69 | - const status_id_wait_list = 'RWL'; |
|
70 | - |
|
71 | - /** |
|
72 | - * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration. |
|
73 | - * the TXN may or may not be completed ( paid in full ) |
|
74 | - * Payments are allowed. |
|
75 | - * A space IS reserved. |
|
76 | - * Registration is active |
|
77 | - */ |
|
78 | - const status_id_approved = 'RAP'; |
|
79 | - |
|
80 | - /** |
|
81 | - * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee. |
|
82 | - * Payments are NOT allowed. |
|
83 | - * NO space reserved. |
|
84 | - * Registration is NOT active |
|
85 | - */ |
|
86 | - const status_id_cancelled = 'RCN'; |
|
87 | - |
|
88 | - /** |
|
89 | - * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin |
|
90 | - * Payments are NOT allowed. |
|
91 | - * No space reserved. |
|
92 | - * Registration is NOT active |
|
93 | - */ |
|
94 | - const status_id_declined = 'RDC'; |
|
95 | - |
|
96 | - /** |
|
97 | - * @var TableAnalysis $table_analysis |
|
98 | - */ |
|
99 | - protected $_table_analysis; |
|
100 | - |
|
101 | - |
|
102 | - /** |
|
103 | - * private constructor to prevent direct creation |
|
104 | - * |
|
105 | - * @Constructor |
|
106 | - * @access protected |
|
107 | - * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
108 | - * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
109 | - * date time model field objects. Default is NULL (and will be assumed using the set |
|
110 | - * timezone in the 'timezone_string' wp option) |
|
111 | - * @throws EE_Error |
|
112 | - */ |
|
113 | - protected function __construct($timezone = null) |
|
114 | - { |
|
115 | - $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
116 | - $this->singular_item = esc_html__('Registration', 'event_espresso'); |
|
117 | - $this->plural_item = esc_html__('Registrations', 'event_espresso'); |
|
118 | - $this->_tables = array( |
|
119 | - 'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'), |
|
120 | - ); |
|
121 | - $this->_fields = array( |
|
122 | - 'Registration' => array( |
|
123 | - 'REG_ID' => new EE_Primary_Key_Int_Field( |
|
124 | - 'REG_ID', |
|
125 | - esc_html__('Registration ID', 'event_espresso') |
|
126 | - ), |
|
127 | - 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
128 | - 'EVT_ID', |
|
129 | - esc_html__('Event ID', 'event_espresso'), |
|
130 | - false, |
|
131 | - 0, |
|
132 | - 'Event' |
|
133 | - ), |
|
134 | - 'ATT_ID' => new EE_Foreign_Key_Int_Field( |
|
135 | - 'ATT_ID', |
|
136 | - esc_html__('Attendee ID', 'event_espresso'), |
|
137 | - false, |
|
138 | - 0, |
|
139 | - 'Attendee' |
|
140 | - ), |
|
141 | - 'TXN_ID' => new EE_Foreign_Key_Int_Field( |
|
142 | - 'TXN_ID', |
|
143 | - esc_html__('Transaction ID', 'event_espresso'), |
|
144 | - false, |
|
145 | - 0, |
|
146 | - 'Transaction' |
|
147 | - ), |
|
148 | - 'TKT_ID' => new EE_Foreign_Key_Int_Field( |
|
149 | - 'TKT_ID', |
|
150 | - esc_html__('Ticket ID', 'event_espresso'), |
|
151 | - false, |
|
152 | - 0, |
|
153 | - 'Ticket' |
|
154 | - ), |
|
155 | - 'STS_ID' => new EE_Foreign_Key_String_Field( |
|
156 | - 'STS_ID', |
|
157 | - esc_html__('Status ID', 'event_espresso'), |
|
158 | - false, |
|
159 | - EEM_Registration::status_id_incomplete, |
|
160 | - 'Status' |
|
161 | - ), |
|
162 | - 'REG_date' => new EE_Datetime_Field( |
|
163 | - 'REG_date', |
|
164 | - esc_html__('Time registration occurred', 'event_espresso'), |
|
165 | - false, |
|
166 | - EE_Datetime_Field::now, |
|
167 | - $timezone |
|
168 | - ), |
|
169 | - 'REG_final_price' => new EE_Money_Field( |
|
170 | - 'REG_final_price', |
|
171 | - esc_html__('Registration\'s share of the transaction total', 'event_espresso'), |
|
172 | - false, |
|
173 | - 0 |
|
174 | - ), |
|
175 | - 'REG_paid' => new EE_Money_Field( |
|
176 | - 'REG_paid', |
|
177 | - esc_html__('Amount paid to date towards registration', 'event_espresso'), |
|
178 | - false, |
|
179 | - 0 |
|
180 | - ), |
|
181 | - 'REG_session' => new EE_Plain_Text_Field( |
|
182 | - 'REG_session', |
|
183 | - esc_html__('Session ID of registration', 'event_espresso'), |
|
184 | - false, |
|
185 | - '' |
|
186 | - ), |
|
187 | - 'REG_code' => new EE_Plain_Text_Field( |
|
188 | - 'REG_code', |
|
189 | - esc_html__('Unique Code for this registration', 'event_espresso'), |
|
190 | - false, |
|
191 | - '' |
|
192 | - ), |
|
193 | - 'REG_url_link' => new EE_Plain_Text_Field( |
|
194 | - 'REG_url_link', |
|
195 | - esc_html__('String to be used in URL for identifying registration', 'event_espresso'), |
|
196 | - false, |
|
197 | - '' |
|
198 | - ), |
|
199 | - 'REG_count' => new EE_Integer_Field( |
|
200 | - 'REG_count', |
|
201 | - esc_html__('Count of this registration in the group registration ', 'event_espresso'), |
|
202 | - true, |
|
203 | - 1 |
|
204 | - ), |
|
205 | - 'REG_group_size' => new EE_Integer_Field( |
|
206 | - 'REG_group_size', |
|
207 | - esc_html__('Number of registrations on this group', 'event_espresso'), |
|
208 | - false, |
|
209 | - 1 |
|
210 | - ), |
|
211 | - 'REG_att_is_going' => new EE_Boolean_Field( |
|
212 | - 'REG_att_is_going', |
|
213 | - esc_html__('Flag indicating the registrant plans on attending', 'event_espresso'), |
|
214 | - false, |
|
215 | - false |
|
216 | - ), |
|
217 | - 'REG_deleted' => new EE_Trashed_Flag_Field( |
|
218 | - 'REG_deleted', |
|
219 | - esc_html__('Flag indicating if registration has been archived or not.', 'event_espresso'), |
|
220 | - false, |
|
221 | - false |
|
222 | - ), |
|
223 | - ), |
|
224 | - ); |
|
225 | - $this->_model_relations = array( |
|
226 | - 'Event' => new EE_Belongs_To_Relation(), |
|
227 | - 'Attendee' => new EE_Belongs_To_Relation(), |
|
228 | - 'Transaction' => new EE_Belongs_To_Relation(), |
|
229 | - 'Ticket' => new EE_Belongs_To_Relation(), |
|
230 | - 'Status' => new EE_Belongs_To_Relation(), |
|
231 | - 'Answer' => new EE_Has_Many_Relation(), |
|
232 | - 'Checkin' => new EE_Has_Many_Relation(), |
|
233 | - 'Registration_Payment' => new EE_Has_Many_Relation(), |
|
234 | - 'Payment' => new EE_HABTM_Relation('Registration_Payment'), |
|
235 | - 'Message' => new EE_Has_Many_Any_Relation(false) |
|
236 | - // allow deletes even if there are messages in the queue related |
|
237 | - ); |
|
238 | - $this->_model_chain_to_wp_user = 'Event'; |
|
239 | - parent::__construct($timezone); |
|
240 | - } |
|
241 | - |
|
242 | - |
|
243 | - /** |
|
244 | - * a list of ALL valid registration statuses currently in use within the system |
|
245 | - * generated by combining the filterable active and inactive reg status arrays |
|
246 | - * |
|
247 | - * @return array |
|
248 | - */ |
|
249 | - public static function reg_statuses() |
|
250 | - { |
|
251 | - return array_unique( |
|
252 | - array_merge( |
|
253 | - EEM_Registration::active_reg_statuses(), |
|
254 | - EEM_Registration::inactive_reg_statuses() |
|
255 | - ) |
|
256 | - ); |
|
257 | - } |
|
258 | - |
|
259 | - |
|
260 | - /** |
|
261 | - * reg_statuses_that_allow_payment |
|
262 | - * a filterable list of registration statuses that allow a registrant to make a payment |
|
263 | - * |
|
264 | - * @access public |
|
265 | - * @return array |
|
266 | - */ |
|
267 | - public static function reg_statuses_that_allow_payment() |
|
268 | - { |
|
269 | - return apply_filters( |
|
270 | - 'FHEE__EEM_Registration__reg_statuses_that_allow_payment', |
|
271 | - array( |
|
272 | - EEM_Registration::status_id_approved, |
|
273 | - EEM_Registration::status_id_pending_payment, |
|
274 | - ) |
|
275 | - ); |
|
276 | - } |
|
277 | - |
|
278 | - |
|
279 | - /** |
|
280 | - * active_reg_statuses |
|
281 | - * a filterable list of registration statuses that are considered active |
|
282 | - * |
|
283 | - * @access public |
|
284 | - * @return array |
|
285 | - */ |
|
286 | - public static function active_reg_statuses() |
|
287 | - { |
|
288 | - return apply_filters( |
|
289 | - 'FHEE__EEM_Registration__active_reg_statuses', |
|
290 | - array( |
|
291 | - EEM_Registration::status_id_approved, |
|
292 | - EEM_Registration::status_id_pending_payment, |
|
293 | - EEM_Registration::status_id_wait_list, |
|
294 | - EEM_Registration::status_id_not_approved, |
|
295 | - ) |
|
296 | - ); |
|
297 | - } |
|
298 | - |
|
299 | - |
|
300 | - /** |
|
301 | - * inactive_reg_statuses |
|
302 | - * a filterable list of registration statuses that are not considered active |
|
303 | - * |
|
304 | - * @access public |
|
305 | - * @return array |
|
306 | - */ |
|
307 | - public static function inactive_reg_statuses() |
|
308 | - { |
|
309 | - return apply_filters( |
|
310 | - 'FHEE__EEM_Registration__inactive_reg_statuses', |
|
311 | - array( |
|
312 | - EEM_Registration::status_id_incomplete, |
|
313 | - EEM_Registration::status_id_cancelled, |
|
314 | - EEM_Registration::status_id_declined, |
|
315 | - ) |
|
316 | - ); |
|
317 | - } |
|
318 | - |
|
319 | - |
|
320 | - /** |
|
321 | - * closed_reg_statuses |
|
322 | - * a filterable list of registration statuses that are considered "closed" |
|
323 | - * meaning they should not be considered in any calculations involving monies owing |
|
324 | - * |
|
325 | - * @access public |
|
326 | - * @return array |
|
327 | - */ |
|
328 | - public static function closed_reg_statuses() |
|
329 | - { |
|
330 | - return apply_filters( |
|
331 | - 'FHEE__EEM_Registration__closed_reg_statuses', |
|
332 | - array( |
|
333 | - EEM_Registration::status_id_cancelled, |
|
334 | - EEM_Registration::status_id_declined, |
|
335 | - EEM_Registration::status_id_wait_list, |
|
336 | - ) |
|
337 | - ); |
|
338 | - } |
|
339 | - |
|
340 | - |
|
341 | - /** |
|
342 | - * get list of registration statuses |
|
343 | - * |
|
344 | - * @access public |
|
345 | - * @param array $exclude The status ids to exclude from the returned results |
|
346 | - * @param bool $translated If true will return the values as singular localized strings |
|
347 | - * @return array |
|
348 | - * @throws EE_Error |
|
349 | - */ |
|
350 | - public static function reg_status_array($exclude = array(), $translated = false) |
|
351 | - { |
|
352 | - EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
353 | - return $translated |
|
354 | - ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence') |
|
355 | - : self::$_reg_status; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * get list of registration statuses |
|
361 | - * |
|
362 | - * @access private |
|
363 | - * @param array $exclude |
|
364 | - * @return void |
|
365 | - * @throws EE_Error |
|
366 | - */ |
|
367 | - private function _get_registration_status_array($exclude = array()) |
|
368 | - { |
|
369 | - // in the very rare circumstance that we are deleting a model's table's data |
|
370 | - // and the table hasn't actually been created, this could have an error |
|
371 | - /** @type WPDB $wpdb */ |
|
372 | - global $wpdb; |
|
373 | - if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
374 | - $results = $wpdb->get_results( |
|
375 | - "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'" |
|
376 | - ); |
|
377 | - self::$_reg_status = array(); |
|
378 | - foreach ($results as $status) { |
|
379 | - if (!in_array($status->STS_ID, $exclude, true)) { |
|
380 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
381 | - } |
|
382 | - } |
|
383 | - } |
|
384 | - } |
|
385 | - |
|
386 | - |
|
387 | - /** |
|
388 | - * Gets the injected table analyzer, or throws an exception |
|
389 | - * |
|
390 | - * @return TableAnalysis |
|
391 | - * @throws EE_Error |
|
392 | - */ |
|
393 | - protected function _get_table_analysis() |
|
394 | - { |
|
395 | - if ($this->_table_analysis instanceof TableAnalysis) { |
|
396 | - return $this->_table_analysis; |
|
397 | - } |
|
398 | - throw new EE_Error( |
|
399 | - sprintf( |
|
400 | - esc_html__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
401 | - get_class($this) |
|
402 | - ) |
|
403 | - ); |
|
404 | - } |
|
405 | - |
|
406 | - |
|
407 | - /** |
|
408 | - * This returns a wpdb->results array of all registration date month and years matching the incoming query params |
|
409 | - * and grouped by month and year. |
|
410 | - * |
|
411 | - * @param array $where_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
412 | - * @return array |
|
413 | - * @throws EE_Error |
|
414 | - */ |
|
415 | - public function get_reg_months_and_years($where_params) |
|
416 | - { |
|
417 | - $query_params[0] = $where_params; |
|
418 | - $query_params['group_by'] = array('reg_year', 'reg_month'); |
|
419 | - $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
420 | - $columns_to_select = array( |
|
421 | - 'reg_year' => array('YEAR(REG_date)', '%s'), |
|
422 | - 'reg_month' => array('MONTHNAME(REG_date)', '%s'), |
|
423 | - ); |
|
424 | - return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
425 | - } |
|
426 | - |
|
427 | - |
|
428 | - /** |
|
429 | - * retrieve ALL registrations for a particular Attendee from db |
|
430 | - * |
|
431 | - * @param int $ATT_ID |
|
432 | - * @return EE_Base_Class[]|EE_Registration[]|null |
|
433 | - * @throws EE_Error |
|
434 | - */ |
|
435 | - public function get_all_registrations_for_attendee($ATT_ID = 0) |
|
436 | - { |
|
437 | - if (!$ATT_ID) { |
|
438 | - return null; |
|
439 | - } |
|
440 | - return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
441 | - } |
|
442 | - |
|
443 | - |
|
444 | - /** |
|
445 | - * Gets a registration given their REG_url_link. Yes, this should usually |
|
446 | - * be passed via a GET parameter. |
|
447 | - * |
|
448 | - * @param string $REG_url_link |
|
449 | - * @return EE_Base_Class|EE_Registration|null |
|
450 | - * @throws EE_Error |
|
451 | - */ |
|
452 | - public function get_registration_for_reg_url_link($REG_url_link) |
|
453 | - { |
|
454 | - if (!$REG_url_link) { |
|
455 | - return null; |
|
456 | - } |
|
457 | - return $this->get_one(array(array('REG_url_link' => $REG_url_link))); |
|
458 | - } |
|
459 | - |
|
460 | - |
|
461 | - /** |
|
462 | - * retrieve registration for a specific transaction attendee from db |
|
463 | - * |
|
464 | - * @access public |
|
465 | - * @param int $TXN_ID |
|
466 | - * @param int $ATT_ID |
|
467 | - * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the |
|
468 | - * attendee number is required |
|
469 | - * @return mixed array on success, FALSE on fail |
|
470 | - * @throws EE_Error |
|
471 | - */ |
|
472 | - public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) |
|
473 | - { |
|
474 | - return $this->get_one(array( |
|
475 | - array( |
|
476 | - 'TXN_ID' => $TXN_ID, |
|
477 | - 'ATT_ID' => $ATT_ID, |
|
478 | - ), |
|
479 | - 'limit' => array(min($att_nmbr - 1, 0), 1), |
|
480 | - )); |
|
481 | - } |
|
482 | - |
|
483 | - |
|
484 | - /** |
|
485 | - * get the number of registrations per day for the Registration Admin page Reports Tab. |
|
486 | - * (doesn't utilize models because it's a fairly specialized query) |
|
487 | - * |
|
488 | - * @access public |
|
489 | - * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
490 | - * @return stdClass[] with properties regDate and total |
|
491 | - * @throws EE_Error |
|
492 | - */ |
|
493 | - public function get_registrations_per_day_report($period = '-1 month') |
|
494 | - { |
|
495 | - $sql_date = $this->convert_datetime_for_query( |
|
496 | - 'REG_date', |
|
497 | - date('Y-m-d H:i:s', strtotime($period)), |
|
498 | - 'Y-m-d H:i:s', |
|
499 | - 'UTC' |
|
500 | - ); |
|
501 | - $where = array( |
|
502 | - 'REG_date' => array('>=', $sql_date), |
|
503 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
504 | - ); |
|
505 | - if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
506 | - $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
507 | - } |
|
508 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
509 | - $results = $this->_get_all_wpdb_results( |
|
510 | - array( |
|
511 | - $where, |
|
512 | - 'group_by' => 'regDate', |
|
513 | - 'order_by' => array('REG_date' => 'ASC'), |
|
514 | - ), |
|
515 | - OBJECT, |
|
516 | - array( |
|
517 | - 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
518 | - 'total' => array('count(REG_ID)', '%d'), |
|
519 | - ) |
|
520 | - ); |
|
521 | - return $results; |
|
522 | - } |
|
523 | - |
|
524 | - |
|
525 | - /** |
|
526 | - * Get the number of registrations per day including the count of registrations for each Registration Status. |
|
527 | - * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
528 | - * |
|
529 | - * @param string $period |
|
530 | - * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
|
531 | - * @throws EE_Error |
|
532 | - * (i.e. RAP) |
|
533 | - */ |
|
534 | - public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
|
535 | - { |
|
536 | - global $wpdb; |
|
537 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
538 | - $event_table = $wpdb->posts; |
|
539 | - $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
540 | - // prepare the query interval for displaying offset |
|
541 | - $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
542 | - // inner date query |
|
543 | - $inner_date_query = "SELECT DISTINCT REG_date from {$registration_table} "; |
|
544 | - $inner_where = ' WHERE'; |
|
545 | - // exclude events not authored by user if permissions in effect |
|
546 | - if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
547 | - $inner_date_query .= "LEFT JOIN {$event_table} ON ID = EVT_ID"; |
|
548 | - $inner_where .= ' post_author = ' . get_current_user_id() . ' AND'; |
|
549 | - } |
|
550 | - $inner_where .= " REG_date >= '{$sql_date}'"; |
|
551 | - $inner_date_query .= $inner_where; |
|
552 | - // start main query |
|
553 | - $select = "SELECT DATE({$query_interval}) as Registration_REG_date, "; |
|
554 | - $join = ''; |
|
555 | - $join_parts = array(); |
|
556 | - $select_parts = array(); |
|
557 | - // loop through registration stati to do parts for each status. |
|
558 | - foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
559 | - if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
560 | - continue; |
|
561 | - } |
|
562 | - $select_parts[] = "COUNT({$STS_code}.REG_ID) as {$STS_ID}"; |
|
563 | - $join_parts[] = "{$registration_table} AS {$STS_code} ON {$STS_code}.REG_date = dates.REG_date AND {$STS_code}.STS_ID = '{$STS_ID}'"; |
|
564 | - } |
|
565 | - // setup the selects |
|
566 | - $select .= implode(', ', $select_parts); |
|
567 | - $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
|
568 | - // setup the joins |
|
569 | - $join .= implode(' LEFT JOIN ', $join_parts); |
|
570 | - // now let's put it all together |
|
571 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
572 | - // and execute it |
|
573 | - return $wpdb->get_results($query, ARRAY_A); |
|
574 | - } |
|
575 | - |
|
576 | - |
|
577 | - /** |
|
578 | - * get the number of registrations per event for the Registration Admin page Reports Tab |
|
579 | - * |
|
580 | - * @access public |
|
581 | - * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
582 | - * @return stdClass[] each with properties event_name, reg_limit, and total |
|
583 | - * @throws EE_Error |
|
584 | - */ |
|
585 | - public function get_registrations_per_event_report($period = '-1 month') |
|
586 | - { |
|
587 | - $date_sql = $this->convert_datetime_for_query( |
|
588 | - 'REG_date', |
|
589 | - date('Y-m-d H:i:s', strtotime($period)), |
|
590 | - 'Y-m-d H:i:s', |
|
591 | - 'UTC' |
|
592 | - ); |
|
593 | - $where = array( |
|
594 | - 'REG_date' => array('>=', $date_sql), |
|
595 | - 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
596 | - ); |
|
597 | - if ( |
|
598 | - !EE_Registry::instance()->CAP->current_user_can( |
|
599 | - 'ee_read_others_registrations', |
|
600 | - 'reg_per_event_report' |
|
601 | - ) |
|
602 | - ) { |
|
603 | - $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
604 | - } |
|
605 | - $results = $this->_get_all_wpdb_results( |
|
606 | - array( |
|
607 | - $where, |
|
608 | - 'group_by' => 'Event.EVT_name', |
|
609 | - 'order_by' => 'Event.EVT_name', |
|
610 | - 'limit' => array(0, 24), |
|
611 | - ), |
|
612 | - OBJECT, |
|
613 | - array( |
|
614 | - 'event_name' => array('Event_CPT.post_title', '%s'), |
|
615 | - 'total' => array('COUNT(REG_ID)', '%s'), |
|
616 | - ) |
|
617 | - ); |
|
618 | - return $results; |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - /** |
|
623 | - * Get the number of registrations per event grouped by registration status. |
|
624 | - * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
625 | - * |
|
626 | - * @param string $period |
|
627 | - * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
|
628 | - * @throws EE_Error |
|
629 | - * (i.e. RAP) |
|
630 | - */ |
|
631 | - public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
|
632 | - { |
|
633 | - global $wpdb; |
|
634 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
635 | - $event_table = $wpdb->posts; |
|
636 | - $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
637 | - // inner date query |
|
638 | - $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
|
639 | - $inner_where = ' WHERE'; |
|
640 | - // exclude events not authored by user if permissions in effect |
|
641 | - if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
642 | - $inner_date_query .= "LEFT JOIN {$event_table} ON ID = EVT_ID"; |
|
643 | - $inner_where .= ' post_author = ' . get_current_user_id() . ' AND'; |
|
644 | - } |
|
645 | - $inner_where .= " REG_date >= '{$sql_date}'"; |
|
646 | - $inner_date_query .= $inner_where; |
|
647 | - // build main query |
|
648 | - $select = 'SELECT Event.post_title as Registration_Event, '; |
|
649 | - $join = ''; |
|
650 | - $join_parts = array(); |
|
651 | - $select_parts = array(); |
|
652 | - // loop through registration stati to do parts for each status. |
|
653 | - foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
654 | - if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
655 | - continue; |
|
656 | - } |
|
657 | - $select_parts[] = "COUNT({$STS_code}.REG_ID) as {$STS_ID}"; |
|
658 | - $join_parts[] = "{$registration_table} AS {$STS_code} ON {$STS_code}.EVT_ID = dates.EVT_ID AND {$STS_code}.STS_ID = '{$STS_ID}' AND {$STS_code}.REG_date = dates.REG_date"; |
|
659 | - } |
|
660 | - // setup the selects |
|
661 | - $select .= implode(', ', $select_parts); |
|
662 | - $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
|
663 | - // setup remaining joins |
|
664 | - $join .= implode(' LEFT JOIN ', $join_parts); |
|
665 | - // now put it all together |
|
666 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
667 | - // and execute |
|
668 | - return $wpdb->get_results($query, ARRAY_A); |
|
669 | - } |
|
670 | - |
|
671 | - |
|
672 | - /** |
|
673 | - * Returns the EE_Registration of the primary attendee on the transaction id provided |
|
674 | - * |
|
675 | - * @param int $TXN_ID |
|
676 | - * @return EE_Base_Class|EE_Registration|null |
|
677 | - * @throws EE_Error |
|
678 | - */ |
|
679 | - public function get_primary_registration_for_transaction_ID($TXN_ID = 0) |
|
680 | - { |
|
681 | - if (!$TXN_ID) { |
|
682 | - return null; |
|
683 | - } |
|
684 | - return $this->get_one(array( |
|
685 | - array( |
|
686 | - 'TXN_ID' => $TXN_ID, |
|
687 | - 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT, |
|
688 | - ), |
|
689 | - )); |
|
690 | - } |
|
691 | - |
|
692 | - |
|
693 | - /** |
|
694 | - * get_event_registration_count |
|
695 | - * |
|
696 | - * @access public |
|
697 | - * @param int $EVT_ID |
|
698 | - * @param boolean $for_incomplete_payments |
|
699 | - * @return int |
|
700 | - * @throws EE_Error |
|
701 | - */ |
|
702 | - public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false) |
|
703 | - { |
|
704 | - // we only count approved registrations towards registration limits |
|
705 | - $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
706 | - if ($for_incomplete_payments) { |
|
707 | - $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
708 | - } |
|
709 | - return $this->count($query_params); |
|
710 | - } |
|
711 | - |
|
712 | - |
|
713 | - /** |
|
714 | - * Deletes all registrations with no transactions. Note that this needs to be very efficient |
|
715 | - * and so it uses wpdb directly. Also, we can't put a limit on this because MySQL doesn't allow a limit on a delete |
|
716 | - * when joining tables like this. |
|
717 | - * |
|
718 | - * @global WPDB $wpdb |
|
719 | - * @return int number deleted |
|
720 | - * @throws EE_Error |
|
721 | - */ |
|
722 | - public function delete_registrations_with_no_transaction() |
|
723 | - { |
|
724 | - /** @type WPDB $wpdb */ |
|
725 | - global $wpdb; |
|
726 | - return $wpdb->query( |
|
727 | - 'DELETE r FROM ' |
|
728 | - . $this->table() |
|
729 | - . ' r LEFT JOIN ' |
|
730 | - . EEM_Transaction::instance()->table() |
|
731 | - . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' |
|
732 | - ); |
|
733 | - } |
|
734 | - |
|
735 | - |
|
736 | - /** |
|
737 | - * Count registrations checked into (or out of) a datetime |
|
738 | - * |
|
739 | - * @param int $DTT_ID datetime ID |
|
740 | - * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
741 | - * @return int |
|
742 | - * @throws EE_Error |
|
743 | - */ |
|
744 | - public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) |
|
745 | - { |
|
746 | - global $wpdb; |
|
747 | - // subquery to get latest checkin |
|
748 | - $query = $wpdb->prepare( |
|
749 | - 'SELECT ' |
|
750 | - . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
751 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
752 | - . '( SELECT ' |
|
753 | - . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
754 | - . 'REG_ID AS REG_ID ' |
|
755 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' ' |
|
756 | - . 'WHERE DTT_ID=%d ' |
|
757 | - . 'GROUP BY REG_ID' |
|
758 | - . ') AS most_recent_checkin_per_reg ' |
|
759 | - . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
760 | - . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
761 | - . 'WHERE ' |
|
762 | - . 'checkins.CHK_in=%d', |
|
763 | - $DTT_ID, |
|
764 | - $checked_in |
|
765 | - ); |
|
766 | - return (int) $wpdb->get_var($query); |
|
767 | - } |
|
768 | - |
|
769 | - |
|
770 | - /** |
|
771 | - * Count registrations checked into (or out of) an event. |
|
772 | - * |
|
773 | - * @param int $EVT_ID event ID |
|
774 | - * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
775 | - * @return int |
|
776 | - * @throws EE_Error |
|
777 | - */ |
|
778 | - public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) |
|
779 | - { |
|
780 | - global $wpdb; |
|
781 | - // subquery to get latest checkin |
|
782 | - $query = $wpdb->prepare( |
|
783 | - 'SELECT ' |
|
784 | - . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
785 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
786 | - . '( SELECT ' |
|
787 | - . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
788 | - . 'REG_ID AS REG_ID ' |
|
789 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c ' |
|
790 | - . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d ' |
|
791 | - . 'ON c.DTT_ID=d.DTT_ID ' |
|
792 | - . 'WHERE d.EVT_ID=%d ' |
|
793 | - . 'GROUP BY REG_ID' |
|
794 | - . ') AS most_recent_checkin_per_reg ' |
|
795 | - . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
796 | - . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
797 | - . 'WHERE ' |
|
798 | - . 'checkins.CHK_in=%d', |
|
799 | - $EVT_ID, |
|
800 | - $checked_in |
|
801 | - ); |
|
802 | - return (int) $wpdb->get_var($query); |
|
803 | - } |
|
804 | - |
|
805 | - |
|
806 | - /** |
|
807 | - * The purpose of this method is to retrieve an array of |
|
808 | - * EE_Registration objects that represent the latest registration |
|
809 | - * for each ATT_ID given in the function argument. |
|
810 | - * |
|
811 | - * @param array $attendee_ids |
|
812 | - * @return EE_Base_Class[]|EE_Registration[] |
|
813 | - * @throws EE_Error |
|
814 | - */ |
|
815 | - public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) |
|
816 | - { |
|
817 | - // first do a native wp_query to get the latest REG_ID's matching these attendees. |
|
818 | - global $wpdb; |
|
819 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
820 | - $attendee_table = $wpdb->posts; |
|
821 | - $attendee_ids = is_array($attendee_ids) |
|
822 | - ? array_map('absint', $attendee_ids) |
|
823 | - : array((int) $attendee_ids); |
|
824 | - $ATT_IDs = implode(',', $attendee_ids); |
|
825 | - // first we do a query to get the registration ids |
|
826 | - // (because a group by before order by causes the order by to be ignored.) |
|
827 | - $registration_id_query = " |
|
17 | + /** |
|
18 | + * @var EEM_Registration $_instance |
|
19 | + */ |
|
20 | + protected static $_instance; |
|
21 | + |
|
22 | + /** |
|
23 | + * Keys are the status IDs for registrations (eg, RAP, RCN, etc), and the values |
|
24 | + * are status codes (eg, approved, cancelled, etc) |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + private static $_reg_status; |
|
29 | + |
|
30 | + /** |
|
31 | + * The value of REG_count for a primary registrant |
|
32 | + */ |
|
33 | + const PRIMARY_REGISTRANT_COUNT = 1; |
|
34 | + |
|
35 | + /** |
|
36 | + * Status ID (STS_ID on esp_status table) to indicate an INCOMPLETE registration. |
|
37 | + * Initial status for registrations when they are first created |
|
38 | + * Payments are NOT allowed. |
|
39 | + * Automatically toggled to whatever the default Event registration status is upon completion of the attendee |
|
40 | + * information reg step NO space reserved. Registration is NOT active |
|
41 | + */ |
|
42 | + const status_id_incomplete = 'RIC'; |
|
43 | + |
|
44 | + /** |
|
45 | + * Status ID (STS_ID on esp_status table) to indicate an UNAPPROVED registration. |
|
46 | + * Payments are NOT allowed. |
|
47 | + * Event Admin must manually toggle STS_ID for it to change |
|
48 | + * No space reserved. |
|
49 | + * Registration is active |
|
50 | + */ |
|
51 | + const status_id_not_approved = 'RNA'; |
|
52 | + |
|
53 | + /** |
|
54 | + * Status ID (STS_ID on esp_status table) to indicate registration is PENDING_PAYMENT . |
|
55 | + * Payments are allowed. |
|
56 | + * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
57 | + * No space reserved. |
|
58 | + * Registration is active |
|
59 | + */ |
|
60 | + const status_id_pending_payment = 'RPP'; |
|
61 | + |
|
62 | + /** |
|
63 | + * Status ID (STS_ID on esp_status table) to indicate registration is on the WAIT_LIST . |
|
64 | + * Payments are allowed. |
|
65 | + * STS_ID will automatically be toggled to RAP if payment is made in full by the attendee |
|
66 | + * No space reserved. |
|
67 | + * Registration is active |
|
68 | + */ |
|
69 | + const status_id_wait_list = 'RWL'; |
|
70 | + |
|
71 | + /** |
|
72 | + * Status ID (STS_ID on esp_status table) to indicate an APPROVED registration. |
|
73 | + * the TXN may or may not be completed ( paid in full ) |
|
74 | + * Payments are allowed. |
|
75 | + * A space IS reserved. |
|
76 | + * Registration is active |
|
77 | + */ |
|
78 | + const status_id_approved = 'RAP'; |
|
79 | + |
|
80 | + /** |
|
81 | + * Status ID (STS_ID on esp_status table) to indicate a registration was CANCELLED by the attendee. |
|
82 | + * Payments are NOT allowed. |
|
83 | + * NO space reserved. |
|
84 | + * Registration is NOT active |
|
85 | + */ |
|
86 | + const status_id_cancelled = 'RCN'; |
|
87 | + |
|
88 | + /** |
|
89 | + * Status ID (STS_ID on esp_status table) to indicate a registration was DECLINED by the Event Admin |
|
90 | + * Payments are NOT allowed. |
|
91 | + * No space reserved. |
|
92 | + * Registration is NOT active |
|
93 | + */ |
|
94 | + const status_id_declined = 'RDC'; |
|
95 | + |
|
96 | + /** |
|
97 | + * @var TableAnalysis $table_analysis |
|
98 | + */ |
|
99 | + protected $_table_analysis; |
|
100 | + |
|
101 | + |
|
102 | + /** |
|
103 | + * private constructor to prevent direct creation |
|
104 | + * |
|
105 | + * @Constructor |
|
106 | + * @access protected |
|
107 | + * @param string $timezone string representing the timezone we want to set for returned Date Time Strings (and any |
|
108 | + * incoming timezone data that gets saved). Note this just sends the timezone info to the |
|
109 | + * date time model field objects. Default is NULL (and will be assumed using the set |
|
110 | + * timezone in the 'timezone_string' wp option) |
|
111 | + * @throws EE_Error |
|
112 | + */ |
|
113 | + protected function __construct($timezone = null) |
|
114 | + { |
|
115 | + $this->_table_analysis = EE_Registry::instance()->create('TableAnalysis', array(), true); |
|
116 | + $this->singular_item = esc_html__('Registration', 'event_espresso'); |
|
117 | + $this->plural_item = esc_html__('Registrations', 'event_espresso'); |
|
118 | + $this->_tables = array( |
|
119 | + 'Registration' => new EE_Primary_Table('esp_registration', 'REG_ID'), |
|
120 | + ); |
|
121 | + $this->_fields = array( |
|
122 | + 'Registration' => array( |
|
123 | + 'REG_ID' => new EE_Primary_Key_Int_Field( |
|
124 | + 'REG_ID', |
|
125 | + esc_html__('Registration ID', 'event_espresso') |
|
126 | + ), |
|
127 | + 'EVT_ID' => new EE_Foreign_Key_Int_Field( |
|
128 | + 'EVT_ID', |
|
129 | + esc_html__('Event ID', 'event_espresso'), |
|
130 | + false, |
|
131 | + 0, |
|
132 | + 'Event' |
|
133 | + ), |
|
134 | + 'ATT_ID' => new EE_Foreign_Key_Int_Field( |
|
135 | + 'ATT_ID', |
|
136 | + esc_html__('Attendee ID', 'event_espresso'), |
|
137 | + false, |
|
138 | + 0, |
|
139 | + 'Attendee' |
|
140 | + ), |
|
141 | + 'TXN_ID' => new EE_Foreign_Key_Int_Field( |
|
142 | + 'TXN_ID', |
|
143 | + esc_html__('Transaction ID', 'event_espresso'), |
|
144 | + false, |
|
145 | + 0, |
|
146 | + 'Transaction' |
|
147 | + ), |
|
148 | + 'TKT_ID' => new EE_Foreign_Key_Int_Field( |
|
149 | + 'TKT_ID', |
|
150 | + esc_html__('Ticket ID', 'event_espresso'), |
|
151 | + false, |
|
152 | + 0, |
|
153 | + 'Ticket' |
|
154 | + ), |
|
155 | + 'STS_ID' => new EE_Foreign_Key_String_Field( |
|
156 | + 'STS_ID', |
|
157 | + esc_html__('Status ID', 'event_espresso'), |
|
158 | + false, |
|
159 | + EEM_Registration::status_id_incomplete, |
|
160 | + 'Status' |
|
161 | + ), |
|
162 | + 'REG_date' => new EE_Datetime_Field( |
|
163 | + 'REG_date', |
|
164 | + esc_html__('Time registration occurred', 'event_espresso'), |
|
165 | + false, |
|
166 | + EE_Datetime_Field::now, |
|
167 | + $timezone |
|
168 | + ), |
|
169 | + 'REG_final_price' => new EE_Money_Field( |
|
170 | + 'REG_final_price', |
|
171 | + esc_html__('Registration\'s share of the transaction total', 'event_espresso'), |
|
172 | + false, |
|
173 | + 0 |
|
174 | + ), |
|
175 | + 'REG_paid' => new EE_Money_Field( |
|
176 | + 'REG_paid', |
|
177 | + esc_html__('Amount paid to date towards registration', 'event_espresso'), |
|
178 | + false, |
|
179 | + 0 |
|
180 | + ), |
|
181 | + 'REG_session' => new EE_Plain_Text_Field( |
|
182 | + 'REG_session', |
|
183 | + esc_html__('Session ID of registration', 'event_espresso'), |
|
184 | + false, |
|
185 | + '' |
|
186 | + ), |
|
187 | + 'REG_code' => new EE_Plain_Text_Field( |
|
188 | + 'REG_code', |
|
189 | + esc_html__('Unique Code for this registration', 'event_espresso'), |
|
190 | + false, |
|
191 | + '' |
|
192 | + ), |
|
193 | + 'REG_url_link' => new EE_Plain_Text_Field( |
|
194 | + 'REG_url_link', |
|
195 | + esc_html__('String to be used in URL for identifying registration', 'event_espresso'), |
|
196 | + false, |
|
197 | + '' |
|
198 | + ), |
|
199 | + 'REG_count' => new EE_Integer_Field( |
|
200 | + 'REG_count', |
|
201 | + esc_html__('Count of this registration in the group registration ', 'event_espresso'), |
|
202 | + true, |
|
203 | + 1 |
|
204 | + ), |
|
205 | + 'REG_group_size' => new EE_Integer_Field( |
|
206 | + 'REG_group_size', |
|
207 | + esc_html__('Number of registrations on this group', 'event_espresso'), |
|
208 | + false, |
|
209 | + 1 |
|
210 | + ), |
|
211 | + 'REG_att_is_going' => new EE_Boolean_Field( |
|
212 | + 'REG_att_is_going', |
|
213 | + esc_html__('Flag indicating the registrant plans on attending', 'event_espresso'), |
|
214 | + false, |
|
215 | + false |
|
216 | + ), |
|
217 | + 'REG_deleted' => new EE_Trashed_Flag_Field( |
|
218 | + 'REG_deleted', |
|
219 | + esc_html__('Flag indicating if registration has been archived or not.', 'event_espresso'), |
|
220 | + false, |
|
221 | + false |
|
222 | + ), |
|
223 | + ), |
|
224 | + ); |
|
225 | + $this->_model_relations = array( |
|
226 | + 'Event' => new EE_Belongs_To_Relation(), |
|
227 | + 'Attendee' => new EE_Belongs_To_Relation(), |
|
228 | + 'Transaction' => new EE_Belongs_To_Relation(), |
|
229 | + 'Ticket' => new EE_Belongs_To_Relation(), |
|
230 | + 'Status' => new EE_Belongs_To_Relation(), |
|
231 | + 'Answer' => new EE_Has_Many_Relation(), |
|
232 | + 'Checkin' => new EE_Has_Many_Relation(), |
|
233 | + 'Registration_Payment' => new EE_Has_Many_Relation(), |
|
234 | + 'Payment' => new EE_HABTM_Relation('Registration_Payment'), |
|
235 | + 'Message' => new EE_Has_Many_Any_Relation(false) |
|
236 | + // allow deletes even if there are messages in the queue related |
|
237 | + ); |
|
238 | + $this->_model_chain_to_wp_user = 'Event'; |
|
239 | + parent::__construct($timezone); |
|
240 | + } |
|
241 | + |
|
242 | + |
|
243 | + /** |
|
244 | + * a list of ALL valid registration statuses currently in use within the system |
|
245 | + * generated by combining the filterable active and inactive reg status arrays |
|
246 | + * |
|
247 | + * @return array |
|
248 | + */ |
|
249 | + public static function reg_statuses() |
|
250 | + { |
|
251 | + return array_unique( |
|
252 | + array_merge( |
|
253 | + EEM_Registration::active_reg_statuses(), |
|
254 | + EEM_Registration::inactive_reg_statuses() |
|
255 | + ) |
|
256 | + ); |
|
257 | + } |
|
258 | + |
|
259 | + |
|
260 | + /** |
|
261 | + * reg_statuses_that_allow_payment |
|
262 | + * a filterable list of registration statuses that allow a registrant to make a payment |
|
263 | + * |
|
264 | + * @access public |
|
265 | + * @return array |
|
266 | + */ |
|
267 | + public static function reg_statuses_that_allow_payment() |
|
268 | + { |
|
269 | + return apply_filters( |
|
270 | + 'FHEE__EEM_Registration__reg_statuses_that_allow_payment', |
|
271 | + array( |
|
272 | + EEM_Registration::status_id_approved, |
|
273 | + EEM_Registration::status_id_pending_payment, |
|
274 | + ) |
|
275 | + ); |
|
276 | + } |
|
277 | + |
|
278 | + |
|
279 | + /** |
|
280 | + * active_reg_statuses |
|
281 | + * a filterable list of registration statuses that are considered active |
|
282 | + * |
|
283 | + * @access public |
|
284 | + * @return array |
|
285 | + */ |
|
286 | + public static function active_reg_statuses() |
|
287 | + { |
|
288 | + return apply_filters( |
|
289 | + 'FHEE__EEM_Registration__active_reg_statuses', |
|
290 | + array( |
|
291 | + EEM_Registration::status_id_approved, |
|
292 | + EEM_Registration::status_id_pending_payment, |
|
293 | + EEM_Registration::status_id_wait_list, |
|
294 | + EEM_Registration::status_id_not_approved, |
|
295 | + ) |
|
296 | + ); |
|
297 | + } |
|
298 | + |
|
299 | + |
|
300 | + /** |
|
301 | + * inactive_reg_statuses |
|
302 | + * a filterable list of registration statuses that are not considered active |
|
303 | + * |
|
304 | + * @access public |
|
305 | + * @return array |
|
306 | + */ |
|
307 | + public static function inactive_reg_statuses() |
|
308 | + { |
|
309 | + return apply_filters( |
|
310 | + 'FHEE__EEM_Registration__inactive_reg_statuses', |
|
311 | + array( |
|
312 | + EEM_Registration::status_id_incomplete, |
|
313 | + EEM_Registration::status_id_cancelled, |
|
314 | + EEM_Registration::status_id_declined, |
|
315 | + ) |
|
316 | + ); |
|
317 | + } |
|
318 | + |
|
319 | + |
|
320 | + /** |
|
321 | + * closed_reg_statuses |
|
322 | + * a filterable list of registration statuses that are considered "closed" |
|
323 | + * meaning they should not be considered in any calculations involving monies owing |
|
324 | + * |
|
325 | + * @access public |
|
326 | + * @return array |
|
327 | + */ |
|
328 | + public static function closed_reg_statuses() |
|
329 | + { |
|
330 | + return apply_filters( |
|
331 | + 'FHEE__EEM_Registration__closed_reg_statuses', |
|
332 | + array( |
|
333 | + EEM_Registration::status_id_cancelled, |
|
334 | + EEM_Registration::status_id_declined, |
|
335 | + EEM_Registration::status_id_wait_list, |
|
336 | + ) |
|
337 | + ); |
|
338 | + } |
|
339 | + |
|
340 | + |
|
341 | + /** |
|
342 | + * get list of registration statuses |
|
343 | + * |
|
344 | + * @access public |
|
345 | + * @param array $exclude The status ids to exclude from the returned results |
|
346 | + * @param bool $translated If true will return the values as singular localized strings |
|
347 | + * @return array |
|
348 | + * @throws EE_Error |
|
349 | + */ |
|
350 | + public static function reg_status_array($exclude = array(), $translated = false) |
|
351 | + { |
|
352 | + EEM_Registration::instance()->_get_registration_status_array($exclude); |
|
353 | + return $translated |
|
354 | + ? EEM_Status::instance()->localized_status(self::$_reg_status, false, 'sentence') |
|
355 | + : self::$_reg_status; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * get list of registration statuses |
|
361 | + * |
|
362 | + * @access private |
|
363 | + * @param array $exclude |
|
364 | + * @return void |
|
365 | + * @throws EE_Error |
|
366 | + */ |
|
367 | + private function _get_registration_status_array($exclude = array()) |
|
368 | + { |
|
369 | + // in the very rare circumstance that we are deleting a model's table's data |
|
370 | + // and the table hasn't actually been created, this could have an error |
|
371 | + /** @type WPDB $wpdb */ |
|
372 | + global $wpdb; |
|
373 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
374 | + $results = $wpdb->get_results( |
|
375 | + "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'" |
|
376 | + ); |
|
377 | + self::$_reg_status = array(); |
|
378 | + foreach ($results as $status) { |
|
379 | + if (!in_array($status->STS_ID, $exclude, true)) { |
|
380 | + self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
381 | + } |
|
382 | + } |
|
383 | + } |
|
384 | + } |
|
385 | + |
|
386 | + |
|
387 | + /** |
|
388 | + * Gets the injected table analyzer, or throws an exception |
|
389 | + * |
|
390 | + * @return TableAnalysis |
|
391 | + * @throws EE_Error |
|
392 | + */ |
|
393 | + protected function _get_table_analysis() |
|
394 | + { |
|
395 | + if ($this->_table_analysis instanceof TableAnalysis) { |
|
396 | + return $this->_table_analysis; |
|
397 | + } |
|
398 | + throw new EE_Error( |
|
399 | + sprintf( |
|
400 | + esc_html__('Table analysis class on class %1$s is not set properly.', 'event_espresso'), |
|
401 | + get_class($this) |
|
402 | + ) |
|
403 | + ); |
|
404 | + } |
|
405 | + |
|
406 | + |
|
407 | + /** |
|
408 | + * This returns a wpdb->results array of all registration date month and years matching the incoming query params |
|
409 | + * and grouped by month and year. |
|
410 | + * |
|
411 | + * @param array $where_params @see https://github.com/eventespresso/event-espresso-core/tree/master/docs/G--Model-System/model-query-params.md#0-where-conditions |
|
412 | + * @return array |
|
413 | + * @throws EE_Error |
|
414 | + */ |
|
415 | + public function get_reg_months_and_years($where_params) |
|
416 | + { |
|
417 | + $query_params[0] = $where_params; |
|
418 | + $query_params['group_by'] = array('reg_year', 'reg_month'); |
|
419 | + $query_params['order_by'] = array('REG_date' => 'DESC'); |
|
420 | + $columns_to_select = array( |
|
421 | + 'reg_year' => array('YEAR(REG_date)', '%s'), |
|
422 | + 'reg_month' => array('MONTHNAME(REG_date)', '%s'), |
|
423 | + ); |
|
424 | + return $this->_get_all_wpdb_results($query_params, OBJECT, $columns_to_select); |
|
425 | + } |
|
426 | + |
|
427 | + |
|
428 | + /** |
|
429 | + * retrieve ALL registrations for a particular Attendee from db |
|
430 | + * |
|
431 | + * @param int $ATT_ID |
|
432 | + * @return EE_Base_Class[]|EE_Registration[]|null |
|
433 | + * @throws EE_Error |
|
434 | + */ |
|
435 | + public function get_all_registrations_for_attendee($ATT_ID = 0) |
|
436 | + { |
|
437 | + if (!$ATT_ID) { |
|
438 | + return null; |
|
439 | + } |
|
440 | + return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
|
441 | + } |
|
442 | + |
|
443 | + |
|
444 | + /** |
|
445 | + * Gets a registration given their REG_url_link. Yes, this should usually |
|
446 | + * be passed via a GET parameter. |
|
447 | + * |
|
448 | + * @param string $REG_url_link |
|
449 | + * @return EE_Base_Class|EE_Registration|null |
|
450 | + * @throws EE_Error |
|
451 | + */ |
|
452 | + public function get_registration_for_reg_url_link($REG_url_link) |
|
453 | + { |
|
454 | + if (!$REG_url_link) { |
|
455 | + return null; |
|
456 | + } |
|
457 | + return $this->get_one(array(array('REG_url_link' => $REG_url_link))); |
|
458 | + } |
|
459 | + |
|
460 | + |
|
461 | + /** |
|
462 | + * retrieve registration for a specific transaction attendee from db |
|
463 | + * |
|
464 | + * @access public |
|
465 | + * @param int $TXN_ID |
|
466 | + * @param int $ATT_ID |
|
467 | + * @param int $att_nmbr in case the ATT_ID is the same for multiple registrations (same details used) then the |
|
468 | + * attendee number is required |
|
469 | + * @return mixed array on success, FALSE on fail |
|
470 | + * @throws EE_Error |
|
471 | + */ |
|
472 | + public function get_registration_for_transaction_attendee($TXN_ID = 0, $ATT_ID = 0, $att_nmbr = 0) |
|
473 | + { |
|
474 | + return $this->get_one(array( |
|
475 | + array( |
|
476 | + 'TXN_ID' => $TXN_ID, |
|
477 | + 'ATT_ID' => $ATT_ID, |
|
478 | + ), |
|
479 | + 'limit' => array(min($att_nmbr - 1, 0), 1), |
|
480 | + )); |
|
481 | + } |
|
482 | + |
|
483 | + |
|
484 | + /** |
|
485 | + * get the number of registrations per day for the Registration Admin page Reports Tab. |
|
486 | + * (doesn't utilize models because it's a fairly specialized query) |
|
487 | + * |
|
488 | + * @access public |
|
489 | + * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
490 | + * @return stdClass[] with properties regDate and total |
|
491 | + * @throws EE_Error |
|
492 | + */ |
|
493 | + public function get_registrations_per_day_report($period = '-1 month') |
|
494 | + { |
|
495 | + $sql_date = $this->convert_datetime_for_query( |
|
496 | + 'REG_date', |
|
497 | + date('Y-m-d H:i:s', strtotime($period)), |
|
498 | + 'Y-m-d H:i:s', |
|
499 | + 'UTC' |
|
500 | + ); |
|
501 | + $where = array( |
|
502 | + 'REG_date' => array('>=', $sql_date), |
|
503 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
504 | + ); |
|
505 | + if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
506 | + $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
507 | + } |
|
508 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
|
509 | + $results = $this->_get_all_wpdb_results( |
|
510 | + array( |
|
511 | + $where, |
|
512 | + 'group_by' => 'regDate', |
|
513 | + 'order_by' => array('REG_date' => 'ASC'), |
|
514 | + ), |
|
515 | + OBJECT, |
|
516 | + array( |
|
517 | + 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
518 | + 'total' => array('count(REG_ID)', '%d'), |
|
519 | + ) |
|
520 | + ); |
|
521 | + return $results; |
|
522 | + } |
|
523 | + |
|
524 | + |
|
525 | + /** |
|
526 | + * Get the number of registrations per day including the count of registrations for each Registration Status. |
|
527 | + * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
528 | + * |
|
529 | + * @param string $period |
|
530 | + * @return stdClass[] with properties Registration_REG_date and a column for each registration status as the STS_ID |
|
531 | + * @throws EE_Error |
|
532 | + * (i.e. RAP) |
|
533 | + */ |
|
534 | + public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
|
535 | + { |
|
536 | + global $wpdb; |
|
537 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
538 | + $event_table = $wpdb->posts; |
|
539 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
540 | + // prepare the query interval for displaying offset |
|
541 | + $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'dates.REG_date'); |
|
542 | + // inner date query |
|
543 | + $inner_date_query = "SELECT DISTINCT REG_date from {$registration_table} "; |
|
544 | + $inner_where = ' WHERE'; |
|
545 | + // exclude events not authored by user if permissions in effect |
|
546 | + if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
547 | + $inner_date_query .= "LEFT JOIN {$event_table} ON ID = EVT_ID"; |
|
548 | + $inner_where .= ' post_author = ' . get_current_user_id() . ' AND'; |
|
549 | + } |
|
550 | + $inner_where .= " REG_date >= '{$sql_date}'"; |
|
551 | + $inner_date_query .= $inner_where; |
|
552 | + // start main query |
|
553 | + $select = "SELECT DATE({$query_interval}) as Registration_REG_date, "; |
|
554 | + $join = ''; |
|
555 | + $join_parts = array(); |
|
556 | + $select_parts = array(); |
|
557 | + // loop through registration stati to do parts for each status. |
|
558 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
559 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
560 | + continue; |
|
561 | + } |
|
562 | + $select_parts[] = "COUNT({$STS_code}.REG_ID) as {$STS_ID}"; |
|
563 | + $join_parts[] = "{$registration_table} AS {$STS_code} ON {$STS_code}.REG_date = dates.REG_date AND {$STS_code}.STS_ID = '{$STS_ID}'"; |
|
564 | + } |
|
565 | + // setup the selects |
|
566 | + $select .= implode(', ', $select_parts); |
|
567 | + $select .= " FROM ($inner_date_query) AS dates LEFT JOIN "; |
|
568 | + // setup the joins |
|
569 | + $join .= implode(' LEFT JOIN ', $join_parts); |
|
570 | + // now let's put it all together |
|
571 | + $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
572 | + // and execute it |
|
573 | + return $wpdb->get_results($query, ARRAY_A); |
|
574 | + } |
|
575 | + |
|
576 | + |
|
577 | + /** |
|
578 | + * get the number of registrations per event for the Registration Admin page Reports Tab |
|
579 | + * |
|
580 | + * @access public |
|
581 | + * @param $period string which can be passed to php's strtotime function (eg "-1 month") |
|
582 | + * @return stdClass[] each with properties event_name, reg_limit, and total |
|
583 | + * @throws EE_Error |
|
584 | + */ |
|
585 | + public function get_registrations_per_event_report($period = '-1 month') |
|
586 | + { |
|
587 | + $date_sql = $this->convert_datetime_for_query( |
|
588 | + 'REG_date', |
|
589 | + date('Y-m-d H:i:s', strtotime($period)), |
|
590 | + 'Y-m-d H:i:s', |
|
591 | + 'UTC' |
|
592 | + ); |
|
593 | + $where = array( |
|
594 | + 'REG_date' => array('>=', $date_sql), |
|
595 | + 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
|
596 | + ); |
|
597 | + if ( |
|
598 | + !EE_Registry::instance()->CAP->current_user_can( |
|
599 | + 'ee_read_others_registrations', |
|
600 | + 'reg_per_event_report' |
|
601 | + ) |
|
602 | + ) { |
|
603 | + $where['Event.EVT_wp_user'] = get_current_user_id(); |
|
604 | + } |
|
605 | + $results = $this->_get_all_wpdb_results( |
|
606 | + array( |
|
607 | + $where, |
|
608 | + 'group_by' => 'Event.EVT_name', |
|
609 | + 'order_by' => 'Event.EVT_name', |
|
610 | + 'limit' => array(0, 24), |
|
611 | + ), |
|
612 | + OBJECT, |
|
613 | + array( |
|
614 | + 'event_name' => array('Event_CPT.post_title', '%s'), |
|
615 | + 'total' => array('COUNT(REG_ID)', '%s'), |
|
616 | + ) |
|
617 | + ); |
|
618 | + return $results; |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + /** |
|
623 | + * Get the number of registrations per event grouped by registration status. |
|
624 | + * Note: EEM_Registration::status_id_incomplete registrations are excluded from the results. |
|
625 | + * |
|
626 | + * @param string $period |
|
627 | + * @return stdClass[] with properties `Registration_Event` and a column for each registration status as the STS_ID |
|
628 | + * @throws EE_Error |
|
629 | + * (i.e. RAP) |
|
630 | + */ |
|
631 | + public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
|
632 | + { |
|
633 | + global $wpdb; |
|
634 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
635 | + $event_table = $wpdb->posts; |
|
636 | + $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
|
637 | + // inner date query |
|
638 | + $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
|
639 | + $inner_where = ' WHERE'; |
|
640 | + // exclude events not authored by user if permissions in effect |
|
641 | + if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
642 | + $inner_date_query .= "LEFT JOIN {$event_table} ON ID = EVT_ID"; |
|
643 | + $inner_where .= ' post_author = ' . get_current_user_id() . ' AND'; |
|
644 | + } |
|
645 | + $inner_where .= " REG_date >= '{$sql_date}'"; |
|
646 | + $inner_date_query .= $inner_where; |
|
647 | + // build main query |
|
648 | + $select = 'SELECT Event.post_title as Registration_Event, '; |
|
649 | + $join = ''; |
|
650 | + $join_parts = array(); |
|
651 | + $select_parts = array(); |
|
652 | + // loop through registration stati to do parts for each status. |
|
653 | + foreach (EEM_Registration::reg_status_array() as $STS_ID => $STS_code) { |
|
654 | + if ($STS_ID === EEM_Registration::status_id_incomplete) { |
|
655 | + continue; |
|
656 | + } |
|
657 | + $select_parts[] = "COUNT({$STS_code}.REG_ID) as {$STS_ID}"; |
|
658 | + $join_parts[] = "{$registration_table} AS {$STS_code} ON {$STS_code}.EVT_ID = dates.EVT_ID AND {$STS_code}.STS_ID = '{$STS_ID}' AND {$STS_code}.REG_date = dates.REG_date"; |
|
659 | + } |
|
660 | + // setup the selects |
|
661 | + $select .= implode(', ', $select_parts); |
|
662 | + $select .= " FROM ($inner_date_query) AS dates LEFT JOIN $event_table as Event ON Event.ID = dates.EVT_ID LEFT JOIN "; |
|
663 | + // setup remaining joins |
|
664 | + $join .= implode(' LEFT JOIN ', $join_parts); |
|
665 | + // now put it all together |
|
666 | + $query = $select . $join . ' GROUP BY Registration_Event'; |
|
667 | + // and execute |
|
668 | + return $wpdb->get_results($query, ARRAY_A); |
|
669 | + } |
|
670 | + |
|
671 | + |
|
672 | + /** |
|
673 | + * Returns the EE_Registration of the primary attendee on the transaction id provided |
|
674 | + * |
|
675 | + * @param int $TXN_ID |
|
676 | + * @return EE_Base_Class|EE_Registration|null |
|
677 | + * @throws EE_Error |
|
678 | + */ |
|
679 | + public function get_primary_registration_for_transaction_ID($TXN_ID = 0) |
|
680 | + { |
|
681 | + if (!$TXN_ID) { |
|
682 | + return null; |
|
683 | + } |
|
684 | + return $this->get_one(array( |
|
685 | + array( |
|
686 | + 'TXN_ID' => $TXN_ID, |
|
687 | + 'REG_count' => EEM_Registration::PRIMARY_REGISTRANT_COUNT, |
|
688 | + ), |
|
689 | + )); |
|
690 | + } |
|
691 | + |
|
692 | + |
|
693 | + /** |
|
694 | + * get_event_registration_count |
|
695 | + * |
|
696 | + * @access public |
|
697 | + * @param int $EVT_ID |
|
698 | + * @param boolean $for_incomplete_payments |
|
699 | + * @return int |
|
700 | + * @throws EE_Error |
|
701 | + */ |
|
702 | + public function get_event_registration_count($EVT_ID, $for_incomplete_payments = false) |
|
703 | + { |
|
704 | + // we only count approved registrations towards registration limits |
|
705 | + $query_params = array(array('EVT_ID' => $EVT_ID, 'STS_ID' => self::status_id_approved)); |
|
706 | + if ($for_incomplete_payments) { |
|
707 | + $query_params[0]['Transaction.STS_ID'] = array('!=', EEM_Transaction::complete_status_code); |
|
708 | + } |
|
709 | + return $this->count($query_params); |
|
710 | + } |
|
711 | + |
|
712 | + |
|
713 | + /** |
|
714 | + * Deletes all registrations with no transactions. Note that this needs to be very efficient |
|
715 | + * and so it uses wpdb directly. Also, we can't put a limit on this because MySQL doesn't allow a limit on a delete |
|
716 | + * when joining tables like this. |
|
717 | + * |
|
718 | + * @global WPDB $wpdb |
|
719 | + * @return int number deleted |
|
720 | + * @throws EE_Error |
|
721 | + */ |
|
722 | + public function delete_registrations_with_no_transaction() |
|
723 | + { |
|
724 | + /** @type WPDB $wpdb */ |
|
725 | + global $wpdb; |
|
726 | + return $wpdb->query( |
|
727 | + 'DELETE r FROM ' |
|
728 | + . $this->table() |
|
729 | + . ' r LEFT JOIN ' |
|
730 | + . EEM_Transaction::instance()->table() |
|
731 | + . ' t ON r.TXN_ID = t.TXN_ID WHERE t.TXN_ID IS NULL' |
|
732 | + ); |
|
733 | + } |
|
734 | + |
|
735 | + |
|
736 | + /** |
|
737 | + * Count registrations checked into (or out of) a datetime |
|
738 | + * |
|
739 | + * @param int $DTT_ID datetime ID |
|
740 | + * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
741 | + * @return int |
|
742 | + * @throws EE_Error |
|
743 | + */ |
|
744 | + public function count_registrations_checked_into_datetime($DTT_ID, $checked_in = true) |
|
745 | + { |
|
746 | + global $wpdb; |
|
747 | + // subquery to get latest checkin |
|
748 | + $query = $wpdb->prepare( |
|
749 | + 'SELECT ' |
|
750 | + . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
751 | + . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
752 | + . '( SELECT ' |
|
753 | + . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
754 | + . 'REG_ID AS REG_ID ' |
|
755 | + . 'FROM ' . EEM_Checkin::instance()->table() . ' ' |
|
756 | + . 'WHERE DTT_ID=%d ' |
|
757 | + . 'GROUP BY REG_ID' |
|
758 | + . ') AS most_recent_checkin_per_reg ' |
|
759 | + . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
760 | + . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
761 | + . 'WHERE ' |
|
762 | + . 'checkins.CHK_in=%d', |
|
763 | + $DTT_ID, |
|
764 | + $checked_in |
|
765 | + ); |
|
766 | + return (int) $wpdb->get_var($query); |
|
767 | + } |
|
768 | + |
|
769 | + |
|
770 | + /** |
|
771 | + * Count registrations checked into (or out of) an event. |
|
772 | + * |
|
773 | + * @param int $EVT_ID event ID |
|
774 | + * @param boolean $checked_in whether to count registrations checked IN or OUT |
|
775 | + * @return int |
|
776 | + * @throws EE_Error |
|
777 | + */ |
|
778 | + public function count_registrations_checked_into_event($EVT_ID, $checked_in = true) |
|
779 | + { |
|
780 | + global $wpdb; |
|
781 | + // subquery to get latest checkin |
|
782 | + $query = $wpdb->prepare( |
|
783 | + 'SELECT ' |
|
784 | + . 'COUNT( DISTINCT checkins.REG_ID ) ' |
|
785 | + . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
786 | + . '( SELECT ' |
|
787 | + . 'max( CHK_timestamp ) AS latest_checkin, ' |
|
788 | + . 'REG_ID AS REG_ID ' |
|
789 | + . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c ' |
|
790 | + . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d ' |
|
791 | + . 'ON c.DTT_ID=d.DTT_ID ' |
|
792 | + . 'WHERE d.EVT_ID=%d ' |
|
793 | + . 'GROUP BY REG_ID' |
|
794 | + . ') AS most_recent_checkin_per_reg ' |
|
795 | + . 'ON checkins.REG_ID=most_recent_checkin_per_reg.REG_ID ' |
|
796 | + . 'AND checkins.CHK_timestamp = most_recent_checkin_per_reg.latest_checkin ' |
|
797 | + . 'WHERE ' |
|
798 | + . 'checkins.CHK_in=%d', |
|
799 | + $EVT_ID, |
|
800 | + $checked_in |
|
801 | + ); |
|
802 | + return (int) $wpdb->get_var($query); |
|
803 | + } |
|
804 | + |
|
805 | + |
|
806 | + /** |
|
807 | + * The purpose of this method is to retrieve an array of |
|
808 | + * EE_Registration objects that represent the latest registration |
|
809 | + * for each ATT_ID given in the function argument. |
|
810 | + * |
|
811 | + * @param array $attendee_ids |
|
812 | + * @return EE_Base_Class[]|EE_Registration[] |
|
813 | + * @throws EE_Error |
|
814 | + */ |
|
815 | + public function get_latest_registration_for_each_of_given_contacts($attendee_ids = array()) |
|
816 | + { |
|
817 | + // first do a native wp_query to get the latest REG_ID's matching these attendees. |
|
818 | + global $wpdb; |
|
819 | + $registration_table = $wpdb->prefix . 'esp_registration'; |
|
820 | + $attendee_table = $wpdb->posts; |
|
821 | + $attendee_ids = is_array($attendee_ids) |
|
822 | + ? array_map('absint', $attendee_ids) |
|
823 | + : array((int) $attendee_ids); |
|
824 | + $ATT_IDs = implode(',', $attendee_ids); |
|
825 | + // first we do a query to get the registration ids |
|
826 | + // (because a group by before order by causes the order by to be ignored.) |
|
827 | + $registration_id_query = " |
|
828 | 828 | SELECT registrations.registration_ids as registration_id |
829 | 829 | FROM ( |
830 | 830 | SELECT |
@@ -838,61 +838,61 @@ discard block |
||
838 | 838 | ) AS registrations |
839 | 839 | GROUP BY registrations.attendee_ids |
840 | 840 | "; |
841 | - $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A); |
|
842 | - if (empty($registration_ids)) { |
|
843 | - return array(); |
|
844 | - } |
|
845 | - $ids_for_model_query = array(); |
|
846 | - // let's flatten the ids so they can be used in the model query. |
|
847 | - foreach ($registration_ids as $registration_id) { |
|
848 | - if (isset($registration_id['registration_id'])) { |
|
849 | - $ids_for_model_query[] = $registration_id['registration_id']; |
|
850 | - } |
|
851 | - } |
|
852 | - // construct query |
|
853 | - $_where = array( |
|
854 | - 'REG_ID' => array('IN', $ids_for_model_query), |
|
855 | - ); |
|
856 | - return $this->get_all(array($_where)); |
|
857 | - } |
|
858 | - |
|
859 | - |
|
860 | - |
|
861 | - /** |
|
862 | - * returns a count of registrations for the supplied event having the status as specified |
|
863 | - * |
|
864 | - * @param int $EVT_ID |
|
865 | - * @param array $statuses |
|
866 | - * @return int |
|
867 | - * @throws InvalidArgumentException |
|
868 | - * @throws InvalidStatusException |
|
869 | - * @throws EE_Error |
|
870 | - */ |
|
871 | - public function event_reg_count_for_statuses($EVT_ID, $statuses = array()) |
|
872 | - { |
|
873 | - $EVT_ID = absint($EVT_ID); |
|
874 | - if (! $EVT_ID) { |
|
875 | - throw new InvalidArgumentException( |
|
876 | - esc_html__('An invalid Event ID was supplied.', 'event_espresso') |
|
877 | - ); |
|
878 | - } |
|
879 | - $statuses = is_array($statuses) ? $statuses : array($statuses); |
|
880 | - $statuses = ! empty($statuses) ? $statuses : array(EEM_Registration::status_id_approved); |
|
881 | - $valid_reg_statuses = EEM_Registration::reg_statuses(); |
|
882 | - foreach ($statuses as $status) { |
|
883 | - if (! in_array($status, $valid_reg_statuses, true)) { |
|
884 | - throw new InvalidStatusException($status, esc_html__('Registration', 'event_espresso')); |
|
885 | - } |
|
886 | - } |
|
887 | - return $this->count( |
|
888 | - array( |
|
889 | - array( |
|
890 | - 'EVT_ID' => $EVT_ID, |
|
891 | - 'STS_ID' => array('IN', $statuses), |
|
892 | - ), |
|
893 | - ), |
|
894 | - 'REG_ID', |
|
895 | - true |
|
896 | - ); |
|
897 | - } |
|
841 | + $registration_ids = $wpdb->get_results($registration_id_query, ARRAY_A); |
|
842 | + if (empty($registration_ids)) { |
|
843 | + return array(); |
|
844 | + } |
|
845 | + $ids_for_model_query = array(); |
|
846 | + // let's flatten the ids so they can be used in the model query. |
|
847 | + foreach ($registration_ids as $registration_id) { |
|
848 | + if (isset($registration_id['registration_id'])) { |
|
849 | + $ids_for_model_query[] = $registration_id['registration_id']; |
|
850 | + } |
|
851 | + } |
|
852 | + // construct query |
|
853 | + $_where = array( |
|
854 | + 'REG_ID' => array('IN', $ids_for_model_query), |
|
855 | + ); |
|
856 | + return $this->get_all(array($_where)); |
|
857 | + } |
|
858 | + |
|
859 | + |
|
860 | + |
|
861 | + /** |
|
862 | + * returns a count of registrations for the supplied event having the status as specified |
|
863 | + * |
|
864 | + * @param int $EVT_ID |
|
865 | + * @param array $statuses |
|
866 | + * @return int |
|
867 | + * @throws InvalidArgumentException |
|
868 | + * @throws InvalidStatusException |
|
869 | + * @throws EE_Error |
|
870 | + */ |
|
871 | + public function event_reg_count_for_statuses($EVT_ID, $statuses = array()) |
|
872 | + { |
|
873 | + $EVT_ID = absint($EVT_ID); |
|
874 | + if (! $EVT_ID) { |
|
875 | + throw new InvalidArgumentException( |
|
876 | + esc_html__('An invalid Event ID was supplied.', 'event_espresso') |
|
877 | + ); |
|
878 | + } |
|
879 | + $statuses = is_array($statuses) ? $statuses : array($statuses); |
|
880 | + $statuses = ! empty($statuses) ? $statuses : array(EEM_Registration::status_id_approved); |
|
881 | + $valid_reg_statuses = EEM_Registration::reg_statuses(); |
|
882 | + foreach ($statuses as $status) { |
|
883 | + if (! in_array($status, $valid_reg_statuses, true)) { |
|
884 | + throw new InvalidStatusException($status, esc_html__('Registration', 'event_espresso')); |
|
885 | + } |
|
886 | + } |
|
887 | + return $this->count( |
|
888 | + array( |
|
889 | + array( |
|
890 | + 'EVT_ID' => $EVT_ID, |
|
891 | + 'STS_ID' => array('IN', $statuses), |
|
892 | + ), |
|
893 | + ), |
|
894 | + 'REG_ID', |
|
895 | + true |
|
896 | + ); |
|
897 | + } |
|
898 | 898 | } |
@@ -370,14 +370,14 @@ discard block |
||
370 | 370 | // and the table hasn't actually been created, this could have an error |
371 | 371 | /** @type WPDB $wpdb */ |
372 | 372 | global $wpdb; |
373 | - if ($this->_get_table_analysis()->tableExists($wpdb->prefix . 'esp_status')) { |
|
373 | + if ($this->_get_table_analysis()->tableExists($wpdb->prefix.'esp_status')) { |
|
374 | 374 | $results = $wpdb->get_results( |
375 | 375 | "SELECT STS_ID, STS_code FROM {$wpdb->prefix}esp_status WHERE STS_type = 'registration'" |
376 | 376 | ); |
377 | 377 | self::$_reg_status = array(); |
378 | 378 | foreach ($results as $status) { |
379 | - if (!in_array($status->STS_ID, $exclude, true)) { |
|
380 | - self::$_reg_status[ $status->STS_ID ] = $status->STS_code; |
|
379 | + if ( ! in_array($status->STS_ID, $exclude, true)) { |
|
380 | + self::$_reg_status[$status->STS_ID] = $status->STS_code; |
|
381 | 381 | } |
382 | 382 | } |
383 | 383 | } |
@@ -434,7 +434,7 @@ discard block |
||
434 | 434 | */ |
435 | 435 | public function get_all_registrations_for_attendee($ATT_ID = 0) |
436 | 436 | { |
437 | - if (!$ATT_ID) { |
|
437 | + if ( ! $ATT_ID) { |
|
438 | 438 | return null; |
439 | 439 | } |
440 | 440 | return $this->get_all(array(array('ATT_ID' => $ATT_ID))); |
@@ -451,7 +451,7 @@ discard block |
||
451 | 451 | */ |
452 | 452 | public function get_registration_for_reg_url_link($REG_url_link) |
453 | 453 | { |
454 | - if (!$REG_url_link) { |
|
454 | + if ( ! $REG_url_link) { |
|
455 | 455 | return null; |
456 | 456 | } |
457 | 457 | return $this->get_one(array(array('REG_url_link' => $REG_url_link))); |
@@ -502,7 +502,7 @@ discard block |
||
502 | 502 | 'REG_date' => array('>=', $sql_date), |
503 | 503 | 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
504 | 504 | ); |
505 | - if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
505 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_day_report')) { |
|
506 | 506 | $where['Event.EVT_wp_user'] = get_current_user_id(); |
507 | 507 | } |
508 | 508 | $query_interval = EEH_DTT_Helper::get_sql_query_interval_for_offset($this->get_timezone(), 'REG_date'); |
@@ -514,7 +514,7 @@ discard block |
||
514 | 514 | ), |
515 | 515 | OBJECT, |
516 | 516 | array( |
517 | - 'regDate' => array('DATE(' . $query_interval . ')', '%s'), |
|
517 | + 'regDate' => array('DATE('.$query_interval.')', '%s'), |
|
518 | 518 | 'total' => array('count(REG_ID)', '%d'), |
519 | 519 | ) |
520 | 520 | ); |
@@ -534,7 +534,7 @@ discard block |
||
534 | 534 | public function get_registrations_per_day_and_per_status_report($period = '-1 month') |
535 | 535 | { |
536 | 536 | global $wpdb; |
537 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
537 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
538 | 538 | $event_table = $wpdb->posts; |
539 | 539 | $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
540 | 540 | // prepare the query interval for displaying offset |
@@ -543,9 +543,9 @@ discard block |
||
543 | 543 | $inner_date_query = "SELECT DISTINCT REG_date from {$registration_table} "; |
544 | 544 | $inner_where = ' WHERE'; |
545 | 545 | // exclude events not authored by user if permissions in effect |
546 | - if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
546 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
547 | 547 | $inner_date_query .= "LEFT JOIN {$event_table} ON ID = EVT_ID"; |
548 | - $inner_where .= ' post_author = ' . get_current_user_id() . ' AND'; |
|
548 | + $inner_where .= ' post_author = '.get_current_user_id().' AND'; |
|
549 | 549 | } |
550 | 550 | $inner_where .= " REG_date >= '{$sql_date}'"; |
551 | 551 | $inner_date_query .= $inner_where; |
@@ -568,7 +568,7 @@ discard block |
||
568 | 568 | // setup the joins |
569 | 569 | $join .= implode(' LEFT JOIN ', $join_parts); |
570 | 570 | // now let's put it all together |
571 | - $query = $select . $join . ' GROUP BY Registration_REG_date'; |
|
571 | + $query = $select.$join.' GROUP BY Registration_REG_date'; |
|
572 | 572 | // and execute it |
573 | 573 | return $wpdb->get_results($query, ARRAY_A); |
574 | 574 | } |
@@ -595,7 +595,7 @@ discard block |
||
595 | 595 | 'STS_ID' => array('!=', EEM_Registration::status_id_incomplete), |
596 | 596 | ); |
597 | 597 | if ( |
598 | - !EE_Registry::instance()->CAP->current_user_can( |
|
598 | + ! EE_Registry::instance()->CAP->current_user_can( |
|
599 | 599 | 'ee_read_others_registrations', |
600 | 600 | 'reg_per_event_report' |
601 | 601 | ) |
@@ -631,16 +631,16 @@ discard block |
||
631 | 631 | public function get_registrations_per_event_and_per_status_report($period = '-1 month') |
632 | 632 | { |
633 | 633 | global $wpdb; |
634 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
634 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
635 | 635 | $event_table = $wpdb->posts; |
636 | 636 | $sql_date = date('Y-m-d H:i:s', strtotime($period)); |
637 | 637 | // inner date query |
638 | 638 | $inner_date_query = "SELECT DISTINCT EVT_ID, REG_date from $registration_table "; |
639 | 639 | $inner_where = ' WHERE'; |
640 | 640 | // exclude events not authored by user if permissions in effect |
641 | - if (!EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
641 | + if ( ! EE_Registry::instance()->CAP->current_user_can('ee_read_others_registrations', 'reg_per_event_report')) { |
|
642 | 642 | $inner_date_query .= "LEFT JOIN {$event_table} ON ID = EVT_ID"; |
643 | - $inner_where .= ' post_author = ' . get_current_user_id() . ' AND'; |
|
643 | + $inner_where .= ' post_author = '.get_current_user_id().' AND'; |
|
644 | 644 | } |
645 | 645 | $inner_where .= " REG_date >= '{$sql_date}'"; |
646 | 646 | $inner_date_query .= $inner_where; |
@@ -663,7 +663,7 @@ discard block |
||
663 | 663 | // setup remaining joins |
664 | 664 | $join .= implode(' LEFT JOIN ', $join_parts); |
665 | 665 | // now put it all together |
666 | - $query = $select . $join . ' GROUP BY Registration_Event'; |
|
666 | + $query = $select.$join.' GROUP BY Registration_Event'; |
|
667 | 667 | // and execute |
668 | 668 | return $wpdb->get_results($query, ARRAY_A); |
669 | 669 | } |
@@ -678,7 +678,7 @@ discard block |
||
678 | 678 | */ |
679 | 679 | public function get_primary_registration_for_transaction_ID($TXN_ID = 0) |
680 | 680 | { |
681 | - if (!$TXN_ID) { |
|
681 | + if ( ! $TXN_ID) { |
|
682 | 682 | return null; |
683 | 683 | } |
684 | 684 | return $this->get_one(array( |
@@ -748,11 +748,11 @@ discard block |
||
748 | 748 | $query = $wpdb->prepare( |
749 | 749 | 'SELECT ' |
750 | 750 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
751 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
751 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
752 | 752 | . '( SELECT ' |
753 | 753 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
754 | 754 | . 'REG_ID AS REG_ID ' |
755 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' ' |
|
755 | + . 'FROM '.EEM_Checkin::instance()->table().' ' |
|
756 | 756 | . 'WHERE DTT_ID=%d ' |
757 | 757 | . 'GROUP BY REG_ID' |
758 | 758 | . ') AS most_recent_checkin_per_reg ' |
@@ -782,12 +782,12 @@ discard block |
||
782 | 782 | $query = $wpdb->prepare( |
783 | 783 | 'SELECT ' |
784 | 784 | . 'COUNT( DISTINCT checkins.REG_ID ) ' |
785 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS checkins INNER JOIN' |
|
785 | + . 'FROM '.EEM_Checkin::instance()->table().' AS checkins INNER JOIN' |
|
786 | 786 | . '( SELECT ' |
787 | 787 | . 'max( CHK_timestamp ) AS latest_checkin, ' |
788 | 788 | . 'REG_ID AS REG_ID ' |
789 | - . 'FROM ' . EEM_Checkin::instance()->table() . ' AS c ' |
|
790 | - . 'INNER JOIN ' . EEM_Datetime::instance()->table() . ' AS d ' |
|
789 | + . 'FROM '.EEM_Checkin::instance()->table().' AS c ' |
|
790 | + . 'INNER JOIN '.EEM_Datetime::instance()->table().' AS d ' |
|
791 | 791 | . 'ON c.DTT_ID=d.DTT_ID ' |
792 | 792 | . 'WHERE d.EVT_ID=%d ' |
793 | 793 | . 'GROUP BY REG_ID' |
@@ -816,7 +816,7 @@ discard block |
||
816 | 816 | { |
817 | 817 | // first do a native wp_query to get the latest REG_ID's matching these attendees. |
818 | 818 | global $wpdb; |
819 | - $registration_table = $wpdb->prefix . 'esp_registration'; |
|
819 | + $registration_table = $wpdb->prefix.'esp_registration'; |
|
820 | 820 | $attendee_table = $wpdb->posts; |
821 | 821 | $attendee_ids = is_array($attendee_ids) |
822 | 822 | ? array_map('absint', $attendee_ids) |
@@ -871,7 +871,7 @@ discard block |
||
871 | 871 | public function event_reg_count_for_statuses($EVT_ID, $statuses = array()) |
872 | 872 | { |
873 | 873 | $EVT_ID = absint($EVT_ID); |
874 | - if (! $EVT_ID) { |
|
874 | + if ( ! $EVT_ID) { |
|
875 | 875 | throw new InvalidArgumentException( |
876 | 876 | esc_html__('An invalid Event ID was supplied.', 'event_espresso') |
877 | 877 | ); |
@@ -880,7 +880,7 @@ discard block |
||
880 | 880 | $statuses = ! empty($statuses) ? $statuses : array(EEM_Registration::status_id_approved); |
881 | 881 | $valid_reg_statuses = EEM_Registration::reg_statuses(); |
882 | 882 | foreach ($statuses as $status) { |
883 | - if (! in_array($status, $valid_reg_statuses, true)) { |
|
883 | + if ( ! in_array($status, $valid_reg_statuses, true)) { |
|
884 | 884 | throw new InvalidStatusException($status, esc_html__('Registration', 'event_espresso')); |
885 | 885 | } |
886 | 886 | } |
@@ -8,26 +8,26 @@ |
||
8 | 8 | |
9 | 9 | class InvalidStatusException extends InvalidArgumentException |
10 | 10 | { |
11 | - /** |
|
12 | - * InvalidStatusException constructor. |
|
13 | - * @param string $status the invalid status id that was supplied |
|
14 | - * @param string $domain the name of the domain, model, or class that the status belongs to |
|
15 | - * @param string $message custom message |
|
16 | - * @param int $code |
|
17 | - * @param Exception|null $previous |
|
18 | - */ |
|
19 | - public function __construct($status, $domain, $message = '', $code = 0, Exception $previous = null) |
|
20 | - { |
|
21 | - if (empty($message)) { |
|
22 | - $message = sprintf( |
|
23 | - __( |
|
24 | - '"%1$s" is not a valid %2$s status', |
|
25 | - 'event_espresso' |
|
26 | - ), |
|
27 | - $status, |
|
28 | - $domain |
|
29 | - ); |
|
30 | - } |
|
31 | - parent::__construct($message, $code, $previous); |
|
32 | - } |
|
11 | + /** |
|
12 | + * InvalidStatusException constructor. |
|
13 | + * @param string $status the invalid status id that was supplied |
|
14 | + * @param string $domain the name of the domain, model, or class that the status belongs to |
|
15 | + * @param string $message custom message |
|
16 | + * @param int $code |
|
17 | + * @param Exception|null $previous |
|
18 | + */ |
|
19 | + public function __construct($status, $domain, $message = '', $code = 0, Exception $previous = null) |
|
20 | + { |
|
21 | + if (empty($message)) { |
|
22 | + $message = sprintf( |
|
23 | + __( |
|
24 | + '"%1$s" is not a valid %2$s status', |
|
25 | + 'event_espresso' |
|
26 | + ), |
|
27 | + $status, |
|
28 | + $domain |
|
29 | + ); |
|
30 | + } |
|
31 | + parent::__construct($message, $code, $previous); |
|
32 | + } |
|
33 | 33 | } |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | { |
121 | 121 | wp_register_style( |
122 | 122 | 'espresso-admin-toolbar', |
123 | - EE_GLOBAL_ASSETS_URL . 'css/espresso-admin-toolbar.css', |
|
123 | + EE_GLOBAL_ASSETS_URL.'css/espresso-admin-toolbar.css', |
|
124 | 124 | array('dashicons'), |
125 | 125 | EVENT_ESPRESSO_VERSION |
126 | 126 | ); |
@@ -143,7 +143,7 @@ discard block |
||
143 | 143 | 'href' => $this->events_admin_url, |
144 | 144 | 'meta' => array( |
145 | 145 | 'title' => esc_html__('Event Espresso', 'event_espresso'), |
146 | - 'class' => $this->menu_class . 'first', |
|
146 | + 'class' => $this->menu_class.'first', |
|
147 | 147 | ), |
148 | 148 | ) |
149 | 149 | ); |
@@ -491,7 +491,7 @@ discard block |
||
491 | 491 | 'meta' => array( |
492 | 492 | 'title' => esc_html__('Approved', 'event_espresso'), |
493 | 493 | 'target' => '', |
494 | - 'class' => $this->menu_class . ' ee-toolbar-icon-approved', |
|
494 | + 'class' => $this->menu_class.' ee-toolbar-icon-approved', |
|
495 | 495 | ), |
496 | 496 | ) |
497 | 497 | ); |
@@ -528,7 +528,7 @@ discard block |
||
528 | 528 | 'meta' => array( |
529 | 529 | 'title' => esc_html__('Pending Payment', 'event_espresso'), |
530 | 530 | 'target' => '', |
531 | - 'class' => $this->menu_class . ' ee-toolbar-icon-pending', |
|
531 | + 'class' => $this->menu_class.' ee-toolbar-icon-pending', |
|
532 | 532 | ), |
533 | 533 | ) |
534 | 534 | ); |
@@ -565,7 +565,7 @@ discard block |
||
565 | 565 | 'meta' => array( |
566 | 566 | 'title' => esc_html__('Not Approved', 'event_espresso'), |
567 | 567 | 'target' => '', |
568 | - 'class' => $this->menu_class . ' ee-toolbar-icon-not-approved', |
|
568 | + 'class' => $this->menu_class.' ee-toolbar-icon-not-approved', |
|
569 | 569 | ), |
570 | 570 | ) |
571 | 571 | ); |
@@ -602,7 +602,7 @@ discard block |
||
602 | 602 | 'meta' => array( |
603 | 603 | 'title' => esc_html__('Cancelled', 'event_espresso'), |
604 | 604 | 'target' => '', |
605 | - 'class' => $this->menu_class . ' ee-toolbar-icon-cancelled', |
|
605 | + 'class' => $this->menu_class.' ee-toolbar-icon-cancelled', |
|
606 | 606 | ), |
607 | 607 | ) |
608 | 608 | ); |
@@ -674,7 +674,7 @@ discard block |
||
674 | 674 | 'meta' => array( |
675 | 675 | 'title' => esc_html__('Approved', 'event_espresso'), |
676 | 676 | 'target' => '', |
677 | - 'class' => $this->menu_class . ' ee-toolbar-icon-approved', |
|
677 | + 'class' => $this->menu_class.' ee-toolbar-icon-approved', |
|
678 | 678 | ), |
679 | 679 | ) |
680 | 680 | ); |
@@ -711,7 +711,7 @@ discard block |
||
711 | 711 | 'meta' => array( |
712 | 712 | 'title' => esc_html__('Pending', 'event_espresso'), |
713 | 713 | 'target' => '', |
714 | - 'class' => $this->menu_class . ' ee-toolbar-icon-pending', |
|
714 | + 'class' => $this->menu_class.' ee-toolbar-icon-pending', |
|
715 | 715 | ), |
716 | 716 | ) |
717 | 717 | ); |
@@ -748,7 +748,7 @@ discard block |
||
748 | 748 | 'meta' => array( |
749 | 749 | 'title' => esc_html__('Not Approved', 'event_espresso'), |
750 | 750 | 'target' => '', |
751 | - 'class' => $this->menu_class . ' ee-toolbar-icon-not-approved', |
|
751 | + 'class' => $this->menu_class.' ee-toolbar-icon-not-approved', |
|
752 | 752 | ), |
753 | 753 | ) |
754 | 754 | ); |
@@ -785,7 +785,7 @@ discard block |
||
785 | 785 | 'meta' => array( |
786 | 786 | 'title' => esc_html__('Cancelled', 'event_espresso'), |
787 | 787 | 'target' => '', |
788 | - 'class' => $this->menu_class . ' ee-toolbar-icon-cancelled', |
|
788 | + 'class' => $this->menu_class.' ee-toolbar-icon-cancelled', |
|
789 | 789 | ), |
790 | 790 | ) |
791 | 791 | ); |
@@ -19,780 +19,780 @@ |
||
19 | 19 | class AdminToolBar |
20 | 20 | { |
21 | 21 | |
22 | - /** |
|
23 | - * @var WP_Admin_Bar $admin_bar |
|
24 | - */ |
|
25 | - private $admin_bar; |
|
26 | - |
|
27 | - /** |
|
28 | - * @var EE_Capabilities $capabilities |
|
29 | - */ |
|
30 | - private $capabilities; |
|
31 | - |
|
32 | - /** |
|
33 | - * @var string $events_admin_url |
|
34 | - */ |
|
35 | - private $events_admin_url; |
|
36 | - |
|
37 | - /** |
|
38 | - * @var string $menu_class |
|
39 | - */ |
|
40 | - private $menu_class = 'espresso_menu_item_class'; |
|
41 | - |
|
42 | - /** |
|
43 | - * @var string $reg_admin_url |
|
44 | - */ |
|
45 | - private $reg_admin_url; |
|
46 | - |
|
47 | - |
|
48 | - /** |
|
49 | - * AdminToolBar constructor. |
|
50 | - * |
|
51 | - * @param EE_Capabilities $capabilities |
|
52 | - */ |
|
53 | - public function __construct(EE_Capabilities $capabilities) |
|
54 | - { |
|
55 | - $this->capabilities = $capabilities; |
|
56 | - add_action('admin_bar_menu', array($this, 'espressoToolbarItems'), 100); |
|
57 | - $this->enqueueAssets(); |
|
58 | - } |
|
59 | - |
|
60 | - |
|
61 | - /** |
|
62 | - * espresso_toolbar_items |
|
63 | - * |
|
64 | - * @access public |
|
65 | - * @param WP_Admin_Bar $admin_bar |
|
66 | - * @return void |
|
67 | - */ |
|
68 | - public function espressoToolbarItems(WP_Admin_Bar $admin_bar) |
|
69 | - { |
|
70 | - // if its an AJAX request, or user is NOT an admin, or in full M-Mode |
|
71 | - if ( |
|
72 | - defined('DOING_AJAX') |
|
73 | - || ! $this->capabilities->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
74 | - || EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance |
|
75 | - ) { |
|
76 | - return; |
|
77 | - } |
|
78 | - do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
79 | - $this->admin_bar = $admin_bar; |
|
80 | - // we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
81 | - // because they're only defined in each of their respective constructors |
|
82 | - // and this might be a frontend request, in which case they aren't available |
|
83 | - $this->events_admin_url = admin_url('admin.php?page=espresso_events'); |
|
84 | - $this->reg_admin_url = admin_url('admin.php?page=espresso_registrations'); |
|
85 | - // now let's add all of the menu items |
|
86 | - $this->addTopLevelMenu(); |
|
87 | - $this->addEventsSubMenu(); |
|
88 | - $this->addEventsAddEditHeader(); |
|
89 | - $this->addEventsAddNew(); |
|
90 | - $this->addEventsEditCurrentEvent(); |
|
91 | - $this->addEventsViewHeader(); |
|
92 | - $this->addEventsViewAll(); |
|
93 | - $this->addEventsViewToday(); |
|
94 | - $this->addEventsViewThisMonth(); |
|
95 | - $this->addRegistrationSubMenu(); |
|
96 | - $this->addRegistrationOverviewToday(); |
|
97 | - $this->addRegistrationOverviewTodayApproved(); |
|
98 | - $this->addRegistrationOverviewTodayPendingPayment(); |
|
99 | - $this->addRegistrationOverviewTodayNotApproved(); |
|
100 | - $this->addRegistrationOverviewTodayCancelled(); |
|
101 | - $this->addRegistrationOverviewThisMonth(); |
|
102 | - $this->addRegistrationOverviewThisMonthApproved(); |
|
103 | - $this->addRegistrationOverviewThisMonthPending(); |
|
104 | - $this->addRegistrationOverviewThisMonthNotApproved(); |
|
105 | - $this->addRegistrationOverviewThisMonthCancelled(); |
|
106 | - $this->addExtensionsAndServices(); |
|
107 | - } |
|
108 | - |
|
109 | - |
|
110 | - /** |
|
111 | - * @return void |
|
112 | - */ |
|
113 | - private function enqueueAssets() |
|
114 | - { |
|
115 | - wp_register_style( |
|
116 | - 'espresso-admin-toolbar', |
|
117 | - EE_GLOBAL_ASSETS_URL . 'css/espresso-admin-toolbar.css', |
|
118 | - array('dashicons'), |
|
119 | - EVENT_ESPRESSO_VERSION |
|
120 | - ); |
|
121 | - wp_enqueue_style('espresso-admin-toolbar'); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @return void |
|
127 | - */ |
|
128 | - private function addTopLevelMenu() |
|
129 | - { |
|
130 | - $this->admin_bar->add_menu( |
|
131 | - array( |
|
132 | - 'id' => 'espresso-toolbar', |
|
133 | - 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
134 | - . esc_html_x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
135 | - . '</span>', |
|
136 | - 'href' => $this->events_admin_url, |
|
137 | - 'meta' => array( |
|
138 | - 'title' => esc_html__('Event Espresso', 'event_espresso'), |
|
139 | - 'class' => $this->menu_class . 'first', |
|
140 | - ), |
|
141 | - ) |
|
142 | - ); |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - * @return void |
|
148 | - */ |
|
149 | - private function addEventsSubMenu() |
|
150 | - { |
|
151 | - if ( |
|
152 | - $this->capabilities->current_user_can( |
|
153 | - 'ee_read_events', |
|
154 | - 'ee_admin_bar_menu_espresso-toolbar-events' |
|
155 | - ) |
|
156 | - ) { |
|
157 | - $this->admin_bar->add_menu( |
|
158 | - array( |
|
159 | - 'id' => 'espresso-toolbar-events', |
|
160 | - 'parent' => 'espresso-toolbar', |
|
161 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
162 | - . esc_html__('Events', 'event_espresso'), |
|
163 | - 'href' => $this->events_admin_url, |
|
164 | - 'meta' => array( |
|
165 | - 'title' => esc_html__('Events', 'event_espresso'), |
|
166 | - 'target' => '', |
|
167 | - 'class' => $this->menu_class, |
|
168 | - ), |
|
169 | - ) |
|
170 | - ); |
|
171 | - } |
|
172 | - } |
|
173 | - |
|
174 | - |
|
175 | - /** |
|
176 | - * @return void |
|
177 | - */ |
|
178 | - private function addEventsAddEditHeader() |
|
179 | - { |
|
180 | - if ( |
|
181 | - $this->capabilities->current_user_can( |
|
182 | - 'ee_read_events', |
|
183 | - 'ee_admin_bar_menu_espresso-toolbar-events-view' |
|
184 | - ) |
|
185 | - ) { |
|
186 | - $this->admin_bar->add_menu( |
|
187 | - array( |
|
188 | - 'id' => 'espresso-toolbar-events-add-edit', |
|
189 | - 'parent' => 'espresso-toolbar-events', |
|
190 | - 'title' => esc_html__('Add / Edit', 'event_espresso'), |
|
191 | - 'href' => '', |
|
192 | - ) |
|
193 | - ); |
|
194 | - } |
|
195 | - } |
|
196 | - |
|
197 | - |
|
198 | - /** |
|
199 | - * @return void |
|
200 | - */ |
|
201 | - private function addEventsAddNew() |
|
202 | - { |
|
203 | - if ( |
|
204 | - $this->capabilities->current_user_can( |
|
205 | - 'ee_edit_events', |
|
206 | - 'ee_admin_bar_menu_espresso-toolbar-events-new' |
|
207 | - ) |
|
208 | - ) { |
|
209 | - $this->admin_bar->add_menu( |
|
210 | - array( |
|
211 | - 'id' => 'espresso-toolbar-events-new', |
|
212 | - 'parent' => 'espresso-toolbar-events', |
|
213 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
214 | - . esc_html__('Add New', 'event_espresso'), |
|
215 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
216 | - array('action' => 'create_new'), |
|
217 | - $this->events_admin_url |
|
218 | - ), |
|
219 | - 'meta' => array( |
|
220 | - 'title' => esc_html__('Add New', 'event_espresso'), |
|
221 | - 'target' => '', |
|
222 | - 'class' => $this->menu_class, |
|
223 | - ), |
|
224 | - ) |
|
225 | - ); |
|
226 | - } |
|
227 | - } |
|
228 | - |
|
229 | - |
|
230 | - /** |
|
231 | - * @return void |
|
232 | - */ |
|
233 | - private function addEventsEditCurrentEvent() |
|
234 | - { |
|
235 | - if (is_single() && (get_post_type() === 'espresso_events')) { |
|
236 | - // Current post |
|
237 | - global $post; |
|
238 | - if ( |
|
239 | - $this->capabilities->current_user_can( |
|
240 | - 'ee_edit_event', |
|
241 | - 'ee_admin_bar_menu_espresso-toolbar-events-edit', |
|
242 | - $post->ID |
|
243 | - ) |
|
244 | - ) { |
|
245 | - $this->admin_bar->add_menu( |
|
246 | - array( |
|
247 | - 'id' => 'espresso-toolbar-events-edit', |
|
248 | - 'parent' => 'espresso-toolbar-events', |
|
249 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
250 | - . esc_html__('Edit Event', 'event_espresso'), |
|
251 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
252 | - array( |
|
253 | - 'action' => 'edit', |
|
254 | - 'post' => $post->ID, |
|
255 | - ), |
|
256 | - $this->events_admin_url |
|
257 | - ), |
|
258 | - 'meta' => array( |
|
259 | - 'title' => esc_html__('Edit Event', 'event_espresso'), |
|
260 | - 'target' => '', |
|
261 | - 'class' => $this->menu_class, |
|
262 | - ), |
|
263 | - ) |
|
264 | - ); |
|
265 | - } |
|
266 | - } |
|
267 | - } |
|
268 | - |
|
269 | - |
|
270 | - /** |
|
271 | - * @return void |
|
272 | - */ |
|
273 | - private function addEventsViewHeader() |
|
274 | - { |
|
275 | - if ( |
|
276 | - $this->capabilities->current_user_can( |
|
277 | - 'ee_read_events', |
|
278 | - 'ee_admin_bar_menu_espresso-toolbar-events-view' |
|
279 | - ) |
|
280 | - ) { |
|
281 | - $this->admin_bar->add_menu( |
|
282 | - array( |
|
283 | - 'id' => 'espresso-toolbar-events-view', |
|
284 | - 'parent' => 'espresso-toolbar-events', |
|
285 | - 'title' => esc_html__('View', 'event_espresso'), |
|
286 | - 'href' => '', |
|
287 | - ) |
|
288 | - ); |
|
289 | - } |
|
290 | - } |
|
291 | - |
|
292 | - |
|
293 | - /** |
|
294 | - * @return void |
|
295 | - */ |
|
296 | - private function addEventsViewAll() |
|
297 | - { |
|
298 | - if ( |
|
299 | - $this->capabilities->current_user_can( |
|
300 | - 'ee_read_events', |
|
301 | - 'ee_admin_bar_menu_espresso-toolbar-events-all' |
|
302 | - ) |
|
303 | - ) { |
|
304 | - $this->admin_bar->add_menu( |
|
305 | - array( |
|
306 | - 'id' => 'espresso-toolbar-events-all', |
|
307 | - 'parent' => 'espresso-toolbar-events', |
|
308 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
309 | - . esc_html__('All', 'event_espresso'), |
|
310 | - 'href' => $this->events_admin_url, |
|
311 | - 'meta' => array( |
|
312 | - 'title' => esc_html__('All', 'event_espresso'), |
|
313 | - 'target' => '', |
|
314 | - 'class' => $this->menu_class, |
|
315 | - ), |
|
316 | - ) |
|
317 | - ); |
|
318 | - } |
|
319 | - } |
|
320 | - |
|
321 | - |
|
322 | - /** |
|
323 | - * @return void |
|
324 | - */ |
|
325 | - private function addEventsViewToday() |
|
326 | - { |
|
327 | - if ( |
|
328 | - $this->capabilities->current_user_can( |
|
329 | - 'ee_read_events', |
|
330 | - 'ee_admin_bar_menu_espresso-toolbar-events-today' |
|
331 | - ) |
|
332 | - ) { |
|
333 | - $this->admin_bar->add_menu( |
|
334 | - array( |
|
335 | - 'id' => 'espresso-toolbar-events-today', |
|
336 | - 'parent' => 'espresso-toolbar-events', |
|
337 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
338 | - . esc_html__('Today', 'event_espresso'), |
|
339 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
340 | - array( |
|
341 | - 'action' => 'default', |
|
342 | - 'status' => 'today', |
|
343 | - ), |
|
344 | - $this->events_admin_url |
|
345 | - ), |
|
346 | - 'meta' => array( |
|
347 | - 'title' => esc_html__('Today', 'event_espresso'), |
|
348 | - 'target' => '', |
|
349 | - 'class' => $this->menu_class, |
|
350 | - ), |
|
351 | - ) |
|
352 | - ); |
|
353 | - } |
|
354 | - } |
|
355 | - |
|
356 | - |
|
357 | - /** |
|
358 | - * @return void |
|
359 | - */ |
|
360 | - private function addEventsViewThisMonth() |
|
361 | - { |
|
362 | - if ( |
|
363 | - $this->capabilities->current_user_can( |
|
364 | - 'ee_read_events', |
|
365 | - 'ee_admin_bar_menu_espresso-toolbar-events-month' |
|
366 | - ) |
|
367 | - ) { |
|
368 | - $this->admin_bar->add_menu( |
|
369 | - array( |
|
370 | - 'id' => 'espresso-toolbar-events-month', |
|
371 | - 'parent' => 'espresso-toolbar-events', |
|
372 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
373 | - . esc_html__('This Month', 'event_espresso'), |
|
374 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
375 | - array( |
|
376 | - 'action' => 'default', |
|
377 | - 'status' => 'month', |
|
378 | - ), |
|
379 | - $this->events_admin_url |
|
380 | - ), |
|
381 | - 'meta' => array( |
|
382 | - 'title' => esc_html__('This Month', 'event_espresso'), |
|
383 | - 'target' => '', |
|
384 | - 'class' => $this->menu_class, |
|
385 | - ), |
|
386 | - ) |
|
387 | - ); |
|
388 | - } |
|
389 | - } |
|
390 | - |
|
391 | - |
|
392 | - /** |
|
393 | - * @return void |
|
394 | - */ |
|
395 | - private function addRegistrationSubMenu() |
|
396 | - { |
|
397 | - if ( |
|
398 | - $this->capabilities->current_user_can( |
|
399 | - 'ee_read_registrations', |
|
400 | - 'ee_admin_bar_menu_espresso-toolbar-registrations' |
|
401 | - ) |
|
402 | - ) { |
|
403 | - $this->admin_bar->add_menu( |
|
404 | - array( |
|
405 | - 'id' => 'espresso-toolbar-registrations', |
|
406 | - 'parent' => 'espresso-toolbar', |
|
407 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
408 | - . esc_html__('Registrations', 'event_espresso'), |
|
409 | - 'href' => $this->reg_admin_url, |
|
410 | - 'meta' => array( |
|
411 | - 'title' => esc_html__('Registrations', 'event_espresso'), |
|
412 | - 'target' => '', |
|
413 | - 'class' => $this->menu_class, |
|
414 | - ), |
|
415 | - ) |
|
416 | - ); |
|
417 | - } |
|
418 | - } |
|
419 | - |
|
420 | - |
|
421 | - /** |
|
422 | - * @return void |
|
423 | - */ |
|
424 | - private function addRegistrationOverviewToday() |
|
425 | - { |
|
426 | - if ( |
|
427 | - $this->capabilities->current_user_can( |
|
428 | - 'ee_read_registrations', |
|
429 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today' |
|
430 | - ) |
|
431 | - ) { |
|
432 | - $this->admin_bar->add_menu( |
|
433 | - array( |
|
434 | - 'id' => 'espresso-toolbar-registrations-today', |
|
435 | - 'parent' => 'espresso-toolbar-registrations', |
|
436 | - 'title' => esc_html__('Today', 'event_espresso'), |
|
437 | - 'href' => '', |
|
438 | - 'meta' => array( |
|
439 | - 'title' => esc_html__('Today', 'event_espresso'), |
|
440 | - 'target' => '', |
|
441 | - 'class' => $this->menu_class, |
|
442 | - ), |
|
443 | - ) |
|
444 | - ); |
|
445 | - } |
|
446 | - } |
|
447 | - |
|
448 | - |
|
449 | - /** |
|
450 | - * @return void |
|
451 | - */ |
|
452 | - private function addRegistrationOverviewTodayApproved() |
|
453 | - { |
|
454 | - if ( |
|
455 | - $this->capabilities->current_user_can( |
|
456 | - 'ee_read_registrations', |
|
457 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' |
|
458 | - ) |
|
459 | - ) { |
|
460 | - $this->admin_bar->add_menu( |
|
461 | - array( |
|
462 | - 'id' => 'espresso-toolbar-registrations-today-approved', |
|
463 | - 'parent' => 'espresso-toolbar-registrations', |
|
464 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
465 | - . esc_html__('Approved', 'event_espresso'), |
|
466 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
467 | - array( |
|
468 | - 'action' => 'default', |
|
469 | - 'status' => 'today', |
|
470 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
471 | - ), |
|
472 | - $this->reg_admin_url |
|
473 | - ), |
|
474 | - 'meta' => array( |
|
475 | - 'title' => esc_html__('Approved', 'event_espresso'), |
|
476 | - 'target' => '', |
|
477 | - 'class' => $this->menu_class . ' ee-toolbar-icon-approved', |
|
478 | - ), |
|
479 | - ) |
|
480 | - ); |
|
481 | - } |
|
482 | - } |
|
483 | - |
|
484 | - |
|
485 | - /** |
|
486 | - * @return void |
|
487 | - */ |
|
488 | - private function addRegistrationOverviewTodayPendingPayment() |
|
489 | - { |
|
490 | - if ( |
|
491 | - $this->capabilities->current_user_can( |
|
492 | - 'ee_read_registrations', |
|
493 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' |
|
494 | - ) |
|
495 | - ) { |
|
496 | - $this->admin_bar->add_menu( |
|
497 | - array( |
|
498 | - 'id' => 'espresso-toolbar-registrations-today-pending', |
|
499 | - 'parent' => 'espresso-toolbar-registrations', |
|
500 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
501 | - . esc_html__('Pending', 'event_espresso'), |
|
502 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
503 | - array( |
|
504 | - 'action' => 'default', |
|
505 | - 'status' => 'today', |
|
506 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
507 | - ), |
|
508 | - $this->reg_admin_url |
|
509 | - ), |
|
510 | - 'meta' => array( |
|
511 | - 'title' => esc_html__('Pending Payment', 'event_espresso'), |
|
512 | - 'target' => '', |
|
513 | - 'class' => $this->menu_class . ' ee-toolbar-icon-pending', |
|
514 | - ), |
|
515 | - ) |
|
516 | - ); |
|
517 | - } |
|
518 | - } |
|
519 | - |
|
520 | - |
|
521 | - /** |
|
522 | - * @return void |
|
523 | - */ |
|
524 | - private function addRegistrationOverviewTodayNotApproved() |
|
525 | - { |
|
526 | - if ( |
|
527 | - $this->capabilities->current_user_can( |
|
528 | - 'ee_read_registrations', |
|
529 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' |
|
530 | - ) |
|
531 | - ) { |
|
532 | - $this->admin_bar->add_menu( |
|
533 | - array( |
|
534 | - 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
535 | - 'parent' => 'espresso-toolbar-registrations', |
|
536 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
537 | - . esc_html__('Not Approved', 'event_espresso'), |
|
538 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
539 | - array( |
|
540 | - 'action' => 'default', |
|
541 | - 'status' => 'today', |
|
542 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
543 | - ), |
|
544 | - $this->reg_admin_url |
|
545 | - ), |
|
546 | - 'meta' => array( |
|
547 | - 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
548 | - 'target' => '', |
|
549 | - 'class' => $this->menu_class . ' ee-toolbar-icon-not-approved', |
|
550 | - ), |
|
551 | - ) |
|
552 | - ); |
|
553 | - } |
|
554 | - } |
|
555 | - |
|
556 | - |
|
557 | - /** |
|
558 | - * @return void |
|
559 | - */ |
|
560 | - private function addRegistrationOverviewTodayCancelled() |
|
561 | - { |
|
562 | - if ( |
|
563 | - $this->capabilities->current_user_can( |
|
564 | - 'ee_read_registrations', |
|
565 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' |
|
566 | - ) |
|
567 | - ) { |
|
568 | - $this->admin_bar->add_menu( |
|
569 | - array( |
|
570 | - 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
571 | - 'parent' => 'espresso-toolbar-registrations', |
|
572 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
573 | - . esc_html__('Cancelled', 'event_espresso'), |
|
574 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
575 | - array( |
|
576 | - 'action' => 'default', |
|
577 | - 'status' => 'today', |
|
578 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
579 | - ), |
|
580 | - $this->reg_admin_url |
|
581 | - ), |
|
582 | - 'meta' => array( |
|
583 | - 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
584 | - 'target' => '', |
|
585 | - 'class' => $this->menu_class . ' ee-toolbar-icon-cancelled', |
|
586 | - ), |
|
587 | - ) |
|
588 | - ); |
|
589 | - } |
|
590 | - } |
|
591 | - |
|
592 | - |
|
593 | - /** |
|
594 | - * @return void |
|
595 | - */ |
|
596 | - private function addRegistrationOverviewThisMonth() |
|
597 | - { |
|
598 | - if ( |
|
599 | - $this->capabilities->current_user_can( |
|
600 | - 'ee_read_registrations', |
|
601 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month' |
|
602 | - ) |
|
603 | - ) { |
|
604 | - $this->admin_bar->add_menu( |
|
605 | - array( |
|
606 | - 'id' => 'espresso-toolbar-registrations-month', |
|
607 | - 'parent' => 'espresso-toolbar-registrations', |
|
608 | - 'title' => esc_html__('This Month', 'event_espresso'), |
|
609 | - 'href' => '', // EEH_URL::add_query_args_and_nonce( |
|
610 | - // array( |
|
611 | - // 'action' => 'default', |
|
612 | - // 'status' => 'month' |
|
613 | - // ), |
|
614 | - // $this->reg_admin_url |
|
615 | - // ), |
|
616 | - 'meta' => array( |
|
617 | - 'title' => esc_html__('This Month', 'event_espresso'), |
|
618 | - 'target' => '', |
|
619 | - 'class' => $this->menu_class, |
|
620 | - ), |
|
621 | - ) |
|
622 | - ); |
|
623 | - } |
|
624 | - } |
|
625 | - |
|
626 | - |
|
627 | - /** |
|
628 | - * @return void |
|
629 | - */ |
|
630 | - private function addRegistrationOverviewThisMonthApproved() |
|
631 | - { |
|
632 | - if ( |
|
633 | - $this->capabilities->current_user_can( |
|
634 | - 'ee_read_registrations', |
|
635 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' |
|
636 | - ) |
|
637 | - ) { |
|
638 | - $this->admin_bar->add_menu( |
|
639 | - array( |
|
640 | - 'id' => 'espresso-toolbar-registrations-month-approved', |
|
641 | - 'parent' => 'espresso-toolbar-registrations', |
|
642 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
643 | - . esc_html__('Approved', 'event_espresso'), |
|
644 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
645 | - array( |
|
646 | - 'action' => 'default', |
|
647 | - 'status' => 'month', |
|
648 | - '_reg_status' => EEM_Registration::status_id_approved, |
|
649 | - ), |
|
650 | - $this->reg_admin_url |
|
651 | - ), |
|
652 | - 'meta' => array( |
|
653 | - 'title' => esc_html__('Approved', 'event_espresso'), |
|
654 | - 'target' => '', |
|
655 | - 'class' => $this->menu_class . ' ee-toolbar-icon-approved', |
|
656 | - ), |
|
657 | - ) |
|
658 | - ); |
|
659 | - } |
|
660 | - } |
|
661 | - |
|
662 | - |
|
663 | - /** |
|
664 | - * @return void |
|
665 | - */ |
|
666 | - private function addRegistrationOverviewThisMonthPending() |
|
667 | - { |
|
668 | - if ( |
|
669 | - $this->capabilities->current_user_can( |
|
670 | - 'ee_read_registrations', |
|
671 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' |
|
672 | - ) |
|
673 | - ) { |
|
674 | - $this->admin_bar->add_menu( |
|
675 | - array( |
|
676 | - 'id' => 'espresso-toolbar-registrations-month-pending', |
|
677 | - 'parent' => 'espresso-toolbar-registrations', |
|
678 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
679 | - . esc_html__('Pending', 'event_espresso'), |
|
680 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
681 | - array( |
|
682 | - 'action' => 'default', |
|
683 | - 'status' => 'month', |
|
684 | - '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
685 | - ), |
|
686 | - $this->reg_admin_url |
|
687 | - ), |
|
688 | - 'meta' => array( |
|
689 | - 'title' => esc_html__('Pending', 'event_espresso'), |
|
690 | - 'target' => '', |
|
691 | - 'class' => $this->menu_class . ' ee-toolbar-icon-pending', |
|
692 | - ), |
|
693 | - ) |
|
694 | - ); |
|
695 | - } |
|
696 | - } |
|
697 | - |
|
698 | - |
|
699 | - /** |
|
700 | - * @return void |
|
701 | - */ |
|
702 | - private function addRegistrationOverviewThisMonthNotApproved() |
|
703 | - { |
|
704 | - if ( |
|
705 | - $this->capabilities->current_user_can( |
|
706 | - 'ee_read_registrations', |
|
707 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' |
|
708 | - ) |
|
709 | - ) { |
|
710 | - $this->admin_bar->add_menu( |
|
711 | - array( |
|
712 | - 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
713 | - 'parent' => 'espresso-toolbar-registrations', |
|
714 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
715 | - . esc_html__('Not Approved', 'event_espresso'), |
|
716 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
717 | - array( |
|
718 | - 'action' => 'default', |
|
719 | - 'status' => 'month', |
|
720 | - '_reg_status' => EEM_Registration::status_id_not_approved, |
|
721 | - ), |
|
722 | - $this->reg_admin_url |
|
723 | - ), |
|
724 | - 'meta' => array( |
|
725 | - 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
726 | - 'target' => '', |
|
727 | - 'class' => $this->menu_class . ' ee-toolbar-icon-not-approved', |
|
728 | - ), |
|
729 | - ) |
|
730 | - ); |
|
731 | - } |
|
732 | - } |
|
733 | - |
|
734 | - |
|
735 | - /** |
|
736 | - * @return void |
|
737 | - */ |
|
738 | - private function addRegistrationOverviewThisMonthCancelled() |
|
739 | - { |
|
740 | - if ( |
|
741 | - $this->capabilities->current_user_can( |
|
742 | - 'ee_read_registrations', |
|
743 | - 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' |
|
744 | - ) |
|
745 | - ) { |
|
746 | - $this->admin_bar->add_menu( |
|
747 | - array( |
|
748 | - 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
749 | - 'parent' => 'espresso-toolbar-registrations', |
|
750 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
751 | - . esc_html__('Cancelled', 'event_espresso'), |
|
752 | - 'href' => EEH_URL::add_query_args_and_nonce( |
|
753 | - array( |
|
754 | - 'action' => 'default', |
|
755 | - 'status' => 'month', |
|
756 | - '_reg_status' => EEM_Registration::status_id_cancelled, |
|
757 | - ), |
|
758 | - $this->reg_admin_url |
|
759 | - ), |
|
760 | - 'meta' => array( |
|
761 | - 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
762 | - 'target' => '', |
|
763 | - 'class' => $this->menu_class . ' ee-toolbar-icon-cancelled', |
|
764 | - ), |
|
765 | - ) |
|
766 | - ); |
|
767 | - } |
|
768 | - } |
|
769 | - |
|
770 | - |
|
771 | - /** |
|
772 | - * @return void |
|
773 | - */ |
|
774 | - private function addExtensionsAndServices() |
|
775 | - { |
|
776 | - if ( |
|
777 | - $this->capabilities->current_user_can( |
|
778 | - 'ee_read_ee', |
|
779 | - 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' |
|
780 | - ) |
|
781 | - ) { |
|
782 | - $this->admin_bar->add_menu( |
|
783 | - array( |
|
784 | - 'id' => 'espresso-toolbar-extensions-and-services', |
|
785 | - 'parent' => 'espresso-toolbar', |
|
786 | - 'title' => '<span class="ee-toolbar-icon"></span>' |
|
787 | - . esc_html__('Extensions & Services', 'event_espresso'), |
|
788 | - 'href' => admin_url('admin.php?page=espresso_packages'), |
|
789 | - 'meta' => array( |
|
790 | - 'title' => esc_html__('Extensions & Services', 'event_espresso'), |
|
791 | - 'target' => '', |
|
792 | - 'class' => $this->menu_class, |
|
793 | - ), |
|
794 | - ) |
|
795 | - ); |
|
796 | - } |
|
797 | - } |
|
22 | + /** |
|
23 | + * @var WP_Admin_Bar $admin_bar |
|
24 | + */ |
|
25 | + private $admin_bar; |
|
26 | + |
|
27 | + /** |
|
28 | + * @var EE_Capabilities $capabilities |
|
29 | + */ |
|
30 | + private $capabilities; |
|
31 | + |
|
32 | + /** |
|
33 | + * @var string $events_admin_url |
|
34 | + */ |
|
35 | + private $events_admin_url; |
|
36 | + |
|
37 | + /** |
|
38 | + * @var string $menu_class |
|
39 | + */ |
|
40 | + private $menu_class = 'espresso_menu_item_class'; |
|
41 | + |
|
42 | + /** |
|
43 | + * @var string $reg_admin_url |
|
44 | + */ |
|
45 | + private $reg_admin_url; |
|
46 | + |
|
47 | + |
|
48 | + /** |
|
49 | + * AdminToolBar constructor. |
|
50 | + * |
|
51 | + * @param EE_Capabilities $capabilities |
|
52 | + */ |
|
53 | + public function __construct(EE_Capabilities $capabilities) |
|
54 | + { |
|
55 | + $this->capabilities = $capabilities; |
|
56 | + add_action('admin_bar_menu', array($this, 'espressoToolbarItems'), 100); |
|
57 | + $this->enqueueAssets(); |
|
58 | + } |
|
59 | + |
|
60 | + |
|
61 | + /** |
|
62 | + * espresso_toolbar_items |
|
63 | + * |
|
64 | + * @access public |
|
65 | + * @param WP_Admin_Bar $admin_bar |
|
66 | + * @return void |
|
67 | + */ |
|
68 | + public function espressoToolbarItems(WP_Admin_Bar $admin_bar) |
|
69 | + { |
|
70 | + // if its an AJAX request, or user is NOT an admin, or in full M-Mode |
|
71 | + if ( |
|
72 | + defined('DOING_AJAX') |
|
73 | + || ! $this->capabilities->current_user_can('ee_read_ee', 'ee_admin_bar_menu_top_level') |
|
74 | + || EE_Maintenance_Mode::instance()->level() === EE_Maintenance_Mode::level_2_complete_maintenance |
|
75 | + ) { |
|
76 | + return; |
|
77 | + } |
|
78 | + do_action('AHEE_log', __FILE__, __FUNCTION__, ''); |
|
79 | + $this->admin_bar = $admin_bar; |
|
80 | + // we don't use the constants EVENTS_ADMIN_URL or REG_ADMIN_URL |
|
81 | + // because they're only defined in each of their respective constructors |
|
82 | + // and this might be a frontend request, in which case they aren't available |
|
83 | + $this->events_admin_url = admin_url('admin.php?page=espresso_events'); |
|
84 | + $this->reg_admin_url = admin_url('admin.php?page=espresso_registrations'); |
|
85 | + // now let's add all of the menu items |
|
86 | + $this->addTopLevelMenu(); |
|
87 | + $this->addEventsSubMenu(); |
|
88 | + $this->addEventsAddEditHeader(); |
|
89 | + $this->addEventsAddNew(); |
|
90 | + $this->addEventsEditCurrentEvent(); |
|
91 | + $this->addEventsViewHeader(); |
|
92 | + $this->addEventsViewAll(); |
|
93 | + $this->addEventsViewToday(); |
|
94 | + $this->addEventsViewThisMonth(); |
|
95 | + $this->addRegistrationSubMenu(); |
|
96 | + $this->addRegistrationOverviewToday(); |
|
97 | + $this->addRegistrationOverviewTodayApproved(); |
|
98 | + $this->addRegistrationOverviewTodayPendingPayment(); |
|
99 | + $this->addRegistrationOverviewTodayNotApproved(); |
|
100 | + $this->addRegistrationOverviewTodayCancelled(); |
|
101 | + $this->addRegistrationOverviewThisMonth(); |
|
102 | + $this->addRegistrationOverviewThisMonthApproved(); |
|
103 | + $this->addRegistrationOverviewThisMonthPending(); |
|
104 | + $this->addRegistrationOverviewThisMonthNotApproved(); |
|
105 | + $this->addRegistrationOverviewThisMonthCancelled(); |
|
106 | + $this->addExtensionsAndServices(); |
|
107 | + } |
|
108 | + |
|
109 | + |
|
110 | + /** |
|
111 | + * @return void |
|
112 | + */ |
|
113 | + private function enqueueAssets() |
|
114 | + { |
|
115 | + wp_register_style( |
|
116 | + 'espresso-admin-toolbar', |
|
117 | + EE_GLOBAL_ASSETS_URL . 'css/espresso-admin-toolbar.css', |
|
118 | + array('dashicons'), |
|
119 | + EVENT_ESPRESSO_VERSION |
|
120 | + ); |
|
121 | + wp_enqueue_style('espresso-admin-toolbar'); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @return void |
|
127 | + */ |
|
128 | + private function addTopLevelMenu() |
|
129 | + { |
|
130 | + $this->admin_bar->add_menu( |
|
131 | + array( |
|
132 | + 'id' => 'espresso-toolbar', |
|
133 | + 'title' => '<span class="ee-icon ee-icon-ee-cup-thick ee-icon-size-20"></span><span class="ab-label">' |
|
134 | + . esc_html_x('Event Espresso', 'admin bar menu group label', 'event_espresso') |
|
135 | + . '</span>', |
|
136 | + 'href' => $this->events_admin_url, |
|
137 | + 'meta' => array( |
|
138 | + 'title' => esc_html__('Event Espresso', 'event_espresso'), |
|
139 | + 'class' => $this->menu_class . 'first', |
|
140 | + ), |
|
141 | + ) |
|
142 | + ); |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + * @return void |
|
148 | + */ |
|
149 | + private function addEventsSubMenu() |
|
150 | + { |
|
151 | + if ( |
|
152 | + $this->capabilities->current_user_can( |
|
153 | + 'ee_read_events', |
|
154 | + 'ee_admin_bar_menu_espresso-toolbar-events' |
|
155 | + ) |
|
156 | + ) { |
|
157 | + $this->admin_bar->add_menu( |
|
158 | + array( |
|
159 | + 'id' => 'espresso-toolbar-events', |
|
160 | + 'parent' => 'espresso-toolbar', |
|
161 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
162 | + . esc_html__('Events', 'event_espresso'), |
|
163 | + 'href' => $this->events_admin_url, |
|
164 | + 'meta' => array( |
|
165 | + 'title' => esc_html__('Events', 'event_espresso'), |
|
166 | + 'target' => '', |
|
167 | + 'class' => $this->menu_class, |
|
168 | + ), |
|
169 | + ) |
|
170 | + ); |
|
171 | + } |
|
172 | + } |
|
173 | + |
|
174 | + |
|
175 | + /** |
|
176 | + * @return void |
|
177 | + */ |
|
178 | + private function addEventsAddEditHeader() |
|
179 | + { |
|
180 | + if ( |
|
181 | + $this->capabilities->current_user_can( |
|
182 | + 'ee_read_events', |
|
183 | + 'ee_admin_bar_menu_espresso-toolbar-events-view' |
|
184 | + ) |
|
185 | + ) { |
|
186 | + $this->admin_bar->add_menu( |
|
187 | + array( |
|
188 | + 'id' => 'espresso-toolbar-events-add-edit', |
|
189 | + 'parent' => 'espresso-toolbar-events', |
|
190 | + 'title' => esc_html__('Add / Edit', 'event_espresso'), |
|
191 | + 'href' => '', |
|
192 | + ) |
|
193 | + ); |
|
194 | + } |
|
195 | + } |
|
196 | + |
|
197 | + |
|
198 | + /** |
|
199 | + * @return void |
|
200 | + */ |
|
201 | + private function addEventsAddNew() |
|
202 | + { |
|
203 | + if ( |
|
204 | + $this->capabilities->current_user_can( |
|
205 | + 'ee_edit_events', |
|
206 | + 'ee_admin_bar_menu_espresso-toolbar-events-new' |
|
207 | + ) |
|
208 | + ) { |
|
209 | + $this->admin_bar->add_menu( |
|
210 | + array( |
|
211 | + 'id' => 'espresso-toolbar-events-new', |
|
212 | + 'parent' => 'espresso-toolbar-events', |
|
213 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
214 | + . esc_html__('Add New', 'event_espresso'), |
|
215 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
216 | + array('action' => 'create_new'), |
|
217 | + $this->events_admin_url |
|
218 | + ), |
|
219 | + 'meta' => array( |
|
220 | + 'title' => esc_html__('Add New', 'event_espresso'), |
|
221 | + 'target' => '', |
|
222 | + 'class' => $this->menu_class, |
|
223 | + ), |
|
224 | + ) |
|
225 | + ); |
|
226 | + } |
|
227 | + } |
|
228 | + |
|
229 | + |
|
230 | + /** |
|
231 | + * @return void |
|
232 | + */ |
|
233 | + private function addEventsEditCurrentEvent() |
|
234 | + { |
|
235 | + if (is_single() && (get_post_type() === 'espresso_events')) { |
|
236 | + // Current post |
|
237 | + global $post; |
|
238 | + if ( |
|
239 | + $this->capabilities->current_user_can( |
|
240 | + 'ee_edit_event', |
|
241 | + 'ee_admin_bar_menu_espresso-toolbar-events-edit', |
|
242 | + $post->ID |
|
243 | + ) |
|
244 | + ) { |
|
245 | + $this->admin_bar->add_menu( |
|
246 | + array( |
|
247 | + 'id' => 'espresso-toolbar-events-edit', |
|
248 | + 'parent' => 'espresso-toolbar-events', |
|
249 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
250 | + . esc_html__('Edit Event', 'event_espresso'), |
|
251 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
252 | + array( |
|
253 | + 'action' => 'edit', |
|
254 | + 'post' => $post->ID, |
|
255 | + ), |
|
256 | + $this->events_admin_url |
|
257 | + ), |
|
258 | + 'meta' => array( |
|
259 | + 'title' => esc_html__('Edit Event', 'event_espresso'), |
|
260 | + 'target' => '', |
|
261 | + 'class' => $this->menu_class, |
|
262 | + ), |
|
263 | + ) |
|
264 | + ); |
|
265 | + } |
|
266 | + } |
|
267 | + } |
|
268 | + |
|
269 | + |
|
270 | + /** |
|
271 | + * @return void |
|
272 | + */ |
|
273 | + private function addEventsViewHeader() |
|
274 | + { |
|
275 | + if ( |
|
276 | + $this->capabilities->current_user_can( |
|
277 | + 'ee_read_events', |
|
278 | + 'ee_admin_bar_menu_espresso-toolbar-events-view' |
|
279 | + ) |
|
280 | + ) { |
|
281 | + $this->admin_bar->add_menu( |
|
282 | + array( |
|
283 | + 'id' => 'espresso-toolbar-events-view', |
|
284 | + 'parent' => 'espresso-toolbar-events', |
|
285 | + 'title' => esc_html__('View', 'event_espresso'), |
|
286 | + 'href' => '', |
|
287 | + ) |
|
288 | + ); |
|
289 | + } |
|
290 | + } |
|
291 | + |
|
292 | + |
|
293 | + /** |
|
294 | + * @return void |
|
295 | + */ |
|
296 | + private function addEventsViewAll() |
|
297 | + { |
|
298 | + if ( |
|
299 | + $this->capabilities->current_user_can( |
|
300 | + 'ee_read_events', |
|
301 | + 'ee_admin_bar_menu_espresso-toolbar-events-all' |
|
302 | + ) |
|
303 | + ) { |
|
304 | + $this->admin_bar->add_menu( |
|
305 | + array( |
|
306 | + 'id' => 'espresso-toolbar-events-all', |
|
307 | + 'parent' => 'espresso-toolbar-events', |
|
308 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
309 | + . esc_html__('All', 'event_espresso'), |
|
310 | + 'href' => $this->events_admin_url, |
|
311 | + 'meta' => array( |
|
312 | + 'title' => esc_html__('All', 'event_espresso'), |
|
313 | + 'target' => '', |
|
314 | + 'class' => $this->menu_class, |
|
315 | + ), |
|
316 | + ) |
|
317 | + ); |
|
318 | + } |
|
319 | + } |
|
320 | + |
|
321 | + |
|
322 | + /** |
|
323 | + * @return void |
|
324 | + */ |
|
325 | + private function addEventsViewToday() |
|
326 | + { |
|
327 | + if ( |
|
328 | + $this->capabilities->current_user_can( |
|
329 | + 'ee_read_events', |
|
330 | + 'ee_admin_bar_menu_espresso-toolbar-events-today' |
|
331 | + ) |
|
332 | + ) { |
|
333 | + $this->admin_bar->add_menu( |
|
334 | + array( |
|
335 | + 'id' => 'espresso-toolbar-events-today', |
|
336 | + 'parent' => 'espresso-toolbar-events', |
|
337 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
338 | + . esc_html__('Today', 'event_espresso'), |
|
339 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
340 | + array( |
|
341 | + 'action' => 'default', |
|
342 | + 'status' => 'today', |
|
343 | + ), |
|
344 | + $this->events_admin_url |
|
345 | + ), |
|
346 | + 'meta' => array( |
|
347 | + 'title' => esc_html__('Today', 'event_espresso'), |
|
348 | + 'target' => '', |
|
349 | + 'class' => $this->menu_class, |
|
350 | + ), |
|
351 | + ) |
|
352 | + ); |
|
353 | + } |
|
354 | + } |
|
355 | + |
|
356 | + |
|
357 | + /** |
|
358 | + * @return void |
|
359 | + */ |
|
360 | + private function addEventsViewThisMonth() |
|
361 | + { |
|
362 | + if ( |
|
363 | + $this->capabilities->current_user_can( |
|
364 | + 'ee_read_events', |
|
365 | + 'ee_admin_bar_menu_espresso-toolbar-events-month' |
|
366 | + ) |
|
367 | + ) { |
|
368 | + $this->admin_bar->add_menu( |
|
369 | + array( |
|
370 | + 'id' => 'espresso-toolbar-events-month', |
|
371 | + 'parent' => 'espresso-toolbar-events', |
|
372 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
373 | + . esc_html__('This Month', 'event_espresso'), |
|
374 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
375 | + array( |
|
376 | + 'action' => 'default', |
|
377 | + 'status' => 'month', |
|
378 | + ), |
|
379 | + $this->events_admin_url |
|
380 | + ), |
|
381 | + 'meta' => array( |
|
382 | + 'title' => esc_html__('This Month', 'event_espresso'), |
|
383 | + 'target' => '', |
|
384 | + 'class' => $this->menu_class, |
|
385 | + ), |
|
386 | + ) |
|
387 | + ); |
|
388 | + } |
|
389 | + } |
|
390 | + |
|
391 | + |
|
392 | + /** |
|
393 | + * @return void |
|
394 | + */ |
|
395 | + private function addRegistrationSubMenu() |
|
396 | + { |
|
397 | + if ( |
|
398 | + $this->capabilities->current_user_can( |
|
399 | + 'ee_read_registrations', |
|
400 | + 'ee_admin_bar_menu_espresso-toolbar-registrations' |
|
401 | + ) |
|
402 | + ) { |
|
403 | + $this->admin_bar->add_menu( |
|
404 | + array( |
|
405 | + 'id' => 'espresso-toolbar-registrations', |
|
406 | + 'parent' => 'espresso-toolbar', |
|
407 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
408 | + . esc_html__('Registrations', 'event_espresso'), |
|
409 | + 'href' => $this->reg_admin_url, |
|
410 | + 'meta' => array( |
|
411 | + 'title' => esc_html__('Registrations', 'event_espresso'), |
|
412 | + 'target' => '', |
|
413 | + 'class' => $this->menu_class, |
|
414 | + ), |
|
415 | + ) |
|
416 | + ); |
|
417 | + } |
|
418 | + } |
|
419 | + |
|
420 | + |
|
421 | + /** |
|
422 | + * @return void |
|
423 | + */ |
|
424 | + private function addRegistrationOverviewToday() |
|
425 | + { |
|
426 | + if ( |
|
427 | + $this->capabilities->current_user_can( |
|
428 | + 'ee_read_registrations', |
|
429 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today' |
|
430 | + ) |
|
431 | + ) { |
|
432 | + $this->admin_bar->add_menu( |
|
433 | + array( |
|
434 | + 'id' => 'espresso-toolbar-registrations-today', |
|
435 | + 'parent' => 'espresso-toolbar-registrations', |
|
436 | + 'title' => esc_html__('Today', 'event_espresso'), |
|
437 | + 'href' => '', |
|
438 | + 'meta' => array( |
|
439 | + 'title' => esc_html__('Today', 'event_espresso'), |
|
440 | + 'target' => '', |
|
441 | + 'class' => $this->menu_class, |
|
442 | + ), |
|
443 | + ) |
|
444 | + ); |
|
445 | + } |
|
446 | + } |
|
447 | + |
|
448 | + |
|
449 | + /** |
|
450 | + * @return void |
|
451 | + */ |
|
452 | + private function addRegistrationOverviewTodayApproved() |
|
453 | + { |
|
454 | + if ( |
|
455 | + $this->capabilities->current_user_can( |
|
456 | + 'ee_read_registrations', |
|
457 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-approved' |
|
458 | + ) |
|
459 | + ) { |
|
460 | + $this->admin_bar->add_menu( |
|
461 | + array( |
|
462 | + 'id' => 'espresso-toolbar-registrations-today-approved', |
|
463 | + 'parent' => 'espresso-toolbar-registrations', |
|
464 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
465 | + . esc_html__('Approved', 'event_espresso'), |
|
466 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
467 | + array( |
|
468 | + 'action' => 'default', |
|
469 | + 'status' => 'today', |
|
470 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
471 | + ), |
|
472 | + $this->reg_admin_url |
|
473 | + ), |
|
474 | + 'meta' => array( |
|
475 | + 'title' => esc_html__('Approved', 'event_espresso'), |
|
476 | + 'target' => '', |
|
477 | + 'class' => $this->menu_class . ' ee-toolbar-icon-approved', |
|
478 | + ), |
|
479 | + ) |
|
480 | + ); |
|
481 | + } |
|
482 | + } |
|
483 | + |
|
484 | + |
|
485 | + /** |
|
486 | + * @return void |
|
487 | + */ |
|
488 | + private function addRegistrationOverviewTodayPendingPayment() |
|
489 | + { |
|
490 | + if ( |
|
491 | + $this->capabilities->current_user_can( |
|
492 | + 'ee_read_registrations', |
|
493 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-pending' |
|
494 | + ) |
|
495 | + ) { |
|
496 | + $this->admin_bar->add_menu( |
|
497 | + array( |
|
498 | + 'id' => 'espresso-toolbar-registrations-today-pending', |
|
499 | + 'parent' => 'espresso-toolbar-registrations', |
|
500 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
501 | + . esc_html__('Pending', 'event_espresso'), |
|
502 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
503 | + array( |
|
504 | + 'action' => 'default', |
|
505 | + 'status' => 'today', |
|
506 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
507 | + ), |
|
508 | + $this->reg_admin_url |
|
509 | + ), |
|
510 | + 'meta' => array( |
|
511 | + 'title' => esc_html__('Pending Payment', 'event_espresso'), |
|
512 | + 'target' => '', |
|
513 | + 'class' => $this->menu_class . ' ee-toolbar-icon-pending', |
|
514 | + ), |
|
515 | + ) |
|
516 | + ); |
|
517 | + } |
|
518 | + } |
|
519 | + |
|
520 | + |
|
521 | + /** |
|
522 | + * @return void |
|
523 | + */ |
|
524 | + private function addRegistrationOverviewTodayNotApproved() |
|
525 | + { |
|
526 | + if ( |
|
527 | + $this->capabilities->current_user_can( |
|
528 | + 'ee_read_registrations', |
|
529 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-not-approved' |
|
530 | + ) |
|
531 | + ) { |
|
532 | + $this->admin_bar->add_menu( |
|
533 | + array( |
|
534 | + 'id' => 'espresso-toolbar-registrations-today-not-approved', |
|
535 | + 'parent' => 'espresso-toolbar-registrations', |
|
536 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
537 | + . esc_html__('Not Approved', 'event_espresso'), |
|
538 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
539 | + array( |
|
540 | + 'action' => 'default', |
|
541 | + 'status' => 'today', |
|
542 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
543 | + ), |
|
544 | + $this->reg_admin_url |
|
545 | + ), |
|
546 | + 'meta' => array( |
|
547 | + 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
548 | + 'target' => '', |
|
549 | + 'class' => $this->menu_class . ' ee-toolbar-icon-not-approved', |
|
550 | + ), |
|
551 | + ) |
|
552 | + ); |
|
553 | + } |
|
554 | + } |
|
555 | + |
|
556 | + |
|
557 | + /** |
|
558 | + * @return void |
|
559 | + */ |
|
560 | + private function addRegistrationOverviewTodayCancelled() |
|
561 | + { |
|
562 | + if ( |
|
563 | + $this->capabilities->current_user_can( |
|
564 | + 'ee_read_registrations', |
|
565 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-today-cancelled' |
|
566 | + ) |
|
567 | + ) { |
|
568 | + $this->admin_bar->add_menu( |
|
569 | + array( |
|
570 | + 'id' => 'espresso-toolbar-registrations-today-cancelled', |
|
571 | + 'parent' => 'espresso-toolbar-registrations', |
|
572 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
573 | + . esc_html__('Cancelled', 'event_espresso'), |
|
574 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
575 | + array( |
|
576 | + 'action' => 'default', |
|
577 | + 'status' => 'today', |
|
578 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
579 | + ), |
|
580 | + $this->reg_admin_url |
|
581 | + ), |
|
582 | + 'meta' => array( |
|
583 | + 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
584 | + 'target' => '', |
|
585 | + 'class' => $this->menu_class . ' ee-toolbar-icon-cancelled', |
|
586 | + ), |
|
587 | + ) |
|
588 | + ); |
|
589 | + } |
|
590 | + } |
|
591 | + |
|
592 | + |
|
593 | + /** |
|
594 | + * @return void |
|
595 | + */ |
|
596 | + private function addRegistrationOverviewThisMonth() |
|
597 | + { |
|
598 | + if ( |
|
599 | + $this->capabilities->current_user_can( |
|
600 | + 'ee_read_registrations', |
|
601 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month' |
|
602 | + ) |
|
603 | + ) { |
|
604 | + $this->admin_bar->add_menu( |
|
605 | + array( |
|
606 | + 'id' => 'espresso-toolbar-registrations-month', |
|
607 | + 'parent' => 'espresso-toolbar-registrations', |
|
608 | + 'title' => esc_html__('This Month', 'event_espresso'), |
|
609 | + 'href' => '', // EEH_URL::add_query_args_and_nonce( |
|
610 | + // array( |
|
611 | + // 'action' => 'default', |
|
612 | + // 'status' => 'month' |
|
613 | + // ), |
|
614 | + // $this->reg_admin_url |
|
615 | + // ), |
|
616 | + 'meta' => array( |
|
617 | + 'title' => esc_html__('This Month', 'event_espresso'), |
|
618 | + 'target' => '', |
|
619 | + 'class' => $this->menu_class, |
|
620 | + ), |
|
621 | + ) |
|
622 | + ); |
|
623 | + } |
|
624 | + } |
|
625 | + |
|
626 | + |
|
627 | + /** |
|
628 | + * @return void |
|
629 | + */ |
|
630 | + private function addRegistrationOverviewThisMonthApproved() |
|
631 | + { |
|
632 | + if ( |
|
633 | + $this->capabilities->current_user_can( |
|
634 | + 'ee_read_registrations', |
|
635 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-approved' |
|
636 | + ) |
|
637 | + ) { |
|
638 | + $this->admin_bar->add_menu( |
|
639 | + array( |
|
640 | + 'id' => 'espresso-toolbar-registrations-month-approved', |
|
641 | + 'parent' => 'espresso-toolbar-registrations', |
|
642 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
643 | + . esc_html__('Approved', 'event_espresso'), |
|
644 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
645 | + array( |
|
646 | + 'action' => 'default', |
|
647 | + 'status' => 'month', |
|
648 | + '_reg_status' => EEM_Registration::status_id_approved, |
|
649 | + ), |
|
650 | + $this->reg_admin_url |
|
651 | + ), |
|
652 | + 'meta' => array( |
|
653 | + 'title' => esc_html__('Approved', 'event_espresso'), |
|
654 | + 'target' => '', |
|
655 | + 'class' => $this->menu_class . ' ee-toolbar-icon-approved', |
|
656 | + ), |
|
657 | + ) |
|
658 | + ); |
|
659 | + } |
|
660 | + } |
|
661 | + |
|
662 | + |
|
663 | + /** |
|
664 | + * @return void |
|
665 | + */ |
|
666 | + private function addRegistrationOverviewThisMonthPending() |
|
667 | + { |
|
668 | + if ( |
|
669 | + $this->capabilities->current_user_can( |
|
670 | + 'ee_read_registrations', |
|
671 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-pending' |
|
672 | + ) |
|
673 | + ) { |
|
674 | + $this->admin_bar->add_menu( |
|
675 | + array( |
|
676 | + 'id' => 'espresso-toolbar-registrations-month-pending', |
|
677 | + 'parent' => 'espresso-toolbar-registrations', |
|
678 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
679 | + . esc_html__('Pending', 'event_espresso'), |
|
680 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
681 | + array( |
|
682 | + 'action' => 'default', |
|
683 | + 'status' => 'month', |
|
684 | + '_reg_status' => EEM_Registration::status_id_pending_payment, |
|
685 | + ), |
|
686 | + $this->reg_admin_url |
|
687 | + ), |
|
688 | + 'meta' => array( |
|
689 | + 'title' => esc_html__('Pending', 'event_espresso'), |
|
690 | + 'target' => '', |
|
691 | + 'class' => $this->menu_class . ' ee-toolbar-icon-pending', |
|
692 | + ), |
|
693 | + ) |
|
694 | + ); |
|
695 | + } |
|
696 | + } |
|
697 | + |
|
698 | + |
|
699 | + /** |
|
700 | + * @return void |
|
701 | + */ |
|
702 | + private function addRegistrationOverviewThisMonthNotApproved() |
|
703 | + { |
|
704 | + if ( |
|
705 | + $this->capabilities->current_user_can( |
|
706 | + 'ee_read_registrations', |
|
707 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-not-approved' |
|
708 | + ) |
|
709 | + ) { |
|
710 | + $this->admin_bar->add_menu( |
|
711 | + array( |
|
712 | + 'id' => 'espresso-toolbar-registrations-month-not-approved', |
|
713 | + 'parent' => 'espresso-toolbar-registrations', |
|
714 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
715 | + . esc_html__('Not Approved', 'event_espresso'), |
|
716 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
717 | + array( |
|
718 | + 'action' => 'default', |
|
719 | + 'status' => 'month', |
|
720 | + '_reg_status' => EEM_Registration::status_id_not_approved, |
|
721 | + ), |
|
722 | + $this->reg_admin_url |
|
723 | + ), |
|
724 | + 'meta' => array( |
|
725 | + 'title' => esc_html__('Not Approved', 'event_espresso'), |
|
726 | + 'target' => '', |
|
727 | + 'class' => $this->menu_class . ' ee-toolbar-icon-not-approved', |
|
728 | + ), |
|
729 | + ) |
|
730 | + ); |
|
731 | + } |
|
732 | + } |
|
733 | + |
|
734 | + |
|
735 | + /** |
|
736 | + * @return void |
|
737 | + */ |
|
738 | + private function addRegistrationOverviewThisMonthCancelled() |
|
739 | + { |
|
740 | + if ( |
|
741 | + $this->capabilities->current_user_can( |
|
742 | + 'ee_read_registrations', |
|
743 | + 'ee_admin_bar_menu_espresso-toolbar-registrations-month-cancelled' |
|
744 | + ) |
|
745 | + ) { |
|
746 | + $this->admin_bar->add_menu( |
|
747 | + array( |
|
748 | + 'id' => 'espresso-toolbar-registrations-month-cancelled', |
|
749 | + 'parent' => 'espresso-toolbar-registrations', |
|
750 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
751 | + . esc_html__('Cancelled', 'event_espresso'), |
|
752 | + 'href' => EEH_URL::add_query_args_and_nonce( |
|
753 | + array( |
|
754 | + 'action' => 'default', |
|
755 | + 'status' => 'month', |
|
756 | + '_reg_status' => EEM_Registration::status_id_cancelled, |
|
757 | + ), |
|
758 | + $this->reg_admin_url |
|
759 | + ), |
|
760 | + 'meta' => array( |
|
761 | + 'title' => esc_html__('Cancelled', 'event_espresso'), |
|
762 | + 'target' => '', |
|
763 | + 'class' => $this->menu_class . ' ee-toolbar-icon-cancelled', |
|
764 | + ), |
|
765 | + ) |
|
766 | + ); |
|
767 | + } |
|
768 | + } |
|
769 | + |
|
770 | + |
|
771 | + /** |
|
772 | + * @return void |
|
773 | + */ |
|
774 | + private function addExtensionsAndServices() |
|
775 | + { |
|
776 | + if ( |
|
777 | + $this->capabilities->current_user_can( |
|
778 | + 'ee_read_ee', |
|
779 | + 'ee_admin_bar_menu_espresso-toolbar-extensions-and-services' |
|
780 | + ) |
|
781 | + ) { |
|
782 | + $this->admin_bar->add_menu( |
|
783 | + array( |
|
784 | + 'id' => 'espresso-toolbar-extensions-and-services', |
|
785 | + 'parent' => 'espresso-toolbar', |
|
786 | + 'title' => '<span class="ee-toolbar-icon"></span>' |
|
787 | + . esc_html__('Extensions & Services', 'event_espresso'), |
|
788 | + 'href' => admin_url('admin.php?page=espresso_packages'), |
|
789 | + 'meta' => array( |
|
790 | + 'title' => esc_html__('Extensions & Services', 'event_espresso'), |
|
791 | + 'target' => '', |
|
792 | + 'class' => $this->menu_class, |
|
793 | + ), |
|
794 | + ) |
|
795 | + ); |
|
796 | + } |
|
797 | + } |
|
798 | 798 | } |
@@ -151,7 +151,7 @@ |
||
151 | 151 | * This provides a count of events using this custom template |
152 | 152 | * |
153 | 153 | * @param EE_Message_Template_Group $item message_template group data |
154 | - * @return string column output |
|
154 | + * @return integer column output |
|
155 | 155 | */ |
156 | 156 | public function column_events($item) |
157 | 157 | { |
@@ -12,259 +12,259 @@ |
||
12 | 12 | class Custom_Messages_Template_List_Table extends Messages_Template_List_Table |
13 | 13 | { |
14 | 14 | |
15 | - /** |
|
16 | - * Setup initial data. |
|
17 | - */ |
|
18 | - protected function _setup_data() |
|
19 | - { |
|
20 | - $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | - $this->_per_page, |
|
22 | - $this->_view, |
|
23 | - false, |
|
24 | - false, |
|
25 | - false |
|
26 | - ); |
|
27 | - $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
28 | - $this->_per_page, |
|
29 | - $this->_view, |
|
30 | - true, |
|
31 | - true, |
|
32 | - false |
|
33 | - ); |
|
34 | - } |
|
15 | + /** |
|
16 | + * Setup initial data. |
|
17 | + */ |
|
18 | + protected function _setup_data() |
|
19 | + { |
|
20 | + $this->_data = $this->get_admin_page()->get_message_templates( |
|
21 | + $this->_per_page, |
|
22 | + $this->_view, |
|
23 | + false, |
|
24 | + false, |
|
25 | + false |
|
26 | + ); |
|
27 | + $this->_all_data_count = $this->get_admin_page()->get_message_templates( |
|
28 | + $this->_per_page, |
|
29 | + $this->_view, |
|
30 | + true, |
|
31 | + true, |
|
32 | + false |
|
33 | + ); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | - /** |
|
38 | - * Set initial properties |
|
39 | - */ |
|
40 | - protected function _set_properties() |
|
41 | - { |
|
42 | - parent::_set_properties(); |
|
43 | - $this->_wp_list_args = array( |
|
44 | - 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
45 | - 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
46 | - 'ajax' => true, // for now, |
|
47 | - 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
48 | - ); |
|
37 | + /** |
|
38 | + * Set initial properties |
|
39 | + */ |
|
40 | + protected function _set_properties() |
|
41 | + { |
|
42 | + parent::_set_properties(); |
|
43 | + $this->_wp_list_args = array( |
|
44 | + 'singular' => esc_html__('Message Template Group', 'event_espresso'), |
|
45 | + 'plural' => esc_html__('Message Template', 'event_espresso'), |
|
46 | + 'ajax' => true, // for now, |
|
47 | + 'screen' => $this->get_admin_page()->get_current_screen()->id, |
|
48 | + ); |
|
49 | 49 | |
50 | - $this->_columns = array_merge( |
|
51 | - array( |
|
52 | - 'cb' => '<input type="checkbox" />', |
|
53 | - 'name' => esc_html__('Template Name', 'event_espresso'), |
|
54 | - ), |
|
55 | - $this->_columns, |
|
56 | - array( |
|
57 | - 'events' => esc_html__('Events', 'event_espresso'), |
|
58 | - 'actions' => '', |
|
59 | - ) |
|
60 | - ); |
|
61 | - } |
|
50 | + $this->_columns = array_merge( |
|
51 | + array( |
|
52 | + 'cb' => '<input type="checkbox" />', |
|
53 | + 'name' => esc_html__('Template Name', 'event_espresso'), |
|
54 | + ), |
|
55 | + $this->_columns, |
|
56 | + array( |
|
57 | + 'events' => esc_html__('Events', 'event_espresso'), |
|
58 | + 'actions' => '', |
|
59 | + ) |
|
60 | + ); |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | - /** |
|
65 | - * Custom message for when there are no items found. |
|
66 | - * |
|
67 | - * @since 4.3.0 |
|
68 | - */ |
|
69 | - public function no_items() |
|
70 | - { |
|
71 | - if ($this->_view !== 'trashed') { |
|
72 | - printf( |
|
73 | - esc_html__( |
|
74 | - '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
75 | - 'event_espresso' |
|
76 | - ), |
|
77 | - '<strong>', |
|
78 | - '</strong>' |
|
79 | - ); |
|
80 | - } else { |
|
81 | - parent::no_items(); |
|
82 | - } |
|
83 | - } |
|
64 | + /** |
|
65 | + * Custom message for when there are no items found. |
|
66 | + * |
|
67 | + * @since 4.3.0 |
|
68 | + */ |
|
69 | + public function no_items() |
|
70 | + { |
|
71 | + if ($this->_view !== 'trashed') { |
|
72 | + printf( |
|
73 | + esc_html__( |
|
74 | + '%sNo Custom Templates found.%s To create your first custom message template, go to the "Default Message Templates" tab and click the "Create Custom" button next to the template you want to use as a base for the new one.', |
|
75 | + 'event_espresso' |
|
76 | + ), |
|
77 | + '<strong>', |
|
78 | + '</strong>' |
|
79 | + ); |
|
80 | + } else { |
|
81 | + parent::no_items(); |
|
82 | + } |
|
83 | + } |
|
84 | 84 | |
85 | 85 | |
86 | - /** |
|
87 | - * @param EE_Message_Template_Group $item |
|
88 | - * @return string |
|
89 | - */ |
|
90 | - public function column_cb($item) |
|
91 | - { |
|
92 | - return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
93 | - } |
|
86 | + /** |
|
87 | + * @param EE_Message_Template_Group $item |
|
88 | + * @return string |
|
89 | + */ |
|
90 | + public function column_cb($item) |
|
91 | + { |
|
92 | + return sprintf('<input type="checkbox" name="checkbox[%s]" value="1" />', $item->GRP_ID()); |
|
93 | + } |
|
94 | 94 | |
95 | 95 | |
96 | - /** |
|
97 | - * @param EE_Message_Template_Group $item |
|
98 | - * @return string |
|
99 | - */ |
|
100 | - public function column_name($item) |
|
101 | - { |
|
102 | - return '<p>' . $item->name() . '</p>'; |
|
103 | - } |
|
96 | + /** |
|
97 | + * @param EE_Message_Template_Group $item |
|
98 | + * @return string |
|
99 | + */ |
|
100 | + public function column_name($item) |
|
101 | + { |
|
102 | + return '<p>' . $item->name() . '</p>'; |
|
103 | + } |
|
104 | 104 | |
105 | 105 | |
106 | - /** |
|
107 | - * @param EE_Message_Template_Group $item |
|
108 | - * @return string |
|
109 | - */ |
|
110 | - public function column_actions($item) |
|
111 | - { |
|
112 | - if ( |
|
113 | - EE_Registry::instance()->CAP->current_user_can( |
|
114 | - 'ee_edit_messages', |
|
115 | - 'espresso_messages_add_new_message_template' |
|
116 | - ) |
|
117 | - ) { |
|
118 | - $create_args = array( |
|
119 | - 'GRP_ID' => $item->ID(), |
|
120 | - 'messenger' => $item->messenger(), |
|
121 | - 'message_type' => $item->message_type(), |
|
122 | - 'action' => 'add_new_message_template', |
|
123 | - ); |
|
124 | - $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
125 | - return sprintf( |
|
126 | - '<p><a href="%s" class="button button-small">%s</a></p>', |
|
127 | - $create_link, |
|
128 | - esc_html__('Create Custom', 'event_espresso') |
|
129 | - ); |
|
130 | - } |
|
131 | - return ''; |
|
132 | - } |
|
106 | + /** |
|
107 | + * @param EE_Message_Template_Group $item |
|
108 | + * @return string |
|
109 | + */ |
|
110 | + public function column_actions($item) |
|
111 | + { |
|
112 | + if ( |
|
113 | + EE_Registry::instance()->CAP->current_user_can( |
|
114 | + 'ee_edit_messages', |
|
115 | + 'espresso_messages_add_new_message_template' |
|
116 | + ) |
|
117 | + ) { |
|
118 | + $create_args = array( |
|
119 | + 'GRP_ID' => $item->ID(), |
|
120 | + 'messenger' => $item->messenger(), |
|
121 | + 'message_type' => $item->message_type(), |
|
122 | + 'action' => 'add_new_message_template', |
|
123 | + ); |
|
124 | + $create_link = EE_Admin_Page::add_query_args_and_nonce($create_args, EE_MSG_ADMIN_URL); |
|
125 | + return sprintf( |
|
126 | + '<p><a href="%s" class="button button-small">%s</a></p>', |
|
127 | + $create_link, |
|
128 | + esc_html__('Create Custom', 'event_espresso') |
|
129 | + ); |
|
130 | + } |
|
131 | + return ''; |
|
132 | + } |
|
133 | 133 | |
134 | - /** |
|
135 | - * Set the view counts on the _views property |
|
136 | - */ |
|
137 | - protected function _add_view_counts() |
|
138 | - { |
|
139 | - foreach ($this->_views as $view => $args) { |
|
140 | - $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
141 | - $this->_per_page, |
|
142 | - $view, |
|
143 | - true, |
|
144 | - true, |
|
145 | - false |
|
146 | - ); |
|
147 | - } |
|
148 | - } |
|
134 | + /** |
|
135 | + * Set the view counts on the _views property |
|
136 | + */ |
|
137 | + protected function _add_view_counts() |
|
138 | + { |
|
139 | + foreach ($this->_views as $view => $args) { |
|
140 | + $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
141 | + $this->_per_page, |
|
142 | + $view, |
|
143 | + true, |
|
144 | + true, |
|
145 | + false |
|
146 | + ); |
|
147 | + } |
|
148 | + } |
|
149 | 149 | |
150 | 150 | |
151 | - /** |
|
152 | - * column_events |
|
153 | - * This provides a count of events using this custom template |
|
154 | - * |
|
155 | - * @param EE_Message_Template_Group $item message_template group data |
|
156 | - * @return string column output |
|
157 | - */ |
|
158 | - public function column_events($item) |
|
159 | - { |
|
160 | - return $item->count_events(); |
|
161 | - } |
|
151 | + /** |
|
152 | + * column_events |
|
153 | + * This provides a count of events using this custom template |
|
154 | + * |
|
155 | + * @param EE_Message_Template_Group $item message_template group data |
|
156 | + * @return string column output |
|
157 | + */ |
|
158 | + public function column_events($item) |
|
159 | + { |
|
160 | + return $item->count_events(); |
|
161 | + } |
|
162 | 162 | |
163 | 163 | |
164 | - /** |
|
165 | - * Add additional actions for custom message template list view. |
|
166 | - * |
|
167 | - * @param EE_Message_Template_Group $item |
|
168 | - * @return array |
|
169 | - * @throws EE_Error |
|
170 | - */ |
|
171 | - protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
172 | - { |
|
173 | - $actions = parent::_get_actions_for_messenger_column($item); |
|
164 | + /** |
|
165 | + * Add additional actions for custom message template list view. |
|
166 | + * |
|
167 | + * @param EE_Message_Template_Group $item |
|
168 | + * @return array |
|
169 | + * @throws EE_Error |
|
170 | + */ |
|
171 | + protected function _get_actions_for_messenger_column(EE_Message_Template_Group $item) |
|
172 | + { |
|
173 | + $actions = parent::_get_actions_for_messenger_column($item); |
|
174 | 174 | |
175 | - // add additional actions for trash/restore etc. |
|
176 | - $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
177 | - 'action' => 'trash_message_template', |
|
178 | - 'id' => $item->GRP_ID(), |
|
179 | - 'noheader' => true, |
|
180 | - ), EE_MSG_ADMIN_URL); |
|
181 | - // restore link |
|
182 | - $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
183 | - 'action' => 'restore_message_template', |
|
184 | - 'id' => $item->GRP_ID(), |
|
185 | - 'noheader' => true, |
|
186 | - ), EE_MSG_ADMIN_URL); |
|
187 | - // delete price link |
|
188 | - $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
189 | - 'action' => 'delete_message_template', |
|
190 | - 'id' => $item->GRP_ID(), |
|
191 | - 'noheader' => true, |
|
192 | - ), EE_MSG_ADMIN_URL); |
|
175 | + // add additional actions for trash/restore etc. |
|
176 | + $trash_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
177 | + 'action' => 'trash_message_template', |
|
178 | + 'id' => $item->GRP_ID(), |
|
179 | + 'noheader' => true, |
|
180 | + ), EE_MSG_ADMIN_URL); |
|
181 | + // restore link |
|
182 | + $restore_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
183 | + 'action' => 'restore_message_template', |
|
184 | + 'id' => $item->GRP_ID(), |
|
185 | + 'noheader' => true, |
|
186 | + ), EE_MSG_ADMIN_URL); |
|
187 | + // delete price link |
|
188 | + $delete_lnk_url = EE_Admin_Page::add_query_args_and_nonce(array( |
|
189 | + 'action' => 'delete_message_template', |
|
190 | + 'id' => $item->GRP_ID(), |
|
191 | + 'noheader' => true, |
|
192 | + ), EE_MSG_ADMIN_URL); |
|
193 | 193 | |
194 | - if ( |
|
195 | - ! $item->get('MTP_deleted') |
|
196 | - && EE_Registry::instance()->CAP->current_user_can( |
|
197 | - 'ee_delete_message', |
|
198 | - 'espresso_messages_trash_message_template', |
|
199 | - $item->ID() |
|
200 | - ) |
|
201 | - ) { |
|
202 | - $actions['trash'] = '<a href="' |
|
203 | - . $trash_lnk_url |
|
204 | - . '" title="' |
|
205 | - . esc_attr__('Move Template Group to Trash', 'event_espresso') |
|
206 | - . '">' |
|
207 | - . esc_html__('Move to Trash', 'event_espresso') |
|
208 | - . '</a>'; |
|
209 | - } else { |
|
210 | - if ( |
|
211 | - EE_Registry::instance()->CAP->current_user_can( |
|
212 | - 'ee_delete_message', |
|
213 | - 'espresso_messages_restore_message_template', |
|
214 | - $item->ID() |
|
215 | - ) |
|
216 | - ) { |
|
217 | - $actions['restore'] = '<a href="' |
|
218 | - . $restore_lnk_url |
|
219 | - . '" title="' |
|
220 | - . esc_attr__('Restore Message Template', 'event_espresso') |
|
221 | - . '">' |
|
222 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
223 | - } |
|
194 | + if ( |
|
195 | + ! $item->get('MTP_deleted') |
|
196 | + && EE_Registry::instance()->CAP->current_user_can( |
|
197 | + 'ee_delete_message', |
|
198 | + 'espresso_messages_trash_message_template', |
|
199 | + $item->ID() |
|
200 | + ) |
|
201 | + ) { |
|
202 | + $actions['trash'] = '<a href="' |
|
203 | + . $trash_lnk_url |
|
204 | + . '" title="' |
|
205 | + . esc_attr__('Move Template Group to Trash', 'event_espresso') |
|
206 | + . '">' |
|
207 | + . esc_html__('Move to Trash', 'event_espresso') |
|
208 | + . '</a>'; |
|
209 | + } else { |
|
210 | + if ( |
|
211 | + EE_Registry::instance()->CAP->current_user_can( |
|
212 | + 'ee_delete_message', |
|
213 | + 'espresso_messages_restore_message_template', |
|
214 | + $item->ID() |
|
215 | + ) |
|
216 | + ) { |
|
217 | + $actions['restore'] = '<a href="' |
|
218 | + . $restore_lnk_url |
|
219 | + . '" title="' |
|
220 | + . esc_attr__('Restore Message Template', 'event_espresso') |
|
221 | + . '">' |
|
222 | + . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
223 | + } |
|
224 | 224 | |
225 | - if ( |
|
226 | - $this->_view === 'trashed' |
|
227 | - && EE_Registry::instance()->CAP->current_user_can( |
|
228 | - 'ee_delete_message', |
|
229 | - 'espresso_messages_delete_message_template', |
|
230 | - $item->ID() |
|
231 | - ) |
|
232 | - ) { |
|
233 | - $actions['delete'] = '<a href="' |
|
234 | - . $delete_lnk_url |
|
235 | - . '" title="' |
|
236 | - . esc_attr__('Delete Template Group Permanently', 'event_espresso') |
|
237 | - . '">' |
|
238 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
239 | - . '</a>'; |
|
240 | - } |
|
241 | - } |
|
242 | - return $actions; |
|
243 | - } |
|
225 | + if ( |
|
226 | + $this->_view === 'trashed' |
|
227 | + && EE_Registry::instance()->CAP->current_user_can( |
|
228 | + 'ee_delete_message', |
|
229 | + 'espresso_messages_delete_message_template', |
|
230 | + $item->ID() |
|
231 | + ) |
|
232 | + ) { |
|
233 | + $actions['delete'] = '<a href="' |
|
234 | + . $delete_lnk_url |
|
235 | + . '" title="' |
|
236 | + . esc_attr__('Delete Template Group Permanently', 'event_espresso') |
|
237 | + . '">' |
|
238 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
239 | + . '</a>'; |
|
240 | + } |
|
241 | + } |
|
242 | + return $actions; |
|
243 | + } |
|
244 | 244 | |
245 | 245 | |
246 | - /** |
|
247 | - * Generate dropdown filter select input for messengers |
|
248 | - * |
|
249 | - * @param bool $global |
|
250 | - * @return string |
|
251 | - * @throws EE_Error |
|
252 | - */ |
|
253 | - protected function _get_messengers_dropdown_filter($global = true) |
|
254 | - { |
|
255 | - return parent::_get_messengers_dropdown_filter(false); |
|
256 | - } |
|
246 | + /** |
|
247 | + * Generate dropdown filter select input for messengers |
|
248 | + * |
|
249 | + * @param bool $global |
|
250 | + * @return string |
|
251 | + * @throws EE_Error |
|
252 | + */ |
|
253 | + protected function _get_messengers_dropdown_filter($global = true) |
|
254 | + { |
|
255 | + return parent::_get_messengers_dropdown_filter(false); |
|
256 | + } |
|
257 | 257 | |
258 | 258 | |
259 | - /** |
|
260 | - * Generate dropdown filter select input for message types |
|
261 | - * |
|
262 | - * @param bool $global |
|
263 | - * @return string |
|
264 | - * @throws EE_Error |
|
265 | - */ |
|
266 | - protected function _get_message_types_dropdown_filter($global = true) |
|
267 | - { |
|
268 | - return parent::_get_message_types_dropdown_filter(false); |
|
269 | - } |
|
259 | + /** |
|
260 | + * Generate dropdown filter select input for message types |
|
261 | + * |
|
262 | + * @param bool $global |
|
263 | + * @return string |
|
264 | + * @throws EE_Error |
|
265 | + */ |
|
266 | + protected function _get_message_types_dropdown_filter($global = true) |
|
267 | + { |
|
268 | + return parent::_get_message_types_dropdown_filter(false); |
|
269 | + } |
|
270 | 270 | } |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | */ |
100 | 100 | public function column_name($item) |
101 | 101 | { |
102 | - return '<p>' . $item->name() . '</p>'; |
|
102 | + return '<p>'.$item->name().'</p>'; |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | |
@@ -137,7 +137,7 @@ discard block |
||
137 | 137 | protected function _add_view_counts() |
138 | 138 | { |
139 | 139 | foreach ($this->_views as $view => $args) { |
140 | - $this->_views[ $view ]['count'] = $this->get_admin_page()->get_message_templates( |
|
140 | + $this->_views[$view]['count'] = $this->get_admin_page()->get_message_templates( |
|
141 | 141 | $this->_per_page, |
142 | 142 | $view, |
143 | 143 | true, |
@@ -219,7 +219,7 @@ discard block |
||
219 | 219 | . '" title="' |
220 | 220 | . esc_attr__('Restore Message Template', 'event_espresso') |
221 | 221 | . '">' |
222 | - . esc_html__('Restore', 'event_espresso') . '</a>'; |
|
222 | + . esc_html__('Restore', 'event_espresso').'</a>'; |
|
223 | 223 | } |
224 | 224 | |
225 | 225 | if ( |
@@ -47,7 +47,7 @@ |
||
47 | 47 | /** |
48 | 48 | * This retrieves any EE_Message_Template_Group in the repo by its ID. |
49 | 49 | * |
50 | - * @param $GRP_ID |
|
50 | + * @param integer $GRP_ID |
|
51 | 51 | * @return EE_Message_Template_Group | null |
52 | 52 | */ |
53 | 53 | public function get_by_ID($GRP_ID) |
@@ -14,115 +14,115 @@ |
||
14 | 14 | { |
15 | 15 | |
16 | 16 | |
17 | - /** |
|
18 | - * EE_Message_Template_Group_Collection constructor. |
|
19 | - */ |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - $this->interface = 'EE_Message_Template_Group'; |
|
23 | - } |
|
17 | + /** |
|
18 | + * EE_Message_Template_Group_Collection constructor. |
|
19 | + */ |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + $this->interface = 'EE_Message_Template_Group'; |
|
23 | + } |
|
24 | 24 | |
25 | 25 | |
26 | - /** |
|
27 | - * Adds the Message Template Group object to the repository. |
|
28 | - * |
|
29 | - * @param $message_template_group |
|
30 | - * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
31 | - * indexing the template by key. If this template is shared among multiple events then |
|
32 | - * include the events as an array. |
|
33 | - * @return bool |
|
34 | - */ |
|
35 | - public function add($message_template_group, $EVT_ID = array()) |
|
36 | - { |
|
37 | - $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
38 | - if ($message_template_group instanceof $this->interface) { |
|
39 | - $data['key'] = $this->getKey( |
|
40 | - $message_template_group->messenger(), |
|
41 | - $message_template_group->message_type(), |
|
42 | - $EVT_ID |
|
43 | - ); |
|
44 | - return parent::add($message_template_group, $data); |
|
45 | - } |
|
46 | - return false; |
|
47 | - } |
|
26 | + /** |
|
27 | + * Adds the Message Template Group object to the repository. |
|
28 | + * |
|
29 | + * @param $message_template_group |
|
30 | + * @param array|int $EVT_ID Some templates are specific to EVT, so this is provided as a way of |
|
31 | + * indexing the template by key. If this template is shared among multiple events then |
|
32 | + * include the events as an array. |
|
33 | + * @return bool |
|
34 | + */ |
|
35 | + public function add($message_template_group, $EVT_ID = array()) |
|
36 | + { |
|
37 | + $EVT_ID = is_array($EVT_ID) ? $EVT_ID : (array) $EVT_ID; |
|
38 | + if ($message_template_group instanceof $this->interface) { |
|
39 | + $data['key'] = $this->getKey( |
|
40 | + $message_template_group->messenger(), |
|
41 | + $message_template_group->message_type(), |
|
42 | + $EVT_ID |
|
43 | + ); |
|
44 | + return parent::add($message_template_group, $data); |
|
45 | + } |
|
46 | + return false; |
|
47 | + } |
|
48 | 48 | |
49 | 49 | |
50 | - /** |
|
51 | - * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
52 | - * |
|
53 | - * @param $GRP_ID |
|
54 | - * @return EE_Message_Template_Group | null |
|
55 | - */ |
|
56 | - public function get_by_ID($GRP_ID) |
|
57 | - { |
|
58 | - $this->rewind(); |
|
59 | - while ($this->valid()) { |
|
60 | - if ($this->current()->ID() === $GRP_ID) { |
|
61 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
62 | - $message_template_group = $this->current(); |
|
63 | - $this->rewind(); |
|
64 | - return $message_template_group; |
|
65 | - } |
|
66 | - $this->next(); |
|
67 | - } |
|
68 | - return null; |
|
69 | - } |
|
50 | + /** |
|
51 | + * This retrieves any EE_Message_Template_Group in the repo by its ID. |
|
52 | + * |
|
53 | + * @param $GRP_ID |
|
54 | + * @return EE_Message_Template_Group | null |
|
55 | + */ |
|
56 | + public function get_by_ID($GRP_ID) |
|
57 | + { |
|
58 | + $this->rewind(); |
|
59 | + while ($this->valid()) { |
|
60 | + if ($this->current()->ID() === $GRP_ID) { |
|
61 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
62 | + $message_template_group = $this->current(); |
|
63 | + $this->rewind(); |
|
64 | + return $message_template_group; |
|
65 | + } |
|
66 | + $this->next(); |
|
67 | + } |
|
68 | + return null; |
|
69 | + } |
|
70 | 70 | |
71 | 71 | |
72 | - /** |
|
73 | - * Generates a hash used to identify a given Message Template Group. |
|
74 | - * |
|
75 | - * @param string $messenger The EE_messenger->name |
|
76 | - * @param string $message_type The EE_message_type->name |
|
77 | - * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
78 | - * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
79 | - * @return string |
|
80 | - */ |
|
81 | - public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
82 | - { |
|
83 | - $EVT_ID = (array) $EVT_ID; |
|
84 | - return $this->getKey($messenger, $message_type, $EVT_ID); |
|
85 | - } |
|
72 | + /** |
|
73 | + * Generates a hash used to identify a given Message Template Group. |
|
74 | + * |
|
75 | + * @param string $messenger The EE_messenger->name |
|
76 | + * @param string $message_type The EE_message_type->name |
|
77 | + * @param int $EVT_ID Optional. If the template is for a specific EVT then that should be included. |
|
78 | + * @deprecated 4.9.40.rc.017 Use getKey instead. |
|
79 | + * @return string |
|
80 | + */ |
|
81 | + public function get_key($messenger, $message_type, $EVT_ID = 0) |
|
82 | + { |
|
83 | + $EVT_ID = (array) $EVT_ID; |
|
84 | + return $this->getKey($messenger, $message_type, $EVT_ID); |
|
85 | + } |
|
86 | 86 | |
87 | 87 | |
88 | - /** |
|
89 | - * Generates a hash used to identify a given Message Template Group |
|
90 | - * @param string $messenger The EE_messenger->name |
|
91 | - * @param string $message_type The EE_message_type->name |
|
92 | - * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
93 | - * be included. |
|
94 | - * @since 4.9.40.rc.017 |
|
95 | - * @return string |
|
96 | - */ |
|
97 | - public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
98 | - { |
|
99 | - sort($EVT_ID); |
|
100 | - $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
102 | - } |
|
88 | + /** |
|
89 | + * Generates a hash used to identify a given Message Template Group |
|
90 | + * @param string $messenger The EE_messenger->name |
|
91 | + * @param string $message_type The EE_message_type->name |
|
92 | + * @param array $EVT_ID Optional. If the template is for a specific EVT_ID (or events) then that should |
|
93 | + * be included. |
|
94 | + * @since 4.9.40.rc.017 |
|
95 | + * @return string |
|
96 | + */ |
|
97 | + public function getKey($messenger, $message_type, array $EVT_ID = array()) |
|
98 | + { |
|
99 | + sort($EVT_ID); |
|
100 | + $EVT_ID = implode(',', array_unique($EVT_ID)); |
|
101 | + return md5($messenger . $message_type . $EVT_ID); |
|
102 | + } |
|
103 | 103 | |
104 | 104 | |
105 | - /** |
|
106 | - * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
107 | - * the given string. |
|
108 | - * |
|
109 | - * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
110 | - * @return null|EE_Message_Template_Group |
|
111 | - */ |
|
112 | - public function get_by_key($key) |
|
113 | - { |
|
114 | - $this->rewind(); |
|
115 | - while ($this->valid()) { |
|
116 | - $data = $this->getInfo(); |
|
117 | - if (isset($data['key']) && $data['key'] === $key) { |
|
118 | - /** @var EE_Message_Template_Group $message_template_group */ |
|
119 | - $message_template_group = $this->current(); |
|
120 | - $this->rewind(); |
|
121 | - return $message_template_group; |
|
122 | - } |
|
123 | - $this->next(); |
|
124 | - } |
|
125 | - return null; |
|
126 | - } |
|
105 | + /** |
|
106 | + * This returns a saved EE_Message_Template_Group object if there is one in the repository indexed by a key matching |
|
107 | + * the given string. |
|
108 | + * |
|
109 | + * @param string $key @see EE_Message_Template_Group::get_key() to setup a key formatted for searching. |
|
110 | + * @return null|EE_Message_Template_Group |
|
111 | + */ |
|
112 | + public function get_by_key($key) |
|
113 | + { |
|
114 | + $this->rewind(); |
|
115 | + while ($this->valid()) { |
|
116 | + $data = $this->getInfo(); |
|
117 | + if (isset($data['key']) && $data['key'] === $key) { |
|
118 | + /** @var EE_Message_Template_Group $message_template_group */ |
|
119 | + $message_template_group = $this->current(); |
|
120 | + $this->rewind(); |
|
121 | + return $message_template_group; |
|
122 | + } |
|
123 | + $this->next(); |
|
124 | + } |
|
125 | + return null; |
|
126 | + } |
|
127 | 127 | |
128 | 128 | } |
@@ -98,7 +98,7 @@ |
||
98 | 98 | { |
99 | 99 | sort($EVT_ID); |
100 | 100 | $EVT_ID = implode(',', array_unique($EVT_ID)); |
101 | - return md5($messenger . $message_type . $EVT_ID); |
|
101 | + return md5($messenger.$message_type.$EVT_ID); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | * can_use_espresso_conditionals |
131 | 131 | * tests whether the Espresso Conditional tags like is_espresso_event_single() can be called |
132 | 132 | * |
133 | - * @param $conditional_tag |
|
133 | + * @param string $conditional_tag |
|
134 | 134 | * @return bool |
135 | 135 | */ |
136 | 136 | function can_use_espresso_conditionals( $conditional_tag ) { |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | if ( ! function_exists( 'espresso_ticket_selector' )) { |
202 | 202 | /** |
203 | 203 | * espresso_ticket_selector |
204 | - * @param null $event |
|
204 | + * @param EE_Event $event |
|
205 | 205 | */ |
206 | 206 | function espresso_ticket_selector( $event = NULL ) { |
207 | 207 | if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
@@ -842,7 +842,7 @@ discard block |
||
842 | 842 | /** |
843 | 843 | * espresso_event_venues |
844 | 844 | * |
845 | - * @return array all venues related to an event |
|
845 | + * @return EE_Venue[] all venues related to an event |
|
846 | 846 | */ |
847 | 847 | function espresso_event_venues() { |
848 | 848 | return EEH_Venue_View::get_event_venues(); |
@@ -875,7 +875,7 @@ discard block |
||
875 | 875 | * |
876 | 876 | * @param int $VNU_ID optional, the venue id to check. |
877 | 877 | * |
878 | - * @return bool | null |
|
878 | + * @return null|boolean | null |
|
879 | 879 | */ |
880 | 880 | function espresso_is_venue_private( $VNU_ID = 0 ) { |
881 | 881 | return EEH_Venue_View::is_venue_private( $VNU_ID ); |
@@ -889,7 +889,7 @@ discard block |
||
889 | 889 | * returns true or false if a venue is password protected or not |
890 | 890 | * |
891 | 891 | * @param int $VNU_ID optional, the venue id to check. |
892 | - * @return string |
|
892 | + * @return boolean |
|
893 | 893 | */ |
894 | 894 | function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
895 | 895 | EE_Registry::instance()->load_helper( 'Venue_View' ); |
@@ -206,7 +206,7 @@ discard block |
||
206 | 206 | function espresso_ticket_selector( $event = NULL ) { |
207 | 207 | if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
208 | 208 | espresso_load_ticket_selector(); |
209 | - \EED_Ticket_Selector::set_definitions(); |
|
209 | + \EED_Ticket_Selector::set_definitions(); |
|
210 | 210 | echo EED_Ticket_Selector::display_ticket_selector( $event ); |
211 | 211 | } |
212 | 212 | } |
@@ -460,12 +460,12 @@ discard block |
||
460 | 460 | * @return string |
461 | 461 | */ |
462 | 462 | function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
463 | - $arguments = apply_filters( |
|
464 | - 'FHEE__espresso_list_of_event_dates__arguments', |
|
465 | - [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ] |
|
466 | - ); |
|
467 | - list($EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit) = $arguments; |
|
468 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
463 | + $arguments = apply_filters( |
|
464 | + 'FHEE__espresso_list_of_event_dates__arguments', |
|
465 | + [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ] |
|
466 | + ); |
|
467 | + list($EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit) = $arguments; |
|
468 | + $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
469 | 469 | $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
470 | 470 | $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
471 | 471 | $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
@@ -478,42 +478,42 @@ discard block |
||
478 | 478 | $html = '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">'; |
479 | 479 | foreach ( $datetimes as $datetime ) { |
480 | 480 | if ( $datetime instanceof EE_Datetime ) { |
481 | - $datetime_name = $datetime->name(); |
|
482 | - $datetime_description = $datetime->description(); |
|
483 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
484 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
485 | - $inner_html = ''; |
|
486 | - if (! empty( $datetime_name )) { |
|
487 | - $inner_html .= '<strong>' . $datetime_name . '</strong>'; |
|
488 | - $inner_html .= $add_breaks ? '<br />' : ''; |
|
489 | - } |
|
490 | - // add date |
|
491 | - $inner_html .= '<span class="dashicons dashicons-calendar"></span>'; |
|
492 | - $inner_html .= '</span><span class="ee-event-datetimes-li-daterange">'; |
|
493 | - $inner_html .= $datetime->date_range( $date_format ) . '</span><br/>'; |
|
494 | - // add time |
|
495 | - $inner_html .= '<span class="dashicons dashicons-clock"></span>'; |
|
496 | - $inner_html .= '<span class="ee-event-datetimes-li-timerange">'; |
|
497 | - $inner_html .= $datetime->time_range( $time_format ) . '</span>'; |
|
498 | - if (! empty( $datetime_description )) { |
|
499 | - $inner_html .= $add_breaks ? '<br />' : ''; |
|
500 | - $inner_html .= ' - ' . $datetime_description; |
|
501 | - } |
|
502 | - $inner_html = apply_filters( |
|
503 | - 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
504 | - $inner_html, |
|
505 | - $datetime, |
|
506 | - $arguments |
|
507 | - ); |
|
508 | - $html .= $inner_html . '</li>'; |
|
481 | + $datetime_name = $datetime->name(); |
|
482 | + $datetime_description = $datetime->description(); |
|
483 | + $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
484 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
485 | + $inner_html = ''; |
|
486 | + if (! empty( $datetime_name )) { |
|
487 | + $inner_html .= '<strong>' . $datetime_name . '</strong>'; |
|
488 | + $inner_html .= $add_breaks ? '<br />' : ''; |
|
489 | + } |
|
490 | + // add date |
|
491 | + $inner_html .= '<span class="dashicons dashicons-calendar"></span>'; |
|
492 | + $inner_html .= '</span><span class="ee-event-datetimes-li-daterange">'; |
|
493 | + $inner_html .= $datetime->date_range( $date_format ) . '</span><br/>'; |
|
494 | + // add time |
|
495 | + $inner_html .= '<span class="dashicons dashicons-clock"></span>'; |
|
496 | + $inner_html .= '<span class="ee-event-datetimes-li-timerange">'; |
|
497 | + $inner_html .= $datetime->time_range( $time_format ) . '</span>'; |
|
498 | + if (! empty( $datetime_description )) { |
|
499 | + $inner_html .= $add_breaks ? '<br />' : ''; |
|
500 | + $inner_html .= ' - ' . $datetime_description; |
|
501 | + } |
|
502 | + $inner_html = apply_filters( |
|
503 | + 'FHEE__espresso_list_of_event_dates__datetime_html', |
|
504 | + $inner_html, |
|
505 | + $datetime, |
|
506 | + $arguments |
|
507 | + ); |
|
508 | + $html .= $inner_html . '</li>'; |
|
509 | 509 | } |
510 | 510 | } |
511 | 511 | $html .= '</ul>'; |
512 | - $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime); |
|
512 | + $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime); |
|
513 | 513 | } else { |
514 | - $html = '<p><span class="dashicons dashicons-marker pink-text"></span>'; |
|
515 | - $html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' ); |
|
516 | - $html .= '</p><br/>'; |
|
514 | + $html = '<p><span class="dashicons dashicons-marker pink-text"></span>'; |
|
515 | + $html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' ); |
|
516 | + $html .= '</p><br/>'; |
|
517 | 517 | } |
518 | 518 | if ( $echo ) { |
519 | 519 | echo $html; |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | * @param int | \EE_Event $event |
15 | 15 | * @return bool |
16 | 16 | */ |
17 | -function is_espresso_event( $event = NULL ) { |
|
18 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
17 | +function is_espresso_event($event = NULL) { |
|
18 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
19 | 19 | // extract EE_Event object from passed param regardless of what it is (within reason of course) |
20 | - $event = EEH_Event_View::get_event( $event ); |
|
20 | + $event = EEH_Event_View::get_event($event); |
|
21 | 21 | // do we have a valid event ? |
22 | - return $event instanceof EE_Event ? TRUE : FALSE; |
|
22 | + return $event instanceof EE_Event ? TRUE : FALSE; |
|
23 | 23 | } |
24 | 24 | return FALSE; |
25 | 25 | } |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | * @return bool |
32 | 32 | */ |
33 | 33 | function is_espresso_event_single() { |
34 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
34 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
35 | 35 | global $wp_query; |
36 | 36 | // return conditionals set by CPTs |
37 | 37 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_single : FALSE; |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | * @return bool |
47 | 47 | */ |
48 | 48 | function is_espresso_event_archive() { |
49 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
49 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
50 | 50 | global $wp_query; |
51 | 51 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_archive : FALSE; |
52 | 52 | } |
@@ -60,7 +60,7 @@ discard block |
||
60 | 60 | * @return bool |
61 | 61 | */ |
62 | 62 | function is_espresso_event_taxonomy() { |
63 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
63 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
64 | 64 | global $wp_query; |
65 | 65 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_event_taxonomy : FALSE; |
66 | 66 | } |
@@ -74,10 +74,10 @@ discard block |
||
74 | 74 | * @param int | \EE_Venue $venue |
75 | 75 | * @return bool |
76 | 76 | */ |
77 | -function is_espresso_venue( $venue = NULL ) { |
|
78 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
77 | +function is_espresso_venue($venue = NULL) { |
|
78 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
79 | 79 | // extract EE_Venue object from passed param regardless of what it is (within reason of course) |
80 | - $venue = EEH_Venue_View::get_venue( $venue, FALSE ); |
|
80 | + $venue = EEH_Venue_View::get_venue($venue, FALSE); |
|
81 | 81 | // do we have a valid event ? |
82 | 82 | return $venue instanceof EE_Venue ? TRUE : FALSE; |
83 | 83 | } |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @return bool |
92 | 92 | */ |
93 | 93 | function is_espresso_venue_single() { |
94 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
94 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
95 | 95 | global $wp_query; |
96 | 96 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_single : FALSE; |
97 | 97 | } |
@@ -105,7 +105,7 @@ discard block |
||
105 | 105 | * @return bool |
106 | 106 | */ |
107 | 107 | function is_espresso_venue_archive() { |
108 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
108 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
109 | 109 | global $wp_query; |
110 | 110 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_archive : FALSE; |
111 | 111 | } |
@@ -119,7 +119,7 @@ discard block |
||
119 | 119 | * @return bool |
120 | 120 | */ |
121 | 121 | function is_espresso_venue_taxonomy() { |
122 | - if ( can_use_espresso_conditionals( __FUNCTION__ )) { |
|
122 | + if (can_use_espresso_conditionals(__FUNCTION__)) { |
|
123 | 123 | global $wp_query; |
124 | 124 | return $wp_query instanceof WP_Query ? $wp_query->is_espresso_venue_taxonomy : FALSE; |
125 | 125 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | * @param $conditional_tag |
134 | 134 | * @return bool |
135 | 135 | */ |
136 | -function can_use_espresso_conditionals( $conditional_tag ) { |
|
137 | - if ( ! did_action( 'AHEE__EE_System__initialize' )) { |
|
136 | +function can_use_espresso_conditionals($conditional_tag) { |
|
137 | + if ( ! did_action('AHEE__EE_System__initialize')) { |
|
138 | 138 | EE_Error::doing_it_wrong( |
139 | 139 | __FUNCTION__, |
140 | 140 | sprintf( |
141 | - esc_html__( 'The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.','event_espresso'), |
|
141 | + esc_html__('The "%s" conditional tag can not be used until after the "init" hook has run, but works best when used within a theme\'s template files.', 'event_espresso'), |
|
142 | 142 | $conditional_tag |
143 | 143 | ), |
144 | 144 | '4.4.0' |
@@ -153,13 +153,13 @@ discard block |
||
153 | 153 | |
154 | 154 | /*************************** Event Queries ***************************/ |
155 | 155 | |
156 | -if ( ! function_exists( 'espresso_get_events' )) { |
|
156 | +if ( ! function_exists('espresso_get_events')) { |
|
157 | 157 | /** |
158 | 158 | * espresso_get_events |
159 | 159 | * @param array $params |
160 | 160 | * @return array |
161 | 161 | */ |
162 | - function espresso_get_events( $params = array() ) { |
|
162 | + function espresso_get_events($params = array()) { |
|
163 | 163 | //set default params |
164 | 164 | $default_espresso_events_params = array( |
165 | 165 | 'limit' => 10, |
@@ -170,18 +170,18 @@ discard block |
||
170 | 170 | 'sort' => 'ASC' |
171 | 171 | ); |
172 | 172 | // allow the defaults to be filtered |
173 | - $default_espresso_events_params = apply_filters( 'espresso_get_events__default_espresso_events_params', $default_espresso_events_params ); |
|
173 | + $default_espresso_events_params = apply_filters('espresso_get_events__default_espresso_events_params', $default_espresso_events_params); |
|
174 | 174 | // grab params and merge with defaults, then extract |
175 | - $params = array_merge( $default_espresso_events_params, $params ); |
|
175 | + $params = array_merge($default_espresso_events_params, $params); |
|
176 | 176 | // run the query |
177 | - $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery( $params ); |
|
177 | + $events_query = new EventEspresso\core\domain\services\wp_queries\EventListQuery($params); |
|
178 | 178 | // assign results to a variable so we can return it |
179 | 179 | $events = $events_query->have_posts() ? $events_query->posts : array(); |
180 | 180 | // but first reset the query and postdata |
181 | 181 | wp_reset_query(); |
182 | 182 | wp_reset_postdata(); |
183 | 183 | EED_Events_Archive::remove_all_events_archive_filters(); |
184 | - unset( $events_query ); |
|
184 | + unset($events_query); |
|
185 | 185 | return $events; |
186 | 186 | } |
187 | 187 | } |
@@ -195,33 +195,33 @@ discard block |
||
195 | 195 | * espresso_load_ticket_selector |
196 | 196 | */ |
197 | 197 | function espresso_load_ticket_selector() { |
198 | - EE_Registry::instance()->load_file( EE_MODULES . 'ticket_selector', 'EED_Ticket_Selector', 'module' ); |
|
198 | + EE_Registry::instance()->load_file(EE_MODULES.'ticket_selector', 'EED_Ticket_Selector', 'module'); |
|
199 | 199 | } |
200 | 200 | |
201 | -if ( ! function_exists( 'espresso_ticket_selector' )) { |
|
201 | +if ( ! function_exists('espresso_ticket_selector')) { |
|
202 | 202 | /** |
203 | 203 | * espresso_ticket_selector |
204 | 204 | * @param null $event |
205 | 205 | */ |
206 | - function espresso_ticket_selector( $event = NULL ) { |
|
207 | - if ( ! apply_filters( 'FHEE_disable_espresso_ticket_selector', FALSE ) ) { |
|
206 | + function espresso_ticket_selector($event = NULL) { |
|
207 | + if ( ! apply_filters('FHEE_disable_espresso_ticket_selector', FALSE)) { |
|
208 | 208 | espresso_load_ticket_selector(); |
209 | 209 | \EED_Ticket_Selector::set_definitions(); |
210 | - echo EED_Ticket_Selector::display_ticket_selector( $event ); |
|
210 | + echo EED_Ticket_Selector::display_ticket_selector($event); |
|
211 | 211 | } |
212 | 212 | } |
213 | 213 | } |
214 | 214 | |
215 | 215 | |
216 | - if ( ! function_exists( 'espresso_view_details_btn' )) { |
|
216 | + if ( ! function_exists('espresso_view_details_btn')) { |
|
217 | 217 | /** |
218 | 218 | * espresso_view_details_btn |
219 | 219 | * @param null $event |
220 | 220 | */ |
221 | - function espresso_view_details_btn( $event = NULL ) { |
|
222 | - if ( ! apply_filters( 'FHEE_disable_espresso_view_details_btn', FALSE ) ) { |
|
221 | + function espresso_view_details_btn($event = NULL) { |
|
222 | + if ( ! apply_filters('FHEE_disable_espresso_view_details_btn', FALSE)) { |
|
223 | 223 | espresso_load_ticket_selector(); |
224 | - echo EED_Ticket_Selector::display_ticket_selector( $event, TRUE ); |
|
224 | + echo EED_Ticket_Selector::display_ticket_selector($event, TRUE); |
|
225 | 225 | } |
226 | 226 | } |
227 | 227 | } |
@@ -231,7 +231,7 @@ discard block |
||
231 | 231 | |
232 | 232 | /*************************** EEH_Event_View ***************************/ |
233 | 233 | |
234 | -if ( ! function_exists( 'espresso_load_event_list_assets' )) { |
|
234 | +if ( ! function_exists('espresso_load_event_list_assets')) { |
|
235 | 235 | /** |
236 | 236 | * espresso_load_event_list_assets |
237 | 237 | * ensures that event list styles and scripts are loaded |
@@ -240,13 +240,13 @@ discard block |
||
240 | 240 | */ |
241 | 241 | function espresso_load_event_list_assets() { |
242 | 242 | $event_list = EED_Events_Archive::instance(); |
243 | - add_action( 'AHEE__EE_System__initialize_last', array( $event_list, 'load_event_list_assets' ), 10 ); |
|
244 | - add_filter( 'FHEE_enable_default_espresso_css', '__return_true' ); |
|
243 | + add_action('AHEE__EE_System__initialize_last', array($event_list, 'load_event_list_assets'), 10); |
|
244 | + add_filter('FHEE_enable_default_espresso_css', '__return_true'); |
|
245 | 245 | } |
246 | 246 | } |
247 | 247 | |
248 | 248 | |
249 | -if ( ! function_exists( 'espresso_event_reg_button' )) { |
|
249 | +if ( ! function_exists('espresso_event_reg_button')) { |
|
250 | 250 | /** |
251 | 251 | * espresso_event_reg_button |
252 | 252 | * returns the "Register Now" button if event is active, |
@@ -258,13 +258,13 @@ discard block |
||
258 | 258 | * @param bool $EVT_ID |
259 | 259 | * @return string |
260 | 260 | */ |
261 | - function espresso_event_reg_button( $btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE ) { |
|
262 | - $event = EEH_Event_View::get_event( $EVT_ID ); |
|
263 | - if ( ! $event instanceof EE_Event ) { |
|
261 | + function espresso_event_reg_button($btn_text_if_active = NULL, $btn_text_if_inactive = FALSE, $EVT_ID = FALSE) { |
|
262 | + $event = EEH_Event_View::get_event($EVT_ID); |
|
263 | + if ( ! $event instanceof EE_Event) { |
|
264 | 264 | return; |
265 | 265 | } |
266 | 266 | $event_status = $event->get_active_status(); |
267 | - switch ( $event_status ) { |
|
267 | + switch ($event_status) { |
|
268 | 268 | case EE_Datetime::sold_out : |
269 | 269 | $btn_text = esc_html__('Sold Out', 'event_espresso'); |
270 | 270 | $class = 'ee-pink'; |
@@ -284,15 +284,15 @@ discard block |
||
284 | 284 | case EE_Datetime::upcoming : |
285 | 285 | case EE_Datetime::active : |
286 | 286 | default : |
287 | - $btn_text =! empty( $btn_text_if_active ) ? $btn_text_if_active : esc_html__( 'Register Now', 'event_espresso' ); |
|
287 | + $btn_text = ! empty($btn_text_if_active) ? $btn_text_if_active : esc_html__('Register Now', 'event_espresso'); |
|
288 | 288 | $class = 'ee-green'; |
289 | 289 | } |
290 | - if ( $event_status < 1 && ! empty( $btn_text_if_inactive )) { |
|
290 | + if ($event_status < 1 && ! empty($btn_text_if_inactive)) { |
|
291 | 291 | $btn_text = $btn_text_if_inactive; |
292 | 292 | $class = 'ee-grey'; |
293 | 293 | } |
294 | 294 | ?> |
295 | - <a class="ee-button ee-register-button <?php echo $class; ?>" href="<?php espresso_event_link_url( $EVT_ID ); ?>"<?php echo \EED_Events_Archive::link_target(); ?>> |
|
295 | + <a class="ee-button ee-register-button <?php echo $class; ?>" href="<?php espresso_event_link_url($EVT_ID); ?>"<?php echo \EED_Events_Archive::link_target(); ?>> |
|
296 | 296 | <?php echo $btn_text; ?> |
297 | 297 | </a> |
298 | 298 | <?php |
@@ -301,7 +301,7 @@ discard block |
||
301 | 301 | |
302 | 302 | |
303 | 303 | |
304 | -if ( ! function_exists( 'espresso_display_ticket_selector' )) { |
|
304 | +if ( ! function_exists('espresso_display_ticket_selector')) { |
|
305 | 305 | /** |
306 | 306 | * espresso_display_ticket_selector |
307 | 307 | * whether or not to display the Ticket Selector for an event |
@@ -309,14 +309,14 @@ discard block |
||
309 | 309 | * @param bool $EVT_ID |
310 | 310 | * @return boolean |
311 | 311 | */ |
312 | - function espresso_display_ticket_selector( $EVT_ID = FALSE ) { |
|
313 | - return EEH_Event_View::display_ticket_selector( $EVT_ID ); |
|
312 | + function espresso_display_ticket_selector($EVT_ID = FALSE) { |
|
313 | + return EEH_Event_View::display_ticket_selector($EVT_ID); |
|
314 | 314 | } |
315 | 315 | } |
316 | 316 | |
317 | 317 | |
318 | 318 | |
319 | -if ( ! function_exists( 'espresso_event_status_banner' )) { |
|
319 | +if ( ! function_exists('espresso_event_status_banner')) { |
|
320 | 320 | /** |
321 | 321 | * espresso_event_status |
322 | 322 | * returns a banner showing the event status if it is sold out, expired, or inactive |
@@ -324,13 +324,13 @@ discard block |
||
324 | 324 | * @param bool $EVT_ID |
325 | 325 | * @return string |
326 | 326 | */ |
327 | - function espresso_event_status_banner( $EVT_ID = FALSE ) { |
|
328 | - return EEH_Event_View::event_status( $EVT_ID ); |
|
327 | + function espresso_event_status_banner($EVT_ID = FALSE) { |
|
328 | + return EEH_Event_View::event_status($EVT_ID); |
|
329 | 329 | } |
330 | 330 | } |
331 | 331 | |
332 | 332 | |
333 | -if ( ! function_exists( 'espresso_event_status' )) { |
|
333 | +if ( ! function_exists('espresso_event_status')) { |
|
334 | 334 | /** |
335 | 335 | * espresso_event_status |
336 | 336 | * returns the event status if it is sold out, expired, or inactive |
@@ -339,13 +339,13 @@ discard block |
||
339 | 339 | * @param bool $echo |
340 | 340 | * @return string |
341 | 341 | */ |
342 | - function espresso_event_status( $EVT_ID = 0, $echo = TRUE ) { |
|
343 | - return EEH_Event_View::event_active_status( $EVT_ID, $echo ); |
|
342 | + function espresso_event_status($EVT_ID = 0, $echo = TRUE) { |
|
343 | + return EEH_Event_View::event_active_status($EVT_ID, $echo); |
|
344 | 344 | } |
345 | 345 | } |
346 | 346 | |
347 | 347 | |
348 | -if ( ! function_exists( 'espresso_event_categories' )) { |
|
348 | +if ( ! function_exists('espresso_event_categories')) { |
|
349 | 349 | /** |
350 | 350 | * espresso_event_categories |
351 | 351 | * returns the terms associated with an event |
@@ -355,17 +355,17 @@ discard block |
||
355 | 355 | * @param bool $echo |
356 | 356 | * @return string |
357 | 357 | */ |
358 | - function espresso_event_categories( $EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
359 | - if ( $echo ) { |
|
360 | - echo EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
358 | + function espresso_event_categories($EVT_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
359 | + if ($echo) { |
|
360 | + echo EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
361 | 361 | return ''; |
362 | 362 | } |
363 | - return EEH_Event_View::event_categories( $EVT_ID, $hide_uncategorized ); |
|
363 | + return EEH_Event_View::event_categories($EVT_ID, $hide_uncategorized); |
|
364 | 364 | } |
365 | 365 | } |
366 | 366 | |
367 | 367 | |
368 | -if ( ! function_exists( 'espresso_event_tickets_available' )) { |
|
368 | +if ( ! function_exists('espresso_event_tickets_available')) { |
|
369 | 369 | /** |
370 | 370 | * espresso_event_tickets_available |
371 | 371 | * returns the ticket types available for purchase for an event |
@@ -375,26 +375,26 @@ discard block |
||
375 | 375 | * @param bool $format |
376 | 376 | * @return string |
377 | 377 | */ |
378 | - function espresso_event_tickets_available( $EVT_ID = 0, $echo = TRUE, $format = TRUE ) { |
|
379 | - $tickets = EEH_Event_View::event_tickets_available( $EVT_ID ); |
|
380 | - if ( is_array( $tickets ) && ! empty( $tickets )) { |
|
378 | + function espresso_event_tickets_available($EVT_ID = 0, $echo = TRUE, $format = TRUE) { |
|
379 | + $tickets = EEH_Event_View::event_tickets_available($EVT_ID); |
|
380 | + if (is_array($tickets) && ! empty($tickets)) { |
|
381 | 381 | // if formatting then $html will be a string, else it will be an array of ticket objects |
382 | - $html = $format ? '<ul id="ee-event-tickets-ul-' . $EVT_ID . '" class="ee-event-tickets-ul">' : array(); |
|
383 | - foreach ( $tickets as $ticket ) { |
|
384 | - if ( $ticket instanceof EE_Ticket ) { |
|
385 | - if ( $format ) { |
|
386 | - $html .= '<li id="ee-event-tickets-li-' . $ticket->ID() . '" class="ee-event-tickets-li">'; |
|
387 | - $html .= $ticket->name() . ' ' . EEH_Template::format_currency( $ticket->get_ticket_total_with_taxes() ); |
|
382 | + $html = $format ? '<ul id="ee-event-tickets-ul-'.$EVT_ID.'" class="ee-event-tickets-ul">' : array(); |
|
383 | + foreach ($tickets as $ticket) { |
|
384 | + if ($ticket instanceof EE_Ticket) { |
|
385 | + if ($format) { |
|
386 | + $html .= '<li id="ee-event-tickets-li-'.$ticket->ID().'" class="ee-event-tickets-li">'; |
|
387 | + $html .= $ticket->name().' '.EEH_Template::format_currency($ticket->get_ticket_total_with_taxes()); |
|
388 | 388 | $html .= '</li>'; |
389 | 389 | } else { |
390 | 390 | $html[] = $ticket; |
391 | 391 | } |
392 | 392 | } |
393 | 393 | } |
394 | - if ( $format ) { |
|
394 | + if ($format) { |
|
395 | 395 | $html .= '</ul>'; |
396 | 396 | } |
397 | - if ( $echo && $format ) { |
|
397 | + if ($echo && $format) { |
|
398 | 398 | echo $html; |
399 | 399 | return ''; |
400 | 400 | } |
@@ -404,7 +404,7 @@ discard block |
||
404 | 404 | } |
405 | 405 | } |
406 | 406 | |
407 | -if ( ! function_exists( 'espresso_event_date_obj' )) { |
|
407 | +if ( ! function_exists('espresso_event_date_obj')) { |
|
408 | 408 | /** |
409 | 409 | * espresso_event_date_obj |
410 | 410 | * returns the primary date object for an event |
@@ -412,13 +412,13 @@ discard block |
||
412 | 412 | * @param bool $EVT_ID |
413 | 413 | * @return object |
414 | 414 | */ |
415 | - function espresso_event_date_obj( $EVT_ID = FALSE ) { |
|
416 | - return EEH_Event_View::get_primary_date_obj( $EVT_ID ); |
|
415 | + function espresso_event_date_obj($EVT_ID = FALSE) { |
|
416 | + return EEH_Event_View::get_primary_date_obj($EVT_ID); |
|
417 | 417 | } |
418 | 418 | } |
419 | 419 | |
420 | 420 | |
421 | -if ( ! function_exists( 'espresso_event_date' )) { |
|
421 | +if ( ! function_exists('espresso_event_date')) { |
|
422 | 422 | /** |
423 | 423 | * espresso_event_date |
424 | 424 | * returns the primary date for an event |
@@ -429,22 +429,22 @@ discard block |
||
429 | 429 | * @param bool $echo |
430 | 430 | * @return string |
431 | 431 | */ |
432 | - function espresso_event_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
433 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
434 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
435 | - $date_format = apply_filters( 'FHEE__espresso_event_date__date_format', $date_format ); |
|
436 | - $time_format = apply_filters( 'FHEE__espresso_event_date__time_format', $time_format ); |
|
437 | - if($echo){ |
|
438 | - echo EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
432 | + function espresso_event_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
433 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
434 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
435 | + $date_format = apply_filters('FHEE__espresso_event_date__date_format', $date_format); |
|
436 | + $time_format = apply_filters('FHEE__espresso_event_date__time_format', $time_format); |
|
437 | + if ($echo) { |
|
438 | + echo EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
439 | 439 | return ''; |
440 | 440 | } |
441 | - return EEH_Event_View::the_event_date( $date_format, $time_format, $EVT_ID ); |
|
441 | + return EEH_Event_View::the_event_date($date_format, $time_format, $EVT_ID); |
|
442 | 442 | |
443 | 443 | } |
444 | 444 | } |
445 | 445 | |
446 | 446 | |
447 | -if ( ! function_exists( 'espresso_list_of_event_dates' )) { |
|
447 | +if ( ! function_exists('espresso_list_of_event_dates')) { |
|
448 | 448 | /** |
449 | 449 | * espresso_list_of_event_dates |
450 | 450 | * returns a unordered list of dates for an event |
@@ -459,45 +459,45 @@ discard block |
||
459 | 459 | * @param null $limit |
460 | 460 | * @return string |
461 | 461 | */ |
462 | - function espresso_list_of_event_dates( $EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL ) { |
|
462 | + function espresso_list_of_event_dates($EVT_ID = 0, $date_format = '', $time_format = '', $echo = TRUE, $show_expired = NULL, $format = TRUE, $add_breaks = TRUE, $limit = NULL) { |
|
463 | 463 | $arguments = apply_filters( |
464 | 464 | 'FHEE__espresso_list_of_event_dates__arguments', |
465 | - [ $EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit ] |
|
465 | + [$EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit] |
|
466 | 466 | ); |
467 | 467 | list($EVT_ID, $date_format, $time_format, $echo, $show_expired, $format, $add_breaks, $limit) = $arguments; |
468 | - $datetimes = EEH_Event_View::get_all_date_obj( $EVT_ID, $show_expired, FALSE, $limit ); |
|
469 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
470 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
471 | - $date_format = apply_filters( 'FHEE__espresso_list_of_event_dates__date_format', $date_format ); |
|
472 | - $time_format = apply_filters( 'FHEE__espresso_list_of_event_dates__time_format', $time_format ); |
|
473 | - if ( ! $format ) { |
|
474 | - return apply_filters( 'FHEE__espresso_list_of_event_dates__datetimes', $datetimes ); |
|
468 | + $datetimes = EEH_Event_View::get_all_date_obj($EVT_ID, $show_expired, FALSE, $limit); |
|
469 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
470 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
471 | + $date_format = apply_filters('FHEE__espresso_list_of_event_dates__date_format', $date_format); |
|
472 | + $time_format = apply_filters('FHEE__espresso_list_of_event_dates__time_format', $time_format); |
|
473 | + if ( ! $format) { |
|
474 | + return apply_filters('FHEE__espresso_list_of_event_dates__datetimes', $datetimes); |
|
475 | 475 | } |
476 | - if ( is_array( $datetimes ) && ! empty( $datetimes )) { |
|
476 | + if (is_array($datetimes) && ! empty($datetimes)) { |
|
477 | 477 | global $post; |
478 | - $html = '<ul id="ee-event-datetimes-ul-' . $post->ID . '" class="ee-event-datetimes-ul ee-clearfix">'; |
|
479 | - foreach ( $datetimes as $datetime ) { |
|
480 | - if ( $datetime instanceof EE_Datetime ) { |
|
478 | + $html = '<ul id="ee-event-datetimes-ul-'.$post->ID.'" class="ee-event-datetimes-ul ee-clearfix">'; |
|
479 | + foreach ($datetimes as $datetime) { |
|
480 | + if ($datetime instanceof EE_Datetime) { |
|
481 | 481 | $datetime_name = $datetime->name(); |
482 | 482 | $datetime_description = $datetime->description(); |
483 | - $html .= '<li id="ee-event-datetimes-li-' . $datetime->ID(); |
|
484 | - $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-' . $datetime->get_active_status() . '">'; |
|
483 | + $html .= '<li id="ee-event-datetimes-li-'.$datetime->ID(); |
|
484 | + $html .= '" class="ee-event-datetimes-li ee-event-datetimes-li-'.$datetime->get_active_status().'">'; |
|
485 | 485 | $inner_html = ''; |
486 | - if (! empty( $datetime_name )) { |
|
487 | - $inner_html .= '<strong>' . $datetime_name . '</strong>'; |
|
486 | + if ( ! empty($datetime_name)) { |
|
487 | + $inner_html .= '<strong>'.$datetime_name.'</strong>'; |
|
488 | 488 | $inner_html .= $add_breaks ? '<br />' : ''; |
489 | 489 | } |
490 | 490 | // add date |
491 | 491 | $inner_html .= '<span class="dashicons dashicons-calendar"></span>'; |
492 | 492 | $inner_html .= '</span><span class="ee-event-datetimes-li-daterange">'; |
493 | - $inner_html .= $datetime->date_range( $date_format ) . '</span><br/>'; |
|
493 | + $inner_html .= $datetime->date_range($date_format).'</span><br/>'; |
|
494 | 494 | // add time |
495 | 495 | $inner_html .= '<span class="dashicons dashicons-clock"></span>'; |
496 | 496 | $inner_html .= '<span class="ee-event-datetimes-li-timerange">'; |
497 | - $inner_html .= $datetime->time_range( $time_format ) . '</span>'; |
|
498 | - if (! empty( $datetime_description )) { |
|
497 | + $inner_html .= $datetime->time_range($time_format).'</span>'; |
|
498 | + if ( ! empty($datetime_description)) { |
|
499 | 499 | $inner_html .= $add_breaks ? '<br />' : ''; |
500 | - $inner_html .= ' - ' . $datetime_description; |
|
500 | + $inner_html .= ' - '.$datetime_description; |
|
501 | 501 | } |
502 | 502 | $inner_html = apply_filters( |
503 | 503 | 'FHEE__espresso_list_of_event_dates__datetime_html', |
@@ -505,17 +505,17 @@ discard block |
||
505 | 505 | $datetime, |
506 | 506 | $arguments |
507 | 507 | ); |
508 | - $html .= $inner_html . '</li>'; |
|
508 | + $html .= $inner_html.'</li>'; |
|
509 | 509 | } |
510 | 510 | } |
511 | 511 | $html .= '</ul>'; |
512 | 512 | $html = apply_filters('FHEE__espresso_list_of_event_dates__html', $html, $arguments, $datetime); |
513 | 513 | } else { |
514 | 514 | $html = '<p><span class="dashicons dashicons-marker pink-text"></span>'; |
515 | - $html .= esc_html__( 'There are no upcoming dates for this event.', 'event_espresso' ); |
|
515 | + $html .= esc_html__('There are no upcoming dates for this event.', 'event_espresso'); |
|
516 | 516 | $html .= '</p><br/>'; |
517 | 517 | } |
518 | - if ( $echo ) { |
|
518 | + if ($echo) { |
|
519 | 519 | echo $html; |
520 | 520 | return ''; |
521 | 521 | } |
@@ -524,7 +524,7 @@ discard block |
||
524 | 524 | } |
525 | 525 | |
526 | 526 | |
527 | -if ( ! function_exists( 'espresso_event_end_date' )) { |
|
527 | +if ( ! function_exists('espresso_event_end_date')) { |
|
528 | 528 | /** |
529 | 529 | * espresso_event_end_date |
530 | 530 | * returns the last date for an event |
@@ -535,20 +535,20 @@ discard block |
||
535 | 535 | * @param bool $echo |
536 | 536 | * @return string |
537 | 537 | */ |
538 | - function espresso_event_end_date( $date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
539 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
540 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
541 | - $date_format = apply_filters( 'FHEE__espresso_event_end_date__date_format', $date_format ); |
|
542 | - $time_format = apply_filters( 'FHEE__espresso_event_end_date__time_format', $time_format ); |
|
543 | - if($echo){ |
|
544 | - echo EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
538 | + function espresso_event_end_date($date_format = '', $time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
539 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
540 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
541 | + $date_format = apply_filters('FHEE__espresso_event_end_date__date_format', $date_format); |
|
542 | + $time_format = apply_filters('FHEE__espresso_event_end_date__time_format', $time_format); |
|
543 | + if ($echo) { |
|
544 | + echo EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
545 | 545 | return ''; |
546 | 546 | } |
547 | - return EEH_Event_View::the_event_end_date( $date_format, $time_format, $EVT_ID ); |
|
547 | + return EEH_Event_View::the_event_end_date($date_format, $time_format, $EVT_ID); |
|
548 | 548 | } |
549 | 549 | } |
550 | 550 | |
551 | -if ( ! function_exists( 'espresso_event_date_range' )) { |
|
551 | +if ( ! function_exists('espresso_event_date_range')) { |
|
552 | 552 | /** |
553 | 553 | * espresso_event_date_range |
554 | 554 | * returns the first and last chronologically ordered dates for an event (if different) |
@@ -561,32 +561,32 @@ discard block |
||
561 | 561 | * @param bool $echo |
562 | 562 | * @return string |
563 | 563 | */ |
564 | - function espresso_event_date_range( $date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE ) { |
|
564 | + function espresso_event_date_range($date_format = '', $time_format = '', $single_date_format = '', $single_time_format = '', $EVT_ID = FALSE, $echo = TRUE) { |
|
565 | 565 | // set and filter date and time formats when a range is returned |
566 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
567 | - $date_format = apply_filters( 'FHEE__espresso_event_date_range__date_format', $date_format ); |
|
566 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
567 | + $date_format = apply_filters('FHEE__espresso_event_date_range__date_format', $date_format); |
|
568 | 568 | // get the start and end date with NO time portion |
569 | - $the_event_date = EEH_Event_View::the_earliest_event_date( $date_format, '', $EVT_ID ); |
|
570 | - $the_event_end_date = EEH_Event_View::the_latest_event_date( $date_format, '', $EVT_ID ); |
|
569 | + $the_event_date = EEH_Event_View::the_earliest_event_date($date_format, '', $EVT_ID); |
|
570 | + $the_event_end_date = EEH_Event_View::the_latest_event_date($date_format, '', $EVT_ID); |
|
571 | 571 | // now we can determine if date range spans more than one day |
572 | - if ( $the_event_date != $the_event_end_date ) { |
|
573 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
574 | - $time_format = apply_filters( 'FHEE__espresso_event_date_range__time_format', $time_format ); |
|
572 | + if ($the_event_date != $the_event_end_date) { |
|
573 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
574 | + $time_format = apply_filters('FHEE__espresso_event_date_range__time_format', $time_format); |
|
575 | 575 | $html = sprintf( |
576 | 576 | /* translators: 1: first event date, 2: last event date */ |
577 | - esc_html__( '%1$s - %2$s', 'event_espresso' ), |
|
578 | - EEH_Event_View::the_earliest_event_date( $date_format, $time_format, $EVT_ID ), |
|
579 | - EEH_Event_View::the_latest_event_date( $date_format, $time_format, $EVT_ID ) |
|
577 | + esc_html__('%1$s - %2$s', 'event_espresso'), |
|
578 | + EEH_Event_View::the_earliest_event_date($date_format, $time_format, $EVT_ID), |
|
579 | + EEH_Event_View::the_latest_event_date($date_format, $time_format, $EVT_ID) |
|
580 | 580 | ); |
581 | 581 | } else { |
582 | 582 | // set and filter date and time formats when only a single datetime is returned |
583 | - $single_date_format = ! empty( $single_date_format ) ? $single_date_format : get_option( 'date_format' ); |
|
584 | - $single_time_format = ! empty( $single_time_format ) ? $single_time_format : get_option( 'time_format' ); |
|
585 | - $single_date_format = apply_filters( 'FHEE__espresso_event_date_range__single_date_format', $single_date_format ); |
|
586 | - $single_time_format = apply_filters( 'FHEE__espresso_event_date_range__single_time_format', $single_time_format ); |
|
587 | - $html = EEH_Event_View::the_earliest_event_date( $single_date_format, $single_time_format, $EVT_ID ); |
|
583 | + $single_date_format = ! empty($single_date_format) ? $single_date_format : get_option('date_format'); |
|
584 | + $single_time_format = ! empty($single_time_format) ? $single_time_format : get_option('time_format'); |
|
585 | + $single_date_format = apply_filters('FHEE__espresso_event_date_range__single_date_format', $single_date_format); |
|
586 | + $single_time_format = apply_filters('FHEE__espresso_event_date_range__single_time_format', $single_time_format); |
|
587 | + $html = EEH_Event_View::the_earliest_event_date($single_date_format, $single_time_format, $EVT_ID); |
|
588 | 588 | } |
589 | - if ( $echo ) { |
|
589 | + if ($echo) { |
|
590 | 590 | echo $html; |
591 | 591 | return ''; |
592 | 592 | } |
@@ -594,7 +594,7 @@ discard block |
||
594 | 594 | } |
595 | 595 | } |
596 | 596 | |
597 | -if ( ! function_exists( 'espresso_next_upcoming_datetime_obj' )) { |
|
597 | +if ( ! function_exists('espresso_next_upcoming_datetime_obj')) { |
|
598 | 598 | /** |
599 | 599 | * espresso_next_upcoming_datetime_obj |
600 | 600 | * returns the next upcoming datetime object for an event |
@@ -602,12 +602,12 @@ discard block |
||
602 | 602 | * @param int $EVT_ID |
603 | 603 | * @return EE_Datetime|null |
604 | 604 | */ |
605 | - function espresso_next_upcoming_datetime_obj( $EVT_ID = 0 ) { |
|
606 | - return EEH_Event_View::get_next_upcoming_date_obj( $EVT_ID ); |
|
605 | + function espresso_next_upcoming_datetime_obj($EVT_ID = 0) { |
|
606 | + return EEH_Event_View::get_next_upcoming_date_obj($EVT_ID); |
|
607 | 607 | } |
608 | 608 | } |
609 | 609 | |
610 | -if ( ! function_exists( 'espresso_next_upcoming_datetime' ) ) { |
|
610 | +if ( ! function_exists('espresso_next_upcoming_datetime')) { |
|
611 | 611 | /** |
612 | 612 | * espresso_next_upcoming_datetime |
613 | 613 | * returns the start date and time for the next upcoming event. |
@@ -618,30 +618,30 @@ discard block |
||
618 | 618 | * @param bool $echo |
619 | 619 | * @return string |
620 | 620 | */ |
621 | - function espresso_next_upcoming_datetime( $date_format = '', $time_format = '', $EVT_ID = 0, $echo = true ) { |
|
621 | + function espresso_next_upcoming_datetime($date_format = '', $time_format = '', $EVT_ID = 0, $echo = true) { |
|
622 | 622 | |
623 | - $date_format = ! empty( $date_format ) ? $date_format : get_option( 'date_format' ); |
|
624 | - $date_format = apply_filters( 'FHEE__espresso_next_upcoming_datetime__date_format', $date_format ); |
|
623 | + $date_format = ! empty($date_format) ? $date_format : get_option('date_format'); |
|
624 | + $date_format = apply_filters('FHEE__espresso_next_upcoming_datetime__date_format', $date_format); |
|
625 | 625 | |
626 | - $time_format = ! empty( $time_format ) ? $time_format : get_option( 'time_format' ); |
|
627 | - $time_format = apply_filters( 'FHEE__espresso_next_upcoming_datetime__time_format', $time_format ); |
|
626 | + $time_format = ! empty($time_format) ? $time_format : get_option('time_format'); |
|
627 | + $time_format = apply_filters('FHEE__espresso_next_upcoming_datetime__time_format', $time_format); |
|
628 | 628 | |
629 | - $datetime_format = trim( $date_format . ' ' . $time_format); |
|
629 | + $datetime_format = trim($date_format.' '.$time_format); |
|
630 | 630 | |
631 | - $datetime = espresso_next_upcoming_datetime_obj( $EVT_ID ); |
|
631 | + $datetime = espresso_next_upcoming_datetime_obj($EVT_ID); |
|
632 | 632 | |
633 | - if( ! $datetime instanceof EE_Datetime ) { |
|
633 | + if ( ! $datetime instanceof EE_Datetime) { |
|
634 | 634 | return ''; |
635 | 635 | } |
636 | - if ( $echo ){ |
|
637 | - echo $datetime->get_i18n_datetime( 'DTT_EVT_start', $datetime_format ); |
|
636 | + if ($echo) { |
|
637 | + echo $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
638 | 638 | return ''; |
639 | 639 | } |
640 | - return $datetime->get_i18n_datetime( 'DTT_EVT_start', $datetime_format ); |
|
640 | + return $datetime->get_i18n_datetime('DTT_EVT_start', $datetime_format); |
|
641 | 641 | } |
642 | 642 | } |
643 | 643 | |
644 | -if ( ! function_exists( 'espresso_event_date_as_calendar_page' )) { |
|
644 | +if ( ! function_exists('espresso_event_date_as_calendar_page')) { |
|
645 | 645 | /** |
646 | 646 | * espresso_event_date_as_calendar_page |
647 | 647 | * returns the primary date for an event, stylized to appear as the page of a calendar |
@@ -649,15 +649,15 @@ discard block |
||
649 | 649 | * @param bool $EVT_ID |
650 | 650 | * @return string |
651 | 651 | */ |
652 | - function espresso_event_date_as_calendar_page( $EVT_ID = FALSE ) { |
|
653 | - EEH_Event_View::event_date_as_calendar_page( $EVT_ID ); |
|
652 | + function espresso_event_date_as_calendar_page($EVT_ID = FALSE) { |
|
653 | + EEH_Event_View::event_date_as_calendar_page($EVT_ID); |
|
654 | 654 | } |
655 | 655 | } |
656 | 656 | |
657 | 657 | |
658 | 658 | |
659 | 659 | |
660 | -if ( ! function_exists( 'espresso_event_link_url' )) { |
|
660 | +if ( ! function_exists('espresso_event_link_url')) { |
|
661 | 661 | /** |
662 | 662 | * espresso_event_link_url |
663 | 663 | * |
@@ -665,18 +665,18 @@ discard block |
||
665 | 665 | * @param bool $echo |
666 | 666 | * @return string |
667 | 667 | */ |
668 | - function espresso_event_link_url( $EVT_ID = 0, $echo = TRUE ) { |
|
669 | - if ( $echo ) { |
|
670 | - echo EEH_Event_View::event_link_url( $EVT_ID ); |
|
668 | + function espresso_event_link_url($EVT_ID = 0, $echo = TRUE) { |
|
669 | + if ($echo) { |
|
670 | + echo EEH_Event_View::event_link_url($EVT_ID); |
|
671 | 671 | return ''; |
672 | 672 | } |
673 | - return EEH_Event_View::event_link_url( $EVT_ID ); |
|
673 | + return EEH_Event_View::event_link_url($EVT_ID); |
|
674 | 674 | } |
675 | 675 | } |
676 | 676 | |
677 | 677 | |
678 | 678 | |
679 | -if ( ! function_exists( 'espresso_event_has_content_or_excerpt' )) { |
|
679 | +if ( ! function_exists('espresso_event_has_content_or_excerpt')) { |
|
680 | 680 | /** |
681 | 681 | * espresso_event_has_content_or_excerpt |
682 | 682 | * |
@@ -684,15 +684,15 @@ discard block |
||
684 | 684 | * @param bool $EVT_ID |
685 | 685 | * @return boolean |
686 | 686 | */ |
687 | - function espresso_event_has_content_or_excerpt( $EVT_ID = FALSE ) { |
|
688 | - return EEH_Event_View::event_has_content_or_excerpt( $EVT_ID ); |
|
687 | + function espresso_event_has_content_or_excerpt($EVT_ID = FALSE) { |
|
688 | + return EEH_Event_View::event_has_content_or_excerpt($EVT_ID); |
|
689 | 689 | } |
690 | 690 | } |
691 | 691 | |
692 | 692 | |
693 | 693 | |
694 | 694 | |
695 | -if ( ! function_exists( 'espresso_event_content_or_excerpt' )) { |
|
695 | +if ( ! function_exists('espresso_event_content_or_excerpt')) { |
|
696 | 696 | /** |
697 | 697 | * espresso_event_content_or_excerpt |
698 | 698 | * |
@@ -701,18 +701,18 @@ discard block |
||
701 | 701 | * @param bool $echo |
702 | 702 | * @return string |
703 | 703 | */ |
704 | - function espresso_event_content_or_excerpt( $num_words = 55, $more = NULL, $echo = TRUE ) { |
|
705 | - if ( $echo ) { |
|
706 | - echo EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
704 | + function espresso_event_content_or_excerpt($num_words = 55, $more = NULL, $echo = TRUE) { |
|
705 | + if ($echo) { |
|
706 | + echo EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
707 | 707 | return ''; |
708 | 708 | } |
709 | - return EEH_Event_View::event_content_or_excerpt( $num_words, $more ); |
|
709 | + return EEH_Event_View::event_content_or_excerpt($num_words, $more); |
|
710 | 710 | } |
711 | 711 | } |
712 | 712 | |
713 | 713 | |
714 | 714 | |
715 | -if ( ! function_exists( 'espresso_event_phone' )) { |
|
715 | +if ( ! function_exists('espresso_event_phone')) { |
|
716 | 716 | /** |
717 | 717 | * espresso_event_phone |
718 | 718 | * |
@@ -720,18 +720,18 @@ discard block |
||
720 | 720 | * @param bool $echo |
721 | 721 | * @return string |
722 | 722 | */ |
723 | - function espresso_event_phone( $EVT_ID = 0, $echo = TRUE ) { |
|
724 | - if ( $echo ) { |
|
725 | - echo EEH_Event_View::event_phone( $EVT_ID ); |
|
723 | + function espresso_event_phone($EVT_ID = 0, $echo = TRUE) { |
|
724 | + if ($echo) { |
|
725 | + echo EEH_Event_View::event_phone($EVT_ID); |
|
726 | 726 | return ''; |
727 | 727 | } |
728 | - return EEH_Event_View::event_phone( $EVT_ID ); |
|
728 | + return EEH_Event_View::event_phone($EVT_ID); |
|
729 | 729 | } |
730 | 730 | } |
731 | 731 | |
732 | 732 | |
733 | 733 | |
734 | -if ( ! function_exists( 'espresso_edit_event_link' )) { |
|
734 | +if ( ! function_exists('espresso_edit_event_link')) { |
|
735 | 735 | /** |
736 | 736 | * espresso_edit_event_link |
737 | 737 | * returns a link to edit an event |
@@ -740,39 +740,39 @@ discard block |
||
740 | 740 | * @param bool $echo |
741 | 741 | * @return string |
742 | 742 | */ |
743 | - function espresso_edit_event_link( $EVT_ID = 0, $echo = TRUE ) { |
|
744 | - if ( $echo ) { |
|
745 | - echo EEH_Event_View::edit_event_link( $EVT_ID ); |
|
743 | + function espresso_edit_event_link($EVT_ID = 0, $echo = TRUE) { |
|
744 | + if ($echo) { |
|
745 | + echo EEH_Event_View::edit_event_link($EVT_ID); |
|
746 | 746 | return ''; |
747 | 747 | } |
748 | - return EEH_Event_View::edit_event_link( $EVT_ID ); |
|
748 | + return EEH_Event_View::edit_event_link($EVT_ID); |
|
749 | 749 | } |
750 | 750 | } |
751 | 751 | |
752 | 752 | |
753 | -if ( ! function_exists( 'espresso_organization_name' )) { |
|
753 | +if ( ! function_exists('espresso_organization_name')) { |
|
754 | 754 | /** |
755 | 755 | * espresso_organization_name |
756 | 756 | * @param bool $echo |
757 | 757 | * @return string |
758 | 758 | */ |
759 | 759 | function espresso_organization_name($echo = TRUE) { |
760 | - if($echo){ |
|
761 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
760 | + if ($echo) { |
|
761 | + echo EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
762 | 762 | return ''; |
763 | 763 | } |
764 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'name' ); |
|
764 | + return EE_Registry::instance()->CFG->organization->get_pretty('name'); |
|
765 | 765 | } |
766 | 766 | } |
767 | 767 | |
768 | -if ( ! function_exists( 'espresso_organization_address' )) { |
|
768 | +if ( ! function_exists('espresso_organization_address')) { |
|
769 | 769 | /** |
770 | 770 | * espresso_organization_address |
771 | 771 | * @param string $type |
772 | 772 | * @return string |
773 | 773 | */ |
774 | - function espresso_organization_address( $type = 'inline' ) { |
|
775 | - if ( EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config ) { |
|
774 | + function espresso_organization_address($type = 'inline') { |
|
775 | + if (EE_Registry::instance()->CFG->organization instanceof EE_Organization_Config) { |
|
776 | 776 | $address = new EventEspresso\core\domain\entities\GenericAddress( |
777 | 777 | EE_Registry::instance()->CFG->organization->address_1, |
778 | 778 | EE_Registry::instance()->CFG->organization->address_2, |
@@ -781,129 +781,129 @@ discard block |
||
781 | 781 | EE_Registry::instance()->CFG->organization->zip, |
782 | 782 | EE_Registry::instance()->CFG->organization->CNT_ISO |
783 | 783 | ); |
784 | - return EEH_Address::format( $address, $type ); |
|
784 | + return EEH_Address::format($address, $type); |
|
785 | 785 | } |
786 | 786 | return ''; |
787 | 787 | } |
788 | 788 | } |
789 | 789 | |
790 | -if ( ! function_exists( 'espresso_organization_email' )) { |
|
790 | +if ( ! function_exists('espresso_organization_email')) { |
|
791 | 791 | /** |
792 | 792 | * espresso_organization_email |
793 | 793 | * @param bool $echo |
794 | 794 | * @return string |
795 | 795 | */ |
796 | - function espresso_organization_email( $echo = TRUE ) { |
|
797 | - if($echo){ |
|
798 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
796 | + function espresso_organization_email($echo = TRUE) { |
|
797 | + if ($echo) { |
|
798 | + echo EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
799 | 799 | return ''; |
800 | 800 | } |
801 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'email' ); |
|
801 | + return EE_Registry::instance()->CFG->organization->get_pretty('email'); |
|
802 | 802 | } |
803 | 803 | } |
804 | 804 | |
805 | -if ( ! function_exists( 'espresso_organization_logo_url' )) { |
|
805 | +if ( ! function_exists('espresso_organization_logo_url')) { |
|
806 | 806 | /** |
807 | 807 | * espresso_organization_logo_url |
808 | 808 | * @param bool $echo |
809 | 809 | * @return string |
810 | 810 | */ |
811 | - function espresso_organization_logo_url( $echo = TRUE ) { |
|
812 | - if($echo){ |
|
813 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
811 | + function espresso_organization_logo_url($echo = TRUE) { |
|
812 | + if ($echo) { |
|
813 | + echo EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
814 | 814 | return ''; |
815 | 815 | } |
816 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'logo_url' ); |
|
816 | + return EE_Registry::instance()->CFG->organization->get_pretty('logo_url'); |
|
817 | 817 | } |
818 | 818 | } |
819 | 819 | |
820 | -if ( ! function_exists( 'espresso_organization_facebook' )) { |
|
820 | +if ( ! function_exists('espresso_organization_facebook')) { |
|
821 | 821 | /** |
822 | 822 | * espresso_organization_facebook |
823 | 823 | * @param bool $echo |
824 | 824 | * @return string |
825 | 825 | */ |
826 | - function espresso_organization_facebook( $echo = TRUE ) { |
|
827 | - if($echo){ |
|
828 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
826 | + function espresso_organization_facebook($echo = TRUE) { |
|
827 | + if ($echo) { |
|
828 | + echo EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
829 | 829 | return ''; |
830 | 830 | } |
831 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'facebook' ); |
|
831 | + return EE_Registry::instance()->CFG->organization->get_pretty('facebook'); |
|
832 | 832 | } |
833 | 833 | } |
834 | 834 | |
835 | -if ( ! function_exists( 'espresso_organization_twitter' )) { |
|
835 | +if ( ! function_exists('espresso_organization_twitter')) { |
|
836 | 836 | /** |
837 | 837 | * espresso_organization_twitter |
838 | 838 | * @param bool $echo |
839 | 839 | * @return string |
840 | 840 | */ |
841 | - function espresso_organization_twitter( $echo = TRUE ) { |
|
842 | - if($echo){ |
|
843 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
841 | + function espresso_organization_twitter($echo = TRUE) { |
|
842 | + if ($echo) { |
|
843 | + echo EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
844 | 844 | return ''; |
845 | 845 | } |
846 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'twitter' ); |
|
846 | + return EE_Registry::instance()->CFG->organization->get_pretty('twitter'); |
|
847 | 847 | } |
848 | 848 | } |
849 | 849 | |
850 | -if ( ! function_exists( 'espresso_organization_linkedin' )) { |
|
850 | +if ( ! function_exists('espresso_organization_linkedin')) { |
|
851 | 851 | /** |
852 | 852 | * espresso_organization_linkedin |
853 | 853 | * @param bool $echo |
854 | 854 | * @return string |
855 | 855 | */ |
856 | - function espresso_organization_linkedin( $echo = TRUE ) { |
|
857 | - if($echo){ |
|
858 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
856 | + function espresso_organization_linkedin($echo = TRUE) { |
|
857 | + if ($echo) { |
|
858 | + echo EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
859 | 859 | return ''; |
860 | 860 | } |
861 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'linkedin' ); |
|
861 | + return EE_Registry::instance()->CFG->organization->get_pretty('linkedin'); |
|
862 | 862 | } |
863 | 863 | } |
864 | 864 | |
865 | -if ( ! function_exists( 'espresso_organization_pinterest' )) { |
|
865 | +if ( ! function_exists('espresso_organization_pinterest')) { |
|
866 | 866 | /** |
867 | 867 | * espresso_organization_pinterest |
868 | 868 | * @param bool $echo |
869 | 869 | * @return string |
870 | 870 | */ |
871 | - function espresso_organization_pinterest( $echo = TRUE ) { |
|
872 | - if($echo){ |
|
873 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
871 | + function espresso_organization_pinterest($echo = TRUE) { |
|
872 | + if ($echo) { |
|
873 | + echo EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
874 | 874 | return ''; |
875 | 875 | } |
876 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'pinterest' ); |
|
876 | + return EE_Registry::instance()->CFG->organization->get_pretty('pinterest'); |
|
877 | 877 | } |
878 | 878 | } |
879 | 879 | |
880 | -if ( ! function_exists( 'espresso_organization_google' )) { |
|
880 | +if ( ! function_exists('espresso_organization_google')) { |
|
881 | 881 | /** |
882 | 882 | * espresso_organization_google |
883 | 883 | * @param bool $echo |
884 | 884 | * @return string |
885 | 885 | */ |
886 | - function espresso_organization_google( $echo = TRUE ) { |
|
887 | - if($echo){ |
|
888 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
886 | + function espresso_organization_google($echo = TRUE) { |
|
887 | + if ($echo) { |
|
888 | + echo EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
889 | 889 | return ''; |
890 | 890 | } |
891 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'google' ); |
|
891 | + return EE_Registry::instance()->CFG->organization->get_pretty('google'); |
|
892 | 892 | } |
893 | 893 | } |
894 | 894 | |
895 | -if ( ! function_exists( 'espresso_organization_instagram' )) { |
|
895 | +if ( ! function_exists('espresso_organization_instagram')) { |
|
896 | 896 | /** |
897 | 897 | * espresso_organization_instagram |
898 | 898 | * @param bool $echo |
899 | 899 | * @return string |
900 | 900 | */ |
901 | - function espresso_organization_instagram( $echo = TRUE ) { |
|
902 | - if($echo){ |
|
903 | - echo EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
901 | + function espresso_organization_instagram($echo = TRUE) { |
|
902 | + if ($echo) { |
|
903 | + echo EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
904 | 904 | return ''; |
905 | 905 | } |
906 | - return EE_Registry::instance()->CFG->organization->get_pretty( 'instagram' ); |
|
906 | + return EE_Registry::instance()->CFG->organization->get_pretty('instagram'); |
|
907 | 907 | } |
908 | 908 | } |
909 | 909 | |
@@ -913,7 +913,7 @@ discard block |
||
913 | 913 | |
914 | 914 | |
915 | 915 | |
916 | -if ( ! function_exists( 'espresso_event_venues' )) { |
|
916 | +if ( ! function_exists('espresso_event_venues')) { |
|
917 | 917 | /** |
918 | 918 | * espresso_event_venues |
919 | 919 | * |
@@ -927,7 +927,7 @@ discard block |
||
927 | 927 | |
928 | 928 | |
929 | 929 | |
930 | -if ( ! function_exists( 'espresso_venue_id' )) { |
|
930 | +if ( ! function_exists('espresso_venue_id')) { |
|
931 | 931 | /** |
932 | 932 | * espresso_venue_name |
933 | 933 | * |
@@ -935,15 +935,15 @@ discard block |
||
935 | 935 | * @param int $EVT_ID |
936 | 936 | * @return string |
937 | 937 | */ |
938 | - function espresso_venue_id( $EVT_ID = 0 ) { |
|
939 | - $venue = EEH_Venue_View::get_venue( $EVT_ID ); |
|
938 | + function espresso_venue_id($EVT_ID = 0) { |
|
939 | + $venue = EEH_Venue_View::get_venue($EVT_ID); |
|
940 | 940 | return $venue instanceof EE_Venue ? $venue->ID() : 0; |
941 | 941 | } |
942 | 942 | } |
943 | 943 | |
944 | 944 | |
945 | 945 | |
946 | -if ( ! function_exists( 'espresso_is_venue_private' ) ) { |
|
946 | +if ( ! function_exists('espresso_is_venue_private')) { |
|
947 | 947 | /** |
948 | 948 | * Return whether a venue is private or not. |
949 | 949 | * @see EEH_Venue_View::get_venue() for more info on expected return results. |
@@ -952,45 +952,45 @@ discard block |
||
952 | 952 | * |
953 | 953 | * @return bool | null |
954 | 954 | */ |
955 | - function espresso_is_venue_private( $VNU_ID = 0 ) { |
|
956 | - return EEH_Venue_View::is_venue_private( $VNU_ID ); |
|
955 | + function espresso_is_venue_private($VNU_ID = 0) { |
|
956 | + return EEH_Venue_View::is_venue_private($VNU_ID); |
|
957 | 957 | } |
958 | 958 | } |
959 | 959 | |
960 | 960 | |
961 | 961 | |
962 | -if ( ! function_exists( 'espresso_venue_is_password_protected' ) ) { |
|
962 | +if ( ! function_exists('espresso_venue_is_password_protected')) { |
|
963 | 963 | /** |
964 | 964 | * returns true or false if a venue is password protected or not |
965 | 965 | * |
966 | 966 | * @param int $VNU_ID optional, the venue id to check. |
967 | 967 | * @return string |
968 | 968 | */ |
969 | - function espresso_venue_is_password_protected( $VNU_ID = 0 ) { |
|
970 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
971 | - return EEH_Venue_View::is_venue_password_protected( $VNU_ID ); |
|
969 | + function espresso_venue_is_password_protected($VNU_ID = 0) { |
|
970 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
971 | + return EEH_Venue_View::is_venue_password_protected($VNU_ID); |
|
972 | 972 | } |
973 | 973 | } |
974 | 974 | |
975 | 975 | |
976 | 976 | |
977 | -if ( ! function_exists( 'espresso_password_protected_venue_form' ) ) { |
|
977 | +if ( ! function_exists('espresso_password_protected_venue_form')) { |
|
978 | 978 | /** |
979 | 979 | * Returns a password form if venue is password protected. |
980 | 980 | * |
981 | 981 | * @param int $VNU_ID optional, the venue id to check. |
982 | 982 | * @return string |
983 | 983 | */ |
984 | - function espresso_password_protected_venue_form( $VNU_ID = 0 ) { |
|
985 | - EE_Registry::instance()->load_helper( 'Venue_View' ); |
|
986 | - return EEH_Venue_View::password_protected_venue_form( $VNU_ID ); |
|
984 | + function espresso_password_protected_venue_form($VNU_ID = 0) { |
|
985 | + EE_Registry::instance()->load_helper('Venue_View'); |
|
986 | + return EEH_Venue_View::password_protected_venue_form($VNU_ID); |
|
987 | 987 | } |
988 | 988 | } |
989 | 989 | |
990 | 990 | |
991 | 991 | |
992 | 992 | |
993 | -if ( ! function_exists( 'espresso_venue_name' )) { |
|
993 | +if ( ! function_exists('espresso_venue_name')) { |
|
994 | 994 | /** |
995 | 995 | * espresso_venue_name |
996 | 996 | * |
@@ -1000,19 +1000,19 @@ discard block |
||
1000 | 1000 | * @param bool $echo |
1001 | 1001 | * @return string |
1002 | 1002 | */ |
1003 | - function espresso_venue_name( $VNU_ID = 0, $link_to = 'details', $echo = TRUE ) { |
|
1004 | - if($echo){ |
|
1005 | - echo EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
1003 | + function espresso_venue_name($VNU_ID = 0, $link_to = 'details', $echo = TRUE) { |
|
1004 | + if ($echo) { |
|
1005 | + echo EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1006 | 1006 | return ''; |
1007 | 1007 | } |
1008 | - return EEH_Venue_View::venue_name( $link_to, $VNU_ID ); |
|
1008 | + return EEH_Venue_View::venue_name($link_to, $VNU_ID); |
|
1009 | 1009 | } |
1010 | 1010 | } |
1011 | 1011 | |
1012 | 1012 | |
1013 | 1013 | |
1014 | 1014 | |
1015 | -if ( ! function_exists( 'espresso_venue_link' )) { |
|
1015 | +if ( ! function_exists('espresso_venue_link')) { |
|
1016 | 1016 | /** |
1017 | 1017 | * espresso_venue_link |
1018 | 1018 | * |
@@ -1021,14 +1021,14 @@ discard block |
||
1021 | 1021 | * @param string $text |
1022 | 1022 | * @return string |
1023 | 1023 | */ |
1024 | - function espresso_venue_link( $VNU_ID = 0, $text = '' ) { |
|
1025 | - return EEH_Venue_View::venue_details_link( $VNU_ID, $text ); |
|
1024 | + function espresso_venue_link($VNU_ID = 0, $text = '') { |
|
1025 | + return EEH_Venue_View::venue_details_link($VNU_ID, $text); |
|
1026 | 1026 | } |
1027 | 1027 | } |
1028 | 1028 | |
1029 | 1029 | |
1030 | 1030 | |
1031 | -if ( ! function_exists( 'espresso_venue_description' )) { |
|
1031 | +if ( ! function_exists('espresso_venue_description')) { |
|
1032 | 1032 | /** |
1033 | 1033 | * espresso_venue_description |
1034 | 1034 | * |
@@ -1037,17 +1037,17 @@ discard block |
||
1037 | 1037 | * @param bool $echo |
1038 | 1038 | * @return string |
1039 | 1039 | */ |
1040 | - function espresso_venue_description( $VNU_ID = FALSE, $echo = TRUE ) { |
|
1041 | - if($echo){ |
|
1042 | - echo EEH_Venue_View::venue_description( $VNU_ID ); |
|
1040 | + function espresso_venue_description($VNU_ID = FALSE, $echo = TRUE) { |
|
1041 | + if ($echo) { |
|
1042 | + echo EEH_Venue_View::venue_description($VNU_ID); |
|
1043 | 1043 | return ''; |
1044 | 1044 | } |
1045 | - return EEH_Venue_View::venue_description( $VNU_ID ); |
|
1045 | + return EEH_Venue_View::venue_description($VNU_ID); |
|
1046 | 1046 | } |
1047 | 1047 | } |
1048 | 1048 | |
1049 | 1049 | |
1050 | -if ( ! function_exists( 'espresso_venue_excerpt' )) { |
|
1050 | +if ( ! function_exists('espresso_venue_excerpt')) { |
|
1051 | 1051 | /** |
1052 | 1052 | * espresso_venue_excerpt |
1053 | 1053 | * |
@@ -1056,18 +1056,18 @@ discard block |
||
1056 | 1056 | * @param bool $echo |
1057 | 1057 | * @return string |
1058 | 1058 | */ |
1059 | - function espresso_venue_excerpt( $VNU_ID = 0, $echo = TRUE ) { |
|
1060 | - if ( $echo ) { |
|
1061 | - echo EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
1059 | + function espresso_venue_excerpt($VNU_ID = 0, $echo = TRUE) { |
|
1060 | + if ($echo) { |
|
1061 | + echo EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1062 | 1062 | return ''; |
1063 | 1063 | } |
1064 | - return EEH_Venue_View::venue_excerpt( $VNU_ID ); |
|
1064 | + return EEH_Venue_View::venue_excerpt($VNU_ID); |
|
1065 | 1065 | } |
1066 | 1066 | } |
1067 | 1067 | |
1068 | 1068 | |
1069 | 1069 | |
1070 | -if ( ! function_exists( 'espresso_venue_categories' )) { |
|
1070 | +if ( ! function_exists('espresso_venue_categories')) { |
|
1071 | 1071 | /** |
1072 | 1072 | * espresso_venue_categories |
1073 | 1073 | * returns the terms associated with a venue |
@@ -1077,17 +1077,17 @@ discard block |
||
1077 | 1077 | * @param bool $echo |
1078 | 1078 | * @return string |
1079 | 1079 | */ |
1080 | - function espresso_venue_categories( $VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE ) { |
|
1081 | - if ( $echo ) { |
|
1082 | - echo EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1080 | + function espresso_venue_categories($VNU_ID = 0, $hide_uncategorized = TRUE, $echo = TRUE) { |
|
1081 | + if ($echo) { |
|
1082 | + echo EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1083 | 1083 | return ''; |
1084 | 1084 | } |
1085 | - return EEH_Venue_View::venue_categories( $VNU_ID, $hide_uncategorized ); |
|
1085 | + return EEH_Venue_View::venue_categories($VNU_ID, $hide_uncategorized); |
|
1086 | 1086 | } |
1087 | 1087 | } |
1088 | 1088 | |
1089 | 1089 | |
1090 | -if ( ! function_exists( 'espresso_venue_address' )) { |
|
1090 | +if ( ! function_exists('espresso_venue_address')) { |
|
1091 | 1091 | /** |
1092 | 1092 | * espresso_venue_address |
1093 | 1093 | * returns a formatted block of html for displaying a venue's address |
@@ -1097,17 +1097,17 @@ discard block |
||
1097 | 1097 | * @param bool $echo |
1098 | 1098 | * @return string |
1099 | 1099 | */ |
1100 | - function espresso_venue_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1101 | - if ( $echo ) { |
|
1102 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1100 | + function espresso_venue_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1101 | + if ($echo) { |
|
1102 | + echo EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1103 | 1103 | return ''; |
1104 | 1104 | } |
1105 | - return EEH_Venue_View::venue_address( $type, $VNU_ID ); |
|
1105 | + return EEH_Venue_View::venue_address($type, $VNU_ID); |
|
1106 | 1106 | } |
1107 | 1107 | } |
1108 | 1108 | |
1109 | 1109 | |
1110 | -if ( ! function_exists( 'espresso_venue_raw_address' )) { |
|
1110 | +if ( ! function_exists('espresso_venue_raw_address')) { |
|
1111 | 1111 | /** |
1112 | 1112 | * espresso_venue_address |
1113 | 1113 | * returns an UN-formatted string containing a venue's address |
@@ -1117,17 +1117,17 @@ discard block |
||
1117 | 1117 | * @param bool $echo |
1118 | 1118 | * @return string |
1119 | 1119 | */ |
1120 | - function espresso_venue_raw_address( $type = 'multiline', $VNU_ID = 0, $echo = TRUE ) { |
|
1121 | - if ( $echo ) { |
|
1122 | - echo EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1120 | + function espresso_venue_raw_address($type = 'multiline', $VNU_ID = 0, $echo = TRUE) { |
|
1121 | + if ($echo) { |
|
1122 | + echo EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1123 | 1123 | return ''; |
1124 | 1124 | } |
1125 | - return EEH_Venue_View::venue_address( $type, $VNU_ID, FALSE, FALSE ); |
|
1125 | + return EEH_Venue_View::venue_address($type, $VNU_ID, FALSE, FALSE); |
|
1126 | 1126 | } |
1127 | 1127 | } |
1128 | 1128 | |
1129 | 1129 | |
1130 | -if ( ! function_exists( 'espresso_venue_has_address' )) { |
|
1130 | +if ( ! function_exists('espresso_venue_has_address')) { |
|
1131 | 1131 | /** |
1132 | 1132 | * espresso_venue_has_address |
1133 | 1133 | * returns TRUE or FALSE if a Venue has address information |
@@ -1135,13 +1135,13 @@ discard block |
||
1135 | 1135 | * @param int $VNU_ID |
1136 | 1136 | * @return bool |
1137 | 1137 | */ |
1138 | - function espresso_venue_has_address( $VNU_ID = 0 ) { |
|
1139 | - return EEH_Venue_View::venue_has_address( $VNU_ID ); |
|
1138 | + function espresso_venue_has_address($VNU_ID = 0) { |
|
1139 | + return EEH_Venue_View::venue_has_address($VNU_ID); |
|
1140 | 1140 | } |
1141 | 1141 | } |
1142 | 1142 | |
1143 | 1143 | |
1144 | -if ( ! function_exists( 'espresso_venue_gmap' )) { |
|
1144 | +if ( ! function_exists('espresso_venue_gmap')) { |
|
1145 | 1145 | /** |
1146 | 1146 | * espresso_venue_gmap |
1147 | 1147 | * returns a google map for the venue address |
@@ -1152,17 +1152,17 @@ discard block |
||
1152 | 1152 | * @param bool $echo |
1153 | 1153 | * @return string |
1154 | 1154 | */ |
1155 | - function espresso_venue_gmap( $VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE ) { |
|
1156 | - if ( $echo ) { |
|
1157 | - echo EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1155 | + function espresso_venue_gmap($VNU_ID = 0, $map_ID = FALSE, $gmap = array(), $echo = TRUE) { |
|
1156 | + if ($echo) { |
|
1157 | + echo EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1158 | 1158 | return ''; |
1159 | 1159 | } |
1160 | - return EEH_Venue_View::venue_gmap( $VNU_ID, $map_ID, $gmap ); |
|
1160 | + return EEH_Venue_View::venue_gmap($VNU_ID, $map_ID, $gmap); |
|
1161 | 1161 | } |
1162 | 1162 | } |
1163 | 1163 | |
1164 | 1164 | |
1165 | -if ( ! function_exists( 'espresso_venue_phone' )) { |
|
1165 | +if ( ! function_exists('espresso_venue_phone')) { |
|
1166 | 1166 | /** |
1167 | 1167 | * espresso_venue_phone |
1168 | 1168 | * |
@@ -1170,18 +1170,18 @@ discard block |
||
1170 | 1170 | * @param bool $echo |
1171 | 1171 | * @return string |
1172 | 1172 | */ |
1173 | - function espresso_venue_phone( $VNU_ID = 0, $echo = TRUE ) { |
|
1174 | - if ( $echo ) { |
|
1175 | - echo EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1173 | + function espresso_venue_phone($VNU_ID = 0, $echo = TRUE) { |
|
1174 | + if ($echo) { |
|
1175 | + echo EEH_Venue_View::venue_phone($VNU_ID); |
|
1176 | 1176 | return ''; |
1177 | 1177 | } |
1178 | - return EEH_Venue_View::venue_phone( $VNU_ID ); |
|
1178 | + return EEH_Venue_View::venue_phone($VNU_ID); |
|
1179 | 1179 | } |
1180 | 1180 | } |
1181 | 1181 | |
1182 | 1182 | |
1183 | 1183 | |
1184 | -if ( ! function_exists( 'espresso_venue_website' )) { |
|
1184 | +if ( ! function_exists('espresso_venue_website')) { |
|
1185 | 1185 | /** |
1186 | 1186 | * espresso_venue_website |
1187 | 1187 | * |
@@ -1189,18 +1189,18 @@ discard block |
||
1189 | 1189 | * @param bool $echo |
1190 | 1190 | * @return string |
1191 | 1191 | */ |
1192 | - function espresso_venue_website( $VNU_ID = 0, $echo = TRUE ) { |
|
1193 | - if ( $echo ) { |
|
1194 | - echo EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1192 | + function espresso_venue_website($VNU_ID = 0, $echo = TRUE) { |
|
1193 | + if ($echo) { |
|
1194 | + echo EEH_Venue_View::venue_website_link($VNU_ID); |
|
1195 | 1195 | return ''; |
1196 | 1196 | } |
1197 | - return EEH_Venue_View::venue_website_link( $VNU_ID ); |
|
1197 | + return EEH_Venue_View::venue_website_link($VNU_ID); |
|
1198 | 1198 | } |
1199 | 1199 | } |
1200 | 1200 | |
1201 | 1201 | |
1202 | 1202 | |
1203 | -if ( ! function_exists( 'espresso_edit_venue_link' )) { |
|
1203 | +if ( ! function_exists('espresso_edit_venue_link')) { |
|
1204 | 1204 | /** |
1205 | 1205 | * espresso_edit_venue_link |
1206 | 1206 | * |
@@ -1208,12 +1208,12 @@ discard block |
||
1208 | 1208 | * @param bool $echo |
1209 | 1209 | * @return string |
1210 | 1210 | */ |
1211 | - function espresso_edit_venue_link( $VNU_ID = 0, $echo = TRUE ) { |
|
1212 | - if($echo){ |
|
1213 | - echo EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1211 | + function espresso_edit_venue_link($VNU_ID = 0, $echo = TRUE) { |
|
1212 | + if ($echo) { |
|
1213 | + echo EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1214 | 1214 | return ''; |
1215 | 1215 | } |
1216 | - return EEH_Venue_View::edit_venue_link( $VNU_ID ); |
|
1216 | + return EEH_Venue_View::edit_venue_link($VNU_ID); |
|
1217 | 1217 | } |
1218 | 1218 | } |
1219 | 1219 |
@@ -140,7 +140,7 @@ discard block |
||
140 | 140 | // with these parameters |
141 | 141 | $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
142 | 142 | // then md5 the above to control it's length, add all of our prefixes, and truncate |
143 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
143 | + return substr($this->cachePrefix().$id_prefix.'-'.md5($cache_id), 0, 182); |
|
144 | 144 | } |
145 | 145 | |
146 | 146 | |
@@ -170,9 +170,9 @@ discard block |
||
170 | 170 | return ' |
171 | 171 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
172 | 172 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
173 | - <b>' . $type . '</b><span style="color:#999"> : </span> |
|
174 | - <span>' . $cache_id . '</span> |
|
175 | - <span style="margin-left:2em;">' . __FILE__ . '</span> |
|
173 | + <b>' . $type.'</b><span style="color:#999"> : </span> |
|
174 | + <span>' . $cache_id.'</span> |
|
175 | + <span style="margin-left:2em;">' . __FILE__.'</span> |
|
176 | 176 | </p> |
177 | 177 | </div>'; |
178 | 178 | } |
@@ -16,135 +16,135 @@ discard block |
||
16 | 16 | class BasicCacheManager implements CacheManagerInterface |
17 | 17 | { |
18 | 18 | |
19 | - /** |
|
20 | - * @type string |
|
21 | - */ |
|
22 | - const CACHE_PREFIX = 'ee_cache_'; |
|
23 | - |
|
24 | - |
|
25 | - /** |
|
26 | - * @var CacheStorageInterface $cache_storage |
|
27 | - */ |
|
28 | - private $cache_storage; |
|
29 | - |
|
30 | - |
|
31 | - /** |
|
32 | - * BasicCacheManager constructor. |
|
33 | - * |
|
34 | - * @param CacheStorageInterface $cache_storage [required] |
|
35 | - */ |
|
36 | - public function __construct(CacheStorageInterface $cache_storage) |
|
37 | - { |
|
38 | - $this->cache_storage = $cache_storage; |
|
39 | - } |
|
40 | - |
|
41 | - |
|
42 | - /** |
|
43 | - * returns a string that will be prepended to all cache identifiers |
|
44 | - * |
|
45 | - * @return string |
|
46 | - */ |
|
47 | - public function cachePrefix() |
|
48 | - { |
|
49 | - return BasicCacheManager::CACHE_PREFIX; |
|
50 | - } |
|
51 | - |
|
52 | - |
|
53 | - /** |
|
54 | - * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
55 | - * May also be helpful to include an additional specific identifier, |
|
56 | - * such as a post ID as part of the $id_prefix so that individual caches |
|
57 | - * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
58 | - * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
59 | - * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
60 | - * It is advisable to use some of the actual data |
|
61 | - * that is used to generate the content being cached, |
|
62 | - * in order to guarantee that the cache id is unique for that content. |
|
63 | - * The cache id will be md5'd before usage to make it more db friendly, |
|
64 | - * and the entire cache id string will be truncated to 190 characters. |
|
65 | - * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
66 | - * necessary, |
|
67 | - * we wrap our content creation in a Closure so that it is not executed until needed. |
|
68 | - * @param int $expiration |
|
69 | - * @return Closure|mixed |
|
70 | - */ |
|
71 | - public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
72 | - { |
|
73 | - $content = ''; |
|
74 | - $expiration = absint( |
|
75 | - apply_filters( |
|
76 | - 'FHEE__CacheManager__get__cache_expiration', |
|
77 | - $expiration, |
|
78 | - $id_prefix, |
|
79 | - $cache_id |
|
80 | - ) |
|
81 | - ); |
|
82 | - $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
83 | - // is caching enabled for this content ? |
|
84 | - if ($expiration) { |
|
85 | - $content = $this->cache_storage->get($cache_id); |
|
86 | - } |
|
87 | - // any existing content ? |
|
88 | - if (empty($content)) { |
|
89 | - // nope! let's generate some new stuff |
|
90 | - $content = $callback(); |
|
91 | - // save the new content if caching is enabled |
|
92 | - if ($expiration) { |
|
93 | - $this->cache_storage->add($cache_id, $content, $expiration); |
|
94 | - if (EE_DEBUG) { |
|
95 | - $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
96 | - } |
|
97 | - } |
|
98 | - } else { |
|
99 | - if (EE_DEBUG) { |
|
100 | - $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
101 | - } |
|
102 | - } |
|
103 | - return $content; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * Generates a unique identifier string for the cache |
|
109 | - * |
|
110 | - * @param string $id_prefix [required] see BasicCacheManager::get() |
|
111 | - * @param string $cache_id [required] see BasicCacheManager::get() |
|
112 | - * @return string |
|
113 | - */ |
|
114 | - private function generateCacheIdentifier($id_prefix, $cache_id) |
|
115 | - { |
|
116 | - // let's make the cached content unique for this "page" |
|
117 | - $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
118 | - // with these parameters |
|
119 | - $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
120 | - // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
121 | - return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
122 | - } |
|
123 | - |
|
124 | - |
|
125 | - /** |
|
126 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
127 | - * or a specific ID targeting a single cache item |
|
128 | - * @return void |
|
129 | - */ |
|
130 | - public function clear($cache_id) |
|
131 | - { |
|
132 | - // ensure incoming arg is in an array |
|
133 | - $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
134 | - // delete corresponding transients for the supplied id prefix |
|
135 | - $this->cache_storage->deleteMany($cache_id); |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
141 | - * or a specific ID targeting a single cache item |
|
142 | - * @param string $type |
|
143 | - * @return string |
|
144 | - */ |
|
145 | - private function displayCacheNotice($cache_id, $type) |
|
146 | - { |
|
147 | - return ' |
|
19 | + /** |
|
20 | + * @type string |
|
21 | + */ |
|
22 | + const CACHE_PREFIX = 'ee_cache_'; |
|
23 | + |
|
24 | + |
|
25 | + /** |
|
26 | + * @var CacheStorageInterface $cache_storage |
|
27 | + */ |
|
28 | + private $cache_storage; |
|
29 | + |
|
30 | + |
|
31 | + /** |
|
32 | + * BasicCacheManager constructor. |
|
33 | + * |
|
34 | + * @param CacheStorageInterface $cache_storage [required] |
|
35 | + */ |
|
36 | + public function __construct(CacheStorageInterface $cache_storage) |
|
37 | + { |
|
38 | + $this->cache_storage = $cache_storage; |
|
39 | + } |
|
40 | + |
|
41 | + |
|
42 | + /** |
|
43 | + * returns a string that will be prepended to all cache identifiers |
|
44 | + * |
|
45 | + * @return string |
|
46 | + */ |
|
47 | + public function cachePrefix() |
|
48 | + { |
|
49 | + return BasicCacheManager::CACHE_PREFIX; |
|
50 | + } |
|
51 | + |
|
52 | + |
|
53 | + /** |
|
54 | + * @param string $id_prefix [required] Prepended to all cache IDs. Can be helpful in finding specific cache types. |
|
55 | + * May also be helpful to include an additional specific identifier, |
|
56 | + * such as a post ID as part of the $id_prefix so that individual caches |
|
57 | + * can be found and/or cleared. ex: "venue-28", or "shortcode-156". |
|
58 | + * BasicCacheManager::CACHE_PREFIX will also be prepended to the cache id. |
|
59 | + * @param string $cache_id [required] Additional identifying details that make this cache unique. |
|
60 | + * It is advisable to use some of the actual data |
|
61 | + * that is used to generate the content being cached, |
|
62 | + * in order to guarantee that the cache id is unique for that content. |
|
63 | + * The cache id will be md5'd before usage to make it more db friendly, |
|
64 | + * and the entire cache id string will be truncated to 190 characters. |
|
65 | + * @param Closure $callback [required] since the point of caching is to avoid generating content when not |
|
66 | + * necessary, |
|
67 | + * we wrap our content creation in a Closure so that it is not executed until needed. |
|
68 | + * @param int $expiration |
|
69 | + * @return Closure|mixed |
|
70 | + */ |
|
71 | + public function get($id_prefix, $cache_id, Closure $callback, $expiration = HOUR_IN_SECONDS) |
|
72 | + { |
|
73 | + $content = ''; |
|
74 | + $expiration = absint( |
|
75 | + apply_filters( |
|
76 | + 'FHEE__CacheManager__get__cache_expiration', |
|
77 | + $expiration, |
|
78 | + $id_prefix, |
|
79 | + $cache_id |
|
80 | + ) |
|
81 | + ); |
|
82 | + $cache_id = $this->generateCacheIdentifier($id_prefix, $cache_id); |
|
83 | + // is caching enabled for this content ? |
|
84 | + if ($expiration) { |
|
85 | + $content = $this->cache_storage->get($cache_id); |
|
86 | + } |
|
87 | + // any existing content ? |
|
88 | + if (empty($content)) { |
|
89 | + // nope! let's generate some new stuff |
|
90 | + $content = $callback(); |
|
91 | + // save the new content if caching is enabled |
|
92 | + if ($expiration) { |
|
93 | + $this->cache_storage->add($cache_id, $content, $expiration); |
|
94 | + if (EE_DEBUG) { |
|
95 | + $content .= $this->displayCacheNotice($cache_id, 'REFRESH CACHE'); |
|
96 | + } |
|
97 | + } |
|
98 | + } else { |
|
99 | + if (EE_DEBUG) { |
|
100 | + $content .= $this->displayCacheNotice($cache_id, 'CACHED CONTENT'); |
|
101 | + } |
|
102 | + } |
|
103 | + return $content; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * Generates a unique identifier string for the cache |
|
109 | + * |
|
110 | + * @param string $id_prefix [required] see BasicCacheManager::get() |
|
111 | + * @param string $cache_id [required] see BasicCacheManager::get() |
|
112 | + * @return string |
|
113 | + */ |
|
114 | + private function generateCacheIdentifier($id_prefix, $cache_id) |
|
115 | + { |
|
116 | + // let's make the cached content unique for this "page" |
|
117 | + $cache_id .= filter_input(INPUT_SERVER, 'REQUEST_URI', FILTER_SANITIZE_URL); |
|
118 | + // with these parameters |
|
119 | + $cache_id .= filter_input(INPUT_SERVER, 'QUERY_STRING', FILTER_SANITIZE_URL); |
|
120 | + // then md5 the above to control it's length, add all of our prefixes, and truncate |
|
121 | + return substr($this->cachePrefix() . $id_prefix . '-' . md5($cache_id), 0, 182); |
|
122 | + } |
|
123 | + |
|
124 | + |
|
125 | + /** |
|
126 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
127 | + * or a specific ID targeting a single cache item |
|
128 | + * @return void |
|
129 | + */ |
|
130 | + public function clear($cache_id) |
|
131 | + { |
|
132 | + // ensure incoming arg is in an array |
|
133 | + $cache_id = is_array($cache_id) ? $cache_id : array($cache_id); |
|
134 | + // delete corresponding transients for the supplied id prefix |
|
135 | + $this->cache_storage->deleteMany($cache_id); |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @param array|string $cache_id [required] Could be an ID prefix affecting many caches |
|
141 | + * or a specific ID targeting a single cache item |
|
142 | + * @param string $type |
|
143 | + * @return string |
|
144 | + */ |
|
145 | + private function displayCacheNotice($cache_id, $type) |
|
146 | + { |
|
147 | + return ' |
|
148 | 148 | <div class="ee-cached-content-notice" style="position:fixed; bottom:0; left: 0;"> |
149 | 149 | <p style="font-size:9px;font-weight:normal;color:#666;line-height: 12px;margin:0 0 3px 5px"> |
150 | 150 | <b>' . $type . '</b><span style="color:#999"> : </span> |
@@ -152,5 +152,5 @@ discard block |
||
152 | 152 | <span style="margin-left:2em;">' . __FILE__ . '</span> |
153 | 153 | </p> |
154 | 154 | </div>'; |
155 | - } |
|
155 | + } |
|
156 | 156 | } |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | $this->_form_section->html_id(), |
19 | 19 | $this->_form_section->html_class(), |
20 | 20 | $this->_form_section->html_style() |
21 | - ) . EEH_HTML::tbody(); |
|
21 | + ).EEH_HTML::tbody(); |
|
22 | 22 | } |
23 | 23 | |
24 | 24 | |
@@ -31,7 +31,7 @@ discard block |
||
31 | 31 | */ |
32 | 32 | public function layout_form_end($additional_args = array()) |
33 | 33 | { |
34 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
34 | + return EEH_HTML::tbodyx().EEH_HTML::tablex($this->_form_section->html_id()); |
|
35 | 35 | } |
36 | 36 | |
37 | 37 | |
@@ -50,11 +50,11 @@ discard block |
||
50 | 50 | } else { |
51 | 51 | $html_for_input = $input->get_html_for_input(); |
52 | 52 | $html_for_input .= $input->get_html_for_errors() != '' |
53 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
53 | + ? EEH_HTML::nl().$input->get_html_for_errors() |
|
54 | 54 | : ''; |
55 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
55 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl().$input->get_html_for_help() : ''; |
|
56 | 56 | $html .= EEH_HTML::tr( |
57 | - EEH_HTML::th($input->get_html_for_label()) . |
|
57 | + EEH_HTML::th($input->get_html_for_label()). |
|
58 | 58 | EEH_HTML::td($html_for_input) |
59 | 59 | ); |
60 | 60 | } |
@@ -3,82 +3,82 @@ |
||
3 | 3 | class EE_Two_Column_Layout extends EE_Form_Section_Layout_Base |
4 | 4 | { |
5 | 5 | |
6 | - /** |
|
7 | - * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
8 | - * |
|
9 | - * @param array $additional_args |
|
10 | - * @return string |
|
11 | - */ |
|
12 | - public function layout_form_begin($additional_args = array()) |
|
13 | - { |
|
14 | - return $this->display_form_wide_errors() |
|
15 | - . EEH_HTML::table( |
|
16 | - '', |
|
17 | - $this->_form_section->html_id(), |
|
18 | - $this->_form_section->html_class(), |
|
19 | - $this->_form_section->html_style() |
|
20 | - ) . EEH_HTML::tbody(); |
|
21 | - } |
|
6 | + /** |
|
7 | + * Should be used to start teh form section (Eg a table tag, or a div tag, etc.) |
|
8 | + * |
|
9 | + * @param array $additional_args |
|
10 | + * @return string |
|
11 | + */ |
|
12 | + public function layout_form_begin($additional_args = array()) |
|
13 | + { |
|
14 | + return $this->display_form_wide_errors() |
|
15 | + . EEH_HTML::table( |
|
16 | + '', |
|
17 | + $this->_form_section->html_id(), |
|
18 | + $this->_form_section->html_class(), |
|
19 | + $this->_form_section->html_style() |
|
20 | + ) . EEH_HTML::tbody(); |
|
21 | + } |
|
22 | 22 | |
23 | 23 | |
24 | 24 | |
25 | - /** |
|
26 | - * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
27 | - * |
|
28 | - * @param array $additional_args |
|
29 | - * @return string |
|
30 | - */ |
|
31 | - public function layout_form_end($additional_args = array()) |
|
32 | - { |
|
33 | - return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
34 | - } |
|
25 | + /** |
|
26 | + * Should be used to end the form section (eg a /table tag, or a /div tag, etc) |
|
27 | + * |
|
28 | + * @param array $additional_args |
|
29 | + * @return string |
|
30 | + */ |
|
31 | + public function layout_form_end($additional_args = array()) |
|
32 | + { |
|
33 | + return EEH_HTML::tbodyx() . EEH_HTML::tablex($this->_form_section->html_id()); |
|
34 | + } |
|
35 | 35 | |
36 | 36 | |
37 | 37 | |
38 | - /** |
|
39 | - * Lays out the row for the input, including label and errors |
|
40 | - * |
|
41 | - * @param EE_Form_Input_Base $input |
|
42 | - * @return string |
|
43 | - */ |
|
44 | - public function layout_input($input) |
|
45 | - { |
|
46 | - $html = ''; |
|
47 | - if ($input instanceof EE_Hidden_Input) { |
|
48 | - $html .= $input->get_html_for_input(); |
|
49 | - } else { |
|
50 | - $html_for_input = $input->get_html_for_input(); |
|
51 | - $html_for_input .= $input->get_html_for_errors() != '' |
|
52 | - ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
53 | - : ''; |
|
54 | - $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
55 | - $html .= EEH_HTML::tr( |
|
56 | - EEH_HTML::th($input->get_html_for_label()) . |
|
57 | - EEH_HTML::td($html_for_input) |
|
58 | - ); |
|
59 | - } |
|
60 | - return $html; |
|
61 | - } |
|
38 | + /** |
|
39 | + * Lays out the row for the input, including label and errors |
|
40 | + * |
|
41 | + * @param EE_Form_Input_Base $input |
|
42 | + * @return string |
|
43 | + */ |
|
44 | + public function layout_input($input) |
|
45 | + { |
|
46 | + $html = ''; |
|
47 | + if ($input instanceof EE_Hidden_Input) { |
|
48 | + $html .= $input->get_html_for_input(); |
|
49 | + } else { |
|
50 | + $html_for_input = $input->get_html_for_input(); |
|
51 | + $html_for_input .= $input->get_html_for_errors() != '' |
|
52 | + ? EEH_HTML::nl() . $input->get_html_for_errors() |
|
53 | + : ''; |
|
54 | + $html_for_input .= $input->get_html_for_help() != '' ? EEH_HTML::nl() . $input->get_html_for_help() : ''; |
|
55 | + $html .= EEH_HTML::tr( |
|
56 | + EEH_HTML::th($input->get_html_for_label()) . |
|
57 | + EEH_HTML::td($html_for_input) |
|
58 | + ); |
|
59 | + } |
|
60 | + return $html; |
|
61 | + } |
|
62 | 62 | |
63 | 63 | |
64 | 64 | |
65 | - /** |
|
66 | - * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in |
|
67 | - * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout, |
|
68 | - * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the |
|
69 | - * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table. |
|
70 | - * |
|
71 | - * @param EE_Form_Section_Proper $form_section |
|
72 | - * @return string |
|
73 | - */ |
|
74 | - public function layout_subsection($form_section) |
|
75 | - { |
|
76 | - if ( |
|
77 | - $form_section instanceof EE_Form_Section_Proper |
|
78 | - || $form_section instanceof EE_Form_Section_HTML |
|
79 | - ) { |
|
80 | - return EEH_HTML::no_row($form_section->get_html()); |
|
81 | - } |
|
82 | - return ''; |
|
83 | - } |
|
65 | + /** |
|
66 | + * Lays out a row for the subsection. Please note that if you have a subsection which you don't want wrapped in |
|
67 | + * a tr and td with a colspan=2, you should use a different layout strategy, like EE_No_Layout, EE_Template_Layout, |
|
68 | + * or EE_Div_Per_Section_Layout, and create subsections using EE_Two_Column_Layout for everywhere you want the |
|
69 | + * two-column layout, and then other sub-sections can be outside the EE_Two_Column_Layout table. |
|
70 | + * |
|
71 | + * @param EE_Form_Section_Proper $form_section |
|
72 | + * @return string |
|
73 | + */ |
|
74 | + public function layout_subsection($form_section) |
|
75 | + { |
|
76 | + if ( |
|
77 | + $form_section instanceof EE_Form_Section_Proper |
|
78 | + || $form_section instanceof EE_Form_Section_HTML |
|
79 | + ) { |
|
80 | + return EEH_HTML::no_row($form_section->get_html()); |
|
81 | + } |
|
82 | + return ''; |
|
83 | + } |
|
84 | 84 | } |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | * |
103 | 103 | * @abstract |
104 | 104 | * @access protected |
105 | - * @return array |
|
105 | + * @return string[] |
|
106 | 106 | */ |
107 | 107 | protected function _get_table_filters() |
108 | 108 | { |
@@ -265,7 +265,7 @@ discard block |
||
265 | 265 | * column_TXN_paid |
266 | 266 | * |
267 | 267 | * @param \EE_Transaction $transaction |
268 | - * @return mixed|string |
|
268 | + * @return string |
|
269 | 269 | * @throws \EE_Error |
270 | 270 | */ |
271 | 271 | public function column_TXN_paid(EE_Transaction $transaction) |
@@ -15,121 +15,121 @@ discard block |
||
15 | 15 | class EE_Admin_Transactions_List_Table extends EE_Admin_List_Table |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var SessionLifespan $session_lifespan |
|
20 | - */ |
|
21 | - private $session_lifespan; |
|
22 | - |
|
23 | - private $_status; |
|
24 | - |
|
25 | - |
|
26 | - /** |
|
27 | - * @param \Transactions_Admin_Page $admin_page |
|
28 | - * @param SessionLifespan $lifespan |
|
29 | - */ |
|
30 | - public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan) |
|
31 | - { |
|
32 | - parent::__construct($admin_page); |
|
33 | - $this->session_lifespan = $lifespan; |
|
34 | - $this->_status = $this->_admin_page->get_transaction_status_array(); |
|
35 | - } |
|
36 | - |
|
37 | - |
|
38 | - /** |
|
39 | - *_setup_data |
|
40 | - */ |
|
41 | - protected function _setup_data() |
|
42 | - { |
|
43 | - $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
44 | - $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
45 | - $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status); |
|
46 | - } |
|
47 | - |
|
48 | - |
|
49 | - /** |
|
50 | - *_set_properties |
|
51 | - */ |
|
52 | - protected function _set_properties() |
|
53 | - { |
|
54 | - $this->_wp_list_args = array( |
|
55 | - 'singular' => __('transaction', 'event_espresso'), |
|
56 | - 'plural' => __('transactions', 'event_espresso'), |
|
57 | - 'ajax' => true, |
|
58 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
59 | - ); |
|
60 | - $ID_column_name = __('ID', 'event_espresso'); |
|
61 | - $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
62 | - $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
63 | - $ID_column_name .= '</span> '; |
|
64 | - $this->_columns = array( |
|
65 | - 'TXN_ID' => $ID_column_name, |
|
66 | - 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
67 | - 'TXN_total' => __('Total', 'event_espresso'), |
|
68 | - 'TXN_paid' => __('Paid', 'event_espresso'), |
|
69 | - 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
70 | - 'event_name' => __('Event', 'event_espresso'), |
|
71 | - 'actions' => __('Actions', 'event_espresso'), |
|
72 | - ); |
|
73 | - |
|
74 | - $this->_sortable_columns = array( |
|
75 | - 'TXN_ID' => array('TXN_ID' => false), |
|
76 | - 'event_name' => array('event_name' => false), |
|
77 | - 'ATT_fname' => array('ATT_fname' => false), |
|
78 | - 'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted |
|
79 | - ); |
|
80 | - |
|
81 | - $this->_primary_column = 'TXN_ID'; |
|
82 | - |
|
83 | - $this->_hidden_columns = array(); |
|
84 | - } |
|
85 | - |
|
86 | - |
|
87 | - /** |
|
88 | - * This simply sets up the row class for the table rows. |
|
89 | - * Allows for easier overriding of child methods for setting up sorting. |
|
90 | - * |
|
91 | - * @param EE_Transaction $transaction the current item |
|
92 | - * @return string |
|
93 | - * @throws \EE_Error |
|
94 | - */ |
|
95 | - protected function _get_row_class($transaction) |
|
96 | - { |
|
97 | - $class = parent::_get_row_class($transaction); |
|
98 | - // add status class |
|
99 | - $class .= ' ee-status-strip txn-status-' . $transaction->status_ID(); |
|
100 | - if ($this->_has_checkbox_column) { |
|
101 | - $class .= ' has-checkbox-column'; |
|
102 | - } |
|
103 | - return $class; |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * _get_table_filters |
|
109 | - * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
110 | - * get's shown in the table. |
|
111 | - * |
|
112 | - * @abstract |
|
113 | - * @access protected |
|
114 | - * @return array |
|
115 | - */ |
|
116 | - protected function _get_table_filters() |
|
117 | - { |
|
118 | - $filters = array(); |
|
119 | - $start_date = isset($this->_req_data['txn-filter-start-date']) |
|
120 | - ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) |
|
121 | - : date( |
|
122 | - 'm/d/Y', |
|
123 | - strtotime('-10 year') |
|
124 | - ); |
|
125 | - $end_date = isset($this->_req_data['txn-filter-end-date']) |
|
126 | - ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) |
|
127 | - : date( |
|
128 | - 'm/d/Y', |
|
129 | - current_time('timestamp') |
|
130 | - ); |
|
131 | - ob_start(); |
|
132 | - ?> |
|
18 | + /** |
|
19 | + * @var SessionLifespan $session_lifespan |
|
20 | + */ |
|
21 | + private $session_lifespan; |
|
22 | + |
|
23 | + private $_status; |
|
24 | + |
|
25 | + |
|
26 | + /** |
|
27 | + * @param \Transactions_Admin_Page $admin_page |
|
28 | + * @param SessionLifespan $lifespan |
|
29 | + */ |
|
30 | + public function __construct(\Transactions_Admin_Page $admin_page, SessionLifespan $lifespan) |
|
31 | + { |
|
32 | + parent::__construct($admin_page); |
|
33 | + $this->session_lifespan = $lifespan; |
|
34 | + $this->_status = $this->_admin_page->get_transaction_status_array(); |
|
35 | + } |
|
36 | + |
|
37 | + |
|
38 | + /** |
|
39 | + *_setup_data |
|
40 | + */ |
|
41 | + protected function _setup_data() |
|
42 | + { |
|
43 | + $this->_data = $this->_admin_page->get_transactions($this->_per_page); |
|
44 | + $status = ! empty($this->_req_data['status']) ? $this->_req_data['status'] : 'all'; |
|
45 | + $this->_all_data_count = $this->_admin_page->get_transactions($this->_per_page, true, $status); |
|
46 | + } |
|
47 | + |
|
48 | + |
|
49 | + /** |
|
50 | + *_set_properties |
|
51 | + */ |
|
52 | + protected function _set_properties() |
|
53 | + { |
|
54 | + $this->_wp_list_args = array( |
|
55 | + 'singular' => __('transaction', 'event_espresso'), |
|
56 | + 'plural' => __('transactions', 'event_espresso'), |
|
57 | + 'ajax' => true, |
|
58 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
59 | + ); |
|
60 | + $ID_column_name = __('ID', 'event_espresso'); |
|
61 | + $ID_column_name .= ' : <span class="show-on-mobile-view-only" style="float:none">'; |
|
62 | + $ID_column_name .= __('Transaction Date', 'event_espresso'); |
|
63 | + $ID_column_name .= '</span> '; |
|
64 | + $this->_columns = array( |
|
65 | + 'TXN_ID' => $ID_column_name, |
|
66 | + 'TXN_timestamp' => __('Transaction Date', 'event_espresso'), |
|
67 | + 'TXN_total' => __('Total', 'event_espresso'), |
|
68 | + 'TXN_paid' => __('Paid', 'event_espresso'), |
|
69 | + 'ATT_fname' => __('Primary Registrant', 'event_espresso'), |
|
70 | + 'event_name' => __('Event', 'event_espresso'), |
|
71 | + 'actions' => __('Actions', 'event_espresso'), |
|
72 | + ); |
|
73 | + |
|
74 | + $this->_sortable_columns = array( |
|
75 | + 'TXN_ID' => array('TXN_ID' => false), |
|
76 | + 'event_name' => array('event_name' => false), |
|
77 | + 'ATT_fname' => array('ATT_fname' => false), |
|
78 | + 'TXN_timestamp' => array('TXN_timestamp' => true) // true means its already sorted |
|
79 | + ); |
|
80 | + |
|
81 | + $this->_primary_column = 'TXN_ID'; |
|
82 | + |
|
83 | + $this->_hidden_columns = array(); |
|
84 | + } |
|
85 | + |
|
86 | + |
|
87 | + /** |
|
88 | + * This simply sets up the row class for the table rows. |
|
89 | + * Allows for easier overriding of child methods for setting up sorting. |
|
90 | + * |
|
91 | + * @param EE_Transaction $transaction the current item |
|
92 | + * @return string |
|
93 | + * @throws \EE_Error |
|
94 | + */ |
|
95 | + protected function _get_row_class($transaction) |
|
96 | + { |
|
97 | + $class = parent::_get_row_class($transaction); |
|
98 | + // add status class |
|
99 | + $class .= ' ee-status-strip txn-status-' . $transaction->status_ID(); |
|
100 | + if ($this->_has_checkbox_column) { |
|
101 | + $class .= ' has-checkbox-column'; |
|
102 | + } |
|
103 | + return $class; |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * _get_table_filters |
|
109 | + * We use this to assemble and return any filters that are associated with this table that help further refine what |
|
110 | + * get's shown in the table. |
|
111 | + * |
|
112 | + * @abstract |
|
113 | + * @access protected |
|
114 | + * @return array |
|
115 | + */ |
|
116 | + protected function _get_table_filters() |
|
117 | + { |
|
118 | + $filters = array(); |
|
119 | + $start_date = isset($this->_req_data['txn-filter-start-date']) |
|
120 | + ? wp_strip_all_tags($this->_req_data['txn-filter-start-date']) |
|
121 | + : date( |
|
122 | + 'm/d/Y', |
|
123 | + strtotime('-10 year') |
|
124 | + ); |
|
125 | + $end_date = isset($this->_req_data['txn-filter-end-date']) |
|
126 | + ? wp_strip_all_tags($this->_req_data['txn-filter-end-date']) |
|
127 | + : date( |
|
128 | + 'm/d/Y', |
|
129 | + current_time('timestamp') |
|
130 | + ); |
|
131 | + ob_start(); |
|
132 | + ?> |
|
133 | 133 | <label for="txn-filter-start-date">Display Transactions from </label> |
134 | 134 | <input id="txn-filter-start-date" class="datepicker" type="text" value="<?php echo $start_date; ?>" |
135 | 135 | name="txn-filter-start-date" size="15"/> |
@@ -137,585 +137,585 @@ discard block |
||
137 | 137 | <input id="txn-filter-end-date" class="datepicker" type="text" value="<?php echo $end_date; ?>" |
138 | 138 | name="txn-filter-end-date" size="15"/> |
139 | 139 | <?php |
140 | - $filters[] = ob_get_contents(); |
|
141 | - ob_end_clean(); |
|
142 | - return $filters; |
|
143 | - } |
|
144 | - |
|
145 | - |
|
146 | - /** |
|
147 | - *_add_view_counts |
|
148 | - */ |
|
149 | - protected function _add_view_counts() |
|
150 | - { |
|
151 | - foreach ($this->_views as $view) { |
|
152 | - $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']); |
|
153 | - } |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * column TXN_ID |
|
159 | - * |
|
160 | - * @param \EE_Transaction $transaction |
|
161 | - * @return string |
|
162 | - * @throws \EE_Error |
|
163 | - */ |
|
164 | - public function column_TXN_ID(EE_Transaction $transaction) |
|
165 | - { |
|
166 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
167 | - array( |
|
168 | - 'action' => 'view_transaction', |
|
169 | - 'TXN_ID' => $transaction->ID(), |
|
170 | - ), |
|
171 | - TXN_ADMIN_URL |
|
172 | - ); |
|
173 | - $content = '<a href="' . $view_lnk_url . '"' |
|
174 | - . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">' |
|
175 | - . $transaction->ID() |
|
176 | - . '</a>'; |
|
177 | - |
|
178 | - // txn timestamp |
|
179 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>'; |
|
180 | - return $content; |
|
181 | - } |
|
182 | - |
|
183 | - |
|
184 | - /** |
|
185 | - * @param \EE_Transaction $transaction |
|
186 | - * @return string |
|
187 | - * @throws EE_Error |
|
188 | - * @throws InvalidArgumentException |
|
189 | - * @throws InvalidDataTypeException |
|
190 | - * @throws InvalidInterfaceException |
|
191 | - */ |
|
192 | - protected function _get_txn_timestamp(EE_Transaction $transaction) |
|
193 | - { |
|
194 | - // is TXN less than 2 hours old ? |
|
195 | - if ( |
|
196 | - ($transaction->failed() || $transaction->is_abandoned()) |
|
197 | - && $this->session_lifespan->expiration() < $transaction->datetime(false, true) |
|
198 | - ) { |
|
199 | - $timestamp = esc_html__('TXN in progress...', 'event_espresso'); |
|
200 | - } else { |
|
201 | - $timestamp = $transaction->get_i18n_datetime('TXN_timestamp'); |
|
202 | - } |
|
203 | - return $timestamp; |
|
204 | - } |
|
205 | - |
|
206 | - |
|
207 | - /** |
|
208 | - * column_cb |
|
209 | - * |
|
210 | - * @param \EE_Transaction $transaction |
|
211 | - * @return string |
|
212 | - * @throws \EE_Error |
|
213 | - */ |
|
214 | - public function column_cb($transaction) |
|
215 | - { |
|
216 | - return sprintf( |
|
217 | - '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
|
218 | - $this->_wp_list_args['singular'], |
|
219 | - $transaction->ID() |
|
220 | - ); |
|
221 | - } |
|
222 | - |
|
223 | - |
|
224 | - /** |
|
225 | - * column_TXN_timestamp |
|
226 | - * |
|
227 | - * @param \EE_Transaction $transaction |
|
228 | - * @return string |
|
229 | - * @throws \EE_Error |
|
230 | - */ |
|
231 | - public function column_TXN_timestamp(EE_Transaction $transaction) |
|
232 | - { |
|
233 | - $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
234 | - array( |
|
235 | - 'action' => 'view_transaction', |
|
236 | - 'TXN_ID' => $transaction->ID(), |
|
237 | - ), |
|
238 | - TXN_ADMIN_URL |
|
239 | - ); |
|
240 | - $txn_date = '<a href="' . $view_lnk_url . '"' |
|
241 | - . ' title="' |
|
242 | - . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">' |
|
243 | - . $this->_get_txn_timestamp($transaction) |
|
244 | - . '</a>'; |
|
245 | - // status |
|
246 | - $txn_date .= '<br><span class="ee-status-text-small">' |
|
247 | - . EEH_Template::pretty_status( |
|
248 | - $transaction->status_ID(), |
|
249 | - false, |
|
250 | - 'sentence' |
|
251 | - ) |
|
252 | - . '</span>'; |
|
253 | - return $txn_date; |
|
254 | - } |
|
255 | - |
|
256 | - |
|
257 | - /** |
|
258 | - * column_TXN_total |
|
259 | - * |
|
260 | - * @param \EE_Transaction $transaction |
|
261 | - * @return string |
|
262 | - * @throws \EE_Error |
|
263 | - */ |
|
264 | - public function column_TXN_total(EE_Transaction $transaction) |
|
265 | - { |
|
266 | - if ($transaction->get('TXN_total') > 0) { |
|
267 | - return '<span class="txn-pad-rght">' |
|
268 | - . apply_filters( |
|
269 | - 'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
270 | - $transaction->get_pretty('TXN_total'), |
|
271 | - $transaction |
|
272 | - ) |
|
273 | - . '</span>'; |
|
274 | - } else { |
|
275 | - return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
276 | - } |
|
277 | - } |
|
278 | - |
|
279 | - |
|
280 | - /** |
|
281 | - * column_TXN_paid |
|
282 | - * |
|
283 | - * @param \EE_Transaction $transaction |
|
284 | - * @return mixed|string |
|
285 | - * @throws \EE_Error |
|
286 | - */ |
|
287 | - public function column_TXN_paid(EE_Transaction $transaction) |
|
288 | - { |
|
289 | - $transaction_total = $transaction->get('TXN_total'); |
|
290 | - $transaction_paid = $transaction->get('TXN_paid'); |
|
291 | - |
|
292 | - if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
293 | - // monies owing |
|
294 | - $span_class = 'txn-overview-part-payment-spn'; |
|
295 | - if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
296 | - // paid in full |
|
297 | - $span_class = 'txn-overview-full-payment-spn'; |
|
298 | - } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
299 | - // no payments made |
|
300 | - $span_class = 'txn-overview-no-payment-spn'; |
|
301 | - } |
|
302 | - } else { |
|
303 | - // transaction_total == 0 so this is a free event |
|
304 | - $span_class = 'txn-overview-free-event-spn'; |
|
305 | - } |
|
306 | - |
|
307 | - $payment_method = $transaction->payment_method(); |
|
308 | - $payment_method_name = $payment_method instanceof EE_Payment_Method |
|
309 | - ? $payment_method->admin_name() |
|
310 | - : esc_html__('Unknown', 'event_espresso'); |
|
311 | - |
|
312 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' |
|
313 | - . $transaction->get_pretty('TXN_paid') |
|
314 | - . '</span>'; |
|
315 | - if ($transaction_paid > 0) { |
|
316 | - $content .= '<br><span class="ee-status-text-small">' |
|
317 | - . sprintf( |
|
318 | - esc_html__('...via %s', 'event_espresso'), |
|
319 | - $payment_method_name |
|
320 | - ) |
|
321 | - . '</span>'; |
|
322 | - } |
|
323 | - return $content; |
|
324 | - } |
|
325 | - |
|
326 | - |
|
327 | - /** |
|
328 | - * column_ATT_fname |
|
329 | - * |
|
330 | - * @param \EE_Transaction $transaction |
|
331 | - * @return string |
|
332 | - * @throws EE_Error |
|
333 | - * @throws InvalidArgumentException |
|
334 | - * @throws InvalidDataTypeException |
|
335 | - * @throws InvalidInterfaceException |
|
336 | - */ |
|
337 | - public function column_ATT_fname(EE_Transaction $transaction) |
|
338 | - { |
|
339 | - $primary_reg = $transaction->primary_registration(); |
|
340 | - $attendee = $primary_reg->get_first_related('Attendee'); |
|
341 | - if ($attendee instanceof EE_Attendee) { |
|
342 | - $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
343 | - array( |
|
344 | - 'action' => 'view_registration', |
|
345 | - '_REG_ID' => $primary_reg->ID(), |
|
346 | - ), |
|
347 | - REG_ADMIN_URL |
|
348 | - ); |
|
349 | - $content = EE_Registry::instance()->CAP->current_user_can( |
|
350 | - 'ee_read_registration', |
|
351 | - 'espresso_registrations_view_registration', |
|
352 | - $primary_reg->ID() |
|
353 | - ) |
|
354 | - ? '<a href="' . $edit_lnk_url . '"' |
|
355 | - . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
356 | - . $attendee->full_name() |
|
357 | - . '</a>' |
|
358 | - : $attendee->full_name(); |
|
359 | - $content .= '<br>' . $attendee->email(); |
|
360 | - return $content; |
|
361 | - } |
|
362 | - return $transaction->failed() || $transaction->is_abandoned() |
|
363 | - ? esc_html__('no contact record.', 'event_espresso') |
|
364 | - : esc_html__( |
|
365 | - 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
366 | - 'event_espresso' |
|
367 | - ); |
|
368 | - } |
|
369 | - |
|
370 | - |
|
371 | - /** |
|
372 | - * column_ATT_email |
|
373 | - * |
|
374 | - * @param \EE_Transaction $transaction |
|
375 | - * @return string |
|
376 | - * @throws \EE_Error |
|
377 | - */ |
|
378 | - public function column_ATT_email(EE_Transaction $transaction) |
|
379 | - { |
|
380 | - $attendee = $transaction->primary_registration()->get_first_related('Attendee'); |
|
381 | - if (! empty($attendee)) { |
|
382 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' |
|
383 | - . $attendee->get('ATT_email') |
|
384 | - . '</a>'; |
|
385 | - } else { |
|
386 | - return $transaction->failed() || $transaction->is_abandoned() |
|
387 | - ? esc_html__('no contact record.', 'event_espresso') |
|
388 | - : esc_html__( |
|
389 | - 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
390 | - 'event_espresso' |
|
391 | - ); |
|
392 | - } |
|
393 | - } |
|
394 | - |
|
395 | - |
|
396 | - /** |
|
397 | - * column_event_name |
|
398 | - * |
|
399 | - * @param \EE_Transaction $transaction |
|
400 | - * @return string |
|
401 | - * @throws EE_Error |
|
402 | - * @throws InvalidArgumentException |
|
403 | - * @throws InvalidDataTypeException |
|
404 | - * @throws InvalidInterfaceException |
|
405 | - */ |
|
406 | - public function column_event_name(EE_Transaction $transaction) |
|
407 | - { |
|
408 | - $actions = array(); |
|
409 | - $event = $transaction->primary_registration()->get_first_related('Event'); |
|
410 | - if (! empty($event)) { |
|
411 | - $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
412 | - array('action' => 'edit', 'post' => $event->ID()), |
|
413 | - EVENTS_ADMIN_URL |
|
414 | - ); |
|
415 | - $event_name = $event->get('EVT_name'); |
|
416 | - |
|
417 | - // filter this view by transactions for this event |
|
418 | - $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce( |
|
419 | - array( |
|
420 | - 'action' => 'default', |
|
421 | - 'EVT_ID' => $event->ID(), |
|
422 | - ) |
|
423 | - ); |
|
424 | - if ( |
|
425 | - empty($this->_req_data['EVT_ID']) |
|
426 | - && EE_Registry::instance()->CAP->current_user_can( |
|
427 | - 'ee_edit_event', |
|
428 | - 'espresso_events_edit', |
|
429 | - $event->ID() |
|
430 | - ) |
|
431 | - ) { |
|
432 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"' |
|
433 | - . ' title="' . esc_attr__( |
|
434 | - 'Filter transactions by this event', |
|
435 | - 'event_espresso' |
|
436 | - ) . '">' |
|
437 | - . esc_html__('View Transactions for this event', 'event_espresso') |
|
438 | - . '</a>'; |
|
439 | - } |
|
440 | - |
|
441 | - return sprintf( |
|
442 | - '%1$s %2$s', |
|
443 | - EE_Registry::instance()->CAP->current_user_can( |
|
444 | - 'ee_edit_event', |
|
445 | - 'espresso_events_edit', |
|
446 | - $event->ID() |
|
447 | - ) |
|
448 | - ? '<a href="' . $edit_event_url . '"' |
|
449 | - . ' title="' |
|
450 | - . sprintf( |
|
451 | - esc_attr__('Edit Event: %s', 'event_espresso'), |
|
452 | - $event->get('EVT_name') |
|
453 | - ) |
|
454 | - . '">' |
|
455 | - . wp_trim_words( |
|
456 | - $event_name, |
|
457 | - 30, |
|
458 | - '...' |
|
459 | - ) |
|
460 | - . '</a>' |
|
461 | - : wp_trim_words($event_name, 30, '...'), |
|
462 | - $this->row_actions($actions) |
|
463 | - ); |
|
464 | - } else { |
|
465 | - return esc_html__( |
|
466 | - 'The event associated with this transaction via the primary registration cannot be retrieved.', |
|
467 | - 'event_espresso' |
|
468 | - ); |
|
469 | - } |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * column_actions |
|
475 | - * |
|
476 | - * @param \EE_Transaction $transaction |
|
477 | - * @return string |
|
478 | - * @throws \EE_Error |
|
479 | - */ |
|
480 | - public function column_actions(EE_Transaction $transaction) |
|
481 | - { |
|
482 | - return $this->_action_string( |
|
483 | - $this->get_transaction_details_link($transaction) |
|
484 | - . $this->get_invoice_link($transaction) |
|
485 | - . $this->get_receipt_link($transaction) |
|
486 | - . $this->get_primary_registration_details_link($transaction) |
|
487 | - . $this->get_send_payment_reminder_trigger_link($transaction) |
|
488 | - . $this->get_payment_overview_link($transaction) |
|
489 | - . $this->get_related_messages_link($transaction), |
|
490 | - $transaction, |
|
491 | - 'ul', |
|
492 | - 'txn-overview-actions-ul' |
|
493 | - ); |
|
494 | - } |
|
495 | - |
|
496 | - |
|
497 | - /** |
|
498 | - * Get the transaction details link. |
|
499 | - * |
|
500 | - * @param EE_Transaction $transaction |
|
501 | - * @return string |
|
502 | - * @throws EE_Error |
|
503 | - */ |
|
504 | - protected function get_transaction_details_link(EE_Transaction $transaction) |
|
505 | - { |
|
506 | - $url = EE_Admin_Page::add_query_args_and_nonce( |
|
507 | - array( |
|
508 | - 'action' => 'view_transaction', |
|
509 | - 'TXN_ID' => $transaction->ID(), |
|
510 | - ), |
|
511 | - TXN_ADMIN_URL |
|
512 | - ); |
|
513 | - return ' |
|
140 | + $filters[] = ob_get_contents(); |
|
141 | + ob_end_clean(); |
|
142 | + return $filters; |
|
143 | + } |
|
144 | + |
|
145 | + |
|
146 | + /** |
|
147 | + *_add_view_counts |
|
148 | + */ |
|
149 | + protected function _add_view_counts() |
|
150 | + { |
|
151 | + foreach ($this->_views as $view) { |
|
152 | + $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']); |
|
153 | + } |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * column TXN_ID |
|
159 | + * |
|
160 | + * @param \EE_Transaction $transaction |
|
161 | + * @return string |
|
162 | + * @throws \EE_Error |
|
163 | + */ |
|
164 | + public function column_TXN_ID(EE_Transaction $transaction) |
|
165 | + { |
|
166 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
167 | + array( |
|
168 | + 'action' => 'view_transaction', |
|
169 | + 'TXN_ID' => $transaction->ID(), |
|
170 | + ), |
|
171 | + TXN_ADMIN_URL |
|
172 | + ); |
|
173 | + $content = '<a href="' . $view_lnk_url . '"' |
|
174 | + . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">' |
|
175 | + . $transaction->ID() |
|
176 | + . '</a>'; |
|
177 | + |
|
178 | + // txn timestamp |
|
179 | + $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>'; |
|
180 | + return $content; |
|
181 | + } |
|
182 | + |
|
183 | + |
|
184 | + /** |
|
185 | + * @param \EE_Transaction $transaction |
|
186 | + * @return string |
|
187 | + * @throws EE_Error |
|
188 | + * @throws InvalidArgumentException |
|
189 | + * @throws InvalidDataTypeException |
|
190 | + * @throws InvalidInterfaceException |
|
191 | + */ |
|
192 | + protected function _get_txn_timestamp(EE_Transaction $transaction) |
|
193 | + { |
|
194 | + // is TXN less than 2 hours old ? |
|
195 | + if ( |
|
196 | + ($transaction->failed() || $transaction->is_abandoned()) |
|
197 | + && $this->session_lifespan->expiration() < $transaction->datetime(false, true) |
|
198 | + ) { |
|
199 | + $timestamp = esc_html__('TXN in progress...', 'event_espresso'); |
|
200 | + } else { |
|
201 | + $timestamp = $transaction->get_i18n_datetime('TXN_timestamp'); |
|
202 | + } |
|
203 | + return $timestamp; |
|
204 | + } |
|
205 | + |
|
206 | + |
|
207 | + /** |
|
208 | + * column_cb |
|
209 | + * |
|
210 | + * @param \EE_Transaction $transaction |
|
211 | + * @return string |
|
212 | + * @throws \EE_Error |
|
213 | + */ |
|
214 | + public function column_cb($transaction) |
|
215 | + { |
|
216 | + return sprintf( |
|
217 | + '<input type="checkbox" name="%1$s[]" value="%2$s" />', |
|
218 | + $this->_wp_list_args['singular'], |
|
219 | + $transaction->ID() |
|
220 | + ); |
|
221 | + } |
|
222 | + |
|
223 | + |
|
224 | + /** |
|
225 | + * column_TXN_timestamp |
|
226 | + * |
|
227 | + * @param \EE_Transaction $transaction |
|
228 | + * @return string |
|
229 | + * @throws \EE_Error |
|
230 | + */ |
|
231 | + public function column_TXN_timestamp(EE_Transaction $transaction) |
|
232 | + { |
|
233 | + $view_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
234 | + array( |
|
235 | + 'action' => 'view_transaction', |
|
236 | + 'TXN_ID' => $transaction->ID(), |
|
237 | + ), |
|
238 | + TXN_ADMIN_URL |
|
239 | + ); |
|
240 | + $txn_date = '<a href="' . $view_lnk_url . '"' |
|
241 | + . ' title="' |
|
242 | + . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">' |
|
243 | + . $this->_get_txn_timestamp($transaction) |
|
244 | + . '</a>'; |
|
245 | + // status |
|
246 | + $txn_date .= '<br><span class="ee-status-text-small">' |
|
247 | + . EEH_Template::pretty_status( |
|
248 | + $transaction->status_ID(), |
|
249 | + false, |
|
250 | + 'sentence' |
|
251 | + ) |
|
252 | + . '</span>'; |
|
253 | + return $txn_date; |
|
254 | + } |
|
255 | + |
|
256 | + |
|
257 | + /** |
|
258 | + * column_TXN_total |
|
259 | + * |
|
260 | + * @param \EE_Transaction $transaction |
|
261 | + * @return string |
|
262 | + * @throws \EE_Error |
|
263 | + */ |
|
264 | + public function column_TXN_total(EE_Transaction $transaction) |
|
265 | + { |
|
266 | + if ($transaction->get('TXN_total') > 0) { |
|
267 | + return '<span class="txn-pad-rght">' |
|
268 | + . apply_filters( |
|
269 | + 'FHEE__EE_Admin_Transactions_List_Table__column_TXN_total__TXN_total', |
|
270 | + $transaction->get_pretty('TXN_total'), |
|
271 | + $transaction |
|
272 | + ) |
|
273 | + . '</span>'; |
|
274 | + } else { |
|
275 | + return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
276 | + } |
|
277 | + } |
|
278 | + |
|
279 | + |
|
280 | + /** |
|
281 | + * column_TXN_paid |
|
282 | + * |
|
283 | + * @param \EE_Transaction $transaction |
|
284 | + * @return mixed|string |
|
285 | + * @throws \EE_Error |
|
286 | + */ |
|
287 | + public function column_TXN_paid(EE_Transaction $transaction) |
|
288 | + { |
|
289 | + $transaction_total = $transaction->get('TXN_total'); |
|
290 | + $transaction_paid = $transaction->get('TXN_paid'); |
|
291 | + |
|
292 | + if (\EEH_Money::compare_floats($transaction_total, 0, '>')) { |
|
293 | + // monies owing |
|
294 | + $span_class = 'txn-overview-part-payment-spn'; |
|
295 | + if (\EEH_Money::compare_floats($transaction_paid, $transaction_total, '>=')) { |
|
296 | + // paid in full |
|
297 | + $span_class = 'txn-overview-full-payment-spn'; |
|
298 | + } elseif (\EEH_Money::compare_floats($transaction_paid, 0, '==')) { |
|
299 | + // no payments made |
|
300 | + $span_class = 'txn-overview-no-payment-spn'; |
|
301 | + } |
|
302 | + } else { |
|
303 | + // transaction_total == 0 so this is a free event |
|
304 | + $span_class = 'txn-overview-free-event-spn'; |
|
305 | + } |
|
306 | + |
|
307 | + $payment_method = $transaction->payment_method(); |
|
308 | + $payment_method_name = $payment_method instanceof EE_Payment_Method |
|
309 | + ? $payment_method->admin_name() |
|
310 | + : esc_html__('Unknown', 'event_espresso'); |
|
311 | + |
|
312 | + $content = '<span class="' . $span_class . ' txn-pad-rght">' |
|
313 | + . $transaction->get_pretty('TXN_paid') |
|
314 | + . '</span>'; |
|
315 | + if ($transaction_paid > 0) { |
|
316 | + $content .= '<br><span class="ee-status-text-small">' |
|
317 | + . sprintf( |
|
318 | + esc_html__('...via %s', 'event_espresso'), |
|
319 | + $payment_method_name |
|
320 | + ) |
|
321 | + . '</span>'; |
|
322 | + } |
|
323 | + return $content; |
|
324 | + } |
|
325 | + |
|
326 | + |
|
327 | + /** |
|
328 | + * column_ATT_fname |
|
329 | + * |
|
330 | + * @param \EE_Transaction $transaction |
|
331 | + * @return string |
|
332 | + * @throws EE_Error |
|
333 | + * @throws InvalidArgumentException |
|
334 | + * @throws InvalidDataTypeException |
|
335 | + * @throws InvalidInterfaceException |
|
336 | + */ |
|
337 | + public function column_ATT_fname(EE_Transaction $transaction) |
|
338 | + { |
|
339 | + $primary_reg = $transaction->primary_registration(); |
|
340 | + $attendee = $primary_reg->get_first_related('Attendee'); |
|
341 | + if ($attendee instanceof EE_Attendee) { |
|
342 | + $edit_lnk_url = EE_Admin_Page::add_query_args_and_nonce( |
|
343 | + array( |
|
344 | + 'action' => 'view_registration', |
|
345 | + '_REG_ID' => $primary_reg->ID(), |
|
346 | + ), |
|
347 | + REG_ADMIN_URL |
|
348 | + ); |
|
349 | + $content = EE_Registry::instance()->CAP->current_user_can( |
|
350 | + 'ee_read_registration', |
|
351 | + 'espresso_registrations_view_registration', |
|
352 | + $primary_reg->ID() |
|
353 | + ) |
|
354 | + ? '<a href="' . $edit_lnk_url . '"' |
|
355 | + . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
356 | + . $attendee->full_name() |
|
357 | + . '</a>' |
|
358 | + : $attendee->full_name(); |
|
359 | + $content .= '<br>' . $attendee->email(); |
|
360 | + return $content; |
|
361 | + } |
|
362 | + return $transaction->failed() || $transaction->is_abandoned() |
|
363 | + ? esc_html__('no contact record.', 'event_espresso') |
|
364 | + : esc_html__( |
|
365 | + 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
366 | + 'event_espresso' |
|
367 | + ); |
|
368 | + } |
|
369 | + |
|
370 | + |
|
371 | + /** |
|
372 | + * column_ATT_email |
|
373 | + * |
|
374 | + * @param \EE_Transaction $transaction |
|
375 | + * @return string |
|
376 | + * @throws \EE_Error |
|
377 | + */ |
|
378 | + public function column_ATT_email(EE_Transaction $transaction) |
|
379 | + { |
|
380 | + $attendee = $transaction->primary_registration()->get_first_related('Attendee'); |
|
381 | + if (! empty($attendee)) { |
|
382 | + return '<a href="mailto:' . $attendee->get('ATT_email') . '">' |
|
383 | + . $attendee->get('ATT_email') |
|
384 | + . '</a>'; |
|
385 | + } else { |
|
386 | + return $transaction->failed() || $transaction->is_abandoned() |
|
387 | + ? esc_html__('no contact record.', 'event_espresso') |
|
388 | + : esc_html__( |
|
389 | + 'No contact record, because the transaction was abandoned or the registration process failed.', |
|
390 | + 'event_espresso' |
|
391 | + ); |
|
392 | + } |
|
393 | + } |
|
394 | + |
|
395 | + |
|
396 | + /** |
|
397 | + * column_event_name |
|
398 | + * |
|
399 | + * @param \EE_Transaction $transaction |
|
400 | + * @return string |
|
401 | + * @throws EE_Error |
|
402 | + * @throws InvalidArgumentException |
|
403 | + * @throws InvalidDataTypeException |
|
404 | + * @throws InvalidInterfaceException |
|
405 | + */ |
|
406 | + public function column_event_name(EE_Transaction $transaction) |
|
407 | + { |
|
408 | + $actions = array(); |
|
409 | + $event = $transaction->primary_registration()->get_first_related('Event'); |
|
410 | + if (! empty($event)) { |
|
411 | + $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
|
412 | + array('action' => 'edit', 'post' => $event->ID()), |
|
413 | + EVENTS_ADMIN_URL |
|
414 | + ); |
|
415 | + $event_name = $event->get('EVT_name'); |
|
416 | + |
|
417 | + // filter this view by transactions for this event |
|
418 | + $txn_by_event_lnk = EE_Admin_Page::add_query_args_and_nonce( |
|
419 | + array( |
|
420 | + 'action' => 'default', |
|
421 | + 'EVT_ID' => $event->ID(), |
|
422 | + ) |
|
423 | + ); |
|
424 | + if ( |
|
425 | + empty($this->_req_data['EVT_ID']) |
|
426 | + && EE_Registry::instance()->CAP->current_user_can( |
|
427 | + 'ee_edit_event', |
|
428 | + 'espresso_events_edit', |
|
429 | + $event->ID() |
|
430 | + ) |
|
431 | + ) { |
|
432 | + $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"' |
|
433 | + . ' title="' . esc_attr__( |
|
434 | + 'Filter transactions by this event', |
|
435 | + 'event_espresso' |
|
436 | + ) . '">' |
|
437 | + . esc_html__('View Transactions for this event', 'event_espresso') |
|
438 | + . '</a>'; |
|
439 | + } |
|
440 | + |
|
441 | + return sprintf( |
|
442 | + '%1$s %2$s', |
|
443 | + EE_Registry::instance()->CAP->current_user_can( |
|
444 | + 'ee_edit_event', |
|
445 | + 'espresso_events_edit', |
|
446 | + $event->ID() |
|
447 | + ) |
|
448 | + ? '<a href="' . $edit_event_url . '"' |
|
449 | + . ' title="' |
|
450 | + . sprintf( |
|
451 | + esc_attr__('Edit Event: %s', 'event_espresso'), |
|
452 | + $event->get('EVT_name') |
|
453 | + ) |
|
454 | + . '">' |
|
455 | + . wp_trim_words( |
|
456 | + $event_name, |
|
457 | + 30, |
|
458 | + '...' |
|
459 | + ) |
|
460 | + . '</a>' |
|
461 | + : wp_trim_words($event_name, 30, '...'), |
|
462 | + $this->row_actions($actions) |
|
463 | + ); |
|
464 | + } else { |
|
465 | + return esc_html__( |
|
466 | + 'The event associated with this transaction via the primary registration cannot be retrieved.', |
|
467 | + 'event_espresso' |
|
468 | + ); |
|
469 | + } |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * column_actions |
|
475 | + * |
|
476 | + * @param \EE_Transaction $transaction |
|
477 | + * @return string |
|
478 | + * @throws \EE_Error |
|
479 | + */ |
|
480 | + public function column_actions(EE_Transaction $transaction) |
|
481 | + { |
|
482 | + return $this->_action_string( |
|
483 | + $this->get_transaction_details_link($transaction) |
|
484 | + . $this->get_invoice_link($transaction) |
|
485 | + . $this->get_receipt_link($transaction) |
|
486 | + . $this->get_primary_registration_details_link($transaction) |
|
487 | + . $this->get_send_payment_reminder_trigger_link($transaction) |
|
488 | + . $this->get_payment_overview_link($transaction) |
|
489 | + . $this->get_related_messages_link($transaction), |
|
490 | + $transaction, |
|
491 | + 'ul', |
|
492 | + 'txn-overview-actions-ul' |
|
493 | + ); |
|
494 | + } |
|
495 | + |
|
496 | + |
|
497 | + /** |
|
498 | + * Get the transaction details link. |
|
499 | + * |
|
500 | + * @param EE_Transaction $transaction |
|
501 | + * @return string |
|
502 | + * @throws EE_Error |
|
503 | + */ |
|
504 | + protected function get_transaction_details_link(EE_Transaction $transaction) |
|
505 | + { |
|
506 | + $url = EE_Admin_Page::add_query_args_and_nonce( |
|
507 | + array( |
|
508 | + 'action' => 'view_transaction', |
|
509 | + 'TXN_ID' => $transaction->ID(), |
|
510 | + ), |
|
511 | + TXN_ADMIN_URL |
|
512 | + ); |
|
513 | + return ' |
|
514 | 514 | <li> |
515 | 515 | <a href="' . $url . '"' |
516 | - . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text"> |
|
516 | + . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text"> |
|
517 | 517 | <span class="dashicons dashicons-cart"></span> |
518 | 518 | </a> |
519 | 519 | </li>'; |
520 | - } |
|
521 | - |
|
522 | - |
|
523 | - /** |
|
524 | - * Get the invoice link for the given registration. |
|
525 | - * |
|
526 | - * @param EE_Transaction $transaction |
|
527 | - * @return string |
|
528 | - * @throws EE_Error |
|
529 | - */ |
|
530 | - protected function get_invoice_link(EE_Transaction $transaction) |
|
531 | - { |
|
532 | - $registration = $transaction->primary_registration(); |
|
533 | - if ($registration instanceof EE_Registration) { |
|
534 | - $url = $registration->invoice_url(); |
|
535 | - // only show invoice link if message type is active. |
|
536 | - if ( |
|
537 | - $registration->attendee() instanceof EE_Attendee |
|
538 | - && EEH_MSG_Template::is_mt_active('invoice') |
|
539 | - ) { |
|
540 | - return ' |
|
520 | + } |
|
521 | + |
|
522 | + |
|
523 | + /** |
|
524 | + * Get the invoice link for the given registration. |
|
525 | + * |
|
526 | + * @param EE_Transaction $transaction |
|
527 | + * @return string |
|
528 | + * @throws EE_Error |
|
529 | + */ |
|
530 | + protected function get_invoice_link(EE_Transaction $transaction) |
|
531 | + { |
|
532 | + $registration = $transaction->primary_registration(); |
|
533 | + if ($registration instanceof EE_Registration) { |
|
534 | + $url = $registration->invoice_url(); |
|
535 | + // only show invoice link if message type is active. |
|
536 | + if ( |
|
537 | + $registration->attendee() instanceof EE_Attendee |
|
538 | + && EEH_MSG_Template::is_mt_active('invoice') |
|
539 | + ) { |
|
540 | + return ' |
|
541 | 541 | <li> |
542 | 542 | <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"' |
543 | - . ' target="_blank" href="' . $url . '" class="tiny-text"> |
|
543 | + . ' target="_blank" href="' . $url . '" class="tiny-text"> |
|
544 | 544 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
545 | 545 | </a> |
546 | 546 | </li>'; |
547 | - } |
|
548 | - } |
|
549 | - return ''; |
|
550 | - } |
|
551 | - |
|
552 | - |
|
553 | - /** |
|
554 | - * Get the receipt link for the transaction. |
|
555 | - * |
|
556 | - * @param EE_Transaction $transaction |
|
557 | - * @return string |
|
558 | - * @throws EE_Error |
|
559 | - */ |
|
560 | - protected function get_receipt_link(EE_Transaction $transaction) |
|
561 | - { |
|
562 | - $registration = $transaction->primary_registration(); |
|
563 | - if ($registration instanceof EE_Registration) { |
|
564 | - $url = $registration->receipt_url(); |
|
565 | - // only show receipt link if message type is active. |
|
566 | - if ( |
|
567 | - $registration->attendee() instanceof EE_Attendee |
|
568 | - && EEH_MSG_Template::is_mt_active('receipt') |
|
569 | - ) { |
|
570 | - return ' |
|
547 | + } |
|
548 | + } |
|
549 | + return ''; |
|
550 | + } |
|
551 | + |
|
552 | + |
|
553 | + /** |
|
554 | + * Get the receipt link for the transaction. |
|
555 | + * |
|
556 | + * @param EE_Transaction $transaction |
|
557 | + * @return string |
|
558 | + * @throws EE_Error |
|
559 | + */ |
|
560 | + protected function get_receipt_link(EE_Transaction $transaction) |
|
561 | + { |
|
562 | + $registration = $transaction->primary_registration(); |
|
563 | + if ($registration instanceof EE_Registration) { |
|
564 | + $url = $registration->receipt_url(); |
|
565 | + // only show receipt link if message type is active. |
|
566 | + if ( |
|
567 | + $registration->attendee() instanceof EE_Attendee |
|
568 | + && EEH_MSG_Template::is_mt_active('receipt') |
|
569 | + ) { |
|
570 | + return ' |
|
571 | 571 | <li> |
572 | 572 | <a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"' |
573 | - . ' target="_blank" href="' . $url . '" class="tiny-text"> |
|
573 | + . ' target="_blank" href="' . $url . '" class="tiny-text"> |
|
574 | 574 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
575 | 575 | </a> |
576 | 576 | </li>'; |
577 | - } |
|
578 | - } |
|
579 | - return ''; |
|
580 | - } |
|
581 | - |
|
582 | - |
|
583 | - /** |
|
584 | - * Get the link to view the details for the primary registration. |
|
585 | - * |
|
586 | - * @param EE_Transaction $transaction |
|
587 | - * @return string |
|
588 | - * @throws EE_Error |
|
589 | - * @throws InvalidArgumentException |
|
590 | - * @throws InvalidDataTypeException |
|
591 | - * @throws InvalidInterfaceException |
|
592 | - */ |
|
593 | - protected function get_primary_registration_details_link(EE_Transaction $transaction) |
|
594 | - { |
|
595 | - $registration = $transaction->primary_registration(); |
|
596 | - if ($registration instanceof EE_Registration) { |
|
597 | - $url = EE_Admin_Page::add_query_args_and_nonce( |
|
598 | - array( |
|
599 | - 'action' => 'view_registration', |
|
600 | - '_REG_ID' => $registration->ID(), |
|
601 | - ), |
|
602 | - REG_ADMIN_URL |
|
603 | - ); |
|
604 | - return EE_Registry::instance()->CAP->current_user_can( |
|
605 | - 'ee_read_registration', |
|
606 | - 'espresso_registrations_view_registration', |
|
607 | - $registration->ID() |
|
608 | - ) |
|
609 | - ? ' |
|
577 | + } |
|
578 | + } |
|
579 | + return ''; |
|
580 | + } |
|
581 | + |
|
582 | + |
|
583 | + /** |
|
584 | + * Get the link to view the details for the primary registration. |
|
585 | + * |
|
586 | + * @param EE_Transaction $transaction |
|
587 | + * @return string |
|
588 | + * @throws EE_Error |
|
589 | + * @throws InvalidArgumentException |
|
590 | + * @throws InvalidDataTypeException |
|
591 | + * @throws InvalidInterfaceException |
|
592 | + */ |
|
593 | + protected function get_primary_registration_details_link(EE_Transaction $transaction) |
|
594 | + { |
|
595 | + $registration = $transaction->primary_registration(); |
|
596 | + if ($registration instanceof EE_Registration) { |
|
597 | + $url = EE_Admin_Page::add_query_args_and_nonce( |
|
598 | + array( |
|
599 | + 'action' => 'view_registration', |
|
600 | + '_REG_ID' => $registration->ID(), |
|
601 | + ), |
|
602 | + REG_ADMIN_URL |
|
603 | + ); |
|
604 | + return EE_Registry::instance()->CAP->current_user_can( |
|
605 | + 'ee_read_registration', |
|
606 | + 'espresso_registrations_view_registration', |
|
607 | + $registration->ID() |
|
608 | + ) |
|
609 | + ? ' |
|
610 | 610 | <li> |
611 | 611 | <a href="' . $url . '"' |
612 | - . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text"> |
|
612 | + . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text"> |
|
613 | 613 | <span class="dashicons dashicons-clipboard"></span> |
614 | 614 | </a> |
615 | 615 | </li>' |
616 | - : ''; |
|
617 | - } |
|
618 | - return ''; |
|
619 | - } |
|
620 | - |
|
621 | - |
|
622 | - /** |
|
623 | - * Get send payment reminder trigger link |
|
624 | - * |
|
625 | - * @param EE_Transaction $transaction |
|
626 | - * @return string |
|
627 | - * @throws EE_Error |
|
628 | - * @throws InvalidArgumentException |
|
629 | - * @throws InvalidDataTypeException |
|
630 | - * @throws InvalidInterfaceException |
|
631 | - */ |
|
632 | - protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction) |
|
633 | - { |
|
634 | - $registration = $transaction->primary_registration(); |
|
635 | - if ( |
|
636 | - $registration instanceof EE_Registration |
|
637 | - && $registration->attendee() instanceof EE_Attendee |
|
638 | - && EEH_MSG_Template::is_mt_active('payment_reminder') |
|
639 | - && ! in_array( |
|
640 | - $transaction->status_ID(), |
|
641 | - array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code), |
|
642 | - true |
|
643 | - ) |
|
644 | - && EE_Registry::instance()->CAP->current_user_can( |
|
645 | - 'ee_send_message', |
|
646 | - 'espresso_transactions_send_payment_reminder' |
|
647 | - ) |
|
648 | - ) { |
|
649 | - $url = EE_Admin_Page::add_query_args_and_nonce( |
|
650 | - array( |
|
651 | - 'action' => 'send_payment_reminder', |
|
652 | - 'TXN_ID' => $transaction->ID(), |
|
653 | - ), |
|
654 | - TXN_ADMIN_URL |
|
655 | - ); |
|
656 | - return ' |
|
616 | + : ''; |
|
617 | + } |
|
618 | + return ''; |
|
619 | + } |
|
620 | + |
|
621 | + |
|
622 | + /** |
|
623 | + * Get send payment reminder trigger link |
|
624 | + * |
|
625 | + * @param EE_Transaction $transaction |
|
626 | + * @return string |
|
627 | + * @throws EE_Error |
|
628 | + * @throws InvalidArgumentException |
|
629 | + * @throws InvalidDataTypeException |
|
630 | + * @throws InvalidInterfaceException |
|
631 | + */ |
|
632 | + protected function get_send_payment_reminder_trigger_link(EE_Transaction $transaction) |
|
633 | + { |
|
634 | + $registration = $transaction->primary_registration(); |
|
635 | + if ( |
|
636 | + $registration instanceof EE_Registration |
|
637 | + && $registration->attendee() instanceof EE_Attendee |
|
638 | + && EEH_MSG_Template::is_mt_active('payment_reminder') |
|
639 | + && ! in_array( |
|
640 | + $transaction->status_ID(), |
|
641 | + array(EEM_Transaction::complete_status_code, EEM_Transaction::overpaid_status_code), |
|
642 | + true |
|
643 | + ) |
|
644 | + && EE_Registry::instance()->CAP->current_user_can( |
|
645 | + 'ee_send_message', |
|
646 | + 'espresso_transactions_send_payment_reminder' |
|
647 | + ) |
|
648 | + ) { |
|
649 | + $url = EE_Admin_Page::add_query_args_and_nonce( |
|
650 | + array( |
|
651 | + 'action' => 'send_payment_reminder', |
|
652 | + 'TXN_ID' => $transaction->ID(), |
|
653 | + ), |
|
654 | + TXN_ADMIN_URL |
|
655 | + ); |
|
656 | + return ' |
|
657 | 657 | <li> |
658 | 658 | <a href="' . $url . '"' |
659 | - . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text"> |
|
659 | + . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text"> |
|
660 | 660 | <span class="dashicons dashicons-email-alt"></span> |
661 | 661 | </a> |
662 | 662 | </li>'; |
663 | - } |
|
664 | - return ''; |
|
665 | - } |
|
666 | - |
|
667 | - |
|
668 | - /** |
|
669 | - * Get link to filtered view in the message activity list table of messages for this transaction. |
|
670 | - * |
|
671 | - * @param EE_Transaction $transaction |
|
672 | - * @return string |
|
673 | - * @throws EE_Error |
|
674 | - * @throws InvalidArgumentException |
|
675 | - * @throws InvalidDataTypeException |
|
676 | - * @throws InvalidInterfaceException |
|
677 | - */ |
|
678 | - protected function get_related_messages_link(EE_Transaction $transaction) |
|
679 | - { |
|
680 | - $url = EEH_MSG_Template::get_message_action_link( |
|
681 | - 'see_notifications_for', |
|
682 | - null, |
|
683 | - array('TXN_ID' => $transaction->ID()) |
|
684 | - ); |
|
685 | - return EE_Registry::instance()->CAP->current_user_can( |
|
686 | - 'ee_read_global_messages', |
|
687 | - 'view_filtered_messages' |
|
688 | - ) |
|
689 | - ? '<li>' . $url . '</li>' |
|
690 | - : ''; |
|
691 | - } |
|
692 | - |
|
693 | - |
|
694 | - /** |
|
695 | - * Return the link to make a payment on the frontend |
|
696 | - * |
|
697 | - * @param EE_Transaction $transaction |
|
698 | - * @return string |
|
699 | - * @throws EE_Error |
|
700 | - */ |
|
701 | - protected function get_payment_overview_link(EE_Transaction $transaction) |
|
702 | - { |
|
703 | - $registration = $transaction->primary_registration(); |
|
704 | - if ( |
|
705 | - $registration instanceof EE_Registration |
|
706 | - && $transaction->status_ID() !== EEM_Transaction::complete_status_code |
|
707 | - && $registration->owes_monies_and_can_pay() |
|
708 | - ) { |
|
709 | - return ' |
|
663 | + } |
|
664 | + return ''; |
|
665 | + } |
|
666 | + |
|
667 | + |
|
668 | + /** |
|
669 | + * Get link to filtered view in the message activity list table of messages for this transaction. |
|
670 | + * |
|
671 | + * @param EE_Transaction $transaction |
|
672 | + * @return string |
|
673 | + * @throws EE_Error |
|
674 | + * @throws InvalidArgumentException |
|
675 | + * @throws InvalidDataTypeException |
|
676 | + * @throws InvalidInterfaceException |
|
677 | + */ |
|
678 | + protected function get_related_messages_link(EE_Transaction $transaction) |
|
679 | + { |
|
680 | + $url = EEH_MSG_Template::get_message_action_link( |
|
681 | + 'see_notifications_for', |
|
682 | + null, |
|
683 | + array('TXN_ID' => $transaction->ID()) |
|
684 | + ); |
|
685 | + return EE_Registry::instance()->CAP->current_user_can( |
|
686 | + 'ee_read_global_messages', |
|
687 | + 'view_filtered_messages' |
|
688 | + ) |
|
689 | + ? '<li>' . $url . '</li>' |
|
690 | + : ''; |
|
691 | + } |
|
692 | + |
|
693 | + |
|
694 | + /** |
|
695 | + * Return the link to make a payment on the frontend |
|
696 | + * |
|
697 | + * @param EE_Transaction $transaction |
|
698 | + * @return string |
|
699 | + * @throws EE_Error |
|
700 | + */ |
|
701 | + protected function get_payment_overview_link(EE_Transaction $transaction) |
|
702 | + { |
|
703 | + $registration = $transaction->primary_registration(); |
|
704 | + if ( |
|
705 | + $registration instanceof EE_Registration |
|
706 | + && $transaction->status_ID() !== EEM_Transaction::complete_status_code |
|
707 | + && $registration->owes_monies_and_can_pay() |
|
708 | + ) { |
|
709 | + return ' |
|
710 | 710 | <li> |
711 | 711 | <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"' |
712 | - . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"' |
|
713 | - . ' class="tiny-text"> |
|
712 | + . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"' |
|
713 | + . ' class="tiny-text"> |
|
714 | 714 | <span class="dashicons dashicons-money ee-icon-size-18"></span> |
715 | 715 | </a> |
716 | 716 | </li> |
717 | 717 | '; |
718 | - } |
|
719 | - return ''; |
|
720 | - } |
|
718 | + } |
|
719 | + return ''; |
|
720 | + } |
|
721 | 721 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | { |
97 | 97 | $class = parent::_get_row_class($transaction); |
98 | 98 | // add status class |
99 | - $class .= ' ee-status-strip txn-status-' . $transaction->status_ID(); |
|
99 | + $class .= ' ee-status-strip txn-status-'.$transaction->status_ID(); |
|
100 | 100 | if ($this->_has_checkbox_column) { |
101 | 101 | $class .= ' has-checkbox-column'; |
102 | 102 | } |
@@ -149,7 +149,7 @@ discard block |
||
149 | 149 | protected function _add_view_counts() |
150 | 150 | { |
151 | 151 | foreach ($this->_views as $view) { |
152 | - $this->_views[ $view['slug'] ]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']); |
|
152 | + $this->_views[$view['slug']]['count'] = $this->_admin_page->get_transactions($this->_per_page, true, $view['slug']); |
|
153 | 153 | } |
154 | 154 | } |
155 | 155 | |
@@ -170,13 +170,13 @@ discard block |
||
170 | 170 | ), |
171 | 171 | TXN_ADMIN_URL |
172 | 172 | ); |
173 | - $content = '<a href="' . $view_lnk_url . '"' |
|
174 | - . ' title="' . esc_attr__('Go to Transaction Details', 'event_espresso') . '">' |
|
173 | + $content = '<a href="'.$view_lnk_url.'"' |
|
174 | + . ' title="'.esc_attr__('Go to Transaction Details', 'event_espresso').'">' |
|
175 | 175 | . $transaction->ID() |
176 | 176 | . '</a>'; |
177 | 177 | |
178 | 178 | // txn timestamp |
179 | - $content .= ' <span class="show-on-mobile-view-only">' . $this->_get_txn_timestamp($transaction) . '</span>'; |
|
179 | + $content .= ' <span class="show-on-mobile-view-only">'.$this->_get_txn_timestamp($transaction).'</span>'; |
|
180 | 180 | return $content; |
181 | 181 | } |
182 | 182 | |
@@ -237,9 +237,9 @@ discard block |
||
237 | 237 | ), |
238 | 238 | TXN_ADMIN_URL |
239 | 239 | ); |
240 | - $txn_date = '<a href="' . $view_lnk_url . '"' |
|
240 | + $txn_date = '<a href="'.$view_lnk_url.'"' |
|
241 | 241 | . ' title="' |
242 | - . esc_attr__('View Transaction Details for TXN #', 'event_espresso') . $transaction->ID() . '">' |
|
242 | + . esc_attr__('View Transaction Details for TXN #', 'event_espresso').$transaction->ID().'">' |
|
243 | 243 | . $this->_get_txn_timestamp($transaction) |
244 | 244 | . '</a>'; |
245 | 245 | // status |
@@ -272,7 +272,7 @@ discard block |
||
272 | 272 | ) |
273 | 273 | . '</span>'; |
274 | 274 | } else { |
275 | - return '<span class="txn-overview-free-event-spn">' . esc_html__('free', 'event_espresso') . '</span>'; |
|
275 | + return '<span class="txn-overview-free-event-spn">'.esc_html__('free', 'event_espresso').'</span>'; |
|
276 | 276 | } |
277 | 277 | } |
278 | 278 | |
@@ -309,7 +309,7 @@ discard block |
||
309 | 309 | ? $payment_method->admin_name() |
310 | 310 | : esc_html__('Unknown', 'event_espresso'); |
311 | 311 | |
312 | - $content = '<span class="' . $span_class . ' txn-pad-rght">' |
|
312 | + $content = '<span class="'.$span_class.' txn-pad-rght">' |
|
313 | 313 | . $transaction->get_pretty('TXN_paid') |
314 | 314 | . '</span>'; |
315 | 315 | if ($transaction_paid > 0) { |
@@ -351,12 +351,12 @@ discard block |
||
351 | 351 | 'espresso_registrations_view_registration', |
352 | 352 | $primary_reg->ID() |
353 | 353 | ) |
354 | - ? '<a href="' . $edit_lnk_url . '"' |
|
355 | - . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '">' |
|
354 | + ? '<a href="'.$edit_lnk_url.'"' |
|
355 | + . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'">' |
|
356 | 356 | . $attendee->full_name() |
357 | 357 | . '</a>' |
358 | 358 | : $attendee->full_name(); |
359 | - $content .= '<br>' . $attendee->email(); |
|
359 | + $content .= '<br>'.$attendee->email(); |
|
360 | 360 | return $content; |
361 | 361 | } |
362 | 362 | return $transaction->failed() || $transaction->is_abandoned() |
@@ -378,8 +378,8 @@ discard block |
||
378 | 378 | public function column_ATT_email(EE_Transaction $transaction) |
379 | 379 | { |
380 | 380 | $attendee = $transaction->primary_registration()->get_first_related('Attendee'); |
381 | - if (! empty($attendee)) { |
|
382 | - return '<a href="mailto:' . $attendee->get('ATT_email') . '">' |
|
381 | + if ( ! empty($attendee)) { |
|
382 | + return '<a href="mailto:'.$attendee->get('ATT_email').'">' |
|
383 | 383 | . $attendee->get('ATT_email') |
384 | 384 | . '</a>'; |
385 | 385 | } else { |
@@ -407,7 +407,7 @@ discard block |
||
407 | 407 | { |
408 | 408 | $actions = array(); |
409 | 409 | $event = $transaction->primary_registration()->get_first_related('Event'); |
410 | - if (! empty($event)) { |
|
410 | + if ( ! empty($event)) { |
|
411 | 411 | $edit_event_url = EE_Admin_Page::add_query_args_and_nonce( |
412 | 412 | array('action' => 'edit', 'post' => $event->ID()), |
413 | 413 | EVENTS_ADMIN_URL |
@@ -429,11 +429,11 @@ discard block |
||
429 | 429 | $event->ID() |
430 | 430 | ) |
431 | 431 | ) { |
432 | - $actions['filter_by_event'] = '<a href="' . $txn_by_event_lnk . '"' |
|
433 | - . ' title="' . esc_attr__( |
|
432 | + $actions['filter_by_event'] = '<a href="'.$txn_by_event_lnk.'"' |
|
433 | + . ' title="'.esc_attr__( |
|
434 | 434 | 'Filter transactions by this event', |
435 | 435 | 'event_espresso' |
436 | - ) . '">' |
|
436 | + ).'">' |
|
437 | 437 | . esc_html__('View Transactions for this event', 'event_espresso') |
438 | 438 | . '</a>'; |
439 | 439 | } |
@@ -445,7 +445,7 @@ discard block |
||
445 | 445 | 'espresso_events_edit', |
446 | 446 | $event->ID() |
447 | 447 | ) |
448 | - ? '<a href="' . $edit_event_url . '"' |
|
448 | + ? '<a href="'.$edit_event_url.'"' |
|
449 | 449 | . ' title="' |
450 | 450 | . sprintf( |
451 | 451 | esc_attr__('Edit Event: %s', 'event_espresso'), |
@@ -512,8 +512,8 @@ discard block |
||
512 | 512 | ); |
513 | 513 | return ' |
514 | 514 | <li> |
515 | - <a href="' . $url . '"' |
|
516 | - . ' title="' . esc_attr__('View Transaction Details', 'event_espresso') . '" class="tiny-text"> |
|
515 | + <a href="' . $url.'"' |
|
516 | + . ' title="'.esc_attr__('View Transaction Details', 'event_espresso').'" class="tiny-text"> |
|
517 | 517 | <span class="dashicons dashicons-cart"></span> |
518 | 518 | </a> |
519 | 519 | </li>'; |
@@ -539,8 +539,8 @@ discard block |
||
539 | 539 | ) { |
540 | 540 | return ' |
541 | 541 | <li> |
542 | - <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso') . '"' |
|
543 | - . ' target="_blank" href="' . $url . '" class="tiny-text"> |
|
542 | + <a title="' . esc_attr__('View Transaction Invoice', 'event_espresso').'"' |
|
543 | + . ' target="_blank" href="'.$url.'" class="tiny-text"> |
|
544 | 544 | <span class="dashicons dashicons-media-spreadsheet ee-icon-size-18"></span> |
545 | 545 | </a> |
546 | 546 | </li>'; |
@@ -569,8 +569,8 @@ discard block |
||
569 | 569 | ) { |
570 | 570 | return ' |
571 | 571 | <li> |
572 | - <a title="' . esc_attr__('View Transaction Receipt', 'event_espresso') . '"' |
|
573 | - . ' target="_blank" href="' . $url . '" class="tiny-text"> |
|
572 | + <a title="' . esc_attr__('View Transaction Receipt', 'event_espresso').'"' |
|
573 | + . ' target="_blank" href="'.$url.'" class="tiny-text"> |
|
574 | 574 | <span class="dashicons dashicons-media-default ee-icon-size-18"></span> |
575 | 575 | </a> |
576 | 576 | </li>'; |
@@ -608,8 +608,8 @@ discard block |
||
608 | 608 | ) |
609 | 609 | ? ' |
610 | 610 | <li> |
611 | - <a href="' . $url . '"' |
|
612 | - . ' title="' . esc_attr__('View Registration Details', 'event_espresso') . '" class="tiny-text"> |
|
611 | + <a href="' . $url.'"' |
|
612 | + . ' title="'.esc_attr__('View Registration Details', 'event_espresso').'" class="tiny-text"> |
|
613 | 613 | <span class="dashicons dashicons-clipboard"></span> |
614 | 614 | </a> |
615 | 615 | </li>' |
@@ -655,8 +655,8 @@ discard block |
||
655 | 655 | ); |
656 | 656 | return ' |
657 | 657 | <li> |
658 | - <a href="' . $url . '"' |
|
659 | - . ' title="' . esc_attr__('Send Payment Reminder', 'event_espresso') . '" class="tiny-text"> |
|
658 | + <a href="' . $url.'"' |
|
659 | + . ' title="'.esc_attr__('Send Payment Reminder', 'event_espresso').'" class="tiny-text"> |
|
660 | 660 | <span class="dashicons dashicons-email-alt"></span> |
661 | 661 | </a> |
662 | 662 | </li>'; |
@@ -686,7 +686,7 @@ discard block |
||
686 | 686 | 'ee_read_global_messages', |
687 | 687 | 'view_filtered_messages' |
688 | 688 | ) |
689 | - ? '<li>' . $url . '</li>' |
|
689 | + ? '<li>'.$url.'</li>' |
|
690 | 690 | : ''; |
691 | 691 | } |
692 | 692 | |
@@ -708,8 +708,8 @@ discard block |
||
708 | 708 | ) { |
709 | 709 | return ' |
710 | 710 | <li> |
711 | - <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso') . '"' |
|
712 | - . ' target="_blank" href="' . $registration->payment_overview_url(true) . '"' |
|
711 | + <a title="' . esc_attr__('Make Payment from the Frontend.', 'event_espresso').'"' |
|
712 | + . ' target="_blank" href="'.$registration->payment_overview_url(true).'"' |
|
713 | 713 | . ' class="tiny-text"> |
714 | 714 | <span class="dashicons dashicons-money ee-icon-size-18"></span> |
715 | 715 | </a> |