Make WordPress Core

Changeset 46254


Ignore:
Timestamp:
09/23/2019 05:50:22 PM (7 years ago)
Author:
johnjamesjacoby
Message:

Multisite/Sites: supplemental commit to r46251.

This commit adds the links to the list-table class itself (that were missed in r46251.)

See #37392. Props pbiron, thomaswm.

File:
1 edited

Legend:

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

    r46212 r46254  
    161161                }
    162162
     163                // Take into account the role the user has selected.
     164                $status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
     165                if ( in_array( $status, array( 'public', 'archived', 'mature', 'spam', 'deleted' ), true ) ) {
     166                        $args[ $status ] = 1;
     167                }
     168
    163169                /**
    164170                 * Filters the arguments for the site query in the sites list table.
     
    200206        public function no_items() {
    201207                _e( 'No sites found.' );
     208        }
     209
     210        /**
     211         * Gets links to filter sites by status.
     212         *
     213         * @since 5.3.0
     214         *
     215         * @return array
     216         *
     217         */
     218        protected function get_views() {
     219                $counts = wp_count_sites();
     220
     221                $statuses = array(
     222                        'all'      => _n_noop( 'All <span class="count">(%s)</span>', 'All <span class="count">(%1$s)</span>' ),
     223                        'public'   => _n_noop( 'Public <span class="count">(%s)</span>', 'Public <span class="count">(%1$s)</span>' ),
     224                        'archived' => _n_noop( 'Archived <span class="count">(%1$s)</span>', 'Archived <span class="count">(%1$s)</span>' ),
     225                        'mature'   => _n_noop( 'Mature <span class="count">(%1$s)</span>', 'Mature <span class="count">(%1$s)</span>' ),
     226                        'spam'     => _n_noop( 'Spam <span class="count">(%1$s)</span>', 'Spam <span class="count">(%1$s)</span>' ),
     227                        'deleted'  => _n_noop( 'Deleted <span class="count">(%1$s)</span>', 'Deleted <span class="count">(%1$s)</span>' ),
     228                );
     229
     230                $view_links       = array();
     231                $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
     232                $url              = 'sites.php';
     233
     234                foreach ( $statuses as $status => $label_count ) {
     235                        $current_link_attributes = $requested_status === $status || ( $requested_status === '' && 'all' === $status )
     236                                ? ' class="current" aria-current="page"'
     237                                : '';
     238                        if ( (int) $counts[ $status ] > 0 ) {
     239                                $label = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) );
     240                                $full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
     241
     242                                $view_links[ $status ] = sprintf(
     243                                        '<a href="%1$s"%2$s>%3$s</a>',
     244                                        esc_url( $full_url ),
     245                                        $current_link_attributes,
     246                                        $label
     247                                );
     248                        }
     249                }
     250
     251                return $view_links;
    202252        }
    203253
Note: See TracChangeset for help on using the changeset viewer.