API / Minn\Runtime / AssetQueue

AssetQueue final class

Minn\Runtime\AssetQueue · public/minn/src/Minn/Runtime/AssetQueue.php · 201 lines

The scripts and styles a request queues, as WordPress's asset functions queue them: each kind's registry kept for the request, a handle queued (with the notice for one queued before init), and a script's element, from a file or inline, through the attribute filters.

Constants and properties

privatestatic ?Closure $firstUse

Public

staticfollow(string $kind, mixed $global): Minn\Runtime\Assets#

The registry the page's functions work on: the one held by the object in the global a plugin may replace ($wp_scripts, $wp_styles), as the reference's functions follow that global. Elementor's editor starts from a new registry of each kind, leaving every other plugin's assets out; from then on that one is the page's, the engine's own printing included. Without such an object, the request's own.

staticof(mixed $registry): ?Minn\Runtime\Assets#

The engine queue a registry object holds (a WP_Scripts or WP_Styles), null for anything else.

staticforFunctions(string $kind, mixed $global): Minn\Runtime\Assets#

The registry a page's script or style function works on (follow), a script one used first (used).

staticsnapshot(): array#

The scripts, styles and script modules queued now, to compare with once a block has rendered.

@return array{0: list<string>, 1: list<string>, 2: list<string>}
staticdequeueSince(array $before): void#

Takes off the queues what joined them since the snapshot: what a block that rendered nothing enqueued, as the reference takes it off.

$beforearray{0: list<string>, 1: list<string>, 2: list<string>}
staticsettleBlock(array $before, string $html, string $name, Closure $enqueue, mixed $type = NULL): void#

After a block has rendered: when a named block rendered nothing, whitespace aside, and its render enqueued something or its own assets are not all queued yet, enqueue_empty_block_content_assets is asked; unless it keeps them, what the render enqueued is taken off the queues again and the block's own are not added. Otherwise $enqueue adds its own. The text between blocks (no name) is never asked about, as on the reference.

$beforearray{0: list<string>, 1: list<string>, 2: list<string>}
staticassets(string $kind): Minn\Runtime\Assets#

The request's registry of one kind of asset, script or style, made the first time it is asked for.

staticwarnTooEarly(mixed $function, mixed $handle = ''): void#

The notice (doing it wrong, 3.3.0) for an asset function run before init and before any of the enqueue actions (_wp_scripts_maybe_doing_it_wrong), naming the handle when there is one.

staticlinedUp(Minn\Runtime\Assets $scripts, array $toDo): mixed#

The scripts lined up for printing, as print_scripts_array leaves them. WordPress's own scripts among them that the engine has no file for are noted for the Minn Legacy Pack (LegacyPack::noteScripts).

$toDolist<string>
staticenqueueScript(string $handle): void#

A registered script queued (wp_enqueue_script with a handle alone).

staticused(): void#

The page's script registry used, as rendering a block or queuing a script uses the reference's (it is made then, and what it is told as it is made, it is told now): the facade's callback runs once and is gone.

staticonFirstUse(?Closure $first): void#

What the page's script registry is told on its first use (the facade's wp_scripts()); null for nothing.

staticenqueueStyle(string $handle): void#

A registered style queued (wp_enqueue_style with a handle alone).

statictag(mixed $attributes): string#

A script file's element (wp_get_script_tag), its attributes through wp_script_attributes first.

staticinlineTag(mixed $data, mixed $attributes = array ( )): string#

Inline code's element (wp_get_inline_script_tag): the code trimmed between newlines, wp_inline_script_attributes asked.

Internals 1

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

privatepending(mixed $type): bool#

Whether a block type has assets of its own not queued yet (its scripts, view scripts and modules, styles).