WP_MS_Sites_List_Table::get_views() WordPress Method
The WP_MS_Sites_List_Table::get_views() method is a tool for displaying the number of sites on a WordPress Multisite network. This method is called by the WP_MS_Sites_List_Table::display() method, which is the default callback for the network_admin_manage_sites_action hook. The WP_MS_Sites_List_Table::get_views() method generates an array of HTML links, one for each view (e.g. All, Deleted, Spam), which are displayed as tabs at the top of the Sites list table. The active view is determined by the $which variable, which is set to 'all' by default.
WP_MS_Sites_List_Table::get_views() #
Gets links to filter sites by status.
Return
(array)
Source
File: wp-admin/includes/class-wp-ms-sites-list-table.php
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 ) { $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; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
5.3.0 | Introduced. |