Skip to content
Permalink
Browse files

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.



git-svn-id: https://develop.svn.wordpress.org/trunk@46254 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
JJJ committed Sep 23, 2019
1 parent 83dd94f commit 1c69792253c0662b66c38bbed68e89cb3b39b7b4
Showing with 50 additions and 0 deletions.
  1. +50 −0 src/wp-admin/includes/class-wp-ms-sites-list-table.php
@@ -160,6 +160,12 @@ public function prepare_items() {
$args['no_found_rows'] = false;
}
// Take into account the role the user has selected.
$status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
if ( in_array( $status, array( 'public', 'archived', 'mature', 'spam', 'deleted' ), true ) ) {
$args[ $status ] = 1;
}
/**
* Filters the arguments for the site query in the sites list table.
*
@@ -201,6 +207,50 @@ public function no_items() {
_e( 'No sites found.' );
}
/**
* Gets links to filter sites by status.
*
* @since 5.3.0
*
* @return array
*
*/
protected function get_views() {
$counts = wp_count_sites();
$statuses = array(
'all' => _n_noop( 'All <span class="count">(%s)</span>', 'All <span class="count">(%1$s)</span>' ),
'public' => _n_noop( 'Public <span class="count">(%s)</span>', 'Public <span class="count">(%1$s)</span>' ),
'archived' => _n_noop( 'Archived <span class="count">(%1$s)</span>', 'Archived <span class="count">(%1$s)</span>' ),
'mature' => _n_noop( 'Mature <span class="count">(%1$s)</span>', 'Mature <span class="count">(%1$s)</span>' ),
'spam' => _n_noop( 'Spam <span class="count">(%1$s)</span>', 'Spam <span class="count">(%1$s)</span>' ),
'deleted' => _n_noop( 'Deleted <span class="count">(%1$s)</span>', 'Deleted <span class="count">(%1$s)</span>' ),
);
$view_links = array();
$requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
$url = 'sites.php';
foreach ( $statuses as $status => $label_count ) {
$current_link_attributes = $requested_status === $status || ( $requested_status === '' && 'all' === $status )
? ' class="current" aria-current="page"'
: '';
if ( (int) $counts[ $status ] > 0 ) {
$label = sprintf( translate_nooped_plural( $label_count, $counts[ $status ] ), number_format_i18n( $counts[ $status ] ) );
$full_url = 'all' === $status ? $url : add_query_arg( 'status', $status, $url );
$view_links[ $status ] = sprintf(
'<a href="%1$s"%2$s>%3$s</a>',
esc_url( $full_url ),
$current_link_attributes,
$label
);
}
}
return $view_links;
}
/**
* @return array
*/

0 comments on commit 1c69792

Please sign in to comment.
You can’t perform that action at this time.