Skip to content

Instantly share code, notes, and snippets.

View gvgvgvijayan's full-sized avatar

Vijayan gvgvgvijayan

View GitHub Profile
<?php
...
/**
* This function is responsible for render the drafts table
*/
function bootload_drafts_table() : void {
$drafts_table = new Drafts_List_Table();
?>
<div class="wrap">
<h2><?php esc_html_e( 'All Drafts List', 'admin-table-tut' ); ?></h2>
<?php
...
/**
* Fires before the administration menu loads in the admin.
*/
add_action(
'admin_menu',
function() : void {
add_menu_page(
'All Drafts',
<?php
...
/**
* Fires in head section of admin page
*/
add_action(
'admin_head',
function() : void {
$page = esc_attr( filter_input( INPUT_GET, 'page' ) );
if ( 'all-drafts' !== $page ) {
<?php
...
/**
* Include the columns which can be sortable.
*
* @return Array $sortable_columns Return array of sortable columns.
*/
public function get_sortable_columns() {
return array(
<?php
...
/**
* Navigation dropdown HTML generator
*
* @param array $args Argument array to generate dropdown.
*
* @return void
*/
private function html_dropdown( $args ) {
<?php
...
/**
* Overriden method to add dropdown filters column type.
*
* @param string $which Position of the navigation, either top or bottom.
*
* @return void
*/
protected function extra_tablenav( $which ) {
<?php
...
/**
* Generates the table navigation above or below the table
*
* @param string $which Position of the navigation, either top or bottom.
*
* @return void
*/
protected function display_tablenav( $which ) {
<?php
...
/**
* Get bulk actions.
*
* @return void
*/
public function process_bulk_action() {
if ( 'trash' === $this->current_action() ) {
$post_ids = filter_input( INPUT_GET, 'draft_id', FILTER_DEFAULT, FILTER_REQUIRE_ARRAY );
<?php
...
/**
* Get bulk actions.
*
* @return array
*/
public function get_bulk_actions() {
return array(
'trash' => __( 'Move to Trash', 'admin-table-tut' ),
<?php
...
/**
* Prepare the data for the WP List Table
*
* @return void
*/
public function prepare_items() {
$columns = $this->get_columns();
$sortable = $this->get_sortable_columns();