Skip to content

Commit 3730d35

Browse files
committed
Widgets: Show post excerpts in On This Day widget if no title.
Match the behavior of posts in list tables by showing a short excerpt in the On This Day widget when the post does not have a saved title. Developed in WordPress/wordpress-develop#12581 Props alshakero, softglaze, iamraju, mirmpro, shailu25, bph, nazmulasif, wildworks, annezazu, mukesh27, peterwilsoncc, joedolson. Fixes #65658. Built from https://develop.svn.wordpress.org/trunk@62968 git-svn-id: http://core.svn.wordpress.org/trunk@62209 1a063a9b-81f0-0310-95a4-ce76da25c4cd
1 parent 95306e4 commit 3730d35

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎wp-admin/includes/dashboard-on-this-day.php‎

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,34 @@ function wp_dashboard_on_this_day() {
114114
<ul>
115115
<?php foreach ( $year_posts as $year_post ) : ?>
116116
<?php
117-
$title = get_the_title( $year_post );
117+
$title = get_the_title( $year_post );
118+
$no_title_excerpt = '';
118119

119120
if ( '' === trim( $title ) ) {
120121
$title = __( '(no title)' );
122+
123+
if ( current_user_can( 'read_post', $year_post->ID ) && ! post_password_required( $year_post ) ) {
124+
$excerpt = get_the_excerpt( $year_post );
125+
126+
if ( is_string( $excerpt ) && '' !== $excerpt ) {
127+
$no_title_excerpt = wp_trim_words( $excerpt, 15 );
128+
}
129+
}
121130
}
122131

123132
$author_id = (int) $year_post->post_author;
124133
$author_name = $author_id > 0 ? (string) get_the_author_meta( 'display_name', $author_id ) : '';
125134
$show_author = '' !== trim( $author_name ) && get_current_user_id() !== $author_id;
126135
?>
127136
<li>
128-
<a href="<?php echo esc_url( get_permalink( $year_post ) ); ?>"><?php echo esc_html( $title ); ?></a>
137+
<a href="<?php echo esc_url( get_permalink( $year_post ) ); ?>">
138+
<?php echo esc_html( $title ); ?>
139+
<?php
140+
if ( '' !== $no_title_excerpt ) {
141+
echo esc_html( $no_title_excerpt );
142+
}
143+
?>
144+
</a>
129145
<?php if ( $show_author ) : ?>
130146
<?php
131147
echo '<span class="wp-on-this-day-post-author">' . esc_html(

‎wp-includes/version.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
*
1717
* @global string $wp_version
1818
*/
19-
$wp_version = '7.1-beta4-62967';
19+
$wp_version = '7.1-beta4-62968';
2020

2121
/**
2222
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.

0 commit comments

Comments
 (0)