Skip to content

fix: root template requires at __DIR__ and drop an unused template part - #139

Merged
Herm71 merged 1 commit into
mainfrom
fix/134-template-plumbing
Aug 4, 2026
Merged

Herm71 merged 1 commit into
mainfrom
fix/134-template-plumbing

Conversation

@Herm71

@Herm71 Herm71 commented Aug 4, 2026

Copy link
Copy Markdown
Member

Closes #134.

Changes

1. __DIR__-rooted requires — lib/templates/taxonomy-fund-type.php and taxonomy-fund-theme.php:

-<?php require 'parts/funds-search.php'; ?>
-<?php require 'parts/post-query-funds.php'; ?>
+<?php require __DIR__ . '/parts/funds-search.php'; ?>
+<?php require __DIR__ . '/parts/post-query-funds.php'; ?>

To be precise about what this fixes: the old form worked — PHP falls back to the calling file's directory when a relative include isn't found on the include path. This removes the reliance on that implicit lookup rather than repairing a break. Behavior is unchanged.

2. Deleted lib/templates/parts/post-query.php. Nothing referenced it — verified repo-wide, the only mention was a line in copilot-instructions.md listing it. It also queries "postType":"post", not fund, so it's a generic blog loop that could never have served these templates. It shipped in the ZIP regardless, since lib/ is in the files array.

3. Docs — CLAUDE.md and copilot-instructions.md both described the requires as relative; both now describe the current state.

ROADMAP note on the template split

Recorded in §4 as an open question rather than acted on, since you wanted to look at the templates first:

Template Lines Composition
taxonomy-fund-type.php 11 composed from parts/
taxonomy-fund-theme.php 11 composed from parts/
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 a change to the archive layout has to be made in both, and neither picks up edits to parts/.

The note also flags that the three questions are entangled — the inlined templates are also the ones carrying the hardcoded media (#133) and the unpinned template-part references (#136), so they're best looked at together.

Verification

composer lint clean, PHPUnit green (24 tests) — but neither covers template rendering, which is what this change actually touches. So I rendered all six templates through ucscgiving_get_template_content() from a different working directory (/), which is the case the implicit fallback was covering:

taxonomy-fund-type.php     rendered= 3486 raw=  842  wp:search=yes wp:query=yes
taxonomy-fund-theme.php    rendered= 3486 raw=  842  wp:search=yes wp:query=yes
archive-fund.php           rendered= 6606 raw= 6606  wp:search=yes wp:query=yes
single-fund.php            rendered= 3640 raw= 3640  wp:search=no  wp:query=no
taxonomy-area.php          rendered= 6491 raw= 6491  wp:search=yes wp:query=yes
taxonomy-keyword.php       rendered= 6491 raw= 6491  wp:search=yes wp:query=yes

The two parts-based templates expand from 842 bytes to 3486, so the parts are being pulled in, and both carry the wp:search and wp:query markup that only exists in those parts. The four inlined templates render byte-identical to source, as expected. No warnings or fatals.

Still worth a manual look before merge: Fund Type and Fund Theme taxonomy archives in a browser. The unit suite does not cover template output (ROADMAP §3).

🤖 Generated with Claude Code

The two taxonomy templates that compose from parts/ used bare relative
requires, which resolved only via PHP's fallback to the calling file's
directory. Rooting them at __DIR__ removes the reliance on that implicit
lookup. Behavior is unchanged.

Also removes lib/templates/parts/post-query.php. Nothing required it,
and it queries postType "post" rather than "fund", so it could not have
served these templates anyway. It shipped in the ZIP regardless, since
lib/ is in the files array.

Records the template composition split in ROADMAP section 4 as an open
question: taxonomy-fund-type and taxonomy-fund-theme are 11 lines built
from parts, while archive-fund, single-fund, taxonomy-area and
taxonomy-keyword inline everything, and the two inlined taxonomy
templates are near-identical to each other.

Closes #134

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@Herm71
Herm71 merged commit 2053cd9 into main Aug 4, 2026
2 checks passed
@Herm71
Herm71 deleted the fix/134-template-plumbing branch August 4, 2026 19:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Template plumbing: __DIR__-relative requires and a dead template part

1 participant