Site Builder
Editing:
tools-links.php
writable 0666
<?php /************************************************************************** * LINKS MODULE — Recommended articles & resources * ---------------------------------------------------------------------- * • Reads ../../links.json (array of {title,url,excerpt}) * • Premium users: show list when ≥1 links * • Free users: show gentle upsell when 0 links **************************************************************************/ /* ---------- 1. Load profile & determine tier ---------- */ if (function_exists('get_profile')) { $profile = get_profile(); } $isPremium = !empty($profile['premium']) && strtolower($profile['premium']) !== 'off'; /* ---- NEW: always fall back to business “name” field ---- */ $name = $profile['display_name'] ?? $profile['name'] // ← business profiles ?? $profile['handle'] ?? 'BestDealOn'; /* ---------- 2. Load links.json ---------- */ $linksPath = dirname(__DIR__, 2) . '/links.json'; $linksRaw = is_readable($linksPath) ? json_decode(file_get_contents($linksPath), true) : []; $linksRaw = get_links(); $links = is_array($linksRaw) ? array_values(array_filter($linksRaw, fn($l)=>!empty($l['title']) && !empty($l['url']))) : []; /* ---------- 3. Decide what to render ---------- */ $showList = $isPremium && $links; $showUpsell = !$showList; // either free tier OR premium with zero links ?> <section class="ln-shell"> <div class="ln-card"> <?php if ($showList): ?> <h2>🔗 <?= htmlspecialchars($name) ?>’s Recommended Links</h2> <ul class="ln-list"> <?php foreach (array_slice($links, 0, 5) as $l): $title = htmlspecialchars($l['title']); $url = htmlspecialchars($l['url']); $disp = preg_replace('#^https?://#','',$url); $ex = htmlspecialchars($l['excerpt'] ?? ''); ?> <li> <a class="ln-title" href="<?= $url ?>" target="_blank" rel="noopener"><?= $title ?></a> <div class="ln-url"><?= $disp ?></div> <?php if ($ex): ?><div class="ln-excerpt"><?= $ex ?></div><?php endif; ?> </li> <?php endforeach; ?> </ul> <?php else: /* upsell or placeholder */ ?> <h2>🔗 Recommended Links</h2> <p class="ln-upsell"> <?php if ($isPremium): ?> You haven’t added any links yet. Head to your dashboard to showcase your favourite articles and sponsor pages. <?php else: ?> Upgrade to a verified creator account to showcase your favourite articles, videos and sponsor pages here. <?php endif; ?> </p> <?php endif; ?> </div> </section> <style> /* ---------- shell keeps width consistent with other cards ---------- */ .ln-shell{margin:2.6rem auto;max-width:clamp(480px,70vw,720px);width:100%; font-family:system-ui,Arial,sans-serif} /* ---------- card ---------- */ .ln-card{ background:#fff;padding:1.7rem 1.5rem;border:3.5px solid #ffb63b; border-radius:27px;box-shadow:0 8px 26px rgba(0,0,0,.06) } .ln-card h2{margin:0 0 1.1rem;font-size:1.35rem;font-weight:700;color:#102a66;text-align:center} /* ---------- list styles ---------- */ .ln-list{list-style:none;padding:0;margin:0} .ln-list li{margin:1.15em 0} .ln-title{font-size:1.05rem;color:#1a0dab;text-decoration:none} .ln-title:hover{text-decoration:underline} .ln-url{font-size:.83rem;color:#006621;margin-top:.1em} .ln-excerpt{font-size:.9rem;color:#545454;margin-top:.25em;line-height:1.35} /* ---------- upsell paragraph ---------- */ .ln-upsell{font-size:.95rem;color:#333;text-align:center;margin:0} </style>
Save changes
Create folder
writable 0777
Create
Cancel