get_columns();
$hidden = $this->get_hidden_columns();
$sortable = $this->get_sortable_columns();
$this->_column_headers = array( $columns, $hidden, $sortable );
$query = $this->table_data();
if ( is_wp_error( $query ) ) {
$this->error = $query->get_error_message();
$this->items = array();
return;
}
$this->set_pagination_args(
array(
'total_items' => $query->pagination->count,
'per_page' => $this->get_items_per_page( 'affiliate_referrals' ),
)
);
$this->items = $query->data;
}
/**
* Get views for the list table status links.
*
* @global int $post_id
* @global string $comment_status
* @global string $comment_type
*
* @return string
*/
protected function get_views() {
foreach ( $this->getStatuses() as $status => $label ) {
$link = admin_url( 'admin.php?page=sc-affiliate-referrals' );
$current_link_attributes = '';
if ( ! empty( $_GET['status'] ) ) {
if ( $status === $_GET['status'] ) {
$current_link_attributes = ' class="current" aria-current="page"';
}
} elseif ( 'all' === $status ) {
$current_link_attributes = ' class="current" aria-current="page"';
}
$link = add_query_arg( 'status', $status, $link );
$link = esc_url( $link );
$status_links[ $status ] = "" . $label . '';
}
/**
* Filters the affiliation referrals status links.
*
* @since 2.5.0
* @since 5.1.0 The 'Mine' link was added.
*
* @param string[] $status_links An associative array of fully-formed affiliation referrals status links. Includes 'All', 'Reviewing', 'Approved', 'Denied', 'Cancelled' and 'Paid Out'.
* */
return apply_filters( 'sc_affiliation_referrals_status_links', $status_links );
}
/**
* Override the parent columns method. Defines the columns to use in your listing table
*
* @return array
*/
public function get_columns() {
return array_merge(
[
'date' => esc_html__( 'Date', 'surecart' ),
'status' => esc_html__( 'Status', 'surecart' ),
'payout_status' => esc_html__( 'Payout Status', 'surecart' ),
'payout_date' => esc_html__( 'Payout Date', 'surecart' ),
'affiliate' => esc_html__( 'Affiliate', 'surecart' ),
'description' => esc_html__( 'Description', 'surecart' ),
'order' => esc_html__( 'Order', 'surecart' ),
'commission' => esc_html__( 'Commission', 'surecart' ),
'mode' => '',
],
parent::get_columns()
);
}
/**
* Handle the date column.
*
* @param \SureCart\Models\Referral $referral The Referral model.
*
* @return string
*/
public function column_date( $referral ) {
ob_start();
echo esc_attr( $referral->created_at_date_time );
?>
row_actions(
array_filter(
array(
'view' => '' . esc_html__( 'View', 'surecart' ) . '',
'edit' => '' . esc_html__( 'Edit', 'surecart' ) . '',
'approve' => '' . esc_html__( 'Approve', 'surecart' ) . '',
'deny' => '' . esc_html__( 'Deny', 'surecart' ) . '',
'make_reviewing' => '' . esc_html__( 'Make Reviewing', 'surecart' ) . '',
'delete' => '' . esc_html__( 'Delete', 'surecart' ) . '',
),
function ( $action, $key ) use ( $referral ) {
// only view a paid referral.
if ( 'view' === $key && 'paid' !== $referral->status ) {
return false;
}
// don't edit a paid referral.
if ( 'paid' === $referral->status && 'view' !== $key ) {
return false;
}
// don't approve approved referral.
if ( 'approve' === $key && 'approved' === $referral->status ) {
return false;
}
// don't deny denied referral.
if ( 'deny' === $key && 'denied' === $referral->status ) {
return false;
}
// don't make reviewing reviewing referral.
if ( 'make_reviewing' === $key && 'reviewing' === $referral->status ) {
return false;
}
return true;
},
ARRAY_FILTER_USE_BOTH
)
)
)
?>
status_display_text ) ) {
return '';
}
ob_start();
?>