PluginProbe ʕ •ᴥ•ʔ
GiveWP – Donation Plugin and Fundraising Platform / trunk
GiveWP – Donation Plugin and Fundraising Platform vtrunk
4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 2.32.0 2.33.0 2.33.1 2.33.2 2.33.3 2.33.4 2.33.5 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 2.4.5 2.4.6 2.4.7 2.5.0 2.5.1 2.5.10 2.5.11 2.5.12 2.5.13 2.5.2 2.5.3 2.5.4 2.5.5 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.7.0 2.7.1 2.7.2 2.7.3 2.7.4 2.7.5 2.8.0 2.8.1 2.9.0 2.9.1 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.10.0 3.11.0 3.12.0 3.12.1 3.12.2 3.12.3 3.13.0 3.14.0 3.14.1 3.14.2 3.15.0 3.15.1 3.16.0 3.16.1 3.16.2 3.16.3 3.16.4 3.16.5 3.17.0 3.17.1 3.17.2 3.18.0 3.19.0 3.19.1 3.19.2 3.19.3 3.19.4 3.2.0 3.2.1 3.2.2 3.20.0 3.21.0 3.21.1 3.22.0 3.22.1 3.22.2 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 3.5.0 3.5.1 3.6.0 3.6.1 3.6.2 3.7.0 3.8.0 3.9.0 4.0.0 4.1.0 4.1.1 4.10.0 4.10.1 4.11.0 4.12.0 4.13.0 4.13.1 4.13.2 4.14.0 4.14.1 4.14.2 4.14.3 4.14.4 4.14.5 4.14.6 4.2.0 4.2.1 4.3.0 4.3.1 4.3.2 4.4.0 4.5.0 4.6.1 4.7.0 4.7.1 4.8.0 4.8.1 4.9.0 trunk 1.9.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.1.7 2.1.8 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.2 2.11.3 2.12.0 2.12.1 2.12.2 2.12.3 2.13.0 2.13.1 2.13.2 2.13.3 2.13.4 2.14.0 2.15.0 2.16.0 2.16.1 2.17.0 2.17.1 2.17.3 2.18.0 2.18.1 2.19.1 2.19.2 2.19.3 2.19.4 2.19.5 2.19.6 2.19.7 2.19.8 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.2.6 2.20.0 2.20.1 2.20.2 2.21.0 2.21.1 2.21.2 2.21.3 2.21.4 2.22.0 2.22.1 2.22.2 2.22.3 2.23.0 2.23.1 2.23.2 2.24.0 2.24.1 2.24.2 2.25.0 2.25.1 2.25.2 2.25.3 2.26.0 2.27.0 2.27.1 2.27.2 2.27.3 2.28.0 2.29.0 2.29.1 2.29.2
give / includes / admin / donors / class-donor-table.php
give / includes / admin / donors Last commit date
class-donor-table.php 1 year ago donor-actions.php 1 year ago donor-functions.php 1 year ago donors.php 7 months ago
class-donor-table.php
661 lines
1 <?php
2 /**
3 * Donor List Table Class.
4 *
5 * The list view under WP-Admin > Donations > Donors.
6 *
7 * @package Give
8 * @subpackage Admin/Reports
9 * @copyright Copyright (c) 2016, GiveWP
10 * @license https://opensource.org/licenses/gpl-license GNU Public License
11 * @since 1.0
12 */
13
14 // Exit if accessed directly.
15 if ( ! defined( 'ABSPATH' ) ) {
16 exit;
17 }
18
19 // Load WP_List_Table if not loaded.
20 if ( ! class_exists( 'WP_List_Table' ) ) {
21 require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
22 }
23
24 /**
25 * Give_Donor_List_Table Class.
26 *
27 * @since 1.0
28 */
29 class Give_Donor_List_Table extends WP_List_Table {
30
31 /**
32 * Number of items per page.
33 *
34 * @var int
35 * @since 1.0
36 */
37 public $per_page = 30;
38
39 /**
40 * Number of donors found.
41 *
42 * @var int
43 * @since 1.0
44 */
45 public $count = 0;
46
47 /**
48 * Total donors.
49 *
50 * @var int
51 * @since 1.0
52 */
53 public $total = 0;
54
55 /**
56 * Get things started.
57 *
58 * @since 1.0
59 * @see WP_List_Table::__construct()
60 */
61 public function __construct() {
62 // Set parent defaults.
63 parent::__construct(
64 [
65 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records.
66 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records.
67 'ajax' => false, // Does this table support ajax?.
68 ]
69 );
70
71 }
72 /**
73 * Add donors search filter.
74 *
75 * @since 3.5.0 Escape search query string.
76 * @since 2.4.0
77 * @return void
78 */
79 public function advanced_filters() {
80 $start_date = isset( $_GET['start-date'] ) ? strtotime( give_clean( $_GET['start-date'] ) ) : '';
81 $end_date = isset( $_GET['end-date'] ) ? strtotime( give_clean( $_GET['end-date'] ) ) : '';
82 $status = isset( $_GET['status'] ) ? give_clean( $_GET['status'] ) : '';
83 $donor = isset( $_GET['donor'] ) ? absint( $_GET['donor'] ) : '';
84 $search = $this->get_search();
85 $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : 0;
86 ?>
87 <div id="give-donor-filters" class="give-filters">
88 <div class="give-donor-search-box">
89 <input type="text" id="give-donors-search-input" placeholder="<?php
90 _e('Name, Email, or Donor ID', 'give'); ?>" name="s" value="<?php
91 echo esc_attr($search); ?>">
92 <?php
93 submit_button(
94 __( 'Search', 'give' ),
95 'button',
96 false,
97 false,
98 [
99 'ID' => 'donor-search-submit',
100 ]
101 );
102 ?>
103 </div>
104 <div class="give-filter give-filter-half">
105 <label for="start-date"
106 class="give-start-date-label"><?php _e( 'Start Date', 'give' ); ?></label>
107 <input type="text"
108 id="start-date"
109 name="start-date"
110 class="give_datepicker"
111 autocomplete="off"
112 value="<?php echo $start_date ? date_i18n( give_date_format(), $start_date ) : ''; ?>"
113 data-standard-date="<?php echo $start_date ? date( 'Y-m-d', $start_date ) : $start_date; ?>"
114 placeholder="<?php _e( 'Start Date', 'give' ); ?>"
115 />
116 </div>
117 <div class="give-filter give-filter-half">
118 <label for="end-date" class="give-end-date-label"><?php _e( 'End Date', 'give' ); ?></label>
119 <input type="text"
120 id="end-date"
121 name="end-date"
122 class="give_datepicker"
123 autocomplete="off"
124 value="<?php echo $end_date ? date_i18n( give_date_format(), $end_date ) : ''; ?>"
125 data-standard-date="<?php echo $end_date ? date( 'Y-m-d', $end_date ) : $end_date; ?>"
126 placeholder="<?php _e( 'End Date', 'give' ); ?>"
127 />
128 </div>
129 <div id="give-payment-form-filter" class="give-filter">
130 <label for="give-donation-forms-filter"
131 class="give-donation-forms-filter-label"><?php _e( 'Form', 'give' ); ?></label>
132 <?php
133 // Filter Donations by Donation Forms.
134 echo Give()->html->forms_dropdown(
135 [
136 'name' => 'form_id',
137 'id' => 'give-donation-forms-filter',
138 'class' => 'give-donation-forms-filter',
139 'selected' => $form_id, // Make sure to have $form_id set to 0, if there is no selection.
140 'chosen' => true,
141 'number' => 30,
142 ]
143 );
144 ?>
145 </div>
146
147 <?php
148 /**
149 * Action to add hidden fields and HTML in donor search.
150 *
151 * @since 2.4.0
152 */
153 do_action( 'give_donor_table_advanced_filters' );
154
155 if ( ! empty( $status ) ) {
156 echo sprintf( '<input type="hidden" name="status" value="%s"/>', esc_attr( $status ) );
157 }
158
159 if ( ! empty( $donor ) ) {
160 echo sprintf( '<input type="hidden" name="donor" value="%s"/>', absint( $donor ) );
161 }
162 ?>
163
164 <div class="give-filter">
165 <?php submit_button( __( 'Apply', 'give' ), 'secondary', '', false ); ?>
166 <?php
167 // Clear active filters button.
168 if ( ! empty( $start_date ) || ! empty( $end_date ) || ! empty( $donor ) || ! empty( $search ) || ! empty( $status ) || ! empty( $form_id ) ) :
169 ?>
170 <a href="<?php echo admin_url( 'edit.php?post_type=give_forms&page=give-donors' ); ?>"
171 class="button give-clear-filters-button"><?php _e( 'Clear Filters', 'give' ); ?></a>
172 <?php endif; ?>
173 </div>
174 </div>
175
176 <?php
177 }
178
179 /**
180 * This function renders most of the columns in the list table.
181 *
182 * @param array $donor Contains all the data of the donors.
183 * @param string $column_name The name of the column.
184 *
185 * @access public
186 * @since 1.0
187 *
188 * @return string Column Name.
189 */
190 public function column_default( $donor, $column_name ) {
191
192 switch ( $column_name ) {
193
194 case 'num_donations':
195 $value = sprintf(
196 '<a href="%s">%s</a>',
197 admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ),
198 esc_html( $donor['num_donations'] )
199 );
200 break;
201
202 case 'amount_spent':
203 $value = give_currency_filter( give_format_amount( $donor[ $column_name ], [ 'sanitize' => false ] ) );
204 break;
205
206 case 'date_created':
207 $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) );
208 break;
209
210 default:
211 $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null;
212 break;
213 }
214
215 return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] );
216
217 }
218
219 /**
220 * For CheckBox Column
221 *
222 * @param array $donor Donor Data.
223 *
224 * @access public
225 * @since 1.8.16
226 *
227 * @return string
228 */
229 public function column_cb( $donor ) {
230 return sprintf(
231 '<input class="donor-selector" type="checkbox" name="donor[]" value="%1$d" data-name="%2$s" />',
232 $donor['id'],
233 esc_attr( $donor['name'] )
234 );
235 }
236
237 /**
238 * Column name.
239 *
240 * @param array $donor Donor Data.
241 *
242 * @access public
243 * @since 1.0
244 *
245 * @return string
246 */
247 public function column_name( $donor ) {
248
249 // Get donor's initials for non-gravatars
250 $title_prefix = Give()->donor_meta->get_meta( $donor['id'], '_give_donor_title_prefix', true );
251 $donor_name_without_prefix = trim( str_replace( $title_prefix, '', $donor['name'] ) );
252 $donor_name_array = explode( ' ', $donor_name_without_prefix );
253 $donor_name_args['firstname'] = ! empty( $donor_name_array[0] ) ? $donor_name_array[0] : '';
254 $donor_name_args['lastname'] = ! empty( $donor_name_array[1] ) ? $donor_name_array[1] : '';
255 $donor_name_initial = give_get_name_initial( $donor_name_args );
256
257 $donation_gravatar_image = sprintf(
258 '<span class="give-donor__image give-donor-admin-avatar" data-donor_email="%1$s" data-has-valid-gravatar="%2$s">%3$s</span>',
259 md5( strtolower( trim( $donor['email'] ) ) ),
260 absint( give_validate_gravatar( $donor['email'] ) ),
261 esc_attr( $donor_name_initial )
262 );
263
264 $name = ! empty( $donor['name'] )
265 ? sprintf(
266 '%1$s<span class="give-donor-name-text">%2$s</span>',
267 $donation_gravatar_image,
268 esc_attr( $donor['name'] )
269 )
270 : sprintf(
271 '<em>%1$s</em>',
272 __( 'Unnamed Donor', 'give' )
273 );
274
275 $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=legacy-overview&id=' . $donor['id'] );
276 $actions = $this->get_row_actions( $donor );
277
278 return sprintf(
279 '<a href="%1$s" class="give-donor-name">%2$s</a>%3$s',
280 esc_url( $view_url ),
281 $name,
282 $this->row_actions( $actions )
283 );
284 }
285
286 /**
287 * Retrieve the table columns.
288 *
289 * @access public
290 * @since 1.0
291 *
292 * @return array $columns Array of all the list table columns.
293 */
294 public function get_columns() {
295 $columns = [
296 'cb' => '<input type="checkbox" />', // Render a checkbox instead of text.
297 'name' => __( 'Name', 'give' ),
298 'email' => __( 'Email', 'give' ),
299 'num_donations' => __( 'Donations', 'give' ),
300 'amount_spent' => __( 'Total Donated', 'give' ),
301 'date_created' => __( 'Date Created', 'give' ),
302 ];
303
304 return apply_filters( 'give_list_donors_columns', $columns );
305
306 }
307
308 /**
309 * Get the sortable columns.
310 *
311 * @access public
312 * @since 2.1
313 * @return array Array of all the sortable columns.
314 */
315 public function get_sortable_columns() {
316
317 $columns = [
318 'date_created' => [ 'date_created', true ],
319 'name' => [ 'name', true ],
320 'num_donations' => [ 'purchase_count', false ],
321 'amount_spent' => [ 'purchase_value', false ],
322 ];
323
324 return apply_filters( 'give_list_donors_sortable_columns', $columns );
325 }
326
327 /**
328 * Retrieve row actions.
329 *
330 * @param array $donor Donor Data.
331 *
332 * @since 1.7
333 * @access public
334 *
335 * @return array An array of action links.
336 */
337 public function get_row_actions( $donor ) {
338
339 $actions = [
340 'id' => '<span class="give-donor-id">ID: ' . $donor['id'] . ' </span>',
341 'view' => sprintf( '<a href="%1$s" aria-label="%2$s">%3$s</a>', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=legacy-overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), esc_attr( $donor['name'] ) ), __( 'View Donor', 'give' ) ),
342 'delete' => sprintf( '<a class="%1$s" data-id="%2$s" href="#" aria-label="%3$s">%4$s</a>', 'give-single-donor-delete', $donor['id'], sprintf( esc_attr__( 'Delete "%s"', 'give' ), esc_attr( $donor['name'] ) ), __( 'Delete', 'give' ) ),
343 ];
344
345 return apply_filters( 'give_donor_row_actions', $actions, $donor );
346
347 }
348
349 /**
350 * Retrieve the current page number.
351 *
352 * @access public
353 * @since 1.0
354 *
355 * @return int Current page number.
356 */
357 public function get_paged() {
358 return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1;
359 }
360
361 /**
362 * Retrieves the search query string.
363 *
364 * @access public
365 * @since 3.5.0 Remove escape function
366 * @since 1.0
367 *
368 * @return mixed string If search is present, false otherwise.
369 */
370 public function get_search() {
371
372 if ( ! isset( $_GET['s'] ) ) {
373 return false;
374 }
375
376 $search = urldecode(trim($_GET['s']));
377
378 return ! empty($search) ? $search : false;
379 }
380
381 /**
382 * Get the Bulk Actions.
383 *
384 * @access public
385 * @since 1.8.16
386 *
387 * @return array
388 */
389 public function get_bulk_actions() {
390 $actions = [
391 'delete' => __( 'Delete', 'give' ),
392 ];
393
394 return $actions;
395 }
396
397 /**
398 * Generate the table navigation above or below the table
399 *
400 * @param string $which Position to trigger i.e. Top/Bottom.
401 *
402 * @access protected
403 * @since 1.8.16
404 */
405 protected function display_tablenav( $which ) {
406 if ( 'top' === $which ) {
407 wp_nonce_field( 'bulk-donors', '_wpnonce', false );
408 }
409 ?>
410 <div class="tablenav <?php echo esc_attr( $which ); ?>">
411 <?php if ( $this->has_items() ) : ?>
412 <div class="alignleft actions bulkactions">
413 <?php $this->bulk_actions( $which ); ?>
414 </div>
415 <?php
416 endif;
417 $this->extra_tablenav( $which );
418 $this->pagination( $which );
419 ?>
420 <br class="clear"/>
421 </div>
422 <?php
423 }
424
425 /**
426 * Retrieves the donor data from db.
427 *
428 * @since 2.21.2 Add second param to "give_donors_column_query_data" filter hook.
429 * @since 1.0
430 *
431 * @return array $data The Donor data.
432 */
433 public function donor_data() {
434
435 $data = [];
436
437 // Get donor query.
438 $args = $this->get_donor_query();
439 $donors = Give()->donors->get_donors( $args );
440
441 if ( $donors ) {
442
443 foreach ( $donors as $donor ) {
444
445 $user_id = ! empty( $donor->user_id ) ? intval( $donor->user_id ) : 0;
446 $title_prefix = Give()->donor_meta->get_meta( $donor->id, '_give_donor_title_prefix', true );
447
448 // If title prefix is set, then update the donor name.
449 $donor->name = give_get_donor_name_with_title_prefixes( $title_prefix, $donor->name );
450
451 $data[] = [
452 'id' => $donor->id,
453 'user_id' => $user_id,
454 'name' => $donor->name,
455 'email' => $donor->email,
456 'num_donations' => $donor->purchase_count,
457 'amount_spent' => $donor->purchase_value,
458 'date_created' => $donor->date_created,
459 ];
460 }
461 }
462
463 return apply_filters( 'give_donors_column_query_data', $data, $donors );
464 }
465
466 /**
467 * Get donor count.
468 *
469 * @since 1.8.1
470 * @access private
471 */
472 private function get_donor_count() {
473 // Get donor query.
474 $_donor_query = $this->get_donor_query();
475
476 $_donor_query['number'] = - 1;
477 $_donor_query['offset'] = 0;
478 $_donor_query['count'] = true;
479
480 return Give()->donors->get_donors( $_donor_query );
481 }
482
483 /**
484 * Get donor query.
485 *
486 * @since 3.5.0 Escape search query string.
487 * @since 1.8.1
488 * @access public
489 *
490 * @return array
491 */
492 public function get_donor_query() {
493 $per_page = $this->per_page;
494 $paged = $this->get_paged();
495 $donor = isset( $_GET['donor'] ) ? absint( $_GET['donor'] ) : null;
496 $start_date = ! empty( $_GET['start-date'] ) ? strtotime( give_clean( $_GET['start-date'] ) ) : false;
497 $end_date = ! empty( $_GET['end-date'] ) ? strtotime( give_clean( $_GET['end-date'] ) ) : false;
498 $form_id = ! empty( $_GET['form_id'] ) ? absint( $_GET['form_id'] ) : null;
499 $offset = $this->per_page * ( $paged - 1 );
500 $search = $this->get_search();
501 $order = isset( $_GET['order'] ) ? sanitize_text_field( $_GET['order'] ) : 'DESC';
502 $orderby = isset( $_GET['orderby'] ) ? sanitize_text_field( $_GET['orderby'] ) : 'id';
503
504 $args = [
505 'output' => 'payments',
506 'number' => $per_page,
507 'offset' => $offset,
508 'page' => isset( $_GET['paged'] ) ? $_GET['paged'] : null,
509 'orderby' => $orderby,
510 'order' => $order,
511 'donor' => $donor,
512 's' => esc_sql($search),
513 'start_date' => $start_date,
514 'end_date' => $end_date,
515 'give_forms' => $form_id,
516 ];
517
518 /**
519 * Filter to modify donor table argument.
520 *
521 * @since 2.4.0
522 */
523 $args = (array) apply_filters( 'give_donor_table_query', $args );
524
525 return $args;
526 }
527
528 /**
529 * Generates content for a single row of the table
530 *
531 * @param object $item The current item.
532 *
533 * @since 1.8.17
534 * @access public
535 */
536 public function single_row( $item ) {
537 echo sprintf( '<tr id="donor-%1$d" data-id="%2$d" data-name="%3$s">', $item['id'], $item['id'], esc_attr( $item['name'] ) );
538 $this->single_row_columns( $item );
539 echo '</tr>';
540 }
541
542 /**
543 * Display the final donor table
544 *
545 * @since 1.8.17
546 * @access public
547 */
548 public function display() {
549 $singular = $this->_args['singular'];
550
551 $this->display_tablenav( 'top' );
552
553 $this->screen->render_screen_reader_content( 'heading_list' );
554
555 $get_data = give_clean( $_GET ); // WPCS: input var ok, sanitization ok, CSRF ok.
556
557 $order = ! empty( $get_data['order'] ) ? $get_data['order'] : 'DESC';
558 $order_by = ! empty( $get_data['orderby'] ) ? $get_data['orderby'] : 'id';
559 ?>
560 <table class="wp-list-table <?php echo implode( ' ', $this->get_table_classes() ); ?>">
561 <thead>
562 <tr>
563 <?php $this->print_column_headers(); ?>
564 </tr>
565 </thead>
566
567 <tbody id="the-list"
568 <?php
569 if ( $singular ) {
570 echo " data-wp-lists='list:$singular'";
571 }
572 ?>
573 >
574 <tr class="hidden"></tr>
575 <tr id="give-bulk-delete"
576 class="inline-edit-row inline-edit-row-page inline-edit-page bulk-edit-row bulk-edit-row-page bulk-edit-page inline-editor"
577 style="display: none;">
578 <td colspan="6" class="colspanchange">
579
580 <fieldset class="inline-edit-col-left">
581 <legend class="inline-edit-legend"><?php esc_attr_e( 'BULK DELETE', 'give' ); ?></legend>
582 <div class="inline-edit-col">
583 <div id="bulk-titles">
584 <div id="give-bulk-donors" class="give-bulk-donors">
585
586 </div>
587 </div>
588 </fieldset>
589
590 <fieldset class="inline-edit-col-right">
591 <div class="inline-edit-col">
592 <label>
593 <input class="give-donor-delete-confirm" type="checkbox"
594 name="give-donor-delete-confirm"/>
595 <?php esc_attr_e( 'Are you sure you want to delete the selected donor(s)?', 'give' ); ?>
596 </label>
597 <label>
598 <input class="give-donor-delete-records" type="checkbox"
599 name="give-donor-delete-records"/>
600 <?php esc_attr_e( 'Delete all associated donations and records?', 'give' ); ?>
601 </label>
602 </div>
603 </fieldset>
604
605 <p class="submit inline-edit-save">
606 <input type="hidden" name="give_action" value="delete_bulk_donor"/>
607 <input type="hidden" name="orderby" value="<?php echo esc_html( $order_by ); ?>"/>
608 <input type="hidden" name="order" value="<?php echo esc_html( $order ); ?>"/>
609 <button type="button" id="give-bulk-delete-cancel"
610 class="button cancel alignleft"><?php esc_attr_e( 'Cancel', 'give' ); ?></button>
611 <input type="submit" id="give-bulk-delete-button" disabled
612 class="button button-primary alignright"
613 value="<?php esc_attr_e( 'Delete', 'give' ); ?>">
614 <br class="clear">
615 </p>
616 </td>
617 </tr>
618 <?php $this->display_rows_or_placeholder(); ?>
619 </tbody>
620
621 <tfoot>
622 <tr>
623 <?php $this->print_column_headers( false ); ?>
624 </tr>
625 </tfoot>
626
627 </table>
628 <?php
629 $this->display_tablenav( 'bottom' );
630 }
631
632 /**
633 * Setup the final data for the table.
634 *
635 * @access public
636 * @since 1.0
637 *
638 * @return void
639 */
640 public function prepare_items() {
641
642 $columns = $this->get_columns();
643 $hidden = []; // No hidden columns.
644 $sortable = $this->get_sortable_columns();
645
646 $this->_column_headers = [ $columns, $hidden, $sortable ];
647
648 $this->items = $this->donor_data();
649
650 $this->total = $this->get_donor_count();
651
652 $this->set_pagination_args(
653 [
654 'total_items' => $this->total,
655 'per_page' => $this->per_page,
656 'total_pages' => ceil( $this->total / $this->per_page ),
657 ]
658 );
659 }
660 }
661