Renderer final class
Minn\Blocks\Renderer · public/minn/src/Minn/Blocks/Renderer.php · 449 lines
Renders a block tree the way the reference renders post_content: delimiters gone, each block's own HTML kept with inner blocks rendered in place, then the per-block render-time additions (layout classes, the paragraph class, image attributes, gallery ids, style-variation counters), and finally texturize over the whole.
Uses 35 (show)
Constants and properties
| private | CLASSNAME_ALWAYS = array ( 0 => 'core/query-pagination-next', 1 => 'core/query-pagination-numbers', 2 => 'core/query-pagination-previous', ) | The dynamic core blocks that ask block_default_classname even when they render nothing (generatedClass()). |
| private | CLASSNAME_NEVER = array ( 0 => 'core/rss', 1 => 'core/widget-group', 2 => 'core/tabs', 3 => 'core/tab-list', 4 => 'core/tab-panel', 5 => 'core/accordion', 6 => 'core/accordion-item', ) | The dynamic core blocks that never ask it (the tabs and accordion blocks edit their saved markup instead). |
| private | array $dynamic | |
| private | array $native | |
| private | bool $unfiltered | Whether the next block renders without the block filters around it (renderNativeUnfiltered()). |
| private | bool $asCallback | Whether the next block renders as its render callback called alone would (renderNativeAsCallback()). |
| private | mixed $imageFinish | |
| private | ?array $handed | |
| private | ?array $own | |
| private | array $provided | |
| private | Minn\Blocks\Context $context | |
| private | Minn\Blocks\RenderState $state | |
| private | readonly Minn\Blocks\ImageTags $images | Promoted from the constructor. |
Public
| new | __construct(Minn\Blocks\ImageTags $images)# | ||||
| static | numberedStyle(string $blockName, string $className): ?string# | The numbered companion of a block style variation the block's class names (is-style-{name}--N), consuming the counter: a variation with styles of its own, the theme's or a registered style's (the facade answers the private minn_block_style_variation filter), whose CSS the facade prints once numbered (minn_block_style_variation_used). Null when none applies. | |||
| method | state(): Minn\Blocks\RenderState# | The per-request rendering state: counters, containers, variations, the images seen. | |||
| method | context(): Minn\Blocks\Context# | What is being rendered. | |||
| method | withContext(Minn\Blocks\Context $context): void# | Sets what is being rendered. | |||
| method | images(): Minn\Blocks\ImageTags# | The image tag builder. | |||
| static | forDb(Minn\Db $db): self# | A renderer with every dynamic block wired over the database door. | |||
| method | registerDynamic(string $name, callable $render): void# | Registers the engine's own renderer for a dynamic block. A plugin's callback that already took the block over (bridge()) keeps it, as a replaced render callback does on the reference.
| |||
| method | bridge(string $name, callable $render): void# | Hands a block to a plugin's render callback; the engine's own renderer for it stays for renderNative().
| |||
| method | renderNative(Minn\Blocks\Block $block): string# | One block as HTML through the engine's own renderer for its name (its static markup when it has none), even where a plugin's callback took the block over: what a core render callback gives, so a plugin's callback that calls the one it replaced does not call itself. | |||
| method | render(string $markup): string# | Block markup as HTML, texturized. | |||
| method | renderBlocks(array $blocks): string# | A tree of blocks as HTML.
| |||
| method | renderNativeUnfiltered(Minn\Blocks\Block $block): string# | A core block as renderNative() renders it, without the block filters around this one block (its inner blocks keep theirs): its caller, the facade's WP_Block::render, applies them once. | |||
| method | renderNativeAsCallback(Minn\Blocks\Block $block): string# | A core block as its render callback called directly renders it: not a block being rendered, so enqueue_empty_block_content_assets is not asked for it (its inner blocks are), as the reference asks it only in a block's render (probe plugin-surface2). | |||
| method | finishImagesWith(callable $finish): void# | What the runtime does to an image block's markup once the engine has rendered it: the lightbox, when the image's settings or the theme's ask for one.
| |||
| method | handContext(array $context): void# | The context render_block_context already gave the next block, when render_block() or a WP_Block renders it: a block that provides its own context (a tabs block's id) reads it with ownContext() rather than asking again.
| |||
| method | ownContext(): ?array# | The context render_block_context gave the block that has just begun to render; null when nothing did. A block's renderer reads it first, before its inner blocks begin. @return array<string, mixed>|null | |||
| method | renderBlock(Minn\Blocks\Block $block): string# | One block as HTML, with the filters around it (unless renderNativeUnfiltered() asked for this one without). | |||
| method | blockContext(): array# | The context a block's bindings read: the post being rendered (postId, postType) and what enclosing blocks provide (a synced pattern's overrides). @return array<string, mixed> | |||
| method | providing(array $context, Closure $render): string# | Renders with context provided to the blocks inside (render_block_context's job on the reference). @param array<string, mixed> $context
| |||
| method | rendersNatively(string $name): bool# | Whether the engine's own renderer answers for a block: a core block no plugin's callback took over. It applies the block supports it knows itself (layout, element styles); the facade's render_block filters do the rest, and all of them for any other block. |
Internals 6
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | renderWith(string $name, ?callable $render): void# | ||||
| private | generatedClass(Minn\Blocks\Block $block, string $html): string# | A dynamic core block's own class through block_default_classname, as the reference asks it while the block takes its wrapper attributes: for a block that renders something (the query pagination links even when they do not; the RSS and widget-group blocks never), and a class a plugin changes replaces the block's on its wrapper. | |||
| private | elementsClass(Minn\Blocks\Block $block): ?string# | A core block's wp-elements-N class, its rules recorded, when the engine renders it itself. | |||
| private | renderNamed(Minn\Blocks\Block $block, array $bound = array ( )): string# |
| |||
| private | decorate(Minn\Blocks\Block $block, string $html, ?string $elements, ?string $numbered): string# | ||||
| private | gallery(): int# |
Nothing matches.