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,7 +281,10 @@ function get_woocommerce_currency() {
* @return array
*/
function get_woocommerce_currencies() {
return array_unique(
static $currencies;
if ( ! isset( $currencies ) ) {
$currencies = array_unique(
apply_filters( 'woocommerce_currencies',
array(
'AED' => __( 'United Arab Emirates dirham', 'woocommerce' ),
@ -450,6 +453,10 @@ function get_woocommerce_currencies() {
);
}
return $currencies;
}
/**
* Get Currency symbol.
*
@ -625,7 +632,6 @@ function get_woocommerce_currency_symbol( $currency = '' ) {
'ZAR' => 'R',
'ZMW' => 'ZK',
) );
$currency_symbol = isset( $symbols[ $currency ] ) ? $symbols[ $currency ] : '';
return apply_filters( 'woocommerce_currency_symbol', $currency_symbol, $currency );