feat: Add cardStyle attribute to feature cards for enhanced styling options

This commit is contained in:
Matt Batchelder
2026-04-17 21:24:11 -04:00
parent 93b571d6aa
commit 29ae3632f1
3 changed files with 44 additions and 11 deletions

View File

@@ -388,6 +388,7 @@ add_action('init', function () {
'url' => ['type' => 'string', 'default' => ''],
'centered' => ['type' => 'boolean', 'default' => false],
'scene' => ['type' => 'string', 'default' => ''],
'cardStyle' => ['type' => 'string', 'default' => ''],
],
oribi_card_image_attributes()
),
@@ -1209,10 +1210,26 @@ function oribi_render_feature_card($a)
$scene = !empty($a['scene']) ? trim($a['scene']) : '';
$img = oribi_card_image_html($a);
$img_cls = $img['card_class'] ? ' ' . $img['card_class'] : '';
$style_cls = '';
if (!empty($a['cardStyle'])) {
$allowed_styles = [
'bold-statement',
'minimal-feature',
'prominent-stat',
'testimonial',
'action',
'comparison-row',
];
$style = sanitize_html_class($a['cardStyle']);
if (in_array($style, $allowed_styles, true)) {
$style_cls = ' ' . $style;
}
}
ob_start();
if ($img['html'] && $img['position'] === 'left'): ?>
<<?php echo $tag . $href; ?> class="oribi-card<?php echo esc_attr($link_cls . $img_cls); ?>">
<<?php echo $tag . $href; ?> class="oribi-card<?php echo esc_attr($link_cls . $img_cls . $style_cls); ?>">
<?php echo $img['html']; ?>
<div class="oribi-card-body">
<h3><?php echo wp_kses_post($a['title']); ?></h3>
@@ -1221,7 +1238,7 @@ function oribi_render_feature_card($a)
</<?php echo $tag; ?>>
<?php
elseif ($img['html'] && $img['position'] === 'background'): ?>
<<?php echo $tag . $href; ?> class="oribi-card<?php echo esc_attr($link_cls . $img_cls); ?>">
<<?php echo $tag . $href; ?> class="oribi-card<?php echo esc_attr($link_cls . $img_cls . $style_cls); ?>">
<?php echo $img['html']; ?>
<div class="oribi-card-body">
<?php if (oribi_has_icon($a)): ?><div class="feature-icon"<?php echo $center ? ' style="margin-inline:auto;"' : ''; ?>><?php echo oribi_render_icon($a); ?></div><?php
@@ -1232,7 +1249,7 @@ function oribi_render_feature_card($a)
</<?php echo $tag; ?>>
<?php
else: ?>
<<?php echo $tag . $href; ?> class="oribi-card<?php echo esc_attr($link_cls . $img_cls); ?><?php echo $center ? ' text-center' : ''; ?>">
<<?php echo $tag . $href; ?> class="oribi-card<?php echo esc_attr($link_cls . $img_cls . $style_cls); ?><?php echo $center ? ' text-center' : ''; ?>">
<?php if ($img['html'] && ($img['position'] === 'top' || $img['position'] === 'replace-icon')): ?>
<?php echo $img['html']; ?>
<?php