Ticket #37392: 37392.patch
File 37392.patch, 4.5 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/class-wp-ms-sites-list-table.php
commit b72a907a1473fe53c6fbe60245dda666358399ce Author: Mike Nelson <michael@eventespresso.com> Date: Tue Jan 23 19:53:21 2018 -0800 [touch:37392]adds links on the sites page to view public, spam, deleted sites, etc. Adds a function wp_count_sites() too which is used by the sites list table diff --git src/wp-admin/includes/class-wp-ms-sites-list-table.php src/wp-admin/includes/class-wp-ms-sites-list-table.php index 1741d51..2b1f259 100644
class WP_MS_Sites_List_Table extends WP_List_Table { 157 157 } else { 158 158 $args['no_found_rows'] = false; 159 159 } 160 //take into account the role the user has selected 161 $status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : ''; 162 if ( in_array( 163 $status, 164 array( 165 'public', 166 'archived', 167 'mature', 168 'spam', 169 'deletected', 170 ), 171 true 172 ) 173 ) { 174 $args[ $status ] = 1; 175 } 160 176 161 177 /** 162 178 * Filters the arguments for the site query in the sites list table. … … class WP_MS_Sites_List_Table extends WP_List_Table { 199 215 } 200 216 201 217 /** 218 * @since 4.9.3 219 * @return array 220 */ 221 protected function get_views() { 222 223 $counts = wp_count_sites(); 224 $slug_to_label = array( 225 'public' => esc_html__( 'Public' ), 226 'archived' => esc_html__( 'Archived' ), 227 'mature' => esc_html__( 'Mature' ), 228 'spam' => esc_html__( 'Spam' ), 229 'deleted' => esc_html__( 'Deleted' ), 230 ); 231 $view_links = array(); 232 $requested_status = isset( $_REQUEST['status'] ) ? wp_unslash( trim( $_REQUEST['status'] ) ) : ''; 233 $url = 'sites.php'; 234 $current_link_attributes = $requested_status === '' ? ' class="current" aria-current="page"' : ''; 235 $view_links['all'] = '<a href="' . $url . '" ' . $current_link_attributes . ' >' 236 . sprintf( 237 _nx( 238 'All <span class="count">(%s)</span>', 239 'All <span class="count">(%s)</span>', 240 $counts->all_blogs, 241 'sites' 242 ), 243 number_format_i18n( $counts->all_blogs ) 244 ) 245 . '</a>'; 246 foreach ( $slug_to_label as $this_status => $name ) { 247 $current_link_attributes = $requested_status == $this_status ? ' class="current" aria-current="page"' : ''; 248 if ( (int) $counts->{$this_status} > 0 ) { 249 $name = sprintf( 250 __( '%1$s <span class="count">(%2$s)</span>' ), 251 $name, 252 number_format_i18n( $counts->{$this_status} ) 253 ); 254 $view_links[ $this_status ] = '<a href="' 255 . esc_url( add_query_arg( 'status', $this_status, $url ) ) 256 . '"' 257 . $current_link_attributes 258 . '>' 259 . $name 260 . '</a>'; 261 } 262 } 263 264 return $view_links; 265 } 266 267 /** 202 268 * @return array 203 269 */ 204 270 protected function get_bulk_actions() { -
src/wp-admin/network/sites.php
diff --git src/wp-admin/network/sites.php src/wp-admin/network/sites.php index b5b55bd..322282e 100644
if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { 355 355 356 356 <hr class="wp-header-end"> 357 357 358 <?php $wp_list_table->views(); ?> 359 358 360 <?php echo $msg; ?> 359 361 360 362 <form method="get" id="ms-search"> -
src/wp-includes/ms-functions.php
diff --git src/wp-includes/ms-functions.php src/wp-includes/ms-functions.php index 984a69c..fa73d6f 100644
All at ###SITENAME### 2919 2919 ), $email_change_email['message'], $email_change_email['headers'] 2920 2920 ); 2921 2921 } 2922 2923 /** 2924 * Count number of sites who have each of the statuses. 2925 * 2926 * @since 4.9.3 2927 * @global wpdb $wpdb WordPress database abstraction object. 2928 * @return stdClass Includes a grand total 'all' and an array of counts indexed by status strings: public, archived, mature, 2929 * spam, deleted 2930 */ 2931 function wp_count_sites() { 2932 global $wpdb; 2933 2934 return $wpdb->get_row( 2935 ' 2936 SELECT 2937 COUNT(blog_id) AS all_blogs, 2938 COUNT(IF(public=1,blog_id,null)) AS public, 2939 COUNT(IF(archived=1, blog_id, null)) AS archived, 2940 COUNT(IF(mature=1, blog_id, null)) AS mature, 2941 COUNT(IF(spam=1, blog_id, null)) AS spam, 2942 COUNT(IF(deleted=1, blog_id, null)) AS deleted 2943 FROM wp_blogs' 2944 ); 2945 } 2946 No newline at end of file