API / Minn\Runtime / BlockFilters

BlockFilters final class

Minn\Runtime\BlockFilters · public/minn/src/Minn/Runtime/BlockFilters.php · 127 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

constNATIVE_DATA_DONE = array ( 'wp_render_elements_support_styles' => 10, 'wp_render_block_style_variation_support_styles' => 10, 'block_core_gallery_data_id_backcompatibility' => 10, )

The data filters the engine's renderer does itself for a block it renders natively: element styles, style variations, a gallery's image ids.

constNATIVE_RENDER_DONE = array ( 'wp_render_elements_class_name' => 10, 'wp_render_block_style_variation_class_name' => 10, 'wp_render_layout_support_flag' => array ( 0 => 10, 1 => '_minn_render_child_layout_support', ), 'block_core_paragraph_add_class' => 10, )

The render filters it does itself: the element and style variation classes, the layout's container classes (a child's own layout left to a stand-in), the paragraph's class.

privatestatic array $parsedFor

Public

staticactive(): bool#

Whether any block filter is registered.

statictoArray(Minn\Blocks\Block $block): array#

A block as the parsed array plugins receive.

@return array<string, mixed> the parsed-array shape plugin code reads
staticfromArray(array $parsed): Minn\Blocks\Block#

A block from the parsed array plugins hand back.

staticdata(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).

$parsedarray<string, mixed>
$parentobject|nullthe WP_Block rendering it, when there is one
$donearray<string, int|array{0: int, 1: string}>
staticrendered(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).

$parsedarray<string, mixed>
$instanceobject|nullthe WP_Block the filters receive
$donearray<string, int|array{0: int, 1: string}>
staticbefore(Minn\Blocks\Block $block, array $done = array ( )): Minn\Blocks\Block|string#

A short-circuit from pre_render_block, or the block as render_block_data left it.

$donearray<string, int|array{0: int, 1: string}>the data filters done already
staticafter(Minn\Blocks\Block $block, string $html, array $done = array ( )): string#

A rendered block through render_block and its per-name filter.

$donearray<string, int|array{0: int, 1: string}>the render filters done already

Internals 1

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

privatecontext(): array#
@return array<string, mixed>