Gets links to filter sites by status.
Source
protected function get_views() {
$counts = wp_count_sites();
$statuses = array(
/* translators: %s: Number of sites. */
'all' => _nx_noop(
'All <span class="count">(%s)</span>',
'All <span class="count">(%s)</span>',
'sites'
),
/* translators: %s: Number of sites. */
'public' => _n_noop(
'Public <span class="count">(%s)</span>',
'Public <span class="count">(%s)</span>'
),
/* translators: %s: Number of sites. */
'archived' => _n_noop(
'Archived <span class="count">(%s)</span>',
'Archived <span class="count">(%s)</span>'
),
/* translators: %s: Number of sites. */
'mature' => _n_noop(
'Mature <span class="count">(%s)</span>',
'Mature <span class="count">(%s)</span>'
),
/* translators: %s: Number of sites. */
'spam' => _nx_noop(
'Spam <span class="count">(%s)</span>',
'Spam <span class="count">(%s)</span>',
'sites'
),
/* translators: %s: Number of sites. */
'deleted' => _n_noop(
'Deleted <span class="count">(%s)</span>',
'Deleted <span class="count">(%s)</span>'
),
);
$view_links = array();
$requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : '';
$url = 'sites.php';
foreach ( $statuses as $status => $label_count ) {
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 ] = array(
'url' => esc_url( $full_url ),
'label' => $label,
'current' => $requested_status === $status || ( '' === $requested_status && 'all' === $status ),
);
}
}
return $this->get_views_links( $view_links );
}
Changelog
Version | Description |
---|---|
5.3.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.