Files
Portfolio-2026/views/components/project-stat-card.php
T

27 lines
905 B
PHP

<?php
/**
* Project Stat Card Component
*
* Renders one stat tile. Expects $label, $value, and $icon (optional SVG
* markup) in scope. $icon MUST be aria-hidden decorative markup; the label
* is the accessible name.
*
* @package KsPortfolio
*/
namespace KsPortfolio;
if ( ! isset( $label ) || ! isset( $value ) ) {
return;
}
$stat_label = (string) $label;
$stat_value = (string) $value;
?>
<div class="stat-card" role="group" aria-label="<?php echo esc_attr( $stat_label ); ?>">
<?php if ( isset( $icon ) && $icon ) : ?>
<span class="stat-card__icon" aria-hidden="true"><?php echo $icon; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped -- icon is hardcoded decorative SVG in callers. ?></span>
<?php endif; ?>
<span class="stat-card__value"><?php echo esc_html( $stat_value ); ?></span>
<span class="stat-card__label"><?php echo esc_html( $stat_label ); ?></span>
</div>