Ticket #38071: 38071.patch
File 38071.patch, 7.0 KB (added by , 7 years ago) |
---|
-
src/wp-admin/includes/class-wp-ms-sites-list-table.php
diff --git src/wp-admin/includes/class-wp-ms-sites-list-table.php src/wp-admin/includes/class-wp-ms-sites-list-table.php old mode 100644 new mode 100755 index 9ce3ffe..987813c
157 157 $args['no_found_rows'] = false; 158 158 } 159 159 160 // Site status 161 if ( ! empty( $_REQUEST['site_status'] ) && in_array( $_REQUEST['site_status'], array_keys( $this->status_list ), true ) ) { 162 $args[ $_REQUEST['site_status'] ] = '1'; 163 } 164 160 165 /** 161 166 * Filters the arguments for the site query in the sites list table. 162 167 * … … 193 198 } 194 199 195 200 /** 201 * Determine if the current view is the "All" view. 202 * 203 * @since 4.7.0 204 * 205 * @return bool Whether the current view is the "All" view. 206 */ 207 protected function is_base_request() { 208 $vars = $_GET; 209 unset( $vars['paged'] ); 210 211 if ( empty( $vars ) ) { 212 return true; 213 } 214 215 return 1 === count( $vars ) && ! empty( $vars['mode'] ); 216 } 217 218 /** 219 * Helper to create links to sites.php with params. 220 * 221 * @since 4.7.0 222 * @access protected 223 * 224 * @param array $args URL parameters for the link. 225 * @param string $label Link text. 226 * @param string $class Optional. Class attribute. Default empty string. 227 * @return string The formatted link string. 228 */ 229 protected function get_edit_link( $args, $label, $class = '' ) { 230 $url = add_query_arg( $args, 'sites.php' ); 231 232 $class_html = ''; 233 if ( ! empty( $class ) ) { 234 $class_html = sprintf( 235 ' class="%s"', 236 esc_attr( $class ) 237 ); 238 } 239 240 return sprintf( 241 '<a href="%s"%s>%s</a>', 242 esc_url( $url ), 243 $class_html, 244 $label 245 ); 246 } 247 248 /** 249 * Return array of site status views 250 * 251 * @since 4.7.0 252 * 253 * @return array 254 */ 255 protected function get_views() { 256 257 $total_sites = get_blog_count(); 258 $counts = wp_count_sites(); 259 $status_links = array(); 260 261 // All sites 262 if ( empty( $class ) && ( $this->is_base_request() || isset( $_REQUEST['all_sites'] ) ) ) { 263 $class = 'current'; 264 } else { 265 $class = ''; 266 } 267 268 $all_inner_html = sprintf( 269 _nx( 270 'All <span class="count">(%s)</span>', 271 'All <span class="count">(%s)</span>', 272 $total_sites, 273 'sites' 274 ), 275 number_format_i18n( $total_sites ) 276 ); 277 278 $status_links['all'] = $this->get_edit_link( array(), $all_inner_html, $class ); 279 280 // Add public to available site statuses 281 $avail_site_stati = array_keys( $this->status_list ); 282 array_unshift( $avail_site_stati, 'public' ); 283 284 // Loop through statuses looking for counts 285 foreach ( $this->status_list as $status_key => $status ) { 286 $class = ''; 287 288 if ( ! in_array( $status_key, $avail_site_stati, true ) || empty( $counts->{$status_key} ) ) { 289 continue; 290 } 291 292 if ( isset( $_REQUEST['site_status'] ) && ( $status_key === $_REQUEST['site_status'] ) ) { 293 $class = 'current'; 294 } 295 296 $status_args = array( 297 'site_status' => $status_key, 298 ); 299 300 $status_label = sprintf( 301 sprintf( '%s <span class="count">(%s)</span>', $status[1], '%s' ), 302 number_format_i18n( $counts->$status_key ) 303 ); 304 305 $status_links[ $status_key ] = $this->get_edit_link( $status_args, $status_label, $class ); 306 } 307 308 return $status_links; 309 } 310 311 /** 196 312 * 197 313 * @return array 198 314 */ -
src/wp-admin/network/sites.php
diff --git src/wp-admin/network/sites.php src/wp-admin/network/sites.php index 38aa2ec..57fb011 100644
282 282 ?> 283 283 284 284 <div class="wrap"> 285 <h1><?php _e( 'Sites' ); ?> 285 <h1><?php _e( 'Sites' ); 286 if ( current_user_can( 'create_sites') ) : ?> 287 <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a> 288 <?php endif; 286 289 287 <?php if ( current_user_can( 'create_sites') ) : ?> 288 <a href="<?php echo network_admin_url('site-new.php'); ?>" class="page-title-action"><?php echo esc_html_x( 'Add New', 'site' ); ?></a> 289 <?php endif; ?> 290 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { 291 /* translators: %s: search keywords */ 292 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); 293 } ?> 294 </h1> 290 295 291 <?php 292 if ( isset( $_REQUEST['s'] ) && strlen( $_REQUEST['s'] ) ) { 293 /* translators: %s: search keywords */ 294 printf( '<span class="subtitle">' . __( 'Search results for “%s”' ) . '</span>', esc_html( $s ) ); 295 } ?> 296 </h1> 296 <?php echo $msg; ?> 297 297 298 <?php echo $msg; ?>298 <?php $wp_list_table->views(); ?> 299 299 300 <form method="get" id="ms-search">301 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?>302 <input type="hidden" name="action" value="blogs" />303 </form>300 <form method="get" id="ms-search"> 301 <?php $wp_list_table->search_box( __( 'Search Sites' ), 'site' ); ?> 302 <input type="hidden" name="action" value="blogs" /> 303 </form> 304 304 305 <form id="form-site-list" action="sites.php?action=allblogs" method="post">306 <?php $wp_list_table->display(); ?>307 </form>305 <form id="form-site-list" action="sites.php?action=allblogs" method="post"> 306 <?php $wp_list_table->display(); ?> 307 </form> 308 308 </div> 309 <?php310 309 311 require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?>310 <?php require_once( ABSPATH . 'wp-admin/admin-footer.php' ); ?> -
src/wp-includes/ms-functions.php
diff --git src/wp-includes/ms-functions.php src/wp-includes/ms-functions.php index 0d97ea7..f889f1a 100644
2267 2267 } 2268 2268 2269 2269 /** 2270 * Count number of sites of a site status. 2271 * 2272 * This function provides an efficient method of finding the amount of sites 2273 * 2274 * @since 2.5.0 2275 * 2276 * @global wpdb $wpdb WordPress database abstraction object. 2277 * 2278 * @return object Number of sites for each status. 2279 */ 2280 function wp_count_sites() { 2281 global $wpdb; 2282 2283 // Get network ID 2284 $network_id = get_current_network_id(); 2285 2286 // Bail if counts already cached 2287 $counts = wp_cache_get( "sites-{$network_id}", 'networks' ); 2288 if ( false !== $counts ) { 2289 return apply_filters( 'wp_count_sites', $counts ); 2290 } 2291 2292 // Query for site statuses 2293 $query = "SELECT public, archived, mature, spam, deleted FROM {$wpdb->blogs} WHERE site_id = %d"; 2294 $prepare = $wpdb->prepare( $query, $network_id ); 2295 $results = $wpdb->get_results( $prepare, ARRAY_A ); 2296 2297 // Populate counts 2298 $statuses = array( 'public', 'archived', 'mature', 'spam', 'deleted' ); 2299 $counts = array_fill_keys( $statuses, 0 ); 2300 foreach ( $results as $row ) { 2301 foreach ( $row as $status => $value ) { 2302 if ( ! empty( $value ) ) { 2303 ++$counts[ $status ]; 2304 } 2305 } 2306 } 2307 2308 // Objectify for caching 2309 $counts = (object) $counts; 2310 wp_cache_set( "sites-{$network_id}", $counts, 'networks' ); 2311 2312 /** 2313 * Modify returned site counts by status for the current network. 2314 * 2315 * @since 4.7.0 2316 * 2317 * @param object $counts An object containing the current network's site 2318 * counts by status. 2319 */ 2320 return apply_filters( 'wp_count_sites', $counts, $network_id ); 2321 } 2322 2323 /** 2270 2324 * Returns the space used by the current blog. 2271 2325 * 2272 2326 * @since 3.5.0