Browse Source

Update hush-payment-gateway.php

Storing price as option and using stored price when CoinGecko returns no price or errors.
main
fekt 2 years ago
parent
commit
a4ec64e672
  1. 7
      hush-payment-gateway.php

7
hush-payment-gateway.php

@ -77,7 +77,7 @@ function get_hush_price() {
$request = wp_remote_get('https://api.coingecko.com/api/v3/simple/price?ids=hush&vs_currencies=btc%2Cusd%2Ceur%2Ceth%2Cgbp%2Ccny%2Cjpy%2Cidr%2Crub%2Ccad%2Csgd%2Cchf%2Cinr%2Caud%2Cinr%2Ckrw%2Cthb%2Cnzd%2Czar%2Cvef%2Cxau%2Cxag%2Cvnd%2Csar%2Ctwd%2Caed%2Cars%2Cbdt%2Cbhd%2Cbmd%2Cbrl%2Cclp%2Cczk%2Cdkk%2Chuf%2Cils%2Ckwd%2Clkr%2Cpkr%2Cnok%2Ctry%2Csek%2Cmxn%2Cuah%2Chkd&include_market_cap=true&include_24hr_vol=true&include_24hr_change=true');
if(is_wp_error($request)){
return false;
return get_option('hushPriceCached');
}
$body = wp_remote_retrieve_body($request);
@ -86,14 +86,15 @@ function get_hush_price() {
if(!empty($data)){
$hushPrice = $data['hush']['usd'];
if(is_numeric($hushPrice)){
update_option('hushPriceCached',sanitize_text_field($hushPrice));
return $hushPrice;
}
else{
return false;
return get_option('hushPriceCached');
}
}
else{
return false;
return get_option('hushPriceCached');
}
}

Loading…
Cancel
Save