Changeset 47250 for trunk/src/wp-includes/blocks/latest-posts.php
- Timestamp:
- 02/10/2020 10:31:13 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/latest-posts.php
r46586 r47250 30 30 $list_items_markup = ''; 31 31 32 $excerpt_length = $attributes['excerptLength'];33 34 32 foreach ( $recent_posts as $post ) { 33 $list_items_markup .= '<li>'; 34 35 if ( $attributes['displayFeaturedImage'] && has_post_thumbnail( $post ) ) { 36 $image_style = ''; 37 if ( isset( $attributes['featuredImageSizeWidth'] ) ) { 38 $image_style .= sprintf( 'max-width:%spx;', $attributes['featuredImageSizeWidth'] ); 39 } 40 if ( isset( $attributes['featuredImageSizeHeight'] ) ) { 41 $image_style .= sprintf( 'max-height:%spx;', $attributes['featuredImageSizeHeight'] ); 42 } 43 44 $image_classes = 'wp-block-latest-posts__featured-image'; 45 if ( isset( $attributes['featuredImageAlign'] ) ) { 46 $image_classes .= ' align' . $attributes['featuredImageAlign']; 47 } 48 49 $list_items_markup .= sprintf( 50 '<div class="%1$s">%2$s</div>', 51 $image_classes, 52 get_the_post_thumbnail( 53 $post, 54 $attributes['featuredImageSizeSlug'], 55 array( 56 'style' => $image_style, 57 ) 58 ) 59 ); 60 } 61 35 62 $title = get_the_title( $post ); 36 63 if ( ! $title ) { … … 38 65 } 39 66 $list_items_markup .= sprintf( 40 '< li><a href="%1$s">%2$s</a>',67 '<a href="%1$s">%2$s</a>', 41 68 esc_url( get_permalink( $post ) ), 42 69 $title … … 53 80 if ( isset( $attributes['displayPostContent'] ) && $attributes['displayPostContent'] 54 81 && isset( $attributes['displayPostContentRadio'] ) && 'excerpt' === $attributes['displayPostContentRadio'] ) { 55 $post_excerpt = $post->post_excerpt; 56 if ( ! ( $post_excerpt ) ) { 57 $post_excerpt = $post->post_content; 58 } 59 $trimmed_excerpt = esc_html( wp_trim_words( $post_excerpt, $excerpt_length, ' … ' ) ); 82 83 $trimmed_excerpt = get_the_excerpt( $post ); 60 84 61 85 $list_items_markup .= sprintf( … … 170 194 'default' => 'date', 171 195 ), 196 'displayFeaturedImage' => array( 197 'type' => 'boolean', 198 'default' => false, 199 ), 200 'featuredImageAlign' => array( 201 'type' => 'string', 202 'enum' => array( 'left', 'center', 'right' ), 203 ), 204 'featuredImageSizeSlug' => array( 205 'type' => 'string', 206 'default' => 'thumbnail', 207 ), 208 'featuredImageSizeWidth' => array( 209 'type' => 'number', 210 'default' => null, 211 ), 212 'featuredImageSizeHeight' => array( 213 'type' => 'number', 214 'default' => null, 215 ), 172 216 ), 173 217 'render_callback' => 'render_block_core_latest_posts',
Note: See TracChangeset
for help on using the changeset viewer.