diff --git a/src/wp-admin/includes/dashboard-on-this-day.php b/src/wp-admin/includes/dashboard-on-this-day.php index 1939f8ca4b0e3..1caa37057d08a 100644 --- a/src/wp-admin/includes/dashboard-on-this-day.php +++ b/src/wp-admin/includes/dashboard-on-this-day.php @@ -49,6 +49,33 @@ function wp_dashboard_on_this_day_postbox_classes( $classes ) { return $classes; } +/** + * Gets a trimmed excerpt to display in place of a missing post title. + * + * Only returns text for posts that have no title and do not require a password. + * + * @since 7.1.0 + * @access private + * + * @param WP_Post $post The current WP_Post object. + * @return string The trimmed excerpt, or an empty string. + */ +function _wp_dashboard_on_this_day_get_no_title_excerpt( $post ) { + if ( '' !== get_the_title( $post ) + || post_password_required( $post ) + ) { + return ''; + } + + $excerpt = get_the_excerpt( $post ); + + if ( '' === $excerpt || ! is_string( $excerpt ) ) { + return ''; + } + + return wp_trim_words( $excerpt, 15 ); +} + /** * Renders the On This Day dashboard widget. * @@ -114,10 +141,12 @@ function wp_dashboard_on_this_day() {