Merge pull request #16680 from atimmer/stories/at/improve-currencies-performance

Cache currencies for performance
This commit is contained in:
Claudiu Lodromanean 2017-09-01 11:29:17 -07:00 committed by GitHub
commit 2576ba7f8e
1 changed files with 173 additions and 167 deletions

View File

@ -281,175 +281,182 @@ function get_woocommerce_currency() {
* @return array * @return array
*/ */
function get_woocommerce_currencies() { function get_woocommerce_currencies() {
return array_unique( static $currencies;
apply_filters( 'woocommerce_currencies',
array( if ( ! isset( $currencies ) ) {
'AED' => __( 'United Arab Emirates dirham', 'woocommerce' ), $currencies = array_unique(
'AFN' => __( 'Afghan afghani', 'woocommerce' ), apply_filters( 'woocommerce_currencies',
'ALL' => __( 'Albanian lek', 'woocommerce' ), array(
'AMD' => __( 'Armenian dram', 'woocommerce' ), 'AED' => __( 'United Arab Emirates dirham', 'woocommerce' ),
'ANG' => __( 'Netherlands Antillean guilder', 'woocommerce' ), 'AFN' => __( 'Afghan afghani', 'woocommerce' ),
'AOA' => __( 'Angolan kwanza', 'woocommerce' ), 'ALL' => __( 'Albanian lek', 'woocommerce' ),
'ARS' => __( 'Argentine peso', 'woocommerce' ), 'AMD' => __( 'Armenian dram', 'woocommerce' ),
'AUD' => __( 'Australian dollar', 'woocommerce' ), 'ANG' => __( 'Netherlands Antillean guilder', 'woocommerce' ),
'AWG' => __( 'Aruban florin', 'woocommerce' ), 'AOA' => __( 'Angolan kwanza', 'woocommerce' ),
'AZN' => __( 'Azerbaijani manat', 'woocommerce' ), 'ARS' => __( 'Argentine peso', 'woocommerce' ),
'BAM' => __( 'Bosnia and Herzegovina convertible mark', 'woocommerce' ), 'AUD' => __( 'Australian dollar', 'woocommerce' ),
'BBD' => __( 'Barbadian dollar', 'woocommerce' ), 'AWG' => __( 'Aruban florin', 'woocommerce' ),
'BDT' => __( 'Bangladeshi taka', 'woocommerce' ), 'AZN' => __( 'Azerbaijani manat', 'woocommerce' ),
'BGN' => __( 'Bulgarian lev', 'woocommerce' ), 'BAM' => __( 'Bosnia and Herzegovina convertible mark', 'woocommerce' ),
'BHD' => __( 'Bahraini dinar', 'woocommerce' ), 'BBD' => __( 'Barbadian dollar', 'woocommerce' ),
'BIF' => __( 'Burundian franc', 'woocommerce' ), 'BDT' => __( 'Bangladeshi taka', 'woocommerce' ),
'BMD' => __( 'Bermudian dollar', 'woocommerce' ), 'BGN' => __( 'Bulgarian lev', 'woocommerce' ),
'BND' => __( 'Brunei dollar', 'woocommerce' ), 'BHD' => __( 'Bahraini dinar', 'woocommerce' ),
'BOB' => __( 'Bolivian boliviano', 'woocommerce' ), 'BIF' => __( 'Burundian franc', 'woocommerce' ),
'BRL' => __( 'Brazilian real', 'woocommerce' ), 'BMD' => __( 'Bermudian dollar', 'woocommerce' ),
'BSD' => __( 'Bahamian dollar', 'woocommerce' ), 'BND' => __( 'Brunei dollar', 'woocommerce' ),
'BTC' => __( 'Bitcoin', 'woocommerce' ), 'BOB' => __( 'Bolivian boliviano', 'woocommerce' ),
'BTN' => __( 'Bhutanese ngultrum', 'woocommerce' ), 'BRL' => __( 'Brazilian real', 'woocommerce' ),
'BWP' => __( 'Botswana pula', 'woocommerce' ), 'BSD' => __( 'Bahamian dollar', 'woocommerce' ),
'BYR' => __( 'Belarusian ruble', 'woocommerce' ), 'BTC' => __( 'Bitcoin', 'woocommerce' ),
'BZD' => __( 'Belize dollar', 'woocommerce' ), 'BTN' => __( 'Bhutanese ngultrum', 'woocommerce' ),
'CAD' => __( 'Canadian dollar', 'woocommerce' ), 'BWP' => __( 'Botswana pula', 'woocommerce' ),
'CDF' => __( 'Congolese franc', 'woocommerce' ), 'BYR' => __( 'Belarusian ruble', 'woocommerce' ),
'CHF' => __( 'Swiss franc', 'woocommerce' ), 'BZD' => __( 'Belize dollar', 'woocommerce' ),
'CLP' => __( 'Chilean peso', 'woocommerce' ), 'CAD' => __( 'Canadian dollar', 'woocommerce' ),
'CNY' => __( 'Chinese yuan', 'woocommerce' ), 'CDF' => __( 'Congolese franc', 'woocommerce' ),
'COP' => __( 'Colombian peso', 'woocommerce' ), 'CHF' => __( 'Swiss franc', 'woocommerce' ),
'CRC' => __( 'Costa Rican colón', 'woocommerce' ), 'CLP' => __( 'Chilean peso', 'woocommerce' ),
'CUC' => __( 'Cuban convertible peso', 'woocommerce' ), 'CNY' => __( 'Chinese yuan', 'woocommerce' ),
'CUP' => __( 'Cuban peso', 'woocommerce' ), 'COP' => __( 'Colombian peso', 'woocommerce' ),
'CVE' => __( 'Cape Verdean escudo', 'woocommerce' ), 'CRC' => __( 'Costa Rican colón', 'woocommerce' ),
'CZK' => __( 'Czech koruna', 'woocommerce' ), 'CUC' => __( 'Cuban convertible peso', 'woocommerce' ),
'DJF' => __( 'Djiboutian franc', 'woocommerce' ), 'CUP' => __( 'Cuban peso', 'woocommerce' ),
'DKK' => __( 'Danish krone', 'woocommerce' ), 'CVE' => __( 'Cape Verdean escudo', 'woocommerce' ),
'DOP' => __( 'Dominican peso', 'woocommerce' ), 'CZK' => __( 'Czech koruna', 'woocommerce' ),
'DZD' => __( 'Algerian dinar', 'woocommerce' ), 'DJF' => __( 'Djiboutian franc', 'woocommerce' ),
'EGP' => __( 'Egyptian pound', 'woocommerce' ), 'DKK' => __( 'Danish krone', 'woocommerce' ),
'ERN' => __( 'Eritrean nakfa', 'woocommerce' ), 'DOP' => __( 'Dominican peso', 'woocommerce' ),
'ETB' => __( 'Ethiopian birr', 'woocommerce' ), 'DZD' => __( 'Algerian dinar', 'woocommerce' ),
'EUR' => __( 'Euro', 'woocommerce' ), 'EGP' => __( 'Egyptian pound', 'woocommerce' ),
'FJD' => __( 'Fijian dollar', 'woocommerce' ), 'ERN' => __( 'Eritrean nakfa', 'woocommerce' ),
'FKP' => __( 'Falkland Islands pound', 'woocommerce' ), 'ETB' => __( 'Ethiopian birr', 'woocommerce' ),
'GBP' => __( 'Pound sterling', 'woocommerce' ), 'EUR' => __( 'Euro', 'woocommerce' ),
'GEL' => __( 'Georgian lari', 'woocommerce' ), 'FJD' => __( 'Fijian dollar', 'woocommerce' ),
'GGP' => __( 'Guernsey pound', 'woocommerce' ), 'FKP' => __( 'Falkland Islands pound', 'woocommerce' ),
'GHS' => __( 'Ghana cedi', 'woocommerce' ), 'GBP' => __( 'Pound sterling', 'woocommerce' ),
'GIP' => __( 'Gibraltar pound', 'woocommerce' ), 'GEL' => __( 'Georgian lari', 'woocommerce' ),
'GMD' => __( 'Gambian dalasi', 'woocommerce' ), 'GGP' => __( 'Guernsey pound', 'woocommerce' ),
'GNF' => __( 'Guinean franc', 'woocommerce' ), 'GHS' => __( 'Ghana cedi', 'woocommerce' ),
'GTQ' => __( 'Guatemalan quetzal', 'woocommerce' ), 'GIP' => __( 'Gibraltar pound', 'woocommerce' ),
'GYD' => __( 'Guyanese dollar', 'woocommerce' ), 'GMD' => __( 'Gambian dalasi', 'woocommerce' ),
'HKD' => __( 'Hong Kong dollar', 'woocommerce' ), 'GNF' => __( 'Guinean franc', 'woocommerce' ),
'HNL' => __( 'Honduran lempira', 'woocommerce' ), 'GTQ' => __( 'Guatemalan quetzal', 'woocommerce' ),
'HRK' => __( 'Croatian kuna', 'woocommerce' ), 'GYD' => __( 'Guyanese dollar', 'woocommerce' ),
'HTG' => __( 'Haitian gourde', 'woocommerce' ), 'HKD' => __( 'Hong Kong dollar', 'woocommerce' ),
'HUF' => __( 'Hungarian forint', 'woocommerce' ), 'HNL' => __( 'Honduran lempira', 'woocommerce' ),
'IDR' => __( 'Indonesian rupiah', 'woocommerce' ), 'HRK' => __( 'Croatian kuna', 'woocommerce' ),
'ILS' => __( 'Israeli new shekel', 'woocommerce' ), 'HTG' => __( 'Haitian gourde', 'woocommerce' ),
'IMP' => __( 'Manx pound', 'woocommerce' ), 'HUF' => __( 'Hungarian forint', 'woocommerce' ),
'INR' => __( 'Indian rupee', 'woocommerce' ), 'IDR' => __( 'Indonesian rupiah', 'woocommerce' ),
'IQD' => __( 'Iraqi dinar', 'woocommerce' ), 'ILS' => __( 'Israeli new shekel', 'woocommerce' ),
'IRR' => __( 'Iranian rial', 'woocommerce' ), 'IMP' => __( 'Manx pound', 'woocommerce' ),
'IRT' => __( 'Iranian toman', 'woocommerce' ), 'INR' => __( 'Indian rupee', 'woocommerce' ),
'ISK' => __( 'Icelandic króna', 'woocommerce' ), 'IQD' => __( 'Iraqi dinar', 'woocommerce' ),
'JEP' => __( 'Jersey pound', 'woocommerce' ), 'IRR' => __( 'Iranian rial', 'woocommerce' ),
'JMD' => __( 'Jamaican dollar', 'woocommerce' ), 'IRT' => __( 'Iranian toman', 'woocommerce' ),
'JOD' => __( 'Jordanian dinar', 'woocommerce' ), 'ISK' => __( 'Icelandic króna', 'woocommerce' ),
'JPY' => __( 'Japanese yen', 'woocommerce' ), 'JEP' => __( 'Jersey pound', 'woocommerce' ),
'KES' => __( 'Kenyan shilling', 'woocommerce' ), 'JMD' => __( 'Jamaican dollar', 'woocommerce' ),
'KGS' => __( 'Kyrgyzstani som', 'woocommerce' ), 'JOD' => __( 'Jordanian dinar', 'woocommerce' ),
'KHR' => __( 'Cambodian riel', 'woocommerce' ), 'JPY' => __( 'Japanese yen', 'woocommerce' ),
'KMF' => __( 'Comorian franc', 'woocommerce' ), 'KES' => __( 'Kenyan shilling', 'woocommerce' ),
'KPW' => __( 'North Korean won', 'woocommerce' ), 'KGS' => __( 'Kyrgyzstani som', 'woocommerce' ),
'KRW' => __( 'South Korean won', 'woocommerce' ), 'KHR' => __( 'Cambodian riel', 'woocommerce' ),
'KWD' => __( 'Kuwaiti dinar', 'woocommerce' ), 'KMF' => __( 'Comorian franc', 'woocommerce' ),
'KYD' => __( 'Cayman Islands dollar', 'woocommerce' ), 'KPW' => __( 'North Korean won', 'woocommerce' ),
'KZT' => __( 'Kazakhstani tenge', 'woocommerce' ), 'KRW' => __( 'South Korean won', 'woocommerce' ),
'LAK' => __( 'Lao kip', 'woocommerce' ), 'KWD' => __( 'Kuwaiti dinar', 'woocommerce' ),
'LBP' => __( 'Lebanese pound', 'woocommerce' ), 'KYD' => __( 'Cayman Islands dollar', 'woocommerce' ),
'LKR' => __( 'Sri Lankan rupee', 'woocommerce' ), 'KZT' => __( 'Kazakhstani tenge', 'woocommerce' ),
'LRD' => __( 'Liberian dollar', 'woocommerce' ), 'LAK' => __( 'Lao kip', 'woocommerce' ),
'LSL' => __( 'Lesotho loti', 'woocommerce' ), 'LBP' => __( 'Lebanese pound', 'woocommerce' ),
'LYD' => __( 'Libyan dinar', 'woocommerce' ), 'LKR' => __( 'Sri Lankan rupee', 'woocommerce' ),
'MAD' => __( 'Moroccan dirham', 'woocommerce' ), 'LRD' => __( 'Liberian dollar', 'woocommerce' ),
'MDL' => __( 'Moldovan leu', 'woocommerce' ), 'LSL' => __( 'Lesotho loti', 'woocommerce' ),
'MGA' => __( 'Malagasy ariary', 'woocommerce' ), 'LYD' => __( 'Libyan dinar', 'woocommerce' ),
'MKD' => __( 'Macedonian denar', 'woocommerce' ), 'MAD' => __( 'Moroccan dirham', 'woocommerce' ),
'MMK' => __( 'Burmese kyat', 'woocommerce' ), 'MDL' => __( 'Moldovan leu', 'woocommerce' ),
'MNT' => __( 'Mongolian tögrög', 'woocommerce' ), 'MGA' => __( 'Malagasy ariary', 'woocommerce' ),
'MOP' => __( 'Macanese pataca', 'woocommerce' ), 'MKD' => __( 'Macedonian denar', 'woocommerce' ),
'MRO' => __( 'Mauritanian ouguiya', 'woocommerce' ), 'MMK' => __( 'Burmese kyat', 'woocommerce' ),
'MUR' => __( 'Mauritian rupee', 'woocommerce' ), 'MNT' => __( 'Mongolian tögrög', 'woocommerce' ),
'MVR' => __( 'Maldivian rufiyaa', 'woocommerce' ), 'MOP' => __( 'Macanese pataca', 'woocommerce' ),
'MWK' => __( 'Malawian kwacha', 'woocommerce' ), 'MRO' => __( 'Mauritanian ouguiya', 'woocommerce' ),
'MXN' => __( 'Mexican peso', 'woocommerce' ), 'MUR' => __( 'Mauritian rupee', 'woocommerce' ),
'MYR' => __( 'Malaysian ringgit', 'woocommerce' ), 'MVR' => __( 'Maldivian rufiyaa', 'woocommerce' ),
'MZN' => __( 'Mozambican metical', 'woocommerce' ), 'MWK' => __( 'Malawian kwacha', 'woocommerce' ),
'NAD' => __( 'Namibian dollar', 'woocommerce' ), 'MXN' => __( 'Mexican peso', 'woocommerce' ),
'NGN' => __( 'Nigerian naira', 'woocommerce' ), 'MYR' => __( 'Malaysian ringgit', 'woocommerce' ),
'NIO' => __( 'Nicaraguan córdoba', 'woocommerce' ), 'MZN' => __( 'Mozambican metical', 'woocommerce' ),
'NOK' => __( 'Norwegian krone', 'woocommerce' ), 'NAD' => __( 'Namibian dollar', 'woocommerce' ),
'NPR' => __( 'Nepalese rupee', 'woocommerce' ), 'NGN' => __( 'Nigerian naira', 'woocommerce' ),
'NZD' => __( 'New Zealand dollar', 'woocommerce' ), 'NIO' => __( 'Nicaraguan córdoba', 'woocommerce' ),
'OMR' => __( 'Omani rial', 'woocommerce' ), 'NOK' => __( 'Norwegian krone', 'woocommerce' ),
'PAB' => __( 'Panamanian balboa', 'woocommerce' ), 'NPR' => __( 'Nepalese rupee', 'woocommerce' ),
'PEN' => __( 'Peruvian nuevo sol', 'woocommerce' ), 'NZD' => __( 'New Zealand dollar', 'woocommerce' ),
'PGK' => __( 'Papua New Guinean kina', 'woocommerce' ), 'OMR' => __( 'Omani rial', 'woocommerce' ),
'PHP' => __( 'Philippine peso', 'woocommerce' ), 'PAB' => __( 'Panamanian balboa', 'woocommerce' ),
'PKR' => __( 'Pakistani rupee', 'woocommerce' ), 'PEN' => __( 'Peruvian nuevo sol', 'woocommerce' ),
'PLN' => __( 'Polish złoty', 'woocommerce' ), 'PGK' => __( 'Papua New Guinean kina', 'woocommerce' ),
'PRB' => __( 'Transnistrian ruble', 'woocommerce' ), 'PHP' => __( 'Philippine peso', 'woocommerce' ),
'PYG' => __( 'Paraguayan guaraní', 'woocommerce' ), 'PKR' => __( 'Pakistani rupee', 'woocommerce' ),
'QAR' => __( 'Qatari riyal', 'woocommerce' ), 'PLN' => __( 'Polish złoty', 'woocommerce' ),
'RON' => __( 'Romanian leu', 'woocommerce' ), 'PRB' => __( 'Transnistrian ruble', 'woocommerce' ),
'RSD' => __( 'Serbian dinar', 'woocommerce' ), 'PYG' => __( 'Paraguayan guaraní', 'woocommerce' ),
'RUB' => __( 'Russian ruble', 'woocommerce' ), 'QAR' => __( 'Qatari riyal', 'woocommerce' ),
'RWF' => __( 'Rwandan franc', 'woocommerce' ), 'RON' => __( 'Romanian leu', 'woocommerce' ),
'SAR' => __( 'Saudi riyal', 'woocommerce' ), 'RSD' => __( 'Serbian dinar', 'woocommerce' ),
'SBD' => __( 'Solomon Islands dollar', 'woocommerce' ), 'RUB' => __( 'Russian ruble', 'woocommerce' ),
'SCR' => __( 'Seychellois rupee', 'woocommerce' ), 'RWF' => __( 'Rwandan franc', 'woocommerce' ),
'SDG' => __( 'Sudanese pound', 'woocommerce' ), 'SAR' => __( 'Saudi riyal', 'woocommerce' ),
'SEK' => __( 'Swedish krona', 'woocommerce' ), 'SBD' => __( 'Solomon Islands dollar', 'woocommerce' ),
'SGD' => __( 'Singapore dollar', 'woocommerce' ), 'SCR' => __( 'Seychellois rupee', 'woocommerce' ),
'SHP' => __( 'Saint Helena pound', 'woocommerce' ), 'SDG' => __( 'Sudanese pound', 'woocommerce' ),
'SLL' => __( 'Sierra Leonean leone', 'woocommerce' ), 'SEK' => __( 'Swedish krona', 'woocommerce' ),
'SOS' => __( 'Somali shilling', 'woocommerce' ), 'SGD' => __( 'Singapore dollar', 'woocommerce' ),
'SRD' => __( 'Surinamese dollar', 'woocommerce' ), 'SHP' => __( 'Saint Helena pound', 'woocommerce' ),
'SSP' => __( 'South Sudanese pound', 'woocommerce' ), 'SLL' => __( 'Sierra Leonean leone', 'woocommerce' ),
'STD' => __( 'São Tomé and Príncipe dobra', 'woocommerce' ), 'SOS' => __( 'Somali shilling', 'woocommerce' ),
'SYP' => __( 'Syrian pound', 'woocommerce' ), 'SRD' => __( 'Surinamese dollar', 'woocommerce' ),
'SZL' => __( 'Swazi lilangeni', 'woocommerce' ), 'SSP' => __( 'South Sudanese pound', 'woocommerce' ),
'THB' => __( 'Thai baht', 'woocommerce' ), 'STD' => __( 'São Tomé and Príncipe dobra', 'woocommerce' ),
'TJS' => __( 'Tajikistani somoni', 'woocommerce' ), 'SYP' => __( 'Syrian pound', 'woocommerce' ),
'TMT' => __( 'Turkmenistan manat', 'woocommerce' ), 'SZL' => __( 'Swazi lilangeni', 'woocommerce' ),
'TND' => __( 'Tunisian dinar', 'woocommerce' ), 'THB' => __( 'Thai baht', 'woocommerce' ),
'TOP' => __( 'Tongan paʻanga', 'woocommerce' ), 'TJS' => __( 'Tajikistani somoni', 'woocommerce' ),
'TRY' => __( 'Turkish lira', 'woocommerce' ), 'TMT' => __( 'Turkmenistan manat', 'woocommerce' ),
'TTD' => __( 'Trinidad and Tobago dollar', 'woocommerce' ), 'TND' => __( 'Tunisian dinar', 'woocommerce' ),
'TWD' => __( 'New Taiwan dollar', 'woocommerce' ), 'TOP' => __( 'Tongan paʻanga', 'woocommerce' ),
'TZS' => __( 'Tanzanian shilling', 'woocommerce' ), 'TRY' => __( 'Turkish lira', 'woocommerce' ),
'UAH' => __( 'Ukrainian hryvnia', 'woocommerce' ), 'TTD' => __( 'Trinidad and Tobago dollar', 'woocommerce' ),
'UGX' => __( 'Ugandan shilling', 'woocommerce' ), 'TWD' => __( 'New Taiwan dollar', 'woocommerce' ),
'USD' => __( 'United States dollar', 'woocommerce' ), 'TZS' => __( 'Tanzanian shilling', 'woocommerce' ),
'UYU' => __( 'Uruguayan peso', 'woocommerce' ), 'UAH' => __( 'Ukrainian hryvnia', 'woocommerce' ),
'UZS' => __( 'Uzbekistani som', 'woocommerce' ), 'UGX' => __( 'Ugandan shilling', 'woocommerce' ),
'VEF' => __( 'Venezuelan bolívar', 'woocommerce' ), 'USD' => __( 'United States dollar', 'woocommerce' ),
'VND' => __( 'Vietnamese đồng', 'woocommerce' ), 'UYU' => __( 'Uruguayan peso', 'woocommerce' ),
'VUV' => __( 'Vanuatu vatu', 'woocommerce' ), 'UZS' => __( 'Uzbekistani som', 'woocommerce' ),
'WST' => __( 'Samoan tālā', 'woocommerce' ), 'VEF' => __( 'Venezuelan bolívar', 'woocommerce' ),
'XAF' => __( 'Central African CFA franc', 'woocommerce' ), 'VND' => __( 'Vietnamese đồng', 'woocommerce' ),
'XCD' => __( 'East Caribbean dollar', 'woocommerce' ), 'VUV' => __( 'Vanuatu vatu', 'woocommerce' ),
'XOF' => __( 'West African CFA franc', 'woocommerce' ), 'WST' => __( 'Samoan tālā', 'woocommerce' ),
'XPF' => __( 'CFP franc', 'woocommerce' ), 'XAF' => __( 'Central African CFA franc', 'woocommerce' ),
'YER' => __( 'Yemeni rial', 'woocommerce' ), 'XCD' => __( 'East Caribbean dollar', 'woocommerce' ),
'ZAR' => __( 'South African rand', 'woocommerce' ), 'XOF' => __( 'West African CFA franc', 'woocommerce' ),
'ZMW' => __( 'Zambian kwacha', 'woocommerce' ), 'XPF' => __( 'CFP franc', 'woocommerce' ),
'YER' => __( 'Yemeni rial', 'woocommerce' ),
'ZAR' => __( 'South African rand', 'woocommerce' ),
'ZMW' => __( 'Zambian kwacha', 'woocommerce' ),
)
) )
) );
); }
return $currencies;
} }
/** /**
* Get Currency symbol. * Get Currency symbol.
* *
@ -625,7 +632,6 @@ function get_woocommerce_currency_symbol( $currency = '' ) {
'ZAR' => 'R', 'ZAR' => 'R',
'ZMW' => 'ZK', 'ZMW' => 'ZK',
) ); ) );
$currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : ''; $currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : '';
return apply_filters( 'woocommerce_currency_symbol', $currency_symbol, $currency ); return apply_filters( 'woocommerce_currency_symbol', $currency_symbol, $currency );