views();
}
}
/**
* Define which columns are hidden
*
* @return Array
*/
public function get_hidden_columns() {
return array();
}
/**
* Sanitised `?page` query arg.
*
* @return string
*/
protected function getCurrentPage(): string {
// phpcs:ignore WordPress.Security.NonceVerification.Recommended
return ! empty( $_GET['page'] ) ? sanitize_key( wp_unslash( $_GET['page'] ) ) : '';
}
/**
* Override the parent columns method. Defines the columns to use in your listing table
*
* @return Array
*/
public function get_columns() {
$current_page = $this->getCurrentPage();
/**
* Filters the columns displayed in the Coupons list table.
*
* @param string[] $coupon_columns An associative array of column headings.
*/
return (array) apply_filters( "manage_{$current_page}_columns", array() );
}
/**
* Handles the default column output.
*
* @param WP_Post $item The current WP_Post object.
* @param string $column_name The current column name.
*/
public function column_default( $item, $column_name ) {
$current_page = $this->getCurrentPage();
/**
* Fires for each custom column of any SureCart List Table.
*
* The dynamic portion of the hook name, `$current_page`, refers to the page name.
*
* Possible hook names include:
*
* - `manage_orders_custom_column`
* - `manage_products_custom_column`
*
* @param string $column_name The name of the column to display.
* @param mixed $item The current item's data object.
*/
do_action( "manage_{$current_page}_custom_column", $column_name, $item );
}
/**
* Get the archive query status.
*
* @return boolean|null
*/
public function getArchiveStatus( $default = 'active' ) {
$status = sanitize_text_field( wp_unslash( $_GET['status'] ?? $default ) );
$archived = false;
if ( 'archived' === $status ) {
$archived = true;
}
if ( 'all' === $status ) {
$archived = null;
}
return $archived;
}
/**
* Handle the date
*
* @param \SureCart\Models\Model $model Model.
*
* @return string
*/
public function column_date( $model ) {
$created = sprintf(
'',
esc_attr( $model->created_at ),
esc_html( $model->created_at_date_time ),
esc_html( TimeDate::humanTimeDiff( $model->created_at ) )
);
$updated = sprintf(
'%1$s ',
__( 'Updated', 'surecart' ),
esc_attr( $model->updated_at_date_time ),
esc_html( $model->updated_at_date_time ),
esc_html( TimeDate::humanTimeDiff( $model->updated_at ) )
);
return $created . '
' . $updated . '';
}
/**
* Handle the created column
*
* @param \SureCart\Models\Model $model Model.
*
* @return string
*/
public function column_created( $model ) {
return esc_attr( $model->created_at_date_time );
}
/**
* The mode for the model.
*
* @param \SureCart\Models\Model $model Model.
*
* @return string
*/
public function column_mode( $model ) {
return empty( $model->live_mode ) ? '
label ); ?>