Site Builder
Editing:
modules-social-linkts.php
writable 0666
<?php /************************************************************************** * SOCIAL LINKS MODULE – Gold‑card version * ---------------------------------------------------------------------- * • 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 (gold‑outline card) ===== --> <section class="sl-shell"> <div class="sl-card"> <h2>Follow <?= htmlspecialchars($name) ?></h2> <?= sl_group('Video Channels', $channels['video'] ?? [], 'vid') ?> <?= sl_group('Podcasts', $channels['podcast'] ?? [], 'pod') ?> <?= sl_group('Social', $channels['social'] ?? [], 'soc') ?> </div> </section> <style> /* outer wrapper + card */ .sl-shell{ margin:2.6rem auto; max-width:clamp(480px,70vw,720px); width:100%; font-family:system-ui,Arial,sans-serif; } .sl-card{ background:#fff; padding:1.8rem 1.6rem; border:3.5px solid #ffb63b; /* gold outline */ border-radius:27px; box-shadow:0 8px 26px rgba(0,0,0,.06); text-align:left; } /* headings */ .sl-card h2{margin:0 0 1rem;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} /* badges */ .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 FontAwesome 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