Minn\Blocks
The block parser and renderer. 23 classes, 152 public methods and 65 internals. This page is the public surface; each class name opens the whole class.
Attributes final readonly class
public/minn/src/Minn/Blocks/Attributes.php · 30 lines · Open the class →
The JSON object a block delimiter carries, read in place. Rewriting one block's attributes must not disturb the rest of the markup, so callers take the object's exact substring rather than reserializing the document.
| static | objectAt(string $markup, int $at): ?string | The JSON object starting at $at, brace-matched through any strings; null when there is none. |
Bindings final class
public/minn/src/Minn/Blocks/Bindings.php · 138 lines · Open the class →
Block bindings (probe block-bindings): a block attribute bound to a source registered with register_block_bindings_source takes the source's value as the block renders. Only the attributes a block supports bind (SUPPORTED, widened by block_bindings_supported_attributes and its per-block form); a "__default" pattern-overrides binding stands for every one of them. A static block's saved HTML takes the values (rich text, kses'd, inside the element its definition selects; plain values set as the selected element's attribute); a dynamic block renders with them.
| const | SUPPORTED = array ( 'core/paragraph' => array ( 0 => 'content', ), 'core/heading' => array ( 0 => 'content', ), 'core/image' => array ( 0 => 'id', 1 => 'url', 2 => 'title', 3 => 'alt', 4 => 'caption', ), 'core/button' => array ( 0 => 'url', 1 => 'text', 2 => 'linkTarget', 3 => 'rel', ), 'core/post-date' => array ( 0 => 'datetime', ), 'core/navigation-link' => array ( 0 => 'url', ), 'core/navigation-submenu' => array ( 0 => 'url', ), ) | |
| static | supported(string $name): array | The attributes a block may bind (get_block_bindings_supported_attributes). @return list<string> @return list<string> |
| static | values(Minn\Blocks\Block $block, array $context): array | The bound attributes' values for a block about to render, as the sources answer them for a WP_Block made with the context given (each source also seeing the context it uses); the expanded bindings ride along under metadata for a pattern-overrides default. Empty when nothing is bound or nothing answered. @param array<string, mixed> $context@return array<string, mixed> |
| static | html(string $html, string $blockName, array $values): string | A static block's HTML with the bound values in place, by its type's attribute definitions: rich text and html replace what the selected element holds; an attribute source sets the selected element's attribute; anything else is left alone. @param array<string, mixed> $values |
| inside | inner(), closing(), opening(), attribute() |
Block final readonly class
public/minn/src/Minn/Blocks/Block.php · 63 lines · Open the class →
One parsed block. A null name is freeform HTML between blocks. The innerContent list holds the block's own HTML chunks in order, with a null placeholder wherever an inner block sits.
| new | __construct(?string $name, array $attrs, array $innerBlocks, string $innerHtml, array $innerContent) | |
| prop | readonly ?string $name | |
| prop | readonly array $attrs | |
| prop | readonly array $innerBlocks | |
| prop | readonly string $innerHtml | |
| prop | readonly array $innerContent | |
| static | freeform(string $html): self | A block-less run of HTML, as the parser reads it. |
| static | fromArray(array $block): self | A block as parse_blocks hands it out, as the value object. @param array<string, mixed> $block @param array<string, mixed> $block |
| method | withAttrs(array $attrs): self | The same block with other attributes. @param array<string, mixed> $attrs @param array<string, mixed> $attrs |
| method | toArray(): array | The block as parse_blocks hands it to plugin code. @return array{blockName: ?string, attrs: array<string, mixed>, innerBlocks: list<array<string, mixed>>, innerHTML: string, innerContent: list<string|null>} |
| method | attr(string $key, mixed $default = NULL): mixed | One attribute, or the default. |
| method | className(): string | The class names declared on the block's own attributes (className). |
BlockName final class
public/minn/src/Minn/Blocks/BlockName.php · 17 lines · Open the class →
The block name rules: a string, lower-case, `namespace/name`.
| static | refuse(mixed $name): ?Minn\Runtime\Refusal | Why a block name is invalid, or null when it is fine. |
BlockStream final class
public/minn/src/Minn/Blocks/BlockStream.php · 285 lines · Open the class →
Block markup read one token at a time, as the reference's streaming block processor reads it (probe block-processor). A delimiter is an HTML comment: whitespace after "<!--", an optional "/" (the closing flag), "wp:", a name (lowercase, an optional namespace), whitespace, optional JSON object attributes followed by whitespace, then "-->" or "/-->" (void). Any other comment is HTML. The HTML between delimiters comes out as its own token, reported as void (freeform at the top, inner HTML in a block) before the delimiter that ends it, which is already read, so the closing flag shows that delimiter's. Quirks kept on purpose: - trailing HTML after the last delimiter is dropped when it holds a comment; - an unterminated comment is incomplete input only when it could still become a delimiter, otherwise reading just stops; - attributes are parsed only when asked, and only that sets the JSON error.
| const | CLOSER = 'closer' | |
| const | OPENER = 'opener' | |
| const | VOID = 'void' | |
| const | READY = 'processor-ready' | |
| const | MATCHED = 'processor-matched' | |
| const | HTML_SPAN = 'processor-html-span' | |
| const | INCOMPLETE_INPUT = 'incomplete-input' | |
| const | COMPLETE = 'processor-complete' | |
| new | __construct(string $text) | A stream over block markup, before its first token. |
| static | normalize(string $name): string | The name with core/ in front when it has no namespace. |
| method | next(): bool | Moves to the next token, HTML or delimiter; false at the end or on incomplete input. |
| method | state(): string | The current token's state: one of the class constants. |
| method | error(): ?string | incomplete-input when the text ran out inside what could be a delimiter, else null. |
| method | jsonError(): int | The JSON error from the last time attributes were asked for. |
| method | delimiterType(): ?string | opener, closer or void for a delimiter, void for HTML, null otherwise. |
| method | closing(): bool | The last delimiter read had the closing flag. |
| method | blockType(): ?string | The delimiter's block type, null for anything else. |
| method | printableType(): ?string | The block type, or core/freeform for top-level HTML and #innerHTML for HTML inside a block. |
| method | isHtml(): bool | Whether the token is HTML between delimiters. |
| method | htmlContent(): ?string | The HTML span's text, null for anything else. |
| method | nonWhitespaceHtml(): bool | Whether the token is HTML with something other than whitespace in it. |
| method | breadcrumbs(): array | The open block types, outermost first, with #html for an HTML span. @return list<string> @return list<string> |
| method | opens(?string $type): bool | Whether this token opens a block (of the type, when given): never after a closer, and HTML only at the top. |
| method | isType(string $type): bool | Whether the token is of the type; * matches anything. |
| method | span(): ?array | The token's start and length in the text, null when there is no token. @return array{0: int, 1: int}|null @return array{0: int, 1: int}|null |
| method | attributes(): ?array | The delimiter's attributes, parsed now (setting the JSON error), or null. @return array<mixed>|null @return array<mixed>|null |
| inside | scan(), emitHtml(), matchDelimiter(), finish(), nextDelimiter(), commentEnd(), couldBeDelimiter() |
Context final class
public/minn/src/Minn/Blocks/Context.php · 76 lines · Open the class →
What the template blocks render against: the resolution, the main query's posts, and a stack of "current post" frames pushed by post templates and comment templates as they loop.
| new | __construct(Minn\Front\Resolution $resolution, array $posts, int $total, int $perPage, bool $front) | @param list<PostRecord> $posts the main query's page of posts |
| prop | readonly Minn\Front\Resolution $resolution | |
| prop | readonly array $posts | |
| prop | readonly int $total | |
| prop | readonly int $perPage | |
| prop | readonly bool $front | |
| static | forRest(): self | A context for rendering outside a page: the home resolution and no posts. |
| method | post(): ?Minn\Content\PostRecord | The post being rendered, innermost first. |
| method | pushPost(Minn\Content\PostRecord $post): void | Enters a post's scope. |
| method | popPost(): void | Leaves the innermost post's scope. |
| method | inLoop(): bool | Inside a post template loop (as opposed to the singular view). |
| method | comment(): ?Minn\Content\CommentRecord | The comment being rendered, if any. |
| method | withComment(?Minn\Content\CommentRecord $comment): void | Enters or leaves a comment's scope. |
| method | paged(): int | The page number being rendered. |
| method | totalPages(): int | How many pages the listing makes. |
CoreBlocks final class
public/minn/src/Minn/Blocks/CoreBlocks.php · 26 lines · Open the class →
The core block types' metadata as the reference registers them (data/blocks.json): their supports and selectors, read once.
| static | metadata(string $name): array | A core block type's registered metadata; empty for a name core does not register. @return array<string, mixed> |
| static | supports(string $name): array | A core block type's supports. @return array<string, mixed> |
Duotone final class
public/minn/src/Minn/Blocks/Duotone.php · 79 lines · Open the class →
Duotone filters (probe block-supports): a CSS color read into its red, green, blue (0 to 255) and alpha (0 to 1, to two places) channels, and the hidden SVG filter that maps an image's shades onto a list of colors, one table of values per channel.
| static | svg(string $filterId, array $colors): string | The filter for a list of colors; colors that do not parse are left out. @param list<string> $colors |
| static | parse(string $input): ?array | A color's channels: hex (3, 4, 6 or 8 digits), rgb()/rgba() and hsl()/hsla(). @return array{r: float, g: float, b: float, a: float}|null |
| inside | alpha(), hsl() |
Elements final class
public/minn/src/Minn/Blocks/Elements.php · 121 lines · Open the class →
Per-block element styles (style.elements in a block's attributes, the link colour most often; probe block-supports). A block whose element styles set a colour gets a numbered wp-elements-N class and a rule per element and state, recorded with the page's block-support styles in render order: links (their text colour, plain or on hover), headings, each heading level and buttons (text, background or gradient). A block type whose colour support skips serialization, whole or for links, headings or buttons, writes none for those.
| static | className(array $attrs, array $supports): ?string | The block's wp-elements-N class, recording its rules; null when its element styles earn none. @param array<string, mixed> $supports the block type's supports |
| static | shouldAdd(array $elements, array $skip): bool | Whether element styles earn a class: a link's text colour (or its hover's), a heading's, a heading level's or a button's text, background or gradient, for a kind not skipped. @param array<string, mixed> $elements@param array<string, bool> $skip by kind: link, heading, button |
| static | skips(array $supports): array | The kinds a block type's colour support skips serializing. @param array<string, mixed> $supports@return array<string, bool> |
| inside | rules(), declarations() |
ImageTags final readonly class
public/minn/src/Minn/Blocks/ImageTags.php · 312 lines · Open the class →
The attributes the reference adds to an <img> that carries a wp-image-{id} class: loading, decoding, width and height (prepended, in that order), and srcset plus sizes (appended). The srcset lists the displayed size first, then every same-ratio size in stored order, then the original.
| new | __construct(Minn\Content\Posts $posts, Minn\Media\Uploads $uploads, Closure $front) | @param Closure(): bool $front whether the images are on a front-end page, where the loading budget applies |
| method | enrich(string $html): string | Rewrites every wp-image-* <img> in a fragment; other images pass through. |
| method | enrichGallery(string $html): string | The same for a gallery: every image also carries its data-id. |
| method | enrichPlugin(string $html): string | The same for a plugin block's output, where the reference adds no sizes="auto". |
| method | content(string $html, mixed $context = NULL): string | Every <img> and <iframe> of a content fragment as the reference's wp_filter_content_tags leaves it: an attachment's image is enriched as above (a loading it already has is kept, and an eager large one is fetched first); any other image is decoded asynchronously and, when its size is known, loaded lazily or by the page's budget; an iframe with a size is loaded lazily. |
| method | finished(string $html, string $context): string | Content the engine fitted out itself, with what the_content's other callbacks added on the way (an attachment's own link, a plugin's image): an image still without its loading attributes is fitted as the rest were, then each is offered to wp_content_img_tag, as wp_filter_content_tags would. |
| method | featured(int $attachmentId, string $alt, string $style): string | A post's featured image at full size, in the reference's attribute order (dimensions, source, class, alt, style, then the loading attributes and the srcset). Empty when the attachment has no file. |
| inside | sized(), fit(), attachmentOf(), plainImage(), autoSized(), lazyFrame(), rewrite(), loadingPrefix(), givenLoading(), minimumPriorityPixels(), enrichTag(), candidates(), srcsetAttributes() |
Layout final class
public/minn/src/Minn/Blocks/Layout.php · 167 lines · Open the class →
The layout support's classes and rules (wp_render_layout_support_flag, probe block-supports), for core and plugin blocks alike:
- is-layout-{type} and {block}-is-layout-{type} for the layout the block uses (its own over its type's default), with has-global-padding for a constrained layout under a theme with root-padding-aware alignments; - is-vertical or is-horizontal, is-content-justification-* and is-nowrap from the layout the block itself stores; - a wp-container-{block}-is-layout-* class when the layout writes CSS (LayoutStyle), and wp-container-content-* for a child's own size or place in its parent's layout.
The rules go to the page's block-support styles through the private minn_block_support_rules action. A container class's suffix is a digest the engine cannot reproduce (its inputs are not observable), so the engine derives its own from the layout: same shape, different value, which the parity suites normalise.
| static | classes(string $blockName, array $attrs): array | The layout classes a core block's wrapper carries, under its type's supports (data/blocks.json). @return list<string> |
| static | forBlock(string $blockName, array $attrs, array $supports): array | The layout classes a block's wrapper carries, its container's rules recorded, under the theme's layout settings the render state holds (root-padding-aware alignments, block gaps). @param array<string, mixed> $supports the block type's supports (layout and its default, spacing)@return list<string> |
| static | childClass(array $child, array $parent): ?string | The class a child's own layout earns (its size or place in the parent's layout), its rules recorded; null when it writes none. @param array<string, mixed> $child the block's style.layout@param array<string, mixed> $parent the parent's layout |
| static | sanitizeGap(mixed $gap): mixed | A block gap as the layout reads it: a value with a character that could end a declaration or open a function (\ ( & = } or a comment) is dropped, a side of one too; anything not a string is left as it is. |
| static | gapCss(mixed $gap): array|string|null | A gap with its presets as custom properties, a side at a time. @return string|array<string, string>|null |
| static | paddingCss(array $padding): array | A block's side padding with its presets as custom properties. @return array<string, string> |
| static | widths(array $layout): array | A layout with its widths checked: the first declaration of each, through the style attribute filter, empty when that drops it. @return array<string, mixed> |
| inside | safeGap(), skipsGap(), used(), typeClasses(), record() |
LayoutStyle final class
public/minn/src/Minn/Blocks/LayoutStyle.php · 193 lines · Open the class →
The CSS rules a block's layout writes (wp_get_layout_style, probe block-supports), as selector => declarations pairs the style engine turns into a stylesheet:
- flow: only the gap between children (none, then the gap, on each); - constrained: the content width on the children that are not aligned left, right or full, the wide width on wide ones, no limit on full ones (justifyContent pushes the children to a side: both margins with a width, the one side alone without), negative margins on full ones for a block with side padding, then the children's gap; - flex: nowrap, the gap, then the direction and alignments the orientation reads from justifyContent and verticalAlignment; - grid: the column template (a count, a minimum width, or both folded together with the gap, or the fallback gap without one), then the gap.
Widths arrive checked (one dropped as unsafe is empty) and gaps with presets turned into custom properties.
| static | rules(string $selector, array $layout, array|string|null $gap, array $padding = array ( ), string $fallbackGap = '0.5em'): array | The rules for a container. @param array<string, mixed> $layout the layout, its widths checked@param string|array<string, string>|null $gap the block gap (a value, or top and left), null when it is not written@param array<string, string> $padding the block's own padding (left, right), for full-width children@return list<array{selector: string, declarations: array<string, string>}> |
| static | childRules(string $selector, array $child, array $parent): array | The rules a child writes from its own layout (wp_get_child_layout_style_rules): a fixed or filling flex size, a grid span, a grid position, released again (the full row for a span) in a container narrower than the columns it needs: the columns at the parent's minimum width (12rem by default) and the gaps between them (1.5rem, or 24px for a width in px). @param array<string, mixed> $child the child's layout (selfStretch, flexSize, columnSpan, rowSpan, columnStart, rowStart)@param array<string, mixed> $parent the parent's layout@return list<array<string, mixed>> |
| static | containerValues(array $layout): array | A layout's container values: everything but the child keys. |
| static | childValues(array $layout): array | A layout's child values: the child keys alone. |
| inside | flowGap(), constrained(), flex(), grid(), gapValue(), filled(), single() |
Parser final class
public/minn/src/Minn/Blocks/Parser.php · 114 lines · Open the class →
Parses block markup into a tree. The grammar is the delimiter comment: an opener with optional JSON attributes, a closer, or a self-closing void block; a name without a namespace is core/. Anything outside a block is a freeform block that renders as-is.
| static | parse(string $markup): array | Block markup as a tree of blocks. @return list<Block> |
| static | token(string $markup, int $offset): ?array | The first block delimiter at or after an offset: where it starts, its length, its name (core/ when it names no namespace), its attributes as written (null when it has none), and whether it closes a block or is a void one. Null when no delimiter follows. @return array{start: int, length: int, name: string, attrs: ?string, closer: bool, void: bool}|null |
| static | contains(string $content, string $name): bool | Whether serialized content carries a block by name; a bare name means core/, and core blocks are also found by their short delimiter. |
QueryVars final class
public/minn/src/Minn/Blocks/QueryVars.php · 122 lines · Open the class →
The query variables a Query Loop block's context asks for, the way the reference's build_query_vars_from_query_block builds them (probe query-loop): a viewable post type; stickies only, left out, or ignored; exclusions; a page size and offset for the page asked for; the old category and tag ids and each viewable taxonomy's terms, merged; formats (standard as no format) OR'd, beside the terms in a group of their own; order, orderby, authors (a list, a comma list, or one id), a search, and parents for a hierarchical type.
| static | fromContext(?array $context, int $page, array $sticky, array $site): array | The query vars a query block's context amounts to. @param array<string, mixed>|null $context the block's `query` context@param list<int> $sticky the site's sticky post ids@param array{viewableType: callable(string): bool, hierarchicalType: callable(string): bool, viewableTaxonomy: callable(string): bool, formats: list<string>} $site what the site says about types, taxonomies and formats |
| inside | sticky(), idTerms(), taxonomyTerms(), formats(), author() |
RenderState final class
public/minn/src/Minn/Blocks/RenderState.php · 350 lines · Open the class →
Per-request rendering state, owned by the renderer. The reference numbers galleries, style variations, and search inputs from ONE counter that runs across every block rendered in the request (a list response keeps counting from post to post), so the counter lives here, not on any block. Leaf helpers with no renderer in hand reach it through current().
| const | MAX_DEPTH = 64 | |
| static | current(): self | The state of the request being rendered, which its runtime holds, so a request cannot count on from the one before it. Rendering with no runtime (the command line, the unit suite) shares one off-request state instead, since the counters have to survive between calls. |
| method | adopt(): void | Makes this the state current() answers with, for the renderer that brought its own. |
| method | rootPaddingAware(): bool | Whether the theme puts root padding in custom properties, which decides the constrained layout's classes. |
| method | useRootPadding(bool $aware): void | Records what the active theme's layout settings say about root padding. |
| method | blockGap(): bool | Whether the theme writes block gaps, which decides whether a layout's gap makes CSS. |
| method | useBlockGap(bool $writes): void | Records whether the active theme's spacing settings write block gaps. |
| method | nextId(): int | The next per-request counter value. |
| method | countImages(int $amount): int | Adds to the page's count of content images (wp_increase_content_media_count) and returns the new count. |
| method | nextImage(): int | Content images seen so far in this page, for the loading rules. |
| method | refundImages(int $count, bool $priority): void | Images a plugin's block filter removed from the page give their budget back, so the next image still counts as if the hidden ones never rendered. |
| method | aside(Closure $render): mixed | Runs rendering whose images do not count toward the page's loading budget (an excerpt's): the reference fits no image while it makes one, so whatever was seen meanwhile is given back. @param \Closure(): T $render |
| method | filteringContent(string $content, Closure $filter): mixed | $filter run while the_content filters content the engine rendered: the images it already holds count as fitted out, so only what the filter's other callbacks add is fitted (fittedImage()). |
| method | fittedImage(string $tag): bool | Whether an image tag is one the content being filtered held when the filter began. |
| method | claimPriority(): bool | True once, for the image that gets fetchpriority="high". |
| method | priorityAvailable(): bool | Whether no element has taken high fetch priority yet on this page. |
| method | closePriority(): void | Takes high fetch priority off the table for the rest of the page; a plugin prioritising its own element does this. |
| method | reopenPriority(): void | Puts high fetch priority back on offer, so the next large enough image takes it. |
| method | recordBlock(string $blockName): void | Every block name the page rendered; the stylesheet prints block styles for these only. |
| method | blocks(): array | The block names rendering met. @return array<string, true> |
| method | nextElements(): int | The next wp-elements-N class; the reference numbers these apart from the shared counter. |
| method | uniqueLabel(string $label): string | A navigation's aria-label: the label itself the first time, then "label N" for repeats. |
| method | enterNavigation(): void | A page list renders plain on its own and takes the navigation block's item classes, submenu toggles, and interactivity only while it sits inside one, so the navigation block marks the span it owns. |
| method | leaveNavigation(): void | Leaves a navigation block. |
| method | processesDirectives(?bool $answer = NULL): bool | Whether the block rendering now has its Interactivity API directives processed, as interactivity_process_directives answered for it. |
| method | inNavigation(): bool | Whether rendering is inside a navigation block. |
| method | enter(string $key): bool | Marks a nested source as being rendered; false when it is already open (a cycle). |
| method | leave(string $key): void | Leaves a cycle-guarded key. |
| method | inside(string $key): bool | Whether a key is open: a source being rendered, or the page template ("template"). |
| method | descend(): bool | True while the block tree is shallower than the cap; deeper blocks render as nothing. |
| method | ascend(): void | Leaves one nesting level. |
| method | depth(): int | How deep the block tree is right now; zero outside any block render. |
| method | setPendingElements(?string $class): ?string | A dynamic block claims its element class before rendering, so a block that renders nothing still counts. |
| method | takePendingElements(): ?string | The pending elements class, cleared. |
| method | setPendingVariation(?string $class): ?string | Holds the numbered style variation class a dynamic block claimed before rendering; returns the one it replaces. |
| method | takePendingVariation(): ?string | The numbered style variation class the dynamic block being rendered claimed, once: its wrapper takes it. |
| method | recordGallery(int $instance): void | Notes a gallery instance. |
| method | galleries(): array | The gallery instances rendering met. @return list<int> |
| method | reset(): void | Clears every per-request counter. |
Renderer final class
public/minn/src/Minn/Blocks/Renderer.php · 449 lines · Open the class →
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.
| 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. @param callable(Block, Renderer): string $render |
| 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(). @param callable(Block, Renderer): string $render |
| 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. @param list<Block> $blocks |
| 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. @param callable(string, Block): string $finish |
| 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. @param array<string, mixed> $context |
| 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 @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. |
| inside | renderWith(), generatedClass(), elementsClass(), renderNamed(), decorate(), gallery() |
Selector final class
public/minn/src/Minn/Blocks/Selector.php · 43 lines · Open the class →
The CSS selector a block type declares for its root or for one feature, from its `selectors` map or the older per-support keys.
| static | resolve(array $selectors, array $supports, array|string|null $target, bool $fallback, string $defaultClass): ?string | The CSS selector a block's style targets, or null. @param array<string, mixed> $selectors the block type's selectors map@param array<string, mixed> $supports the block type's supports@param string|list<string>|null $target 'root', a dotted feature path, or a path list |
| inside | at() |
Serializer final class
public/minn/src/Minn/Blocks/Serializer.php · 46 lines · Open the class →
Parsed blocks back to markup. A core block is written by its short name; attributes are JSON with every character that could end the comment or open a tag spelled as an escape ("<" "<", "--" "--", a backslash "\"), so a value can never break out of its delimiter.
| static | blocks(array $blocks): string | A list of parsed blocks back to markup, freeform runs as written. @param list<Block> $blocks |
| static | block(Minn\Blocks\Block $block): string | One block with its inner blocks, as the delimiter comments the parser reads. |
| static | delimited(?string $name, array $attrs, string $content): string | Content wrapped in a block's delimiters; a block with no content is written self-closing. |
| static | attributes(array $attrs): string | Block attributes as the delimiter carries them. |
States final class
public/minn/src/Minn/Blocks/States.php · 160 lines · Open the class →
Block state styles (a block's style[":hover"] and the like, probe block-supports): the selector arithmetic and the fallbacks the reference applies when it writes a state's rules. Pure: styles and selectors in, styles, groups and declarations out.
| static | split(string $selector): array | A selector list split at its top-level commas (none inside parentheses counts), each part as written. @return list<string> |
| static | selector(string $base, string $selectors, string $state): string | A state on each selector of a block's list, its leading compound selector swapped for the base; the base alone for an empty list. |
| static | presetVars(mixed $value): mixed | Presets (var:preset|{kind}|{slug}) as their custom properties, through arrays; anything else as it is. |
| static | backgroundResets(array $declarations): array | Declarations with a background image unset under a background colour that sets neither a background nor an image of its own. @param array<string, string> $declarations@return array<string, string> |
| static | borderFallbacks(array $declarations): array | Declarations with a solid border style for a border (or a side of one) given a width or a colour and no style. @param array<string, string> $declarations@return array<string, string> |
| static | dimensionFallbacks(array $style): array | A state's style with an explicit aspect ratio unsetting the height and minimum height, or a height or minimum height unsetting the aspect ratio. @param array<string, mixed> $style@return array<string, mixed> |
| static | groups(array $style, array $selectors): array | A state's style split by the selectors a block gives its features: a feature (or one of its properties) with a selector of its own goes there, a feature's other properties to its root selector, the rest to the block's root. Groups keep the order they are first met in. @param array<string, mixed> $style@param array<string, mixed> $selectors the block's selectors, root among them@return list<array{selector: ?string, style: array<string, mixed>}> |
| static | addGroup(array $groups, ?string $selector, array $style): void | Adds a style to the group of a selector, merged into what it holds. @param array<string, array{selector: ?string, style: array<string, mixed>}> $groups@param array<string, mixed> $style |
StyleEngine final class
public/minn/src/Minn/Blocks/StyleEngine.php · 195 lines · Open the class →
What a block's style object comes to, as the reference's style engine reads it (probe style-engine): the declarations each style property makes and the class names a preset or a set colour earns.
- Groups in the order background, colour, border, shadow, dimensions, spacing, typography, and properties in their order within a group. - A value goes into the declarations as given. Whether it makes CSS is for the declarations holder to judge. - A preset ("var:preset|color|base") becomes a custom property only where the definition names one for its kind (a colour, a gradient, spacing, a font size or family, a shadow, a dimension, a border radius, a border side's colour). Elsewhere it makes nothing, and with presets turned into class names it makes none anywhere. - Sides and corners ("padding" => ["top" => ...]) name their own properties in the order given. Border sides come after the whole border.
| const | DEFINITIONS = array ( 'background' => array ( 'backgroundImage' => array ( 'property_keys' => array ( 'default' => 'background-image', ), 'value_func' => array ( 0 => 'WP_Style_Engine', 1 => 'get_url_or_value_css_declaration', ), 'path' => array ( 0 => 'background', 1 => 'backgroundImage', ), ), 'backgroundPosition' => array ( 'property_keys' => array ( 'default' => 'background-position', ), 'path' => array ( 0 => 'background', 1 => 'backgroundPosition', ), ), 'backgroundRepeat' => array ( 'property_keys' => array ( 'default' => 'background-repeat', ), 'path' => array ( 0 => 'background', 1 => 'backgroundRepeat', ), ), 'backgroundSize' => array ( 'property_keys' => array ( 'default' => 'background-size', ), 'path' => array ( 0 => 'background', 1 => 'backgroundSize', ), ), 'backgroundAttachment' => array ( 'property_keys' => array ( 'default' => 'background-attachment', ), 'path' => array ( 0 => 'background', 1 => 'backgroundAttachment', ), ), 'gradient' => array ( 'property_keys' => array ( 'default' => 'background-image', ), 'css_vars' => array ( 'gradient' => '--wp--preset--gradient--$slug', ), 'path' => array ( 0 => 'background', 1 => 'gradient', ), 'classnames' => array ( 'has-background' => true, ), ), ), 'color' => array ( 'text' => array ( 'property_keys' => array ( 'default' => 'color', ), 'path' => array ( 0 => 'color', 1 => 'text', ), 'css_vars' => array ( 'color' => '--wp--preset--color--$slug', ), 'classnames' => array ( 'has-text-color' => true, 'has-$slug-color' => 'color', ), ), 'background' => array ( 'property_keys' => array ( 'default' => 'background-color', ), 'path' => array ( 0 => 'color', 1 => 'background', ), 'css_vars' => array ( 'color' => '--wp--preset--color--$slug', ), 'classnames' => array ( 'has-background' => true, 'has-$slug-background-color' => 'color', ), ), 'gradient' => array ( 'property_keys' => array ( 'default' => 'background', ), 'path' => array ( 0 => 'color', 1 => 'gradient', ), 'css_vars' => array ( 'gradient' => '--wp--preset--gradient--$slug', ), 'classnames' => array ( 'has-background' => true, 'has-$slug-gradient-background' => 'gradient', ), ), ), 'border' => array ( 'color' => array ( 'property_keys' => array ( 'default' => 'border-color', 'individual' => 'border-%s-color', ), 'path' => array ( 0 => 'border', 1 => 'color', ), 'classnames' => array ( 'has-border-color' => true, 'has-$slug-border-color' => 'color', ), ), 'radius' => array ( 'property_keys' => array ( 'default' => 'border-radius', 'individual' => 'border-%s-radius', ), 'path' => array ( 0 => 'border', 1 => 'radius', ), 'css_vars' => array ( 'border-radius' => '--wp--preset--border-radius--$slug', ), ), 'style' => array ( 'property_keys' => array ( 'default' => 'border-style', 'individual' => 'border-%s-style', ), 'path' => array ( 0 => 'border', 1 => 'style', ), ), 'width' => array ( 'property_keys' => array ( 'default' => 'border-width', 'individual' => 'border-%s-width', ), 'path' => array ( 0 => 'border', 1 => 'width', ), ), 'top' => array ( 'value_func' => array ( 0 => 'WP_Style_Engine', 1 => 'get_individual_property_css_declarations', ), 'path' => array ( 0 => 'border', 1 => 'top', ), 'css_vars' => array ( 'color' => '--wp--preset--color--$slug', ), ), 'right' => array ( 'value_func' => array ( 0 => 'WP_Style_Engine', 1 => 'get_individual_property_css_declarations', ), 'path' => array ( 0 => 'border', 1 => 'right', ), 'css_vars' => array ( 'color' => '--wp--preset--color--$slug', ), ), 'bottom' => array ( 'value_func' => array ( 0 => 'WP_Style_Engine', 1 => 'get_individual_property_css_declarations', ), 'path' => array ( 0 => 'border', 1 => 'bottom', ), 'css_vars' => array ( 'color' => '--wp--preset--color--$slug', ), ), 'left' => array ( 'value_func' => array ( 0 => 'WP_Style_Engine', 1 => 'get_individual_property_css_declarations', ), 'path' => array ( 0 => 'border', 1 => 'left', ), 'css_vars' => array ( 'color' => '--wp--preset--color--$slug', ), ), ), 'shadow' => array ( 'shadow' => array ( 'property_keys' => array ( 'default' => 'box-shadow', ), 'path' => array ( 0 => 'shadow', ), 'css_vars' => array ( 'shadow' => '--wp--preset--shadow--$slug', ), ), ), 'dimensions' => array ( 'aspectRatio' => array ( 'property_keys' => array ( 'default' => 'aspect-ratio', ), 'path' => array ( 0 => 'dimensions', 1 => 'aspectRatio', ), 'classnames' => array ( 'has-aspect-ratio' => true, ), ), 'height' => array ( 'property_keys' => array ( 'default' => 'height', ), 'path' => array ( 0 => 'dimensions', 1 => 'height', ), 'css_vars' => array ( 'dimension' => '--wp--preset--dimension--$slug', ), ), 'minHeight' => array ( 'property_keys' => array ( 'default' => 'min-height', ), 'path' => array ( 0 => 'dimensions', 1 => 'minHeight', ), 'css_vars' => array ( 'dimension' => '--wp--preset--dimension--$slug', ), ), 'minWidth' => array ( 'property_keys' => array ( 'default' => 'min-width', ), 'path' => array ( 0 => 'dimensions', 1 => 'minWidth', ), 'css_vars' => array ( 'dimension' => '--wp--preset--dimension--$slug', ), ), 'objectFit' => array ( 'property_keys' => array ( 'default' => 'object-fit', ), 'path' => array ( 0 => 'dimensions', 1 => 'objectFit', ), ), 'width' => array ( 'property_keys' => array ( 'default' => 'width', ), 'path' => array ( 0 => 'dimensions', 1 => 'width', ), 'css_vars' => array ( 'dimension' => '--wp--preset--dimension--$slug', ), ), ), 'spacing' => array ( 'padding' => array ( 'property_keys' => array ( 'default' => 'padding', 'individual' => 'padding-%s', ), 'path' => array ( 0 => 'spacing', 1 => 'padding', ), 'css_vars' => array ( 'spacing' => '--wp--preset--spacing--$slug', ), ), 'margin' => array ( 'property_keys' => array ( 'default' => 'margin', 'individual' => 'margin-%s', ), 'path' => array ( 0 => 'spacing', 1 => 'margin', ), 'css_vars' => array ( 'spacing' => '--wp--preset--spacing--$slug', ), ), ), 'typography' => array ( 'fontSize' => array ( 'property_keys' => array ( 'default' => 'font-size', ), 'path' => array ( 0 => 'typography', 1 => 'fontSize', ), 'css_vars' => array ( 'font-size' => '--wp--preset--font-size--$slug', ), 'classnames' => array ( 'has-$slug-font-size' => 'font-size', ), ), 'fontFamily' => array ( 'property_keys' => array ( 'default' => 'font-family', ), 'css_vars' => array ( 'font-family' => '--wp--preset--font-family--$slug', ), 'path' => array ( 0 => 'typography', 1 => 'fontFamily', ), 'classnames' => array ( 'has-$slug-font-family' => 'font-family', ), ), 'fontStyle' => array ( 'property_keys' => array ( 'default' => 'font-style', ), 'path' => array ( 0 => 'typography', 1 => 'fontStyle', ), ), 'fontWeight' => array ( 'property_keys' => array ( 'default' => 'font-weight', ), 'path' => array ( 0 => 'typography', 1 => 'fontWeight', ), ), 'lineHeight' => array ( 'property_keys' => array ( 'default' => 'line-height', ), 'path' => array ( 0 => 'typography', 1 => 'lineHeight', ), ), 'textColumns' => array ( 'property_keys' => array ( 'default' => 'column-count', ), 'path' => array ( 0 => 'typography', 1 => 'textColumns', ), ), 'textDecoration' => array ( 'property_keys' => array ( 'default' => 'text-decoration', ), 'path' => array ( 0 => 'typography', 1 => 'textDecoration', ), ), 'textIndent' => array ( 'property_keys' => array ( 'default' => 'text-indent', ), 'path' => array ( 0 => 'typography', 1 => 'textIndent', ), ), 'textTransform' => array ( 'property_keys' => array ( 'default' => 'text-transform', ), 'path' => array ( 0 => 'typography', 1 => 'textTransform', ), ), 'letterSpacing' => array ( 'property_keys' => array ( 'default' => 'letter-spacing', ), 'path' => array ( 0 => 'typography', 1 => 'letterSpacing', ), ), 'writingMode' => array ( 'property_keys' => array ( 'default' => 'writing-mode', ), 'path' => array ( 0 => 'typography', 1 => 'writingMode', ), ), ), ) | The reference's style definitions, by group and property (WP_Style_Engine::BLOCK_STYLE_DEFINITIONS_METADATA). |
| static | parse(array $styles, array $options = array ( )): array | A style object's declarations and class names. @param array<string, mixed> $styles@param array<string, mixed> $options convert_vars_to_classnames turns presets into class names alone@return array{classnames: list<string>, declarations: array<string, mixed>} |
| static | slug(mixed $value, string $kind): ?string | A preset's slug for a kind ("var:preset|color|base" for color is "base"), or null. |
| static | var(mixed $value, array $vars): ?string | A preset as the custom property the definition names for its kind, or null. @param array<string, string> $vars @param array<string, string> $vars |
| static | classNames(mixed $value, array $definition): array | A preset's class names for a definition. @param array<string, mixed> $definition @return list<string> @param array<string, mixed> $definition @return list<string> |
| static | declarationsFor(mixed $value, array $definition, array $options = array ( )): array | The declarations one definition makes of a value; presets as class names make none. @param array<string, mixed> $definition @param array<string, mixed> $options @return array<string, mixed> @param array<string, mixed> $definition @param array<string, mixed> $options @return array<string, mixed> |
| static | individual(mixed $value, array $definition, array $options = array ( )): array | A border side's declarations. @param array<string, mixed> $definition @param array<string, mixed> $options @return array<string, mixed> @param array<string, mixed> $definition @param array<string, mixed> $options @return array<string, mixed> |
| static | urlOrValue(mixed $value, array $definition): array | A url or a plain value. @param array<string, mixed> $definition @return array<string, mixed> @param array<string, mixed> $definition @return array<string, mixed> |
| static | kebab(string $text): string | A name in kebab case, as the reference's _wp_to_kebab_case cuts it ("lineHeight", "Zz Space" become "line-height", "zz-space"). |
| inside | at(), present(), classes(), declarations(), one(), sides(), side(), url() |
Styles final class
public/minn/src/Minn/Blocks/Styles.php · 155 lines · Open the class →
The inline style and class names a block's "style" and preset attributes produce at render time, for the dynamic blocks that build their own wrapper (static blocks already carry them in stored markup).
| static | value(string $value): string | var:preset|spacing|40 becomes var(--wp--preset--spacing--40). A value that could close a declaration or a style element, or carry code, is dropped: these values come from stored block attributes. |
| static | slug(string $value): string | A class-name token from an attribute: letters, digits, dashes, underscores; nothing that ends an attribute. |
| static | inline(array $style): string | The style attribute's declarations. The reference emits the style groups in a fixed order (border, colour, typography, spacing, dimensions) and most properties in a fixed order within a group, but a spacing box's sides come out as the block stored them. |
| static | classes(array $attrs): array | The preset classes (font size, text alignment, custom class names) a block's attributes declare. |
| static | align(array $attrs): ?string | The align class an "align" attribute declares. |
| inside | borderDeclarations(), colorDeclarations(), spacingDeclarations(), typographyDeclarations(), dimensionDeclarations() |
TemplatePartVariations final class
public/minn/src/Minn/Blocks/TemplatePartVariations.php · 41 lines · Open the class →
The template part block's variations as the reference builds them (probes rest-block-types, tabs-and-parts): one per area, the general and the navigation overlay areas aside (by name), carrying the area's label, description and icon, offered in the inserter only while no part variation belongs to it; and one per template part, in the order the parts are listed, offered in the inserter with the part's slug, theme and area as its attributes and its example.
| static | areas(array $areas, array $instances): array | The areas' variations beside the parts' ones. @param list<array<string, mixed>> $areas get_allowed_block_template_part_areas()@param list<array<string, mixed>> $instances the parts' variations@return list<array<string, mixed>> |
| static | instances(array $areas, array $parts): array | One variation per template part. @param list<array<string, mixed>> $areas get_allowed_block_template_part_areas()@param list<object> $parts get_block_templates() for template parts@return list<array<string, mixed>> |
Wrapper final class
public/minn/src/Minn/Blocks/Wrapper.php · 59 lines · Open the class →
The opening tag of a dynamic block's wrapper, in the reference's class order: text alignment, the link-colour marker (for the blocks that carry it), the block's own extra classes (a taxonomy, an alignment), the custom class and its numbered style companion, the element-style class, the block's class, colour presets, font size and family, and the layout classes last; the style attribute inline.
| static | open(string $tag, string $blockClass, Minn\Blocks\Block $block, bool $styleFirst = false, bool $linkColorClass = false, array $extraClasses = array ( ), array $trailingClasses = array ( )): string | A dynamic block's opening tag with its classes in the reference's order. |
Nothing matches.