| Server IP : 35.201.19.92 / Your IP : 216.73.216.156 Web Server : nginx System : Linux pod-200961 6.8.0-1055-gke #61-Ubuntu SMP Tue May 26 22:57:42 UTC 2026 x86_64 User : fpm200098 ( 200098) PHP Version : 8.2.33 Disable Function : apache_child_terminate,apache_get_modules,apache_get_version,apache_getenv,apache_note,apache_setenv,disk_free_space,disk_total_space,diskfreespace,dl,exec,fastcgi_finish_request,link,opcache_compile_file,opcache_get_configuration,opcache_invalidate,opcache_is_script_cached,opcache_reset,passthru,pclose,pcntl_exec,popen,posix_getpid,posix_getppid,posix_getpwuid,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,realpath_cache_get,shell_exec,show_source,symlink,system MySQL : OFF | cURL : ON | WGET : OFF | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /nas/content/live/questfamilyday/wp-content/themes/generatepress_child/admin/ |
Upload File : |
<?php
// WP_List_Table is not loaded automatically so we need to load it in our application
if( ! class_exists( 'WP_List_Table' ) ) {
require_once( ABSPATH . 'wp-admin/includes/class-wp-list-table.php' );
}
/**
* Create a new table class that will extend the WP_List_Table
*/
class Member_Logs_Table extends WP_List_Table
{
/**
* Prepare the items for the table to process
*
* @return Void
*/
public function prepare_items()
{
$columns = $this->get_columns();
$hidden = $this->get_hidden_columns();
$sortable = $this->get_sortable_columns();
$data = $this->table_data();
usort( $data, array( &$this, 'sort_data' ) );
$perPage = 20;
$currentPage = $this->get_pagenum();
$totalItems = count($data);
$this->set_pagination_args( array(
'total_items' => $totalItems,
'per_page' => $perPage
) );
$data = array_slice($data,(($currentPage-1)*$perPage),$perPage);
$this->_column_headers = array($columns, $hidden, $sortable);
$this->items = $data;
}
/**
* Override the parent columns method. Defines the columns to use in your listing table
*
* @return Array
*/
public function get_columns()
{
$columns = array(
'name' => 'Name',
'post' => 'Doc / Video',
'type' => 'Type',
'action' => 'Log',
'date' => 'Date'
);
return $columns;
}
/**
* Define which columns are hidden
*
* @return Array
*/
public function get_hidden_columns()
{
return array();
}
/**
* Define the sortable columns
*
* @return Array
*/
// public function get_sortable_columns()
// {
// return array('amount' => array('amount', false));
// }
public function get_sortable_columns(){
$s_columns = array (
'name' => [ 'name', true],
'date' => [ 'date', true],
);
return $s_columns;
}
/**
* Get the table data
*
* @return Array
*/
private function table_data()
{
global $wpdb;
$table_resources = $wpdb->prefix . 'member_resources_logs';
$table_posts = $wpdb->prefix . 'posts';
$table_users = $wpdb->prefix . 'users';
$results = $wpdb->get_results( "SELECT CONCAT(usermetafirst.meta_value,' ', usermetalast.meta_value) AS name, tbl_posts.post_title AS post, tbl_resources.log_type AS type, tbl_resources.action_type AS action, tbl_resources.created_at AS date FROM {$table_resources} tbl_resources LEFT JOIN {$table_posts} tbl_posts ON (tbl_resources.resource_post_id = tbl_posts.ID) LEFT JOIN {$table_users} tbl_users ON (tbl_resources.user_id = tbl_users.ID) INNER JOIN wp_usermeta usermetalast ON (tbl_users.ID = usermetalast.user_id AND usermetalast.meta_key = 'last_name') INNER JOIN wp_usermeta usermetafirst ON (tbl_users.ID = usermetafirst.user_id AND usermetafirst.meta_key = 'first_name')");
$log_results = json_decode( json_encode($results), true);
return $log_results;
}
/**
* Define what data to show on each column of the table
*
* @param Array $item Data
* @param String $column_name - Current column name
*
* @return Mixed
*/
public function column_default( $item, $column_name )
{
switch( $column_name ) {
case 'name':
case 'post':
case 'type':
case 'action':
case 'date':
return $item[ $column_name ];
default:
return print_r( $item, true ) ;
}
}
/**
* Allows you to sort the data by the variables set in the $_GET
*
* @return Mixed
*/
private function sort_data( $a, $b )
{
// Set defaults
$orderby = 'date';
$order = 'desc';
// If orderby is set, use this as the sort column
if(!empty($_GET['orderby']))
{
$orderby = $_GET['orderby'];
}
// If order is set use this as the order
if(!empty($_GET['order']))
{
$order = $_GET['order'];
}
$result = strnatcmp( $a[$orderby], $b[$orderby] );
if($order === 'asc')
{
return $result;
}
return -$result;
}
}
?>