->sort_by( $orderby )
->order( $order )
->limit( $per_page )
->offset( $offset )
->find();
foreach ( $mails as $mail ) {
/* @var $mail Mail */
$this->items[] = $mail->to_array();
}
$this->set_pagination_args( array(
'total_items' => $total_items, // The total number of items.
'per_page' => $per_page, // Number of items per page.
) );
}
/**
* Renders the cell.
* @since 1.0
* @param array $item The current item.
* @param string $column_name The current column name.
* @return string The cell content
*/
function column_default( $item, $column_name ) {
return ( new SanitizedColumnDecorator($this->columnManager->getColumnRenderer($column_name)))->render($item, ColumnFormat::FULL);
}
/**
* Renders the message column.
* @since 1.3
* @param array $item The current item.
* @return string
*/
function column_message( $item ) {
$content = $item['mail_id'];
$message = 'View';
return $message;
}
/**
* Defines available bulk actions.
* @since 1.0
* @see WP_List_Table::get_bulk_actions()
*/
function get_bulk_actions() {
$actions = array(
'delete' => 'Delete',
'resend' => 'Resend'
);
return $actions;
}
/**
* Processes bulk actions.
* @since 1.0
*/
function process_bulk_action() {
if ( false === $this->current_action() ) {
return;
}
if ( check_admin_referer( WPML_Email_Log_List::NONCE_LIST_TABLE, WPML_Email_Log_List::NONCE_LIST_TABLE . '_nonce' ) ) {
$name = $this->_args['singular'];
// Detect when a bulk action is being triggered.
if ( 'delete' === $this->current_action() ) {
foreach ( $_REQUEST[$name] as $item_id ) {
$mail = Mail::find_one( $item_id );
if ( false !== $mail ) {
$mail->delete();
}
}
} else if ( 'resend' == $this->current_action() ) {
foreach ( $_REQUEST[$name] as $item_id ) {
$mail = Mail::find_one( $item_id );
if ( false !== $mail ) {
$this->resend_email( $mail );
}
}
}
}
}
/**
* Send logged email via wp_mail
* @param Mail $mail the email object to resend
* @since 1.8.0
*/
function resend_email( $mail ) {
$this->emailResender->resendMail( $mail );
}
/**
* Render the cb column
* @since 1.0
* @param array $item The current item.
* @return string the rendered cb cell content
*/
function column_cb($item) {
$name = $this->_args['singular'];
return sprintf(
'', $name, $item['mail_id']
);
}
/**
* Define the sortable columns
* @since 1.0
* @return array
*/
function get_sortable_columns() {
return array(
// Description: column_name => array( 'display_name', true[asc] | false[desc] ).
'mail_id' => array( 'mail_id', false ),
'timestamp' => array( 'timestamp', true ),
'host' => array( 'host', true ),
'receiver' => array( 'receiver', true ),
'subject' => array( 'subject', true ),
'headers' => array( 'headers', true ),
'plugin_version'=> array( 'plugin_version', true ),
);
}
}