diff -r 3d4e9c994f10 -r a86126ab1dd4 wp/wp-admin/includes/dashboard.php --- a/wp/wp-admin/includes/dashboard.php Tue Oct 22 16:11:46 2019 +0200 +++ b/wp/wp-admin/includes/dashboard.php Tue Dec 15 13:49:49 2020 +0100 @@ -42,7 +42,21 @@ wp_add_dashboard_widget( 'dashboard_php_nag', __( 'PHP Update Required' ), 'wp_dashboard_php_nag' ); } - // Right Now + // Site Health. + if ( current_user_can( 'view_site_health_checks' ) && ! is_network_admin() ) { + if ( ! class_exists( 'WP_Site_Health' ) ) { + require_once ABSPATH . 'wp-admin/includes/class-wp-site-health.php'; + } + + WP_Site_Health::get_instance(); + + wp_enqueue_style( 'site-health' ); + wp_enqueue_script( 'site-health' ); + + wp_add_dashboard_widget( 'dashboard_site_health', __( 'Site Health Status' ), 'wp_dashboard_site_health' ); + } + + // Right Now. if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { wp_add_dashboard_widget( 'dashboard_right_now', __( 'At a Glance' ), 'wp_dashboard_right_now' ); } @@ -51,18 +65,18 @@ wp_add_dashboard_widget( 'network_dashboard_right_now', __( 'Right Now' ), 'wp_network_dashboard_right_now' ); } - // Activity Widget + // Activity Widget. if ( is_blog_admin() ) { wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); } - // QuickPress Widget + // QuickPress Widget. if ( is_blog_admin() && current_user_can( get_post_type_object( 'post' )->cap->create_posts ) ) { $quick_draft_title = sprintf( '%1$s %2$s', __( 'Quick Draft' ), __( 'Your Recent Drafts' ) ); wp_add_dashboard_widget( 'dashboard_quick_press', $quick_draft_title, 'wp_dashboard_quick_press' ); } - // WordPress Events and News + // WordPress Events and News. wp_add_dashboard_widget( 'dashboard_primary', __( 'WordPress Events and News' ), 'wp_dashboard_events_news' ); if ( is_network_admin() ) { @@ -123,9 +137,9 @@ wp_add_dashboard_widget( $widget_id, $name, $wp_registered_widgets[ $widget_id ]['callback'], $wp_registered_widget_controls[ $widget_id ]['callback'] ); } - if ( 'POST' == $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) { + if ( 'POST' === $_SERVER['REQUEST_METHOD'] && isset( $_POST['widget_id'] ) ) { check_admin_referer( 'edit-dashboard-widget_' . $_POST['widget_id'], 'dashboard-widget-nonce' ); - ob_start(); // hack - but the same hack wp-admin/widgets.php uses + ob_start(); // Hack - but the same hack wp-admin/widgets.php uses. wp_dashboard_trigger_widget_control( $_POST['widget_id'] ); ob_end_clean(); wp_redirect( remove_query_arg( 'edit' ) ); @@ -181,7 +195,7 @@ $side_widgets = array( 'dashboard_quick_press', 'dashboard_primary' ); $location = 'normal'; - if ( in_array( $widget_id, $side_widgets ) ) { + if ( in_array( $widget_id, $side_widgets, true ) ) { $location = 'side'; } @@ -249,7 +263,7 @@ } // -// Dashboard Widgets +// Dashboard Widgets. // /** @@ -264,13 +278,15 @@
@@ -409,12 +426,12 @@ $c_users = get_user_count(); $c_blogs = get_blog_count(); - /* translators: %s: number of users on the network */ + /* translators: %s: Number of users on the network. */ $user_text = sprintf( _n( '%s user', '%s users', $c_users ), number_format_i18n( $c_users ) ); - /* translators: %s: number of sites on the network */ + /* translators: %s: Number of sites on the network. */ $blog_text = sprintf( _n( '%s site', '%s sites', $c_blogs ), number_format_i18n( $c_blogs ) ); - /* translators: 1: text indicating the number of sites on the network, 2: text indicating the number of users on the network */ + /* translators: 1: Text indicating the number of sites on the network, 2: Text indicating the number of users on the network. */ $sentence = sprintf( __( 'You have %1$s and %2$s.' ), $blog_text, $user_text ); if ( $actions ) { @@ -489,21 +506,21 @@ } /* Check if a new auto-draft (= no new post_ID) is needed or if the old can be used */ - $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID + $last_post_id = (int) get_user_option( 'dashboard_quick_press_last_post_id' ); // Get the last post_ID. if ( $last_post_id ) { $post = get_post( $last_post_id ); - if ( empty( $post ) || $post->post_status != 'auto-draft' ) { // auto-draft doesn't exists anymore + if ( empty( $post ) || 'auto-draft' !== $post->post_status ) { // auto-draft doesn't exist anymore. $post = get_default_post_to_edit( 'post', true ); - update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + update_user_option( get_current_user_id(), 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID. } else { - $post->post_title = ''; // Remove the auto draft title + $post->post_title = ''; // Remove the auto draft title. } } else { $post = get_default_post_to_edit( 'post', true ); $user_id = get_current_user_id(); // Don't create an option if this is a super admin who does not belong to this site. - if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ) ) ) { - update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID + if ( in_array( get_current_blog_id(), array_keys( get_blogs_of_user( $user_id ) ), true ) ) { + update_user_option( $user_id, 'dashboard_quick_press_last_post_id', (int) $post->ID ); // Save post_ID. } } @@ -580,19 +597,33 @@ echo '
'; if ( count( $drafts ) > 3 ) { - echo '

' . __( 'View all drafts' ) . "

\n"; + printf( + '

%s

' . "\n", + esc_url( admin_url( 'edit.php?post_status=draft' ) ), + __( 'View all drafts' ) + ); } echo '

' . __( 'Your Recent Drafts' ) . "

\n