Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/copilot-instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 (`<!-- wp:… -->`) 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
Expand Down
17 changes: 16 additions & 1 deletion ROADMAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 0 additions & 23 deletions lib/templates/parts/post-query.php

This file was deleted.

4 changes: 2 additions & 2 deletions lib/templates/taxonomy-fund-theme.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<!-- wp:group {"tagName":"main","className":"content-region","style":{"spacing":{"margin":{"top":"var:preset|spacing|50"}}},"layout":{"inherit":true,"type":"constrained"}} -->
<main class="wp-block-group content-region" style="margin-top:var(--wp--preset--spacing--50)"><!-- wp:query-title {"type":"archive","textAlign":"center","showPrefix":false} /-->
<?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'; ?>
</main>
<!-- /wp:group -->

Expand Down
4 changes: 2 additions & 2 deletions lib/templates/taxonomy-fund-type.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

<!-- wp:group {"tagName":"main","className":"content-region","style":{"spacing":{"margin":{"top":"var:preset|spacing|50"}}},"layout":{"inherit":true,"type":"constrained"}} -->
<main class="wp-block-group content-region" style="margin-top:var(--wp--preset--spacing--50)"><!-- wp:query-title {"type":"archive","textAlign":"center","showPrefix":false} /-->
<?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'; ?>
</main>
<!-- /wp:group -->

Expand Down