Files
peptide-repo-core/includes/cpt/class-pr-core-topic-taxonomy.php
peptiderepo b84cc656e5 fix: add short descriptions to file docblocks + fix security/Yoda errors in metaboxes
- All 49 PHP includes files: expand minimal file docblocks to include a
  short description (satisfies Generic.Commenting.DocComment.MissingShort)
  Format: <?php\n/**\n * Filename-derived description.\n *\n * @package ...\n */
- settings.php delegation stubs: add compact docblocks to all 8 render_*
  methods (Squiz.Commenting.FunctionComment.Missing, lines 93-231)
- settings.php: compress mirrored @var constant docblocks to single-line;
  remove redundant intermediate class docblock → 273 lines (was 315)
- rest-controller.php: compress 1 mirrored @var docblock → 298 lines
- migration-0004: compress 4 property docblocks → 288 lines
- verification-widget.php line 111: cast days_since to int + phpcs:ignore
- verification-metabox.php line 80: phpcs:ignore on hardcoded badge_class
- peptide-metaboxes.php line 86: phpcs:ignore EscapeOutput (esc_attr'd above)
- peptide-metaboxes.php lines 147/148: Yoda null !== dose_min/dose_max
- peptide-metaboxes.php line 248: phpcs:ignore InputNotSanitized (isset only)
- peptide-metaboxes.php line 259: wrap pr_core_editorial_review_status in wp_unslash()
- peptide-metaboxes.php line 262: Yoda 'published' !== old_status

Agent-Session: claude-adopt-ci-20260616
2026-06-16 16:12:25 +00:00

86 lines
2.2 KiB
PHP

<?php
/**
* Topic Taxonomy.
*
* @package Peptide_Repo_Core
*/
declare(strict_types=1);
/**
* Defines the `peptide_topic` taxonomy attached to the post CPT
*
* @package Peptide_Repo_Core
*/
/**
* Registers the peptide_topic taxonomy for linking blog posts to peptides.
*
* What: Defines the `peptide_topic` taxonomy attached to the post CPT.
* Non-hierarchical, uses peptide slugs as terms (e.g., 'bpc-157', 'tb-500').
* Enables the Related Articles feature for blog posts tagged with a peptide topic.
* Who calls it: PR_Core::init() on plugins_loaded.
* Dependencies: None.
*
* Ownership: As of v0.3.0, PR Core owns `peptide_topic` taxonomy.
* Registration is guarded by `taxonomy_exists()` so deploy order does not matter.
*
* @see ARCHITECTURE.md — Taxonomy specification.
* @see CONVENTIONS.md — Taxonomy ownership rule.
*/
class PR_Core_Topic_Taxonomy {
/**
* Taxonomy: topic (links blog posts to peptides by slug).
*
* @var string Taxonomy: topic (links blog posts to peptides by slug).
*/
public const TAX_TOPIC = 'peptide_topic';
/**
* Register WordPress hooks for taxonomy registration.
*
* @return void
*/
public function register_hooks(): void {
add_action( 'init', array( __CLASS__, 'register_topic_taxonomy' ) );
}
/**
* Register the `peptide_topic` taxonomy.
*
* Guarded with `taxonomy_exists()`: if another plugin has already
* registered the `peptide_topic` taxonomy, this call no-ops.
*
* Side effects: registers taxonomy with WordPress.
*
* @return void
*/
public static function register_topic_taxonomy(): void {
if ( taxonomy_exists( self::TAX_TOPIC ) ) {
return;
}
register_taxonomy(
self::TAX_TOPIC,
'post',
array(
'labels' => array(
'name' => __( 'Peptide Topics', 'peptide-repo-core' ),
'singular_name' => __( 'Peptide Topic', 'peptide-repo-core' ),
),
'public' => true,
'publicly_queryable' => true,
'show_in_rest' => true,
'show_ui' => true,
'show_admin_column' => true,
'hierarchical' => false,
'rewrite' => array(
'slug' => 'peptide-topic',
'with_front' => false,
),
)
);
}
}