API / Minn\Blocks\Dynamic\Theme / QueryBlocks

QueryBlocks final class

Minn\Blocks\Dynamic\Theme\QueryBlocks · public/minn/src/Minn/Blocks/Dynamic/Theme/QueryBlocks.php · 283 lines

query, post-template, query-title, query-no-results, query-pagination, query-total.

Constants and properties

privatearray $queries
privatereadonly Minn\Content\Posts $posts

Promoted from the constructor.

privatereadonly Minn\Content\Site $site

Promoted from the constructor.

privatereadonly Minn\Front\Permalinks $permalinks

Promoted from the constructor.

Public

new__construct(Minn\Content\Posts $posts, Minn\Content\Site $site, Minn\Front\Permalinks $permalinks)#
methodregister(Minn\Blocks\Renderer $renderer): void#

Registers this family's blocks with the renderer.

Internals 13

Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.

privatequery(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#

The query wrapper is stored markup; the block sets the loop its children read.

privatequeried(Minn\Blocks\Block $block, array $attrs, int $page): Minn\Content\Page#

A query loop's posts as the reference finds them: the arguments build_query_vars_from_query_block makes of the block's query (through query_loop_block_query_vars) for the page its query-{id}-page asks for, run through WP_Query, so pre_get_posts and the posts_* filters shape it too.

$attrsarray<string, mixed>the block's query
privateloop(Minn\Blocks\Block $block, array $attrs, Minn\Blocks\Renderer $renderer): array#

A loop as the query block sets it: the main query's page when it inherits, else its own query for the page its query-{id}-page asks for.

$attrsarray<string, mixed>the block's query
@return array{page: Page, inherit: bool, paged: int, perPage: int}
privatecurrent(?Minn\Blocks\Renderer $renderer = NULL): array#

The innermost loop being rendered; outside one, the loop a block's context provides (a post template called by its render callback).

privatetotal(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#

How many posts the loop found, or which of them this page shows (displayType range-display).

privatepostTemplate(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privatepostClasses(Minn\Content\PostRecord $post, bool $sticky): array#
@return list<string>
privatequeryTitle(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privatenoResults(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#
privatepagination(Minn\Blocks\Block $block, Minn\Blocks\Renderer $renderer): string#

Pagination renders only when the loop it belongs to has more than one page.

privatepaginationBase(Minn\Blocks\Renderer $renderer): string#

The current listing's own URL, without a page number.

privatenumbers(int $paged, int $pages, callable $link): string#
$linkcallable(int): string
privatearchiveTitle(array $type): string#

A post type archive's title: the type's label, renamed by the post_type_archive_title filter when a plugin does.