Fix i18n deprecation notice for translating too early

This commit is contained in:
David Stone
2025-02-15 15:06:43 -07:00
parent 6d7e7cef66
commit eb29a438a5
26 changed files with 98 additions and 104 deletions

View File

@ -85,7 +85,7 @@ function wu_get_currencies(): array {
function wu_get_currency_symbol($currency = '') {
if ( ! $currency) {
$currency = wu_get_setting('currency_symbol');
$currency = wu_get_setting('currency_symbol', 'USD');
} switch ($currency) {
case 'AED':
$currency_symbol = 'د.إ';
@ -252,10 +252,10 @@ function wu_format_currency($value, $currency = null, $format = null, $thousands
$atts = wp_parse_args(
$args,
[
'currency' => wu_get_setting('currency_symbol'),
'format' => wu_get_setting('currency_position'),
'thousands_sep' => wu_get_setting('thousand_separator'),
'decimal_sep' => wu_get_setting('decimal_separator'),
'currency' => wu_get_setting('currency_symbol', 'USD'),
'format' => wu_get_setting('currency_position', '%s %v'),
'thousands_sep' => wu_get_setting('thousand_separator', ','),
'decimal_sep' => wu_get_setting('decimal_separator', '.'),
'precision' => (int) wu_get_setting('precision', 2),
]
);

View File

@ -766,3 +766,27 @@ function wu_is_block_theme() {
return false;
}
/**
* Generate flag emoji from a two-character country code.
*
* @param string $country_code The two-letter uppercase country code (e.g., "US", "GB").
* @return string The flag emoji or empty string if invalid input.
*/
function wu_get_flag_emoji(string $country_code): string {
// Ensure the country code is uppercase.
$country_code = strtoupper($country_code);
// Validate that the input is exactly two letters.
if (strlen($country_code) !== 2 || ! ctype_alpha($country_code)) {
return ''; // Return an empty string for invalid input.
}
// Convert the country code to regional indicator symbols.
$emoji = '';
foreach (str_split($country_code) as $char) {
$emoji .= mb_chr(0x1F1E6 - ord('A') + ord($char), 'UTF-8');
}
return $emoji;
}

View File

@ -146,7 +146,7 @@ function wu_get_network_logo($size = 'full') {
switch_to_blog(wu_get_main_site_id());
$settings_logo = wp_get_attachment_image_src(wu_get_setting('company_logo'), $size); // phpcs:ignore
$settings_logo = wp_get_attachment_image_src(wu_get_setting('company_logo', ''), $size); // phpcs:ignore
restore_current_blog();