Make WordPress Core

Changeset 65732


Ignore:
Timestamp:
11/20/2026 09:17:39 PM (9 hours ago)
Author:
peterwilsoncc
Message:

Administration: Revert the On This Day section of the Activity widget.

The On This Day section of the Activity widget has been removed from the WordPress 7.2 release. This restores the Recent Comments section to the Activity widget and removes the dedicated Recent Comments dashboard widget.

This reverts r64593.

Reviewed by audrasjb.

Props annezazu.
See #65116.

Location:
trunk
Files:
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/_index.php

    r64593 r65732  
    8787}
    8888
    89 $help .= '<p>' . __( '<strong>Activity</strong> &mdash; Shows upcoming scheduled posts, recently published posts, and posts published on this day in previous years.' ) . '</p>';
    90 
    91 if ( _wp_dashboard_has_received_comments() ) {
    92         $help .= '<p>' . __( '<strong>Recent Comments</strong> &mdash; Shows the most recent comments on your posts and allows you to moderate them.' ) . '</p>';
    93 }
     89$help .= '<p>' . __( '<strong>Activity</strong> &mdash; Shows the upcoming scheduled posts, recently published posts, and the most recent comments on your posts and allows you to moderate them.' ) . '</p>';
    9490
    9591if ( is_blog_admin() && current_user_can( 'edit_posts' ) ) {
  • trunk/src/wp-admin/css/dashboard.css

    r64799 r65732  
    880880/* Dashboard activity widget */
    881881
    882 #dashboard_recent_comments .comment-meta span.approve::before {
     882#dashboard_activity .comment-meta span.approve::before {
    883883        content: "\f227";
    884884        content: "\f227" / "";
    … …  
    891891}
    892892
    893 #dashboard_activity .inside,
    894 #dashboard_recent_comments .inside {
     893#dashboard_activity .inside {
    895894        margin: 0;
    896895        padding: 0 12px;
    … …  
    908907}
    909908
    910 #dashboard_recent_comments .subsubsub {
     909#dashboard_activity .subsubsub {
    911910        float: none;
    912911        border-top: 1px solid #f0f0f1;
    … …  
    915914}
    916915
    917 #dashboard_recent_comments .subsubsub a .count,
    918 #dashboard_recent_comments .subsubsub a.current .count {
     916#dashboard_activity .subsubsub a .count,
     917#dashboard_activity .subsubsub a.current .count {
    919918        color: #646970; /* white background on the dashboard but #f0f0f1 on list tables */
    920919}
    921920
    922921#future-posts ul,
    923 #published-posts ul,
    924 #on-this-day-posts ul {
     922#published-posts ul {
    925923        margin: 8px -12px 0 -12px;
    926924}
    927925
    928926#future-posts li,
    929 #published-posts li,
    930 #on-this-day-posts li {
     927#published-posts li {
    931928        display: grid;
    932929        grid-template-columns: clamp(160px, calc(2vw + 140px), 200px) auto;
    … …  
    937934
    938935#future-posts li:nth-child(odd),
    939 #published-posts li:nth-child(odd),
    940 #on-this-day-posts li:nth-child(odd) {
     936#published-posts li:nth-child(odd) {
    941937        background-color: #f6f7f7;
    942 }
    943 
    944 #on-this-day-posts .wp-on-this-day-post-author {
    945         color: #646970;
    946938}
    947939
    … …  
    964956/* @todo: needs serious de-duplication */
    965957
    966 #dashboard_recent_comments #the-comment-list tr.undo,
    967 #dashboard_recent_comments #the-comment-list div.undo {
     958#activity-widget #the-comment-list tr.undo,
     959#activity-widget #the-comment-list div.undo {
    968960        background: none;
    969961        padding: 6px 0;
    … …  
    971963}
    972964
    973 #dashboard_recent_comments #the-comment-list .comment-item {
     965#activity-widget #the-comment-list .comment-item {
    974966        background: #f6f7f7;
    975967        padding: 12px;
    … …  
    977969}
    978970
    979 #dashboard_recent_comments #the-comment-list .avatar {
     971#activity-widget #the-comment-list .avatar {
    980972        position: absolute;
    981973        top: 12px;
    982974}
    983975
    984 #dashboard_recent_comments #the-comment-list .dashboard-comment-wrap.has-avatar {
     976#activity-widget #the-comment-list .dashboard-comment-wrap.has-avatar {
    985977        padding-left: 63px;
    986978}
    987979
    988 #dashboard_recent_comments #the-comment-list .dashboard-comment-wrap blockquote {
     980#activity-widget #the-comment-list .dashboard-comment-wrap blockquote {
    989981        margin: 1em 0;
    990982}
    991983
    992 #dashboard_recent_comments #the-comment-list .comment-item p.row-actions {
     984#activity-widget #the-comment-list .comment-item p.row-actions {
    993985        margin: 4px 0 0;
    994986}
    995987
    996 #dashboard_recent_comments #the-comment-list .comment-item:first-child {
     988#activity-widget #the-comment-list .comment-item:first-child {
    997989        border-top: 1px solid #f0f0f1;
    998990}
    999991
    1000 #dashboard_recent_comments #the-comment-list .unapproved {
     992#activity-widget #the-comment-list .unapproved {
    1001993        background-color: #fcf9e8;
    1002994}
    1003995
    1004 #dashboard_recent_comments #the-comment-list .unapproved::before {
     996#activity-widget #the-comment-list .unapproved::before {
    1005997        content: "";
    1006998        display: block;
    … …  
    10131005}
    10141006
    1015 #dashboard_recent_comments #the-comment-list .spam-undo-inside .avatar,
    1016 #dashboard_recent_comments #the-comment-list .trash-undo-inside .avatar {
     1007#activity-widget #the-comment-list .spam-undo-inside .avatar,
     1008#activity-widget #the-comment-list .trash-undo-inside .avatar {
    10171009        position: relative;
    10181010        top: 0;
  • trunk/src/wp-admin/includes/dashboard.php

    r65317 r65732  
    66 * @subpackage Administration
    77 */
    8 
    9 /**
    10  * Determines whether the site has ever received a comment.
    11  *
    12  * The result is persisted so the Recent Comments widget remains registered if
    13  * all comments are later deleted, preserving its Screen Options and position.
    14  *
    15  * @since 7.2.0
    16  * @access private
    17  *
    18  * @return bool Whether the site has received a comment.
    19  */
    20 function _wp_dashboard_has_received_comments() {
    21         if ( get_option( 'dashboard_recent_comments_widget_registered' ) ) {
    22                 return true;
    23         }
    24 
    25         $comment_count = wp_count_comments();
    26 
    27         if ( empty( $comment_count->all ) ) {
    28                 return false;
    29         }
    30 
    31         update_option( 'dashboard_recent_comments_widget_registered', 1, false );
    32 
    33         return true;
    34 }
    358
    369/**
    … …  
    10881        if ( is_blog_admin() ) {
    10982                wp_add_dashboard_widget( 'dashboard_activity', __( 'Activity' ), 'wp_dashboard_site_activity' );
    110         }
    111 
    112         // Recent Comments Widget.
    113         if ( is_blog_admin() && _wp_dashboard_has_received_comments() ) {
    114                 wp_add_dashboard_widget( 'dashboard_recent_comments', __( 'Recent Comments' ), 'wp_dashboard_recent_comments_widget' );
    11583        }
    11684
    … …  
    976944 *
    977945 * @since 3.8.0
    978  * @since 7.2.0 Added the On This Day section and moved Recent Comments to a dedicated widget.
    979946 */
    980947function wp_dashboard_site_activity() {
    … …  
    982949        echo '<div id="activity-widget">';
    983950
    984         $on_this_day_posts = wp_dashboard_on_this_day_get_posts();
    985         $future_posts      = wp_dashboard_recent_posts(
     951        $future_posts = wp_dashboard_recent_posts(
    986952                array(
    987953                        'max'    => 5,
    … …  
    992958                )
    993959        );
    994         $recent_posts      = wp_dashboard_recent_posts(
     960        $recent_posts = wp_dashboard_recent_posts(
    995961                array(
    996                         'max'     => 5,
    997                         'status'  => 'publish',
    998                         'order'   => 'DESC',
    999                         'title'   => __( 'Recently Published' ),
    1000                         'id'      => 'published-posts',
    1001                         'exclude' => wp_list_pluck( $on_this_day_posts, 'ID' ),
     962                        'max'    => 5,
     963                        'status' => 'publish',
     964                        'order'  => 'DESC',
     965                        'title'  => __( 'Recently Published' ),
     966                        'id'     => 'published-posts',
    1002967                )
    1003968        );
    1004969
    1005         $on_this_day_rendered = wp_dashboard_on_this_day( $on_this_day_posts );
    1006 
    1007         if ( ! $future_posts && ! $recent_posts && ! $on_this_day_rendered ) {
     970        $recent_comments = wp_dashboard_recent_comments();
     971
     972        if ( ! $future_posts && ! $recent_posts && ! $recent_comments ) {
    1008973                echo '<div class="no-activity">';
    1009974                echo '<p>' . __( 'No activity yet!' ) . '</p>';
    … …  
    1012977
    1013978        echo '</div>';
    1014 }
    1015 
    1016 /**
    1017  * Outputs the On This Day section of the Activity widget.
    1018  *
    1019  * @since 7.2.0
    1020  *
    1021  * @param WP_Post[]|null $posts Optional. Posts to render. Defaults to querying for posts.
    1022  * @return bool False if no posts were found. True otherwise.
    1023  */
    1024 function wp_dashboard_on_this_day( $posts = null ) {
    1025         if ( null === $posts ) {
    1026                 $posts = wp_dashboard_on_this_day_get_posts();
    1027         }
    1028 
    1029         if ( empty( $posts ) ) {
    1030                 return false;
    1031         }
    1032 
    1033         echo '<div id="on-this-day-posts" class="activity-block">';
    1034         echo '<h3>' . esc_html__( 'Published On This Day' ) . '</h3>';
    1035         echo '<ul>';
    1036 
    1037         foreach ( $posts as $post ) {
    1038                 /* translators: Date format for posts published in a previous year. */
    1039                 $date = get_the_date( __( 'M jS, Y' ), $post );
    1040 
    1041                 $title = get_the_title( $post );
    1042 
    1043                 if ( '' === trim( $title ) ) {
    1044                         $title = __( '(no title)' );
    1045 
    1046                         if ( current_user_can( 'read_post', $post->ID ) && ! post_password_required( $post ) ) {
    1047                                 $excerpt = get_the_excerpt( $post );
    1048 
    1049                                 if ( is_string( $excerpt ) && '' !== $excerpt ) {
    1050                                         $title .= ' ' . wp_trim_words( $excerpt, 15 );
    1051                                 }
    1052                         }
    1053                 }
    1054 
    1055                 $can_edit = current_user_can( 'edit_post', $post->ID );
    1056                 $link     = $can_edit ? get_edit_post_link( $post->ID ) : get_permalink( $post );
    1057 
    1058                 if ( $can_edit ) {
    1059                         /* translators: %s: Post title. */
    1060                         $aria_label = sprintf( __( 'Edit &#8220;%s&#8221;' ), $title );
    1061                 } else {
    1062                         /* translators: %s: Post title. */
    1063                         $aria_label = sprintf( __( 'View &#8220;%s&#8221;' ), $title );
    1064                 }
    1065 
    1066                 $author_id   = (int) $post->post_author;
    1067                 $author_name = $author_id > 0 ? (string) get_the_author_meta( 'display_name', $author_id ) : '';
    1068 
    1069                 printf(
    1070                         '<li><span>%1$s</span><span><a href="%2$s" aria-label="%3$s">%4$s</a>',
    1071                         esc_html( $date ),
    1072                         esc_url( $link ),
    1073                         esc_attr( $aria_label ),
    1074                         esc_html( $title )
    1075                 );
    1076 
    1077                 if ( '' !== trim( $author_name ) && get_current_user_id() !== $author_id ) {
    1078                         printf(
    1079                                 ' <span class="wp-on-this-day-post-author">%s</span>',
    1080                                 esc_html(
    1081                                         sprintf(
    1082                                                 /* translators: %s: Post author's display name. */
    1083                                                 __( 'by %s' ),
    1084                                                 $author_name
    1085                                         )
    1086                                 )
    1087                         );
    1088                 }
    1089 
    1090                 echo '</span></li>';
    1091         }
    1092 
    1093         echo '</ul>';
    1094         echo '</div>';
    1095 
    1096         return true;
    1097 }
    1098 
    1099 /**
    1100  * Retrieves posts published on this calendar day in previous years.
    1101  *
    1102  * Up to ten posts are returned by default. Use the
    1103  * {@see 'wp_dashboard_on_this_day_query_args'} filter to change the limit.
    1104  * Results are cached by WP_Query's native query caching.
    1105  *
    1106  * @since 7.2.0
    1107  *
    1108  * @return WP_Post[] Array of posts ordered by newest first.
    1109  */
    1110 function wp_dashboard_on_this_day_get_posts() {
    1111         $today = current_datetime();
    1112         $year  = (int) $today->format( 'Y' );
    1113 
    1114         $args = array(
    1115                 'post_type'              => 'post',
    1116                 'post_status'            => array( 'publish' ),
    1117                 'posts_per_page'         => 10,
    1118                 'ignore_sticky_posts'    => true,
    1119                 'orderby'                => 'date',
    1120                 'order'                  => 'DESC',
    1121                 'no_found_rows'          => true,
    1122                 'update_post_term_cache' => false,
    1123                 'update_post_meta_cache' => false,
    1124                 'date_query'             => array(
    1125                         'relation' => 'AND',
    1126                         array(
    1127                                 'before' => array( 'year' => $year ),
    1128                         ),
    1129                         _wp_dashboard_on_this_day_date_query_clause( $today ),
    1130                 ),
    1131         );
    1132 
    1133         /**
    1134          * Filters the arguments used to query posts for the On This Day section.
    1135          *
    1136          * @since 7.2.0
    1137          *
    1138          * @param array $args WP_Query arguments.
    1139          */
    1140         $args = apply_filters( 'wp_dashboard_on_this_day_query_args', $args );
    1141 
    1142         $query = new WP_Query( $args );
    1143 
    1144         return $query->posts;
    1145 }
    1146 
    1147 /**
    1148  * Builds the date query clause for today's anniversary date.
    1149  *
    1150  * On February 28 in a non-leap year, February 29 posts are included so
    1151  * leap-day anniversaries still appear.
    1152  *
    1153  * @since 7.2.0
    1154  * @access private
    1155  *
    1156  * @param DateTimeInterface $date Date to build the clause for.
    1157  * @return array Date query clause.
    1158  */
    1159 function _wp_dashboard_on_this_day_date_query_clause( $date ) {
    1160         $month  = (int) $date->format( 'm' );
    1161         $day    = (int) $date->format( 'd' );
    1162         $clause = array(
    1163                 'month' => $month,
    1164                 'day'   => $day,
    1165         );
    1166 
    1167         // Display leap day posts on February 28 in non-leap years.
    1168         if (
    1169                 28 === $day
    1170                 && 2 === $month
    1171                 && false === (bool) $date->format( 'L' )
    1172         ) {
    1173                 $clause = array(
    1174                         'relation' => 'OR',
    1175                         $clause,
    1176                         array(
    1177                                 'month' => 2,
    1178                                 'day'   => 29,
    1179                         ),
    1180                 );
    1181         }
    1182 
    1183         return $clause;
    1184979}
    1185980
    … …  
    1197992 *     @type string $title   Section title.
    1198993 *     @type string $id      The container id.
    1199  *     @type int[]  $exclude Optional. Post IDs to exclude.
    1200994 * }
    1201995 * @return bool False if no posts were found. True otherwise.
    … …  
    12121006                'perm'           => ( 'future' === $args['status'] ) ? 'editable' : 'readable',
    12131007        );
    1214 
    1215         if ( ! empty( $args['exclude'] ) ) {
    1216                 $query_args['post__not_in'] = array_map( 'intval', $args['exclude'] );
    1217         }
    12181008
    12191009        /**
    … …  
    12881078
    12891079/**
    1290  * Outputs the Recent Comments dashboard widget.
    1291  *
    1292  * Callback function for {@see 'dashboard_recent_comments'}.
    1293  *
    1294  * @since 7.2.0
    1295  */
    1296 function wp_dashboard_recent_comments_widget() {
    1297         if ( ! wp_dashboard_recent_comments( 5, false ) ) {
    1298                 echo '<p>' . esc_html__( 'No comments to show.' ) . '</p>';
    1299         }
    1300 }
    1301 
    1302 /**
    1303  * Outputs recent comments.
     1080 * Show Comments section.
    13041081 *
    13051082 * @since 3.8.0
    1306  * @since 7.2.0 Moved from the Activity widget to a dedicated dashboard widget.
    1307  *
    1308  * @param int  $total_items Optional. Number of comments to query. Default 5.
    1309  * @param bool $show_title  Optional. Whether to display the section title. Default true.
     1083 *
     1084 * @param int $total_items Optional. Number of comments to query. Default 5.
    13101085 * @return bool False if no comments were found. True otherwise.
    13111086 */
    1312 function wp_dashboard_recent_comments( $total_items = 5, $show_title = true ) {
     1087function wp_dashboard_recent_comments( $total_items = 5 ) {
    13131088        // Select all comment types and filter out spam later for better query performance.
    13141089        $comments = array();
    … …  
    13541129        if ( $comments ) {
    13551130                echo '<div id="latest-comments" class="activity-block table-view-list">';
    1356 
    1357                 if ( $show_title ) {
    1358                         echo '<h3>' . esc_html__( 'Recent Comments' ) . '</h3>';
    1359                 }
     1131                echo '<h3>' . __( 'Recent Comments' ) . '</h3>';
    13601132
    13611133                echo '<ul id="the-comment-list" data-wp-lists="list:comment">';
Note: See TracChangeset for help on using the changeset viewer.