Created
July 30, 2019 10:44
-
-
Save anhskohbo/9a4bcbc36acce5868b83e89359a0644f to your computer and use it in GitHub Desktop.
This file contains 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
<?php | |
// Paste this code into your theme/functions.php | |
add_action( 'abrs_countries_dataset', function ( $countries ) { | |
$top = [ 'VN', 'US' ]; | |
uasort( $countries, function ( $country1, $country2 ) use ( $top ) { | |
$top = array_reverse( $top ); | |
$priority1 = array_search( $country1['alpha2'], $top ); | |
$priority2 = array_search( $country2['alpha2'], $top ); | |
$priority1 = ( false === $priority1 ) ? -1 : $priority1; | |
$priority2 = ( false === $priority2 ) ? -1 : $priority2; | |
return $priority1 < $priority2 ? 1 : -1; | |
} ); | |
return $countries; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment