Files
wordpress-theme-aksrt/templates/parts/home-modules/module-friend_links.php
T

48 lines
1.5 KiB
PHP

<?php
/**
* Home Module · Friend Links
*
* config: { title? }
*/
defined('ABSPATH') || exit;
$cfg = get_query_var('aksrt_module_config', []);
if (!is_array($cfg)) $cfg = [];
$title = (string) ($cfg['title'] ?? '');
$friend_links = aksrt_get_friend_links();
if (!is_array($friend_links) || empty($friend_links)) return;
if (empty($friend_links)) return;
?>
<section class="home-module home-module--friends container" aria-label="<?php echo esc_attr($title ?: __('友情链接', 'aksrt')); ?>">
<header class="home-module__header">
<h2 class="home-module__title"><?php echo esc_html($title ?: __('友情链接', 'aksrt')); ?></h2>
</header>
<ul class="home-module__friends-list">
<?php foreach ($friend_links as $link) :
$url = $link['url'] ?? '';
$name = $link['name'] ?? '';
$description = $link['description'] ?? '';
$logo = $link['logo'] ?? '';
if (!$url || !$name) continue;
?>
<li>
<a href="<?php echo esc_url($url); ?>" target="_blank" rel="noopener noreferrer external" class="home-module__friend-card">
<?php if ($logo) : ?>
<img src="<?php echo esc_url($logo); ?>" alt="" class="home-module__friend-avatar"<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('other') : ' loading="lazy"'; ?>>
<?php endif; ?>
<div class="home-module__friend-meta">
<strong><?php echo esc_html($name); ?></strong>
<?php if ($description) : ?>
<span><?php echo esc_html($description); ?></span>
<?php endif; ?>
</div>
</a>
</li>
<?php endforeach; ?>
</ul>
</section>