Changeset 61009 for trunk/src/wp-includes/blocks/post-excerpt.php
- Timestamp:
- 10/21/2025 07:11:53 AM (3 months ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/blocks/post-excerpt.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/post-excerpt.php
r58187 r61009 21 21 } 22 22 23 $more_text = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : ''; 24 $filter_excerpt_more = static function ( $more ) use ( $more_text ) { 25 return empty( $more_text ) ? $more : ''; 26 }; 27 /** 28 * Some themes might use `excerpt_more` filter to handle the 29 * `more` link displayed after a trimmed excerpt. Since the 30 * block has a `more text` attribute we have to check and 31 * override if needed the return value from this filter. 32 * So if the block's attribute is not empty override the 33 * `excerpt_more` filter and return nothing. This will 34 * result in showing only one `read more` link at a time. 35 * 36 * This hook needs to be applied before the excerpt is retrieved with get_the_excerpt. 37 * Otherwise, the read more link filter from the theme is not removed. 38 */ 39 add_filter( 'excerpt_more', $filter_excerpt_more ); 40 23 41 /* 24 42 * The purpose of the excerpt length setting is to limit the length of both … … 33 51 } 34 52 35 $more_text = ! empty( $attributes['moreText'] ) ? '<a class="wp-block-post-excerpt__more-link" href="' . esc_url( get_the_permalink( $block->context['postId'] ) ) . '">' . wp_kses_post( $attributes['moreText'] ) . '</a>' : '';36 $filter_excerpt_more = static function ( $more ) use ( $more_text ) {37 return empty( $more_text ) ? $more : '';38 };39 /**40 * Some themes might use `excerpt_more` filter to handle the41 * `more` link displayed after a trimmed excerpt. Since the42 * block has a `more text` attribute we have to check and43 * override if needed the return value from this filter.44 * So if the block's attribute is not empty override the45 * `excerpt_more` filter and return nothing. This will46 * result in showing only one `read more` link at a time.47 */48 add_filter( 'excerpt_more', $filter_excerpt_more );49 53 $classes = array(); 50 54 if ( isset( $attributes['textAlign'] ) ) {
Note: See TracChangeset
for help on using the changeset viewer.