is_taxonomy_viewable example


function is_term_publicly_viewable( $term ) {
    $term = get_term( $term );

    if ( ! $term ) {
        return false;
    }

    return is_taxonomy_viewable( $term->taxonomy );
}

/** * Sets the last changed time for the 'terms' cache group. * * @since 5.0.0 */
function wp_cache_set_terms_last_changed() {
    wp_cache_set_last_changed( 'terms' );
}

$tax_query[] = array(
                    'taxonomy'         => 'post_tag',
                    'terms'            => array_filter( array_map( 'intval', $block->context['query']['tagIds'] ) ),
                    'include_children' => false,
                );
            }
            $query['tax_query'] = $tax_query;
        }
        if ( ! empty( $block->context['query']['taxQuery'] ) ) {
            $query['tax_query'] = array();
            foreach ( $block->context['query']['taxQuery'] as $taxonomy => $terms ) {
                if ( is_taxonomy_viewable( $taxonomy ) && ! empty( $terms ) ) {
                    $query['tax_query'][] = array(
                        'taxonomy'         => $taxonomy,
                        'terms'            => array_filter( array_map( 'intval', $terms ) ),
                        'include_children' => false,
                    );
                }
            }
        }
        if (
            isset( $block->context['query']['order'] ) &&
                in_array( strtoupper( $block->context['query']['order'] ), array( 'ASC', 'DESC' ), true )
        )

function render_block_core_post_terms( $attributes$content$block ) {
    if ( ! isset( $block->context['postId'] ) || ! isset( $attributes['term'] ) ) {
        return '';
    }

    if ( ! is_taxonomy_viewable( $attributes['term'] ) ) {
        return '';
    }

    $post_terms = get_the_terms( $block->context['postId']$attributes['term'] );
    if ( is_wp_error( $post_terms ) || empty( $post_terms ) ) {
        return '';
    }

    $classes = array( 'taxonomy-' . $attributes['term'] );
    if ( isset( $attributes['textAlign'] ) ) {
        $classes[] = 'has-text-align-' . $attributes['textAlign'];
    }
Home | Imprint | This part of the site doesn't use cookies.