Skip to content

Commit 9e78a97

Browse files
committed
Merge branch 'develop' into fix/3736-wp7-text-alignment
2 parents 752fdb0 + 3154353 commit 9e78a97

377 files changed

Lines changed: 27846 additions & 15973 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎.cursor/rules/anti-slop.mdc‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
---
2+
description: Maintainability and anti-slop standards when changing Stackable code
3+
alwaysApply: true
4+
---
5+
6+
# Maintainability & anti-slop
7+
8+
Prefer deepening existing seams over inventing parallel structure. Goal: one place to change a behaviour; freemium gates and shared heuristics stay single-sourced.
9+
10+
## Before you paste
11+
12+
When adding or extending behaviour, check the nearest sibling first. If the change would clone a block (block registration wiring, block-component prop patterns, inspector panel pairs, style generators, upsell/pricing URL builders, `STACKABLE_BUILD` gates), extract or reuse a shared helper **before** adding the nth copy.
13+
14+
## Deepen, don't layer
15+
16+
Keep the runtime spine:
17+
18+
- **Blocks:** `src/block/<name>/` → shared `src/block-components/` / `src/components/` / `src/higher-order/` → style generation
19+
- **Editor plugins / global settings:** `src/plugins/` and related PHP options / localize
20+
- **Frontend behaviour:** block `frontend.js` / shared frontend modules, not a second ad-hoc script beside an existing enqueue
21+
- **Freemium:** free tree + `STACKABLE_BUILD` gates; premium only under `pro__premium_only/`
22+
23+
New behaviour goes into an existing module cluster (block, block-component, plugin, util, premium module) when one fits. Do not add a second block-registration path, parallel style generator, or ad-hoc AJAX twin beside an existing REST route without an explicit extract.
24+
25+
God-file rule of thumb: prefer extracting a coherent cluster over growing a fat edit.js, a catch-all util, or a PHP admin class with another pasted case.
26+
27+
## Single source for shared heuristics
28+
29+
Heuristics that exist on both PHP and JS (settings defaults, "is premium" flags, pricing/upsell URLs, block attribute defaults) share one definition of truth - localized data, shared module, or a documented sync. Do not hand-sync a second map "for convenience."
30+
31+
Ship or silence: do not advertise a premium feature or setting in free UI/copy unless the free build truly exposes it (or clearly marks it as premium upsell).
32+
33+
## Completion check
34+
35+
Before finishing a change that adds a block, attribute, inspector control, style rule, or freemium gate: every list/map/UI/REST surface that must know about it is updated, no phantom options remain, and no new duplicate helper was introduced beside an existing one. Keep premium logic out of the free tree.

