Filter
rpress_shop_states
On this page
Filters the list of states or provinces returned for a country.
Applied at the end of rpress_get_states(). The function picks a country-specific list (for example the US, Canada or India) and returns an empty array for countries that have no list. Use this filter to add, remove or replace entries for any country. Keys are state codes and values are display names.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$states | array | Associative array of state code => state name for the country. Empty if no list exists for the country. |
$country | string | Two-letter country code the states were requested for. |
Return value#
array. The state list for the country.
Example#
function my_add_states( $states, $country ) {
if ( 'NL' === $country && empty( $states ) ) {
$states = array(
'NH' => 'Noord-Holland',
'ZH' => 'Zuid-Holland',
);
}
return $states;
}
add_filter( 'rpress_shop_states', 'my_add_states', 10, 2 );
Source#
Applied in:
includes/country-functions.php(line 126), inrpress_get_states()
See also#
Was this page helpful?
