'login-versuch',
'plural' => 'login-versuche',
'ajax' => false,
)
);
}
public function get_columns() {
return array(
'fingerprint' => __( 'Fingerprint', '360-orbit-login-guard' ),
'username' => __( 'Username', '360-orbit-login-guard' ),
'status' => __( 'Result', '360-orbit-login-guard' ),
'created_at' => __( 'Time', '360-orbit-login-guard' ),
);
}
public function column_fingerprint( $item ) {
return '' . esc_html( substr( $item->ip_hash, 0, 12 ) ) . '…';
}
public function column_username( $item ) {
return $item->username ? esc_html( $item->username ) : '–';
}
public function column_status( $item ) {
return $item->success
? '' . esc_html__( 'Success', '360-orbit-login-guard' ) . ''
: '' . esc_html__( 'Failed', '360-orbit-login-guard' ) . '';
}
public function column_created_at( $item ) {
return esc_html( mysql2date( 'd.m.Y H:i', $item->created_at ) );
}
public function prepare_items() {
global $wpdb;
$per_page = (int) get_user_option( self::PER_PAGE_OPTION );
$per_page = $per_page > 0 ? $per_page : 30;
$current_page = $this->get_pagenum();
$table = Wp360_Login_Guard_Database::table_name();
$total_items = (int) $wpdb->get_var( "SELECT COUNT(*) FROM {$table}" ); // phpcs:ignore
$this->items = $wpdb->get_results( // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching -- plugineigene Tabelle, Abfragen sind vorbereitet; ein Login-Protokoll darf nicht gecacht werden.
$wpdb->prepare(
"SELECT * FROM {$table} ORDER BY created_at DESC LIMIT %d OFFSET %d", // phpcs:ignore
$per_page,
( $current_page - 1 ) * $per_page
)
);
$this->_column_headers = array( $this->get_columns(), array(), array() );
$this->set_pagination_args(
array(
'total_items' => $total_items,
'per_page' => $per_page,
'total_pages' => (int) ceil( $total_items / $per_page ),
)
);
}
}