-
-
Save billerickson/465b6228def301c58f5e0ff3c24b35ea 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 | |
/** | |
* State Dropdown | |
* @author Bill Erickson | |
* @see http://www.billerickson.net/code/wpforms-state-dropdown/ | |
* | |
* @param array $field | |
* @param array $field_atts | |
* @param array $form_data | |
* @return array $field | |
*/ | |
function ea_state_dropdown( $field, $field_atts, $form_data ) { | |
if( ! in_array( 'state', $field_atts['field_class'] ) ) | |
return $field; | |
$field['choices'] = array(); | |
$states = wpforms_us_states(); | |
foreach( $states as $value => $label ) | |
$field['choices'][] = array( 'label' => $label, 'value' => $value ); | |
return $field; | |
} | |
add_filter( 'wpforms_select_field_display', 'ea_state_dropdown', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment