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
|
||||
/**
|
||||
* Disclaimer.
|
||||
*
|
||||
* @package Peptide_Repo_Core
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Provides shortcode [pr_disclaimer surface="dosing"] and function
|
||||
*
|
||||
* @package Peptide_Repo_Core
|
||||
*/
|
||||
|
||||
/**
|
||||
* Shared disclaimer component for all peptide data surfaces.
|
||||
*
|
||||
@@ -17,10 +29,18 @@ declare(strict_types=1);
|
||||
*/
|
||||
class PR_Core_Disclaimer {
|
||||
|
||||
/** @var string Option key for disclaimer copy (JSON). */
|
||||
/**
|
||||
* Option key for disclaimer copy (JSON).
|
||||
*
|
||||
* @var string Option key for disclaimer copy (JSON).
|
||||
*/
|
||||
private const COPY_OPTION = 'pr_core_disclaimer_copy';
|
||||
|
||||
/** @var string Option key for disclaimer version. */
|
||||
/**
|
||||
* Option key for disclaimer version.
|
||||
*
|
||||
* @var string Option key for disclaimer version.
|
||||
*/
|
||||
private const VERSION_OPTION = 'pr_core_disclaimer_version';
|
||||
|
||||
/**
|
||||
@@ -28,13 +48,13 @@ class PR_Core_Disclaimer {
|
||||
*
|
||||
* @var array<string, string>
|
||||
*/
|
||||
private const DEFAULTS = [
|
||||
'dosing' => 'The dosing information presented here is compiled from published peer-reviewed literature and is provided for educational and research purposes only. It does not constitute medical advice, diagnosis, or treatment recommendations. Always consult a licensed healthcare professional before making any decisions based on this information.',
|
||||
'legal' => 'Legal status information is compiled from publicly available regulatory texts and is current as of the last-verified date shown. Regulatory frameworks change frequently. This information does not constitute legal advice. Verify current regulations with the relevant regulatory authority in your jurisdiction before taking any action.',
|
||||
'reconstitution' => 'This calculator is provided for educational purposes only. Always verify your calculations independently and consult a licensed healthcare professional. The results are based on the inputs you provide and standard reconstitution mathematics.',
|
||||
'ai-answer' => 'This response was generated by an AI system and may contain errors or omissions. All claims are grounded in the Peptide Repo corpus and cited sources where possible. This is not medical advice. Always verify information with primary sources and consult a licensed healthcare professional.',
|
||||
'general' => 'The information on this site is for educational and research purposes only. It is not intended as medical advice, diagnosis, or treatment. Always consult a licensed healthcare professional.',
|
||||
];
|
||||
private const DEFAULTS = array(
|
||||
'dosing' => 'The dosing information presented here is compiled from published peer-reviewed literature and is provided for educational and research purposes only. It does not constitute medical advice, diagnosis, or treatment recommendations. Always consult a licensed healthcare professional before making any decisions based on this information.',
|
||||
'legal' => 'Legal status information is compiled from publicly available regulatory texts and is current as of the last-verified date shown. Regulatory frameworks change frequently. This information does not constitute legal advice. Verify current regulations with the relevant regulatory authority in your jurisdiction before taking any action.',
|
||||
'reconstitution' => 'This calculator is provided for educational purposes only. Always verify your calculations independently and consult a licensed healthcare professional. The results are based on the inputs you provide and standard reconstitution mathematics.',
|
||||
'ai-answer' => 'This response was generated by an AI system and may contain errors or omissions. All claims are grounded in the Peptide Repo corpus and cited sources where possible. This is not medical advice. Always verify information with primary sources and consult a licensed healthcare professional.',
|
||||
'general' => 'The information on this site is for educational and research purposes only. It is not intended as medical advice, diagnosis, or treatment. Always consult a licensed healthcare professional.',
|
||||
);
|
||||
|
||||
/**
|
||||
* Register shortcode and any frontend hooks.
|
||||
@@ -42,7 +62,7 @@ class PR_Core_Disclaimer {
|
||||
* @return void
|
||||
*/
|
||||
public function register_hooks(): void {
|
||||
add_shortcode( 'pr_disclaimer', [ $this, 'shortcode_handler' ] );
|
||||
add_shortcode( 'pr_disclaimer', array( $this, 'shortcode_handler' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +72,7 @@ class PR_Core_Disclaimer {
|
||||
* @return string Disclaimer HTML.
|
||||
*/
|
||||
public function shortcode_handler( $atts ): string {
|
||||
$atts = shortcode_atts( [ 'surface' => 'general' ], $atts, 'pr_disclaimer' );
|
||||
$atts = shortcode_atts( array( 'surface' => 'general' ), $atts, 'pr_disclaimer' );
|
||||
return self::render( sanitize_text_field( $atts['surface'] ) );
|
||||
}
|
||||
|
||||
@@ -81,7 +101,7 @@ class PR_Core_Disclaimer {
|
||||
*/
|
||||
public static function get_disclaimer_text( string $surface ): string {
|
||||
$custom = get_option( self::COPY_OPTION, '{}' );
|
||||
$copy = json_decode( $custom, true ) ?: [];
|
||||
$copy = json_decode( $custom, true ) ?: array(); // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
|
||||
|
||||
if ( ! empty( $copy[ $surface ] ) ) {
|
||||
return (string) $copy[ $surface ];
|
||||
@@ -110,7 +130,7 @@ class PR_Core_Disclaimer {
|
||||
*/
|
||||
public static function update_disclaimer( string $surface, string $text ): void {
|
||||
$custom = get_option( self::COPY_OPTION, '{}' );
|
||||
$copy = json_decode( $custom, true ) ?: [];
|
||||
$copy = json_decode( $custom, true ) ?: array(); // phpcs:ignore Universal.Operators.DisallowShortTernary.Found
|
||||
|
||||
$copy[ sanitize_text_field( $surface ) ] = sanitize_textarea_field( $text );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user