__( 'United States', 'cpod-kit' ), 'uk' => __( 'United Kingdom', 'cpod-kit' ), 'eu' => __( 'European Union', 'cpod-kit' ), 'other' => __( 'Other Countries', 'cpod-kit' ), ); } /** * Region group of a country: us, uk, eu or other. * * @param string $country ISO code. * @return string */ public static function of( $country ) { $country = strtoupper( (string) $country ); if ( 'US' === $country ) { return 'us'; } if ( 'GB' === $country ) { return 'uk'; } if ( in_array( $country, self::EU, true ) ) { return 'eu'; } return 'other'; } /** * Countries WooCommerce ships to: code => name. * * @return array */ public static function shipping_countries() { if ( ! function_exists( 'WC' ) || ! WC()->countries ) { return array(); } $countries = WC()->countries->get_shipping_countries(); if ( ! $countries ) { $countries = WC()->countries->get_allowed_countries(); } return array_map( 'html_entity_decode', (array) $countries ); } /** All countries known to WooCommerce: code => name. */ public static function all_countries() { if ( ! function_exists( 'WC' ) || ! WC()->countries ) { return array(); } return array_map( 'html_entity_decode', (array) WC()->countries->get_countries() ); } public static function country_name( $code ) { $all = self::all_countries(); return isset( $all[ $code ] ) ? $all[ $code ] : (string) $code; } }