feat(donations): clickable OKI links in donation disclaimer
This commit is contained in:
+19
-1
@@ -49,6 +49,24 @@ $currencySymbol = $currency === 'EUR' ? '€' : '$';
|
||||
$stripeOneTimeLinks = defined('STRIPE_ONE_TIME_LINKS') ? STRIPE_ONE_TIME_LINKS : [];
|
||||
$stripeMonthlyLinks = defined('STRIPE_MONTHLY_LINKS') ? STRIPE_MONTHLY_LINKS : [];
|
||||
|
||||
/**
|
||||
* Convertit les URLs d'un texte en liens cliquables tout en échappant le reste.
|
||||
* Utilisé pour le message de transparence sur les dons.
|
||||
*/
|
||||
function linkUrlsInText(string $text): string {
|
||||
$parts = preg_split('/(https?:\/\/[^\s<]+)/i', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
|
||||
$result = '';
|
||||
foreach ($parts as $i => $part) {
|
||||
if ($i % 2 === 1) {
|
||||
$url = htmlspecialchars($part, ENT_QUOTES, 'UTF-8');
|
||||
$result .= '<a href="' . $url . '" target="_blank" rel="noopener noreferrer">' . $url . '</a>';
|
||||
} else {
|
||||
$result .= htmlspecialchars($part, ENT_QUOTES, 'UTF-8');
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="fr">
|
||||
@@ -136,7 +154,7 @@ $stripeMonthlyLinks = defined('STRIPE_MONTHLY_LINKS') ? STRIPE_MONTHLY_LINKS : [
|
||||
<!-- Avertissement de transparence (optionnel) -->
|
||||
<?php if (defined('DONATIONS_OKI_DISCLAIMER') && !empty(DONATIONS_OKI_DISCLAIMER)): ?>
|
||||
<div class="donation-disclaimer" role="note">
|
||||
<p><i class="fas fa-info-circle"></i> <?php echo htmlspecialchars(DONATIONS_OKI_DISCLAIMER); ?></p>
|
||||
<p><i class="fas fa-info-circle"></i> <?php echo linkUrlsInText(DONATIONS_OKI_DISCLAIMER); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user