Last active
June 21, 2019 00:21
-
-
Save becomevocal/07d46d046c93b41b1a3f436b3eebbd0e to your computer and use it in GitHub Desktop.
Region Selector PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
$bc4wp_regions = [ | |
'en' => [ | |
'img' => 'http://i64.tinypic.com/fd60km.png', | |
'url' => '?region=en', | |
'label' => 'United States', | |
], | |
'fr' => [ | |
'img' => 'http://i65.tinypic.com/300b30k.png', | |
'url' => '?region=fr', | |
'label' => 'France', | |
] | |
]; | |
?> | |
<ul class="languagepicker"> | |
<? | |
$selected_region = 'en'; | |
if (isset($_GET['region']) && isset($bc4wp_regions[$_GET['region']])) { | |
$selected_region = $_GET['region']; | |
} | |
echo '<a href="'.$bc4wp_regions[$selected_region]['url'].'"><li><img src="'.$bc4wp_regions[$selected_region]['img'].'"/>'.$bc4wp_regions[$selected_region]['label'].'</li></a>'; | |
unset($bc4wp_regions[$selected_region]); | |
foreach ($bc4wp_regions as $region) { | |
echo '<a href="'.$region['url'].'"><li><img src="'.$region['img'].'"/>'.$region['label'].'</li></a>'; | |
} | |
?> | |
</ul> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment