Make WordPress Core

Ticket #37392: 37392.4.patch

File 37392.4.patch, 4.9 KB (added by mnelson4, 7 years ago)

Same as previous, except no unnecessary removal of line in ms-functions.php

  • src/wp-admin/includes/class-wp-ms-sites-list-table.php

    From 648657de6d273457cd8bb13c088f1393aba8e9a3 Mon Sep 17 00:00:00 2001
    From: Mike Nelson <michael@eventespresso.com>
    Date: Thu, 8 Feb 2018 11:36:04 -0800
    Subject: [PATCH] [touch:37392]oups remove extra blank space too
    
    ---
     .../includes/class-wp-ms-sites-list-table.php      | 43 ++++++++++++++++++++++
     src/wp-admin/network/sites.php                     |  2 +
     src/wp-includes/ms-blogs.php                       | 40 ++++++++++++++++++++
     3 files changed, 85 insertions(+)
    
    diff --git src/wp-admin/includes/class-wp-ms-sites-list-table.php src/wp-admin/includes/class-wp-ms-sites-list-table.php
    index 1741d51..c4b7407 100644
    class WP_MS_Sites_List_Table extends WP_List_Table { 
    157157                } else {
    158158                        $args['no_found_rows'] = false;
    159159                }
     160                //take into account the role the user has selected
     161                $status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
     162                if ( in_array( $status, array( 'public', 'archived', 'mature', 'spam', 'deleted' ), true ) ) {
     163                        $args[ $status ] = 1;
     164                }
    160165
    161166                /**
    162167                 * Filters the arguments for the site query in the sites list table.
    class WP_MS_Sites_List_Table extends WP_List_Table { 
    199204        }
    200205
    201206        /**
     207     * Gets links to filter sites by status
     208     * @since 5.0.0
     209         * @return array
     210         */
     211        protected function get_views() {
     212                $counts        = wp_count_sites();
     213                $slug_to_label = array(
     214                        'all'      => _n_noop( 'All <span class="count">(%s)</span>', 'All <span class="count">(%1$s)</span>' ),
     215                        'public'   => _n_noop( 'Public <span class="count">(%s)</span>' ,'Public <span class="count">(%1$s)</span>' ),
     216                        'archived' => _n_noop( 'Archived <span class="count">(%1$s)</span>', 'Archived <span class="count">(%1$s)</span>' ),
     217                        'mature'   => _n_noop( 'Mature <span class="count">(%1$s)</span>', 'Mature <span class="count">(%1$s)</span>' ),
     218                        'spam'     => _n_noop( 'Spam <span class="count">(%1$s)</span>', 'Spam <span class="count">(%1$s)</span>' ),
     219                        'deleted'  => _n_noop( 'Deleted <span class="count">(%1$s)</span>', 'Deleted <span class="count">(%1$s)</span>' ),
     220                );
     221
     222                $view_links       = array();
     223                $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
     224                $url              = 'sites.php';
     225               
     226                foreach ( $slug_to_label as $this_status => $label_count ) {
     227                        $current_link_attributes = $requested_status == $this_status || ( $requested_status === '' && 'all' === $this_status )
     228                                ? ' class="current" aria-current="page"'
     229                                : '';
     230                        if ( (int) $counts->{$this_status} > 0 ) {
     231                                $label = sprintf( translate_nooped_plural( $label_count, $counts->{$this_status} ), number_format_i18n( $counts->{$this_status} ) );
     232                                $view_links[ $this_status ] = sprintf(
     233                                        '<a href="%1$s"%2$s>%3$s</a>',
     234                                        esc_url( add_query_arg( 'status', $this_status, $url ) ),
     235                                        $current_link_attributes,
     236                                        $label
     237                                );
     238                        }
     239                }
     240
     241                return $view_links;
     242        }
     243
     244        /**
    202245         * @return array
    203246         */
    204247        protected function get_bulk_actions() {
  • src/wp-admin/network/sites.php

    diff --git src/wp-admin/network/sites.php src/wp-admin/network/sites.php
    index b5b55bd..322282e 100644
    if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { 
    355355
    356356<hr class="wp-header-end">
    357357
     358<?php $wp_list_table->views(); ?>
     359
    358360<?php echo $msg; ?>
    359361
    360362<form method="get" id="ms-search">
  • src/wp-includes/ms-blogs.php

    diff --git src/wp-includes/ms-blogs.php src/wp-includes/ms-blogs.php
    index b862037..2670a62 100644
    function _update_posts_count_on_transition_post_status( $new_status, $old_status 
    13601360
    13611361        update_posts_count();
    13621362}
     1363
     1364/**
     1365 * Count number of sites grouped by site status.
     1366 *
     1367 * @since 5.0.0
     1368 * @global wpdb $wpdb       WordPress database abstraction object.
     1369 *
     1370 * @param int   $network_id Defaults to the current network id
     1371 *
     1372 * @return object Includes a grand total 'all' and an array of counts indexed by status strings: public, archived,
     1373 *                mature, spam, deleted
     1374 */
     1375function wp_count_sites( $network_id = null ) {
     1376        global $wpdb;
     1377        if ( null === $network_id ) {
     1378                $network_id = get_current_network_id();
     1379        }
     1380        $cache_key = 'counts-' . $network_id;
     1381        $counts = wp_cache_get( $cache_key, 'sites' );
     1382        if ( false !== $counts ) {
     1383                return $counts;
     1384        }
     1385        $counts = $wpdb->get_row(
     1386                $wpdb->prepare( '
     1387                        SELECT
     1388                        COUNT(blog_id) AS `all`,
     1389                        COUNT(IF(public=1,blog_id,null)) AS public,
     1390                        COUNT(IF(archived=1, blog_id, null)) AS archived,
     1391                        COUNT(IF(mature=1, blog_id, null)) AS mature,
     1392                        COUNT(IF(spam=1, blog_id, null)) AS spam,
     1393                        COUNT(IF(deleted=1, blog_id, null)) AS deleted
     1394                        FROM wp_blogs
     1395                        WHERE site_id=%d',
     1396                        $network_id
     1397                )
     1398        );
     1399        wp_cache_set( $cache_key, $counts, 'sites' );
     1400
     1401        return $counts;
     1402}