Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit 1d0cf96

Browse files
author
Justin Shreve
committed
Carry over get_countries_and_states for get_group_settings
1 parent cc5a079 commit 1d0cf96

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

api/class-wc-rest-dev-setting-options-controller.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,30 @@ public function get_group_settings( $group_id ) {
160160
return $filtered_settings;
161161
}
162162

163+
/**
164+
* Returns a list of countries and states for use in the base location setting.
165+
*
166+
* @since 3.0.7
167+
* @return array Array of states and countries.
168+
*/
169+
private function get_countries_and_states() {
170+
$countries = WC()->countries->get_countries();
171+
if ( ! $countries ) {
172+
return array();
173+
}
174+
$output = array();
175+
foreach ( $countries as $key => $value ) {
176+
if ( $states = WC()->countries->get_states( $key ) ) {
177+
foreach ( $states as $state_key => $state_value ) {
178+
$output[ $key . ':' . $state_key ] = $value . ' - ' . $state_value;
179+
}
180+
} else {
181+
$output[ $key ] = $value;
182+
}
183+
}
184+
return $output;
185+
}
186+
163187
/**
164188
* Get the settings schema, conforming to JSON Schema.
165189
*

0 commit comments

Comments
 (0)