导入 AKSRT 主题开发源码
This commit is contained in:
1 parent
9681dd3d48
commit
1268a55dd0
595 files changed
+127705
No files matched your search
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
/**
|
||||
* Home Module · Product Showcase
|
||||
*
|
||||
* config: { title?, products: [{ title, desc, image, price?, url? }], columns? }
|
||||
*
|
||||
* 产品展示模块,用于商城/资源推荐。
|
||||
*/
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$cfg = get_query_var('aksrt_module_config', []);
|
||||
if (!is_array($cfg)) $cfg = [];
|
||||
|
||||
$title = (string) ($cfg['title'] ?? '');
|
||||
$products = isset($cfg['products']) && is_array($cfg['products']) ? $cfg['products'] : [];
|
||||
$columns = max(1, min(4, (int) ($cfg['columns'] ?? 3)));
|
||||
|
||||
if (empty($products)) return;
|
||||
?>
|
||||
|
||||
<section class="home-module home-module--product-showcase 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__product-grid" style="grid-template-columns:repeat(<?php echo esc_attr((string) $columns); ?>, 1fr)">
|
||||
<?php foreach ($products as $product) :
|
||||
$p_title = (string) ($product['title'] ?? '');
|
||||
$p_desc = (string) ($product['desc'] ?? '');
|
||||
$p_image = (string) ($product['image'] ?? '');
|
||||
$p_price = (string) ($product['price'] ?? '');
|
||||
$p_url = (string) ($product['url'] ?? '');
|
||||
if ($p_title === '') continue;
|
||||
?>
|
||||
<a href="<?php echo esc_url($p_url ?: '#'); ?>" class="aksrt-product-card">
|
||||
<?php if ($p_image !== '') : ?>
|
||||
<div class="aksrt-product-card__image">
|
||||
<img src="<?php echo esc_url($p_image); ?>" alt="<?php echo esc_attr($p_title); ?>"<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="aksrt-product-card__body">
|
||||
<h3 class="aksrt-product-card__title"><?php echo esc_html($p_title); ?></h3>
|
||||
<?php if ($p_desc !== '') : ?>
|
||||
<p class="aksrt-product-card__desc"><?php echo esc_html($p_desc); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ($p_price !== '') : ?>
|
||||
<span class="aksrt-product-card__price"><?php echo esc_html($p_price); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</section>
|
||||
Reference in new issue
Block a user