WC_Countries::get_cache_locale
Get the active request locale for geographical cache entries.
Locale filter callbacks may read country data. While determine_locale() runs, those nested lookups reuse the last resolved locale instead of resolving it again, and whatever they cache is discarded afterwards.
Метод класса: WC_Countries{}
Хуков нет.
Возвращает
string.
Использование
// private - только в коде основоного (родительского) класса $result = $this->get_cache_locale();
Код WC_Countries::get_cache_locale() WC Countries::get cache locale WC 11.3.0
private function get_cache_locale() {
if ( null !== self::$locale_resolution_snapshots ) {
$object_id = spl_object_id( $this );
// Every writer of $geo_cache calls this method first, so an instance is snapshotted before any nested write.
if ( ! isset( self::$locale_resolution_snapshots[ $object_id ] ) ) {
self::$locale_resolution_snapshots[ $object_id ] = array( $this, $this->geo_cache );
}
return $this->last_cache_locale ?? 'en_US';
}
self::$locale_resolution_snapshots = array();
try {
$locale = determine_locale();
} finally {
self::restore_locale_resolution_snapshots();
}
$this->last_cache_locale = is_string( $locale ) && $locale ? $locale : 'en_US';
return $this->last_cache_locale;
}