Changeset 52042 for trunk/src/wp-includes/blocks/post-terms.php
- Timestamp:
- 11/08/2021 02:26:27 PM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/blocks/post-terms.php
r51362 r52042 24 24 25 25 $post_terms = get_the_terms( $block->context['postId'], $attributes['term'] ); 26 if ( is_wp_error( $post_terms ) ) { 27 return ''; 28 } 29 if ( empty( $post_terms ) ) { 26 if ( is_wp_error( $post_terms ) || empty( $post_terms ) ) { 30 27 return ''; 31 28 } 32 29 33 $align_class_name = empty( $attributes['textAlign'] ) ? '' : ' ' . "has-text-align-{$attributes['textAlign']}"; 30 $classes = 'taxonomy-' . $attributes['term']; 31 if ( isset( $attributes['textAlign'] ) ) { 32 $classes .= ' has-text-align-' . $attributes['textAlign']; 33 } 34 34 35 $terms_links = ''; 36 foreach ( $post_terms as $term ) { 37 $terms_links .= sprintf( 38 '<a href="%1$s">%2$s</a> | ', 39 get_term_link( $term->term_id ), 40 esc_html( $term->name ) 41 ); 42 } 43 $terms_links = trim( $terms_links, ' | ' ); 44 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $align_class_name ) ); 35 $separator = empty( $attributes['separator'] ) ? ' ' : $attributes['separator']; 45 36 46 return sprintf( 47 '<div %1$s>%2$s</div>', 48 $wrapper_attributes, 49 $terms_links 37 $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => $classes ) ); 38 39 return get_the_term_list( 40 $block->context['postId'], 41 $attributes['term'], 42 "<div $wrapper_attributes>", 43 '<span class="wp-block-post-terms__separator">' . $separator . '</span>', 44 '</div>' 50 45 ); 51 46 }
Note: See TracChangeset
for help on using the changeset viewer.