feat: initial peptide-repo-core plugin (v0.1.0) — canonical schema sprint
Implements ADR-0002: canonical peptide schema as shared data layer for the peptiderepo.com ecosystem. All Tier 1 tools (Reconstitution Calculator, Dosage Reference, Legal Status Tracker, PSA enhancements) build on this. Includes: - pr_peptide CPT with REST, taxonomies, 11 meta fields - 3 custom tables: pr_dosing_rows, pr_legal_cells, pr_ai_candidate_queue - Sequential migration runner with schema versioning - 4 typed DTOs and 4 repository classes (full CRUD) - REST API (pr-core/v1): 6 endpoints (read public, write auth-gated) - Admin UI: 3 meta boxes, custom columns, AI candidate queue page - Shared disclaimer component (shortcode + static API) - JSON-LD Drug schema emission on single peptide pages - Seed data fixture (3 peptides, 10 dosing rows, 5 legal cells) - Full teardown in uninstall.php - CI: PHP lint 8.0-8.2, PHPCS WordPress, 300-line check All 22 PHP files under 300 lines. Highest: peptide-cpt at 265. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
64
includes/class-pr-core-autoloader.php
Normal file
64
includes/class-pr-core-autoloader.php
Normal file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* SPL autoloader for PR_Core_ prefixed classes.
|
||||
*
|
||||
* What: Resolves PR_Core_ class names to file paths under includes/.
|
||||
* Who calls it: peptide-repo-core.php bootstrap.
|
||||
* Dependencies: None.
|
||||
*
|
||||
* Naming convention: PR_Core_Foo_Bar => class-pr-core-foo-bar.php.
|
||||
* Scans includes/ and all immediate subdirectories.
|
||||
*
|
||||
* @see peptide-repo-core.php — Registers this autoloader at boot.
|
||||
*/
|
||||
class PR_Core_Autoloader {
|
||||
|
||||
/** @var string[] Directories to scan for class files. */
|
||||
private static array $dirs = [];
|
||||
|
||||
/**
|
||||
* Register the autoloader with SPL.
|
||||
*
|
||||
* Side effects: calls spl_autoload_register().
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public static function register(): void {
|
||||
$base = PR_CORE_PLUGIN_DIR . 'includes/';
|
||||
|
||||
self::$dirs[] = $base;
|
||||
|
||||
// Add all immediate subdirectories.
|
||||
foreach ( glob( $base . '*', GLOB_ONLYDIR ) as $dir ) {
|
||||
self::$dirs[] = trailingslashit( $dir );
|
||||
}
|
||||
|
||||
spl_autoload_register( [ __CLASS__, 'load' ] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Autoload callback. Only handles PR_Core_ prefixed classes.
|
||||
*
|
||||
* @param string $class Fully-qualified class name.
|
||||
* @return void
|
||||
*/
|
||||
public static function load( string $class ): void {
|
||||
if ( 0 !== strpos( $class, 'PR_Core_' ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// PR_Core_Foo_Bar => foo-bar => class-pr-core-foo-bar.php.
|
||||
$suffix = substr( $class, 8 ); // Strip 'PR_Core_'.
|
||||
$filename = 'class-pr-core-' . str_replace( '_', '-', strtolower( $suffix ) ) . '.php';
|
||||
|
||||
foreach ( self::$dirs as $dir ) {
|
||||
$path = $dir . $filename;
|
||||
if ( file_exists( $path ) ) {
|
||||
require_once $path;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user