From c678ad965abe6ba2430c22a9b8cf3ce31fb490b4 Mon Sep 17 00:00:00 2001 From: Peter Wilson Date: Mon, 16 Nov 2026 07:47:45 +1100 Subject: [PATCH] =?UTF-8?q?Revert=20"Administration:=20Add=20a=20=E2=80=9D?= =?UTF-8?q?On=20This=20Day=E2=80=9D=20section=20to=20the=20Activity=20widg?= =?UTF-8?q?et"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit 051f9dcbd6c5365629ac6460359cdee86672c6f0. --- src/wp-admin/_index.php | 6 +- src/wp-admin/css/dashboard.css | 48 +- src/wp-admin/includes/dashboard.php | 254 +---------- .../tests/admin/wpDashboardSiteActivity.php | 413 ------------------ 4 files changed, 34 insertions(+), 687 deletions(-) delete mode 100644 tests/phpunit/tests/admin/wpDashboardSiteActivity.php diff --git a/src/wp-admin/_index.php b/src/wp-admin/_index.php index 4af8d0d66485b..de5cc21b8ff4f 100644 --- a/src/wp-admin/_index.php +++ b/src/wp-admin/_index.php @@ -86,11 +86,7 @@ $help .= '

' . __( 'At a Glance — Displays a summary of the content on your site and identifies which theme and version of WordPress you are using.' ) . '

'; } -$help .= '

' . __( 'Activity — Shows upcoming scheduled posts, recently published posts, and posts published on this day in previous years.' ) . '

'; - -if ( _wp_dashboard_has_received_comments() ) { - $help .= '

' . __( 'Recent Comments — Shows the most recent comments on your posts and allows you to moderate them.' ) . '

'; -} +$help .= '

' . __( 'Activity — Shows the upcoming scheduled posts, recently published posts, and the most recent comments on your posts and allows you to moderate them.' ) . '

'; if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) { $help .= '

' . __( "Quick Draft — Allows you to create a new post and save it as a draft. Also displays links to the 3 most recent draft posts you've started." ) . '

'; diff --git a/src/wp-admin/css/dashboard.css b/src/wp-admin/css/dashboard.css index 100c4df0a9633..c75eca12ee7be 100644 --- a/src/wp-admin/css/dashboard.css +++ b/src/wp-admin/css/dashboard.css @@ -879,7 +879,7 @@ body #dashboard-widgets .postbox form .submit { /* Dashboard activity widget */ -#dashboard_recent_comments .comment-meta span.approve::before { +#dashboard_activity .comment-meta span.approve::before { content: "\f227"; content: "\f227" / ""; font: 20px/0.5 dashicons; @@ -890,8 +890,7 @@ body #dashboard-widgets .postbox form .submit { margin-right: 2px; } -#dashboard_activity .inside, -#dashboard_recent_comments .inside { +#dashboard_activity .inside { margin: 0; padding: 0 12px; } @@ -907,27 +906,25 @@ body #dashboard-widgets .postbox form .submit { font-size: 16px; } -#dashboard_recent_comments .subsubsub { +#dashboard_activity .subsubsub { float: none; border-top: 1px solid #f0f0f1; margin: 0 -12px; padding: 8px 12px 4px; } -#dashboard_recent_comments .subsubsub a .count, -#dashboard_recent_comments .subsubsub a.current .count { +#dashboard_activity .subsubsub a .count, +#dashboard_activity .subsubsub a.current .count { color: #646970; /* white background on the dashboard but #f0f0f1 on list tables */ } #future-posts ul, -#published-posts ul, -#on-this-day-posts ul { +#published-posts ul { margin: 8px -12px 0 -12px; } #future-posts li, -#published-posts li, -#on-this-day-posts li { +#published-posts li { display: grid; grid-template-columns: clamp(160px, calc(2vw + 140px), 200px) auto; column-gap: 10px; @@ -936,15 +933,10 @@ body #dashboard-widgets .postbox form .submit { } #future-posts li:nth-child(odd), -#published-posts li:nth-child(odd), -#on-this-day-posts li:nth-child(odd) { +#published-posts li:nth-child(odd) { background-color: #f6f7f7; } -#on-this-day-posts .wp-on-this-day-post-author { - color: #646970; -} - .activity-block { border-bottom: 1px solid #f0f0f1; margin: 0 -12px 6px -12px; @@ -963,45 +955,45 @@ body #dashboard-widgets .postbox form .submit { /* Dashboard activity widget - Comments */ /* @todo: needs serious de-duplication */ -#dashboard_recent_comments #the-comment-list tr.undo, -#dashboard_recent_comments #the-comment-list div.undo { +#activity-widget #the-comment-list tr.undo, +#activity-widget #the-comment-list div.undo { background: none; padding: 6px 0; margin-left: 12px; } -#dashboard_recent_comments #the-comment-list .comment-item { +#activity-widget #the-comment-list .comment-item { background: #f6f7f7; padding: 12px; position: relative; } -#dashboard_recent_comments #the-comment-list .avatar { +#activity-widget #the-comment-list .avatar { position: absolute; top: 12px; } -#dashboard_recent_comments #the-comment-list .dashboard-comment-wrap.has-avatar { +#activity-widget #the-comment-list .dashboard-comment-wrap.has-avatar { padding-left: 63px; } -#dashboard_recent_comments #the-comment-list .dashboard-comment-wrap blockquote { +#activity-widget #the-comment-list .dashboard-comment-wrap blockquote { margin: 1em 0; } -#dashboard_recent_comments #the-comment-list .comment-item p.row-actions { +#activity-widget #the-comment-list .comment-item p.row-actions { margin: 4px 0 0; } -#dashboard_recent_comments #the-comment-list .comment-item:first-child { +#activity-widget #the-comment-list .comment-item:first-child { border-top: 1px solid #f0f0f1; } -#dashboard_recent_comments #the-comment-list .unapproved { +#activity-widget #the-comment-list .unapproved { background-color: #fcf9e8; } -#dashboard_recent_comments #the-comment-list .unapproved::before { +#activity-widget #the-comment-list .unapproved::before { content: ""; display: block; position: absolute; @@ -1012,8 +1004,8 @@ body #dashboard-widgets .postbox form .submit { width: 4px; } -#dashboard_recent_comments #the-comment-list .spam-undo-inside .avatar, -#dashboard_recent_comments #the-comment-list .trash-undo-inside .avatar { +#activity-widget #the-comment-list .spam-undo-inside .avatar, +#activity-widget #the-comment-list .trash-undo-inside .avatar { position: relative; top: 0; } diff --git a/src/wp-admin/includes/dashboard.php b/src/wp-admin/includes/dashboard.php index 9ba75b74bc4c2..05e6e24f6b0c6 100644 --- a/src/wp-admin/includes/dashboard.php +++ b/src/wp-admin/includes/dashboard.php @@ -6,33 +6,6 @@ * @subpackage Administration */ -/** - * Determines whether the site has ever received a comment. - * - * The result is persisted so the Recent Comments widget remains registered if - * all comments are later deleted, preserving its Screen Options and position. - * - * @since 7.2.0 - * @access private - * - * @return bool Whether the site has received a comment. - */ -function _wp_dashboard_has_received_comments() { - if ( get_option( 'dashboard_recent_comments_widget_registered' ) ) { - return true; - } - - $comment_count = wp_count_comments(); - - if ( empty( $comment_count->all ) ) { - return false; - } - - update_option( 'dashboard_recent_comments_widget_registered', 1, false ); - - return true; -} - /** * Registers dashboard widgets. * @@ -109,11 +82,6 @@ function wp_dashboard_setup() { wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' ); } - // Recent Comments Widget. - if ( is_blog_admin() && _wp_dashboard_has_received_comments() ) { - wp_add_dashboard_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments_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' ) ); @@ -975,14 +943,12 @@ function _wp_dashboard_recent_comments_row( &$comment, $show_date = true ) { * Callback function for {@see 'dashboard_activity'}. * * @since 3.8.0 - * @since 7.2.0 Added the On This Day section and moved Recent Comments to a dedicated widget. */ function wp_dashboard_site_activity() { echo '
'; - $on_this_day_posts = wp_dashboard_on_this_day_get_posts(); - $future_posts = wp_dashboard_recent_posts( + $future_posts = wp_dashboard_recent_posts( array( 'max' => 5, 'status' => 'future', @@ -991,20 +957,19 @@ function wp_dashboard_site_activity() { 'id' => 'future-posts', ) ); - $recent_posts = wp_dashboard_recent_posts( + $recent_posts = wp_dashboard_recent_posts( array( - 'max' => 5, - 'status' => 'publish', - 'order' => 'DESC', - 'title' => __( 'Recently Published' ), - 'id' => 'published-posts', - 'exclude' => wp_list_pluck( $on_this_day_posts, 'ID' ), + 'max' => 5, + 'status' => 'publish', + 'order' => 'DESC', + 'title' => __( 'Recently Published' ), + 'id' => 'published-posts', ) ); - $on_this_day_rendered = wp_dashboard_on_this_day( $on_this_day_posts ); + $recent_comments = wp_dashboard_recent_comments(); - if ( ! $future_posts && ! $recent_posts && ! $on_this_day_rendered ) { + if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) { echo '
'; echo '

' . __( 'No activity yet!' ) . '

