Changeset 56808 for trunk/src/wp-includes/blocks/latest-posts.php
- Timestamp:
- 10/09/2023 05:21:30 PM (11 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/latest-posts.php
r56710 r56808 49 49 add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 ); 50 50 51 $filter_latest_posts_excerpt_more = static function ( $more ) use ( $attributes ) {52 $use_excerpt = 'excerpt' === $attributes['displayPostContentRadio'];53 /* translators: %1$s is a URL to a post, excerpt truncation character, default … */54 return $use_excerpt ? sprintf( __( ' … <a href="%1$s" rel="noopener noreferrer">Read more</a>' ), esc_url( get_permalink() ) ) : $more;55 };56 57 add_filter( 'excerpt_more', $filter_latest_posts_excerpt_more );58 59 51 if ( ! empty( $attributes['categories'] ) ) { 60 52 $args['category__in'] = array_column( $attributes['categories'], 'id' ); … … 151 143 152 144 $trimmed_excerpt = get_the_excerpt( $post ); 145 146 /* 147 * Adds a "Read more" link with screen reader text. 148 * […] is the default excerpt ending from wp_trim_excerpt() in Core. 149 */ 150 if ( str_ends_with( $trimmed_excerpt, ' […]' ) ) { 151 $excerpt_length = (int) apply_filters( 'excerpt_length', $block_core_latest_posts_excerpt_length ); 152 if ( $excerpt_length <= $block_core_latest_posts_excerpt_length ) { 153 $trimmed_excerpt = substr( $trimmed_excerpt, 0, -11 ); 154 $trimmed_excerpt .= sprintf( 155 /* translators: 1: A URL to a post, 2: The static string "Read more", 3: The post title only visible to screen readers. */ 156 __( '… <a href="%1$s" rel="noopener noreferrer">%2$s<span class="screen-reader-text">: %3$s</span></a>' ), 157 esc_url( $post_link ), 158 __( 'Read more' ), 159 esc_html( $title ) 160 ); 161 } 162 } 153 163 154 164 if ( post_password_required( $post ) ) {
Note: See TracChangeset
for help on using the changeset viewer.