WP_List_Table::view_switcher() WordPress Method

The WP_List_Table::view_switcher() method is used to display a view switcher on a list table. The view switcher allows you to switch between different views of the data in the list table.

WP_List_Table::view_switcher( string $current_mode ) #

Displays a view switcher.


Parameters

$current_mode

(string)(Required)


Top ↑

More Information

Call this to render post-type view switcher buttons (List View and Excerpt View)


Top ↑

Source

File: wp-admin/includes/class-wp-list-table.php

	protected function view_switcher( $current_mode ) {
		?>
		<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
		<div class="view-switch">
		<?php
		foreach ( $this->modes as $mode => $title ) {
			$classes      = array( 'view-' . $mode );
			$aria_current = '';

			if ( $current_mode === $mode ) {
				$classes[]    = 'current';
				$aria_current = ' aria-current="page"';
			}

			printf(
				"<a href='%s' class='%s' id='view-switch-$mode'$aria_current><span class='screen-reader-text'>%s</span></a>\n",
				esc_url( remove_query_arg( 'attachment-filter', add_query_arg( 'mode', $mode ) ) ),
				implode( ' ', $classes ),
				$title
			);
		}
		?>
		</div>
		<?php
	}


Top ↑

Changelog

Changelog
VersionDescription
3.1.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.