Last active
January 20, 2021 21:59
-
-
Save andrasguseo/f0192a39f00c06ba51ce9be2f8c04fa2 to your computer and use it in GitHub Desktop.
TEC > Use abbreviations in US state names
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 | |
/* Description: In the US state dropdown the abbreviations will be used instead of the full state name. | |
* Usage: Paste the below snippet into your active (child) theme's functions.php file | |
* | |
* Plugin: The Events Calendar | |
* Author: Andras Guseo | |
* Last updated: 2021-01-20 | |
*/ | |
add_filter( 'tribe_us_states', 'tec_states_abbrev_only' ); | |
function tec_states_abbrev_only( $states ) { | |
foreach( $states as $abbr => $fullname ) { | |
// Use this for: CA | |
$new_states[$abbr] = $abbr; | |
// Use this for: CA (California) | |
//$new_states[$abbr] = $abbr . ' (' . $fullname . ')'; | |
// Use this for: CA - California | |
//$new_states[$abbr] = $abbr . ' - ' . $fullname; | |
} | |
// Resorting by abbreviation | |
ksort( $new_states ); | |
return $new_states; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment