Major theme extension adding full-featured navigation with dropdown submenus (Tools, My Data, Resources), 9 new page templates (Calculator, Protocol Builder, Tracker, Subject Log, Documentation, Directory, Science Feed, Profile, Sign In/Register), documentation page with sidebar ToC and scroll spy, branded AJAX authentication forms, newsletter signup with admin export, slide-out contact/support panel, Research Modules 6-card grid on front page, and comprehensive footer update. Split functions.php (554→206 lines) into 6 focused inc/ modules: helpers, customizer, auth-handlers, contact-handler, page-setup, newsletter-admin. All new components include dark mode support, CSRF protection, input sanitization, output escaping, and graceful plugin degradation via shortcode_exists(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
99 lines
5.7 KiB
PHP
99 lines
5.7 KiB
PHP
<?php
|
|
/**
|
|
* Template Part: Research Module Cards
|
|
*
|
|
* Renders a 6-card grid of research modules (tools/sections) for the front page.
|
|
* Each card checks if the target plugin is active; inactive cards are dimmed.
|
|
*
|
|
* @see front-page.php — includes this template part
|
|
* @see style.css — .ps-module-* classes
|
|
*
|
|
* What: 3-column grid of research tool cards with SVG icons.
|
|
* Who calls it: get_template_part( 'template-parts/module', 'cards' ).
|
|
* Dependencies: None — all output is self-contained.
|
|
*
|
|
* @package peptide-starter
|
|
*/
|
|
|
|
// Exit if accessed directly.
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
// Module card definitions with shortcode checks for graceful degradation.
|
|
$modules = array(
|
|
array(
|
|
'title' => __( 'Peptides', 'peptide-starter' ),
|
|
'description' => __( 'Browse the complete reagent directory with protocols and research parameters.', 'peptide-starter' ),
|
|
'url' => '/peptides',
|
|
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12 2L12 22"/><path d="M5 12C5 8.13 8.13 5 12 5s7 3.13 7 7-3.13 7-7 7-7-3.13-7-7z"/><circle cx="12" cy="8" r="1.5" fill="currentColor" stroke="none"/><circle cx="12" cy="16" r="1.5" fill="currentColor" stroke="none"/></svg>',
|
|
'available' => shortcode_exists( 'peptide_directory' ) || post_type_exists( 'peptide' ),
|
|
),
|
|
array(
|
|
'title' => __( 'Calculator', 'peptide-starter' ),
|
|
'description' => __( 'Precision reconstitution calculator for accurate laboratory preparations.', 'peptide-starter' ),
|
|
'url' => '/calculator',
|
|
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="4" y="2" width="16" height="20" rx="2"/><line x1="8" y1="6" x2="16" y2="6"/><line x1="8" y1="10" x2="10" y2="10"/><line x1="14" y1="10" x2="16" y2="10"/><line x1="8" y1="14" x2="10" y2="14"/><line x1="14" y1="14" x2="16" y2="14"/><line x1="8" y1="18" x2="16" y2="18"/></svg>',
|
|
'available' => shortcode_exists( 'peptide_tools_calculator' ),
|
|
),
|
|
array(
|
|
'title' => __( 'Protocol Builder', 'peptide-starter' ),
|
|
'description' => __( 'Interactive multi-step wizard for designing research protocols.', 'peptide-starter' ),
|
|
'url' => '/protocol-builder',
|
|
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2"/><rect x="9" y="3" width="6" height="4" rx="1"/><path d="M9 14l2 2 4-4"/></svg>',
|
|
'available' => shortcode_exists( 'peptide_tools_protocol_builder' ),
|
|
),
|
|
array(
|
|
'title' => __( 'Tracker', 'peptide-starter' ),
|
|
'description' => __( 'Log doses, manage active compounds, and forecast vial depletion timelines.', 'peptide-starter' ),
|
|
'url' => '/tracker',
|
|
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><line x1="18" y1="20" x2="18" y2="10"/><line x1="12" y1="20" x2="12" y2="4"/><line x1="6" y1="20" x2="6" y2="14"/><line x1="3" y1="20" x2="21" y2="20"/></svg>',
|
|
'available' => shortcode_exists( 'peptide_tracker' ),
|
|
),
|
|
array(
|
|
'title' => __( 'Science Feed', 'peptide-starter' ),
|
|
'description' => __( 'Latest research publications, clinical studies, and laboratory insights.', 'peptide-starter' ),
|
|
'url' => '/news',
|
|
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M4 22h16a2 2 0 002-2V4a2 2 0 00-2-2H8a2 2 0 00-2 2v16a2 2 0 01-2 2zm0 0a2 2 0 01-2-2v-9c0-1.1.9-2 2-2h2"/><line x1="10" y1="6" x2="18" y2="6"/><line x1="10" y1="10" x2="18" y2="10"/><line x1="10" y1="14" x2="14" y2="14"/></svg>',
|
|
'available' => shortcode_exists( 'peptide_news' ),
|
|
),
|
|
array(
|
|
'title' => __( 'Subject Log', 'peptide-starter' ),
|
|
'description' => __( 'Longitudinal tracking for biomarker data and protocol history.', 'peptide-starter' ),
|
|
'url' => '/subject-log',
|
|
'icon' => '<svg width="24" height="24" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M20 21v-2a4 4 0 00-4-4H8a4 4 0 00-4 4v2"/><circle cx="12" cy="7" r="4"/></svg>',
|
|
'available' => shortcode_exists( 'peptide_tracker_subject_log' ),
|
|
),
|
|
);
|
|
?>
|
|
|
|
<section class="ps-modules-section">
|
|
<div class="ps-container-wide">
|
|
<div class="ps-modules-header">
|
|
<h2 class="ps-modules-title"><?php esc_html_e( 'Research Modules', 'peptide-starter' ); ?></h2>
|
|
<p class="ps-modules-subtitle">
|
|
<?php esc_html_e( 'Tools and resources for laboratory research and data management.', 'peptide-starter' ); ?>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="ps-modules-grid">
|
|
<?php foreach ( $modules as $module ) : ?>
|
|
<a href="<?php echo esc_url( home_url( $module['url'] ) ); ?>"
|
|
class="ps-module-card <?php echo $module['available'] ? '' : 'ps-module-card--inactive'; ?>">
|
|
<div class="ps-module-card__icon">
|
|
<?php
|
|
// SVG icons are defined in this template — safe to output directly.
|
|
echo $module['icon']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- static SVG
|
|
?>
|
|
</div>
|
|
<h3 class="ps-module-card__title"><?php echo esc_html( $module['title'] ); ?></h3>
|
|
<p class="ps-module-card__description"><?php echo esc_html( $module['description'] ); ?></p>
|
|
<span class="ps-module-card__link">
|
|
<?php esc_html_e( 'Open', 'peptide-starter' ); ?> →
|
|
</span>
|
|
</a>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</div>
|
|
</section>
|