<commit_before><?php

/**
 * @file
 * Custom table list class.
 *
 * Created by: Topsitemakers
 * http://www.topsitemakers.com/
 */

// Load base class if it doesn't exist.
if(!class_exists('WP_List_Table')) require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');

// Plugin class.
class Boilerplate_List_Users extends WP_List_Table {
  
  /**
   * Construct function.
   * Set default settings.
   */
  function __construct() {
    global $status, $page;
    //Set parent defaults.
    parent::__construct(array(
      'ajax' => FALSE,
      'singular' => 'user',
      'plural' => 'users',
    ));
  }
  
  
  /**
   * Define column methods.
   */
  function column_default($item, $column_name) {
    switch ($column_name) {
      case 'name':
      case 'username':
      case 'email':
      case 'subscription':
      case 'type':
      case 'action':
        return $item[$column_name];
      default:
        // Debug.
        // return print_r($item, TRUE);
    }
  }

  /**
   * Define columns.
   */
  function get_columns() {
    return array(
      'name'     => __('Full name'),
      'username' => __('Username'),
      'email'    => __('Email'),
      'type'     => __('Type'),
      'action'   => __('Action'),
    );
  }
  
  /**
   * Sortable settings.
   */
  function get_sortable_columns() {
    return array(
      'name' => array('name', TRUE),     //TRUE means its already sorted
      'username' => array('username', FALSE),
      'email' => array('email', FALSE),
    );
  }
  
  
  /**
   * Prepare the data.
   */
  function prepare_items() {
    
    $per_page = 25;
    
    // Column headers.
    $columns  = $this->get_columns();
    $hidden   = array();
    $sortable = $this->get_sortable_columns();
    $this->_column_headers = array($columns, $hidden, $sortable);
    
    /**
     * Prepare the data.
     */
    global $wpdb;

    /**
     * Sorting.
     */
    function usort_reorder($a,$b) {
      $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'name';
      $order   = (!empty($_REQUEST['order'])) ? $_REQUEST['order'] : 'asc';
      $result  = strcmp($a[$orderby], $b[$orderby]);
      return ($order==='asc') ? $result : -$result;
    }
    usort($data, 'usort_reorder');
    
    
    // Pagination.
    $current_page = $this->get_pagenum();
    
    // Total number of items, necessary for pagination.
    $total_items = count($data);
    
    // Get only items for current page.
    $data = array_slice($data,(($current_page-1)*$per_page),$per_page);
    
    // Done - add it to items.
    $this->items = $data;<commit_msg>Cleanup v3<commit_after><?php

/**
 * @file
 * Custom table list class.
 *
 * Created by: Topsitemakers
 * http://www.topsitemakers.com/
 */

// Load base class if it doesn't exist.
if(!class_exists('WP_List_Table')) require_once(ABSPATH . 'wp-admin/includes/class-wp-list-table.php');

// Plugin class.
class Boilerplate_List_Users extends WP_List_Table {
  
  /**
   * Construct function.
   */
  function __construct() {
    global $status;
    global $page;
    // Set parent defaults.
    parent::__construct(array(
      'ajax'     => FALSE,
      'singular' => 'user',
      'plural'   => 'users',
    ));
  }
  
  
  /**
   * Define column methods.
   */
  function column_default($item, $column_name) {
    switch ($column_name) {
      case 'name':
      case 'username':
      case 'email':
      case 'action':
        return $item[$column_name];
      default:
        // Debug.
        // return print_r($item, TRUE);
    }
  }

  /**
   * Define columns.
   */
  function get_columns() {
    return array(
      'name'     => __('Full name'),
      'username' => __('Username'),
      'email'    => __('Email'),
      'action'   => __('Action'),
    );
  }
  
  /**
   * Sortable settings.
   */
  function get_sortable_columns() {
    return array(
      'name' => array('name', TRUE),
      'username' => array('username', FALSE),
      'email' => array('email', FALSE),
    );
  }
  
  
  /**
   * Prepare the data.
   */
  function prepare_items() {
    
    // Number of items per page.
    $per_page = 25;
    
    // Column headers.
    $columns  = $this->get_columns();
    $hidden   = array();
    $sortable = $this->get_sortable_columns();
    $this->_column_headers = array($columns, $hidden, $sortable);
    
    /**
     * Prepare the data.
     */
    global $wpdb;
    // 

    /**
     * Sorting.
     */
    function usort_reorder($a,$b) {
      $orderby = (!empty($_REQUEST['orderby'])) ? $_REQUEST['orderby'] : 'name';
      $order   = (!empty($_REQUEST['order']))   ? $_REQUEST['order']   : 'asc';
      $result  = strcmp($a[$orderby], $b[$orderby]);
      return ($order === 'asc') ? $result : -$result;
    }
    usort($data, 'usort_reorder');
    
    
    // Pagination.
    $current_page = $this->get_pagenum();
    
    // Total number of items, necessary for pagination.
    $total_items = count($data);
    
    // Get only items for current page.
    $data = array_slice($data, (($current_page - 1) * $per_page), $per_page);
    
    // Done - add it to items.
    $this->items = $data;
{'fraction_non_alphanumeric': 0.175725696473797, 'fraction_numerical': 0.0013637249172024158, 'mean_word_length': 2.2432090966519267, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 34, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2201427', 'n_tokens_mistral': 1718, 'n_tokens_neox': 1698, 'n_words': 359}