Plugin Directory

Changeset 1961920


Ignore:
Timestamp:
10/24/2018 09:49:42 AM (7 years ago)
Author:
RealMag777
Message:
  • removed currency agregators which stopped to work
  • added back google and yahoo currency agregators
Location:
currency-switcher/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • currency-switcher/trunk/index.php

    r1860396 r1961920  
    55  Description: Currency Switcher for WordPress
    66  Author: realmag777
    7   Version: 1.1.2
     7  Version: 1.1.3
    88  Requires at least: WP 3.5.0
    9   Tested up to: WP 4.9.5
     9  Tested up to: WP 4.9.8
    1010  Text Domain: currency-switcher
    1111  Domain Path: /languages
     
    3636include_once WPCS_PATH . 'classes/auto_switcher.php';
    3737
    38 //17-04-2018
     38//24-10-2018
    3939final class WPCS {
    4040
    41     public $the_plugin_version = '1.1.2';
     41    public $the_plugin_version = '1.1.3';
    4242    public $storage = null;
    4343    public $options = array();
     
    839839        switch ($mode) {
    840840            case 'yahoo':
    841                 //http://www.idiotinside.com/2015/01/28/create-a-currency-converter-in-php-python-javascript-and-jquery-using-yahoo-currency-api/
    842                 $yql_base_url = "http://query.yahooapis.com/v1/public/yql";
    843                 $yql_query = 'select * from yahoo.finance.xchange where pair in ("' . $this->default_currency . $this->escape($_REQUEST['currency_name']) . '")';
    844                 $yql_query_url = $yql_base_url . "?q=" . urlencode($yql_query);
    845                 $yql_query_url .= "&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
    846                 //***
     841                $date = current_time('timestamp', true);
     842                $yql_query_url = 'https://query1.finance.yahoo.com/v8/finance/chart/' . $this->default_currency . $this->escape($_REQUEST['currency_name']) . '=X?symbol=' . $this->default_currency . $this->escape($_REQUEST['currency_name']) . '%3DX&period1=' . ( $date - 60 * 86400 ) . '&period2=' . $date . '&interval=1d&includePrePost=false&events=div%7Csplit%7Cearn&lang=en-US&region=US&corsDomain=finance.yahoo.com';
    847843                if (function_exists('curl_init') AND $wpcs_use_curl) {
    848844                    $res = $this->file_get_contents_curl($yql_query_url);
     
    850846                    $res = file_get_contents($yql_query_url);
    851847                }
     848                //$yql_query_url="http://query.yahooapis.com/v1/public/yql?q=select+%2A+from+yahoo.finance.xchange+where+pair+in+EURGBP&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys";
    852849                //***
    853                 $yql_json = json_decode($res, true);
    854                 $request = (float) $yql_json['query']['results']['rate']['Rate'];
    855 
    856 
     850                $data = json_decode($res, true);
     851                $result = isset($data['chart']['result'][0]['indicators']['quote'][0]['open']) ? $data['chart']['result'][0]['indicators']['quote'][0]['open'] : ( isset($data['chart']['result'][0]['meta']['previousClose']) ? array($data['chart']['result'][0]['meta']['previousClose']) : array() );
     852
     853                if (count($result) && is_array($result)) {
     854                    $request = end($result);
     855                }
    857856                break;
    858857
     
    861860                $from_Currency = urlencode($this->default_currency);
    862861                $to_Currency = urlencode($this->escape($_REQUEST['currency_name']));
    863                 //$url = "http://www.google.com/finance/converter?a=$amount&from=$from_Currency&to=$to_Currency";
    864                 $url = "https://finance.google.com/finance?q=" . $from_Currency . $to_Currency;
     862                if ($to_Currency == $from_Currency) {
     863                    $request = 1;
     864                    break;
     865                }
     866                $url = 'https://www.google.com/async/currency_update?yv=2&async=source_amount:1,source_currency:' . $from_Currency . ',target_currency:' . $to_Currency . ',chart_width:270,chart_height:94,lang:en,country:vn,_fmt:jspb';
    865867                if (function_exists('curl_init') AND $wpcs_use_curl) {
    866868                    $html = $this->file_get_contents_curl($url);
     
    869871                }
    870872
    871                 preg_match_all('/<span class=bld>(.*?)<\/span>/s', $html, $matches);
    872                 if (isset($matches[1][0])) {
    873                     $request = floatval($matches[1][0]);
    874                 } else {
    875                     $request = sprintf(__("no data for %s", 'currency-switcher'), $this->escape($_REQUEST['currency_name']));
    876                 }
    877 
     873                if ($html) {
     874                    preg_match('/CurrencyUpdate\":\[\[(.+?)\,/', $html, $matches);
     875
     876                    if (count($matches) > 0) {
     877                        $request = isset($matches[1]) ? $matches[1] : 1;
     878                    } else {
     879                        $request = sprintf(__("no data for %s", 'woocommerce-currency-switcher'), $this->escape($_REQUEST['currency_name']));
     880                    }
     881                }
    878882                break;
    879883
     
    11811185                $to_Currency = urlencode($this->escape($_REQUEST['currency_name']));
    11821186                //http://www.xe.com/currencyconverter/convert/?Amount=1&From=ZWD&To=CUP
    1183                 $url = "http://www.xe.com/currencyconverter/convert/?Amount=1&From=" . $from_Currency . "&To=" . $to_Currency;
     1187                $url = "https://www.xe.com/currencyconverter/convert/?Amount=1&From=" . $from_Currency . "&To=" . $to_Currency;
    11841188                if (function_exists('curl_init')) {
    11851189                    $html = $this->file_get_contents_curl($url);
     
    11881192                }
    11891193                //test
    1190                 preg_match_all('/<span class=\'uccResultAmount\'>(.*?)<\/span>/s', $html, $matches);
     1194                var_dump($html);
     1195                preg_match_all('/<span class="converterresult-toAmount">(.*?)<\/span>/s', $html, $matches);
    11911196                if (isset($matches[1][0])) {
    11921197                    $request = floatval(str_replace(",", "", $matches[1][0]));
  • currency-switcher/trunk/js/plugin_options.js

    r1860391 r1961920  
    278278        //jQuery("[name='wpcs_settings[wpcs_customer_signs]']").attr('readonly', 'readonly');
    279279
    280      
     280        jQuery('.wpcs_del_currency').life('click', function () {
     281            jQuery(this).parents('li').hide(220, function () {
     282                jQuery(this).remove();
     283            });
     284            return false;
     285        });
    281286
    282287        jQuery('.wpcs_is_etalon').life('click', function () {
  • currency-switcher/trunk/readme.txt

    r1860397 r1961920  
    44Tags: currency, switcher, currency switcher, converter, marketing
    55Requires at least: 3.5.0
    6 Tested up to: 4.9.5
    7 Stable tag: 1.1.2
     6Tested up to: 4.9.8
     7Stable tag: 1.1.3
    88Requires PHP: 5.4
    99License: GPLv2 or later
     
    111111== Changelog ==
    112112
     113= 1.1.3 =
     114* removed currency agregators which stopped to work
     115* added back Google and Yahoo currency agregators
     116
    113117= 1.1.2 =
    114118* new feature: Side switcher - https://wordpress.currency-switcher.com/documentation/#section_1_1
     
    147151== License ==
    148152
    149 This plugin is copyright pluginus.net &copy; 2012-2018 with [GNU General Public License][] by realmag777.
     153This plugin is copyright pluginus.net &copy; 2012-2019 with [GNU General Public License][] by realmag777.
    150154
    151155This program is free software; you can redistribute it and/or modify it under the terms of the [GNU General Public License][] as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
  • currency-switcher/trunk/views/plugin_options.php

    r1860394 r1961920  
    117117                'css' => 'min-width:300px;',
    118118                'options' => array(
    119                     //'yahoo' => __('http://finance.yahoo.com', 'currency-switcher'),
    120                     //  'google' => __('http://google.com/finance', 'currency-switcher'),
    121                     'appspot' => __('http://rate-exchange.appspot.com', 'currency-switcher'),
     119                    'yahoo' => __('http://finance.yahoo.com', 'currency-switcher'),
     120                    'google' => __('http://google.com/finance', 'currency-switcher'),
     121                    //'appspot' => __('http://rate-exchange.appspot.com', 'currency-switcher'),
    122122                    'rf' => __('http://www.cbr.ru - russian centrobank', 'currency-switcher'),
    123123                    'privatbank' => 'api.privatbank.ua - ukrainian privatbank',
     
    125125                    'free_converter' => 'The Free Currency Converter',
    126126                    'cryptocompare' => 'CryptoCompare',
    127                     'xe' => 'XE Currency Converter'
     127                    //'xe' => 'XE Currency Converter'
    128128                ),
    129129                'default' => 'free_converter'
     
    298298                        <div class="wfc-control-section">
    299299
     300
    300301                            <div style="display: none;">
    301302                                <div id="wpcs_item_tpl"><?php
     
    327328
    328329
    329                             <b style="color:red;"><?php _e('Hint','currency-switcher'); ?>:</b>&nbsp;<?php _e('To update all currencies rates by one click - press radio button of the basic currency and then press "Save changes" button!', 'currency-switcher'); ?><br />
     330                            <b style="color:red;"><?php _e('Hint'); ?>:</b>&nbsp;<?php _e('To update all currencies rates by one click - press radio button of the basic currency and then press "Save changes" button!', 'currency-switcher'); ?><br />
    330331
    331332                        </div><!--/ .wfc-control-section-->
     
    460461                                        </select>
    461462                                        <div class="wfc-description"><?php _e("Style of the fixed switcher", 'currency-switcher') ?></div>
    462 
    463 
    464                                         <div class="wpcs_roll_blocks_wight" <?php if ($wpcs_auto_switcher_skin != 'roll_blocks'): ?>style="display: none;"<?php endif; ?>>
    465                                             <?php $wpcs_auto_switcher_roll_px = (isset($this->options['auto_switcher_roll_px'])) ? $this->options['auto_switcher_roll_px'] : 90; ?>
    466                                             <input type="text" name="wpcs_settings[auto_switcher_roll_px]" placeholder="<?php _e('enter roll width', 'currency-switcher') ?>"  id="wpcs_auto_switcher_roll_px" style="min-width: 300px; margin-top: 3px;" value="<?php echo $wpcs_auto_switcher_roll_px ?>" >
     463                                        <div class="wpcs_roll_blocks_wight" <?php if($wpcs_auto_switcher_skin !='roll_blocks'):?>style="display: none;"<?php endif;?>>
     464                                            <?php
     465                                            $wpcs_auto_switcher_roll_px = (isset($this->options['auto_switcher_roll_px'])) ? $this->options['auto_switcher_roll_px'] : 90;
     466                                            ?>
     467                                           <input type="text" name="wpcs_settings[auto_switcher_roll_px]"  id="wpcs_auto_switcher_roll_px" style="min-width: 100px;" value="<?php echo $wpcs_auto_switcher_roll_px ?>" >
     468                                           <label for="wpcs_auto_switcher_roll_px">px;<?php _e('How much to roll. ', 'currency-switcher') ?></label>
    467469                                        </div>
    468 
    469 
    470470                                    </td>
    471471                                </tr>
     
    502502                                        ?>
    503503                                        <input type="text" name="wpcs_settings[auto_switcher_top_margin]" id="wpcs_auto_switcher_top_margin" style="min-width: 300px;" value="<?php echo $wpcs_auto_switcher_top_margin ?>" >
    504                                         <div class="wfc-description"><?php _e("Distance from the top of the screen to the switcher html block. You can set in px or in %. Example 1: 100px. Example 2: 10%.", 'currency-switcher') ?></div>
     504                                        <div class="wfc-description"><?php _e("Distance from the top of the screen", 'currency-switcher') ?></div>
    505505                                    </td>
    506506                                </tr>
     
    821821            <hr />
    822822
    823             <div style="font-style: italic;">In the free version of the plugin <b style="color: red;">you can operate with 2 ANY currencies only</b>. If you want more currencies and features you can make <a href="http://wordpress.currency-switcher.com/a/buy" target="_blank">upgrade to the premium version of the plugin</a></div><br />
     823            <div style="font-style: italic;">In the free version of the plugin <b>you can operate with 2 ANY currencies only</b>. If you want more currencies and features you can make <a href="http://wordpress.currency-switcher.com/a/buy" target="_blank">upgrade to the premium version of the plugin</a></div><br />
    824824
    825825            <table style="width: 100%;">
     
    827827                    <tr>
    828828                        <td style="width: 50%;">
    829                             <h3 style="color: tomato;"><?php _e("UPGRADE to Full version", 'currency-switcher') ?>:</h3>
     829                            <h3>Get the full version of the plugin from Codecanyon:</h3>
    830830                            <a href="http://wordpress.currency-switcher.com/a/buy" target="_blank"><img width="200" src="<?php echo WPCS_LINK ?>img/wpcs_banner.png" alt="full version of the plugin"></a>
    831831                        </td>
     
    834834                            <a href="http://www.currency-switcher.com/a/buy" target="_blank"><img width="200" src="<?php echo WPCS_LINK ?>img/woocs_banner.png" alt="WooCommerce Currency Switcher"></a>
    835835                        </td>
    836 
    837             <!-- <td style="width: 33%;">
    838                 <h3><?php _e("AliDropship is the best solution for drop shipping", 'currency-switcher') ?>:</h3>
    839                 <a href="https://alidropship.com/plugin/?via=4352" target="_blank"><img width="200" src="<?php echo WPCS_LINK ?>img/drop-ship.jpg" alt="<?php _e("AliDropship is the best solution for drop shipping", 'currency-switcher'); ?>" /></a>
    840             </td> -->
    841 
     836                       
     837                        <!-- <td style="width: 33%;">
     838                            <h3><?php _e("AliDropship is the best solution for drop shipping", 'currency-switcher') ?>:</h3>
     839                            <a href="https://alidropship.com/plugin/?via=4352" target="_blank"><img width="200" src="<?php echo WPCS_LINK ?>img/drop-ship.jpg" alt="<?php _e("AliDropship is the best solution for drop shipping", 'woocommerce-currency-switcher'); ?>" /></a>
     840                        </td> -->
     841                       
    842842                    </tr>
    843843                </tbody>
     
    904904        <input type="hidden" value="<?php echo $flag ?>" class="wpcs_flag_input" name="wpcs_flag[]" />
    905905        <a href="#" class="wpcs_flag help_tip" data-tip="<?php _e("Click to select the flag", 'currency-switcher'); ?>"><img src="<?php echo $flag ?>" alt="<?php _e("Flag", 'currency-switcher'); ?>" /></a>
     906        &nbsp;<a href="#" class="button wpcs_del_currency help_tip" data-tip="<?php _e("remove", 'currency-switcher'); ?>" style="vertical-align: middle;">X</a>
    906907        &nbsp;<a href="#" class="help_tip" data-tip="<?php _e("drag and drope", 'currency-switcher'); ?>"><img style="width: 22px; vertical-align: middle;" src="<?php echo WPCS_LINK ?>img/move.png" alt="<?php _e("move", 'currency-switcher'); ?>" /></a>
    907908    </li>
Note: See TracChangeset for help on using the changeset viewer.