@@ -15,567 +15,567 @@ |
||
15 | 15 | class Events_Admin_List_Table extends EE_Admin_List_Table |
16 | 16 | { |
17 | 17 | |
18 | - /** |
|
19 | - * @var EE_Datetime |
|
20 | - */ |
|
21 | - private $_dtt; |
|
22 | - |
|
23 | - |
|
24 | - /** |
|
25 | - * Initial setup of data properties for the list table. |
|
26 | - */ |
|
27 | - protected function _setup_data() |
|
28 | - { |
|
29 | - $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
|
30 | - $this->_all_data_count = $this->_admin_page->get_events(0, 0, true); |
|
31 | - } |
|
32 | - |
|
33 | - |
|
34 | - /** |
|
35 | - * Set up of additional properties for the list table. |
|
36 | - */ |
|
37 | - protected function _set_properties() |
|
38 | - { |
|
39 | - $this->_wp_list_args = array( |
|
40 | - 'singular' => esc_html__('event', 'event_espresso'), |
|
41 | - 'plural' => esc_html__('events', 'event_espresso'), |
|
42 | - 'ajax' => true, // for now |
|
43 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
44 | - ); |
|
45 | - $this->_columns = array( |
|
46 | - 'cb' => '<input type="checkbox" />', // <-- this checkbox is actually replaced by WP core |
|
47 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
48 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
49 | - 'author' => esc_html__('Author', 'event_espresso'), |
|
50 | - 'venue' => esc_html__('Venue', 'event_espresso'), |
|
51 | - 'start_date_time' => esc_html__('Event Start', 'event_espresso'), |
|
52 | - 'reg_begins' => esc_html__('On Sale', 'event_espresso'), |
|
53 | - 'attendees' => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20">' |
|
54 | - . '<span class="screen-reader-text">' |
|
55 | - . esc_html__('Approved Registrations', 'event_espresso') |
|
56 | - . '</span>' |
|
57 | - . '</span>', |
|
58 | - // 'tkts_sold' => esc_html__('Tickets Sold', 'event_espresso'), |
|
59 | - 'actions' => esc_html__('Actions', 'event_espresso'), |
|
60 | - ); |
|
61 | - $this->addConditionalColumns(); |
|
62 | - $this->_sortable_columns = array( |
|
63 | - 'id' => array('EVT_ID' => true), |
|
64 | - 'name' => array('EVT_name' => false), |
|
65 | - 'author' => array('EVT_wp_user' => false), |
|
66 | - 'venue' => array('Venue.VNU_name' => false), |
|
67 | - 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
|
68 | - 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
|
69 | - ); |
|
70 | - |
|
71 | - $this->_primary_column = 'id'; |
|
72 | - $this->_hidden_columns = array('author', 'event_category'); |
|
73 | - } |
|
74 | - |
|
75 | - |
|
76 | - /** |
|
77 | - * @return array |
|
78 | - */ |
|
79 | - protected function _get_table_filters() |
|
80 | - { |
|
81 | - return array(); // no filters with decaf |
|
82 | - } |
|
83 | - |
|
84 | - |
|
85 | - /** |
|
86 | - * Setup of views properties. |
|
87 | - * |
|
88 | - * @throws InvalidDataTypeException |
|
89 | - * @throws InvalidInterfaceException |
|
90 | - * @throws InvalidArgumentException |
|
91 | - */ |
|
92 | - protected function _add_view_counts() |
|
93 | - { |
|
94 | - $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
95 | - $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
96 | - if ( |
|
97 | - EE_Registry::instance()->CAP->current_user_can( |
|
98 | - 'ee_delete_events', |
|
99 | - 'espresso_events_trash_events' |
|
100 | - ) |
|
101 | - ) { |
|
102 | - $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
103 | - } |
|
104 | - } |
|
105 | - |
|
106 | - |
|
107 | - /** |
|
108 | - * @param EE_Event $item |
|
109 | - * @return string |
|
110 | - * @throws EE_Error |
|
111 | - */ |
|
112 | - protected function _get_row_class($item) |
|
113 | - { |
|
114 | - $class = parent::_get_row_class($item); |
|
115 | - // add status class |
|
116 | - $class .= $item instanceof EE_Event |
|
117 | - ? ' ee-status-strip event-status-' . $item->get_active_status() |
|
118 | - : ''; |
|
119 | - if ($this->_has_checkbox_column) { |
|
120 | - $class .= ' has-checkbox-column'; |
|
121 | - } |
|
122 | - return $class; |
|
123 | - } |
|
124 | - |
|
125 | - |
|
126 | - /** |
|
127 | - * @param EE_Event $item |
|
128 | - * @return string |
|
129 | - * @throws EE_Error |
|
130 | - */ |
|
131 | - public function column_status(EE_Event $item) |
|
132 | - { |
|
133 | - return '<span class="ee-status-strip ee-status-strip-td event-status-' |
|
134 | - . $item->get_active_status() |
|
135 | - . '"></span>'; |
|
136 | - } |
|
137 | - |
|
138 | - |
|
139 | - /** |
|
140 | - * @param EE_Event $item |
|
141 | - * @return string |
|
142 | - * @throws EE_Error |
|
143 | - */ |
|
144 | - public function column_cb($item) |
|
145 | - { |
|
146 | - if (! $item instanceof EE_Event) { |
|
147 | - return ''; |
|
148 | - } |
|
149 | - $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
|
150 | - return sprintf( |
|
151 | - '<input type="checkbox" name="EVT_IDs[]" value="%s" class="ee-event-list-bulk-select-event"/>', |
|
152 | - $item->ID() |
|
153 | - ); |
|
154 | - } |
|
155 | - |
|
156 | - |
|
157 | - /** |
|
158 | - * @param EE_Event $item |
|
159 | - * @return mixed|string |
|
160 | - * @throws EE_Error |
|
161 | - */ |
|
162 | - public function column_id(EE_Event $item) |
|
163 | - { |
|
164 | - $content = $item->ID(); |
|
165 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
166 | - return $content; |
|
167 | - } |
|
168 | - |
|
169 | - |
|
170 | - /** |
|
171 | - * @param EE_Event $item |
|
172 | - * @return string |
|
173 | - * @throws EE_Error |
|
174 | - * @throws InvalidArgumentException |
|
175 | - * @throws InvalidDataTypeException |
|
176 | - * @throws InvalidInterfaceException |
|
177 | - */ |
|
178 | - public function column_name(EE_Event $item) |
|
179 | - { |
|
180 | - $edit_query_args = array( |
|
181 | - 'action' => 'edit', |
|
182 | - 'post' => $item->ID(), |
|
183 | - ); |
|
184 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
185 | - $actions = $this->_column_name_action_setup($item); |
|
186 | - $status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
|
187 | - $content = '<strong><a class="row-title" href="' |
|
188 | - . $edit_link . '">' |
|
189 | - . $item->name() |
|
190 | - . '</a></strong>' |
|
191 | - . $status; |
|
192 | - $content .= '<br><span class="ee-status-text-small">' |
|
193 | - . EEH_Template::pretty_status( |
|
194 | - $item->get_active_status(), |
|
195 | - false, |
|
196 | - 'sentence' |
|
197 | - ) |
|
198 | - . '</span>'; |
|
199 | - $content .= $this->row_actions($actions); |
|
200 | - return $content; |
|
201 | - } |
|
202 | - |
|
203 | - |
|
204 | - /** |
|
205 | - * Just a method for setting up the actions for the name column |
|
206 | - * |
|
207 | - * @param EE_Event $item |
|
208 | - * @return array array of actions |
|
209 | - * @throws EE_Error |
|
210 | - * @throws InvalidArgumentException |
|
211 | - * @throws InvalidDataTypeException |
|
212 | - * @throws InvalidInterfaceException |
|
213 | - */ |
|
214 | - protected function _column_name_action_setup(EE_Event $item) |
|
215 | - { |
|
216 | - // todo: remove when attendees is active |
|
217 | - if (! defined('REG_ADMIN_URL')) { |
|
218 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
219 | - } |
|
220 | - $actions = array(); |
|
221 | - $restore_event_link = ''; |
|
222 | - $delete_event_link = ''; |
|
223 | - $trash_event_link = ''; |
|
224 | - if ( |
|
225 | - EE_Registry::instance()->CAP->current_user_can( |
|
226 | - 'ee_edit_event', |
|
227 | - 'espresso_events_edit', |
|
228 | - $item->ID() |
|
229 | - ) |
|
230 | - ) { |
|
231 | - $edit_query_args = array( |
|
232 | - 'action' => 'edit', |
|
233 | - 'post' => $item->ID(), |
|
234 | - ); |
|
235 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
236 | - $actions['edit'] = '<a href="' . $edit_link . '"' |
|
237 | - . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
238 | - . esc_html__('Edit', 'event_espresso') |
|
239 | - . '</a>'; |
|
240 | - } |
|
241 | - if ( |
|
242 | - EE_Registry::instance()->CAP->current_user_can( |
|
243 | - 'ee_read_registrations', |
|
244 | - 'espresso_registrations_view_registration' |
|
245 | - ) |
|
246 | - && EE_Registry::instance()->CAP->current_user_can( |
|
247 | - 'ee_read_event', |
|
248 | - 'espresso_registrations_view_registration', |
|
249 | - $item->ID() |
|
250 | - ) |
|
251 | - ) { |
|
252 | - $attendees_query_args = array( |
|
253 | - 'action' => 'default', |
|
254 | - 'event_id' => $item->ID(), |
|
255 | - ); |
|
256 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
257 | - $actions['attendees'] = '<a href="' . $attendees_link . '"' |
|
258 | - . ' title="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
259 | - . esc_html__('Registrations', 'event_espresso') |
|
260 | - . '</a>'; |
|
261 | - } |
|
262 | - if ( |
|
263 | - EE_Registry::instance()->CAP->current_user_can( |
|
264 | - 'ee_delete_event', |
|
265 | - 'espresso_events_trash_event', |
|
266 | - $item->ID() |
|
267 | - ) |
|
268 | - ) { |
|
269 | - $trash_event_query_args = array( |
|
270 | - 'action' => 'trash_event', |
|
271 | - 'EVT_ID' => $item->ID(), |
|
272 | - ); |
|
273 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
274 | - $trash_event_query_args, |
|
275 | - EVENTS_ADMIN_URL |
|
276 | - ); |
|
277 | - } |
|
278 | - if ( |
|
279 | - EE_Registry::instance()->CAP->current_user_can( |
|
280 | - 'ee_delete_event', |
|
281 | - 'espresso_events_restore_event', |
|
282 | - $item->ID() |
|
283 | - ) |
|
284 | - ) { |
|
285 | - $restore_event_query_args = array( |
|
286 | - 'action' => 'restore_event', |
|
287 | - 'EVT_ID' => $item->ID(), |
|
288 | - ); |
|
289 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
290 | - $restore_event_query_args, |
|
291 | - EVENTS_ADMIN_URL |
|
292 | - ); |
|
293 | - } |
|
294 | - if ( |
|
295 | - EE_Registry::instance()->CAP->current_user_can( |
|
296 | - 'ee_delete_event', |
|
297 | - 'espresso_events_delete_event', |
|
298 | - $item->ID() |
|
299 | - ) |
|
300 | - ) { |
|
301 | - $delete_event_query_args = array( |
|
302 | - 'action' => 'delete_event', |
|
303 | - 'EVT_ID' => $item->ID(), |
|
304 | - ); |
|
305 | - $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
306 | - $delete_event_query_args, |
|
307 | - EVENTS_ADMIN_URL |
|
308 | - ); |
|
309 | - } |
|
310 | - $view_link = get_permalink($item->ID()); |
|
311 | - $actions['view'] = '<a href="' . $view_link . '"' |
|
312 | - . ' title="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
313 | - . esc_html__('View', 'event_espresso') |
|
314 | - . '</a>'; |
|
315 | - if ($item->get('status') === 'trash') { |
|
316 | - if ( |
|
317 | - EE_Registry::instance()->CAP->current_user_can( |
|
318 | - 'ee_delete_event', |
|
319 | - 'espresso_events_restore_event', |
|
320 | - $item->ID() |
|
321 | - ) |
|
322 | - ) { |
|
323 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"' |
|
324 | - . ' title="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
325 | - . '">' |
|
326 | - . esc_html__('Restore from Trash', 'event_espresso') |
|
327 | - . '</a>'; |
|
328 | - } |
|
329 | - if ( |
|
330 | - EE_Registry::instance()->CAP->current_user_can( |
|
331 | - 'ee_delete_event', |
|
332 | - 'espresso_events_delete_event', |
|
333 | - $item->ID() |
|
334 | - ) |
|
335 | - ) { |
|
336 | - $actions['delete'] = '<a href="' . $delete_event_link . '"' |
|
337 | - . ' title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
338 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
339 | - . '</a>'; |
|
340 | - } |
|
341 | - } else { |
|
342 | - if ( |
|
343 | - EE_Registry::instance()->CAP->current_user_can( |
|
344 | - 'ee_delete_event', |
|
345 | - 'espresso_events_trash_event', |
|
346 | - $item->ID() |
|
347 | - ) |
|
348 | - ) { |
|
349 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '"' |
|
350 | - . ' title="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
351 | - . esc_html__('Trash', 'event_espresso') |
|
352 | - . '</a>'; |
|
353 | - } |
|
354 | - } |
|
355 | - return $actions; |
|
356 | - } |
|
357 | - |
|
358 | - |
|
359 | - /** |
|
360 | - * @param EE_Event $item |
|
361 | - * @return string |
|
362 | - * @throws EE_Error |
|
363 | - */ |
|
364 | - public function column_author(EE_Event $item) |
|
365 | - { |
|
366 | - // user author info |
|
367 | - $event_author = get_userdata($item->wp_user()); |
|
368 | - $gravatar = get_avatar($item->wp_user(), '15'); |
|
369 | - // filter link |
|
370 | - $query_args = array( |
|
371 | - 'action' => 'default', |
|
372 | - 'EVT_wp_user' => $item->wp_user(), |
|
373 | - ); |
|
374 | - $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
375 | - return $gravatar . ' <a href="' . $filter_url . '"' |
|
376 | - . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
377 | - . $event_author->display_name |
|
378 | - . '</a>'; |
|
379 | - } |
|
380 | - |
|
381 | - |
|
382 | - /** |
|
383 | - * @param EE_Event $event |
|
384 | - * @return string |
|
385 | - * @throws EE_Error |
|
386 | - */ |
|
387 | - public function column_event_category(EE_Event $event) |
|
388 | - { |
|
389 | - $event_categories = $event->get_all_event_categories(); |
|
390 | - return implode( |
|
391 | - ', ', |
|
392 | - array_map( |
|
393 | - function (EE_Term $category) { |
|
394 | - return $category->name(); |
|
395 | - }, |
|
396 | - $event_categories |
|
397 | - ) |
|
398 | - ); |
|
399 | - } |
|
400 | - |
|
401 | - |
|
402 | - /** |
|
403 | - * @param EE_Event $item |
|
404 | - * @return string |
|
405 | - * @throws EE_Error |
|
406 | - */ |
|
407 | - public function column_venue(EE_Event $item) |
|
408 | - { |
|
409 | - $venue = $item->get_first_related('Venue'); |
|
410 | - return ! empty($venue) |
|
411 | - ? $venue->name() |
|
412 | - : ''; |
|
413 | - } |
|
414 | - |
|
415 | - |
|
416 | - /** |
|
417 | - * @param EE_Event $item |
|
418 | - * @return string |
|
419 | - * @throws EE_Error |
|
420 | - */ |
|
421 | - public function column_start_date_time(EE_Event $item) |
|
422 | - { |
|
423 | - return $this->_dtt instanceof EE_Datetime |
|
424 | - ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
425 | - : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
426 | - } |
|
427 | - |
|
428 | - |
|
429 | - /** |
|
430 | - * @param EE_Event $item |
|
431 | - * @return string |
|
432 | - * @throws EE_Error |
|
433 | - */ |
|
434 | - public function column_reg_begins(EE_Event $item) |
|
435 | - { |
|
436 | - $reg_start = $item->get_ticket_with_earliest_start_time(); |
|
437 | - return $reg_start instanceof EE_Ticket |
|
438 | - ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
439 | - : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
440 | - } |
|
441 | - |
|
442 | - |
|
443 | - /** |
|
444 | - * @param EE_Event $item |
|
445 | - * @return int|string |
|
446 | - * @throws EE_Error |
|
447 | - * @throws InvalidArgumentException |
|
448 | - * @throws InvalidDataTypeException |
|
449 | - * @throws InvalidInterfaceException |
|
450 | - */ |
|
451 | - public function column_attendees(EE_Event $item) |
|
452 | - { |
|
453 | - $attendees_query_args = array( |
|
454 | - 'action' => 'default', |
|
455 | - 'event_id' => $item->ID(), |
|
456 | - ); |
|
457 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
458 | - $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
459 | - return EE_Registry::instance()->CAP->current_user_can( |
|
460 | - 'ee_read_event', |
|
461 | - 'espresso_registrations_view_registration', |
|
462 | - $item->ID() |
|
463 | - ) |
|
464 | - && EE_Registry::instance()->CAP->current_user_can( |
|
465 | - 'ee_read_registrations', |
|
466 | - 'espresso_registrations_view_registration' |
|
467 | - ) |
|
468 | - ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
469 | - : $registered_attendees; |
|
470 | - } |
|
471 | - |
|
472 | - |
|
473 | - /** |
|
474 | - * @param EE_Event $item |
|
475 | - * @return float |
|
476 | - * @throws EE_Error |
|
477 | - * @throws InvalidArgumentException |
|
478 | - * @throws InvalidDataTypeException |
|
479 | - * @throws InvalidInterfaceException |
|
480 | - */ |
|
481 | - public function column_tkts_sold(EE_Event $item) |
|
482 | - { |
|
483 | - return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
484 | - } |
|
485 | - |
|
486 | - |
|
487 | - /** |
|
488 | - * @param EE_Event $item |
|
489 | - * @return string |
|
490 | - * @throws EE_Error |
|
491 | - * @throws InvalidArgumentException |
|
492 | - * @throws InvalidDataTypeException |
|
493 | - * @throws InvalidInterfaceException |
|
494 | - */ |
|
495 | - public function column_actions(EE_Event $item) |
|
496 | - { |
|
497 | - // todo: remove when attendees is active |
|
498 | - if (! defined('REG_ADMIN_URL')) { |
|
499 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
500 | - } |
|
501 | - $action_links = array(); |
|
502 | - $view_link = get_permalink($item->ID()); |
|
503 | - $action_links[] = '<a href="' . $view_link . '"' |
|
504 | - . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
505 | - $action_links[] = '<div class="dashicons dashicons-search"></div></a>'; |
|
506 | - if ( |
|
507 | - EE_Registry::instance()->CAP->current_user_can( |
|
508 | - 'ee_edit_event', |
|
509 | - 'espresso_events_edit', |
|
510 | - $item->ID() |
|
511 | - ) |
|
512 | - ) { |
|
513 | - $edit_query_args = array( |
|
514 | - 'action' => 'edit', |
|
515 | - 'post' => $item->ID(), |
|
516 | - ); |
|
517 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
518 | - $action_links[] = '<a href="' . $edit_link . '"' |
|
519 | - . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
520 | - . '<div class="ee-icon ee-icon-calendar-edit"></div>' |
|
521 | - . '</a>'; |
|
522 | - } |
|
523 | - if ( |
|
524 | - EE_Registry::instance()->CAP->current_user_can( |
|
525 | - 'ee_read_registrations', |
|
526 | - 'espresso_registrations_view_registration' |
|
527 | - ) && EE_Registry::instance()->CAP->current_user_can( |
|
528 | - 'ee_read_event', |
|
529 | - 'espresso_registrations_view_registration', |
|
530 | - $item->ID() |
|
531 | - ) |
|
532 | - ) { |
|
533 | - $attendees_query_args = array( |
|
534 | - 'action' => 'default', |
|
535 | - 'event_id' => $item->ID(), |
|
536 | - ); |
|
537 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
538 | - $action_links[] = '<a href="' . $attendees_link . '"' |
|
539 | - . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
540 | - . '<div class="dashicons dashicons-groups"></div>' |
|
541 | - . '</a>'; |
|
542 | - } |
|
543 | - $action_links = apply_filters( |
|
544 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
545 | - $action_links, |
|
546 | - $item |
|
547 | - ); |
|
548 | - return $this->_action_string( |
|
549 | - implode("\n\t", $action_links), |
|
550 | - $item, |
|
551 | - 'div' |
|
552 | - ); |
|
553 | - } |
|
554 | - |
|
555 | - |
|
556 | - /** |
|
557 | - * Helper for adding columns conditionally |
|
558 | - * |
|
559 | - * @throws EE_Error |
|
560 | - * @throws InvalidArgumentException |
|
561 | - * @throws InvalidDataTypeException |
|
562 | - * @throws InvalidInterfaceException |
|
563 | - */ |
|
564 | - private function addConditionalColumns() |
|
565 | - { |
|
566 | - $event_category_count = EEM_Term::instance()->count( |
|
567 | - [['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]] |
|
568 | - ); |
|
569 | - if ($event_category_count === 0) { |
|
570 | - return; |
|
571 | - } |
|
572 | - $column_array = []; |
|
573 | - foreach ($this->_columns as $column => $column_label) { |
|
574 | - $column_array[ $column ] = $column_label; |
|
575 | - if ($column === 'venue') { |
|
576 | - $column_array['event_category'] = esc_html__('Event Category', 'event_espresso'); |
|
577 | - } |
|
578 | - } |
|
579 | - $this->_columns = $column_array; |
|
580 | - } |
|
18 | + /** |
|
19 | + * @var EE_Datetime |
|
20 | + */ |
|
21 | + private $_dtt; |
|
22 | + |
|
23 | + |
|
24 | + /** |
|
25 | + * Initial setup of data properties for the list table. |
|
26 | + */ |
|
27 | + protected function _setup_data() |
|
28 | + { |
|
29 | + $this->_data = $this->_admin_page->get_events($this->_per_page, $this->_current_page); |
|
30 | + $this->_all_data_count = $this->_admin_page->get_events(0, 0, true); |
|
31 | + } |
|
32 | + |
|
33 | + |
|
34 | + /** |
|
35 | + * Set up of additional properties for the list table. |
|
36 | + */ |
|
37 | + protected function _set_properties() |
|
38 | + { |
|
39 | + $this->_wp_list_args = array( |
|
40 | + 'singular' => esc_html__('event', 'event_espresso'), |
|
41 | + 'plural' => esc_html__('events', 'event_espresso'), |
|
42 | + 'ajax' => true, // for now |
|
43 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
44 | + ); |
|
45 | + $this->_columns = array( |
|
46 | + 'cb' => '<input type="checkbox" />', // <-- this checkbox is actually replaced by WP core |
|
47 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
48 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
49 | + 'author' => esc_html__('Author', 'event_espresso'), |
|
50 | + 'venue' => esc_html__('Venue', 'event_espresso'), |
|
51 | + 'start_date_time' => esc_html__('Event Start', 'event_espresso'), |
|
52 | + 'reg_begins' => esc_html__('On Sale', 'event_espresso'), |
|
53 | + 'attendees' => '<span class="dashicons dashicons-groups ee-icon-color-ee-green ee-icon-size-20">' |
|
54 | + . '<span class="screen-reader-text">' |
|
55 | + . esc_html__('Approved Registrations', 'event_espresso') |
|
56 | + . '</span>' |
|
57 | + . '</span>', |
|
58 | + // 'tkts_sold' => esc_html__('Tickets Sold', 'event_espresso'), |
|
59 | + 'actions' => esc_html__('Actions', 'event_espresso'), |
|
60 | + ); |
|
61 | + $this->addConditionalColumns(); |
|
62 | + $this->_sortable_columns = array( |
|
63 | + 'id' => array('EVT_ID' => true), |
|
64 | + 'name' => array('EVT_name' => false), |
|
65 | + 'author' => array('EVT_wp_user' => false), |
|
66 | + 'venue' => array('Venue.VNU_name' => false), |
|
67 | + 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
|
68 | + 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
|
69 | + ); |
|
70 | + |
|
71 | + $this->_primary_column = 'id'; |
|
72 | + $this->_hidden_columns = array('author', 'event_category'); |
|
73 | + } |
|
74 | + |
|
75 | + |
|
76 | + /** |
|
77 | + * @return array |
|
78 | + */ |
|
79 | + protected function _get_table_filters() |
|
80 | + { |
|
81 | + return array(); // no filters with decaf |
|
82 | + } |
|
83 | + |
|
84 | + |
|
85 | + /** |
|
86 | + * Setup of views properties. |
|
87 | + * |
|
88 | + * @throws InvalidDataTypeException |
|
89 | + * @throws InvalidInterfaceException |
|
90 | + * @throws InvalidArgumentException |
|
91 | + */ |
|
92 | + protected function _add_view_counts() |
|
93 | + { |
|
94 | + $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
95 | + $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
96 | + if ( |
|
97 | + EE_Registry::instance()->CAP->current_user_can( |
|
98 | + 'ee_delete_events', |
|
99 | + 'espresso_events_trash_events' |
|
100 | + ) |
|
101 | + ) { |
|
102 | + $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
103 | + } |
|
104 | + } |
|
105 | + |
|
106 | + |
|
107 | + /** |
|
108 | + * @param EE_Event $item |
|
109 | + * @return string |
|
110 | + * @throws EE_Error |
|
111 | + */ |
|
112 | + protected function _get_row_class($item) |
|
113 | + { |
|
114 | + $class = parent::_get_row_class($item); |
|
115 | + // add status class |
|
116 | + $class .= $item instanceof EE_Event |
|
117 | + ? ' ee-status-strip event-status-' . $item->get_active_status() |
|
118 | + : ''; |
|
119 | + if ($this->_has_checkbox_column) { |
|
120 | + $class .= ' has-checkbox-column'; |
|
121 | + } |
|
122 | + return $class; |
|
123 | + } |
|
124 | + |
|
125 | + |
|
126 | + /** |
|
127 | + * @param EE_Event $item |
|
128 | + * @return string |
|
129 | + * @throws EE_Error |
|
130 | + */ |
|
131 | + public function column_status(EE_Event $item) |
|
132 | + { |
|
133 | + return '<span class="ee-status-strip ee-status-strip-td event-status-' |
|
134 | + . $item->get_active_status() |
|
135 | + . '"></span>'; |
|
136 | + } |
|
137 | + |
|
138 | + |
|
139 | + /** |
|
140 | + * @param EE_Event $item |
|
141 | + * @return string |
|
142 | + * @throws EE_Error |
|
143 | + */ |
|
144 | + public function column_cb($item) |
|
145 | + { |
|
146 | + if (! $item instanceof EE_Event) { |
|
147 | + return ''; |
|
148 | + } |
|
149 | + $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
|
150 | + return sprintf( |
|
151 | + '<input type="checkbox" name="EVT_IDs[]" value="%s" class="ee-event-list-bulk-select-event"/>', |
|
152 | + $item->ID() |
|
153 | + ); |
|
154 | + } |
|
155 | + |
|
156 | + |
|
157 | + /** |
|
158 | + * @param EE_Event $item |
|
159 | + * @return mixed|string |
|
160 | + * @throws EE_Error |
|
161 | + */ |
|
162 | + public function column_id(EE_Event $item) |
|
163 | + { |
|
164 | + $content = $item->ID(); |
|
165 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
166 | + return $content; |
|
167 | + } |
|
168 | + |
|
169 | + |
|
170 | + /** |
|
171 | + * @param EE_Event $item |
|
172 | + * @return string |
|
173 | + * @throws EE_Error |
|
174 | + * @throws InvalidArgumentException |
|
175 | + * @throws InvalidDataTypeException |
|
176 | + * @throws InvalidInterfaceException |
|
177 | + */ |
|
178 | + public function column_name(EE_Event $item) |
|
179 | + { |
|
180 | + $edit_query_args = array( |
|
181 | + 'action' => 'edit', |
|
182 | + 'post' => $item->ID(), |
|
183 | + ); |
|
184 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
185 | + $actions = $this->_column_name_action_setup($item); |
|
186 | + $status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
|
187 | + $content = '<strong><a class="row-title" href="' |
|
188 | + . $edit_link . '">' |
|
189 | + . $item->name() |
|
190 | + . '</a></strong>' |
|
191 | + . $status; |
|
192 | + $content .= '<br><span class="ee-status-text-small">' |
|
193 | + . EEH_Template::pretty_status( |
|
194 | + $item->get_active_status(), |
|
195 | + false, |
|
196 | + 'sentence' |
|
197 | + ) |
|
198 | + . '</span>'; |
|
199 | + $content .= $this->row_actions($actions); |
|
200 | + return $content; |
|
201 | + } |
|
202 | + |
|
203 | + |
|
204 | + /** |
|
205 | + * Just a method for setting up the actions for the name column |
|
206 | + * |
|
207 | + * @param EE_Event $item |
|
208 | + * @return array array of actions |
|
209 | + * @throws EE_Error |
|
210 | + * @throws InvalidArgumentException |
|
211 | + * @throws InvalidDataTypeException |
|
212 | + * @throws InvalidInterfaceException |
|
213 | + */ |
|
214 | + protected function _column_name_action_setup(EE_Event $item) |
|
215 | + { |
|
216 | + // todo: remove when attendees is active |
|
217 | + if (! defined('REG_ADMIN_URL')) { |
|
218 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
219 | + } |
|
220 | + $actions = array(); |
|
221 | + $restore_event_link = ''; |
|
222 | + $delete_event_link = ''; |
|
223 | + $trash_event_link = ''; |
|
224 | + if ( |
|
225 | + EE_Registry::instance()->CAP->current_user_can( |
|
226 | + 'ee_edit_event', |
|
227 | + 'espresso_events_edit', |
|
228 | + $item->ID() |
|
229 | + ) |
|
230 | + ) { |
|
231 | + $edit_query_args = array( |
|
232 | + 'action' => 'edit', |
|
233 | + 'post' => $item->ID(), |
|
234 | + ); |
|
235 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
236 | + $actions['edit'] = '<a href="' . $edit_link . '"' |
|
237 | + . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
238 | + . esc_html__('Edit', 'event_espresso') |
|
239 | + . '</a>'; |
|
240 | + } |
|
241 | + if ( |
|
242 | + EE_Registry::instance()->CAP->current_user_can( |
|
243 | + 'ee_read_registrations', |
|
244 | + 'espresso_registrations_view_registration' |
|
245 | + ) |
|
246 | + && EE_Registry::instance()->CAP->current_user_can( |
|
247 | + 'ee_read_event', |
|
248 | + 'espresso_registrations_view_registration', |
|
249 | + $item->ID() |
|
250 | + ) |
|
251 | + ) { |
|
252 | + $attendees_query_args = array( |
|
253 | + 'action' => 'default', |
|
254 | + 'event_id' => $item->ID(), |
|
255 | + ); |
|
256 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
257 | + $actions['attendees'] = '<a href="' . $attendees_link . '"' |
|
258 | + . ' title="' . esc_attr__('View Registrations', 'event_espresso') . '">' |
|
259 | + . esc_html__('Registrations', 'event_espresso') |
|
260 | + . '</a>'; |
|
261 | + } |
|
262 | + if ( |
|
263 | + EE_Registry::instance()->CAP->current_user_can( |
|
264 | + 'ee_delete_event', |
|
265 | + 'espresso_events_trash_event', |
|
266 | + $item->ID() |
|
267 | + ) |
|
268 | + ) { |
|
269 | + $trash_event_query_args = array( |
|
270 | + 'action' => 'trash_event', |
|
271 | + 'EVT_ID' => $item->ID(), |
|
272 | + ); |
|
273 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
274 | + $trash_event_query_args, |
|
275 | + EVENTS_ADMIN_URL |
|
276 | + ); |
|
277 | + } |
|
278 | + if ( |
|
279 | + EE_Registry::instance()->CAP->current_user_can( |
|
280 | + 'ee_delete_event', |
|
281 | + 'espresso_events_restore_event', |
|
282 | + $item->ID() |
|
283 | + ) |
|
284 | + ) { |
|
285 | + $restore_event_query_args = array( |
|
286 | + 'action' => 'restore_event', |
|
287 | + 'EVT_ID' => $item->ID(), |
|
288 | + ); |
|
289 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
290 | + $restore_event_query_args, |
|
291 | + EVENTS_ADMIN_URL |
|
292 | + ); |
|
293 | + } |
|
294 | + if ( |
|
295 | + EE_Registry::instance()->CAP->current_user_can( |
|
296 | + 'ee_delete_event', |
|
297 | + 'espresso_events_delete_event', |
|
298 | + $item->ID() |
|
299 | + ) |
|
300 | + ) { |
|
301 | + $delete_event_query_args = array( |
|
302 | + 'action' => 'delete_event', |
|
303 | + 'EVT_ID' => $item->ID(), |
|
304 | + ); |
|
305 | + $delete_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
306 | + $delete_event_query_args, |
|
307 | + EVENTS_ADMIN_URL |
|
308 | + ); |
|
309 | + } |
|
310 | + $view_link = get_permalink($item->ID()); |
|
311 | + $actions['view'] = '<a href="' . $view_link . '"' |
|
312 | + . ' title="' . esc_attr__('View Event', 'event_espresso') . '">' |
|
313 | + . esc_html__('View', 'event_espresso') |
|
314 | + . '</a>'; |
|
315 | + if ($item->get('status') === 'trash') { |
|
316 | + if ( |
|
317 | + EE_Registry::instance()->CAP->current_user_can( |
|
318 | + 'ee_delete_event', |
|
319 | + 'espresso_events_restore_event', |
|
320 | + $item->ID() |
|
321 | + ) |
|
322 | + ) { |
|
323 | + $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"' |
|
324 | + . ' title="' . esc_attr__('Restore from Trash', 'event_espresso') |
|
325 | + . '">' |
|
326 | + . esc_html__('Restore from Trash', 'event_espresso') |
|
327 | + . '</a>'; |
|
328 | + } |
|
329 | + if ( |
|
330 | + EE_Registry::instance()->CAP->current_user_can( |
|
331 | + 'ee_delete_event', |
|
332 | + 'espresso_events_delete_event', |
|
333 | + $item->ID() |
|
334 | + ) |
|
335 | + ) { |
|
336 | + $actions['delete'] = '<a href="' . $delete_event_link . '"' |
|
337 | + . ' title="' . esc_attr__('Delete Permanently', 'event_espresso') . '">' |
|
338 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
339 | + . '</a>'; |
|
340 | + } |
|
341 | + } else { |
|
342 | + if ( |
|
343 | + EE_Registry::instance()->CAP->current_user_can( |
|
344 | + 'ee_delete_event', |
|
345 | + 'espresso_events_trash_event', |
|
346 | + $item->ID() |
|
347 | + ) |
|
348 | + ) { |
|
349 | + $actions['move to trash'] = '<a href="' . $trash_event_link . '"' |
|
350 | + . ' title="' . esc_attr__('Trash Event', 'event_espresso') . '">' |
|
351 | + . esc_html__('Trash', 'event_espresso') |
|
352 | + . '</a>'; |
|
353 | + } |
|
354 | + } |
|
355 | + return $actions; |
|
356 | + } |
|
357 | + |
|
358 | + |
|
359 | + /** |
|
360 | + * @param EE_Event $item |
|
361 | + * @return string |
|
362 | + * @throws EE_Error |
|
363 | + */ |
|
364 | + public function column_author(EE_Event $item) |
|
365 | + { |
|
366 | + // user author info |
|
367 | + $event_author = get_userdata($item->wp_user()); |
|
368 | + $gravatar = get_avatar($item->wp_user(), '15'); |
|
369 | + // filter link |
|
370 | + $query_args = array( |
|
371 | + 'action' => 'default', |
|
372 | + 'EVT_wp_user' => $item->wp_user(), |
|
373 | + ); |
|
374 | + $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
375 | + return $gravatar . ' <a href="' . $filter_url . '"' |
|
376 | + . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
377 | + . $event_author->display_name |
|
378 | + . '</a>'; |
|
379 | + } |
|
380 | + |
|
381 | + |
|
382 | + /** |
|
383 | + * @param EE_Event $event |
|
384 | + * @return string |
|
385 | + * @throws EE_Error |
|
386 | + */ |
|
387 | + public function column_event_category(EE_Event $event) |
|
388 | + { |
|
389 | + $event_categories = $event->get_all_event_categories(); |
|
390 | + return implode( |
|
391 | + ', ', |
|
392 | + array_map( |
|
393 | + function (EE_Term $category) { |
|
394 | + return $category->name(); |
|
395 | + }, |
|
396 | + $event_categories |
|
397 | + ) |
|
398 | + ); |
|
399 | + } |
|
400 | + |
|
401 | + |
|
402 | + /** |
|
403 | + * @param EE_Event $item |
|
404 | + * @return string |
|
405 | + * @throws EE_Error |
|
406 | + */ |
|
407 | + public function column_venue(EE_Event $item) |
|
408 | + { |
|
409 | + $venue = $item->get_first_related('Venue'); |
|
410 | + return ! empty($venue) |
|
411 | + ? $venue->name() |
|
412 | + : ''; |
|
413 | + } |
|
414 | + |
|
415 | + |
|
416 | + /** |
|
417 | + * @param EE_Event $item |
|
418 | + * @return string |
|
419 | + * @throws EE_Error |
|
420 | + */ |
|
421 | + public function column_start_date_time(EE_Event $item) |
|
422 | + { |
|
423 | + return $this->_dtt instanceof EE_Datetime |
|
424 | + ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
425 | + : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
426 | + } |
|
427 | + |
|
428 | + |
|
429 | + /** |
|
430 | + * @param EE_Event $item |
|
431 | + * @return string |
|
432 | + * @throws EE_Error |
|
433 | + */ |
|
434 | + public function column_reg_begins(EE_Event $item) |
|
435 | + { |
|
436 | + $reg_start = $item->get_ticket_with_earliest_start_time(); |
|
437 | + return $reg_start instanceof EE_Ticket |
|
438 | + ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
439 | + : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
440 | + } |
|
441 | + |
|
442 | + |
|
443 | + /** |
|
444 | + * @param EE_Event $item |
|
445 | + * @return int|string |
|
446 | + * @throws EE_Error |
|
447 | + * @throws InvalidArgumentException |
|
448 | + * @throws InvalidDataTypeException |
|
449 | + * @throws InvalidInterfaceException |
|
450 | + */ |
|
451 | + public function column_attendees(EE_Event $item) |
|
452 | + { |
|
453 | + $attendees_query_args = array( |
|
454 | + 'action' => 'default', |
|
455 | + 'event_id' => $item->ID(), |
|
456 | + ); |
|
457 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
458 | + $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
459 | + return EE_Registry::instance()->CAP->current_user_can( |
|
460 | + 'ee_read_event', |
|
461 | + 'espresso_registrations_view_registration', |
|
462 | + $item->ID() |
|
463 | + ) |
|
464 | + && EE_Registry::instance()->CAP->current_user_can( |
|
465 | + 'ee_read_registrations', |
|
466 | + 'espresso_registrations_view_registration' |
|
467 | + ) |
|
468 | + ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
469 | + : $registered_attendees; |
|
470 | + } |
|
471 | + |
|
472 | + |
|
473 | + /** |
|
474 | + * @param EE_Event $item |
|
475 | + * @return float |
|
476 | + * @throws EE_Error |
|
477 | + * @throws InvalidArgumentException |
|
478 | + * @throws InvalidDataTypeException |
|
479 | + * @throws InvalidInterfaceException |
|
480 | + */ |
|
481 | + public function column_tkts_sold(EE_Event $item) |
|
482 | + { |
|
483 | + return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
484 | + } |
|
485 | + |
|
486 | + |
|
487 | + /** |
|
488 | + * @param EE_Event $item |
|
489 | + * @return string |
|
490 | + * @throws EE_Error |
|
491 | + * @throws InvalidArgumentException |
|
492 | + * @throws InvalidDataTypeException |
|
493 | + * @throws InvalidInterfaceException |
|
494 | + */ |
|
495 | + public function column_actions(EE_Event $item) |
|
496 | + { |
|
497 | + // todo: remove when attendees is active |
|
498 | + if (! defined('REG_ADMIN_URL')) { |
|
499 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
500 | + } |
|
501 | + $action_links = array(); |
|
502 | + $view_link = get_permalink($item->ID()); |
|
503 | + $action_links[] = '<a href="' . $view_link . '"' |
|
504 | + . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
505 | + $action_links[] = '<div class="dashicons dashicons-search"></div></a>'; |
|
506 | + if ( |
|
507 | + EE_Registry::instance()->CAP->current_user_can( |
|
508 | + 'ee_edit_event', |
|
509 | + 'espresso_events_edit', |
|
510 | + $item->ID() |
|
511 | + ) |
|
512 | + ) { |
|
513 | + $edit_query_args = array( |
|
514 | + 'action' => 'edit', |
|
515 | + 'post' => $item->ID(), |
|
516 | + ); |
|
517 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
518 | + $action_links[] = '<a href="' . $edit_link . '"' |
|
519 | + . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
520 | + . '<div class="ee-icon ee-icon-calendar-edit"></div>' |
|
521 | + . '</a>'; |
|
522 | + } |
|
523 | + if ( |
|
524 | + EE_Registry::instance()->CAP->current_user_can( |
|
525 | + 'ee_read_registrations', |
|
526 | + 'espresso_registrations_view_registration' |
|
527 | + ) && EE_Registry::instance()->CAP->current_user_can( |
|
528 | + 'ee_read_event', |
|
529 | + 'espresso_registrations_view_registration', |
|
530 | + $item->ID() |
|
531 | + ) |
|
532 | + ) { |
|
533 | + $attendees_query_args = array( |
|
534 | + 'action' => 'default', |
|
535 | + 'event_id' => $item->ID(), |
|
536 | + ); |
|
537 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
538 | + $action_links[] = '<a href="' . $attendees_link . '"' |
|
539 | + . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
540 | + . '<div class="dashicons dashicons-groups"></div>' |
|
541 | + . '</a>'; |
|
542 | + } |
|
543 | + $action_links = apply_filters( |
|
544 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
545 | + $action_links, |
|
546 | + $item |
|
547 | + ); |
|
548 | + return $this->_action_string( |
|
549 | + implode("\n\t", $action_links), |
|
550 | + $item, |
|
551 | + 'div' |
|
552 | + ); |
|
553 | + } |
|
554 | + |
|
555 | + |
|
556 | + /** |
|
557 | + * Helper for adding columns conditionally |
|
558 | + * |
|
559 | + * @throws EE_Error |
|
560 | + * @throws InvalidArgumentException |
|
561 | + * @throws InvalidDataTypeException |
|
562 | + * @throws InvalidInterfaceException |
|
563 | + */ |
|
564 | + private function addConditionalColumns() |
|
565 | + { |
|
566 | + $event_category_count = EEM_Term::instance()->count( |
|
567 | + [['Term_Taxonomy.taxonomy' => EEM_CPT_Base::EVENT_CATEGORY_TAXONOMY]] |
|
568 | + ); |
|
569 | + if ($event_category_count === 0) { |
|
570 | + return; |
|
571 | + } |
|
572 | + $column_array = []; |
|
573 | + foreach ($this->_columns as $column => $column_label) { |
|
574 | + $column_array[ $column ] = $column_label; |
|
575 | + if ($column === 'venue') { |
|
576 | + $column_array['event_category'] = esc_html__('Event Category', 'event_espresso'); |
|
577 | + } |
|
578 | + } |
|
579 | + $this->_columns = $column_array; |
|
580 | + } |
|
581 | 581 | } |