(int) $limit) { return false; } set_transient($key, $count + $amount, (int) $window); return true; } /** * Whether a language code is one this site offers: the default language and the languages the * site has enabled or detects. Language codes come from URLs and request parameters, so anything * that spends translation credits for a language must check this first. * * @param string $lang Language code from the request. * @return bool */ function lang_is_offered($lang) { $lang = strtolower(trim((string) $lang)); if ($lang === '') { return false; } $allowed = array_merge( [(string) AI_Lang::default()], (array) AI_Lang::enabled(), (array) AI_Lang::detectable() ); foreach ($allowed as $code) { if ($lang === strtolower((string) $code)) { return true; } } return false; }