PluginProbe ʕ •ᴥ•ʔ
SiteGuard WP Plugin / 1.0.0
SiteGuard WP Plugin v1.0.0
1.8.7 1.8.6 1.8.6-beta1 1.8.6-beta2 1.8.4 1.8.5 1.8.3 1.8.2 1.8.1 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.4.3 1.5.0 1.5.1 1.5.2 1.6.0 1.6.1 1.7.0 1.7.1 1.7.10 1.7.11 1.7.12 1.7.2 1.7.3 1.7.4 1.7.5 1.7.6 1.7.7 1.7.8 1.7.9 1.8.0 1.8.0-beta1 1.8.0-beta2 1.8.0-beta3 1.8.0-beta4
siteguard / admin / siteguard-login-history-table.php
siteguard / admin Last commit date
siteguard-login-history-table.php 11 years ago siteguard-menu-admin-filter.php 11 years ago siteguard-menu-captcha.php 11 years ago siteguard-menu-dashboard.php 11 years ago siteguard-menu-disable-pingback.php 11 years ago siteguard-menu-fail-once.php 11 years ago siteguard-menu-init.php 11 years ago siteguard-menu-login-lock.php 11 years ago siteguard-menu-rename-login.php 11 years ago siteguard-menu-same-error.php 11 years ago siteguard-menu-waf-tuning-support.php 11 years ago siteguard-waf-exclude-rule-table.php 11 years ago
siteguard-login-history-table.php
110 lines
1 <?php
2 if ( ! class_exists( 'WP_List_Table' ) ) {
3 require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
4 }
5
6 class SiteGuard_LoginHistory_Table extends WP_List_Table {
7
8 function __construct( ) {
9 global $status, $page;
10
11 //Set parent defaults
12 parent::__construct( array(
13 'singular' => 'event', //singular name of the listed records
14 'plural' => 'events', //plural name of the listed records
15 'ajax' => false, //does this table support ajax?
16 ) );
17 }
18
19 function column_default( $item, $column_name ) {
20 switch ( $column_name ) {
21 case 'operation':
22 return SiteGuard_LoginHistory::convert_operation( $item[ $column_name ] );
23 case 'time':
24 case 'login_name':
25 case 'ip_address':
26 return $item[ $column_name ];
27 default:
28 return print_r( $item, true ); //Show the whole array for troubleshooting purposes
29 }
30 }
31
32 function get_columns( ) {
33 $columns = array(
34 #'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
35 'time' => esc_html__( 'Date Time', 'siteguard' ),
36 'operation' => esc_html__( 'Operation', 'siteguard' ),
37 'login_name' => esc_html__( 'Login Name', 'siteguard' ),
38 'ip_address' => esc_html__( 'IP Address', 'siteguard' ),
39 );
40 return $columns;
41 }
42
43 function get_sortable_columns( ) {
44 $sortable_columns = array(
45 'time' => array( 'id', true ), //true means it's already sorted
46 'operation' => array( 'operation', false ), //true means it's already sorted
47 'login_name' => array( 'login_name', false ),
48 'ip_address' => array( 'ip_address', false )
49 );
50 return $sortable_columns;
51 }
52
53 function get_bulk_actions( ) {
54 #$actions = array(
55 # 'delete' => __( 'Delete' ),
56 #);
57 $actions = array();
58 return $actions;
59 }
60
61
62 function process_bulk_action( ) {
63 return;
64 }
65
66 function usort_reorder( $a, $b ){
67 $orderby = ( ! empty( $_REQUEST['orderby'] ) ) ? $_REQUEST['orderby'] : 'id'; //If no sort, default to id
68 $order = ( ! empty( $_REQUEST['order'] ) ) ? $_REQUEST['order'] : 'desc'; //If no order, default to desc
69 if ( 'id' == $orderby ) {
70 $result = ( $a > $b ? 1 : ( $a < $b ? -1 : 0 ) );
71 } else {
72 $result = strcmp( $a[ $orderby ], $b[ $orderby ] ); //Determine sort order
73 }
74 return ( 'asc' == $order ) ? $result : -$result; //Send final sort direction to usort
75 }
76
77 function prepare_items( ) {
78 global $login_history;
79
80 $per_page = 10;
81
82 $columns = $this->get_columns( );
83 $hidden = array();
84 $sortable = $this->get_sortable_columns( );
85
86 $this->_column_headers = array( $columns, $hidden, $sortable );
87
88 $this->process_bulk_action( );
89
90 $data = $login_history->get_history( );
91
92 $total_items = count( $data );
93 $current_page = $this->get_pagenum( );
94
95 if ( $total_items > 0 ) {
96 usort( $data, array( $this, 'usort_reorder' ) );
97 $data = array_slice( $data, ( ( $current_page - 1 ) * $per_page ), $per_page );
98 }
99
100 $this->items = $data;
101
102 $this->set_pagination_args( array(
103 'total_items' => $total_items, //WE have to calculate the total number of items
104 'per_page' => $per_page, //WE have to determine how many items to show on a page
105 'total_pages' => ceil( $total_items / $per_page ) //WE have to calculate the total number of pages
106 ) );
107 }
108 }
109 ?>
110