53 lines
2.1 KiB
PHP
53 lines
2.1 KiB
PHP
<?php
|
|
/**
|
|
* Home Module · Highlight Cards
|
|
*
|
|
* config: { title?, items: [{ title, desc, icon?, image?, url? }], columns? }
|
|
*
|
|
* 亮点卡片模块,用于产品特性、服务介绍等。
|
|
*/
|
|
defined('ABSPATH') || exit;
|
|
|
|
$cfg = get_query_var('aksrt_module_config', []);
|
|
if (!is_array($cfg)) $cfg = [];
|
|
|
|
$title = (string) ($cfg['title'] ?? '');
|
|
$items = isset($cfg['items']) && is_array($cfg['items']) ? $cfg['items'] : [];
|
|
$columns = max(1, min(4, (int) ($cfg['columns'] ?? 3)));
|
|
|
|
if (empty($items)) return;
|
|
?>
|
|
|
|
<section class="home-module home-module--highlight-cards container">
|
|
<?php if ($title !== '') : ?>
|
|
<header class="home-module__header">
|
|
<h2 class="home-module__title"><?php echo esc_html($title); ?></h2>
|
|
</header>
|
|
<?php endif; ?>
|
|
<div class="home-module__highlight-grid" style="grid-template-columns:repeat(<?php echo esc_attr((string) $columns); ?>, 1fr)">
|
|
<?php foreach ($items as $item) :
|
|
$item_title = (string) ($item['title'] ?? '');
|
|
$item_desc = (string) ($item['desc'] ?? '');
|
|
$item_icon = (string) ($item['icon'] ?? '');
|
|
$item_image = (string) ($item['image'] ?? '');
|
|
$item_url = (string) ($item['url'] ?? '');
|
|
if ($item_title === '') continue;
|
|
|
|
$card_tag = $item_url !== '' ? 'a' : 'div';
|
|
$card_attrs = $item_url !== '' ? ' href="' . esc_url($item_url) . '"' : '';
|
|
?>
|
|
<<?php echo esc_attr($card_tag); ?> class="aksrt-highlight-card"<?php echo $card_attrs; ?>>
|
|
<?php if ($item_image !== '') : ?>
|
|
<img class="aksrt-highlight-card__image" src="<?php echo esc_url($item_image); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
|
|
<?php elseif ($item_icon !== '') : ?>
|
|
<div class="aksrt-highlight-card__icon"><i class="<?php echo esc_attr($item_icon); ?>"></i></div>
|
|
<?php endif; ?>
|
|
<h3 class="aksrt-highlight-card__title"><?php echo esc_html($item_title); ?></h3>
|
|
<?php if ($item_desc !== '') : ?>
|
|
<p class="aksrt-highlight-card__desc"><?php echo esc_html($item_desc); ?></p>
|
|
<?php endif; ?>
|
|
</<?php echo esc_attr($card_tag); ?>>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|