Skip to content

Instantly share code, notes, and snippets.

@plusreed
Created December 18, 2022 19:09
Show Gist options
  • Save plusreed/f1c99303a5a069d25f5ce8ab234fcdb2 to your computer and use it in GitHub Desktop.
Save plusreed/f1c99303a5a069d25f5ce8ab234fcdb2 to your computer and use it in GitHub Desktop.
Twitter-compliant social media link aggregator
<?php
$social_media = [
'Instagram' => 'https://www.instagram.com/username/',
'Facebook' => 'https://www.facebook.com/username/',
];
function request_from_twitter() {
return !(strpos($_SERVER['HTTP_REFERER'], 'twitter.com')
|| strpos($_SERVER['HTTP_REFERER'], 't.co'));
}
if (request_from_twitter()) {
$social_media = array();
}
foreach ($social_media as $name => $url) {
echo '<a href="' . $url . '">' . $name . '</a>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment