Files
peptide-starter-theme/template-parts/verdict/card.php
peptiderepo 7b5f992a2a fix: CMO walkthrough P1 fixes — verdict_text, per-row glyphs, conditional disclosure, dark mode (v2.0.0-alpha.3)
P1.1: verdict_text meta field + card.php wiring
- Register verdict_text (textarea, show_in_rest) on peptide CPT
- card.php reads verdict_text meta; falls back to placeholder if empty
- Hardcoded generic placeholder no longer the default for published posts
- All 3 monographs populated with CMO-authored verdict text

P1.2: per-row glyph meta fields
- Register signal_row_1/2/3_glyph (enum: ✓|!|?|⊘|⚠, show_in_rest)
- card.php reads per-row glyph from meta instead of hardcoding by position
- Missing glyph renders nothing (not a wrong glyph)
- Semaglutide: ✓✓! | BPC-157: ✓!? | Melanotan-II: !!⚠

P1.3: conditional inline disclosure
- Register has_partner_link (boolean, default false, show_in_rest)
- single-peptide.php only renders inline disclosure when has_partner_link=true
- All 3 loaded monographs set to has_partner_link=false
- Footer disclosure unaffected (always renders)

N.1: dark mode toggle hidden
- header.php: toggle button hidden (display:none + aria-hidden)
- Dark-mode verdict colors not validated for v1; re-enable in v1.1

Meta box updated with textarea, glyph dropdowns, and partner-link checkbox.
2026-04-26 02:12:35 +00:00

108 lines
3.2 KiB
PHP

<?php
/**
* Verdict Card Component (Monograph Hero)
*
* Displays the full verdict card hero for a peptide post.
* Reads verdict_state, verdict_text, signal_row_1/2/3, and
* signal_row_1/2/3_glyph from post meta.
*
* Who calls it: single-peptide.php for posts with a verdict_state.
* Depends on: inc/verdict-meta.php (meta registration),
* template-parts/verdict/badge.php,
* template-parts/verdict/evidence-row.php.
*
* @see inc/verdict-meta.php
* @see single-peptide.php
* @package peptide-starter
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
$post_id = isset( $args['post_id'] ) ? absint( $args['post_id'] ) : get_the_ID();
// Get verdict state; bail early if unset.
$verdict_state = get_post_meta( $post_id, 'verdict_state', true );
if ( empty( $verdict_state ) ) {
return;
}
// Get opinionated verdict text; fall back to placeholder if not yet authored.
$verdict_text = get_post_meta( $post_id, 'verdict_text', true );
if ( empty( $verdict_text ) ) {
$verdict_text = __( 'This peptide merits careful scientific review. Please consult with a healthcare provider before use.', 'peptide-starter' );
}
// Collect signal rows with their per-row glyphs.
// Glyph comes from the signal_row_N_glyph meta field; if unset, no glyph is
// rendered. This is intentional — a missing glyph is better than a wrong one.
$signals = array();
for ( $i = 1; $i <= 3; $i++ ) {
$signal_text = get_post_meta( $post_id, 'signal_row_' . $i, true );
$signal_glyph = get_post_meta( $post_id, 'signal_row_' . $i . '_glyph', true );
if ( ! empty( $signal_text ) ) {
$signals[] = array(
'glyph' => $signal_glyph, // May be empty string; evidence-row handles that.
'label' => $signal_text,
);
}
}
?>
<div class="pr-verdict-card">
<div class="pr-verdict-card__header">
<div>
<?php
get_template_part(
'template-parts/verdict/badge',
null,
array(
'verdict_state' => $verdict_state,
'show_label' => true,
)
);
?>
</div>
<time class="pr-verdict-card__updated" datetime="<?php echo esc_attr( get_the_date( 'c', $post_id ) ); ?>">
<?php echo esc_html( 'Updated ' . get_the_date( 'M d, Y', $post_id ) ); ?>
</time>
</div>
<h1 class="pr-verdict-card__title"><?php echo esc_html( get_the_title( $post_id ) ); ?></h1>
<p class="pr-verdict-card__summary">
<?php
$summary = get_the_excerpt( $post_id );
if ( empty( $summary ) ) {
$content = get_the_content( null, false, $post_id );
$summary = wp_trim_words( $content, 20 );
}
echo wp_kses_post( $summary );
?>
</p>
<?php if ( ! empty( $signals ) ) : ?>
<?php
get_template_part(
'template-parts/verdict/evidence-row',
null,
array( 'signals' => $signals )
);
?>
<?php endif; ?>
<div class="pr-verdict-card__verdict-label"><?php esc_html_e( 'Our verdict:', 'peptide-starter' ); ?></div>
<div class="pr-verdict-card__verdict-text">
<?php echo wp_kses_post( nl2br( $verdict_text ) ); ?>
</div>
<div class="pr-verdict-card__cta-group">
<a href="#evidence" class="pr-verdict-card__cta-link">
<?php esc_html_e( 'Read the full evidence', 'peptide-starter' ); ?> →
</a>
<a href="#dosing" class="pr-verdict-card__cta-link">
<?php esc_html_e( 'Jump to dosing', 'peptide-starter' ); ?> →
</a>
</div>
</div>