@@ -15,536 +15,536 @@ |
||
| 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" />', |
|
| 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->_sortable_columns = array( |
|
| 62 | - 'id' => array('EVT_ID' => true), |
|
| 63 | - 'name' => array('EVT_name' => false), |
|
| 64 | - 'author' => array('EVT_wp_user' => false), |
|
| 65 | - 'venue' => array('Venue.VNU_name' => false), |
|
| 66 | - 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
|
| 67 | - 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
|
| 68 | - ); |
|
| 69 | - $this->_primary_column = 'id'; |
|
| 70 | - $this->_hidden_columns = array('author'); |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - |
|
| 74 | - /** |
|
| 75 | - * @return array |
|
| 76 | - */ |
|
| 77 | - protected function _get_table_filters() |
|
| 78 | - { |
|
| 79 | - return array(); // no filters with decaf |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - |
|
| 83 | - /** |
|
| 84 | - * Setup of views properties. |
|
| 85 | - * |
|
| 86 | - * @throws InvalidDataTypeException |
|
| 87 | - * @throws InvalidInterfaceException |
|
| 88 | - * @throws InvalidArgumentException |
|
| 89 | - */ |
|
| 90 | - protected function _add_view_counts() |
|
| 91 | - { |
|
| 92 | - $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
| 93 | - $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
| 94 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 95 | - 'ee_delete_events', |
|
| 96 | - 'espresso_events_trash_events' |
|
| 97 | - )) { |
|
| 98 | - $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
| 99 | - } |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - |
|
| 103 | - /** |
|
| 104 | - * @param EE_Event $item |
|
| 105 | - * @return string |
|
| 106 | - * @throws EE_Error |
|
| 107 | - */ |
|
| 108 | - protected function _get_row_class($item) |
|
| 109 | - { |
|
| 110 | - $class = parent::_get_row_class($item); |
|
| 111 | - // add status class |
|
| 112 | - $class .= $item instanceof EE_Event |
|
| 113 | - ? ' ee-status-strip event-status-' . $item->get_active_status() |
|
| 114 | - : ''; |
|
| 115 | - if ($this->_has_checkbox_column) { |
|
| 116 | - $class .= ' has-checkbox-column'; |
|
| 117 | - } |
|
| 118 | - return $class; |
|
| 119 | - } |
|
| 120 | - |
|
| 121 | - |
|
| 122 | - /** |
|
| 123 | - * @param EE_Event $item |
|
| 124 | - * @return string |
|
| 125 | - * @throws EE_Error |
|
| 126 | - */ |
|
| 127 | - public function column_status(EE_Event $item) |
|
| 128 | - { |
|
| 129 | - return '<span class="ee-status-strip ee-status-strip-td event-status-' |
|
| 130 | - . $item->get_active_status() |
|
| 131 | - . '"></span>'; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - |
|
| 135 | - /** |
|
| 136 | - * @param EE_Event $item |
|
| 137 | - * @return string |
|
| 138 | - * @throws EE_Error |
|
| 139 | - */ |
|
| 140 | - public function column_cb($item) |
|
| 141 | - { |
|
| 142 | - if (! $item instanceof EE_Event) { |
|
| 143 | - return ''; |
|
| 144 | - } |
|
| 145 | - $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
|
| 146 | - // does event have any attached registrations? |
|
| 147 | - $regs = $item->count_related('Registration'); |
|
| 148 | - return $regs > 0 && $this->_view === 'trash' |
|
| 149 | - ? '<span class="ee-lock-icon"></span>' |
|
| 150 | - : sprintf( |
|
| 151 | - '<input type="checkbox" name="EVT_IDs[]" value="%s" />', |
|
| 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 (EE_Registry::instance()->CAP->current_user_can( |
|
| 225 | - 'ee_edit_event', |
|
| 226 | - 'espresso_events_edit', |
|
| 227 | - $item->ID() |
|
| 228 | - )) { |
|
| 229 | - $edit_query_args = array( |
|
| 230 | - 'action' => 'edit', |
|
| 231 | - 'post' => $item->ID(), |
|
| 232 | - ); |
|
| 233 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 234 | - $actions['edit'] = '<a href="' . $edit_link . '"' |
|
| 235 | - . ' aria-label="' |
|
| 236 | - /* Translators: The name of the event */ |
|
| 237 | - . sprintf(esc_attr__('Edit Event (%s)', 'event_espresso'), $item->name()) |
|
| 238 | - . '">' |
|
| 239 | - . esc_html__('Edit', 'event_espresso') |
|
| 240 | - . '</a>'; |
|
| 241 | - } |
|
| 242 | - if (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 | - . ' aria-label="' |
|
| 259 | - . sprintf( |
|
| 260 | - /* Translators: The name of the event */ |
|
| 261 | - esc_attr__('View Registrations for the event: %s', 'event_espresso'), |
|
| 262 | - $item->name() |
|
| 263 | - ) |
|
| 264 | - . '">' |
|
| 265 | - . esc_html__('Registrations', 'event_espresso') |
|
| 266 | - . '</a>'; |
|
| 267 | - } |
|
| 268 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 269 | - 'ee_delete_event', |
|
| 270 | - 'espresso_events_trash_event', |
|
| 271 | - $item->ID() |
|
| 272 | - )) { |
|
| 273 | - $trash_event_query_args = array( |
|
| 274 | - 'action' => 'trash_event', |
|
| 275 | - 'EVT_ID' => $item->ID(), |
|
| 276 | - ); |
|
| 277 | - $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 278 | - $trash_event_query_args, |
|
| 279 | - EVENTS_ADMIN_URL |
|
| 280 | - ); |
|
| 281 | - } |
|
| 282 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 283 | - 'ee_delete_event', |
|
| 284 | - 'espresso_events_restore_event', |
|
| 285 | - $item->ID() |
|
| 286 | - )) { |
|
| 287 | - $restore_event_query_args = array( |
|
| 288 | - 'action' => 'restore_event', |
|
| 289 | - 'EVT_ID' => $item->ID(), |
|
| 290 | - ); |
|
| 291 | - $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 292 | - $restore_event_query_args, |
|
| 293 | - EVENTS_ADMIN_URL |
|
| 294 | - ); |
|
| 295 | - } |
|
| 296 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 297 | - 'ee_delete_event', |
|
| 298 | - 'espresso_events_delete_event', |
|
| 299 | - $item->ID() |
|
| 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 | - . ' aria-label="' |
|
| 313 | - /* Translators: The name of the event */ |
|
| 314 | - . sprintf(esc_attr__('View Event (%s)', 'event_espresso'), $item->name()) |
|
| 315 | - . '">' |
|
| 316 | - . esc_html__('View', 'event_espresso') |
|
| 317 | - . '</a>'; |
|
| 318 | - if ($item->get('status') === 'trash') { |
|
| 319 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 320 | - 'ee_delete_event', |
|
| 321 | - 'espresso_events_restore_event', |
|
| 322 | - $item->ID() |
|
| 323 | - )) { |
|
| 324 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"' |
|
| 325 | - . ' aria-label="' |
|
| 326 | - . sprintf( |
|
| 327 | - /* Translators: The name of the event */ |
|
| 328 | - esc_attr__( |
|
| 329 | - 'Restore from Trash the event: %s', |
|
| 330 | - 'event_espresso' |
|
| 331 | - ), |
|
| 332 | - $item->name() |
|
| 333 | - ) |
|
| 334 | - . '">' |
|
| 335 | - . esc_html__('Restore from Trash', 'event_espresso') |
|
| 336 | - . '</a>'; |
|
| 337 | - } |
|
| 338 | - if ($item->count_related('Registration') === 0 |
|
| 339 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 340 | - 'ee_delete_event', |
|
| 341 | - 'espresso_events_delete_event', |
|
| 342 | - $item->ID() |
|
| 343 | - ) |
|
| 344 | - ) { |
|
| 345 | - $actions['delete'] = '<a href="' . $delete_event_link . '"' |
|
| 346 | - . ' aria-label="' |
|
| 347 | - . sprintf( |
|
| 348 | - /* Translators: The name of the event. */ |
|
| 349 | - esc_attr__('Delete Permanently the event: %s', 'event_espresso'), |
|
| 350 | - $item->name() |
|
| 351 | - ) |
|
| 352 | - . '">' |
|
| 353 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
| 354 | - . '</a>'; |
|
| 355 | - } |
|
| 356 | - } else { |
|
| 357 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 358 | - 'ee_delete_event', |
|
| 359 | - 'espresso_events_trash_event', |
|
| 360 | - $item->ID() |
|
| 361 | - )) { |
|
| 362 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '"' |
|
| 363 | - . ' aria-label="' |
|
| 364 | - . sprintf( |
|
| 365 | - /* Translators: The name of the event */ |
|
| 366 | - esc_attr__('Move the event %s to the trash.', 'event_espresso'), |
|
| 367 | - $item->name() |
|
| 368 | - ) |
|
| 369 | - . '">' |
|
| 370 | - . esc_html__('Trash', 'event_espresso') |
|
| 371 | - . '</a>'; |
|
| 372 | - } |
|
| 373 | - } |
|
| 374 | - return $actions; |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - |
|
| 378 | - /** |
|
| 379 | - * @param EE_Event $item |
|
| 380 | - * @return string |
|
| 381 | - * @throws EE_Error |
|
| 382 | - */ |
|
| 383 | - public function column_author(EE_Event $item) |
|
| 384 | - { |
|
| 385 | - // user author info |
|
| 386 | - $event_author = get_userdata($item->wp_user()); |
|
| 387 | - $gravatar = get_avatar($item->wp_user(), '15'); |
|
| 388 | - // filter link |
|
| 389 | - $query_args = array( |
|
| 390 | - 'action' => 'default', |
|
| 391 | - 'EVT_wp_user' => $item->wp_user(), |
|
| 392 | - ); |
|
| 393 | - $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
| 394 | - return $gravatar . ' <a href="' . $filter_url . '"' |
|
| 395 | - . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
| 396 | - . $event_author->display_name |
|
| 397 | - . '</a>'; |
|
| 398 | - } |
|
| 399 | - |
|
| 400 | - |
|
| 401 | - /** |
|
| 402 | - * @param EE_Event $item |
|
| 403 | - * @return string |
|
| 404 | - * @throws EE_Error |
|
| 405 | - */ |
|
| 406 | - public function column_venue(EE_Event $item) |
|
| 407 | - { |
|
| 408 | - $venue = $item->get_first_related('Venue'); |
|
| 409 | - return ! empty($venue) |
|
| 410 | - ? $venue->name() |
|
| 411 | - : ''; |
|
| 412 | - } |
|
| 413 | - |
|
| 414 | - |
|
| 415 | - /** |
|
| 416 | - * @param EE_Event $item |
|
| 417 | - * @return string |
|
| 418 | - * @throws EE_Error |
|
| 419 | - */ |
|
| 420 | - public function column_start_date_time(EE_Event $item) |
|
| 421 | - { |
|
| 422 | - return $this->_dtt instanceof EE_Datetime |
|
| 423 | - ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
| 424 | - : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - |
|
| 428 | - /** |
|
| 429 | - * @param EE_Event $item |
|
| 430 | - * @return string |
|
| 431 | - * @throws EE_Error |
|
| 432 | - */ |
|
| 433 | - public function column_reg_begins(EE_Event $item) |
|
| 434 | - { |
|
| 435 | - $reg_start = $item->get_ticket_with_earliest_start_time(); |
|
| 436 | - return $reg_start instanceof EE_Ticket |
|
| 437 | - ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
| 438 | - : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
| 439 | - } |
|
| 440 | - |
|
| 441 | - |
|
| 442 | - /** |
|
| 443 | - * @param EE_Event $item |
|
| 444 | - * @return int|string |
|
| 445 | - * @throws EE_Error |
|
| 446 | - * @throws InvalidArgumentException |
|
| 447 | - * @throws InvalidDataTypeException |
|
| 448 | - * @throws InvalidInterfaceException |
|
| 449 | - */ |
|
| 450 | - public function column_attendees(EE_Event $item) |
|
| 451 | - { |
|
| 452 | - $attendees_query_args = array( |
|
| 453 | - 'action' => 'default', |
|
| 454 | - 'event_id' => $item->ID(), |
|
| 455 | - ); |
|
| 456 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 457 | - $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
| 458 | - return EE_Registry::instance()->CAP->current_user_can( |
|
| 459 | - 'ee_read_event', |
|
| 460 | - 'espresso_registrations_view_registration', |
|
| 461 | - $item->ID() |
|
| 462 | - ) |
|
| 463 | - && EE_Registry::instance()->CAP->current_user_can( |
|
| 464 | - 'ee_read_registrations', |
|
| 465 | - 'espresso_registrations_view_registration' |
|
| 466 | - ) |
|
| 467 | - ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
| 468 | - : $registered_attendees; |
|
| 469 | - } |
|
| 470 | - |
|
| 471 | - |
|
| 472 | - /** |
|
| 473 | - * @param EE_Event $item |
|
| 474 | - * @return float |
|
| 475 | - * @throws EE_Error |
|
| 476 | - * @throws InvalidArgumentException |
|
| 477 | - * @throws InvalidDataTypeException |
|
| 478 | - * @throws InvalidInterfaceException |
|
| 479 | - */ |
|
| 480 | - public function column_tkts_sold(EE_Event $item) |
|
| 481 | - { |
|
| 482 | - return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
| 483 | - } |
|
| 484 | - |
|
| 485 | - |
|
| 486 | - /** |
|
| 487 | - * @param EE_Event $item |
|
| 488 | - * @return string |
|
| 489 | - * @throws EE_Error |
|
| 490 | - * @throws InvalidArgumentException |
|
| 491 | - * @throws InvalidDataTypeException |
|
| 492 | - * @throws InvalidInterfaceException |
|
| 493 | - */ |
|
| 494 | - public function column_actions(EE_Event $item) |
|
| 495 | - { |
|
| 496 | - // todo: remove when attendees is active |
|
| 497 | - if (! defined('REG_ADMIN_URL')) { |
|
| 498 | - define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 499 | - } |
|
| 500 | - $action_links = array(); |
|
| 501 | - $view_link = get_permalink($item->ID()); |
|
| 502 | - $action_links[] = '<a href="' . $view_link . '"' |
|
| 503 | - . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
| 504 | - $action_links[] = '<div class="dashicons dashicons-search"></div></a>'; |
|
| 505 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 506 | - 'ee_edit_event', |
|
| 507 | - 'espresso_events_edit', |
|
| 508 | - $item->ID() |
|
| 509 | - )) { |
|
| 510 | - $edit_query_args = array( |
|
| 511 | - 'action' => 'edit', |
|
| 512 | - 'post' => $item->ID(), |
|
| 513 | - ); |
|
| 514 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 515 | - $action_links[] = '<a href="' . $edit_link . '"' |
|
| 516 | - . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 517 | - . '<div class="ee-icon ee-icon-calendar-edit"></div>' |
|
| 518 | - . '</a>'; |
|
| 519 | - } |
|
| 520 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 521 | - 'ee_read_registrations', |
|
| 522 | - 'espresso_registrations_view_registration' |
|
| 523 | - ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 524 | - 'ee_read_event', |
|
| 525 | - 'espresso_registrations_view_registration', |
|
| 526 | - $item->ID() |
|
| 527 | - ) |
|
| 528 | - ) { |
|
| 529 | - $attendees_query_args = array( |
|
| 530 | - 'action' => 'default', |
|
| 531 | - 'event_id' => $item->ID(), |
|
| 532 | - ); |
|
| 533 | - $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 534 | - $action_links[] = '<a href="' . $attendees_link . '"' |
|
| 535 | - . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
| 536 | - . '<div class="dashicons dashicons-groups"></div>' |
|
| 537 | - . '</a>'; |
|
| 538 | - } |
|
| 539 | - $action_links = apply_filters( |
|
| 540 | - 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 541 | - $action_links, |
|
| 542 | - $item |
|
| 543 | - ); |
|
| 544 | - return $this->_action_string( |
|
| 545 | - implode("\n\t", $action_links), |
|
| 546 | - $item, |
|
| 547 | - 'div' |
|
| 548 | - ); |
|
| 549 | - } |
|
| 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" />', |
|
| 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->_sortable_columns = array( |
|
| 62 | + 'id' => array('EVT_ID' => true), |
|
| 63 | + 'name' => array('EVT_name' => false), |
|
| 64 | + 'author' => array('EVT_wp_user' => false), |
|
| 65 | + 'venue' => array('Venue.VNU_name' => false), |
|
| 66 | + 'start_date_time' => array('Datetime.DTT_EVT_start' => false), |
|
| 67 | + 'reg_begins' => array('Datetime.Ticket.TKT_start_date' => false), |
|
| 68 | + ); |
|
| 69 | + $this->_primary_column = 'id'; |
|
| 70 | + $this->_hidden_columns = array('author'); |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + |
|
| 74 | + /** |
|
| 75 | + * @return array |
|
| 76 | + */ |
|
| 77 | + protected function _get_table_filters() |
|
| 78 | + { |
|
| 79 | + return array(); // no filters with decaf |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + |
|
| 83 | + /** |
|
| 84 | + * Setup of views properties. |
|
| 85 | + * |
|
| 86 | + * @throws InvalidDataTypeException |
|
| 87 | + * @throws InvalidInterfaceException |
|
| 88 | + * @throws InvalidArgumentException |
|
| 89 | + */ |
|
| 90 | + protected function _add_view_counts() |
|
| 91 | + { |
|
| 92 | + $this->_views['all']['count'] = $this->_admin_page->total_events(); |
|
| 93 | + $this->_views['draft']['count'] = $this->_admin_page->total_events_draft(); |
|
| 94 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 95 | + 'ee_delete_events', |
|
| 96 | + 'espresso_events_trash_events' |
|
| 97 | + )) { |
|
| 98 | + $this->_views['trash']['count'] = $this->_admin_page->total_trashed_events(); |
|
| 99 | + } |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + |
|
| 103 | + /** |
|
| 104 | + * @param EE_Event $item |
|
| 105 | + * @return string |
|
| 106 | + * @throws EE_Error |
|
| 107 | + */ |
|
| 108 | + protected function _get_row_class($item) |
|
| 109 | + { |
|
| 110 | + $class = parent::_get_row_class($item); |
|
| 111 | + // add status class |
|
| 112 | + $class .= $item instanceof EE_Event |
|
| 113 | + ? ' ee-status-strip event-status-' . $item->get_active_status() |
|
| 114 | + : ''; |
|
| 115 | + if ($this->_has_checkbox_column) { |
|
| 116 | + $class .= ' has-checkbox-column'; |
|
| 117 | + } |
|
| 118 | + return $class; |
|
| 119 | + } |
|
| 120 | + |
|
| 121 | + |
|
| 122 | + /** |
|
| 123 | + * @param EE_Event $item |
|
| 124 | + * @return string |
|
| 125 | + * @throws EE_Error |
|
| 126 | + */ |
|
| 127 | + public function column_status(EE_Event $item) |
|
| 128 | + { |
|
| 129 | + return '<span class="ee-status-strip ee-status-strip-td event-status-' |
|
| 130 | + . $item->get_active_status() |
|
| 131 | + . '"></span>'; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + |
|
| 135 | + /** |
|
| 136 | + * @param EE_Event $item |
|
| 137 | + * @return string |
|
| 138 | + * @throws EE_Error |
|
| 139 | + */ |
|
| 140 | + public function column_cb($item) |
|
| 141 | + { |
|
| 142 | + if (! $item instanceof EE_Event) { |
|
| 143 | + return ''; |
|
| 144 | + } |
|
| 145 | + $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
|
| 146 | + // does event have any attached registrations? |
|
| 147 | + $regs = $item->count_related('Registration'); |
|
| 148 | + return $regs > 0 && $this->_view === 'trash' |
|
| 149 | + ? '<span class="ee-lock-icon"></span>' |
|
| 150 | + : sprintf( |
|
| 151 | + '<input type="checkbox" name="EVT_IDs[]" value="%s" />', |
|
| 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 (EE_Registry::instance()->CAP->current_user_can( |
|
| 225 | + 'ee_edit_event', |
|
| 226 | + 'espresso_events_edit', |
|
| 227 | + $item->ID() |
|
| 228 | + )) { |
|
| 229 | + $edit_query_args = array( |
|
| 230 | + 'action' => 'edit', |
|
| 231 | + 'post' => $item->ID(), |
|
| 232 | + ); |
|
| 233 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 234 | + $actions['edit'] = '<a href="' . $edit_link . '"' |
|
| 235 | + . ' aria-label="' |
|
| 236 | + /* Translators: The name of the event */ |
|
| 237 | + . sprintf(esc_attr__('Edit Event (%s)', 'event_espresso'), $item->name()) |
|
| 238 | + . '">' |
|
| 239 | + . esc_html__('Edit', 'event_espresso') |
|
| 240 | + . '</a>'; |
|
| 241 | + } |
|
| 242 | + if (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 | + . ' aria-label="' |
|
| 259 | + . sprintf( |
|
| 260 | + /* Translators: The name of the event */ |
|
| 261 | + esc_attr__('View Registrations for the event: %s', 'event_espresso'), |
|
| 262 | + $item->name() |
|
| 263 | + ) |
|
| 264 | + . '">' |
|
| 265 | + . esc_html__('Registrations', 'event_espresso') |
|
| 266 | + . '</a>'; |
|
| 267 | + } |
|
| 268 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 269 | + 'ee_delete_event', |
|
| 270 | + 'espresso_events_trash_event', |
|
| 271 | + $item->ID() |
|
| 272 | + )) { |
|
| 273 | + $trash_event_query_args = array( |
|
| 274 | + 'action' => 'trash_event', |
|
| 275 | + 'EVT_ID' => $item->ID(), |
|
| 276 | + ); |
|
| 277 | + $trash_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 278 | + $trash_event_query_args, |
|
| 279 | + EVENTS_ADMIN_URL |
|
| 280 | + ); |
|
| 281 | + } |
|
| 282 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 283 | + 'ee_delete_event', |
|
| 284 | + 'espresso_events_restore_event', |
|
| 285 | + $item->ID() |
|
| 286 | + )) { |
|
| 287 | + $restore_event_query_args = array( |
|
| 288 | + 'action' => 'restore_event', |
|
| 289 | + 'EVT_ID' => $item->ID(), |
|
| 290 | + ); |
|
| 291 | + $restore_event_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 292 | + $restore_event_query_args, |
|
| 293 | + EVENTS_ADMIN_URL |
|
| 294 | + ); |
|
| 295 | + } |
|
| 296 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 297 | + 'ee_delete_event', |
|
| 298 | + 'espresso_events_delete_event', |
|
| 299 | + $item->ID() |
|
| 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 | + . ' aria-label="' |
|
| 313 | + /* Translators: The name of the event */ |
|
| 314 | + . sprintf(esc_attr__('View Event (%s)', 'event_espresso'), $item->name()) |
|
| 315 | + . '">' |
|
| 316 | + . esc_html__('View', 'event_espresso') |
|
| 317 | + . '</a>'; |
|
| 318 | + if ($item->get('status') === 'trash') { |
|
| 319 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 320 | + 'ee_delete_event', |
|
| 321 | + 'espresso_events_restore_event', |
|
| 322 | + $item->ID() |
|
| 323 | + )) { |
|
| 324 | + $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"' |
|
| 325 | + . ' aria-label="' |
|
| 326 | + . sprintf( |
|
| 327 | + /* Translators: The name of the event */ |
|
| 328 | + esc_attr__( |
|
| 329 | + 'Restore from Trash the event: %s', |
|
| 330 | + 'event_espresso' |
|
| 331 | + ), |
|
| 332 | + $item->name() |
|
| 333 | + ) |
|
| 334 | + . '">' |
|
| 335 | + . esc_html__('Restore from Trash', 'event_espresso') |
|
| 336 | + . '</a>'; |
|
| 337 | + } |
|
| 338 | + if ($item->count_related('Registration') === 0 |
|
| 339 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 340 | + 'ee_delete_event', |
|
| 341 | + 'espresso_events_delete_event', |
|
| 342 | + $item->ID() |
|
| 343 | + ) |
|
| 344 | + ) { |
|
| 345 | + $actions['delete'] = '<a href="' . $delete_event_link . '"' |
|
| 346 | + . ' aria-label="' |
|
| 347 | + . sprintf( |
|
| 348 | + /* Translators: The name of the event. */ |
|
| 349 | + esc_attr__('Delete Permanently the event: %s', 'event_espresso'), |
|
| 350 | + $item->name() |
|
| 351 | + ) |
|
| 352 | + . '">' |
|
| 353 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
| 354 | + . '</a>'; |
|
| 355 | + } |
|
| 356 | + } else { |
|
| 357 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 358 | + 'ee_delete_event', |
|
| 359 | + 'espresso_events_trash_event', |
|
| 360 | + $item->ID() |
|
| 361 | + )) { |
|
| 362 | + $actions['move to trash'] = '<a href="' . $trash_event_link . '"' |
|
| 363 | + . ' aria-label="' |
|
| 364 | + . sprintf( |
|
| 365 | + /* Translators: The name of the event */ |
|
| 366 | + esc_attr__('Move the event %s to the trash.', 'event_espresso'), |
|
| 367 | + $item->name() |
|
| 368 | + ) |
|
| 369 | + . '">' |
|
| 370 | + . esc_html__('Trash', 'event_espresso') |
|
| 371 | + . '</a>'; |
|
| 372 | + } |
|
| 373 | + } |
|
| 374 | + return $actions; |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + |
|
| 378 | + /** |
|
| 379 | + * @param EE_Event $item |
|
| 380 | + * @return string |
|
| 381 | + * @throws EE_Error |
|
| 382 | + */ |
|
| 383 | + public function column_author(EE_Event $item) |
|
| 384 | + { |
|
| 385 | + // user author info |
|
| 386 | + $event_author = get_userdata($item->wp_user()); |
|
| 387 | + $gravatar = get_avatar($item->wp_user(), '15'); |
|
| 388 | + // filter link |
|
| 389 | + $query_args = array( |
|
| 390 | + 'action' => 'default', |
|
| 391 | + 'EVT_wp_user' => $item->wp_user(), |
|
| 392 | + ); |
|
| 393 | + $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
|
| 394 | + return $gravatar . ' <a href="' . $filter_url . '"' |
|
| 395 | + . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
| 396 | + . $event_author->display_name |
|
| 397 | + . '</a>'; |
|
| 398 | + } |
|
| 399 | + |
|
| 400 | + |
|
| 401 | + /** |
|
| 402 | + * @param EE_Event $item |
|
| 403 | + * @return string |
|
| 404 | + * @throws EE_Error |
|
| 405 | + */ |
|
| 406 | + public function column_venue(EE_Event $item) |
|
| 407 | + { |
|
| 408 | + $venue = $item->get_first_related('Venue'); |
|
| 409 | + return ! empty($venue) |
|
| 410 | + ? $venue->name() |
|
| 411 | + : ''; |
|
| 412 | + } |
|
| 413 | + |
|
| 414 | + |
|
| 415 | + /** |
|
| 416 | + * @param EE_Event $item |
|
| 417 | + * @return string |
|
| 418 | + * @throws EE_Error |
|
| 419 | + */ |
|
| 420 | + public function column_start_date_time(EE_Event $item) |
|
| 421 | + { |
|
| 422 | + return $this->_dtt instanceof EE_Datetime |
|
| 423 | + ? $this->_dtt->get_i18n_datetime('DTT_EVT_start') |
|
| 424 | + : esc_html__('No Date was saved for this Event', 'event_espresso'); |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + |
|
| 428 | + /** |
|
| 429 | + * @param EE_Event $item |
|
| 430 | + * @return string |
|
| 431 | + * @throws EE_Error |
|
| 432 | + */ |
|
| 433 | + public function column_reg_begins(EE_Event $item) |
|
| 434 | + { |
|
| 435 | + $reg_start = $item->get_ticket_with_earliest_start_time(); |
|
| 436 | + return $reg_start instanceof EE_Ticket |
|
| 437 | + ? $reg_start->get_i18n_datetime('TKT_start_date') |
|
| 438 | + : esc_html__('No Tickets have been setup for this Event', 'event_espresso'); |
|
| 439 | + } |
|
| 440 | + |
|
| 441 | + |
|
| 442 | + /** |
|
| 443 | + * @param EE_Event $item |
|
| 444 | + * @return int|string |
|
| 445 | + * @throws EE_Error |
|
| 446 | + * @throws InvalidArgumentException |
|
| 447 | + * @throws InvalidDataTypeException |
|
| 448 | + * @throws InvalidInterfaceException |
|
| 449 | + */ |
|
| 450 | + public function column_attendees(EE_Event $item) |
|
| 451 | + { |
|
| 452 | + $attendees_query_args = array( |
|
| 453 | + 'action' => 'default', |
|
| 454 | + 'event_id' => $item->ID(), |
|
| 455 | + ); |
|
| 456 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 457 | + $registered_attendees = EEM_Registration::instance()->get_event_registration_count($item->ID()); |
|
| 458 | + return EE_Registry::instance()->CAP->current_user_can( |
|
| 459 | + 'ee_read_event', |
|
| 460 | + 'espresso_registrations_view_registration', |
|
| 461 | + $item->ID() |
|
| 462 | + ) |
|
| 463 | + && EE_Registry::instance()->CAP->current_user_can( |
|
| 464 | + 'ee_read_registrations', |
|
| 465 | + 'espresso_registrations_view_registration' |
|
| 466 | + ) |
|
| 467 | + ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
| 468 | + : $registered_attendees; |
|
| 469 | + } |
|
| 470 | + |
|
| 471 | + |
|
| 472 | + /** |
|
| 473 | + * @param EE_Event $item |
|
| 474 | + * @return float |
|
| 475 | + * @throws EE_Error |
|
| 476 | + * @throws InvalidArgumentException |
|
| 477 | + * @throws InvalidDataTypeException |
|
| 478 | + * @throws InvalidInterfaceException |
|
| 479 | + */ |
|
| 480 | + public function column_tkts_sold(EE_Event $item) |
|
| 481 | + { |
|
| 482 | + return EEM_Ticket::instance()->sum(array(array('Datetime.EVT_ID' => $item->ID())), 'TKT_sold'); |
|
| 483 | + } |
|
| 484 | + |
|
| 485 | + |
|
| 486 | + /** |
|
| 487 | + * @param EE_Event $item |
|
| 488 | + * @return string |
|
| 489 | + * @throws EE_Error |
|
| 490 | + * @throws InvalidArgumentException |
|
| 491 | + * @throws InvalidDataTypeException |
|
| 492 | + * @throws InvalidInterfaceException |
|
| 493 | + */ |
|
| 494 | + public function column_actions(EE_Event $item) |
|
| 495 | + { |
|
| 496 | + // todo: remove when attendees is active |
|
| 497 | + if (! defined('REG_ADMIN_URL')) { |
|
| 498 | + define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
|
| 499 | + } |
|
| 500 | + $action_links = array(); |
|
| 501 | + $view_link = get_permalink($item->ID()); |
|
| 502 | + $action_links[] = '<a href="' . $view_link . '"' |
|
| 503 | + . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
| 504 | + $action_links[] = '<div class="dashicons dashicons-search"></div></a>'; |
|
| 505 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 506 | + 'ee_edit_event', |
|
| 507 | + 'espresso_events_edit', |
|
| 508 | + $item->ID() |
|
| 509 | + )) { |
|
| 510 | + $edit_query_args = array( |
|
| 511 | + 'action' => 'edit', |
|
| 512 | + 'post' => $item->ID(), |
|
| 513 | + ); |
|
| 514 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 515 | + $action_links[] = '<a href="' . $edit_link . '"' |
|
| 516 | + . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 517 | + . '<div class="ee-icon ee-icon-calendar-edit"></div>' |
|
| 518 | + . '</a>'; |
|
| 519 | + } |
|
| 520 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 521 | + 'ee_read_registrations', |
|
| 522 | + 'espresso_registrations_view_registration' |
|
| 523 | + ) && EE_Registry::instance()->CAP->current_user_can( |
|
| 524 | + 'ee_read_event', |
|
| 525 | + 'espresso_registrations_view_registration', |
|
| 526 | + $item->ID() |
|
| 527 | + ) |
|
| 528 | + ) { |
|
| 529 | + $attendees_query_args = array( |
|
| 530 | + 'action' => 'default', |
|
| 531 | + 'event_id' => $item->ID(), |
|
| 532 | + ); |
|
| 533 | + $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
|
| 534 | + $action_links[] = '<a href="' . $attendees_link . '"' |
|
| 535 | + . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
| 536 | + . '<div class="dashicons dashicons-groups"></div>' |
|
| 537 | + . '</a>'; |
|
| 538 | + } |
|
| 539 | + $action_links = apply_filters( |
|
| 540 | + 'FHEE__Events_Admin_List_Table__column_actions__action_links', |
|
| 541 | + $action_links, |
|
| 542 | + $item |
|
| 543 | + ); |
|
| 544 | + return $this->_action_string( |
|
| 545 | + implode("\n\t", $action_links), |
|
| 546 | + $item, |
|
| 547 | + 'div' |
|
| 548 | + ); |
|
| 549 | + } |
|
| 550 | 550 | } |
@@ -110,7 +110,7 @@ discard block |
||
| 110 | 110 | $class = parent::_get_row_class($item); |
| 111 | 111 | // add status class |
| 112 | 112 | $class .= $item instanceof EE_Event |
| 113 | - ? ' ee-status-strip event-status-' . $item->get_active_status() |
|
| 113 | + ? ' ee-status-strip event-status-'.$item->get_active_status() |
|
| 114 | 114 | : ''; |
| 115 | 115 | if ($this->_has_checkbox_column) { |
| 116 | 116 | $class .= ' has-checkbox-column'; |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | */ |
| 140 | 140 | public function column_cb($item) |
| 141 | 141 | { |
| 142 | - if (! $item instanceof EE_Event) { |
|
| 142 | + if ( ! $item instanceof EE_Event) { |
|
| 143 | 143 | return ''; |
| 144 | 144 | } |
| 145 | 145 | $this->_dtt = $item->primary_datetime(); // set this for use in other columns |
@@ -162,7 +162,7 @@ discard block |
||
| 162 | 162 | public function column_id(EE_Event $item) |
| 163 | 163 | { |
| 164 | 164 | $content = $item->ID(); |
| 165 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 165 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->name().'</span>'; |
|
| 166 | 166 | return $content; |
| 167 | 167 | } |
| 168 | 168 | |
@@ -185,7 +185,7 @@ discard block |
||
| 185 | 185 | $actions = $this->_column_name_action_setup($item); |
| 186 | 186 | $status = ''; // $item->status() !== 'publish' ? ' (' . $item->status() . ')' : ''; |
| 187 | 187 | $content = '<strong><a class="row-title" href="' |
| 188 | - . $edit_link . '">' |
|
| 188 | + . $edit_link.'">' |
|
| 189 | 189 | . $item->name() |
| 190 | 190 | . '</a></strong>' |
| 191 | 191 | . $status; |
@@ -214,7 +214,7 @@ discard block |
||
| 214 | 214 | protected function _column_name_action_setup(EE_Event $item) |
| 215 | 215 | { |
| 216 | 216 | // todo: remove when attendees is active |
| 217 | - if (! defined('REG_ADMIN_URL')) { |
|
| 217 | + if ( ! defined('REG_ADMIN_URL')) { |
|
| 218 | 218 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
| 219 | 219 | } |
| 220 | 220 | $actions = array(); |
@@ -231,7 +231,7 @@ discard block |
||
| 231 | 231 | 'post' => $item->ID(), |
| 232 | 232 | ); |
| 233 | 233 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
| 234 | - $actions['edit'] = '<a href="' . $edit_link . '"' |
|
| 234 | + $actions['edit'] = '<a href="'.$edit_link.'"' |
|
| 235 | 235 | . ' aria-label="' |
| 236 | 236 | /* Translators: The name of the event */ |
| 237 | 237 | . sprintf(esc_attr__('Edit Event (%s)', 'event_espresso'), $item->name()) |
@@ -254,7 +254,7 @@ discard block |
||
| 254 | 254 | 'event_id' => $item->ID(), |
| 255 | 255 | ); |
| 256 | 256 | $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
| 257 | - $actions['attendees'] = '<a href="' . $attendees_link . '"' |
|
| 257 | + $actions['attendees'] = '<a href="'.$attendees_link.'"' |
|
| 258 | 258 | . ' aria-label="' |
| 259 | 259 | . sprintf( |
| 260 | 260 | /* Translators: The name of the event */ |
@@ -308,7 +308,7 @@ discard block |
||
| 308 | 308 | ); |
| 309 | 309 | } |
| 310 | 310 | $view_link = get_permalink($item->ID()); |
| 311 | - $actions['view'] = '<a href="' . $view_link . '"' |
|
| 311 | + $actions['view'] = '<a href="'.$view_link.'"' |
|
| 312 | 312 | . ' aria-label="' |
| 313 | 313 | /* Translators: The name of the event */ |
| 314 | 314 | . sprintf(esc_attr__('View Event (%s)', 'event_espresso'), $item->name()) |
@@ -321,7 +321,7 @@ discard block |
||
| 321 | 321 | 'espresso_events_restore_event', |
| 322 | 322 | $item->ID() |
| 323 | 323 | )) { |
| 324 | - $actions['restore_from_trash'] = '<a href="' . $restore_event_link . '"' |
|
| 324 | + $actions['restore_from_trash'] = '<a href="'.$restore_event_link.'"' |
|
| 325 | 325 | . ' aria-label="' |
| 326 | 326 | . sprintf( |
| 327 | 327 | /* Translators: The name of the event */ |
@@ -342,7 +342,7 @@ discard block |
||
| 342 | 342 | $item->ID() |
| 343 | 343 | ) |
| 344 | 344 | ) { |
| 345 | - $actions['delete'] = '<a href="' . $delete_event_link . '"' |
|
| 345 | + $actions['delete'] = '<a href="'.$delete_event_link.'"' |
|
| 346 | 346 | . ' aria-label="' |
| 347 | 347 | . sprintf( |
| 348 | 348 | /* Translators: The name of the event. */ |
@@ -359,7 +359,7 @@ discard block |
||
| 359 | 359 | 'espresso_events_trash_event', |
| 360 | 360 | $item->ID() |
| 361 | 361 | )) { |
| 362 | - $actions['move to trash'] = '<a href="' . $trash_event_link . '"' |
|
| 362 | + $actions['move to trash'] = '<a href="'.$trash_event_link.'"' |
|
| 363 | 363 | . ' aria-label="' |
| 364 | 364 | . sprintf( |
| 365 | 365 | /* Translators: The name of the event */ |
@@ -391,8 +391,8 @@ discard block |
||
| 391 | 391 | 'EVT_wp_user' => $item->wp_user(), |
| 392 | 392 | ); |
| 393 | 393 | $filter_url = EE_Admin_Page::add_query_args_and_nonce($query_args, EVENTS_ADMIN_URL); |
| 394 | - return $gravatar . ' <a href="' . $filter_url . '"' |
|
| 395 | - . ' title="' . esc_attr__('Click to filter events by this author.', 'event_espresso') . '">' |
|
| 394 | + return $gravatar.' <a href="'.$filter_url.'"' |
|
| 395 | + . ' title="'.esc_attr__('Click to filter events by this author.', 'event_espresso').'">' |
|
| 396 | 396 | . $event_author->display_name |
| 397 | 397 | . '</a>'; |
| 398 | 398 | } |
@@ -464,7 +464,7 @@ discard block |
||
| 464 | 464 | 'ee_read_registrations', |
| 465 | 465 | 'espresso_registrations_view_registration' |
| 466 | 466 | ) |
| 467 | - ? '<a href="' . $attendees_link . '">' . $registered_attendees . '</a>' |
|
| 467 | + ? '<a href="'.$attendees_link.'">'.$registered_attendees.'</a>' |
|
| 468 | 468 | : $registered_attendees; |
| 469 | 469 | } |
| 470 | 470 | |
@@ -494,13 +494,13 @@ discard block |
||
| 494 | 494 | public function column_actions(EE_Event $item) |
| 495 | 495 | { |
| 496 | 496 | // todo: remove when attendees is active |
| 497 | - if (! defined('REG_ADMIN_URL')) { |
|
| 497 | + if ( ! defined('REG_ADMIN_URL')) { |
|
| 498 | 498 | define('REG_ADMIN_URL', EVENTS_ADMIN_URL); |
| 499 | 499 | } |
| 500 | 500 | $action_links = array(); |
| 501 | 501 | $view_link = get_permalink($item->ID()); |
| 502 | - $action_links[] = '<a href="' . $view_link . '"' |
|
| 503 | - . ' title="' . esc_attr__('View Event', 'event_espresso') . '" target="_blank">'; |
|
| 502 | + $action_links[] = '<a href="'.$view_link.'"' |
|
| 503 | + . ' title="'.esc_attr__('View Event', 'event_espresso').'" target="_blank">'; |
|
| 504 | 504 | $action_links[] = '<div class="dashicons dashicons-search"></div></a>'; |
| 505 | 505 | if (EE_Registry::instance()->CAP->current_user_can( |
| 506 | 506 | 'ee_edit_event', |
@@ -512,8 +512,8 @@ discard block |
||
| 512 | 512 | 'post' => $item->ID(), |
| 513 | 513 | ); |
| 514 | 514 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
| 515 | - $action_links[] = '<a href="' . $edit_link . '"' |
|
| 516 | - . ' title="' . esc_attr__('Edit Event', 'event_espresso') . '">' |
|
| 515 | + $action_links[] = '<a href="'.$edit_link.'"' |
|
| 516 | + . ' title="'.esc_attr__('Edit Event', 'event_espresso').'">' |
|
| 517 | 517 | . '<div class="ee-icon ee-icon-calendar-edit"></div>' |
| 518 | 518 | . '</a>'; |
| 519 | 519 | } |
@@ -531,8 +531,8 @@ discard block |
||
| 531 | 531 | 'event_id' => $item->ID(), |
| 532 | 532 | ); |
| 533 | 533 | $attendees_link = EE_Admin_Page::add_query_args_and_nonce($attendees_query_args, REG_ADMIN_URL); |
| 534 | - $action_links[] = '<a href="' . $attendees_link . '"' |
|
| 535 | - . ' title="' . esc_attr__('View Registrants', 'event_espresso') . '">' |
|
| 534 | + $action_links[] = '<a href="'.$attendees_link.'"' |
|
| 535 | + . ' title="'.esc_attr__('View Registrants', 'event_espresso').'">' |
|
| 536 | 536 | . '<div class="dashicons dashicons-groups"></div>' |
| 537 | 537 | . '</a>'; |
| 538 | 538 | } |
@@ -16,261 +16,261 @@ |
||
| 16 | 16 | class Venues_Admin_List_Table extends EE_Admin_List_Table |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - public function __construct($admin_page) |
|
| 20 | - { |
|
| 21 | - parent::__construct($admin_page); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - protected function _setup_data() |
|
| 26 | - { |
|
| 27 | - $this->_data = $this->_admin_page->get_venues($this->_per_page); |
|
| 28 | - $this->_all_data_count = $this->_admin_page->get_venues($this->_per_page, true); |
|
| 29 | - } |
|
| 30 | - |
|
| 31 | - |
|
| 32 | - protected function _set_properties() |
|
| 33 | - { |
|
| 34 | - $this->_wp_list_args = array( |
|
| 35 | - 'singular' => __('Event Venue', 'event_espresso'), |
|
| 36 | - 'plural' => __('Event Venues', 'event_espresso'), |
|
| 37 | - 'ajax' => true, // for now, |
|
| 38 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 39 | - ); |
|
| 40 | - |
|
| 41 | - $this->_columns = array( |
|
| 42 | - 'cb' => '<input type="checkbox" />', |
|
| 43 | - 'id' => __('ID', 'event_espresso'), |
|
| 44 | - 'name' => __('Name', 'event_espresso'), |
|
| 45 | - 'address' => __('Address', 'event_espresso'), |
|
| 46 | - 'city' => __('City', 'event_espresso'), |
|
| 47 | - 'capacity' => __('Capacity', 'event_espresso'), |
|
| 48 | - // 'shortcode' => __('Shortcode', 'event_espresso'), |
|
| 49 | - ); |
|
| 50 | - |
|
| 51 | - $this->_sortable_columns = array( |
|
| 52 | - 'id' => array('id' => true), |
|
| 53 | - 'name' => array('name' => false), |
|
| 54 | - 'city' => array('city' => false), |
|
| 55 | - 'capacity' => array('capacity' => false), |
|
| 56 | - ); |
|
| 57 | - |
|
| 58 | - $this->_hidden_columns = array(); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - |
|
| 62 | - // todo... add _venue_status in here (which we'll define a EE_Admin_CPT_List_Table for common properties) |
|
| 63 | - protected function _get_table_filters() |
|
| 64 | - { |
|
| 65 | - return array(); |
|
| 66 | - } |
|
| 67 | - |
|
| 68 | - |
|
| 69 | - protected function _add_view_counts() |
|
| 70 | - { |
|
| 71 | - $this->_views['all']['count'] = EEM_Venue::instance()->count(); |
|
| 72 | - if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) { |
|
| 73 | - $this->_views['trash']['count'] = EEM_Venue::instance()->count_deleted(); |
|
| 74 | - } |
|
| 75 | - } |
|
| 76 | - |
|
| 77 | - |
|
| 78 | - public function column_cb($item) |
|
| 79 | - { |
|
| 80 | - |
|
| 81 | - return $item->count_related('Event') > 0 && $item->get('status') === 'trash' |
|
| 82 | - ? '<span class="ee-lock-icon"></span>' |
|
| 83 | - : sprintf( |
|
| 84 | - '<input type="checkbox" name="venue_id[]" value="%s" />', |
|
| 85 | - $item->ID() |
|
| 86 | - ); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - |
|
| 90 | - public function column_id($item) |
|
| 91 | - { |
|
| 92 | - $content = $item->ID(); |
|
| 93 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 94 | - return $content; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - |
|
| 98 | - public function column_name($item) |
|
| 99 | - { |
|
| 100 | - $edit_query_args = array( |
|
| 101 | - 'action' => 'edit', |
|
| 102 | - 'post' => $item->ID(), |
|
| 103 | - ); |
|
| 104 | - |
|
| 105 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
| 106 | - |
|
| 107 | - $statuses = EEM_Venue::instance()->get_status_array(); |
|
| 108 | - $actions = $this->_column_name_action_setup($item); |
|
| 109 | - $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID()) |
|
| 110 | - ? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep( |
|
| 111 | - $item->name() |
|
| 112 | - ) . '</a></strong>' : $item->name(); |
|
| 113 | - $content .= $item->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : ''; |
|
| 114 | - $content .= $this->row_actions($actions); |
|
| 115 | - return $content; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - |
|
| 119 | - /** |
|
| 120 | - * Used to setup the actions for the Venue name column |
|
| 121 | - * |
|
| 122 | - * @param EE_Venue $item |
|
| 123 | - * @return array() |
|
| 124 | - */ |
|
| 125 | - protected function _column_name_action_setup(EE_Venue $item) |
|
| 126 | - { |
|
| 127 | - $actions = array(); |
|
| 128 | - |
|
| 129 | - if (EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID())) { |
|
| 130 | - $edit_query_args = array( |
|
| 131 | - 'action' => 'edit', |
|
| 132 | - 'post' => $item->ID(), |
|
| 133 | - ); |
|
| 134 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
| 135 | - $actions['edit'] = '<a href="' . $edit_link . '"' |
|
| 136 | - . 'aria-label="' |
|
| 137 | - /* Translators: The name of the venue */ |
|
| 138 | - . sprintf(esc_attr__('Edit Venue (%s)', 'event_espresso'), $item->name()) |
|
| 139 | - . '">' |
|
| 140 | - . esc_html__('Edit', 'event_espresso') |
|
| 141 | - . '</a>'; |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - |
|
| 145 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 146 | - 'ee_delete_venue', |
|
| 147 | - 'espresso_venues_trash_venue', |
|
| 148 | - $item->ID() |
|
| 149 | - )) { |
|
| 150 | - $trash_event_query_arg = array( |
|
| 151 | - 'action' => 'trash_venue', |
|
| 152 | - 'VNU_ID' => $item->ID(), |
|
| 153 | - ); |
|
| 154 | - $trash_venue_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_arg, EE_VENUES_ADMIN_URL); |
|
| 155 | - } |
|
| 156 | - |
|
| 157 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 158 | - 'ee_delete_venue', |
|
| 159 | - 'espresso_venues_restore_venue', |
|
| 160 | - $item->ID() |
|
| 161 | - )) { |
|
| 162 | - $restore_venue_query_args = array( |
|
| 163 | - 'action' => 'restore_venue', |
|
| 164 | - 'VNU_ID' => $item->ID(), |
|
| 165 | - ); |
|
| 166 | - $restore_venue_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 167 | - $restore_venue_query_args, |
|
| 168 | - EE_VENUES_ADMIN_URL |
|
| 169 | - ); |
|
| 170 | - } |
|
| 171 | - |
|
| 172 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 173 | - 'ee_delete_venue', |
|
| 174 | - 'espresso_venues_delete_venue', |
|
| 175 | - $item->ID() |
|
| 176 | - )) { |
|
| 177 | - $delete_venue_query_args = array( |
|
| 178 | - 'action' => 'delete_venue', |
|
| 179 | - 'VNU_ID' => $item->ID(), |
|
| 180 | - ); |
|
| 181 | - $delete_venue_link = EE_Admin_Page::add_query_args_and_nonce($delete_venue_query_args, EE_VENUES_ADMIN_URL); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - $view_link = get_permalink($item->ID()); |
|
| 185 | - |
|
| 186 | - switch ($item->get('status')) { |
|
| 187 | - case 'trash': |
|
| 188 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 189 | - 'ee_delete_venue', |
|
| 190 | - 'espresso_venues_restore_venue', |
|
| 191 | - $item->ID() |
|
| 192 | - )) { |
|
| 193 | - $actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '"' |
|
| 194 | - . ' aria-label="' |
|
| 195 | - . sprintf( |
|
| 196 | - /* Translators: The name of the venue */ |
|
| 197 | - esc_attr__( |
|
| 198 | - 'Restore from Trash the venue: %s', |
|
| 199 | - 'event_espresso' |
|
| 200 | - ), |
|
| 201 | - $item->name() |
|
| 202 | - ) |
|
| 203 | - . '">' |
|
| 204 | - . esc_html__('Restore from Trash', 'event_espresso') |
|
| 205 | - . '</a>'; |
|
| 206 | - } |
|
| 207 | - if ($item->count_related('Event') === 0 && EE_Registry::instance()->CAP->current_user_can( |
|
| 208 | - 'ee_delete_venue', |
|
| 209 | - 'espresso_venues_delete_venue', |
|
| 210 | - $item->ID() |
|
| 211 | - )) { |
|
| 212 | - $actions['delete permanently'] = '<a href="' . $delete_venue_link . '"' |
|
| 213 | - . ' aria-label="' |
|
| 214 | - . sprintf( |
|
| 215 | - /* Translators: The name of the venue. */ |
|
| 216 | - esc_attr__('Delete Permanently the venue: %s', 'event_espresso'), |
|
| 217 | - $item->name() |
|
| 218 | - ) |
|
| 219 | - . '">' |
|
| 220 | - . esc_html__('Delete Permanently', 'event_espresso') |
|
| 221 | - . '</a>'; |
|
| 222 | - } |
|
| 223 | - break; |
|
| 224 | - default: |
|
| 225 | - $actions['view'] = '<a href="' . $view_link . '"' |
|
| 226 | - . ' aria-label="' |
|
| 227 | - /* Translators: The name of the venue */ |
|
| 228 | - . sprintf(esc_attr__('View Venue (%s)', 'event_espresso'), $item->name()) |
|
| 229 | - . '">' |
|
| 230 | - . esc_html__('View', 'event_espresso') |
|
| 231 | - . '</a>'; |
|
| 232 | - if (EE_Registry::instance()->CAP->current_user_can( |
|
| 233 | - 'ee_delete_venue', |
|
| 234 | - 'espresso_venues_trash_venue', |
|
| 235 | - $item->ID() |
|
| 236 | - )) { |
|
| 237 | - $actions['move to trash'] = '<a href="' . $trash_venue_link . '"' |
|
| 238 | - . ' aria-label="' |
|
| 239 | - . sprintf( |
|
| 240 | - /* Translators: The name of the venue */ |
|
| 241 | - esc_attr__('Move the venue %s to the trash.', 'event_espresso'), |
|
| 242 | - $item->name() |
|
| 243 | - ) |
|
| 244 | - . '">' |
|
| 245 | - . esc_html__('Trash', 'event_espresso') |
|
| 246 | - . '</a>'; |
|
| 247 | - } |
|
| 248 | - } |
|
| 249 | - return $actions; |
|
| 250 | - } |
|
| 251 | - |
|
| 252 | - |
|
| 253 | - public function column_address($item) |
|
| 254 | - { |
|
| 255 | - return $item->address(); |
|
| 256 | - } |
|
| 257 | - |
|
| 258 | - |
|
| 259 | - public function column_city($item) |
|
| 260 | - { |
|
| 261 | - return $item->city(); |
|
| 262 | - } |
|
| 263 | - |
|
| 264 | - |
|
| 265 | - public function column_capacity($item) |
|
| 266 | - { |
|
| 267 | - return $item->capacity(); |
|
| 268 | - } |
|
| 269 | - |
|
| 270 | - |
|
| 271 | - public function column_shortcode($item) |
|
| 272 | - { |
|
| 273 | - $content = '[ESPRESSO_VENUE id=' . $item->ID() . ']'; |
|
| 274 | - return $content; |
|
| 275 | - } |
|
| 19 | + public function __construct($admin_page) |
|
| 20 | + { |
|
| 21 | + parent::__construct($admin_page); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + protected function _setup_data() |
|
| 26 | + { |
|
| 27 | + $this->_data = $this->_admin_page->get_venues($this->_per_page); |
|
| 28 | + $this->_all_data_count = $this->_admin_page->get_venues($this->_per_page, true); |
|
| 29 | + } |
|
| 30 | + |
|
| 31 | + |
|
| 32 | + protected function _set_properties() |
|
| 33 | + { |
|
| 34 | + $this->_wp_list_args = array( |
|
| 35 | + 'singular' => __('Event Venue', 'event_espresso'), |
|
| 36 | + 'plural' => __('Event Venues', 'event_espresso'), |
|
| 37 | + 'ajax' => true, // for now, |
|
| 38 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 39 | + ); |
|
| 40 | + |
|
| 41 | + $this->_columns = array( |
|
| 42 | + 'cb' => '<input type="checkbox" />', |
|
| 43 | + 'id' => __('ID', 'event_espresso'), |
|
| 44 | + 'name' => __('Name', 'event_espresso'), |
|
| 45 | + 'address' => __('Address', 'event_espresso'), |
|
| 46 | + 'city' => __('City', 'event_espresso'), |
|
| 47 | + 'capacity' => __('Capacity', 'event_espresso'), |
|
| 48 | + // 'shortcode' => __('Shortcode', 'event_espresso'), |
|
| 49 | + ); |
|
| 50 | + |
|
| 51 | + $this->_sortable_columns = array( |
|
| 52 | + 'id' => array('id' => true), |
|
| 53 | + 'name' => array('name' => false), |
|
| 54 | + 'city' => array('city' => false), |
|
| 55 | + 'capacity' => array('capacity' => false), |
|
| 56 | + ); |
|
| 57 | + |
|
| 58 | + $this->_hidden_columns = array(); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + |
|
| 62 | + // todo... add _venue_status in here (which we'll define a EE_Admin_CPT_List_Table for common properties) |
|
| 63 | + protected function _get_table_filters() |
|
| 64 | + { |
|
| 65 | + return array(); |
|
| 66 | + } |
|
| 67 | + |
|
| 68 | + |
|
| 69 | + protected function _add_view_counts() |
|
| 70 | + { |
|
| 71 | + $this->_views['all']['count'] = EEM_Venue::instance()->count(); |
|
| 72 | + if (EE_Registry::instance()->CAP->current_user_can('ee_delete_venues', 'espresso_venues_trash_venues')) { |
|
| 73 | + $this->_views['trash']['count'] = EEM_Venue::instance()->count_deleted(); |
|
| 74 | + } |
|
| 75 | + } |
|
| 76 | + |
|
| 77 | + |
|
| 78 | + public function column_cb($item) |
|
| 79 | + { |
|
| 80 | + |
|
| 81 | + return $item->count_related('Event') > 0 && $item->get('status') === 'trash' |
|
| 82 | + ? '<span class="ee-lock-icon"></span>' |
|
| 83 | + : sprintf( |
|
| 84 | + '<input type="checkbox" name="venue_id[]" value="%s" />', |
|
| 85 | + $item->ID() |
|
| 86 | + ); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + |
|
| 90 | + public function column_id($item) |
|
| 91 | + { |
|
| 92 | + $content = $item->ID(); |
|
| 93 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 94 | + return $content; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + |
|
| 98 | + public function column_name($item) |
|
| 99 | + { |
|
| 100 | + $edit_query_args = array( |
|
| 101 | + 'action' => 'edit', |
|
| 102 | + 'post' => $item->ID(), |
|
| 103 | + ); |
|
| 104 | + |
|
| 105 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
| 106 | + |
|
| 107 | + $statuses = EEM_Venue::instance()->get_status_array(); |
|
| 108 | + $actions = $this->_column_name_action_setup($item); |
|
| 109 | + $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID()) |
|
| 110 | + ? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep( |
|
| 111 | + $item->name() |
|
| 112 | + ) . '</a></strong>' : $item->name(); |
|
| 113 | + $content .= $item->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : ''; |
|
| 114 | + $content .= $this->row_actions($actions); |
|
| 115 | + return $content; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + |
|
| 119 | + /** |
|
| 120 | + * Used to setup the actions for the Venue name column |
|
| 121 | + * |
|
| 122 | + * @param EE_Venue $item |
|
| 123 | + * @return array() |
|
| 124 | + */ |
|
| 125 | + protected function _column_name_action_setup(EE_Venue $item) |
|
| 126 | + { |
|
| 127 | + $actions = array(); |
|
| 128 | + |
|
| 129 | + if (EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID())) { |
|
| 130 | + $edit_query_args = array( |
|
| 131 | + 'action' => 'edit', |
|
| 132 | + 'post' => $item->ID(), |
|
| 133 | + ); |
|
| 134 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
|
| 135 | + $actions['edit'] = '<a href="' . $edit_link . '"' |
|
| 136 | + . 'aria-label="' |
|
| 137 | + /* Translators: The name of the venue */ |
|
| 138 | + . sprintf(esc_attr__('Edit Venue (%s)', 'event_espresso'), $item->name()) |
|
| 139 | + . '">' |
|
| 140 | + . esc_html__('Edit', 'event_espresso') |
|
| 141 | + . '</a>'; |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + |
|
| 145 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 146 | + 'ee_delete_venue', |
|
| 147 | + 'espresso_venues_trash_venue', |
|
| 148 | + $item->ID() |
|
| 149 | + )) { |
|
| 150 | + $trash_event_query_arg = array( |
|
| 151 | + 'action' => 'trash_venue', |
|
| 152 | + 'VNU_ID' => $item->ID(), |
|
| 153 | + ); |
|
| 154 | + $trash_venue_link = EE_Admin_Page::add_query_args_and_nonce($trash_event_query_arg, EE_VENUES_ADMIN_URL); |
|
| 155 | + } |
|
| 156 | + |
|
| 157 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 158 | + 'ee_delete_venue', |
|
| 159 | + 'espresso_venues_restore_venue', |
|
| 160 | + $item->ID() |
|
| 161 | + )) { |
|
| 162 | + $restore_venue_query_args = array( |
|
| 163 | + 'action' => 'restore_venue', |
|
| 164 | + 'VNU_ID' => $item->ID(), |
|
| 165 | + ); |
|
| 166 | + $restore_venue_link = EE_Admin_Page::add_query_args_and_nonce( |
|
| 167 | + $restore_venue_query_args, |
|
| 168 | + EE_VENUES_ADMIN_URL |
|
| 169 | + ); |
|
| 170 | + } |
|
| 171 | + |
|
| 172 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 173 | + 'ee_delete_venue', |
|
| 174 | + 'espresso_venues_delete_venue', |
|
| 175 | + $item->ID() |
|
| 176 | + )) { |
|
| 177 | + $delete_venue_query_args = array( |
|
| 178 | + 'action' => 'delete_venue', |
|
| 179 | + 'VNU_ID' => $item->ID(), |
|
| 180 | + ); |
|
| 181 | + $delete_venue_link = EE_Admin_Page::add_query_args_and_nonce($delete_venue_query_args, EE_VENUES_ADMIN_URL); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + $view_link = get_permalink($item->ID()); |
|
| 185 | + |
|
| 186 | + switch ($item->get('status')) { |
|
| 187 | + case 'trash': |
|
| 188 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 189 | + 'ee_delete_venue', |
|
| 190 | + 'espresso_venues_restore_venue', |
|
| 191 | + $item->ID() |
|
| 192 | + )) { |
|
| 193 | + $actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '"' |
|
| 194 | + . ' aria-label="' |
|
| 195 | + . sprintf( |
|
| 196 | + /* Translators: The name of the venue */ |
|
| 197 | + esc_attr__( |
|
| 198 | + 'Restore from Trash the venue: %s', |
|
| 199 | + 'event_espresso' |
|
| 200 | + ), |
|
| 201 | + $item->name() |
|
| 202 | + ) |
|
| 203 | + . '">' |
|
| 204 | + . esc_html__('Restore from Trash', 'event_espresso') |
|
| 205 | + . '</a>'; |
|
| 206 | + } |
|
| 207 | + if ($item->count_related('Event') === 0 && EE_Registry::instance()->CAP->current_user_can( |
|
| 208 | + 'ee_delete_venue', |
|
| 209 | + 'espresso_venues_delete_venue', |
|
| 210 | + $item->ID() |
|
| 211 | + )) { |
|
| 212 | + $actions['delete permanently'] = '<a href="' . $delete_venue_link . '"' |
|
| 213 | + . ' aria-label="' |
|
| 214 | + . sprintf( |
|
| 215 | + /* Translators: The name of the venue. */ |
|
| 216 | + esc_attr__('Delete Permanently the venue: %s', 'event_espresso'), |
|
| 217 | + $item->name() |
|
| 218 | + ) |
|
| 219 | + . '">' |
|
| 220 | + . esc_html__('Delete Permanently', 'event_espresso') |
|
| 221 | + . '</a>'; |
|
| 222 | + } |
|
| 223 | + break; |
|
| 224 | + default: |
|
| 225 | + $actions['view'] = '<a href="' . $view_link . '"' |
|
| 226 | + . ' aria-label="' |
|
| 227 | + /* Translators: The name of the venue */ |
|
| 228 | + . sprintf(esc_attr__('View Venue (%s)', 'event_espresso'), $item->name()) |
|
| 229 | + . '">' |
|
| 230 | + . esc_html__('View', 'event_espresso') |
|
| 231 | + . '</a>'; |
|
| 232 | + if (EE_Registry::instance()->CAP->current_user_can( |
|
| 233 | + 'ee_delete_venue', |
|
| 234 | + 'espresso_venues_trash_venue', |
|
| 235 | + $item->ID() |
|
| 236 | + )) { |
|
| 237 | + $actions['move to trash'] = '<a href="' . $trash_venue_link . '"' |
|
| 238 | + . ' aria-label="' |
|
| 239 | + . sprintf( |
|
| 240 | + /* Translators: The name of the venue */ |
|
| 241 | + esc_attr__('Move the venue %s to the trash.', 'event_espresso'), |
|
| 242 | + $item->name() |
|
| 243 | + ) |
|
| 244 | + . '">' |
|
| 245 | + . esc_html__('Trash', 'event_espresso') |
|
| 246 | + . '</a>'; |
|
| 247 | + } |
|
| 248 | + } |
|
| 249 | + return $actions; |
|
| 250 | + } |
|
| 251 | + |
|
| 252 | + |
|
| 253 | + public function column_address($item) |
|
| 254 | + { |
|
| 255 | + return $item->address(); |
|
| 256 | + } |
|
| 257 | + |
|
| 258 | + |
|
| 259 | + public function column_city($item) |
|
| 260 | + { |
|
| 261 | + return $item->city(); |
|
| 262 | + } |
|
| 263 | + |
|
| 264 | + |
|
| 265 | + public function column_capacity($item) |
|
| 266 | + { |
|
| 267 | + return $item->capacity(); |
|
| 268 | + } |
|
| 269 | + |
|
| 270 | + |
|
| 271 | + public function column_shortcode($item) |
|
| 272 | + { |
|
| 273 | + $content = '[ESPRESSO_VENUE id=' . $item->ID() . ']'; |
|
| 274 | + return $content; |
|
| 275 | + } |
|
| 276 | 276 | } |
@@ -90,7 +90,7 @@ discard block |
||
| 90 | 90 | public function column_id($item) |
| 91 | 91 | { |
| 92 | 92 | $content = $item->ID(); |
| 93 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->name() . '</span>'; |
|
| 93 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->name().'</span>'; |
|
| 94 | 94 | return $content; |
| 95 | 95 | } |
| 96 | 96 | |
@@ -107,10 +107,10 @@ discard block |
||
| 107 | 107 | $statuses = EEM_Venue::instance()->get_status_array(); |
| 108 | 108 | $actions = $this->_column_name_action_setup($item); |
| 109 | 109 | $content = EE_Registry::instance()->CAP->current_user_can('ee_edit_venue', 'espresso_venues_edit', $item->ID()) |
| 110 | - ? '<strong><a class="row-title" href="' . $edit_link . '">' . stripslashes_deep( |
|
| 110 | + ? '<strong><a class="row-title" href="'.$edit_link.'">'.stripslashes_deep( |
|
| 111 | 111 | $item->name() |
| 112 | - ) . '</a></strong>' : $item->name(); |
|
| 113 | - $content .= $item->status() == 'draft' ? ' - <span class="post-state">' . $statuses['draft'] . '</span>' : ''; |
|
| 112 | + ).'</a></strong>' : $item->name(); |
|
| 113 | + $content .= $item->status() == 'draft' ? ' - <span class="post-state">'.$statuses['draft'].'</span>' : ''; |
|
| 114 | 114 | $content .= $this->row_actions($actions); |
| 115 | 115 | return $content; |
| 116 | 116 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | 'post' => $item->ID(), |
| 133 | 133 | ); |
| 134 | 134 | $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EE_VENUES_ADMIN_URL); |
| 135 | - $actions['edit'] = '<a href="' . $edit_link . '"' |
|
| 135 | + $actions['edit'] = '<a href="'.$edit_link.'"' |
|
| 136 | 136 | . 'aria-label="' |
| 137 | 137 | /* Translators: The name of the venue */ |
| 138 | 138 | . sprintf(esc_attr__('Edit Venue (%s)', 'event_espresso'), $item->name()) |
@@ -190,7 +190,7 @@ discard block |
||
| 190 | 190 | 'espresso_venues_restore_venue', |
| 191 | 191 | $item->ID() |
| 192 | 192 | )) { |
| 193 | - $actions['restore_from_trash'] = '<a href="' . $restore_venue_link . '"' |
|
| 193 | + $actions['restore_from_trash'] = '<a href="'.$restore_venue_link.'"' |
|
| 194 | 194 | . ' aria-label="' |
| 195 | 195 | . sprintf( |
| 196 | 196 | /* Translators: The name of the venue */ |
@@ -209,7 +209,7 @@ discard block |
||
| 209 | 209 | 'espresso_venues_delete_venue', |
| 210 | 210 | $item->ID() |
| 211 | 211 | )) { |
| 212 | - $actions['delete permanently'] = '<a href="' . $delete_venue_link . '"' |
|
| 212 | + $actions['delete permanently'] = '<a href="'.$delete_venue_link.'"' |
|
| 213 | 213 | . ' aria-label="' |
| 214 | 214 | . sprintf( |
| 215 | 215 | /* Translators: The name of the venue. */ |
@@ -222,7 +222,7 @@ discard block |
||
| 222 | 222 | } |
| 223 | 223 | break; |
| 224 | 224 | default: |
| 225 | - $actions['view'] = '<a href="' . $view_link . '"' |
|
| 225 | + $actions['view'] = '<a href="'.$view_link.'"' |
|
| 226 | 226 | . ' aria-label="' |
| 227 | 227 | /* Translators: The name of the venue */ |
| 228 | 228 | . sprintf(esc_attr__('View Venue (%s)', 'event_espresso'), $item->name()) |
@@ -234,7 +234,7 @@ discard block |
||
| 234 | 234 | 'espresso_venues_trash_venue', |
| 235 | 235 | $item->ID() |
| 236 | 236 | )) { |
| 237 | - $actions['move to trash'] = '<a href="' . $trash_venue_link . '"' |
|
| 237 | + $actions['move to trash'] = '<a href="'.$trash_venue_link.'"' |
|
| 238 | 238 | . ' aria-label="' |
| 239 | 239 | . sprintf( |
| 240 | 240 | /* Translators: The name of the venue */ |
@@ -270,7 +270,7 @@ discard block |
||
| 270 | 270 | |
| 271 | 271 | public function column_shortcode($item) |
| 272 | 272 | { |
| 273 | - $content = '[ESPRESSO_VENUE id=' . $item->ID() . ']'; |
|
| 273 | + $content = '[ESPRESSO_VENUE id='.$item->ID().']'; |
|
| 274 | 274 | return $content; |
| 275 | 275 | } |
| 276 | 276 | } |
@@ -16,151 +16,151 @@ |
||
| 16 | 16 | class Event_Categories_Admin_List_Table extends EE_Admin_List_Table |
| 17 | 17 | { |
| 18 | 18 | |
| 19 | - public function __construct($admin_page) |
|
| 20 | - { |
|
| 21 | - parent::__construct($admin_page); |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - |
|
| 25 | - protected function _setup_data() |
|
| 26 | - { |
|
| 27 | - $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
| 28 | - $this->_all_data_count = EEM_Term_Taxonomy::instance()->count( |
|
| 29 | - array(array('taxonomy' => 'espresso_event_categories')) |
|
| 30 | - ); |
|
| 31 | - } |
|
| 32 | - |
|
| 33 | - |
|
| 34 | - protected function _set_properties() |
|
| 35 | - { |
|
| 36 | - $this->_wp_list_args = array( |
|
| 37 | - 'singular' => esc_html__('event category', 'event_espresso'), |
|
| 38 | - 'plural' => esc_html__('event categories', 'event_espresso'), |
|
| 39 | - 'ajax' => true, // for now, |
|
| 40 | - 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 41 | - ); |
|
| 42 | - |
|
| 43 | - $this->_columns = array( |
|
| 44 | - 'cb' => '<input type="checkbox" />', |
|
| 45 | - 'id' => esc_html__('ID', 'event_espresso'), |
|
| 46 | - 'name' => esc_html__('Name', 'event_espresso'), |
|
| 47 | - 'shortcode' => esc_html__('Shortcode', 'event_espresso'), |
|
| 48 | - 'count' => esc_html__('Events', 'event_espresso'), |
|
| 49 | - ); |
|
| 50 | - |
|
| 51 | - $this->_sortable_columns = array( |
|
| 52 | - 'id' => array('Term.term_id' => true), |
|
| 53 | - 'name' => array('Term.slug' => false), |
|
| 54 | - 'count' => array('term_count' => false), |
|
| 55 | - ); |
|
| 56 | - |
|
| 57 | - $this->_primary_column = 'id'; |
|
| 58 | - |
|
| 59 | - $this->_hidden_columns = array(); |
|
| 60 | - } |
|
| 61 | - |
|
| 62 | - |
|
| 63 | - // not needed |
|
| 64 | - protected function _get_table_filters() |
|
| 65 | - { |
|
| 66 | - return array(); |
|
| 67 | - } |
|
| 68 | - |
|
| 69 | - |
|
| 70 | - protected function _add_view_counts() |
|
| 71 | - { |
|
| 72 | - $this->_views['all']['count'] = $this->_all_data_count; |
|
| 73 | - } |
|
| 74 | - |
|
| 75 | - |
|
| 76 | - public function column_cb($item) |
|
| 77 | - { |
|
| 78 | - return sprintf('<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
| 79 | - } |
|
| 80 | - |
|
| 81 | - |
|
| 82 | - public function column_id($item) |
|
| 83 | - { |
|
| 84 | - $content = $item->get('term_id'); |
|
| 85 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
| 86 | - 'name' |
|
| 87 | - ) . '</span>'; |
|
| 88 | - return $content; |
|
| 89 | - } |
|
| 90 | - |
|
| 91 | - |
|
| 92 | - public function column_name($item) |
|
| 93 | - { |
|
| 94 | - $edit_query_args = array( |
|
| 95 | - 'action' => 'edit_category', |
|
| 96 | - 'EVT_CAT_ID' => $item->get('term_id'), |
|
| 97 | - ); |
|
| 98 | - |
|
| 99 | - $delete_query_args = array( |
|
| 100 | - 'action' => 'delete_category', |
|
| 101 | - 'EVT_CAT_ID' => $item->get('term_id'), |
|
| 102 | - ); |
|
| 103 | - |
|
| 104 | - $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 105 | - $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
|
| 106 | - |
|
| 107 | - $term_name = $item->get_first_related('Term')->get('name'); |
|
| 108 | - |
|
| 109 | - $actions = array( |
|
| 110 | - 'edit' => '<a href="' . $edit_link . '" aria-label="' . sprintf( |
|
| 111 | - /* translators: The name of the event category */ |
|
| 112 | - esc_attr__( |
|
| 113 | - 'Edit Category (%s)', |
|
| 114 | - 'event_espresso' |
|
| 115 | - ), |
|
| 116 | - $term_name |
|
| 117 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
| 118 | - ); |
|
| 119 | - |
|
| 120 | - |
|
| 121 | - $actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . sprintf( |
|
| 122 | - /* translators: The name of the event category */ |
|
| 123 | - esc_attr__( |
|
| 124 | - 'Delete Category (%s)', |
|
| 125 | - 'event_espresso' |
|
| 126 | - ), |
|
| 127 | - $term_name |
|
| 128 | - ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
| 19 | + public function __construct($admin_page) |
|
| 20 | + { |
|
| 21 | + parent::__construct($admin_page); |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + |
|
| 25 | + protected function _setup_data() |
|
| 26 | + { |
|
| 27 | + $this->_data = $this->_admin_page->get_categories($this->_per_page, $this->_current_page); |
|
| 28 | + $this->_all_data_count = EEM_Term_Taxonomy::instance()->count( |
|
| 29 | + array(array('taxonomy' => 'espresso_event_categories')) |
|
| 30 | + ); |
|
| 31 | + } |
|
| 32 | + |
|
| 33 | + |
|
| 34 | + protected function _set_properties() |
|
| 35 | + { |
|
| 36 | + $this->_wp_list_args = array( |
|
| 37 | + 'singular' => esc_html__('event category', 'event_espresso'), |
|
| 38 | + 'plural' => esc_html__('event categories', 'event_espresso'), |
|
| 39 | + 'ajax' => true, // for now, |
|
| 40 | + 'screen' => $this->_admin_page->get_current_screen()->id, |
|
| 41 | + ); |
|
| 42 | + |
|
| 43 | + $this->_columns = array( |
|
| 44 | + 'cb' => '<input type="checkbox" />', |
|
| 45 | + 'id' => esc_html__('ID', 'event_espresso'), |
|
| 46 | + 'name' => esc_html__('Name', 'event_espresso'), |
|
| 47 | + 'shortcode' => esc_html__('Shortcode', 'event_espresso'), |
|
| 48 | + 'count' => esc_html__('Events', 'event_espresso'), |
|
| 49 | + ); |
|
| 50 | + |
|
| 51 | + $this->_sortable_columns = array( |
|
| 52 | + 'id' => array('Term.term_id' => true), |
|
| 53 | + 'name' => array('Term.slug' => false), |
|
| 54 | + 'count' => array('term_count' => false), |
|
| 55 | + ); |
|
| 56 | + |
|
| 57 | + $this->_primary_column = 'id'; |
|
| 58 | + |
|
| 59 | + $this->_hidden_columns = array(); |
|
| 60 | + } |
|
| 61 | + |
|
| 62 | + |
|
| 63 | + // not needed |
|
| 64 | + protected function _get_table_filters() |
|
| 65 | + { |
|
| 66 | + return array(); |
|
| 67 | + } |
|
| 68 | + |
|
| 69 | + |
|
| 70 | + protected function _add_view_counts() |
|
| 71 | + { |
|
| 72 | + $this->_views['all']['count'] = $this->_all_data_count; |
|
| 73 | + } |
|
| 74 | + |
|
| 75 | + |
|
| 76 | + public function column_cb($item) |
|
| 77 | + { |
|
| 78 | + return sprintf('<input type="checkbox" name="EVT_CAT_ID[]" value="%s" />', $item->get('term_id')); |
|
| 79 | + } |
|
| 80 | + |
|
| 81 | + |
|
| 82 | + public function column_id($item) |
|
| 83 | + { |
|
| 84 | + $content = $item->get('term_id'); |
|
| 85 | + $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
| 86 | + 'name' |
|
| 87 | + ) . '</span>'; |
|
| 88 | + return $content; |
|
| 89 | + } |
|
| 90 | + |
|
| 91 | + |
|
| 92 | + public function column_name($item) |
|
| 93 | + { |
|
| 94 | + $edit_query_args = array( |
|
| 95 | + 'action' => 'edit_category', |
|
| 96 | + 'EVT_CAT_ID' => $item->get('term_id'), |
|
| 97 | + ); |
|
| 98 | + |
|
| 99 | + $delete_query_args = array( |
|
| 100 | + 'action' => 'delete_category', |
|
| 101 | + 'EVT_CAT_ID' => $item->get('term_id'), |
|
| 102 | + ); |
|
| 103 | + |
|
| 104 | + $edit_link = EE_Admin_Page::add_query_args_and_nonce($edit_query_args, EVENTS_ADMIN_URL); |
|
| 105 | + $delete_link = EE_Admin_Page::add_query_args_and_nonce($delete_query_args, EVENTS_ADMIN_URL); |
|
| 106 | + |
|
| 107 | + $term_name = $item->get_first_related('Term')->get('name'); |
|
| 108 | + |
|
| 109 | + $actions = array( |
|
| 110 | + 'edit' => '<a href="' . $edit_link . '" aria-label="' . sprintf( |
|
| 111 | + /* translators: The name of the event category */ |
|
| 112 | + esc_attr__( |
|
| 113 | + 'Edit Category (%s)', |
|
| 114 | + 'event_espresso' |
|
| 115 | + ), |
|
| 116 | + $term_name |
|
| 117 | + ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
| 118 | + ); |
|
| 119 | + |
|
| 120 | + |
|
| 121 | + $actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . sprintf( |
|
| 122 | + /* translators: The name of the event category */ |
|
| 123 | + esc_attr__( |
|
| 124 | + 'Delete Category (%s)', |
|
| 125 | + 'event_espresso' |
|
| 126 | + ), |
|
| 127 | + $term_name |
|
| 128 | + ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
| 129 | 129 | |
| 130 | - $actions['view'] = sprintf( |
|
| 131 | - '<a href="%s" aria-label="%s">%s</a>', |
|
| 132 | - get_term_link($item->get('term_id')), |
|
| 133 | - esc_attr( |
|
| 134 | - sprintf( |
|
| 135 | - /* translators: %s: event category name */ |
|
| 136 | - __('View “%s” archive', 'event_espresso'), |
|
| 137 | - $item->get_first_related('Term')->get('name') |
|
| 138 | - ) |
|
| 139 | - ), |
|
| 140 | - esc_html__('View', 'event_espresso') |
|
| 141 | - ); |
|
| 142 | - |
|
| 143 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $term_name . '</a></strong>'; |
|
| 144 | - $content .= $this->row_actions($actions); |
|
| 145 | - return $content; |
|
| 146 | - } |
|
| 147 | - |
|
| 148 | - |
|
| 149 | - public function column_shortcode($item) |
|
| 150 | - { |
|
| 151 | - $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
| 152 | - return $content; |
|
| 153 | - } |
|
| 154 | - |
|
| 155 | - |
|
| 156 | - public function column_count($item) |
|
| 157 | - { |
|
| 158 | - $e_args = array( |
|
| 159 | - 'action' => 'default', |
|
| 160 | - 'EVT_CAT' => $item->get_first_related('Term')->ID(), |
|
| 161 | - ); |
|
| 162 | - $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
|
| 163 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
| 164 | - return $content; |
|
| 165 | - } |
|
| 130 | + $actions['view'] = sprintf( |
|
| 131 | + '<a href="%s" aria-label="%s">%s</a>', |
|
| 132 | + get_term_link($item->get('term_id')), |
|
| 133 | + esc_attr( |
|
| 134 | + sprintf( |
|
| 135 | + /* translators: %s: event category name */ |
|
| 136 | + __('View “%s” archive', 'event_espresso'), |
|
| 137 | + $item->get_first_related('Term')->get('name') |
|
| 138 | + ) |
|
| 139 | + ), |
|
| 140 | + esc_html__('View', 'event_espresso') |
|
| 141 | + ); |
|
| 142 | + |
|
| 143 | + $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $term_name . '</a></strong>'; |
|
| 144 | + $content .= $this->row_actions($actions); |
|
| 145 | + return $content; |
|
| 146 | + } |
|
| 147 | + |
|
| 148 | + |
|
| 149 | + public function column_shortcode($item) |
|
| 150 | + { |
|
| 151 | + $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
| 152 | + return $content; |
|
| 153 | + } |
|
| 154 | + |
|
| 155 | + |
|
| 156 | + public function column_count($item) |
|
| 157 | + { |
|
| 158 | + $e_args = array( |
|
| 159 | + 'action' => 'default', |
|
| 160 | + 'EVT_CAT' => $item->get_first_related('Term')->ID(), |
|
| 161 | + ); |
|
| 162 | + $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
|
| 163 | + $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
| 164 | + return $content; |
|
| 165 | + } |
|
| 166 | 166 | } |
@@ -82,9 +82,9 @@ discard block |
||
| 82 | 82 | public function column_id($item) |
| 83 | 83 | { |
| 84 | 84 | $content = $item->get('term_id'); |
| 85 | - $content .= ' <span class="show-on-mobile-view-only">' . $item->get_first_related('Term')->get( |
|
| 85 | + $content .= ' <span class="show-on-mobile-view-only">'.$item->get_first_related('Term')->get( |
|
| 86 | 86 | 'name' |
| 87 | - ) . '</span>'; |
|
| 87 | + ).'</span>'; |
|
| 88 | 88 | return $content; |
| 89 | 89 | } |
| 90 | 90 | |
@@ -107,25 +107,25 @@ discard block |
||
| 107 | 107 | $term_name = $item->get_first_related('Term')->get('name'); |
| 108 | 108 | |
| 109 | 109 | $actions = array( |
| 110 | - 'edit' => '<a href="' . $edit_link . '" aria-label="' . sprintf( |
|
| 110 | + 'edit' => '<a href="'.$edit_link.'" aria-label="'.sprintf( |
|
| 111 | 111 | /* translators: The name of the event category */ |
| 112 | 112 | esc_attr__( |
| 113 | 113 | 'Edit Category (%s)', |
| 114 | 114 | 'event_espresso' |
| 115 | 115 | ), |
| 116 | 116 | $term_name |
| 117 | - ) . '">' . esc_html__('Edit', 'event_espresso') . '</a>', |
|
| 117 | + ).'">'.esc_html__('Edit', 'event_espresso').'</a>', |
|
| 118 | 118 | ); |
| 119 | 119 | |
| 120 | 120 | |
| 121 | - $actions['delete'] = '<a href="' . $delete_link . '" aria-label="' . sprintf( |
|
| 121 | + $actions['delete'] = '<a href="'.$delete_link.'" aria-label="'.sprintf( |
|
| 122 | 122 | /* translators: The name of the event category */ |
| 123 | 123 | esc_attr__( |
| 124 | 124 | 'Delete Category (%s)', |
| 125 | 125 | 'event_espresso' |
| 126 | 126 | ), |
| 127 | 127 | $term_name |
| 128 | - ) . '">' . esc_html__('Delete', 'event_espresso') . '</a>'; |
|
| 128 | + ).'">'.esc_html__('Delete', 'event_espresso').'</a>'; |
|
| 129 | 129 | |
| 130 | 130 | $actions['view'] = sprintf( |
| 131 | 131 | '<a href="%s" aria-label="%s">%s</a>', |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | esc_html__('View', 'event_espresso') |
| 141 | 141 | ); |
| 142 | 142 | |
| 143 | - $content = '<strong><a class="row-title" href="' . $edit_link . '">' . $term_name . '</a></strong>'; |
|
| 143 | + $content = '<strong><a class="row-title" href="'.$edit_link.'">'.$term_name.'</a></strong>'; |
|
| 144 | 144 | $content .= $this->row_actions($actions); |
| 145 | 145 | return $content; |
| 146 | 146 | } |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | |
| 149 | 149 | public function column_shortcode($item) |
| 150 | 150 | { |
| 151 | - $content = '[ESPRESSO_EVENTS category_slug=' . $item->get_first_related('Term')->get('slug') . ']'; |
|
| 151 | + $content = '[ESPRESSO_EVENTS category_slug='.$item->get_first_related('Term')->get('slug').']'; |
|
| 152 | 152 | return $content; |
| 153 | 153 | } |
| 154 | 154 | |
@@ -160,7 +160,7 @@ discard block |
||
| 160 | 160 | 'EVT_CAT' => $item->get_first_related('Term')->ID(), |
| 161 | 161 | ); |
| 162 | 162 | $e_link = EE_Admin_Page::add_query_args_and_nonce($e_args, EVENTS_ADMIN_URL); |
| 163 | - $content = '<a href="' . $e_link . '">' . $item->get('term_count') . '</a>'; |
|
| 163 | + $content = '<a href="'.$e_link.'">'.$item->get('term_count').'</a>'; |
|
| 164 | 164 | return $content; |
| 165 | 165 | } |
| 166 | 166 | } |