Single state file to avoid loops and reading multiple files on page load.
This commit is contained in:
parent
64aafeca27
commit
f1afbcf03a
File diff suppressed because it is too large
Load Diff
|
@ -92,60 +92,13 @@ class WC_Countries {
|
|||
|
||||
/**
|
||||
* Load the states.
|
||||
*
|
||||
* @deprecated 3.6.0 This method was used to load state files, but is no longer needed. @see get_states().
|
||||
*/
|
||||
public function load_country_states() {
|
||||
global $states;
|
||||
|
||||
// States set to array() are blank i.e. the country has no use for the state field.
|
||||
$states = array(
|
||||
'AF' => array(),
|
||||
'AT' => array(),
|
||||
'AX' => array(),
|
||||
'BE' => array(),
|
||||
'BH' => array(),
|
||||
'BI' => array(),
|
||||
'CZ' => array(),
|
||||
'DE' => array(),
|
||||
'DK' => array(),
|
||||
'EE' => array(),
|
||||
'FI' => array(),
|
||||
'FR' => array(),
|
||||
'GP' => array(),
|
||||
'GF' => array(),
|
||||
'IS' => array(),
|
||||
'IL' => array(),
|
||||
'IM' => array(),
|
||||
'KR' => array(),
|
||||
'KW' => array(),
|
||||
'LB' => array(),
|
||||
'LU' => array(),
|
||||
'MQ' => array(),
|
||||
'MT' => array(),
|
||||
'NL' => array(),
|
||||
'NO' => array(),
|
||||
'PL' => array(),
|
||||
'PT' => array(),
|
||||
'RE' => array(),
|
||||
'SG' => array(),
|
||||
'SK' => array(),
|
||||
'SI' => array(),
|
||||
'LK' => array(),
|
||||
'SE' => array(),
|
||||
'VN' => array(),
|
||||
'YT' => array(),
|
||||
);
|
||||
|
||||
// Load states for all other countries from our locale files.
|
||||
$countries = $this->get_countries();
|
||||
|
||||
if ( ! empty( $countries ) ) {
|
||||
foreach ( $countries as $code => $country ) {
|
||||
if ( ! isset( $states[ $code ] ) && file_exists( WC()->plugin_path() . '/i18n/states/' . $code . '.php' ) ) {
|
||||
include WC()->plugin_path() . '/i18n/states/' . $code . '.php';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$states = include WC()->plugin_path() . '/i18n/states.php';
|
||||
$this->states = apply_filters( 'woocommerce_states', $states );
|
||||
}
|
||||
|
||||
|
@ -156,8 +109,8 @@ class WC_Countries {
|
|||
* @return false|array of states
|
||||
*/
|
||||
public function get_states( $cc = null ) {
|
||||
if ( empty( $this->states ) ) {
|
||||
$this->load_country_states();
|
||||
if ( ! isset( $this->states ) ) {
|
||||
$this->states = apply_filters( 'woocommerce_states', include WC()->plugin_path() . '/i18n/states.php' );
|
||||
}
|
||||
|
||||
if ( ! is_null( $cc ) ) {
|
||||
|
|
Loading…
Reference in New Issue