WP_Media_List_Table::views()

In this article

Overrides parent views to use the filter bar display.

Source

public function views() {
	global $mode;

	$views = $this->get_views();

	$this->screen->render_screen_reader_content( 'heading_views' );
	?>
	<div class="wp-filter">
		<div class="filter-items">
			<?php $this->view_switcher( $mode ); ?>

			<label for="attachment-filter" class="screen-reader-text">
				<?php
				/* translators: Hidden accessibility text. */
				_e( 'Filter by type' );
				?>
			</label>
			<select class="attachment-filters" name="attachment-filter" id="attachment-filter">
				<?php
				if ( ! empty( $views ) ) {
					foreach ( $views as $class => $view ) {
						echo "\t$view\n";
					}
				}
				?>
			</select>

			<?php
			$this->extra_tablenav( 'bar' );

			/** This filter is documented in wp-admin/includes/class-wp-list-table.php */
			$views = apply_filters( "views_{$this->screen->id}", array() );

			// Back compat for pre-4.0 view links.
			if ( ! empty( $views ) ) {
				echo '<ul class="filter-links">';
				foreach ( $views as $class => $view ) {
					echo "<li class='$class'>$view</li>";
				}
				echo '</ul>';
			}
			?>
		</div>

		<div class="search-form">
			<p class="search-box">
				<label class="screen-reader-text" for="media-search-input">
				<?php
				/* translators: Hidden accessibility text. */
				esc_html_e( 'Search Media' );
				?>
				</label>
				<input type="search" id="media-search-input" class="search" name="s" value="<?php _admin_search_query(); ?>">
				<input id="search-submit" type="submit" class="button" value="<?php esc_attr_e( 'Search Media' ); ?>">
			</p>
		</div>
	</div>
	<?php
}

Hooks

apply_filters( “views_{$this->screen->id}”, string[] $views )

Filters the list of available list table views.

User Contributed Notes

You must log in before being able to contribute a note or feedback.