WC_Countries::get_countries
Get all countries.
Метод класса: WC_Countries{}
Хуки из метода
Возвращает
array.
Использование
$WC_Countries = new WC_Countries(); $WC_Countries->get_countries();
Код WC_Countries::get_countries() WC Countries::get countries WC 11.2.2
public function get_countries() {
$locale = $this->get_cache_locale();
if ( empty( $this->geo_cache['countries'][ $locale ] ) ) {
// A lookup made while this entry is being built (for example from a locale filter) gets no data instead of recursing.
if ( isset( $this->geo_cache_building['countries'][ $locale ] ) ) {
return array();
}
$this->geo_cache_building['countries'][ $locale ] = true;
try {
/**
* Allows filtering of the list of countries in WC.
*
* @since 1.5.3
*
* @param array $countries
*/
$this->geo_cache['countries'][ $locale ] = apply_filters( 'woocommerce_countries', include WC()->plugin_path() . '/i18n/countries.php' );
/**
* Filters whether the list of countries is sorted by name.
*
* @since 2.0.0
*
* @param bool $sort Whether to sort the countries. Default true.
*/
if ( apply_filters( 'woocommerce_sort_countries', true ) ) {
wc_asort_by_locale( $this->geo_cache['countries'][ $locale ], $locale );
}
} finally {
unset( $this->geo_cache_building['countries'][ $locale ] );
}
}
return $this->geo_cache['countries'][ $locale ];
}