<?php

namespace Quicker\Core\Admin\Settings;

defined( 'ABSPATH' ) || exit;

if ( ! class_exists( 'WP_List_Table' ) ) {
	require_once ABSPATH . 'wp-admin/includes/class-wp-list-table.php';
}

class Table extends \WP_List_Table {

	public $singular_name;
	public $plural_name;
	public $id      = '';
	public $columns = array();

	/**
	 * Show list
	 */
	function __construct( $all_data_of_table ) {

		$this->singular_name = $all_data_of_table['singular_name'];
		$this->plural_name   = $all_data_of_table['plural_name'];
		$this->columns       = $all_data_of_table['columns'];

		parent::__construct(
			array(
				'singular' => $this->singular_name,
				'plural'   => $this->plural_name,
				'ajax'     => true,
			)
		);
	}

	/**
	 * Get column header function
	 */
	public function get_columns() {
		return $this->columns;
	}


	/**
	 * Sortable column function
	 */
	public function get_sortable_columns() {
		unset( $this->columns['enable_rules'] );
		unset( $this->columns['action'] );

		return $this->columns;
	}

	/**
	 * Display all row function
	 */
	protected function column_default( $item, $column_name ) {
		switch ( $column_name ) {
			case $column_name:
				return $item[ $column_name ];
			default:
				isset( $item[ $column_name ] ) ? $item[ $column_name ] : '';
				break;
		}
	}

	/**
	 * Main query and show function
	 */
	public function preparing_items() {
	}
}
