LocationList.php
27 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Give\DonorDashboards\Helpers; |
| 4 | |
| 5 | use FormatObjectList; |
| 6 | |
| 7 | /** |
| 8 | * Normalize format of location type lists. |
| 9 | * @since 2.10.0 |
| 10 | */ |
| 11 | class LocationList { |
| 12 | |
| 13 | public static function getCountries() { |
| 14 | $countries = give_get_country_list(); |
| 15 | unset( $countries[''] ); |
| 16 | $formatter = FormatObjectList\Factory::fromKeyValue( $countries ); |
| 17 | return $formatter->format(); |
| 18 | } |
| 19 | |
| 20 | public static function getStates( $country ) { |
| 21 | $states = give_get_states( $country ); |
| 22 | $states[''] = sprintf( '%s...', esc_html__( 'Select', 'give' ) ); |
| 23 | $formatter = FormatObjectList\Factory::fromKeyValue( $states ); |
| 24 | return $formatter->format(); |
| 25 | } |
| 26 | } |
| 27 |