In WP_List_Table
, add a property, $modes
, to allow WP_Media_List_Table
to inherit ->view_switcher()
.
See #30224. git-svn-id: https://develop.svn.wordpress.org/trunk@30154 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f759c23d31
commit
c171bb4aae
@ -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';
|
||||
|
@ -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.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user