| @@ -18,32 +18,20 @@ | ||
| 18 | 18 | if ( ! isset( $block->context['postId'] ) ) { |
| 19 | 19 | return ''; |
| 20 | 20 | } |
| 21 | 21 | |
| 22 | - $post_ID = $block->context['postId']; | |
| 23 | - $title = get_the_title(); | |
| 24 | - | |
| 25 | - if ( ! $title ) { | |
| 26 | - return ''; | |
| 27 | - } | |
| 28 | - | |
| 29 | 22 | $tag_name = 'h2'; |
| 30 | - $align_class_name = empty( $attributes['textAlign'] ) ? '' : "has-text-align-{$attributes['textAlign']}"; | |
| 23 | + $align_class_name = empty( $attributes['align'] ) ? '' : ' ' . "has-text-align-{$attributes['align']}"; | |
| 31 | 24 | |
| 32 | 25 | if ( isset( $attributes['level'] ) ) { |
| 33 | 26 | $tag_name = 0 === $attributes['level'] ? 'p' : 'h' . $attributes['level']; |
| 34 | 27 | } |
| 35 | 28 | |
| 36 | - if ( isset( $attributes['isLink'] ) && $attributes['isLink'] ) { | |
| 37 | - $title = sprintf( '<a href="%1$s" target="%2$s" rel="%3$s">%4$s</a>', get_the_permalink( $post_ID ), esc_attr( $attributes['linkTarget'] ), esc_attr( $attributes['rel'] ), $title ); | |
| 38 | - } | |
| 39 | - $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); | |
| 40 | - | |
| 41 | 29 | return sprintf( |
| 42 | - '<%1$s %2$s>%3$s</%1$s>', | |
| 30 | + '<%1$s class="%2$s">%3$s</%1$s>', | |
| 43 | 31 | $tag_name, |
| 44 | - $wrapper_attributes, | |
| 45 | - $title | |
| 32 | + 'wp-block-post-title' . esc_attr( $align_class_name ), | |
| 33 | + get_the_title( $block->context['postId'] ) | |
| 46 | 34 | ); |
| 47 | 35 | } |
| 48 | 36 | |
| 49 | 37 | /** |