From b1e80f038880d2012090eceab53c81958d013adc Mon Sep 17 00:00:00 2001 From: Jeremy Felt Date: Wed, 27 May 2015 23:13:04 +0000 Subject: [PATCH] Use site objects rather than get_blog_status() in MS list tables. Removes several repetitive calls to `get_blog_status()` that are not needed, as the data is already available as part of each site's object. Fixes #32512. git-svn-id: https://develop.svn.wordpress.org/trunk@32630 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-ms-sites-list-table.php | 34 +++++++++++-------- .../includes/class-wp-ms-users-list-table.php | 12 ++++--- src/wp-includes/user.php | 2 ++ 3 files changed, 29 insertions(+), 19 deletions(-) diff --git a/src/wp-admin/includes/class-wp-ms-sites-list-table.php b/src/wp-admin/includes/class-wp-ms-sites-list-table.php index 0fa5b44210..0708791b35 100644 --- a/src/wp-admin/includes/class-wp-ms-sites-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-sites-list-table.php @@ -214,7 +214,7 @@ class WP_MS_Sites_List_Table extends WP_List_Table { $blog_states = array(); foreach ( $status_list as $status => $col ) { - if ( get_blog_status( $blog['blog_id'], $status ) == 1 ) { + if ( $blog[ $status ] == 1 ) { $class = " class='{$col[0]}'"; $blog_states[] = $col[1]; } @@ -283,23 +283,27 @@ class WP_MS_Sites_List_Table extends WP_List_Table { $actions['edit'] = '' . __( 'Edit' ) . ''; $actions['backend'] = "" . __( 'Dashboard' ) . ''; if ( get_current_site()->blog_id != $blog['blog_id'] ) { - if ( get_blog_status( $blog['blog_id'], 'deleted' ) == '1' ) - $actions['activate'] = '' . __( 'Activate' ) . ''; - else - $actions['deactivate'] = '' . __( 'Deactivate' ) . ''; + if ( $blog['deleted'] == '1' ) { + $actions['activate'] = '' . __( 'Activate' ) . ''; + } else { + $actions['deactivate'] = '' . __( 'Deactivate' ) . ''; + } - if ( get_blog_status( $blog['blog_id'], 'archived' ) == '1' ) - $actions['unarchive'] = '' . __( 'Unarchive' ) . ''; - else - $actions['archive'] = '' . _x( 'Archive', 'verb; site' ) . ''; + if ( $blog['archived'] == '1' ) { + $actions['unarchive'] = '' . __( 'Unarchive' ) . ''; + } else { + $actions['archive'] = '' . _x( 'Archive', 'verb; site' ) . ''; + } - if ( get_blog_status( $blog['blog_id'], 'spam' ) == '1' ) - $actions['unspam'] = '' . _x( 'Not Spam', 'site' ) . ''; - else - $actions['spam'] = '' . _x( 'Spam', 'site' ) . ''; + if ( $blog['spam'] == '1' ) { + $actions['unspam'] = '' . _x( 'Not Spam', 'site' ) . ''; + } else { + $actions['spam'] = '' . _x( 'Spam', 'site' ) . ''; + } - if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) - $actions['delete'] = '' . __( 'Delete' ) . ''; + if ( current_user_can( 'delete_site', $blog['blog_id'] ) ) { + $actions['delete'] = '' . __( 'Delete' ) . ''; + } } $actions['visit'] = "" . __( 'Visit' ) . ''; diff --git a/src/wp-admin/includes/class-wp-ms-users-list-table.php b/src/wp-admin/includes/class-wp-ms-users-list-table.php index e5eaeb5056..9ab485bf9e 100644 --- a/src/wp-admin/includes/class-wp-ms-users-list-table.php +++ b/src/wp-admin/includes/class-wp-ms-users-list-table.php @@ -252,14 +252,18 @@ class WP_MS_Users_List_Table extends WP_List_Table { $actions['edit'] = '' . __( 'Edit' ) . ''; $class = ''; - if ( get_blog_status( $val->userblog_id, 'spam' ) == 1 ) + if ( $val->spam == 1 ) { $class .= 'site-spammed '; - if ( get_blog_status( $val->userblog_id, 'mature' ) == 1 ) + } + if ( $val->mature == 1 ) { $class .= 'site-mature '; - if ( get_blog_status( $val->userblog_id, 'deleted' ) == 1 ) + } + if ( $val->deleted == 1 ) { $class .= 'site-deleted '; - if ( get_blog_status( $val->userblog_id, 'archived' ) == 1 ) + } + if ( $val->archived == 1 ) { $class .= 'site-archived '; + } $actions['view'] = '' . __( 'View' ) . ''; diff --git a/src/wp-includes/user.php b/src/wp-includes/user.php index 916fd52bab..bd1760b056 100644 --- a/src/wp-includes/user.php +++ b/src/wp-includes/user.php @@ -1176,6 +1176,7 @@ function get_blogs_of_user( $user_id, $all = false ) { 'site_id' => $blog->site_id, 'siteurl' => $blog->siteurl, 'archived' => $blog->archived, + 'mature' => $blog->mature, 'spam' => $blog->spam, 'deleted' => $blog->deleted, ); @@ -1205,6 +1206,7 @@ function get_blogs_of_user( $user_id, $all = false ) { 'site_id' => $blog->site_id, 'siteurl' => $blog->siteurl, 'archived' => $blog->archived, + 'mature' => $blog->mature, 'spam' => $blog->spam, 'deleted' => $blog->deleted, );