Merged in feature/81-dev-dev01 (pull request #5)
auto-patch 81-dev-dev01-2023-12-05T22_45_26 * auto-patch 81-dev-dev01-2023-12-05T22_45_26
This commit is contained in:
@@ -48,15 +48,7 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
$block_core_latest_posts_excerpt_length = $attributes['excerptLength'];
|
||||
add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 );
|
||||
|
||||
$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;
|
||||
};
|
||||
|
||||
add_filter( 'excerpt_more', $filter_latest_posts_excerpt_more );
|
||||
|
||||
if ( isset( $attributes['categories'] ) ) {
|
||||
if ( ! empty( $attributes['categories'] ) ) {
|
||||
$args['category__in'] = array_column( $attributes['categories'], 'id' );
|
||||
}
|
||||
if ( isset( $attributes['selectedAuthor'] ) ) {
|
||||
@@ -151,6 +143,23 @@ function render_block_core_latest_posts( $attributes ) {
|
||||
|
||||
$trimmed_excerpt = get_the_excerpt( $post );
|
||||
|
||||
/*
|
||||
* Adds a "Read more" link with screen reader text.
|
||||
* […] is the default excerpt ending from wp_trim_excerpt() in Core.
|
||||
*/
|
||||
if ( str_ends_with( $trimmed_excerpt, ' […]' ) ) {
|
||||
$excerpt_length = (int) apply_filters( 'excerpt_length', $block_core_latest_posts_excerpt_length );
|
||||
if ( $excerpt_length <= $block_core_latest_posts_excerpt_length ) {
|
||||
$trimmed_excerpt = substr( $trimmed_excerpt, 0, -11 );
|
||||
$trimmed_excerpt .= sprintf(
|
||||
/* translators: 1: A URL to a post, 2: Hidden accessibility text: Post title */
|
||||
__( '… <a href="%1$s" rel="noopener noreferrer">Read more<span class="screen-reader-text">: %2$s</span></a>' ),
|
||||
esc_url( $post_link ),
|
||||
esc_html( $title )
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( post_password_required( $post ) ) {
|
||||
$trimmed_excerpt = __( 'This content is password protected.' );
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user