Donations > Donors. * * @package Give * @subpackage Admin/Reports * @copyright Copyright (c) 2016, WordImpress * @license https://opensource.org/licenses/gpl-license GNU Public License * @since 1.0 */ // Exit if accessed directly. if ( ! defined( 'ABSPATH' ) ) { exit; } // Load WP_List_Table if not loaded. if ( ! class_exists( 'WP_List_Table' ) ) { require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php'; } /** * Give_Donor_List_Table Class. * * @since 1.0 */ class Give_Donor_List_Table extends WP_List_Table { /** * Number of items per page. * * @var int * @since 1.0 */ public $per_page = 30; /** * Number of donors found. * * @var int * @since 1.0 */ public $count = 0; /** * Total donors. * * @var int * @since 1.0 */ public $total = 0; /** * Get things started. * * @since 1.0 * @see WP_List_Table::__construct() */ public function __construct() { // Set parent defaults. parent::__construct( array( 'singular' => __( 'Donor', 'give' ), // Singular name of the listed records. 'plural' => __( 'Donors', 'give' ), // Plural name of the listed records. 'ajax' => false, // Does this table support ajax?. ) ); } /** * Show the search field. * * @param string $text Label for the search box. * @param string $input_id ID of the search box. * * @since 1.0 * @access public * * @return void */ public function search_box( $text, $input_id ) { $input_id = $input_id . '-search-input'; if ( ! empty( $_REQUEST['orderby'] ) ) { echo sprintf( '', esc_attr( $_REQUEST['orderby'] ) ); } if ( ! empty( $_REQUEST['order'] ) ) { echo sprintf( '', esc_attr( $_REQUEST['order'] ) ); } ?>
'search-submit', ) ); ?>
%s', admin_url( 'edit.php?post_type=give_forms&page=give-payment-history&donor=' . absint( $donor['id'] ) ), esc_html( $donor['num_donations'] ) ); break; case 'amount_spent' : $value = give_currency_filter( give_format_amount( $donor[ $column_name ], array( 'sanitize' => false ) ) ); break; case 'date_created' : $value = date_i18n( give_date_format(), strtotime( $donor['date_created'] ) ); break; default: $value = isset( $donor[ $column_name ] ) ? $donor[ $column_name ] : null; break; } return apply_filters( "give_donors_column_{$column_name}", $value, $donor['id'] ); } /** * For CheckBox Column * * @param array $donor Donor Data. * * @access public * @since 1.8.16 * * @return string */ public function column_cb( $donor ) { return sprintf( '', $this->_args['singular'], $donor['id'], $donor['name'] ); } /** * Column name. * * @param array $donor Donor Data. * * @access public * @since 1.0 * * @return string */ public function column_name( $donor ) { $name = ! empty( $donor['name'] ) ? $donor['name'] : '' . __( 'Unnamed Donor', 'give' ) . ''; $view_url = admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ); $actions = $this->get_row_actions( $donor ); return '' . $name . '' . $this->row_actions( $actions ); } /** * Retrieve the table columns. * * @access public * @since 1.0 * * @return array $columns Array of all the list table columns. */ public function get_columns() { $columns = array( 'cb' => '', // Render a checkbox instead of text. 'name' => __( 'Name', 'give' ), 'email' => __( 'Email', 'give' ), 'num_donations' => __( 'Donations', 'give' ), 'amount_spent' => __( 'Total Donated', 'give' ), 'date_created' => __( 'Date Created', 'give' ), ); return apply_filters( 'give_list_donors_columns', $columns ); } /** * Get the sortable columns. * * @access public * @since 2.1 * @return array Array of all the sortable columns. */ public function get_sortable_columns() { $columns = array( 'date_created' => array( 'date_created', true ), 'name' => array( 'name', true ), 'num_donations' => array( 'purchase_count', false ), 'amount_spent' => array( 'purchase_value', false ), ); return apply_filters( 'give_list_donors_sortable_columns', $columns ); } /** * Retrieve row actions. * * @param array $donor Donor Data. * * @since 1.7 * @access public * * @return array An array of action links. */ public function get_row_actions( $donor ) { $actions = array( 'view' => sprintf( '%3$s', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $donor['id'] ), sprintf( esc_attr__( 'View "%s"', 'give' ), $donor['name'] ), __( 'View Donor', 'give' ) ), 'notes' => sprintf( '%3$s', admin_url( 'edit.php?post_type=give_forms&page=give-donors&view=notes&id=' . $donor['id'] ), sprintf( esc_attr__( 'Notes for "%s"', 'give' ), $donor['name'] ), __( 'Notes', 'give' ) ), 'delete' => sprintf( '%4$s', 'give-single-donor-delete', $donor['id'],sprintf( esc_attr__( 'Delete "%s"', 'give' ), $donor['name'] ), __( 'Delete', 'give' ) ), ); return apply_filters( 'give_donor_row_actions', $actions, $donor ); } /** * Retrieve the current page number. * * @access public * @since 1.0 * * @return int Current page number. */ public function get_paged() { return isset( $_GET['paged'] ) ? absint( $_GET['paged'] ) : 1; } /** * Retrieves the search query string. * * @access public * @since 1.0 * * @return mixed string If search is present, false otherwise. */ public function get_search() { return ! empty( $_GET['s'] ) ? urldecode( trim( $_GET['s'] ) ) : false; } /** * Get the Bulk Actions. * * @access public * @since 1.8.16 * * @return array */ public function get_bulk_actions() { $actions = array( 'delete' => __( 'Delete', 'give' ), ); return $actions; } /** * Generate the table navigation above or below the table * * @param string $which Position to trigger i.e. Top/Bottom. * * @access protected * @since 1.8.16 */ protected function display_tablenav( $which ) { if ( 'top' === $which ) { wp_nonce_field( 'bulk-' . $this->_args['plural'], '_wpnonce', false ); } ?>