WordPress.org

Make WordPress Core

Ticket #37684: 37684.diff

File 37684.diff, 2.2 KB (added by johnjamesjacoby, 4 years ago)

Add _site_states() to wp-admin/includes/template.php and use in Sites list-table

  • 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..7146931 100644
     
    326326                ?>
    327327                <a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname . $blog_state; ?></a>
    328328                <?php
     329
     330                _site_states( $blog );
     331
    329332                if ( 'list' !== $mode ) {
    330333                        switch_to_blog( $blog['blog_id'] );
    331334                        echo '<p>';
  • src/wp-admin/includes/template.php

    diff --git src/wp-admin/includes/template.php src/wp-admin/includes/template.php
    index 57478a1..f224bfb 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'] = __( 'Spam' );
     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