diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 3b03b31..462dedd 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -23,7 +23,7 @@ npm install # Install Node dev dependencies (@wordpress/scripts, stan - **Main file**: `plugin.php` - Entry point with template registration and ACF JSON configuration - **Functions**: Split into `lib/functions/general.php` (block bindings, search variations) and `lib/functions/settings.php` (admin settings page) - **Templates**: `lib/templates/` contains block-based templates for single funds and taxonomy archives -- **Template Parts**: `lib/templates/parts/` contains reusable template partials (`funds-search.php`, `post-query-funds.php`, `post-query.php`) +- **Template Parts**: `lib/templates/parts/` contains reusable template partials (`funds-search.php`, `post-query-funds.php`), pulled in with `__DIR__`-relative `require` - **Styles**: `lib/css/admin-settings.css` - Admin settings page styles - **ACF Configuration**: `acf-json/` directory stores Advanced Custom Fields configuration as JSON diff --git a/CLAUDE.md b/CLAUDE.md index 213411a..724eb0e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -60,7 +60,7 @@ So the same URL is computed by two different paths — `ucscgiving_fund_url()` f `lib/templates/*.php` are block-comment markup (``) with a couple of `require` statements, not PHP source. They are read through `ucscgiving_get_template_content()` (output buffering) and handed to `register_block_template()` in `plugin.php`. Two consequences: -- The `require 'parts/…'` calls inside them use **relative paths**, which resolve only because PHP falls back to the calling file's directory. Fragile — prefer `__DIR__` if touching them. +- The `require __DIR__ . '/parts/…'` calls inside them are explicitly rooted. Keep them that way — they were relative paths until #134, resolving only because PHP falls back to the calling file's directory. - PHPCS file-docblock sniffs are excluded for `lib/templates/` in `.phpcs.xml.dist`, since a file docblock there is meaningless. ## Conventions diff --git a/ROADMAP.md b/ROADMAP.md index 3b9f05d..823006c 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -92,7 +92,22 @@ The suite covers functions that are pure once WordPress is stubbed. Anything nee ## 4. Harden packaging and templates -- **Relative `require` in block templates.** `lib/templates/*.php` use `require 'parts/…'`, which resolves only because PHP falls back to the calling file's directory. Change to `__DIR__`-relative paths. Low effort, removes a latent break. +- ~~**Relative `require` in block templates.**~~ Done in [#134](https://github.com/ucsc/ucsc-giving-functionality/issues/134) — both calls are now `__DIR__`-rooted, and the unused `parts/post-query.php` was removed with them. +- **Template composition is split two ways.** *Needs a look before anything is decided.* + + | Template | Lines | Composition | + |---|---|---| + | `taxonomy-fund-type.php` | 11 | `require`s `parts/funds-search.php` + `parts/post-query-funds.php` | + | `taxonomy-fund-theme.php` | 11 | same | + | `taxonomy-area.php` | 74 | fully inlined | + | `taxonomy-keyword.php` | 74 | fully inlined | + | `archive-fund.php` | 74 | fully inlined | + | `single-fund.php` | 30 | fully inlined | + + The two inlined taxonomy templates are near-identical to each other, so there is real duplication: a change to the archive layout currently has to be made in both, and neither picks up edits to `parts/`. Converting them to the parts pattern would remove that, but it changes rendered markup and needs visual QA, so it is not a mechanical cleanup. + + Worth noting the two are entangled: the inlined templates are also the ones carrying the hardcoded production media ([#133](https://github.com/ucsc/ucsc-giving-functionality/issues/133)) and the unpinned template-part references ([#136](https://github.com/ucsc/ucsc-giving-functionality/issues/136)). Whoever picks up the composition question should look at all three together rather than in isolation. + - **Single URL-construction path.** `ucscgiving_fund_url()` (block binding) and `ucscgiving_link_filter()` (permalink) build the same URL independently. Extract one helper so they cannot diverge. Both now have characterization tests (§3), so the extraction can be made and shown to preserve behavior — this is the cheapest remaining item. ## 5. Maintenance diff --git a/lib/templates/parts/post-query.php b/lib/templates/parts/post-query.php deleted file mode 100644 index 799ccef..0000000 --- a/lib/templates/parts/post-query.php +++ /dev/null @@ -1,23 +0,0 @@ - -
- -
- - - - - - - -
- - - - - - - - - -
- \ No newline at end of file diff --git a/lib/templates/taxonomy-fund-theme.php b/lib/templates/taxonomy-fund-theme.php index 352a1bc..84cd391 100644 --- a/lib/templates/taxonomy-fund-theme.php +++ b/lib/templates/taxonomy-fund-theme.php @@ -4,8 +4,8 @@
- - + +
diff --git a/lib/templates/taxonomy-fund-type.php b/lib/templates/taxonomy-fund-type.php index 352a1bc..84cd391 100644 --- a/lib/templates/taxonomy-fund-type.php +++ b/lib/templates/taxonomy-fund-type.php @@ -4,8 +4,8 @@
- - + +