You have to call the method process_bulk_action()
inside the method prepare_items()
Please find the gist which I created: https://gist.github.com/gvgvgvijayan/d46a52ca47309d1685ac91db3e9cf759#file-admin-table-tut-php-L272
Snippet:
public function prepare_items() {
$columns = $this->get_columns();
$sortable = $this->get_sortable_columns();
$hidden = array();
$primary = 'title';
$this->_column_headers = array( $columns, $hidden, $sortable, $primary );
$data = array();
$this->process_bulk_action();
$get_posts_obj = $this->get_posts_object();
if ( $get_posts_obj->have_posts() ) {
while ( $get_posts_obj->have_posts() ) {
$get_posts_obj->the_post();
$data[ get_the_ID() ] = array(
'id' => get_the_ID(),
'title' => get_the_title(),
'type' => ucwords( get_post_type_object( get_post_type() )->labels->singular_name ),
'date' => get_post_datetime(),
'author' => get_the_author(),
);
}
wp_reset_postdata();
}
$this->items = $data;
$this->set_pagination_args(
array(
'total_items' => $get_posts_obj->found_posts,
'per_page' => $get_posts_obj->post_count,
'total_pages' => $get_posts_obj->max_num_pages,
)
);
}
Update 1:
Place all of your class method calls inside the form
tag as below snippet.
function show_list_table() {
$mnc_list_table = new MNCTableClass();
echo '<h3>MNC List</h3>';
echo "<form method='post' name='frm_search_post' action='" . $_SERVER['PHP_SELF'] . "?page=alluserentries'>";
$mnc_list_table->prepare_items();
$mnc_list_table->display();
$mnc_list_table->search_box("Search", "search_post_id");
echo "</form>";
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…