- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/post-excerpt.php
r55246 r56065 19 19 } 20 20 21 $excerpt = get_the_excerpt(); 22 23 if ( empty( $excerpt ) ) { 24 return ''; 21 /* 22 * The purpose of the excerpt length setting is to limit the length of both 23 * automatically generated and user-created excerpts. 24 * Because the excerpt_length filter only applies to auto generated excerpts, 25 * wp_trim_words is used instead. 26 */ 27 $excerpt_length = $attributes['excerptLength']; 28 $excerpt = get_the_excerpt( $block->context['postId'] ); 29 if ( isset( $excerpt_length ) ) { 30 $excerpt = wp_trim_words( $excerpt, $excerpt_length ); 25 31 } 26 32 27 33 $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>' : ''; 28 $filter_excerpt_more = function( $more ) use ( $more_text ) {34 $filter_excerpt_more = static function( $more ) use ( $more_text ) { 29 35 return empty( $more_text ) ? $more : ''; 30 36 }; … … 71 77 } 72 78 add_action( 'init', 'register_block_core_post_excerpt' ); 79 80 /** 81 * If themes or plugins filter the excerpt_length, we need to 82 * override the filter in the editor, otherwise 83 * the excerpt length block setting has no effect. 84 * Returns 100 because 100 is the max length in the setting. 85 */ 86 if ( is_admin() || 87 defined( 'REST_REQUEST' ) && REST_REQUEST ) { 88 add_filter( 89 'excerpt_length', 90 static function() { 91 return 100; 92 }, 93 PHP_INT_MAX 94 ); 95 }
Note: See TracChangeset
for help on using the changeset viewer.