/**
  * Generates a list of attendees taking into account the Screen Options.
  * It's used both for the Email functionality, as for the CSV export.
  *
  * @param $event_id
  *
  * @return array
  */
 private function generate_filtered_attendees_list($event_id)
 {
     /**
      * Fire immediately prior to the generation of a filtered (exportable) attendee list.
      *
      * @param int $event_id
      */
     do_action('tribe_events_tickets_generate_filtered_attendees_list', $event_id);
     if (empty($this->attendees_page)) {
         $this->attendees_page = 'tribe_events_page_tickets-attendees';
     }
     $items = Tribe__Tickets__Tickets::get_event_attendees($event_id);
     $columns = get_column_headers(get_current_screen());
     $hidden = get_hidden_columns($this->attendees_page);
     // We dont want to export html inputs or private data
     $hidden[] = 'cb';
     $hidden[] = 'provider';
     $hidden = array_flip($hidden);
     $export_columns = array_diff_key($columns, $hidden);
     // Add the Purchaser Information
     $export_columns['purchaser_name'] = esc_html__('Customer Name', 'event-tickets-plus');
     $export_columns['purchaser_email'] = esc_html__('Customer Email Address', 'event-tickets-plus');
     /**
      * Used to modify what columns should be shown on the CSV export
      * The column name should be the Array Index and the Header is the array Value
      *
      * @var array Columns, associative array
      * @var array Items to be exported
      * @var int   Event ID
      */
     $export_columns = apply_filters('tribe_events_tickets_attendees_csv_export_columns', $export_columns, $items, $event_id);
     // Add the export column headers as the first row
     $rows = array(array_values($export_columns));
     foreach ($items as $single_item) {
         // Fresh row!
         $row = array();
         foreach ($export_columns as $column_id => $column_name) {
             // If additional columns have been added to the attendee list table we can obtain the
             // values by calling the table object's column_default() method - any other values
             // should simply be passed back unmodified
             $row[$column_id] = $this->attendees_table->column_default($single_item, $column_id);
             // Special handling for the check_in column
             if ('check_in' === $column_id && 1 == $single_item[$column_id]) {
                 $row[$column_id] = esc_html__('Yes', 'event-tickets');
             }
         }
         $rows[] = array_values($row);
     }
     return array_filter($rows);
 }
 /**
  * Generates a list of attendees taking into account the Screen Options.
  * It's used both for the Email functionality, as for the CSV export.
  *
  * @param $event_id
  *
  * @return array
  */
 private function generate_filtered_attendees_list($event_id)
 {
     /**
      * Fire immediately prior to the generation of a filtered (exportable) attendee list.
      *
      * @param int $event_id
      */
     do_action('tribe_events_tickets_generate_filtered_attendees_list', $event_id);
     if (empty($this->attendees_page)) {
         $this->attendees_page = 'tribe_events_page_tickets-attendees';
     }
     //Add in Columns or get_column_headers() returns nothing
     $filter_name = "manage_{$this->attendees_page}_columns";
     add_filter($filter_name, array($this->attendees_table, 'get_columns'), 15);
     $items = Tribe__Tickets__Tickets::get_event_attendees($event_id);
     //Add Handler for Community Tickets to Prevent Notices in Exports
     if (!is_admin()) {
         $columns = apply_filters($filter_name, array());
     } else {
         $columns = array_map('wp_strip_all_tags', get_column_headers(get_current_screen()));
     }
     $hidden = get_hidden_columns($this->attendees_page);
     // We dont want to export html inputs or private data
     $hidden[] = 'cb';
     $hidden[] = 'provider';
     $hidden = array_flip($hidden);
     $export_columns = array_diff_key($columns, $hidden);
     // Add the Purchaser Information
     $export_columns['purchaser_name'] = esc_html__('Customer Name', 'event-tickets');
     $export_columns['purchaser_email'] = esc_html__('Customer Email Address', 'event-tickets');
     /**
      * Used to modify what columns should be shown on the CSV export
      * The column name should be the Array Index and the Header is the array Value
      *
      * @var array Columns, associative array
      * @var array Items to be exported
      * @var int   Event ID
      */
     $export_columns = apply_filters('tribe_events_tickets_attendees_csv_export_columns', $export_columns, $items, $event_id);
     // Add the export column headers as the first row
     $rows = array(array_values($export_columns));
     foreach ($items as $single_item) {
         // Fresh row!
         $row = array();
         foreach ($export_columns as $column_id => $column_name) {
             // If additional columns have been added to the attendee list table we can obtain the
             // values by calling the table object's column_default() method - any other values
             // should simply be passed back unmodified
             $row[$column_id] = $this->attendees_table->column_default($single_item, $column_id);
             // Special handling for the check_in column
             if ('check_in' === $column_id && 1 == $single_item[$column_id]) {
                 $row[$column_id] = esc_html__('Yes', 'event-tickets');
             }
             // Special handling for new human readable id
             if ('attendee_id' === $column_id) {
                 if (isset($single_item[$column_id])) {
                     $ticket_unique_id = get_post_meta($single_item[$column_id], '_unique_id', true);
                     $ticket_unique_id = $ticket_unique_id === '' ? $single_item[$column_id] : $ticket_unique_id;
                     $row[$column_id] = esc_html($ticket_unique_id);
                 }
             }
             // Handle custom columns that might have names containing HTML tags
             $row[$column_id] = wp_strip_all_tags($row[$column_id]);
         }
         $rows[] = array_values($row);
     }
     return array_filter($rows);
 }