In WP_List_Table, add a property, $modes, to allow WP_Media_List_Table to inherit ->view_switcher().

See #30224.

Built from https://develop.svn.wordpress.org/trunk@30154


git-svn-id: http://core.svn.wordpress.org/trunk@30154 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-11-01 19:56:24 +00:00
parent be707cd614
commit 0b9c1be743
3 changed files with 23 additions and 39 deletions

View File

@ -64,6 +64,15 @@ class WP_List_Table {
*/
private $_pagination;
/**
* The view switcher modes
*
* @since 4.1.0
* @var array
* @access protected
*/
protected $modes = array();
/**
* Constructor.
*
@ -114,6 +123,13 @@ class WP_List_Table {
// wp_enqueue_script( 'list-table' );
add_action( 'admin_footer', array( $this, '_js_vars' ) );
}
if ( empty( $this->modes ) ) {
$this->modes = array(
'list' => __( 'List View' ),
'excerpt' => __( 'Excerpt View' )
);
}
}
/**
@ -520,16 +536,11 @@ class WP_List_Table {
* @access protected
*/
protected function view_switcher( $current_mode ) {
$modes = array(
'list' => __( 'List View' ),
'excerpt' => __( 'Excerpt View' )
);
?>
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
<div class="view-switch">
<?php
foreach ( $modes as $mode => $title ) {
foreach ( $this->modes as $mode => $title ) {
$classes = array( 'view-' . $mode );
if ( $current_mode == $mode )
$classes[] = 'current';

View File

@ -22,6 +22,11 @@ class WP_Media_List_Table extends WP_List_Table {
public function __construct( $args = array() ) {
$this->detached = ( isset( $_REQUEST['attachment-filter'] ) && 'detached' === $_REQUEST['attachment-filter'] );
$this->modes = array(
'list' => __( 'List View' ),
'grid' => __( 'Grid View' )
);
parent::__construct( array(
'plural' => 'media',
'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
@ -147,38 +152,6 @@ class WP_Media_List_Table extends WP_List_Table {
parent::pagination( $which );
}
/**
* Display a view switcher
*
* @since 3.1.0
* @access protected
*/
protected function view_switcher( $current_mode ) {
$modes = array(
'list' => __( 'List View' ),
'grid' => __( 'Grid View' )
);
?>
<input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
<div class="view-switch">
<?php
foreach ( $modes as $mode => $title ) {
$classes = array( 'view-' . $mode );
if ( $current_mode == $mode )
$classes[] = 'current';
printf(
"<a href='%s' class='%s' id='view-switch-$mode'><span class='screen-reader-text'>%s</span></a>\n",
esc_url( add_query_arg( 'mode', $mode ) ),
implode( ' ', $classes ),
$title
);
}
?>
</div>
<?php
}
/**
* Override parent views so we can use the filter bar display.
*/

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.1-alpha-30153';
$wp_version = '4.1-alpha-30154';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.