wp/wp-includes/blocks/post-terms.php
changeset 22 8c2e4d02f4ef
parent 21 48c4eec2b7e6
equal deleted inserted replaced
21:48c4eec2b7e6 22:8c2e4d02f4ef
    22 
    22 
    23 	if ( ! is_taxonomy_viewable( $attributes['term'] ) ) {
    23 	if ( ! is_taxonomy_viewable( $attributes['term'] ) ) {
    24 		return '';
    24 		return '';
    25 	}
    25 	}
    26 
    26 
    27 	$post_terms = get_the_terms( $block->context['postId'], $attributes['term'] );
       
    28 	if ( is_wp_error( $post_terms ) || empty( $post_terms ) ) {
       
    29 		return '';
       
    30 	}
       
    31 
       
    32 	$classes = array( 'taxonomy-' . $attributes['term'] );
    27 	$classes = array( 'taxonomy-' . $attributes['term'] );
    33 	if ( isset( $attributes['textAlign'] ) ) {
    28 	if ( isset( $attributes['textAlign'] ) ) {
    34 		$classes[] = 'has-text-align-' . $attributes['textAlign'];
    29 		$classes[] = 'has-text-align-' . $attributes['textAlign'];
    35 	}
    30 	}
    36 	if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
    31 	if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) {
    49 	$suffix = '</div>';
    44 	$suffix = '</div>';
    50 	if ( isset( $attributes['suffix'] ) && $attributes['suffix'] ) {
    45 	if ( isset( $attributes['suffix'] ) && $attributes['suffix'] ) {
    51 		$suffix = '<span class="wp-block-post-terms__suffix">' . $attributes['suffix'] . '</span>' . $suffix;
    46 		$suffix = '<span class="wp-block-post-terms__suffix">' . $attributes['suffix'] . '</span>' . $suffix;
    52 	}
    47 	}
    53 
    48 
    54 	return get_the_term_list(
    49 	$post_terms = get_the_term_list(
    55 		$block->context['postId'],
    50 		$block->context['postId'],
    56 		$attributes['term'],
    51 		$attributes['term'],
    57 		wp_kses_post( $prefix ),
    52 		wp_kses_post( $prefix ),
    58 		'<span class="wp-block-post-terms__separator">' . esc_html( $separator ) . '</span>',
    53 		'<span class="wp-block-post-terms__separator">' . esc_html( $separator ) . '</span>',
    59 		wp_kses_post( $suffix )
    54 		wp_kses_post( $suffix )
    60 	);
    55 	);
       
    56 
       
    57 	if ( is_wp_error( $post_terms ) || empty( $post_terms ) ) {
       
    58 		return '';
       
    59 	}
       
    60 
       
    61 	return $post_terms;
    61 }
    62 }
    62 
    63 
    63 /**
    64 /**
    64  * Returns the available variations for the `core/post-terms` block.
    65  * Returns the available variations for the `core/post-terms` block.
    65  *
    66  *