Adopt reusable CI standard + PHPUnit conversion (#22)
Squash-merge of PR #22: adopt shared reusable CI workflow, convert PHPUnit to stubs, update branch-protection contexts.
QA-approved at 05d8094a1d. All required CI checks green.
Agent-Session: 2026-06-17-prcore-ci-deploy
This commit is contained in:
@@ -1,6 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Internal Posts Provider.
|
||||
*
|
||||
* @package Peptide_Repo_Core
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Implements PR_Core_Related_Posts_Provider by querying posts tagged
|
||||
*
|
||||
* @package Peptide_Repo_Core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fetches posts related to a peptide via taxonomy and fallback text search.
|
||||
*
|
||||
@@ -33,7 +45,7 @@ class PR_Core_Internal_Posts_Provider implements PR_Core_Related_Posts_Provider
|
||||
public function get_posts( int $peptide_id, int $limit ): array {
|
||||
$peptide = get_post( $peptide_id );
|
||||
if ( ! $peptide || 'peptide' !== $peptide->post_type ) {
|
||||
return [];
|
||||
return array();
|
||||
}
|
||||
|
||||
$cache_key = 'pr_core_related_' . $peptide_id;
|
||||
@@ -64,21 +76,23 @@ class PR_Core_Internal_Posts_Provider implements PR_Core_Related_Posts_Provider
|
||||
* @return array<int, \WP_Post>
|
||||
*/
|
||||
private function query_by_taxonomy( string $peptide_slug, int $limit ): array {
|
||||
$query = new WP_Query( [
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => $limit,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'tax_query' => [
|
||||
[
|
||||
'taxonomy' => 'peptide_topic',
|
||||
'field' => 'slug',
|
||||
'terms' => $peptide_slug,
|
||||
],
|
||||
],
|
||||
] );
|
||||
$query = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => $limit,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
'tax_query' => array(
|
||||
array(
|
||||
'taxonomy' => 'peptide_topic',
|
||||
'field' => 'slug',
|
||||
'terms' => $peptide_slug,
|
||||
),
|
||||
),
|
||||
)
|
||||
);
|
||||
|
||||
return $query->posts ?: [];
|
||||
return $query->posts ?: array(); // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -89,14 +103,16 @@ class PR_Core_Internal_Posts_Provider implements PR_Core_Related_Posts_Provider
|
||||
* @return array<int, \WP_Post>
|
||||
*/
|
||||
private function query_by_search( string $search_term, int $limit ): array {
|
||||
$query = new WP_Query( [
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => $limit,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
's' => $search_term,
|
||||
] );
|
||||
$query = new WP_Query(
|
||||
array(
|
||||
'post_type' => 'post',
|
||||
'posts_per_page' => $limit,
|
||||
'orderby' => 'date',
|
||||
'order' => 'DESC',
|
||||
's' => $search_term,
|
||||
)
|
||||
);
|
||||
|
||||
return $query->posts ?: [];
|
||||
return $query->posts ?: array(); // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Related Posts Provider.
|
||||
*
|
||||
* @package Peptide_Repo_Core
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Interface defining the get_posts() contract for related-post providers
|
||||
*
|
||||
* @package Peptide_Repo_Core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Contract for any provider that retrieves posts related to a peptide.
|
||||
*
|
||||
|
||||
@@ -1,6 +1,18 @@
|
||||
<?php
|
||||
/**
|
||||
* Related Posts Section.
|
||||
*
|
||||
* @package Peptide_Repo_Core
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Hooks into pr_core_after_peptide_content and renders a card grid
|
||||
*
|
||||
* @package Peptide_Repo_Core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Renders the related articles section on peptide single pages.
|
||||
*
|
||||
@@ -15,7 +27,11 @@ declare(strict_types=1);
|
||||
*/
|
||||
class PR_Core_Related_Posts_Section {
|
||||
|
||||
/** @var PR_Core_Related_Posts_Provider */
|
||||
/**
|
||||
* PR_Core_Related_Posts_Provider.
|
||||
*
|
||||
* @var PR_Core_Related_Posts_Provider
|
||||
*/
|
||||
private $provider;
|
||||
|
||||
/**
|
||||
@@ -33,8 +49,8 @@ class PR_Core_Related_Posts_Section {
|
||||
* @return void
|
||||
*/
|
||||
public function register_hooks(): void {
|
||||
add_action( 'pr_core_after_peptide_content', [ $this, 'render' ] );
|
||||
add_action( 'save_post_post', [ $this, 'invalidate_caches' ] );
|
||||
add_action( 'pr_core_after_peptide_content', array( $this, 'render' ) );
|
||||
add_action( 'save_post_post', array( $this, 'invalidate_caches' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +88,7 @@ class PR_Core_Related_Posts_Section {
|
||||
break;
|
||||
}
|
||||
setup_postdata( $post );
|
||||
get_template_part( 'template-parts/related-posts/card', null, [ 'post' => $post ] );
|
||||
get_template_part( 'template-parts/related-posts/card', null, array( 'post' => $post ) );
|
||||
++$count;
|
||||
}
|
||||
wp_reset_postdata();
|
||||
@@ -90,6 +106,7 @@ class PR_Core_Related_Posts_Section {
|
||||
<?php
|
||||
echo wp_kses_post(
|
||||
sprintf(
|
||||
// translators: %s: peptide display name.
|
||||
__( 'View all %s articles →', 'peptide-repo-core' ),
|
||||
esc_html( $peptide->post_title )
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user