Network Admin: Allow Sites to have filterable States in List Table rows.
This change introduces a new `site_states()` method to the Sites List Table class (with a new `display_site_states` filter inside of it) following the pattern popularized in other List Table classes before it (Posts, Media, etc...) Fixes #37684. Props mnelson4, pbiron, jeremyfelt, johnjamesjacoby. Built from https://develop.svn.wordpress.org/trunk@46153 git-svn-id: http://core.svn.wordpress.org/trunk@45965 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
a1a5df805c
commit
757d077669
|
@ -314,30 +314,11 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
global $mode;
|
||||
|
||||
$blogname = untrailingslashit( $blog['domain'] . $blog['path'] );
|
||||
$blog_states = array();
|
||||
reset( $this->status_list );
|
||||
|
||||
foreach ( $this->status_list as $status => $col ) {
|
||||
if ( $blog[ $status ] == 1 ) {
|
||||
$blog_states[] = $col[1];
|
||||
}
|
||||
}
|
||||
$blog_state = '';
|
||||
if ( ! empty( $blog_states ) ) {
|
||||
$state_count = count( $blog_states );
|
||||
$i = 0;
|
||||
$blog_state .= ' — ';
|
||||
foreach ( $blog_states as $state ) {
|
||||
++$i;
|
||||
$sep = ( $i == $state_count ) ? '' : ', ';
|
||||
$blog_state .= "<span class='post-state'>$state$sep</span>";
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
<strong>
|
||||
<a href="<?php echo esc_url( network_admin_url( 'site-info.php?id=' . $blog['blog_id'] ) ); ?>" class="edit"><?php echo $blogname; ?></a>
|
||||
<?php echo $blog_state; ?>
|
||||
<?php $this->site_states( $blog ); ?>
|
||||
</strong>
|
||||
<?php
|
||||
if ( 'list' !== $mode ) {
|
||||
|
@ -494,6 +475,54 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Maybe output comma-separated site states.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*
|
||||
* @param array $site
|
||||
*/
|
||||
protected function site_states( $site ) {
|
||||
$site_states = array();
|
||||
|
||||
// $site is still an array, so get the object.
|
||||
$_site = WP_Site::get_instance( $site['blog_id'] );
|
||||
|
||||
if ( is_main_site( $_site->id ) ) {
|
||||
$site_states['main'] = __( 'Main' );
|
||||
}
|
||||
|
||||
reset( $this->status_list );
|
||||
|
||||
foreach ( $this->status_list as $status => $col ) {
|
||||
if ( $_site->{$status} == 1 ) {
|
||||
$site_states[ $col[0] ] = $col[1];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the default site display states for items in the Sites list table.
|
||||
*
|
||||
* @since 5.3.0
|
||||
*
|
||||
* @param array $site_states An array of site states. Default 'Main',
|
||||
* 'Archived', 'Mature', 'Spam', 'Deleted'.
|
||||
* @param WP_Site $site The current site object.
|
||||
*/
|
||||
$site_states = apply_filters( 'display_site_states', $site_states, $_site );
|
||||
|
||||
if ( ! empty( $site_states ) ) {
|
||||
$state_count = count( $site_states );
|
||||
$i = 0;
|
||||
echo ' — ';
|
||||
foreach ( $site_states as $state ) {
|
||||
++$i;
|
||||
( $i == $state_count ) ? $sep = '' : $sep = ', ';
|
||||
echo "<span class='post-state'>{$state}{$sep}</span>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the name of the default primary column.
|
||||
*
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.3-alpha-46152';
|
||||
$wp_version = '5.3-alpha-46153';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue