contact.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. /**
  3. * Contact page — same minimal, centered style as the landing intro.
  4. * Content (title, text and contact methods) is edited in admin → Contact.
  5. */
  6. require __DIR__ . '/app/bootstrap.php';
  7. $site = site_get();
  8. $title = $site['contact_title'] ?: 'Get in touch';
  9. $email = trim((string)($site['contact_email'] ?? ''));
  10. $phone = trim((string)($site['contact_phone'] ?? ''));
  11. $insta = trim((string)($site['contact_instagram'] ?? ''));
  12. /** Turn an Instagram handle or URL into a link + label. */
  13. $instaLink = null;
  14. $instaLabel = null;
  15. if ($insta !== '') {
  16. if (preg_match('#^https?://#i', $insta)) {
  17. $instaLink = $insta;
  18. $instaLabel = preg_replace('#^https?://(www\.)?instagram\.com/#i', '@', rtrim($insta, '/'));
  19. } else {
  20. $handle = ltrim($insta, '@');
  21. $instaLink = 'https://instagram.com/' . rawurlencode($handle);
  22. $instaLabel = '@' . $handle;
  23. }
  24. }
  25. public_header($title . ' · ' . ($site['intro_title'] ?: config('site.name', '')), 'contact');
  26. ?>
  27. <section class="intro contact">
  28. <h1 class="contact-title"><?= e($title) ?></h1>
  29. <?php if (trim((string)($site['contact_text'] ?? '')) !== ''): ?>
  30. <p><?= e($site['contact_text']) ?></p>
  31. <?php endif; ?>
  32. <div class="contact-methods">
  33. <?php if ($email !== ''): ?>
  34. <a href="mailto:<?= e($email) ?>"><?= e($email) ?></a>
  35. <?php endif; ?>
  36. <?php if ($phone !== ''): ?>
  37. <a href="tel:<?= e(preg_replace('/[^\d+]/', '', $phone)) ?>"><?= e($phone) ?></a>
  38. <?php endif; ?>
  39. <?php if ($instaLink !== null): ?>
  40. <a href="<?= e($instaLink) ?>" target="_blank" rel="noopener noreferrer"><?= e($instaLabel) ?></a>
  41. <?php endif; ?>
  42. </div>
  43. </section>
  44. <?php public_footer(); ?>