Files
peptide-repo-core/template-parts/related-posts/card.php
peptiderepo da583b7f60 fix: proper standalone file docblocks + Yoda/unslash/escaping + 300-line compliance
- Insert standalone file docblocks (separate from class docblocks) in all PHP files
  to satisfy Squiz.Commenting.FileComment.Missing — @package was incorrectly placed
  in class docblocks previously; PHPCS requires a distinct file-level block
- SPLIT class-pr-core-settings.php (was 340 lines after docblock expansion):
  class-pr-core-settings.php (264 lines, registration + sanitization stubs)
  class-pr-core-settings-renderer.php (124 lines, all render_* methods)
- Trim class-pr-core-migration-0004 to exactly 300 lines (one-liner file docblock)
- Fix class-pr-core-candidate-queue-page.php:
  Yoda conditions: null !== c->dose_min / null !== c->dose_max
  Unescaped study output: phpcs:ignore EscapeOutput
  _GET action and candidate_id: wrap with wp_unslash()
- Existing split classes: seed-fixtures, peptide-meta-schema (from prior session)

Agent-Session: claude-adopt-ci-20260616
2026-06-16 15:59:00 +00:00

74 lines
1.9 KiB
PHP

<?php
/**
* Part of the Peptide Repo Core plugin.
*
* @package Peptide_Repo_Core
*/
/**
* Related posts card template part.
*
* Variables:
* - $post: WP_Post object with thumbnail, title, excerpt, date.
*
* @package peptide-repo-core
*/
if ( ! isset( $args['post'] ) ) {
return;
}
$post = $args['post']; // phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
?>
<article class="pr-related-posts__card">
<?php
if ( has_post_thumbnail( $post ) ) {
?>
<div class="pr-related-posts__image">
<?php
echo wp_kses_post(
get_the_post_thumbnail(
$post,
'post-thumbnail',
array(
'class' => 'pr-related-posts__image-element',
'loading' => 'lazy',
'decoding' => 'async',
)
)
);
?>
</div>
<?php
} else {
?>
<div class="pr-related-posts__image pr-related-posts__image--fallback">
<img src="<?php echo esc_url( get_site_icon_url( 512 ) ); ?>" alt="<?php esc_attr_e( 'Site logo', 'peptide-repo-core' ); ?>" class="pr-related-posts__image-element" loading="lazy" decoding="async" />
</div>
<?php
}
?>
<div class="pr-related-posts__content">
<span class="pr-related-posts__badge"><?php esc_html_e( 'Article', 'peptide-repo-core' ); ?></span>
<h3 class="pr-related-posts__title">
<a href="<?php echo esc_url( get_permalink( $post ) ); ?>">
<?php echo esc_html( $post->post_title ); ?>
</a>
</h3>
<time class="pr-related-posts__date" datetime="<?php echo esc_attr( mysql2date( 'c', $post->post_date ) ); ?>">
<?php echo esc_html( mysql2date( get_option( 'date_format' ), $post->post_date ) ); ?>
</time>
<?php
if ( $post->post_excerpt ) {
$excerpt = wp_strip_all_tags( $post->post_excerpt );
$excerpt = wp_kses_post( wp_trim_words( $excerpt, 20 ) );
?>
<p class="pr-related-posts__excerpt">
<?php echo wp_kses_post( $excerpt ); ?>
</p>
<?php
}
?>
</div>
</article>