PATH:
home
/
hunkmedicalstaff
/
.trash
/
wp-includes
/
blocks
<?php /** * Server-side rendering of the `core/query-total` block. * * @package WordPress */ /** * Renders the `query-total` block on the server. * * @since 6.8.0 * * @global WP_Query $wp_query WordPress Query object. * * @param array $attributes Block attributes. * @param string $content Block default content. * @param WP_Block $block Block instance. * * @return string The rendered block content. */ function render_block_core_query_total( $attributes, $content, $block ) { global $wp_query; $wrapper_attributes = get_block_wrapper_attributes(); if ( isset( $block->context['query']['inherit'] ) && $block->context['query']['inherit'] ) { $query_to_use = $wp_query; $current_page = max( 1, (int) get_query_var( 'paged', 1 ) ); } else { $page_key = isset( $block->context['queryId'] ) ? 'query-' . $block->context['queryId'] . '-page' : 'query-page'; $current_page = isset( $_GET[ $page_key ] ) ? (int) $_GET[ $page_key ] : 1; $query_to_use = new WP_Query( build_query_vars_from_query_block( $block, $current_page ) ); } $max_rows = $query_to_use->found_posts; $posts_per_page = (int) $query_to_use->get( 'posts_per_page' ); // Calculate the range of posts being displayed. $start = ( 0 === $max_rows ) ? 0 : ( ( $current_page - 1 ) * $posts_per_page + 1 ); $end = min( $start + $posts_per_page - 1, $max_rows ); // Prepare the display based on the `displayType` attribute. $output = ''; switch ( $attributes['displayType'] ) { case 'range-display': if ( $start === $end ) { $output = sprintf( /* translators: 1: Start index of posts, 2: Total number of posts */ __( 'Displaying %1$s of %2$s' ), $start, $max_rows ); } else { $output = sprintf( /* translators: 1: Start index of posts, 2: End index of posts, 3: Total number of posts */ __( 'Displaying %1$s – %2$s of %3$s' ), $start, $end, $max_rows ); } break; case 'total-results': default: // translators: %d: number of results. $output = sprintf( _n( '%d result found', '%d results found', $max_rows ), $max_rows ); break; } return sprintf( '<div %1$s>%2$s</div>', $wrapper_attributes, $output ); } /** * Registers the `query-total` block. * * @since 6.8.0 */ function register_block_core_query_total() { register_block_type_from_metadata( __DIR__ . '/query-total', array( 'render_callback' => 'render_block_core_query_total', ) ); } add_action( 'init', 'register_block_core_query_total' );
[+]
freeform
[+]
page-list-item
[-] query-pagination-numbers.php
[edit]
[+]
comment-content
[+]
comments-title
[-] tag-cloud.php
[edit]
[-] query-pagination-previous.php
[edit]
[-] post-excerpt.php
[edit]
[-] index.php
[edit]
[-] widget-group.php
[edit]
[+]
post-comments-form
[+]
comment-author-name
[+]
template-part
[-] site-tagline.php
[edit]
[-] post-featured-image.php
[edit]
[-] comment-template.php
[edit]
[+]
widget-group
[+]
query-pagination-previous
[+]
block
[-] latest-posts.php
[edit]
[-] search.php
[edit]
[-] comments-pagination.php
[edit]
[+]
table
[-] navigation-submenu.php
[edit]
[-] post-navigation-link.php
[edit]
[+]
pattern
[+]
heading
[-] comment-content.php
[edit]
[+]
audio
[+]
paragraph
[+]
nextpage
[+]
tag-cloud
[+]
categories
[-] term-description.php
[edit]
[+]
image
[+]
query-pagination-numbers
[+]
post-author-biography
[+]
post-terms
[+]
navigation-submenu
[-] read-more.php
[edit]
[+]
site-tagline
[-] legacy-widget.php
[edit]
[-] page-list-item.php
[edit]
[-] query-title.php
[edit]
[-] categories.php
[edit]
[+]
list-item
[-] require-dynamic-blocks.php
[edit]
[+]
rss
[+]
html
[-] comments-pagination-numbers.php
[edit]
[+]
column
[+]
separator
[+]
quote
[+]
legacy-widget
[+]
code
[+]
comments
[+]
file
[+]
buttons
[-] image.php
[edit]
[-] cover.php
[edit]
[-] site-logo.php
[edit]
[+]
pullquote
[-] comments-pagination-next.php
[edit]
[-] query.php
[edit]
[+]
navigation-link
[+]
list
[+]
query-pagination-next
[-] comment-author-name.php
[edit]
[+]
comments-pagination
[-] post-comments-form.php
[edit]
[-] heading.php
[edit]
[-] post-date.php
[edit]
[+]
comments-pagination-next
[-] navigation.php
[edit]
[-] comments.php
[edit]
[+]
comments-pagination-numbers
[+]
preformatted
[-] query-pagination.php
[edit]
[-] loginout.php
[edit]
[+]
post-author-name
[+]
group
[-] template-part.php
[edit]
[-] home-link.php
[edit]
[+]
shortcode
[+]
query-title
[+]
latest-posts
[-] comment-reply-link.php
[edit]
[-] calendar.php
[edit]
[+]
comment-edit-link
[+]
video
[-] query-no-results.php
[edit]
[-] rss.php
[edit]
[-] comment-date.php
[edit]
[+]
query-total
[+]
post-featured-image
[+]
comments-pagination-previous
[+]
details
[+]
gallery
[+]
comment-template
[-] comments-pagination-previous.php
[edit]
[-] query-total.php
[edit]
[-] page-list.php
[edit]
[+]
read-more
[-] social-link.php
[edit]
[+]
post-excerpt
[-] post-author-biography.php
[edit]
[+]
post-template
[+]
post-title
[+]
navigation
[+]
..
[+]
button
[+]
query-pagination
[+]
post-author
[-] gallery.php
[edit]
[+]
page-list
[+]
post-date
[-] media-text.php
[edit]
[-] archives.php
[edit]
[-] footnotes.php
[edit]
[+]
spacer
[+]
latest-comments
[-] shortcode.php
[edit]
[-] navigation-link.php
[edit]
[+]
archives
[+]
columns
[+]
post-navigation-link
[-] site-title.php
[edit]
[-] require-static-blocks.php
[edit]
[+]
site-logo
[+]
loginout
[+]
search
[+]
term-description
[-] post-title.php
[edit]
[-] post-terms.php
[edit]
[+]
embed
[-] blocks-json.php
[edit]
[+]
more
[+]
media-text
[-] list.php
[edit]
[+]
cover
[+]
query-no-results
[+]
site-title
[+]
footnotes
[+]
missing
[+]
post-content
[-] comment-edit-link.php
[edit]
[+]
social-link
[+]
home-link
[-] post-content.php
[edit]
[-] post-author-name.php
[edit]
[-] post-author.php
[edit]
[+]
calendar
[-] avatar.php
[edit]
[-] pattern.php
[edit]
[-] query-pagination-next.php
[edit]
[-] file.php
[edit]
[+]
query
[+]
verse
[-] button.php
[edit]
[+]
avatar
[+]
comment-reply-link
[+]
text-columns
[+]
social-links
[+]
comment-date
[-] block.php
[edit]
[-] latest-comments.php
[edit]
[-] comments-title.php
[edit]
[-] post-template.php
[edit]