BlockFilters final class
Minn\Runtime\BlockFilters · public/minn/src/Minn/Runtime/BlockFilters.php · 188 lines
The block-level filters plugin code hooks (pre_render_block, render_block_data, render_block, render_block_{name}), applied around the engine's own renderer so a plugin sees every block the page renders, not only the ones it registered.
Constants and properties
| const | NATIVE_DATA_DONE = array ( 'block_core_gallery_data_id_backcompatibility' => 10, ) | The data filters the engine's renderer does itself for a block it renders natively: a gallery's image ids. Element styles and style variations are left to their own filters, which name the classes in the block's className as plugins' later filters read it (probe block-class-stages). |
| const | NATIVE_RENDER_DONE = array ( ) | The render filters it does itself: none. The element, layout, style variation and paragraph classes reach the markup at their own filters, as a plugin's earlier filters see it without them (probe block-class-stages). |
| private | static array $parsedFor | |
| private | static array $begun |
Public
| static | active(): bool# | Whether any block filter is registered. | |||||||||
| static | toArray(Minn\Blocks\Block $block): array# | A block as the parsed array plugins receive. @return array<string, mixed> the parsed-array shape plugin code reads | |||||||||
| static | fromArray(array $parsed): Minn\Blocks\Block# | A block from the parsed array plugins hand back. | |||||||||
| static | data(array $parsed, ?object $parent, array $done = array ( )): mixed# | A parsed block through render_block_data, without the callbacks done already (NATIVE_DATA_DONE for a block the engine's renderer renders).
| |||||||||
| static | rendered(string $html, array $parsed, ?object $instance, array $done = array ( )): string# | A rendered block through render_block and its per-name filter, without the callbacks done already (NATIVE_RENDER_DONE, with its stand-ins, for a block the engine's renderer renders).
| |||||||||
| static | before(Minn\Blocks\Block $block, ?Minn\Objects\RenderedBlock $parent, array $done = array ( )): Minn\Blocks\Block|string# | A block about to render, begun as the reference begins it (probe block-instances): one with no parent block (a document's, a part's, a pattern's) is asked pre_render_block, render_block_data and render_block_context with none, then made a WP_Block with the post's context; an inner one is made a WP_Block from what its parent gives its inner blocks first (its type asked get_block_type_uses_context), then asked the three with its parent (the context filter handed the context its type uses), and adopts what they made of it. A short-circuit from pre_render_block, or the block as render_block_data left it.
| |||||||||
| static | made(Minn\Blocks\Block $block, ?Minn\Objects\RenderedBlock $parent): Minn\Blocks\Block# | A block begun as the reference's block list makes one its parent renders without asking the block filters first (a navigation's own items): its WP_Block, with what the parent gives its inner blocks. | |||||||||
| static | begun(Minn\Blocks\Block $block): array# | The WP_Block a block began as and the context render_block_context gave it. @return array{0: RenderedBlock|null, 1: array<string, mixed>|null} | |||||||||
| static | after(Minn\Blocks\Block $block, string $html, array $done = array ( )): string# | A rendered block through render_block and its per-name filter, with the WP_Block it began as.
|
Internals 2
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | begin(Minn\Blocks\Block $block, array $parsed, ?Minn\Objects\RenderedBlock $instance, ?array $context): Minn\Blocks\Block# |
| ||||||
| private | context(): array# | @return array<string, mixed> the context render_block() gives a document's top block: the global post's, as get_post() reads it |
Nothing matches.