‎.cursor/rules/javascript-react.mdc‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
---
2+
description: Stackable uses plain JavaScript; React for editor/admin, view scripts for frontend
3+
alwaysApply: true
4+
---
5+
6+
# JavaScript & React
7+
8+
Stackable uses **regular JavaScript** (`.js`), not TypeScript, for plugin UI and runtime code. Do not add `.ts` / `.tsx` source files outside e2e tests (`e2e/**/*.ts` is fine).
9+
10+
## Main JS surfaces
11+
12+
1. **Block editor & plugins** (primary product UI) - **React** via `@wordpress/element` under `src/block/`, `src/block-components/`, `src/components/`, `src/plugins/`, and related editor modules.
13+
2. **Admin / welcome** - React or WordPress admin UI under `src/welcome/` and settings surfaces.
14+
3. **Frontend / view scripts** - lighter JS for saved markup behaviour (accordions, carousels, lightbox, etc.). Prefer deepening existing frontend modules over new global scripts.
15+
16+
Prefer putting interactive editor logic in shared modules (`block-components`, `components`, `hooks`, `util`). PHP should register blocks, enqueue assets, REST/AJAX, and capability gates - not reimplement editor UI in PHP.
17+
18+
## React (editor / admin UI)
19+
20+
- Build UI with **React** via `@wordpress/element` (WordPress's React wrapper).
21+
- Use JSX inside `.js` files (wp-scripts / webpack handles transpilation).
22+
- Prefer WordPress packages (`@wordpress/element`, `@wordpress/components`, `@wordpress/i18n`, `@wordpress/block-editor`, `@wordpress/data`, `@wordpress/hooks`, etc.) over adding a separate `react` / `react-dom` dependency when WordPress already provides them.
23+
- Text domain: `stackable-ultimate-gutenberg-blocks` (`STACKABLE_I18N`).
24+
- Freemium UI extensions use `applyFilters( 'stackable.…' )` so premium can swap/inject components without putting premium logic in the free tree.
25+
26+
## Import alias
27+
28+
- Use the `~stackable` alias (maps to `src/`) for cross-folder imports, e.g. `~stackable/components`, `~stackable/block-components`.
29+
30+
## Blocks & shared UI
31+
32+
- New blocks deepen `src/block/<name>/` and reuse `src/block-components/` rather than forking one-off inspector/style paths.
33+
- Keep reusable editor controls in `src/components/` or `src/block-components/`; keep block-specific markup/edit/save in the block folder.

‎.cursor/rules/project-repos.mdc‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,19 @@ This project has two GitHub repositories, used depending on whether we're buildi
1717
### Free version
1818

1919
- Main plugin repo: https://github.com/gambitph/Stackable
20+
- Contains **only** free plugin code and must remain free of premium logic (WordPress.org guidelines).
21+
- Must pass [WordPress Plugin Check](https://github.com/wordpress/plugin-check) for Plugin Directory inclusion (see `wordpress-plugin-check` rule).
2022

2123
### Premium version
2224

2325
- Uses the free version as the main plugin repo, and additionally uses:
2426
- Premium-only repo: https://github.com/bfintal/Stackable-Premium
2527
- The premium repo contains **only** the premium plugin code.
2628
- It is placed in the `pro__premium_only` directory inside the free plugin's root folder.
29+
30+
## Free / Premium boundaries
31+
32+
- Do not put premium feature logic in the free repo.
33+
- Premium code lives exclusively under `pro__premium_only/`.
34+
- The free plugin may gate-load premium via `STACKABLE_BUILD === 'premium'` and `pro__premium_only/index.php` (with Freemius `sugb_fs()->is__premium_only()`).
35+
- When packaging the free build, `pro__premium_only` must not be included.
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
description: Free plugin must pass WordPress Plugin Check for directory submission
3+
alwaysApply: true
4+
---
5+
6+
# WordPress Plugin Directory & Plugin Check
7+
8+
The **free** Stackable plugin is intended for the [WordPress Plugin Directory](https://wordpress.org/plugins/stackable-ultimate-gutenberg-blocks/). Directory inclusion requires meeting WordPress.org plugin guidelines.
9+
10+
## Official checker
11+
12+
Use **[WordPress/plugin-check](https://github.com/wordpress/plugin-check)** (Plugin Check / PCP) as the compliance bar:
13+
14+
- Static + runtime checks for directory requirements and best practices
15+
- WP Admin: **Tools → Plugin Check**
16+
- WP-CLI: `wp plugin check <plugin>` (add `--require=…/plugin-check/cli.php` for runtime checks)
17+
- Also: [wordpress.org/plugins/plugin-check](https://wordpress.org/plugins/plugin-check/)
18+
19+
## What this means for Stackable
20+
21+
- Free-repo code and the free build zip should be written to **pass Plugin Check**.
22+
- Prefer WordPress coding / security / i18n / enqueue practices that PCP enforces (escaping, nonces, capability checks, no forbidden APIs, proper headers, etc.).
23+
- Do not ship premium-only code, `pro__premium_only/`, or directory-disallowed patterns in the free package.
24+
- When changing free-plugin PHP, assets, or packaging, keep Plugin Check green in mind - fix regressions rather than silencing them without cause.
25+
26+
Premium code under `pro__premium_only/` is out of scope for Directory submission, but anything that lands in the **free** tree or free zip is in scope.
27+
28+
Skill for deeper guideline review: `.cursor/skills/wp-plugin-directory-guidelines/`.
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
---
2+
name: code-review
3+
description: Review the changes since a fixed point (commit, branch, tag, or merge-base) along two axes — Standards (does the code follow this repo's documented coding standards?) and Spec (does the code match what the originating issue/spec asked for?). Runs both reviews in parallel sub-agents and reports them side by side. Use when the user wants to review a branch, a PR, work-in-progress changes, or asks to "review since X".
4+
---
5+
6+
Two-axis review of the diff between `HEAD` and a fixed point the user supplies:
7+
8+
- **Standards** — does the code conform to this repo's documented coding standards?
9+
- **Spec** — does the code faithfully implement the originating issue / spec?
10+
11+
Both axes run as **parallel sub-agents** so they don't pollute each other's context, then this skill aggregates their findings.
12+
13+
The issue tracker should have been provided to you — run `/setup-matt-pocock-skills` if `docs/agents/issue-tracker.md` is missing.
14+
15+
## Process
16+
17+
### 1. Pin the fixed point
18+
19+
Whatever the user said is the fixed point — a commit SHA, branch name, tag, `main`, `HEAD~5`, etc. If they didn't specify one, ask for it.
20+
21+
Capture the diff command once: `git diff <fixed-point>...HEAD` (three-dot, so the comparison is against the merge-base). Also note the list of commits via `git log <fixed-point>..HEAD --oneline`.
22+
23+
Before going further, confirm the fixed point resolves (`git rev-parse <fixed-point>`) and the diff is non-empty. A bad ref or empty diff should fail here — not inside two parallel sub-agents.
24+
25+
### 2. Identify the spec source
26+
27+
Look for the originating spec, in this order:
28+
29+
1. Issue references in the commit messages (`#123`, `Closes #45`, GitLab `!67`, etc.) — fetch via the workflow in `docs/agents/issue-tracker.md`.
30+
2. A path the user passed as an argument.
31+
3. A spec file under `docs/`, `specs/`, or `.scratch/` matching the branch name or feature.
32+
4. If nothing is found, ask the user where the spec is. If they say there isn't one, the **Spec** sub-agent will skip and report "no spec available".
33+
34+
### 3. Identify the standards sources
35+
36+
Anything in the repo that documents how code should be written, such as `CODING_STANDARDS.md` or `CONTRIBUTING.md`.
37+
38+
On top of whatever the repo documents, the Standards axis always carries the **smell baseline** below — a fixed set of Fowler code smells (_Refactoring_, ch.3) that applies even when a repo documents nothing. Two rules bind it:
39+
40+
- **The repo overrides.** A documented repo standard always wins; where it endorses something the baseline would flag, suppress the smell.
41+
- **Always a judgement call.** Each smell is a labelled heuristic ("possible Feature Envy"), never a hard violation — and, like any standard here, skip anything tooling already enforces.
42+
43+
Each smell reads *what it is* → *how to fix*; match it against the diff:
44+
45+
- **Mysterious Name** — a function, variable, or type whose name doesn't reveal what it does or holds. → rename it; if no honest name comes, the design's murky.
46+
- **Duplicated Code** — the same logic shape appears in more than one hunk or file in the change. → extract the shared shape, call it from both.
47+
- **Feature Envy** — a method that reaches into another object's data more than its own. → move the method onto the data it envies.
48+
- **Data Clumps** — the same few fields or params keep travelling together (a type wanting to be born). → bundle them into one type, pass that.
49+
- **Primitive Obsession** — a primitive or string standing in for a domain concept that deserves its own type. → give the concept its own small type.
50+
- **Repeated Switches** — the same `switch`/`if`-cascade on the same type recurs across the change. → replace with polymorphism, or one map both sites share.
51+
- **Shotgun Surgery** — one logical change forces scattered edits across many files in the diff. → gather what changes together into one module.
52+
- **Divergent Change** — one file or module is edited for several unrelated reasons. → split so each module changes for one reason.
53+
- **Speculative Generality** — abstraction, parameters, or hooks added for needs the spec doesn't have. → delete it; inline back until a real need shows.
54+
- **Message Chains** — long `a.b().c().d()` navigation the caller shouldn't depend on. → hide the walk behind one method on the first object.
55+
- **Middle Man** — a class or function that mostly just delegates onward. → cut it, call the real target direct.
56+
- **Refused Bequest** — a subclass or implementer that ignores or overrides most of what it inherits. → drop the inheritance, use composition.
57+
58+
### 4. Spawn both sub-agents in parallel
59+
60+
**Standards sub-agent prompt** — include:
61+
62+
- The full diff command and commit list.
63+
- The list of standards-source files you found in step 3, **plus the smell baseline from step 3** pasted in full — the sub-agent has no other access to it.
64+
- The brief: "Report — per file/hunk where relevant — (a) every place the diff violates a documented standard: cite the standard (file + the rule); and (b) any baseline smell you spot: name it and quote the hunk. Distinguish hard violations from judgement calls — documented-standard breaches can be hard, but baseline smells are always judgement calls, and a documented repo standard overrides the baseline. Skip anything tooling enforces. Under 400 words."
65+
66+
**Spec sub-agent prompt** — include:
67+
68+
- The diff command and commit list.
69+
- The path or fetched contents of the spec.
70+
- The brief: "Report: (a) requirements the spec asked for that are missing or partial; (b) behaviour in the diff that wasn't asked for (scope creep); (c) requirements that look implemented but where the implementation looks wrong. Quote the spec line for each finding. Under 400 words."
71+
72+
If the spec is missing, skip the Spec sub-agent and note this in the final report.
73+
74+
### 5. Aggregate
75+
76+
Present the two reports under `## Standards` and `## Spec` headings, verbatim or lightly cleaned. Do **not** merge or rerank findings — the two axes are deliberately separate (see _Why two axes_).
77+
78+
End with a one-line summary: total findings per axis, and the worst issue _within each axis_ (if any). Don't pick a single winner across axes — that's the reranking the separation exists to prevent.
79+
80+
## Why two axes
81+
82+
A change can pass one axis and fail the other:
83+
84+
- Code that follows every standard but implements the wrong thing → **Standards pass, Spec fail.**
85+
- Code that does exactly what the issue asked but breaks the project's conventions → **Spec pass, Standards fail.**
86+
87+
Reporting them separately stops one axis from masking the other.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
interface:
2+
display_name: "Code Review"
3+
short_description: "Review a diff on standards and spec"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Deepening
2+
3+
How to deepen a cluster of shallow modules safely, given its dependencies. Assumes the vocabulary in [SKILL.md](SKILL.md) — **module**, **interface**, **seam**, **adapter**.
4+
5+
## Dependency categories
6+
7+
When assessing a candidate for deepening, classify its dependencies. The category determines how the deepened module is tested across its seam.
8+
9+
### 1. In-process
10+
11+
Pure computation, in-memory state, no I/O. Always deepenable — merge the modules and test through the new interface directly. No adapter needed.
12+
13+
### 2. Local-substitutable
14+
15+
Dependencies that have local test stand-ins (PGLite for Postgres, in-memory filesystem). Deepenable if the stand-in exists. The deepened module is tested with the stand-in running in the test suite. The seam is internal; no port at the module's external interface.
16+
17+
### 3. Remote but owned (Ports & Adapters)
18+
19+
Your own services across a network boundary (microservices, internal APIs). Define a **port** (interface) at the seam. The deep module owns the logic; the transport is injected as an **adapter**. Tests use an in-memory adapter. Production uses an HTTP/gRPC/queue adapter.
20+
21+
Recommendation shape: *"Define a port at the seam, implement an HTTP adapter for production and an in-memory adapter for testing, so the logic sits in one deep module even though it's deployed across a network."*
22+
23+
### 4. True external (Mock)
24+
25+
Third-party services (Stripe, Twilio, etc.) you don't control. The deepened module takes the external dependency as an injected port; tests provide a mock adapter.
26+
27+
## Seam discipline
28+
29+
- **One adapter means a hypothetical seam. Two adapters means a real one.** Don't introduce a port unless at least two adapters are justified (typically production + test). A single-adapter seam is just indirection.
30+
- **Internal seams vs external seams.** A deep module can have internal seams (private to its implementation, used by its own tests) as well as the external seam at its interface. Don't expose internal seams through the interface just because tests use them.
31+
32+
## Testing strategy: replace, don't layer
33+
34+
- Old unit tests on shallow modules become waste once tests at the deepened module's interface exist — delete them.
35+
- Write new tests at the deepened module's interface. The **interface is the test surface**.
36+
- Tests assert on observable outcomes through the interface, not internal state.
37+
- Tests should survive internal refactors — they describe behaviour, not implementation. If a test has to change when the implementation changes, it's testing past the interface.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Design It Twice
2+
3+
When the user wants to explore alternative interfaces for a chosen deepening candidate, use this parallel sub-agent pattern. Based on "Design It Twice" (Ousterhout) — your first idea is unlikely to be the best.
4+
5+
Uses the vocabulary in [SKILL.md](SKILL.md) — **module**, **interface**, **seam**, **adapter**, **leverage**.
6+
7+
## Process
8+
9+
### 1. Frame the problem space
10+
11+
Before spawning sub-agents, write a user-facing explanation of the problem space for the chosen candidate:
12+
13+
- The constraints any new interface would need to satisfy
14+
- The dependencies it would rely on, and which category they fall into (see [DEEPENING.md](DEEPENING.md))
15+
- A rough illustrative code sketch to ground the constraints — not a proposal, just a way to make the constraints concrete
16+
17+
Show this to the user, then immediately proceed to Step 2. The user reads and thinks while the sub-agents work in parallel.
18+
19+
### 2. Spawn sub-agents
20+
21+
Spawn 3+ sub-agents in parallel. Each must produce a **radically different** interface for the deepened module.
22+
23+
Prompt each sub-agent with a separate technical brief (file paths, coupling details, dependency category from [DEEPENING.md](DEEPENING.md), what sits behind the seam). The brief is independent of the user-facing problem-space explanation in Step 1. Give each agent a different design constraint:
24+
25+
- Agent 1: "Minimize the interface — aim for 1–3 entry points max. Maximise leverage per entry point."
26+
- Agent 2: "Maximise flexibility — support many use cases and extension."
27+
- Agent 3: "Optimise for the most common caller — make the default case trivial."
28+
- Agent 4 (if applicable): "Design around ports & adapters for cross-seam dependencies."
29+
30+
Include both [SKILL.md](SKILL.md) vocabulary and CONTEXT.md vocabulary in the brief so each sub-agent names things consistently with the architecture language and the project's domain language.
31+
32+
Each sub-agent outputs:
33+
34+
1. Interface (types, methods, params — plus invariants, ordering, error modes)
35+
2. Usage example showing how callers use it
36+
3. What the implementation hides behind the seam
37+
4. Dependency strategy and adapters (see [DEEPENING.md](DEEPENING.md))
38+
5. Trade-offs — where leverage is high, where it's thin
39+
40+
### 3. Present and compare
41+
42+
Present designs sequentially so the user can absorb each one, then compare them in prose. Contrast by **depth** (leverage at the interface), **locality** (where change concentrates), and **seam placement**.
43+
44+
After comparing, give your own recommendation: which design you think is strongest and why. If elements from different designs would combine well, propose a hybrid. Be opinionated — the user wants a strong read, not a menu.

0 commit comments

Comments
 (0)