WordPress.org

Ready to get started?Download WordPress

Forums

FoxyShop
[resolved] foxyshop_currency double-encodes utf8 (2 posts)

  1. pharazon
    Member
    Posted 2 years ago #

    Hello, we have an issue with foxyshop_currency() function. The money_format branch double-encodes the EURO symbol, when the locale is de_DE.UTF-8 (i.e. already UTF8).

    I think the fix for this would be to check if a UTF8 locale is already used, then do not utf8_encode it twice.

    http://wordpress.org/extend/plugins/foxyshop/

  2. sparkweb
    Member
    Plugin Author

    Posted 1 year ago #

    Great point! I noticed this last week but had been unsure of what to do about it. I think your solution is a good one. Here's what I'll be rolling into the next release of the plugin (current release is 4.1.6):

    function foxyshop_currency($input, $currencysymbol = true) {
    	global $foxyshop_settings;
    	if (function_exists('money_format')) {
    		$currency = money_format("%" . ($currencysymbol ? "" : "!") . ".2n", (double)$input);
    	} else {
    		//Windows: no internationalisation support
    		$currency_code = ($foxyshop_settings['locale_code'] == "en_GB" ? "£" : "$");
    		$currency = $currency_code.number_format((double)$input,2,".",",");
    	}
    	if (strpos($foxyshop_settings['locale_code'], "utf8") === false) $currency = utf8_encode($currency);
    	return apply_filters("foxyshop_currency", $currency);
    }

    Can you try replacing the function in helperfunctions.php and see if that works for you?

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags