peptide-repo-core v0.6.0: peptide schema backfill + Yoast-integrated Drug/MedicalWebPage/FAQ (#19)
Backfill psa_*->_pr_* meta (migration 0004 + PubChem fallback); enrich Drug node with {permalink}#drug @id + molecularFormula/Weight/alternateName; rewrite emitter into Yoast schema graph (MedicalWebPage retype + FAQPage, no duplicate nodes).
QA: APPROVE (independent) — qa-reviews/peptide-repo-core/2026-06-13-817690c1b6ec2118ddcf3b8cfe8bc5ea7f3933b3.md
Agent-Session: peptide-schema-backfill v0.6.0 merge
This commit is contained in:
@@ -21,6 +21,8 @@ Files live in `includes/` or one level of subdirectory under `includes/`.
|
||||
3. Add the field to `PR_Core_Peptide_Repository::post_to_dto()` in `repositories/class-pr-core-peptide-repository.php`.
|
||||
4. Add a form input in `PR_Core_Peptide_Metaboxes::render_identifiers_box()` in `admin/class-pr-core-peptide-metaboxes.php`.
|
||||
5. The `save_meta()` method reads from the same field list — no changes needed unless custom save logic applies.
|
||||
6. **Schema-input meta fields** (`_pr_*` keys introduced in v0.6.0) use `PR_Core_Schema_Sanitizers` as the sanitize_callback. Add new sanitizers to `cpt/class-pr-core-schema-sanitizers.php`, not to `PR_Core_Peptide_CPT` (keeps CPT under 300 lines).
|
||||
7. If the field is purged on uninstall, add it to the `$schema_meta_keys` array in `uninstall.php`.
|
||||
|
||||
## How To: Add a New Post-Meta Field to Repo Daily Posts
|
||||
|
||||
@@ -36,6 +38,7 @@ Files live in `includes/` or one level of subdirectory under `includes/`.
|
||||
3. Add the class name to `PR_Core_Migration_Runner::MIGRATIONS` array (index = version - 1).
|
||||
4. Bump `PR_CORE_TARGET_SCHEMA_VERSION` in `peptide-repo-core.php`.
|
||||
5. All migrations must be idempotent (safe to run twice).
|
||||
6. **Idempotency caveat (all-or-nothing skip):** migration 0004's skip guard requires *all* populated keys; a post with legitimately empty aliases will re-run on manual re-invoke — this is safe (write_meta only overwrites with non-empty values) but expected.
|
||||
|
||||
## How To: Add a New REST Endpoint
|
||||
|
||||
@@ -50,6 +53,16 @@ Files live in `includes/` or one level of subdirectory under `includes/`.
|
||||
2. Use `[pr_disclaimer surface="new-surface"]` in templates.
|
||||
3. Custom copy can be set via `PR_Core_Disclaimer::update_disclaimer()`.
|
||||
|
||||
## How To: Extend the JSON-LD Drug Schema
|
||||
|
||||
v0.6.0 uses four focused classes (see ARCHITECTURE.md §#6). To add a new field to the Drug node:
|
||||
|
||||
1. Add the logic to `PR_Core_Jsonld_Drug::build()` in `includes/frontend/class-pr-core-jsonld-drug.php`.
|
||||
2. Read data from the appropriate `_pr_*` post-meta key (not from PSA `psa_*` keys directly).
|
||||
3. **Always omit the field when the meta is empty** — never emit blank/null/zero values.
|
||||
4. To add a new schema piece (not Drug), create a new `PR_Core_Jsonld_<Piece>` class in `frontend/` and inject it from `PR_Core_Jsonld::inject_graph_pieces()`.
|
||||
5. The `pr_core_jsonld_peptide` filter on the Drug node array is preserved for consumer plugins.
|
||||
|
||||
## Error Handling
|
||||
|
||||
- Repository methods return `null` or `0` on failure, never throw.
|
||||
|
||||
Reference in New Issue
Block a user