Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
.vagrant/
node_modules/
vendor/
_vvv/
2 changes: 1 addition & 1 deletion another-unit-converter/includes/class-admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public function maybe_show_api_key_notice( $hook ) {
$on_plugins_page = 'plugins.php' == $pagenow;

if ( $on_settings_page ) {
echo '<div class="notice notice-warning"><p>';
echo '<div class="notice notice-warning is-dismissible"><p>';

_e( '<strong>Another Unit Converter</strong> requires a <strong>currencylayer API key</strong> to work properly. Obtaining an API key from currencylayer is completely FREE.', 'another-unit-converter' );
echo '<br /><br />';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ public function init() {
$this->currency_conversion->maybe_refresh_rates();

add_filter( 'the_content', array( $this, 'format_currency_amounts' ) );

if( class_exists( 'WooCommerce' ) ){
add_filter( 'wc_price', array( $this, 'format_woocommerce_currency_amounts' ), 10, 4 );
}
}

public function is_external_currency_conversion_api_ready() {
Expand Down Expand Up @@ -127,7 +131,7 @@ public function format_currency_amounts( $content ) {

foreach ( $currency_amounts as $index => $currency_amount ) {
$currency_info = $this->select_currency( $currency_amount['currencies'] );

$start_position = $currency_info['position']['start'] + $offset;
$end_position = $currency_info['position']['end'] + $offset;

Expand Down Expand Up @@ -162,6 +166,13 @@ public function format_currency_amounts( $content ) {
return $content;
}

public function format_woocommerce_currency_amounts( $return, $price, $args, $unformatted_price ){

$content = $this->format_currency_amounts( html_entity_decode( get_woocommerce_currency_symbol( ) ) . $price );

return $content;
}

private function select_currency( $currencies ) {
$default_currency = $this->settings->get_option( 'default_currency' );

Expand Down
2 changes: 1 addition & 1 deletion another-unit-converter/includes/class-currency-parser.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public function __construct( $currencies ) {
}

public function get_currency_amounts( $content ) {
$regexp = '/(*UTF8)(?<currency_amount>\d{4,}|\d{1,3}(?:[,. ]\d{1,3})*)/';
$regexp = '/(*UTF8)(?<currency_amount>(\d{4,}|\d{1,3})(?:[,. ]\d{1,3})*)/';

if ( ! preg_match_all( $regexp, $content, $matches, PREG_OFFSET_CAPTURE ) ) {
return array();
Expand Down