← All changes
|
build/block-library/blocks/post-comments-count.php
+10
-6
12.6.0
→
8.5.1
View file →
| @@ -17,17 +17,16 @@ | ||
| 17 | 17 | if ( ! isset( $block->context['postId'] ) ) { |
| 18 | 18 | return ''; |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - $classes = ''; | |
| 22 | - if ( isset( $attributes['textAlign'] ) ) { | |
| 23 | - $classes .= 'has-text-align-' . $attributes['textAlign']; | |
| 21 | + $class = 'wp-block-post-comments-count'; | |
| 22 | + if ( isset( $attributes['className'] ) ) { | |
| 23 | + $class .= ' ' . $attributes['className']; | |
| 24 | 24 | } |
| 25 | 25 | |
| 26 | - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); | |
| 27 | 26 | return sprintf( |
| 28 | - '<div %1$s>%2$s</div>', | |
| 29 | - $wrapper_attributes, | |
| 27 | + '<span class="%1$s">%2$s</span>', | |
| 28 | + esc_attr( $class ), | |
| 30 | 29 | get_comments_number( $block->context['postId'] ) |
| 31 | 30 | ); |
| 32 | 31 | } |
| 33 | 32 | |
| @@ -37,8 +36,13 @@ | ||
| 37 | 36 | function gutenberg_register_block_core_post_comments_count() { |
| 38 | 37 | register_block_type_from_metadata( |
| 39 | 38 | __DIR__ . '/post-comments-count', |
| 40 | 39 | array( |
| 40 | + 'attributes' => array( | |
| 41 | + 'className' => array( | |
| 42 | + 'type' => 'string', | |
| 43 | + ), | |
| 44 | + ), | |
| 41 | 45 | 'render_callback' => 'gutenberg_render_block_core_post_comments_count', |
| 42 | 46 | ) |
| 43 | 47 | ); |
| 44 | 48 | } |