views_(screen_id)filter-hookWP 3.1.0

Allows you to change the list of available table views.

In the screenshot example, the following data is passed through the filter hook:

Array
(
	[all] => <a href="edit.php?post_type=post&all_posts=1">All <span class="count">(21)</span></a>
	[mine] => <a href="edit.php?post_type=post&author=3" class="current" aria-current="page">Mine <span class="count">(5)</span></a>
	[publish] => <a href="edit.php?post_status=publish&post_type=post">Published <span class="count">(15)</span></a>
	[sticky] => <a href="edit.php?post_type=post&show_sticky=1">Sticky <span class="count">(2)</span></a>
	[future] => <a href="edit.php?post_status=future&post_type=post">Scheduled <span class="count">(1)</span></a>
	[draft] => <a href="edit.php?post_status=draft&post_type=post">Drafts <span class="count">(3)</span></a>
	[pending] => <a href="edit.php?post_status=pending&post_type=post">Pending <span class="count">(2)</span></a>
	[trash] => <a href="edit.php?post_status=trash&post_type=post">Trash <span class="count">(2)</span></a>
)

The hook name is generated dynamically from $this->screen->id (the unique admin screen ID). See get_current_screen() for screen_id values.

Usage

add_filter( 'views_(screen_id)', 'wp_kama_views_screen_id_filter' );

/**
 * Function for `views_(screen_id)` filter-hook.
 * 
 * @param string[] $views An array of available list table views.
 *
 * @return string[]
 */
function wp_kama_views_screen_id_filter( $views ){

	// filter...
	return $views;
}
$views(array)
A list of links representing table views.

Examples

#1 Remove one item (sticky) from the list for the Posts table

add_filter( 'views_edit-post', function( $array ){
	unset( $array['sticky'] );
	return $array;
} );

#2 Remove the entire action list for the Posts table

add_filter( 'views_edit-post', '__return_empty_array' );

Changelog

Since 3.1.0 Introduced.

Where the hook is called

WP_List_Table::views()
views_(screen_id)
WP_Plugin_Install_List_Table::views()
views_(screen_id)
WP_Media_List_Table::views()
views_(screen_id)
wp-admin/includes/class-wp-list-table.php 528
$views = apply_filters( "views_{$this->screen->id}", $views );
wp-admin/includes/class-wp-plugin-install-list-table.php 343
$views = apply_filters( "views_{$this->screen->id}", $views );
wp-admin/includes/class-wp-media-list-table.php 332
$views = apply_filters( "views_{$this->screen->id}", array() );

Where the hook is used in WordPress

Usage not found.