导入 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 · Partner Marquee
|
||||
*
|
||||
* config: { title?, items: [{ name, image, url? }], speed? }
|
||||
*
|
||||
* 合作伙伴横向滚动模块。
|
||||
*/
|
||||
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'] : [];
|
||||
$speed = max(10, min(120, (int) ($cfg['speed'] ?? 30)));
|
||||
|
||||
if (empty($items)) return;
|
||||
?>
|
||||
|
||||
<section class="home-module home-module--partner-marquee 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="aksrt-marquee" style="--marquee-duration:<?php echo esc_attr((string) $speed); ?>s">
|
||||
<div class="aksrt-marquee__track">
|
||||
<?php
|
||||
// 渲染两份以实现无缝循环
|
||||
for ($pass = 0; $pass < 2; $pass++) :
|
||||
foreach ($items as $partner) :
|
||||
$name = (string) ($partner['name'] ?? '');
|
||||
$image = (string) ($partner['image'] ?? '');
|
||||
$url = (string) ($partner['url'] ?? '');
|
||||
if ($image === '' && $name === '') continue;
|
||||
|
||||
$tag = $url !== '' ? 'a' : 'span';
|
||||
$attrs = $url !== '' ? ' href="' . esc_url($url) . '" target="_blank" rel="noopener"' : '';
|
||||
?>
|
||||
<<?php echo esc_attr($tag); ?> class="aksrt-marquee__item"<?php echo $attrs; ?>>
|
||||
<?php if ($image !== '') : ?>
|
||||
<img src="<?php echo esc_url($image); ?>" alt="<?php echo esc_attr($name); ?>"<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
|
||||
<?php else : ?>
|
||||
<span><?php echo esc_html($name); ?></span>
|
||||
<?php endif; ?>
|
||||
</<?php echo esc_attr($tag); ?>>
|
||||
<?php
|
||||
endforeach;
|
||||
endfor;
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
Reference in new issue
Block a user