Plugin Directory

Changeset 2694714


Ignore:
Timestamp:
03/16/2022 09:47:20 AM (4 years ago)
Author:
techuptodate
Message:

Bug fixes and Tested on Wordpress 5.9.1

Location:
what-if-bitcoin/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • what-if-bitcoin/trunk/functions/generate_form_result.php

    r2641673 r2694714  
    1414    add_action( 'wp_ajax_fetch_whatif_result', 'fetch_whatif_result_function' );
    1515    add_action( 'wp_ajax_nopriv_fetch_whatif_result' ,'fetch_whatif_result_function' );
     16
     17function numberToCurrency($text,$number){
     18        $checkMinusVal = explode('-',$number)[0];
     19        $checkMinus = $final = '';
     20        $allStr = explode('.',$number);
     21        if($checkMinusVal == ''){
     22            $checkMinus = '-';
     23            $allStr = explode('.',explode('-',$number)[1]);
     24        }
     25        $str = $allStr[0];
     26        $length = strlen($str);
     27        $count = $first = 0;
     28        for($i = $length; $i >= 0; $i--){   
     29            if($count == 3 && $first == 0){
     30                $final .= $str[$i];
     31                if($str[$i + 1] != ''){
     32                    $final .= '';
     33                }
     34                $count = 0;
     35                $first = 1;
     36            }
     37            elseif($count == 4 && $first == 1){
     38                if( ($i - 1) < 0){
     39                    $final .= $str[$i];
     40                }
     41                else{
     42                    $final .= $str[$i].',';
     43                }
     44                $count = 0;
     45            }
     46            else{
     47                $final .= $str[$i];
     48            }
     49            $count++;
     50        }
     51        $final = strrev($final);
     52        if(array_key_exists("1",$allStr)){
     53            $decimalVal = $allStr[1][0];
     54            if(!empty($allStr[1][1])){
     55                $decimalVal .= $allStr[1][1];
     56            }
     57            else{
     58                $decimalVal .= 0;
     59            }
     60            if($allStr[1][2] >= 5){
     61                $decimalVal++;
     62            }
     63            $final .= '.'.$decimalVal;
     64        }
     65        return $checkMinus.$text.$final;
     66    }
    1667
    1768    function fetch_whatif_result_function() {
     
    57108              $select_data_result = $value;
    58109          }
    59 
    60           $profit = round($whatif_amount/$select_data_result*$current_price-$whatif_amount);
    61           $roi = round($profit/$whatif_amount*100);
    62           echo 'If you invested <b><span class="whatif_form_result_text">'.$text.$whatif_amount.'</span></b> in <i class="fa fa-btc"></i><b>BITCOIN</b> on <b><span class="whatif_form_result_text">'.$date.'</span></b> You would have made <b><span class="whatif_form_result_text">'.number_format($roi).'%</span></b> ROI, that\'s <b><span class="whatif_form_result_text">'.$text.number_format($profit).'</span></b> in profit.';
     110          $profit = $whatif_amount/$select_data_result*$current_price-$whatif_amount;
     111          $roi = $profit/$whatif_amount*100;
     112         
     113          echo 'If you invested <b><span class="whatif_form_result_text">'.$text.$whatif_amount.'</span></b> in <i class="fa fa-btc"></i><b>BITCOIN</b> on <b><span class="whatif_form_result_text">'.$date.'</span></b> You would have made <b><span class="whatif_form_result_text">'.number_format(round($roi,1),2).'%</span></b> ROI, that\'s <b><span class="whatif_form_result_text">'.numberToCurrency($text,number_format(round($profit,1),2)).'</span></b> in profit.';
    63114    }
    64115?>
  • what-if-bitcoin/trunk/readme.txt

    r2641684 r2694714  
    99Donate link: https://techuptodate.com.au/what-if-bitcoin/
    1010Requires at least: 4.7
    11 Tested up to: 5.8.2
     11Tested up to: 5.9.1
    1212Stable tag: 1.0.2
    13 Version: 1.0.3
     13Version: 1.0.4
    1414License: GPLv2 or later
    1515License URI: http://www.gnu.org/licenses/gpl-2.0.html
Note: See TracChangeset for help on using the changeset viewer.