Skip to content

Instantly share code, notes, and snippets.

@andrasguseo
Last active January 20, 2021 21:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrasguseo/f0192a39f00c06ba51ce9be2f8c04fa2 to your computer and use it in GitHub Desktop.
Save andrasguseo/f0192a39f00c06ba51ce9be2f8c04fa2 to your computer and use it in GitHub Desktop.
TEC > Use abbreviations in US state names
<?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