Skip to content

Commit

Permalink
Post terms: Wrap prefix & suffix in spans
Browse files Browse the repository at this point in the history
If the prefix or suffix attributes are provided, wrap them in spans with
a classname.

See #40559
  • Loading branch information
dsas authored and amustaque97 committed Apr 29, 2022
1 parent a7f8ac3 commit fea7dec
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions packages/block-library/src/post-terms/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,22 @@ function render_block_core_post_terms( $attributes, $content, $block ) {

$wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) );

$prefix = "<div $wrapper_attributes>";
if ( isset( $attributes['prefix'] ) && $attributes['prefix'] ) {
$prefix .= '<span class="wp-block-post-terms__prefix">' . $attributes['prefix'] . '</span>';
}

$suffix = '</div>';
if ( isset( $attributes['suffix'] ) && $attributes['suffix'] ) {
$suffix = '<span class="wp-block-post-terms__suffix">' . $attributes['suffix'] . $suffix;
}

return get_the_term_list(
$block->context['postId'],
$attributes['term'],
"<div $wrapper_attributes>" . ( isset( $attributes['prefix'] ) ? $attributes['prefix'] : '' ),
$prefix,
'<span class="wp-block-post-terms__separator">' . esc_html( $separator ) . '</span>',
( isset( $attributes['suffix'] ) ? $attributes['suffix'] : '' ) . '</div>'
$suffix
);
}

Expand Down

0 comments on commit fea7dec

Please sign in to comment.