WordPress.org

Make WordPress Core

Ticket #30325: view-switcher-modes-filter.30325.diff

File view-switcher-modes-filter.30325.diff, 1.1 KB (added by ragulka, 7 years ago)
  • src/wp-admin/includes/class-wp-list-table.php

    diff --git src/wp-admin/includes/class-wp-list-table.php src/wp-admin/includes/class-wp-list-table.php
    index b698d58..6dcecfc 100644
    class WP_List_Table { 
    537537         * @access protected
    538538         */
    539539        protected function view_switcher( $current_mode ) {
     540                /**
     541                 * Filter the list of available view modes.
     542                 *
     543                 * The dynamic portion of the hook name, $this->screen->id, refers
     544                 * to the ID of the current screen, usually a string.
     545                 *
     546                 * @since 4.1.0
     547                 *
     548                 * @param array $views An array of available views modes.
     549                 */
     550                $modes = apply_filters( "view_modes_{$this->screen->id}", $this->modes );
     551
     552                if ( empty( $modes ) )
     553                        return;
     554
    540555?>
    541556                <input type="hidden" name="mode" value="<?php echo esc_attr( $current_mode ); ?>" />
    542557                <div class="view-switch">
    543558<?php
    544                         foreach ( $this->modes as $mode => $title ) {
     559                        foreach ( $modes as $mode => $title ) {
    545560                                $classes = array( 'view-' . $mode );
    546561                                if ( $current_mode == $mode )
    547562                                        $classes[] = 'current';