Make WordPress Core

Changeset 46211


Ignore:
Timestamp:
09/20/2019 08:52:58 PM (4 years ago)
Author:
desrosj
Message:

Networks and Sites: Add support for the extra_tablenav() method in WP_MS_Sites_List_Table.

This method allows additional filters or other UI components to be added to the top and bottom of the WP_List_Table between the bulk actions dropdown and search input field.

Fixes #45954.
Props pbiron, desrosj.

Location:
trunk/src/wp-admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-ms-sites-list-table.php

    r46153 r46211  
    229229            $this->view_switcher( $mode );
    230230        }
     231    }
     232
     233    /**
     234     * Extra controls to be displayed between bulk actions and pagination.
     235     *
     236     * @since 5.3.0
     237     *
     238     * @param string $which
     239     */
     240    protected function extra_tablenav( $which ) {
     241        ?>
     242        <div class="alignleft actions">
     243        <?php
     244        if ( 'top' === $which ) {
     245            ob_start();
     246
     247            /**
     248             * Fires before the Filter button on the MS sites list table.
     249             *
     250             * @since 5.3.0
     251             *
     252             * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
     253             */
     254            do_action( 'restrict_manage_sites', $which );
     255            $output = ob_get_clean();
     256            if ( ! empty( $output ) ) {
     257                echo $output;
     258                submit_button( __( 'Filter' ), '', 'filter_action', false, array( 'id' => 'site-query-submit' ) );
     259            }
     260        }
     261        ?>
     262        </div>
     263        <?php
     264        /**
     265         * Fires immediately following the closing "actions" div in the tablenav for the
     266         * MS sites list table.
     267         *
     268         * @since 5.3.0
     269         *
     270         * @param string $which The location of the extra table nav markup: 'top' or 'bottom'.
     271         */
     272        do_action( 'manage_sites_extra_tablenav', $which );
    231273    }
    232274
  • trunk/src/wp-admin/network/sites.php

    r45932 r46211  
    232232                    exit();
    233233                }
    234             } else {
    235                 $location = network_admin_url( 'sites.php' );
    236                 if ( ! empty( $_REQUEST['paged'] ) ) {
    237                     $location = add_query_arg( 'paged', (int) $_REQUEST['paged'], $location );
    238                 }
    239                 wp_redirect( $location );
    240                 exit();
     234            } elseif ( ! empty( $_GET['_wp_http_referer'] ) ) {
     235                // process query defined by WP_MS_Site_List_Table::extra_table_nav().
     236                wp_redirect( remove_query_arg( array( '_wp_http_referer', '_wpnonce' ), wp_unslash( $_SERVER['REQUEST_URI'] ) ) );
     237                exit;
    241238            }
     239
    242240            break;
    243241
Note: See TracChangeset for help on using the changeset viewer.