API / Minn\Runtime / BlockHooks

BlockHooks final class

Minn\Runtime\BlockHooks · public/minn/src/Minn/Runtime/BlockHooks.php · 69 lines

The Block Hooks API on the engine's own front end: a plugin asks for its block to be inserted next to an anchor block in a template part or a pattern (WooCommerce puts the mini-cart after the navigation in a header), and the markup the renderer reads carries those insertions.

The facade owns the traversal (wp-api/blocks.php); this is the seam the theme blocks call, and it stays inert until a plugin actually hooks something, so a site without such a plugin parses nothing extra.

Uses 1

Public

staticactive(): bool#

Whether block hooks are registered (the runtime's functions are there only once it is up).

staticforPart(string $markup, string $slug, string $area): string#

A template part's markup with its hooked blocks inserted. The context is the part itself: a plugin reads its area to tell a header from a footer, and its content to see whether its block is already there.

staticregisteredPattern(string $slug): ?string#

A plugin-registered pattern's content, hooks already applied by the registry, for a slug the theme does not carry. Null when the runtime is not up or nothing registered that name.

staticforPattern(string $markup, string $slug, array $blockTypes, array $categories): string#

A theme pattern's markup with its hooked blocks inserted, with the pattern array as the context (blockTypes and categories are how a plugin recognises a header pattern).

$blockTypeslist<string>
$categorieslist<string>