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:
74
uninstall.php
Normal file
74
uninstall.php
Normal file
@@ -0,0 +1,74 @@
|
||||
<?php
|
||||
/**
|
||||
* Peptide Repo Core — Full data teardown on uninstall.
|
||||
*
|
||||
* Removes ALL plugin data: custom tables, CPT posts + meta, taxonomy terms,
|
||||
* options, and capabilities. No orphaned data left behind.
|
||||
*
|
||||
* @see ARCHITECTURE.md — Section 2.9 Uninstall specification.
|
||||
*/
|
||||
|
||||
if ( ! defined( 'WP_UNINSTALL_PLUGIN' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
global $wpdb;
|
||||
|
||||
/* ── 1. Drop custom tables ────────────────────────────────────────────── */
|
||||
|
||||
$tables = [
|
||||
$wpdb->prefix . 'pr_dosing_rows',
|
||||
$wpdb->prefix . 'pr_legal_cells',
|
||||
$wpdb->prefix . 'pr_ai_candidate_queue',
|
||||
];
|
||||
|
||||
foreach ( $tables as $table ) {
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.SchemaChange
|
||||
$wpdb->query( "DROP TABLE IF EXISTS {$table}" );
|
||||
}
|
||||
|
||||
/* ── 2. Delete all pr_peptide posts (cascade deletes meta) ────────────── */
|
||||
|
||||
$post_ids = $wpdb->get_col(
|
||||
"SELECT ID FROM {$wpdb->posts} WHERE post_type = 'pr_peptide'"
|
||||
);
|
||||
|
||||
foreach ( $post_ids as $post_id ) {
|
||||
wp_delete_post( (int) $post_id, true );
|
||||
}
|
||||
|
||||
/* ── 3. Delete taxonomy terms ─────────────────────────────────────────── */
|
||||
|
||||
$taxonomies = [ 'pr_peptide_category', 'pr_peptide_family' ];
|
||||
|
||||
foreach ( $taxonomies as $taxonomy ) {
|
||||
$terms = get_terms( [
|
||||
'taxonomy' => $taxonomy,
|
||||
'hide_empty' => false,
|
||||
'fields' => 'ids',
|
||||
] );
|
||||
|
||||
if ( is_array( $terms ) ) {
|
||||
foreach ( $terms as $term_id ) {
|
||||
wp_delete_term( (int) $term_id, $taxonomy );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* ── 4. Delete all pr_core_ prefixed options ──────────────────────────── */
|
||||
|
||||
// phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery
|
||||
$wpdb->query(
|
||||
"DELETE FROM {$wpdb->options} WHERE option_name LIKE 'pr\_core\_%'"
|
||||
);
|
||||
|
||||
/* ── 5. Remove manage_peptide_content capability from all roles ────────── */
|
||||
|
||||
$editable_roles = wp_roles()->roles;
|
||||
|
||||
foreach ( array_keys( $editable_roles ) as $role_name ) {
|
||||
$role = get_role( $role_name );
|
||||
if ( $role && $role->has_cap( 'manage_peptide_content' ) ) {
|
||||
$role->remove_cap( 'manage_peptide_content' );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user