Skip to content

Update latest-posts.php #5259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/wp-includes/blocks/latest-posts.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,16 @@ function render_block_core_latest_posts( $attributes ) {

$filter_latest_posts_excerpt_more = static function( $more ) use ( $attributes ) {
$use_excerpt = 'excerpt' === $attributes['displayPostContentRadio'];
/* translators: %1$s is a URL to a post, excerpt truncation character, default … */
return $use_excerpt ? sprintf( __( ' … <a href="%1$s" rel="noopener noreferrer">Read more</a>' ), esc_url( get_permalink() ) ) : $more;
if ( $use_excerpt ) {
/* translators: %1$s is a URL to a post, excerpt truncation character, default … */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* translators: %1$s is a URL to a post, excerpt truncation character, default … */

The translators comment is no longer needed as only 'Read more' is translated here, and it includes no tokens to be explained. 🙂

return sprintf(
' [&hellip;] <a href="%1$s" rel="noopener noreferrer">%2$s</a>',
esc_url( get_permalink() ),
__( 'Read more' )
);
} else {
return $more;
}
};

add_filter( 'excerpt_more', $filter_latest_posts_excerpt_more );
Expand Down