7.4.33 | Linux x86_64
Server128.199.10.0
Userwww-data (uid:33)
PHP7.4.33 (apache2handler)
Terminal
Upload
Files: /var/www/html/wp-includes/blocks
View: term-template.php
<?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 ( is_taxonomy_hierarchical( $query['taxonomy'] ) && 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' );
NameSizeActions
accordion/--
accordion-heading/--
accordion-item/--
accordion-item.php3KView Edit Del
accordion-panel/--
accordion.php1.1KView Edit Del
archives/--
archives.php4.3KView Edit Del
audio/--
avatar/--
avatar.php5.5KView Edit Del
block/--
block.php4.1KView Edit Del
blocks-json.php194.5KView Edit Del
breadcrumbs/--
breadcrumbs.php18.6KView Edit Del
button/--
button.php1.7KView Edit Del
buttons/--
calendar/--
calendar.php5.9KView Edit Del
categories/--
categories.php4.8KView Edit Del
code/--
column/--
columns/--
comment-author-name/--
comment-author-name.php2.1KView Edit Del
comment-content/--
comment-content.php2.4KView Edit Del
comment-date/--
comment-date.php1.8KView Edit Del
comment-edit-link/--
comment-edit-link.php1.7KView Edit Del
comment-reply-link/--
comment-reply-link.php2KView Edit Del
comment-template/--
comment-template.php4.4KView Edit Del
comments/--
comments-pagination/--
comments-pagination-next/--
comments-pagination-next.php1.9KView Edit Del
comments-pagination-numbers/--
comments-pagination-numbers.php1.6KView Edit Del
comments-pagination-previous/--
comments-pagination-previous.php1.7KView Edit Del
comments-pagination.php1.2KView Edit Del
comments-title/--
comments-title.php2.7KView Edit Del
comments.php6.6KView Edit Del
cover/--
cover.php7.2KView Edit Del
details/--
details.php1.5KView Edit Del
embed/--
file/--
file.php1.8KView Edit Del
footnotes/--
footnotes.php3.7KView Edit Del
freeform/--
gallery/--
gallery.php8.9KView Edit Del
group/--
heading/--
heading.php1.3KView Edit Del
home-link/--
home-link.php5.3KView Edit Del
html/--
icon/--
icon.php4KView Edit Del
image/--
image.php17.2KView Edit Del
index.php5KView Edit Del
latest-comments/--
latest-comments.php5.4KView Edit Del
latest-posts/--
latest-posts.php8.6KView Edit Del
legacy-widget/--
legacy-widget.php3.9KView Edit Del
list/--
list-item/--
list.php1.2KView Edit Del
loginout/--
loginout.php1.6KView Edit Del
math/--
media-text/--
media-text.php4.2KView Edit Del
missing/--
more/--
navigation/--
navigation-link/--
navigation-link.php15.8KView Edit Del
navigation-overlay-close/--
navigation-overlay-close.php1.7KView Edit Del
navigation-submenu/--
navigation-submenu.php11.5KView Edit Del
navigation.php63.3KView Edit Del
nextpage/--
page-list/--
page-list-item/--
page-list-item.php361BView Edit Del
page-list.php14.7KView Edit Del
paragraph/--
paragraph.php1.1KView Edit Del
pattern/--
pattern.php1.7KView Edit Del
post-author/--
post-author-biography/--
post-author-biography.php1.5KView Edit Del
post-author-name/--
post-author-name.php1.9KView Edit Del
post-author.php2.7KView Edit Del
post-comments-count/--
post-comments-count.php1.2KView Edit Del
post-comments-form/--
post-comments-form.php2.7KView Edit Del
post-comments-link/--
post-comments-link.php2.2KView Edit Del
post-content/--
post-content.php2.3KView Edit Del
post-date/--
post-date.php3.6KView Edit Del
post-excerpt/--
post-excerpt.php4.2KView Edit Del
post-featured-image/--
post-featured-image.php9KView Edit Del
post-navigation-link/--
post-navigation-link.php4.7KView Edit Del
post-template/--
post-template.php5.6KView Edit Del
post-terms/--
post-terms.php3.6KView Edit Del
post-time-to-read/--
post-time-to-read.php6.3KView Edit Del
post-title/--
post-title.php2.1KView Edit Del
preformatted/--
pullquote/--
query/--
query-no-results/--
query-no-results.php1.8KView Edit Del
query-pagination/--
query-pagination-next/--
query-pagination-next.php3.6KView Edit Del
query-pagination-numbers/--
query-pagination-numbers.php4.6KView Edit Del
query-pagination-previous/--
query-pagination-previous.php3.4KView Edit Del
query-pagination.php1.1KView Edit Del
query-title/--
query-title.php2.7KView Edit Del
query-total/--
query-total.php2.4KView Edit Del
query.php5.6KView Edit Del
quote/--
read-more/--
read-more.php1.8KView Edit Del
require-dynamic-blocks.php4.9KView Edit Del
require-static-blocks.php520BView Edit Del
rss/--
rss.php4.5KView Edit Del
search/--
search.php23.3KView Edit Del
separator/--
shortcode/--
shortcode.php735BView Edit Del
site-logo/--
site-logo.php6.2KView Edit Del
site-tagline/--
site-tagline.php1.2KView Edit Del
site-title/--
site-title.php1.8KView Edit Del
social-link/--
social-link.php66KView Edit Del
social-links/--
spacer/--
table/--
tag-cloud/--
tag-cloud.php1.6KView Edit Del
template-part/--
template-part.php10.2KView Edit Del
term-count/--
term-count.php1.8KView Edit Del
term-description/--
term-description.php1.7KView Edit Del
term-name/--
term-name.php2KView Edit Del
term-template/--
term-template.php4.4KView Edit Del
terms-query/--
text-columns/--
verse/--
video/--
video.php2.7KView Edit Del
widget-group/--
widget-group.php2.4KView Edit Del