Make WordPress Core

Ticket #37684: 37684.02.diff

File 37684.02.diff, 4.2 KB (added by johnjamesjacoby, 8 years ago)

Remove site states from WP_MS_Sites_List_Table class

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

    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 9ce3ffe..6780a72 100644
     
    1818class WP_MS_Sites_List_Table extends WP_List_Table {
    1919
    2020        /**
    21          * Site status list.
    22          *
    23          * @since 4.3.0
    24          * @access public
    25          * @var array
    26          */
    27         public $status_list;
    28 
    29         /**
    3021         * Constructor.
    3122         *
    3223         * @since 3.1.0
     
    3728         * @param array $args An associative array of arguments.
    3829         */
    3930        public function __construct( $args = array() ) {
    40                 $this->status_list = array(
    41                         'archived' => array( 'site-archived', __( 'Archived' ) ),
    42                         'spam'     => array( 'site-spammed', _x( 'Spam', 'site' ) ),
    43                         'deleted'  => array( 'site-deleted', __( 'Deleted' ) ),
    44                         'mature'   => array( 'site-mature', __( 'Mature' ) )
    45                 );
    46 
    4731                parent::__construct( array(
    4832                        'plural' => 'sites',
    4933                        'screen' => isset( $args['screen'] ) ? $args['screen'] : null,
     
    303287                global $mode;
    304288
    305289                $blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
    306                 $blog_states = array();
    307                 reset( $this->status_list );
    308 
    309                 foreach ( $this->status_list as $status => $col ) {
    310                         if ( $blog[ $status ] == 1 ) {
    311                                 $blog_states[] = $col[1];
    312                         }
    313                 }
    314                 $blog_state = '';
    315                 if ( ! empty( $blog_states ) ) {
    316                         $state_count = count( $blog_states );
    317                         $i = 0;
    318                         $blog_state .= ' - ';
    319                         foreach ( $blog_states as $state ) {
    320                                 ++$i;
    321                                 $sep = ( $i == $state_count ) ? '' : ', ';
    322                                 $blog_state .= "<span class='post-state'>$state$sep</span>";
    323                         }
    324                 }
    325 
    326290                ?>
    327                 <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
     291                <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname; ?></a>
    328292                <?php
     293
     294                _site_states( $blog );
     295
    329296                if ( 'list' !== $mode ) {
    330297                        switch_to_blog( $blog['blog_id'] );
    331298                        echo '<p>';
     
    460427                foreach ( $this->items as $blog ) {
    461428                        $blog = $blog->to_array();
    462429                        $class = '';
    463                         reset( $this->status_list );
     430                        $statuses = array(
     431                                'archived' => array( 'site-archived', __( 'Archived' ) ),
     432                                'spam'     => array( 'site-spammed',  _x( 'Spam', 'site' ) ),
     433                                'deleted'  => array( 'site-deleted',  __( 'Deleted' ) ),
     434                                'mature'   => array( 'site-mature',   __( 'Mature' ) )
     435                        );
    464436
    465                         foreach ( $this->status_list as $status => $col ) {
     437                        foreach ( $statuses as $status => $col ) {
    466438                                if ( $blog[ $status ] == 1 ) {
    467439                                        $class = " class='{$col[0]}'";
    468440                                }
  • src/wp-admin/includes/template.php

    diff --git src/wp-admin/includes/template.php src/wp-admin/includes/template.php
    index 57478a1..522fa4e 100644
     
    17931793}
    17941794
    17951795/**
     1796 *
     1797 * @param WP_Site $site
     1798 */
     1799function _site_states( $site ) {
     1800        $site_states = array();
     1801
     1802        // $site is still an array in class-wp-ms-sites-list-table.php
     1803        $_site = WP_Site::get_instance( $site['blog_id'] );
     1804
     1805        if ( is_main_site( $_site->id ) ) {
     1806                $site_states['deleted'] = __( 'Main' );
     1807        }
     1808
     1809        if ( ! empty( $_site->archived ) ) {
     1810                $site_states['archived'] = __( 'Archived' );
     1811        }
     1812
     1813        if ( ! empty( $_site->mature ) ) {
     1814                $site_states['mature'] = __( 'Mature' );
     1815        }
     1816
     1817        if ( ! empty( $_site->spam ) ) {
     1818                $site_states['spam'] = _x( 'Spam', 'site' );
     1819        }
     1820
     1821        if ( ! empty( $_site->deleted ) ) {
     1822                $site_states['deleted'] = __( 'Deleted' );
     1823        }
     1824
     1825        /**
     1826         * Filter the default site display states for items in the Sites list table.
     1827         *
     1828         * @since 4.7.0
     1829         *
     1830         * @param array $site_states An array of site states. Default 'Main',
     1831         *                            'Archived', 'Mature', 'Spam', 'Deleted'.
     1832         */
     1833        $site_states = apply_filters( 'display_site_states', $site_states );
     1834
     1835        if ( ! empty( $site_states ) ) {
     1836                $state_count = count( $site_states );
     1837                $i = 0;
     1838                echo ' &mdash; ';
     1839                foreach ( $site_states as $state ) {
     1840                        ++$i;
     1841                        ( $i == $state_count ) ? $sep = '' : $sep = ', ';
     1842                        echo "<span class='post-state'>{$state}{$sep}</span>";
     1843                }
     1844        }
     1845}
     1846
     1847/**
    17961848 * Test support for compressing JavaScript from PHP
    17971849 *
    17981850 * Outputs JavaScript that tests if compression from PHP works as expected