Created
November 17, 2022 08:00
-
-
Save ipokkel/a1ba7c5ebf1a489bfeeab2f5507c2f6f to your computer and use it in GitHub Desktop.
Change "$" to "US$" for the PMPro US Dollar currency symbol.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Add "US" as a prefix to "$" for the US Dollar currency code ("US$"). | |
* | |
* You can add this recipe to your site by creating a custom plugin | |
* or using the Code Snippets plugin available for free in the WordPress repository. | |
* Read this companion article for step-by-step directions on either method. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
/** | |
* This function changes the values of specific keys for a currency in the `$pmpro_currencies` array. | |
* | |
* @link https://github.com/strangerstudios/paid-memberships-pro/blob/dev/includes/currencies.php | |
* | |
* @param array $pmpro_currencies The currency array created by PMPro | |
* @return array The adjusted currency array | |
*/ | |
function my_pmpro_customize_us_dollar_currency( $pmpro_currencies ) { | |
$pmpro_currencies['USD'] = array( | |
'name' => __( 'US Dollars ($)', 'paid-memberships-pro' ), | |
'decimals' => '2', | |
'thousands_separator' => ',', | |
'decimal_separator' => '.', | |
'symbol' => 'US$', // e.g. US$25.00 | |
'position' => 'left', | |
); | |
return $pmpro_currencies; | |
} | |
add_filter( 'pmpro_currencies', 'my_pmpro_customize_us_dollar_currency' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment