Skip to content

Instantly share code, notes, and snippets.

@anhskohbo
Created July 30, 2019 10:44
Show Gist options
  • Save anhskohbo/9a4bcbc36acce5868b83e89359a0644f to your computer and use it in GitHub Desktop.
Save anhskohbo/9a4bcbc36acce5868b83e89359a0644f to your computer and use it in GitHub Desktop.
<?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