Warning: chmod(): Operation not permitted in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [0] in function chmod in /var/www/hopeinstoughton_www/wp-content/plugins/simple-universal-google-analytics/main.php on line 8 [1] in function include_once in /var/www/hopeinstoughton_www/wp-settings.php on line 560 [2] in function require_once in /var/www/hopeinstoughton_www/wp-config.php on line 85 [3] in function require_once in /var/www/hopeinstoughton_www/wp-load.php on line 50 [4] in function require_once in /var/www/hopeinstoughton_www/wp-blog-header.php on line 13 [5] in function require in /var/www/hopeinstoughton_www/index.php on line 17
| Server IP : 94.177.8.99 / Your IP : 216.73.217.165 Web Server : Apache/2.4.58 (Ubuntu) System : Linux aries 6.8.0-134-generic #134-Ubuntu SMP PREEMPT_DYNAMIC Fri Jun 26 18:43:11 UTC 2026 x86_64 User : www-data ( 33) PHP Version : 8.1.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/hopeinstoughton_www/wp-content/plugins/his-schedule/ |
Upload File : |
<?php
class Schedule_List_Table extends WP_List_Table {
function __construct(){
global $status, $page;
//Set parent defaults
parent::__construct( array(
'singular' => 'field', //singular name of the listed records
'plural' => 'fields', //plural name of the listed records
'ajax' => false //does this table support ajax?
) );
}
function column_default($item, $column_name){
switch($column_name){
case 'year':
return $item[$column_name];
default:
return print_r($item,true); //Show the whole array for troubleshooting purposes
}
}
function column_year($item){
//Build row actions
$actions = array(
'update' => sprintf('<a href="?page=schedule_edit&id=%s">Edit</a>',$item['id']),
'map' => sprintf('<a href="?page=schedule_xlsx&id=%s">Mapping</a>',$item['id']),
// 'delete' => sprintf('<a href="?page=schedule_xlsx&action=%s&id=%s" onclick="return confirmDelete(false, \'%s\')">Delete</a>','delete',$item['id'], $item['md_name']),
);
//Return the title contents
return sprintf('<a class="row-title" href="?page=schedule_edit&id=%s">%s</a> <span style="color:silver">(id:%s)</span>%s',
$item['id'],
/*$1%s*/ $item['year'],
/*$2%s*/ $item['id'],
/*$3%s*/ $this->row_actions($actions)
);
}
function column_cb($item){
return sprintf(
'<input type="checkbox" name="%1$s[]" value="%2$s" />',
/*$1%s*/ $this->_args['singular'], //Let's simply repurpose the table's singular label ("movie")
/*$2%s*/ $item['id'] //The value of the checkbox should be the record's id
);
}
function get_columns(){
$columns = array(
'cb' => '<input type="checkbox" />', //Render a checkbox instead of text
'year' => 'Year',
);
return $columns;
}
function get_sortable_columns() {
return array(
'year' => array('year',false), //true means it's already sorted
);
}
function get_bulk_actions() {
$actions = array(
'delete' => 'Delete'
);
return $actions;
}
function process_bulk_action() {
//Detect when a bulk action is being triggered...
if( 'delete'===$this->current_action() ) {
wp_die('Items deleted (or they would be if we had items to delete)!');
}
}
function prepare_items() {
global $wpdb;
$per_page = 10;
$columns = $this->get_columns();
$hidden = [];
$sortable = $this->get_sortable_columns();
$this->_column_headers = array($columns, $hidden, $sortable);
$this->process_bulk_action();
$query = 'select option_id,option_name,option_value from ' . $wpdb->prefix . 'options where option_name like "worksheet_%"';
$rows = $wpdb->get_results($query);
$data = [];
foreach($rows as $row) {
$year = preg_match('~(\d+)~', $row->option_name, $match) ? $match[1] : '';
if ($year > 2000) {
$data[] = [ 'id' => $row->option_id, 'year' => $year ];
}
}
usort($data, array($this, 'usort_reorder'));
$current_page = $this->get_pagenum();
$total_items = count($data);
$this->items = array_slice($data,(($current_page-1)*$per_page),$per_page);
$this->set_pagination_args( array(
'total_items' => $total_items,
'per_page' => $per_page,
'total_pages' => ceil($total_items/$per_page)
) );
}
function usort_reorder($a,$b){
$orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'year'; //If no sort, default to year
$order = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'desc'; //If no order, default to desc
$result = strcmp($a[$orderby], $b[$orderby]); //Determine sort order
return ($order==='asc') ? $result : -$result; //Send final sort direction to usort
}
}