'; echo '
'; @@ -1013,176 +978,6 @@ function wp_dashboard_site_activity() { echo '
'; } -/** - * Outputs the On This Day section of the Activity widget. - * - * @since 7.2.0 - * - * @param WP_Post[]|null $posts Optional. Posts to render. Defaults to querying for posts. - * @return bool False if no posts were found. True otherwise. - */ -function wp_dashboard_on_this_day( $posts = null ) { - if ( null === $posts ) { - $posts = wp_dashboard_on_this_day_get_posts(); - } - - if ( empty( $posts ) ) { - return false; - } - - echo '
'; - echo '

' . esc_html__( 'Published On This Day' ) . '

'; - echo ''; - echo '
'; - - return true; -} - -/** - * Retrieves posts published on this calendar day in previous years. - * - * Up to ten posts are returned by default. Use the - * {@see 'wp_dashboard_on_this_day_query_args'} filter to change the limit. - * Results are cached by WP_Query's native query caching. - * - * @since 7.2.0 - * - * @return WP_Post[] Array of posts ordered by newest first. - */ -function wp_dashboard_on_this_day_get_posts() { - $today = current_datetime(); - $year = (int) $today->format( 'Y' ); - - $args = array( - 'post_type' => 'post', - 'post_status' => array( 'publish' ), - 'posts_per_page' => 10, - 'ignore_sticky_posts' => true, - 'orderby' => 'date', - 'order' => 'DESC', - 'no_found_rows' => true, - 'update_post_term_cache' => false, - 'update_post_meta_cache' => false, - 'date_query' => array( - 'relation' => 'AND', - array( - 'before' => array( 'year' => $year ), - ), - _wp_dashboard_on_this_day_date_query_clause( $today ), - ), - ); - - /** - * Filters the arguments used to query posts for the On This Day section. - * - * @since 7.2.0 - * - * @param array $args WP_Query arguments. - */ - $args = apply_filters( 'wp_dashboard_on_this_day_query_args', $args ); - - $query = new WP_Query( $args ); - - return $query->posts; -} - -/** - * Builds the date query clause for today's anniversary date. - * - * On February 28 in a non-leap year, February 29 posts are included so - * leap-day anniversaries still appear. - * - * @since 7.2.0 - * @access private - * - * @param DateTimeInterface $date Date to build the clause for. - * @return array Date query clause. - */ -function _wp_dashboard_on_this_day_date_query_clause( $date ) { - $month = (int) $date->format( 'm' ); - $day = (int) $date->format( 'd' ); - $clause = array( - 'month' => $month, - 'day' => $day, - ); - - // Display leap day posts on February 28 in non-leap years. - if ( - 28 === $day - && 2 === $month - && false === (bool) $date->format( 'L' ) - ) { - $clause = array( - 'relation' => 'OR', - $clause, - array( - 'month' => 2, - 'day' => 29, - ), - ); - } - - return $clause; -} - /** * Generates Publishing Soon and Recently Published sections. * @@ -1196,7 +991,6 @@ function _wp_dashboard_on_this_day_date_query_clause( $date ) { * @type string $order Designates ascending ('ASC') or descending ('DESC') order. * @type string $title Section title. * @type string $id The container id. - * @type int[] $exclude Optional. Post IDs to exclude. * } * @return bool False if no posts were found. True otherwise. */ @@ -1212,10 +1006,6 @@ function wp_dashboard_recent_posts( $args ) { 'perm' => ( 'future' === $args['status'] ) ? 'editable' : 'readable', ); - if ( ! empty( $args['exclude'] ) ) { - $query_args['post__not_in'] = array_map( 'intval', $args['exclude'] ); - } - /** * Filters the query arguments used for the Recent Posts widget. * @@ -1287,29 +1077,14 @@ function wp_dashboard_recent_posts( $args ) { } /** - * Outputs the Recent Comments dashboard widget. - * - * Callback function for {@see 'dashboard_recent_comments'}. - * - * @since 7.2.0 - */ -function wp_dashboard_recent_comments_widget() { - if ( ! wp_dashboard_recent_comments( 5, false ) ) { - echo '

' . esc_html__( 'No comments to show.' ) . '

'; - } -} - -/** - * Outputs recent comments. + * Show Comments section. * * @since 3.8.0 - * @since 7.2.0 Moved from the Activity widget to a dedicated dashboard widget. * - * @param int $total_items Optional. Number of comments to query. Default 5. - * @param bool $show_title Optional. Whether to display the section title. Default true. + * @param int $total_items Optional. Number of comments to query. Default 5. * @return bool False if no comments were found. True otherwise. */ -function wp_dashboard_recent_comments( $total_items = 5, $show_title = true ) { +function wp_dashboard_recent_comments( $total_items = 5 ) { // Select all comment types and filter out spam later for better query performance. $comments = array(); @@ -1353,10 +1128,7 @@ function wp_dashboard_recent_comments( $total_items = 5, $show_title = true ) { if ( $comments ) { echo '
'; - - if ( $show_title ) { - echo '

' . esc_html__( 'Recent Comments' ) . '

'; - } + echo '

' . __( 'Recent Comments' ) . '

'; echo '