'affiliate', //singular name of the listed records
'plural' => 'affiliates', //plural name of the listed records
'ajax' => false //does this table support ajax?
));
}
function column_default($item, $column_name) {
//Just print the data for that column
return $item[$column_name];
}
function column_affiliateId($item) {
//Build row actions
$actions = array(
'edit' => sprintf('View', $item['affiliateId']),
'delete' => sprintf('Delete', $item['affiliateId']),
);
//Return the id column contents
return $item['affiliateId'] . $this->row_actions($actions);
}
function column_dateCreated($item) {
$item['dateCreated'] = date("m/d/Y", strtotime($item['dateCreated']));
return $item['dateCreated'];
}
function column_viewDetail($item) {
$item['viewDetail'] = '' . __('View', 'affiliates-manager') . '';
return $item['viewDetail'];
}
/* overridden function to show a custom message when no records are present */
function no_items() {
echo '
No affiliates Found!';
}
function column_cb($item) {
return sprintf(
'',
/* $1%s */ $this->_args['singular'], //Let's reuse singular label
/* $2%s */ $item['affiliateId'] //The value of the checkbox should be the record's key/id
);
}
function get_columns() {
$columns = array(
'cb' => '', //Render a checkbox instead of text
'affiliateId' => __('Affiliate ID', 'affiliates-manager'),
'status' => __('Status', 'affiliates-manager'),
'balance' => __('Balance', 'affiliates-manager'),
'earnings' => __('Earnings', 'affiliates-manager'),
'firstName' => __('First Name', 'affiliates-manager'),
'lastName' => __('Last Name', 'affiliates-manager'),
'email' => __('Email', 'affiliates-manager'),
'companyName' => __('Company', 'affiliates-manager'),
'dateCreated' => __('Date Joined', 'affiliates-manager'),
'websiteUrl' => __('Website', 'affiliates-manager'),
'viewDetail' => __('', 'affiliates-manager'),
);
return $columns;
}
function get_sortable_columns() {
$sortable_columns = array(
'affiliateId' => array('affiliateId', false), //true means its already sorted
'dateCreated' => array('dateCreated', false)
);
return $sortable_columns;
}
function get_bulk_actions() {
$actions = array(
'delete' => __('Delete', 'affiliates-manager')
);
return $actions;
}
function process_bulk_action() {
//Detect when a bulk action is being triggered... //print_r($_GET);
if ('delete' === $this->current_action()) {
$nvp_key = $this->_args['singular'];
$records_to_delete = $_GET[$nvp_key];
if (empty($records_to_delete)) {
echo '
' . __('Error! You need to select multiple records to perform a bulk action!', 'affiliates-manager') . '
' . __('Selected records deleted successfully!', 'affiliates-manager') . '
' . __('Selected record deleted successfully!', 'affiliates-manager') . '