LegacyPack final class
Minn\Runtime\LegacyPack · public/minn/src/Minn/Runtime/LegacyPack.php · 310 lines
WordPress's own browser files, for the plugins whose screens are built on them: a page builder's editor loads WordPress's media library, its classic editor and the libraries under them, by the addresses WordPress serves them from (/wp-includes/js/..., /wp-admin/css/...), and some of that code names those addresses itself.
The engine carries none of them. They are GPL, and they come with the Minn Legacy Pack, a plugin the site installs like any other (the way a site installs the script pack, ScriptPack), which keeps them under the same paths and registers their handles. While the pack is active the engine answers those addresses from it, ahead of loading any plugin, so a page that loads a hundred of them stays fast. A file the engine serves itself (its jQuery, its embed scripts) is not in the pack and still comes from the engine.
The pack is published on GitHub and delivered through the Minn update service like any plugin that publishes its own releases. Where a site runs a plugin whose editor is known to need it (EDITORS, and what plugins add through minn_legacy_pack_editors) and the pack is not active, Minn Admin offers to install it, and the wp-admin doorway sends a click on that editor to the offer rather than to an editor that cannot load.
Constants and properties
| const | PLUGIN = 'minn-legacy-pack/minn-legacy-pack.php' | The pack, as the active plugins list names it. |
| const | REPOSITORY = 'austinginder/minn-legacy-pack' | Where the pack is published, as its Update URI names it. |
| private | EDITORS = array ( 'elementor/elementor.php' => array ( 'name' => 'Elementor', 'action' => 'elementor', ), 'brizy/brizy.php' => array ( 'name' => 'Brizy', 'action' => 'in-front-editor', ), 'bb-plugin/fl-builder.php' => array ( 'name' => 'Beaver Builder', 'query' => 'fl_builder', ), 'beaver-builder-lite-version/fl-builder.php' => array ( 'name' => 'Beaver Builder', 'query' => 'fl_builder', ), 'bricks' => array ( 'name' => 'Bricks', 'query' => 'bricks=run', 'theme' => true, ), ) | The editors proven to open on Minn with the pack and not without it, by the plugin (its file) or theme (its folder, with `theme`) that brings them: the editor's name, and what opens it, a wp-admin action or a query on the page it edits (`name`, or `name=value` for that value only). |
| private | WANTED = 'minn_legacy_pack_wanted' | Where noteScripts keeps the plugins and themes whose public pages need the pack. |
| private | KEPT_FOR = 2592000 | How long a plugin noteScripts saw needing the pack is still offered it without being seen again. |
| private | NOT_CARRIED = '#^(?:prototype|scriptaculous(?:-[a-z]+)?|wp-tinymce(?:-[a-z]+)?)$#' | WordPress's own scripts the pack does not carry either (nor does the engine): a page needing them is not helped by it. |
| private | PATH = '#^/(?:wp-includes/(?:js|css|images|fonts)|wp-admin/(?:js|css|images))/[A-Za-z0-9._/-]+$#' | |
| private | TYPES = array ( 'js' => 'application/javascript', 'css' => 'text/css', 'png' => 'image/png', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'svg' => 'image/svg+xml', 'webp' => 'image/webp', 'ico' => 'image/x-icon', 'woff' => 'font/woff', 'woff2' => 'font/woff2', 'ttf' => 'font/ttf', 'eot' => 'application/vnd.ms-fontobject', 'json' => 'application/json', 'html' => 'text/html; charset=UTF-8', 'txt' => 'text/plain; charset=UTF-8', ) |
Public
| static | active(): bool# | Whether the pack is active on the site the runtime serves. | |||
| static | status(): array# | The pack's state for the app: whether it is installed and active; the editors of the active plugins and theme that need it, each with the action or query that opens it ('' for the one it has not); and the active plugins and theme whose scripts were seen needing it on the public site (noteScripts), with the scripts they needed and a page that showed it. @return array{installed: bool, active: bool, editors: list<array{plugin: string, theme: string, name: string, action: string, query: string}>, wanted: list<array{plugin: string, theme: string, name: string, handles: list<string>, page: string, seen: int}>} | |||
| static | noteScripts(Minn\Runtime\Assets $scripts, array $lined): void# | Notes, on a public page while the pack is not active, the plugins and the theme whose scripts lined up for printing need one of WordPress's own scripts that the engine carries no file for and the pack does (WooCommerce's variation form needs wp-util, its block cart wp-element and the rest). Such a script prints and fails in the visitor's browser. Each is kept with the scripts it needed and a page that showed it, at most once a day, for Minn Admin to offer the pack.
| |||
| static | wantedFor(string $action): ?array# | The editor a wp-admin action opens that needs the pack while it is not active, or null. @return array{plugin: string, theme: string, name: string, action: string, query: string}|null @return array{plugin: string, theme: string, name: string, action: string, query: string}|null | |||
| static | wantedOn(array $query): ?array# | The editor a page's query opens that needs the pack while it is not active (Beaver Builder's ?fl_builder, Bricks' ?bricks=run), or null.
@return array{plugin: string, theme: string, name: string, action: string, query: string}|null | |||
| static | offer(array $editor, Minn\Front\Permalinks $permalinks, Minn\Http\Request $request): Minn\Http\Response# | Minn Admin's offer to install the pack for an editor, with the way back to the page that opens it: `?legacy-pack=<action or query>&return=<page>`.
| |||
| static | claims(string $path): bool# | Whether a path is one of the addresses WordPress serves its browser files from. | |||
| static | file(string $contentDir, string $path, array $activePlugins): ?string# | The file in the active pack a path names, or null: the pack is not active, the file is not in it, or its type is not one a browser loads.
| |||
| static | response(string $file): Minn\Http\Response# | The file as the answer to the request for it. |
Internals 4
Private and protected methods: how the class does its work. Not a contract; they change whenever the code is tidied.
| private | owner(string $src): ?array# | The active plugin (its file) or theme (its folder, true) a script's address is under, or null. @return array{0: string, 1: bool}|null | |||
| private | editors(): array# | @return list<array{plugin: string, theme: string, name: string, action: string, query: string}> | |||
| private | seenWanting(): array# | What noteScripts kept, for the plugins and theme still active, seen in the last thirty days, each named by its header. @return list<array{plugin: string, theme: string, name: string, handles: list<string>, page: string, seen: int}> | |||
| private | wantedWhere(Closure $opens): ?array# |
|
Nothing matches.