mosaic-headless 1.33.1 → 1.33.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/SKILL.md +6 -3
- package/assets/templates/platforms/claude-ai.json +1 -1
- package/assets/templates/platforms/claude-code.json +1 -1
- package/assets/templates/platforms/codex-cli.json +1 -1
- package/assets/templates/platforms/copilot.json +1 -1
- package/assets/templates/platforms/gemini-cli.json +1 -1
- package/package.json +1 -1
- package/references/styling.md +14 -0
- package/references/write-protocol.md +9 -0
- package/tools/build_page.py +14 -0
- package/tools/prune_unbound.php +116 -0
- package/tools/sweep_node_types.py +5 -0
package/README.md
CHANGED
|
@@ -301,6 +301,7 @@ and heading level — and it earned its place at once: it caught the converter l
|
|
|
301
301
|
| `verify_rwd.py` | does every `_t`/`_m` declaration reach the served stylesheet |
|
|
302
302
|
| `verify_intro.py` / `verify_loop.py` | a page-load sequence that ENDS; a perpetual one that loops, hides nothing, and opens |
|
|
303
303
|
| `theme_export.php` / `theme_import.php` | a whole theme as JSON rows over WP-CLI, ids intact |
|
|
304
|
+
| `prune_unbound.php` | clears the templates and masters that page rebuilds leave bound to nothing, with their nodes; dry run unless `--apply` |
|
|
304
305
|
| `theme_zip.py` / `theme_zip_compare.php` / `theme_delete.php` | Mosaic's own ZIP export/import from outside the editor, the copy held against the source, and a clean delete that refuses the live theme |
|
|
305
306
|
| `list_fields.php` | every `@VAR` / `@LOOP` name a post's custom fields register, with values |
|
|
306
307
|
| `verify_dialog.py` | the 1.0.9 modal, triggers, run rules and memory, driven in a browser |
|
package/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: |
|
|
|
5
5
|
license: "MIT"
|
|
6
6
|
metadata:
|
|
7
7
|
author: "moksa (https://moksaweb.com)"
|
|
8
|
-
version: "1.33.
|
|
8
|
+
version: "1.33.3"
|
|
9
9
|
homepage: "https://github.com/Moksa1123/mosaic-headless"
|
|
10
10
|
---
|
|
11
11
|
|
|
@@ -675,7 +675,9 @@ python tools/build_all.py --config sweep.json # reset + build every design
|
|
|
675
675
|
```
|
|
676
676
|
|
|
677
677
|
Rebuilding a single page without a reset leaves an orphan template bound to the same
|
|
678
|
-
post — `build_all.py` resets first for that reason.
|
|
678
|
+
post — `build_all.py` resets first for that reason. `build_site.py` re-binds the post
|
|
679
|
+
to a fresh master and template and leaves the old pair bound to nothing; clear them
|
|
680
|
+
with `tools/prune_unbound.php` (dry run by default) after a batch of rebuilds.
|
|
679
681
|
|
|
680
682
|
## Facts worth knowing before you look anything up
|
|
681
683
|
|
|
@@ -736,7 +738,7 @@ post — `build_all.py` resets first for that reason.
|
|
|
736
738
|
in templates when nginx closed the upstream at five minutes. Pruned to the bound
|
|
737
739
|
set (masters not reached from a bound template, their templates, their nodes)
|
|
738
740
|
the same import took under two minutes and compared 22 of 22. Prune before you
|
|
739
|
-
export; `wp_mosaic_template_assigns.parentID` -> template -> `masterID` is the
|
|
741
|
+
export - `wp eval-file tools/prune_unbound.php <themeID>` counts, `--apply` deletes; `wp_mosaic_template_assigns.parentID` -> template -> `masterID` is the
|
|
740
742
|
bound set, plus any `assign="auto"` template. Then sweep ORPHANS: a probe run
|
|
741
743
|
that half-failed, or a prune that removed a parent, leaves nodes whose parent id
|
|
742
744
|
points at nothing. The export skips them, so the copy is short by exactly those
|
|
@@ -895,6 +897,7 @@ post — `build_all.py` resets first for that reason.
|
|
|
895
897
|
| `theme_export.php` / `theme_import.php` | move a whole theme across installs, ids intact |
|
|
896
898
|
| `theme_zip.py` | drive Mosaic's OWN export/import - the ZIP the editor makes, attachments included, over the milestone protocol; import lands in test mode unless told `--activate` |
|
|
897
899
|
| `theme_zip_compare.php` | hold an imported copy against its source, tree for tree - every scoped table, the (parentType, type) shape, which ids survive, and orphans named rather than counted |
|
|
900
|
+
| `prune_unbound.php` | delete the templates no post is bound to, the masters no kept template uses, their nodes, then orphan nodes pass after pass - one theme, dry run unless `--apply`, `assign="auto"` templates kept |
|
|
898
901
|
| `theme_delete.php` | remove a theme completely through the plugin's own routine; refuses the live one |
|
|
899
902
|
| `verify_slider.py` | the slider in a real browser: does it advance, do the arrows and bullets drive it, does the keyboard, does it stop when motion is not wanted - `--label`/`--append` put several sliders in one table, which is where a carousel and a plain slider can be held against each other |
|
|
900
903
|
| `verify_navigation.py` | a multi-page site: is every menu item a real `<a href>`, does every page answer 200 (a template that was never bound answers 406 with an empty body, which only a logged-out visitor sees), and with `--viewports` does any page scroll SIDEWAYS - the one question no per-page checker asks - and whether every in-page `#fragment` resolves ON THE PAGE THAT CARRIES IT, which an HTTP check cannot see: a bare `#services` in a SHARED header fetches the current page, answers 200 everywhere, and does nothing on every page but the one that has that section |
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.33.
|
|
23
|
+
"version": "1.33.3"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Upload via Settings -> Skills -> Upload. Claude.ai parses SKILL.md frontmatter and surfaces the skill in your library. The extraction tool (extract-block-schema.php) needs a live WP-CLI connection and won't run in the sandbox; use it from a local terminal against your own site instead.",
|
|
26
26
|
"uploadSteps": [
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.33.
|
|
23
|
+
"version": "1.33.3"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Auto-loads on session start when SKILL.md frontmatter parses successfully.",
|
|
26
26
|
"verified": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.33.
|
|
23
|
+
"version": "1.33.3"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "Confirmed (2026-07-11): Codex CLI natively supports the SKILL.md spec. Place SKILL.md under .codex/skills/<name>/ (project) or ~/.codex/skills/<name>/ (personal) and Codex loads the name+description at session start, then the full body on demand. A parallel, broader convention .agents/skills/ (searched from cwd up to repo root, then ~/.agents/skills/) also exists across multiple tools - if your Codex CLI version prioritizes that path instead, mirror the same SKILL.md there.",
|
|
26
26
|
"verified": true,
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.33.
|
|
23
|
+
"version": "1.33.3"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "CHANGED as of 2026-07-11: GitHub Copilot added a proper '.github/skills/' Agent Skills directory (December 2025), alongside the older single-file .github/copilot-instructions.md convention. This config targets the new skills-directory form. If your Copilot version predates this (pre Dec 2025), use the instructions-append fallback instead (see fallback below).",
|
|
26
26
|
"fallback": {
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
"description": "Build and modify Mosaic Pro (Nextend) sites by writing the underlying data model directly - no visual editor, no DOM. Query the real surface (122 node types, 181 node properties, 98 style properties, 53 style states, 151 element classes, 74 dynamic variables, 114 REST routes, 23 tables) instead of guessing, with every node type placed on a live site one at a time and asserted against the delivered HTML, every style and node property swept against the compiled CSS and markup, and 569 responsive declarations checked against the stylesheet the site actually served.",
|
|
21
21
|
"license": "MIT",
|
|
22
22
|
"author": "moksa (https://moksaweb.com)",
|
|
23
|
-
"version": "1.33.
|
|
23
|
+
"version": "1.33.3"
|
|
24
24
|
},
|
|
25
25
|
"loaderBehaviour": "CHANGED as of 2026-07-11: Gemini CLI now natively supports the same SKILL.md standard as Claude Code and Codex CLI - the same directory-based skill works unmodified. Gemini CLI discovers skills in this precedence order: built-in, extension skills, ~/.gemini/skills/ (personal), .gemini/skills/ (project, shared via version control). At session start Gemini injects each discovered skill's name+description into the system prompt and calls activate_skill when a task matches.",
|
|
26
26
|
"verified": true,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mosaic-headless",
|
|
3
|
-
"version": "1.33.
|
|
3
|
+
"version": "1.33.3",
|
|
4
4
|
"description": "AI-agent skill: build Mosaic Pro (Nextend) WordPress sites by writing the underlying data model directly - 23 custom tables, no visual editor, no DOM. Every node type, style property and node property swept against a live install and asserted on the delivered HTML and compiled CSS. Installs into Claude Code, Cursor, Codex CLI, Gemini CLI, Copilot, Continue, Windsurf and Claude.ai.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wordpress",
|
package/references/styling.md
CHANGED
|
@@ -230,6 +230,20 @@ dropped, which is the only reason they cost minutes instead of a debugging sessi
|
|
|
230
230
|
— a property that is not in the registry cannot be set at all, and Mosaic's own
|
|
231
231
|
API accepts the write and discards it.
|
|
232
232
|
|
|
233
|
+
## `fontFamily` takes a plain family list, nothing else
|
|
234
|
+
|
|
235
|
+
`ValidatorStyleFontFamily` (NEXT-5841) accepts quoted names and unquoted identifier
|
|
236
|
+
runs joined by commas — `"Noto Sans TC", sans-serif`, `system-ui, -apple-system` — or
|
|
237
|
+
a font variable `{"var": id}`. `var(--x)`, any function, or a tab / newline between
|
|
238
|
+
names is not a family list. The commit accepts it, stored data loads without
|
|
239
|
+
validation, and `CSSFontFamilyPropertyFactory` then drops it: no rule, no error, the
|
|
240
|
+
element just inherits. A CSS custom property for the font goes in
|
|
241
|
+
`customDeclarations` (`font-family: var(--x);`). `build_page.py` refuses the bad
|
|
242
|
+
string.
|
|
243
|
+
|
|
244
|
+
`fontWeight` is the enum `100`…`900` only — no `bold`, `bolder`, `normal`; the
|
|
245
|
+
builder refuses those like any other enum miss.
|
|
246
|
+
|
|
233
247
|
## Gradient stops take units (1.0.10)
|
|
234
248
|
|
|
235
249
|
A gradient's `dots[].position` - background and mask alike - used to be a bare float
|
|
@@ -20,6 +20,15 @@ All 114 routes are in `data/rest-routes.csv`; the namespace is
|
|
|
20
20
|
the base URL changes on every Mosaic update. Read it from `mosaicOptions.rest_api_url`
|
|
21
21
|
on any Mosaic admin page rather than composing it yourself.
|
|
22
22
|
|
|
23
|
+
**Mosaic → Settings is the one instance outside the theme:**
|
|
24
|
+
`/mosaic/v<version>/settingsEditorInstance` (+ `/checkout`, `/check`, `/commit`), with
|
|
25
|
+
no `theme/<themeID>/` in the path. `Client.get()` and `Client.commit()` always prefix
|
|
26
|
+
the theme, so they 404 on it; read it with `Client.api_get("settingsEditorInstance")`
|
|
27
|
+
and commit to the same un-prefixed path. Its `scriptsInline` switch inlines only the
|
|
28
|
+
component scripts (accordion, dropdown, navbar, form, slider, dialog — each
|
|
29
|
+
`*ElementMResource` asks `MosaicSettings::isScriptsInlineAllowed()`); `Frontend.js`
|
|
30
|
+
still loads as a file.
|
|
31
|
+
|
|
23
32
|
## The envelopes
|
|
24
33
|
|
|
25
34
|
Both `checkout` and `check` take one required string parameter, `syncCheckEnvelopes`
|
package/tools/build_page.py
CHANGED
|
@@ -251,6 +251,12 @@ class Surface:
|
|
|
251
251
|
for p, value in props.items():
|
|
252
252
|
if p not in self.style_props and p not in shorthands:
|
|
253
253
|
problems.append("%r is not a supported style property (on %s)" % (p, t))
|
|
254
|
+
if (p == "fontFamily" and isinstance(value, str)
|
|
255
|
+
and not FONT_FAMILY_LIST.match(value.strip(" \t\n\r\f"))):
|
|
256
|
+
problems.append("fontFamily=%r is not a plain family list - Mosaic "
|
|
257
|
+
"drops it without a rule (NEXT-5841); use a font "
|
|
258
|
+
"variable {\"var\": id}, or customDeclarations for "
|
|
259
|
+
"var(--x) (on %s)" % (value, t))
|
|
254
260
|
allowed = self.style_enums.get(p)
|
|
255
261
|
if allowed and isinstance(value, str) and value not in allowed:
|
|
256
262
|
problems.append("%s=%r is not one of %s (on %s)"
|
|
@@ -265,6 +271,14 @@ class Surface:
|
|
|
265
271
|
|
|
266
272
|
# A fixed namespace, so a design token's row ID is a function of its name alone and
|
|
267
273
|
# a rebuild rebinds the same row instead of adding a second one.
|
|
274
|
+
# ValidatorStyleFontFamily.php (NEXT-5841): quoted names and unquoted identifier
|
|
275
|
+
# runs, joined by commas with spaces only. Anything else - var(), a function, a tab
|
|
276
|
+
# or newline between names - is dropped at compile time with no error.
|
|
277
|
+
_FF_UNQUOTED = r"[\w-]+(?: +[\w-]+)*"
|
|
278
|
+
_FF_NAME = (r"(?:\"[^\"\\<;{}\x00-\x1f\x7f]+\"|'[^'\\<;{}\x00-\x1f\x7f]+'|"
|
|
279
|
+
+ _FF_UNQUOTED + ")")
|
|
280
|
+
FONT_FAMILY_LIST = re.compile(r"^" + _FF_NAME + r"(?: *, *" + _FF_NAME + r")*$")
|
|
281
|
+
|
|
268
282
|
VAR_NAMESPACE = uuid.UUID("6d6f7361-6963-4865-6164-6c657373ff01")
|
|
269
283
|
VAR_IDS = {}
|
|
270
284
|
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
<?php
|
|
2
|
+
/**
|
|
3
|
+
* Remove the templates and masters no post is bound to, and the nodes under them.
|
|
4
|
+
*
|
|
5
|
+
* wp eval-file prune_unbound.php <themeID> # dry run: counts only
|
|
6
|
+
* wp eval-file prune_unbound.php <themeID> --apply # delete
|
|
7
|
+
*
|
|
8
|
+
* Every build_site.py / build_page.py run makes a fresh master and template and
|
|
9
|
+
* re-binds the post to them; the previous pair stays behind, bound to nothing.
|
|
10
|
+
* On the test theme that grew to 1,028 templates and 440k nodes with 75 templates
|
|
11
|
+
* actually in use, and Mosaic's own ZIP export of a theme that size dies at the
|
|
12
|
+
* nginx timeout. There is no REST route that deletes a template, so this is SQL.
|
|
13
|
+
*
|
|
14
|
+
* What is KEPT, in one theme only:
|
|
15
|
+
* - every template a row of wp_mosaic_template_assigns points at
|
|
16
|
+
* - every template with assign="auto" (fallbacks, condition-matched templates,
|
|
17
|
+
* the sweep's own Sweep Home) - they are bound by conditions, not assigns
|
|
18
|
+
* - every master a kept template uses
|
|
19
|
+
* Everything else of type template / master goes, with its nodes. Then nodes whose
|
|
20
|
+
* parent node no longer exists are removed pass after pass until none are left,
|
|
21
|
+
* because each pass orphans the next level down.
|
|
22
|
+
*
|
|
23
|
+
* Back up first - this has no undo:
|
|
24
|
+
* wp db export pre-prune.sql --tables=$(wp db tables "wp_mosaic_*" --all-tables --format=csv)
|
|
25
|
+
* (`wp db tables` without --all-tables finds no wp_mosaic_* tables: they are not
|
|
26
|
+
* registered with $wpdb.) Purge the page cache afterwards and fetch every bound page.
|
|
27
|
+
*/
|
|
28
|
+
$args = isset($args) ? $args : [];
|
|
29
|
+
$id = isset($args[0]) ? trim($args[0]) : '';
|
|
30
|
+
$apply = in_array('--apply', $args, true);
|
|
31
|
+
|
|
32
|
+
if (!preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i', $id)) {
|
|
33
|
+
WP_CLI::error('usage: wp eval-file prune_unbound.php <themeID> [--apply]');
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
global $wpdb;
|
|
37
|
+
$p = $wpdb->prefix;
|
|
38
|
+
if (!$wpdb->get_var($wpdb->prepare("SELECT ID FROM {$p}mosaic_themes WHERE ID = %s", $id))) {
|
|
39
|
+
WP_CLI::error("no theme $id");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
$unboundTemplates = $wpdb->get_col($wpdb->prepare(
|
|
43
|
+
"SELECT t.ID FROM {$p}mosaic_templates t
|
|
44
|
+
WHERE t.themeID = %s AND t.assign <> 'auto'
|
|
45
|
+
AND t.ID NOT IN (SELECT parentID FROM {$p}mosaic_template_assigns WHERE parentType = 'template')",
|
|
46
|
+
$id));
|
|
47
|
+
$unusedMasters = $wpdb->get_col($wpdb->prepare(
|
|
48
|
+
"SELECT m.ID FROM {$p}mosaic_masters m
|
|
49
|
+
WHERE m.themeID = %s
|
|
50
|
+
AND m.ID NOT IN (SELECT masterID FROM {$p}mosaic_templates
|
|
51
|
+
WHERE themeID = %s AND (assign = 'auto'
|
|
52
|
+
OR ID IN (SELECT parentID FROM {$p}mosaic_template_assigns WHERE parentType = 'template')))",
|
|
53
|
+
$id, $id));
|
|
54
|
+
|
|
55
|
+
$count = function ($type, $ids) use ($wpdb, $p, $id) {
|
|
56
|
+
$n = 0;
|
|
57
|
+
foreach (array_chunk($ids, 500) as $chunk) {
|
|
58
|
+
$in = implode(',', array_fill(0, count($chunk), '%s'));
|
|
59
|
+
$n += (int)$wpdb->get_var($wpdb->prepare(
|
|
60
|
+
"SELECT COUNT(*) FROM {$p}mosaic_nodes WHERE themeID = %s AND documentType = %s AND documentID IN ($in)",
|
|
61
|
+
array_merge([$id, $type], $chunk)));
|
|
62
|
+
}
|
|
63
|
+
return $n;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
$kept = (int)$wpdb->get_var($wpdb->prepare("SELECT COUNT(*) FROM {$p}mosaic_templates WHERE themeID = %s", $id))
|
|
67
|
+
- count($unboundTemplates);
|
|
68
|
+
WP_CLI::log(sprintf('templates: %d unbound, %d kept', count($unboundTemplates), $kept));
|
|
69
|
+
WP_CLI::log(sprintf('masters: %d unused', count($unusedMasters)));
|
|
70
|
+
WP_CLI::log(sprintf('nodes: %d under those templates, %d under those masters',
|
|
71
|
+
$count('template', $unboundTemplates), $count('master', $unusedMasters)));
|
|
72
|
+
|
|
73
|
+
if (!$apply) {
|
|
74
|
+
$orphans = (int)$wpdb->get_var($wpdb->prepare(
|
|
75
|
+
"SELECT COUNT(*) FROM {$p}mosaic_nodes n LEFT JOIN {$p}mosaic_nodes q ON q.ID = n.parentID
|
|
76
|
+
WHERE n.themeID = %s AND n.parentType = 'node' AND q.ID IS NULL", $id));
|
|
77
|
+
WP_CLI::log("orphan nodes already present: $orphans");
|
|
78
|
+
WP_CLI::success('dry run - nothing deleted. Back up, then re-run with --apply');
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
$delete = function ($table, $type, $ids) use ($wpdb, $p, $id) {
|
|
83
|
+
$nodes = $rows = 0;
|
|
84
|
+
foreach (array_chunk($ids, 500) as $chunk) {
|
|
85
|
+
$in = implode(',', array_fill(0, count($chunk), '%s'));
|
|
86
|
+
$nodes += (int)$wpdb->query($wpdb->prepare(
|
|
87
|
+
"DELETE FROM {$p}mosaic_nodes WHERE themeID = %s AND documentType = %s AND documentID IN ($in)",
|
|
88
|
+
array_merge([$id, $type], $chunk)));
|
|
89
|
+
$rows += (int)$wpdb->query($wpdb->prepare(
|
|
90
|
+
"DELETE FROM {$p}mosaic_{$table} WHERE themeID = %s AND ID IN ($in)",
|
|
91
|
+
array_merge([$id], $chunk)));
|
|
92
|
+
}
|
|
93
|
+
return [$rows, $nodes];
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
// nodes first, so a failure part-way never leaves a document row with half its tree
|
|
97
|
+
[$t, $tn] = $delete('templates', 'template', $unboundTemplates);
|
|
98
|
+
[$m, $mn] = $delete('masters', 'master', $unusedMasters);
|
|
99
|
+
|
|
100
|
+
$orphans = 0;
|
|
101
|
+
do {
|
|
102
|
+
// MariaDB cannot DELETE from a table it is also reading in a subquery; a JOIN it can
|
|
103
|
+
$n = (int)$wpdb->query($wpdb->prepare(
|
|
104
|
+
"DELETE n FROM {$p}mosaic_nodes n LEFT JOIN {$p}mosaic_nodes q ON q.ID = n.parentID
|
|
105
|
+
WHERE n.themeID = %s AND n.parentType = 'node' AND q.ID IS NULL", $id));
|
|
106
|
+
$orphans += $n;
|
|
107
|
+
} while ($n > 0);
|
|
108
|
+
|
|
109
|
+
$dangling = (int)$wpdb->get_var($wpdb->prepare(
|
|
110
|
+
"SELECT COUNT(*) FROM {$p}mosaic_templates t LEFT JOIN {$p}mosaic_masters m ON m.ID = t.masterID
|
|
111
|
+
WHERE t.themeID = %s AND m.ID IS NULL", $id));
|
|
112
|
+
WP_CLI::log("deleted: $t templates ($tn nodes), $m masters ($mn nodes), $orphans orphan nodes");
|
|
113
|
+
if ($dangling) {
|
|
114
|
+
WP_CLI::error("$dangling kept templates point at a master that is gone - restore the backup");
|
|
115
|
+
}
|
|
116
|
+
WP_CLI::success('pruned. Purge the page cache and fetch every bound page');
|
|
@@ -86,6 +86,11 @@ class Client:
|
|
|
86
86
|
def get(self, tail):
|
|
87
87
|
return self._call(self.theme_url(tail))
|
|
88
88
|
|
|
89
|
+
def api_get(self, tail):
|
|
90
|
+
"""A route outside the theme, e.g. `settingsEditorInstance` (Mosaic → Settings),
|
|
91
|
+
which lives at /mosaic/v<version>/ and 404s under /theme/<id>/."""
|
|
92
|
+
return self._call("%s/%s" % (self.api, tail))
|
|
93
|
+
|
|
89
94
|
def commit(self, tail, sync, revisions):
|
|
90
95
|
return self._call(
|
|
91
96
|
self.theme_url(tail + "/commit"),
|