feat(cpt): consolidate peptide CPT with PSA; drop pr_peptide (v0.2.0) (#1)

Consolidates the `peptide` CPT under PR Core ownership, dropping the `pr_peptide` slug-collision that was 404ing all 89 peptide detail pages.

- POST_TYPE: pr_peptide -> peptide
- TAX_CATEGORY: pr_peptide_category -> peptide_category
- TAX_FAMILY + pr_peptide_family taxonomy removed
- Defensive post_type_exists/taxonomy_exists guards on both registrations
- Args harmonized as superset of PSA + prior PR Core (adds thumbnail support)
- Activation hook + init:999 version-change flush handler
- Uninstall scoped to _pr_core_authored flag (PSA-authored posts survive)
- Plugin version 0.1.1 -> 0.2.0, CHANGELOG in same commit
- ARCHITECTURE.md + CONVENTIONS.md updated with CPT ownership rule

QA gate verdict: PASS (qa-reviews/peptide-repo-core/2026-04-22-874f93b.md)
Sibling release: peptiderepo/peptide-search-ai#15 (PSA v4.5.0)

Known follow-up: manage_peptide_content capability is not granted to any role as of v0.2.0. No current UI/theme reads or writes PR Core-defined meta keys, so no regression. Follow-up thread to decide role assignment.
This commit is contained in:
peptiderepo
2026-04-22 16:44:04 +07:00
committed by GitHub
parent c70352eb40
commit f086b89e2d
16 changed files with 592 additions and 78 deletions

View File

@@ -5,17 +5,26 @@ declare(strict_types=1);
* Plugin activation handler.
*
* What: Runs migrations, adds capabilities, flushes rewrite rules.
* Who calls it: register_activation_hook() in peptide-repo-core.php.
* Dependencies: PR_Core_Migration_Runner.
* Also detects version changes on subsequent init cycles and re-flushes
* rewrite rules once so in-place plugin updates (without a deactivate +
* reactivate cycle) still pick up CPT/taxonomy slug changes.
* Who calls it: register_activation_hook() in peptide-repo-core.php; and
* PR_Core::init() registers maybe_flush_on_version_change on init:999.
* Dependencies: PR_Core_Migration_Runner, PR_Core_Peptide_CPT.
*
* @see peptide-repo-core.php — Registers this class on activation.
* @see includes/class-pr-core.php — Wires the init:999 version-change handler.
*/
class PR_Core_Activator {
/** @var string Option key storing the last activated/seen plugin version. */
private const VERSION_OPTION = 'pr_core_version';
/**
* Run on plugin activation.
*
* Side effects: database table creation, capability grants, rewrite flush.
* Side effects: database table creation, capability grants, rewrite flush,
* pr_core_version option write.
*
* @return void
*/
@@ -32,7 +41,39 @@ class PR_Core_Activator {
self::add_capabilities();
// Flush rewrite rules for the new CPT.
flush_rewrite_rules();
flush_rewrite_rules( false );
// Record the activated version so the init:999 drift handler can
// detect future in-place updates and re-flush without a manual
// deactivate/reactivate cycle.
update_option( self::VERSION_OPTION, PR_CORE_VERSION, false );
}
/**
* Detect in-place plugin version changes and flush rewrite rules once.
*
* Wired to init:999 so all CPTs + taxonomies (ours and anyone else's)
* are registered before the flush. When the option is absent (first
* install that bypassed the activation hook — e.g., manual SCP deploy)
* or is older than the current constant, we flush once and update.
*
* Side effects: may call flush_rewrite_rules( false ); updates option.
*
* @return void
*/
public static function maybe_flush_on_version_change(): void {
if ( ! defined( 'PR_CORE_VERSION' ) ) {
return;
}
$recorded = get_option( self::VERSION_OPTION, '' );
if ( PR_CORE_VERSION === $recorded ) {
return;
}
flush_rewrite_rules( false );
update_option( self::VERSION_OPTION, PR_CORE_VERSION, false );
}
/**