44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
/**
|
|
* Home Module · Data Grid
|
|
*
|
|
* config: { title?, items: [{ value, label, icon? }], 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(2, min(6, (int) ($cfg['columns'] ?? 4)));
|
|
|
|
if (empty($items)) return;
|
|
?>
|
|
|
|
<section class="home-module home-module--data-grid 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__data-grid" style="grid-template-columns:repeat(<?php echo esc_attr((string) $columns); ?>, 1fr)">
|
|
<?php foreach ($items as $item) :
|
|
$value = (string) ($item['value'] ?? '');
|
|
$label = (string) ($item['label'] ?? '');
|
|
$icon = (string) ($item['icon'] ?? '');
|
|
if ($value === '' && $label === '') continue;
|
|
?>
|
|
<div class="aksrt-data-cell">
|
|
<?php if ($icon !== '') : ?>
|
|
<i class="<?php echo esc_attr($icon); ?>" aria-hidden="true"></i>
|
|
<?php endif; ?>
|
|
<span class="aksrt-data-cell__value"><?php echo esc_html($value); ?></span>
|
|
<span class="aksrt-data-cell__label"><?php echo esc_html($label); ?></span>
|
|
</div>
|
|
<?php endforeach; ?>
|
|
</div>
|
|
</section>
|