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
This commit is contained in:
parent
83dd94f3a8
commit
1c69792253
@ -160,6 +160,12 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
$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 @@ class WP_MS_Sites_List_Table extends WP_List_Table {
|
||||
_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
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user