PATH:
home
/
sarkas88.com
/
public_html
/
wp-includes
/
blocks
<?php /** * Server-side rendering of the `core/term-template` block. * * @package WordPress */ /** * Renders the `core/term-template` block on the server. * * @since 6.9.0 * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. * * @return string Returns the output of the term template. */ function render_block_core_term_template( $attributes, $content, $block ) { if ( ! isset( $block->context ) || empty( $block->context['termQuery'] ) ) { return ''; } $query = $block->context['termQuery']; $query_args = array( 'number' => $query['perPage'], 'order' => $query['order'], 'orderby' => $query['orderBy'], 'hide_empty' => $query['hideEmpty'], ); $inherit_query = isset( $query['inherit'] ) && $query['inherit'] && ( is_tax() || is_category() || is_tag() ); if ( $inherit_query ) { // Get the current term and taxonomy from the queried object. $queried_object = get_queried_object(); // For hierarchical taxonomies, show children of the current term. // For non-hierarchical taxonomies, show all terms (don't set parent). if ( is_taxonomy_hierarchical( $queried_object->taxonomy ) ) { // If showNested is true, use child_of to include nested terms. // Otherwise, use parent to show only direct children. if ( ! empty( $query['showNested'] ) ) { $query_args['child_of'] = $queried_object->term_id; } else { $query_args['parent'] = $queried_object->term_id; } } $query_args['taxonomy'] = $queried_object->taxonomy; } else { // If not inheriting set `taxonomy` from the block attribute. $query_args['taxonomy'] = $query['taxonomy']; // If we are including specific terms we ignore `showNested` argument. if ( ! empty( $query['include'] ) ) { $query_args['include'] = array_unique( array_map( 'intval', $query['include'] ) ); $query_args['orderby'] = 'include'; $query_args['order'] = 'asc'; } elseif ( empty( $query['showNested'] ) ) { // We set parent only when inheriting from the taxonomy archive context or not // showing nested terms, otherwise nested terms are not displayed. $query_args['parent'] = 0; } } $terms_query = new WP_Term_Query( $query_args ); $terms = $terms_query->get_terms(); if ( ! $terms || is_wp_error( $terms ) ) { return ''; } $content = ''; foreach ( $terms as $term ) { // Get an instance of the current Term Template block. $block_instance = $block->parsed_block; // Set the block name to one that does not correspond to an existing registered block. // This ensures that for the inner instances of the Term Template block, we do not render any block supports. $block_instance['blockName'] = 'core/null'; $term_id = $term->term_id; $taxonomy = $term->taxonomy; $filter_block_context = static function ( $context ) use ( $term_id, $taxonomy ) { $context['termId'] = $term_id; $context['taxonomy'] = $taxonomy; return $context; }; // Use an early priority to so that other 'render_block_context' filters have access to the values. add_filter( 'render_block_context', $filter_block_context, 1 ); // Render the inner blocks of the Term Template block with `dynamic` set to `false` to prevent calling // `render_callback` and ensure that no wrapper markup is included. $block_content = ( new WP_Block( $block_instance ) )->render( array( 'dynamic' => false ) ); remove_filter( 'render_block_context', $filter_block_context, 1 ); // Wrap the render inner blocks in a `li` element with the appropriate term classes. $term_classes = "wp-block-term term-{$term->term_id} {$term->taxonomy} taxonomy-{$term->taxonomy}"; $content .= '<li class="' . esc_attr( $term_classes ) . '">' . $block_content . '</li>'; } $classnames = ''; if ( isset( $attributes['style']['elements']['link']['color']['text'] ) ) { $classnames .= 'has-link-color'; } $wrapper_attributes = get_block_wrapper_attributes( array( 'class' => trim( $classnames ) ) ); return sprintf( '<ul %s>%s</ul>', $wrapper_attributes, $content ); } /** * Registers the `core/term-template` block on the server. * * @since 6.9.0 */ function register_block_core_term_template() { register_block_type_from_metadata( __DIR__ . '/term-template', array( 'render_callback' => 'render_block_core_term_template', ) ); } add_action( 'init', 'register_block_core_term_template' );
[+]
..
[-] query-no-results.php
[open]
[-] calendar.php
[open]
[-] comments-pagination-numbers.php
[open]
[+]
paragraph
[+]
post-comments-count
[-] site-title.php
[open]
[+]
widget-group
[-] page-list-item.php
[open]
[+]
site-logo
[-] post-content.php
[open]
[+]
tag-cloud
[+]
categories
[+]
text-columns
[-] legacy-widget.php
[open]
[-] query-pagination-numbers.php
[open]
[-] image.php
[open]
[+]
more
[+]
spacer
[-] list.php
[open]
[+]
post-date
[-] post-comments-link.php
[open]
[+]
page-list-item
[+]
post-author-name
[+]
heading
[-] comments-pagination.php
[open]
[-] gallery.php
[open]
[-] accordion.php
[open]
[-] latest-comments.php
[open]
[+]
loginout
[-] home-link.php
[open]
[+]
query-no-results
[+]
site-title
[+]
math
[+]
post-title
[+]
read-more
[+]
latest-posts
[-] read-more.php
[open]
[-] post-comments-form.php
[open]
[-] page-list.php
[open]
[+]
table
[+]
comments-title
[+]
post-author
[+]
home-link
[+]
comment-author-name
[+]
post-terms
[+]
freeform
[+]
query-pagination-previous
[-] post-date.php
[open]
[+]
post-comments-link
[+]
comment-reply-link
[+]
columns
[+]
post-time-to-read
[+]
post-content
[-] comment-template.php
[open]
[+]
comments-pagination-previous
[-] pattern.php
[open]
[-] accordion-item.php
[open]
[-] site-logo.php
[open]
[-] comments-pagination-previous.php
[open]
[+]
details
[-] archives.php
[open]
[+]
terms-query
[+]
block
[-] widget-group.php
[open]
[+]
accordion-panel
[+]
list-item
[-] post-author.php
[open]
[-] term-name.php
[open]
[-] heading.php
[open]
[-] query-title.php
[open]
[-] latest-posts.php
[open]
[+]
latest-comments
[+]
nextpage
[-] search.php
[open]
[-] blocks-json.php
[open]
[+]
pattern
[-] query-pagination-next.php
[open]
[+]
pullquote
[-] site-tagline.php
[open]
[+]
gallery
[+]
code
[-] post-author-biography.php
[open]
[+]
list
[+]
file
[+]
post-comments-form
[-] navigation-submenu.php
[open]
[-] file.php
[open]
[+]
button
[+]
media-text
[+]
accordion
[-] button.php
[open]
[+]
term-template
[+]
preformatted
[+]
query-total
[+]
accordion-item
[-] index.php
[open]
[+]
legacy-widget
[-] media-text.php
[open]
[+]
image
[-] term-description.php
[open]
[+]
post-excerpt
[-] navigation.php
[open]
[+]
audio
[-] comment-content.php
[open]
[+]
quote
[-] tag-cloud.php
[open]
[-] query.php
[open]
[+]
post-author-biography
[-] avatar.php
[open]
[-] post-featured-image.php
[open]
[+]
comments
[+]
missing
[+]
query
[-] categories.php
[open]
[+]
shortcode
[+]
verse
[+]
comments-pagination-numbers
[-] social-link.php
[open]
[-] comment-date.php
[open]
[+]
social-link
[-] comments.php
[open]
[-] require-dynamic-blocks.php
[open]
[-] post-template.php
[open]
[+]
rss
[+]
comments-pagination-next
[-] comments-pagination-next.php
[open]
[+]
accordion-heading
[-] video.php
[open]
[+]
archives
[-] footnotes.php
[open]
[+]
post-navigation-link
[+]
html
[+]
comment-date
[-] block.php
[open]
[-] require-static-blocks.php
[open]
[+]
social-links
[+]
query-pagination-next
[-] term-template.php
[open]
[-] post-author-name.php
[open]
[+]
comment-edit-link
[+]
video
[-] navigation-link.php
[open]
[+]
term-count
[+]
query-pagination
[-] comment-edit-link.php
[open]
[+]
navigation-submenu
[-] post-title.php
[open]
[-] post-terms.php
[open]
[+]
column
[+]
post-featured-image
[-] template-part.php
[open]
[+]
navigation-link
[+]
comments-pagination
[-] post-time-to-read.php
[open]
[-] cover.php
[open]
[+]
query-pagination-numbers
[+]
embed
[+]
footnotes
[-] rss.php
[open]
[+]
comment-content
[+]
separator
[+]
cover
[-] comments-title.php
[open]
[+]
page-list
[+]
template-part
[-] comment-author-name.php
[open]
[-] term-count.php
[open]
[+]
term-name
[-] loginout.php
[open]
[+]
query-title
[-] post-navigation-link.php
[open]
[-] post-comments-count.php
[open]
[+]
site-tagline
[+]
navigation
[-] query-total.php
[open]
[+]
term-description
[+]
post-template
[-] post-excerpt.php
[open]
[-] query-pagination-previous.php
[open]
[+]
buttons
[+]
avatar
[+]
calendar
[-] query-pagination.php
[open]
[+]
group
[-] comment-reply-link.php
[open]
[-] shortcode.php
[open]
[+]
search
[+]
comment-template