Changeset 47408 for trunk/src/wp-includes/blocks/latest-posts.php
- Timestamp:
- 03/02/2020 11:19:06 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/latest-posts.php
r47250 r47408 7 7 8 8 /** 9 * The excerpt length set by the Latest Posts core block 10 * set at render time and used by the block itself. 11 * 12 * @var int 13 */ 14 $block_core_latest_posts_excerpt_length = 0; 15 16 /** 17 * Callback for the excerpt_length filter used by 18 * the Latest Posts block at render time. 19 * 20 * @return int Returns the global $block_core_latest_posts_excerpt_length variable 21 * to allow the excerpt_length filter respect the Latest Block setting. 22 */ 23 function block_core_latest_posts_get_excerpt_length() { 24 global $block_core_latest_posts_excerpt_length; 25 return $block_core_latest_posts_excerpt_length; 26 } 27 28 /** 9 29 * Renders the `core/latest-posts` block on server. 10 30 * … … 14 34 */ 15 35 function render_block_core_latest_posts( $attributes ) { 36 global $block_core_latest_posts_excerpt_length; 37 16 38 $args = array( 17 39 'posts_per_page' => $attributes['postsToShow'], … … 21 43 'suppress_filters' => false, 22 44 ); 45 46 $block_core_latest_posts_excerpt_length = $attributes['excerptLength']; 47 add_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 ); 23 48 24 49 if ( isset( $attributes['categories'] ) ) { … … 112 137 } 113 138 139 remove_filter( 'excerpt_length', 'block_core_latest_posts_get_excerpt_length', 20 ); 140 114 141 $class = 'wp-block-latest-posts wp-block-latest-posts__list'; 115 142 if ( isset( $attributes['align'] ) ) {
Note: See TracChangeset
for help on using the changeset viewer.