Site Builder
Editing:
modules-social-link1s.php
writable 0666
<?php /************************************************************************** * SOCIAL LINKS MODULE * ---------------------------------------------------------------------- * • Shows channels.video / channels.podcast / channels.social * • Colour‑codes each group, loads FontAwesome once **************************************************************************/ /* 1) Grab profile if caller hasn’t supplied it */ if (!isset($profile) || !is_array($profile)) { $json = dirname(__DIR__, 2) . '/profile.json'; $profile = is_readable($json) ? json_decode(file_get_contents($json), true) : []; } /* 2) Shorthand vars */ $name = $profile['display_name'] ?? $profile['handle'] ?? 'Profile'; $channels = $profile['channels'] ?? []; /* 3) Nothing to show? */ if (!$channels) { return; } /* 4) Badge helper */ function sl_badge(string $label, string $url, string $cls): string { $icon = match(strtolower($label)){ /* video */ 'youtube' => 'fab fa-youtube', 'rumble' => 'fas fa-video', 'odysee' => 'fas fa-video', /* podcast */ 'spotify' => 'fab fa-spotify', 'apple' => 'fab fa-apple', 'rss' => 'fas fa-rss', /* social */ 'twitter' => 'fab fa-twitter', 'tiktok' => 'fab fa-tiktok', 'instagram' => 'fab fa-instagram', 'facebook' => 'fab fa-facebook', 'linkedin' => 'fab fa-linkedin', 'patreon' => 'fab fa-patreon', default => 'fas fa-link' }; $safe = htmlspecialchars($label); $href = htmlspecialchars($url); return "<a class=\"sl-badge $cls\" href=\"$href\" target=\"_blank\" rel=\"noopener\"> <i class=\"$icon\"></i> $safe </a>"; } /* 5) Render a single group if it has ≥1 URLs */ function sl_group(string $title, array $arr, string $cls): string { if (!$arr) return ''; $html = "<h3 class=\"sl-sub\">$title</h3>\n"; foreach ($arr as $lbl => $u) { if (!$u) continue; $html .= sl_badge($lbl, $u, $cls) . "\n"; } return $html; } ?> <!-- ===== SOCIAL LINKS SECTION ===== --> <section class="sl-wrap"> <h2>Follow <?= htmlspecialchars($name) ?></h2> <?= sl_group('Video Channels', $channels['video'] ?? [], 'vid') ?> <?= sl_group('Podcasts', $channels['podcast'] ?? [], 'pod') ?> <?= sl_group('Social', $channels['social'] ?? [], 'soc') ?> </section> <style> /* scoped styles */ .sl-wrap{padding:1.6rem 0;border-bottom:1px solid #e4e9f3;font-family:system-ui,Arial,sans-serif} .sl-wrap h2{margin:.1em 0 .8em;font-size:1.35rem;font-weight:700;color:#102a66} .sl-sub{margin:1.1em 0 .4em;font-size:1.05rem;font-weight:600;color:#555} .sl-badge{ display:inline-block;margin:.25em .33em;padding:.34em .65em .28em; border-radius:16px;font-size:.88rem;font-weight:600;text-decoration:none; color:#fff;transition:.15s background;box-shadow:0 1px 4px rgba(0,0,0,.08) } .sl-badge i{margin-right:.4em} /* colour coding */ .vid {background:#FF5252;} /* red-ish */ .pod {background:#A259FF;} /* purple */ .soc {background:#4285F4;} /* blue */ .sl-badge:hover{opacity:.85} @media(max-width:480px){ .sl-badge{display:inline-flex;align-items:center;gap:.35em} } </style> <?php /* load FA once */ static $faLoaded = false; if (!$faLoaded){ echo '<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.4/css/all.min.css" media="all">'; $faLoaded = true; } ?>
Save changes
Create folder
writable 0777
Create
Cancel