Skip to content

Instantly share code, notes, and snippets.

@gvgvgvijayan
Created January 23, 2021 08:35
Show Gist options
  • Save gvgvgvijayan/f35895f56257196eb688a9b6e54ef545 to your computer and use it in GitHub Desktop.
Save gvgvgvijayan/f35895f56257196eb688a9b6e54ef545 to your computer and use it in GitHub Desktop.
<?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 ) {
if ( 'top' === $which ) {
$drafts_dropdown_arg = array(
'options' => array( '' => 'All' ) + $this->allowed_post_types_readable(),
'container' => array(
'class' => 'alignleft actions',
),
'label' => array(
'class' => 'screen-reader-text',
'inner_text' => __( 'Filter by Post Type', 'admin-table-tut' ),
),
'select' => array(
'name' => 'type',
'id' => 'filter-by-type',
'selected' => filter_input( INPUT_GET, 'type', FILTER_SANITIZE_STRING ),
),
);
$this->html_dropdown( $drafts_dropdown_arg );
submit_button( __( 'Filter', 'admin-table-tut' ), 'secondary', 'action', false );
}
}
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment