Plugin Directory

Changeset 2877106


Ignore:
Timestamp:
03/09/2023 11:19:30 AM (3 years ago)
Author:
zaytseff
Message:

v1.1.1 Fix php-8 install & save settings errors

Location:
multi-crypto-currency-payment/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • multi-crypto-currency-payment/trunk/inc/invoice-admin-trait.php

    r2839125 r2877106  
    4040    */
    4141    public function admin_options() {
    42         $this->update();
    4342        $this->mccp_init_form_fields();
    4443        if ( Apirone::isFiatSupported(get_option('woocommerce_currency')) ) :?>
     
    183182                'description' => __('List of available cryptocurrencies processed by Apirone', 'mccp'),
    184183                'desc_tip' => true,
     184                'default' => [],
    185185            ),
    186186            'factor' => array(
     
    216216        );
    217217    }
     218    /**
     219    * Save apirone currensies into options table
     220    */
     221    public function validate_currencies_list_field($k, $v) {
     222        $currencies = $this->mccp_currencies();
     223
     224        foreach ($currencies as $key => $value) {
     225            if (!empty($value->address) && !$value->valid) {
     226                $currencies[$key]->address = '';
     227                $currencies[$key]->enabled = 0;
     228                $currencies[$key]->valid = 0;
     229            }
     230        }
     231        return $currencies;
     232    }
     233
    218234
    219235    /**
     
    229245    public function mccp_currency($apirone_currency, $apirone_account = false) {
    230246            $currency = $this->get_mccp_currency($apirone_currency->abbr);
    231             if ($currency == false || !property_exists($currency, 'name')) {
     247            if ($currency == false || gettype($currency) === 'array' || !property_exists($currency, 'name')) {
    232248                $currency = new \stdClass();
    233249
     
    244260            // Set address from config
    245261            if ($_SERVER['REQUEST_METHOD'] == 'POST' && $apirone_account) {
    246                 $currency->enabled = sanitize_text_field($_POST['woocommerce_mccp_currencies'][$currency->abbr]['enabled']);
     262                if (array_key_exists('enabled', $_POST['woocommerce_mccp_currencies'][$currency->abbr])) {
     263                    $currency->enabled = sanitize_text_field($_POST['woocommerce_mccp_currencies'][$currency->abbr]['enabled']);
     264                }
    247265                $currency->address = sanitize_text_field($_POST['woocommerce_mccp_currencies'][$currency->abbr]['address']);
    248266                if ($currency->address != '') {
  • multi-crypto-currency-payment/trunk/inc/invoice-utils-trait.php

    r2859028 r2877106  
    102102     */
    103103    public function get_mccp_currency($abbr) {
    104         $currencies = $this->get_option('currencies');
     104        $currencies = (array) $this->get_option('currencies');
    105105
    106106        if ( $currencies && array_key_exists($abbr, $currencies) ) {
     
    133133
    134134        $woo_currency = get_woocommerce_currency();
    135 
    136135        $active_currencies = array();
    137         foreach ($this->get_option('currencies') as $item) {
     136
     137        foreach ((array) $this->get_option('currencies') as $item) {
    138138            if ($item->testnet === 1 && !current_user_can('manage_options')) {
    139139                continue;
     
    190190
    191191    /**
     192     * Update plugin version only
     193     *
     194     * @return void
     195     */
     196    function upd_version($new) {
     197        $settings = get_option('woocommerce_mccp_settings');
     198        $settings['version'] = $new;
     199
     200        update_option('woocommerce_mccp_settings', $settings);
     201    }
     202
     203    /**
    192204     * Plugin version update entry point
    193205     *
     
    195207     */
    196208    function update() {
    197         if ($this->version() === false) {
    198             $this->update_1_0_0__1_1_0();
     209        $this->update_1_0_0__1_1_0();
     210        $this->update_1_1_0__1_1_1();
     211    }
     212
     213    /**
     214     * Update plugin from 1.1.0 to 1.1.1
     215     *
     216     * @return void
     217     */
     218    function update_1_1_0__1_1_1() {
     219        if ($this->version() === '1.1.0') {
     220            $this->upd_version('1.1.1');
    199221        }
    200222    }
     
    206228     */
    207229    function update_1_0_0__1_1_0() {
     230        if ($this->version() !== false) {
     231            return;
     232        }
    208233        global $wpdb, $table_prefix;
    209234
     
    223248
    224249        $apirone_account = $this->mccp_account();
    225        
     250
    226251        // Map old currensies
    227252        foreach (Apirone::currencyList() as $apirone_currency) {
    228253            $currency = $this->mccp_currency($apirone_currency, $apirone_account);
    229             if (array_key_exists($apirone_currency->abbr, $settings['currencies'])) {
     254            if (array_key_exists($apirone_currency->abbr, (array) $settings['currencies'])) {
    230255                $old_currency = $settings['currencies'][$apirone_currency->abbr];
    231                 if ($old_currency['address']) {
    232                     $currency->address = $old_currency['address'];
    233                     $result = Apirone::setTransferAddress($apirone_account, $currency->abbr, $old_currency['address']);
    234                     if ($result) {
    235                         $currency->valid = 1;
     256                if (gettype($old_currency) === 'array') { // Update from version 1.0.0
     257                    if ($old_currency['address']) {
     258                        $currency->address = $old_currency['address'];
     259                        $result = Apirone::setTransferAddress($apirone_account, $currency->abbr, $old_currency['address']);
     260                        if ($result) {
     261                            $currency->valid = 1;
     262                        }
    236263                    }
     264                    $currency->enabled = ($old_currency['enabled']) ? 1 : 0;
    237265                }
    238                 $currency->enabled = ($old_currency['enabled']) ? 1 : 0;
     266                else { // Clear install of 1.1.1
     267                    $currency = $old_currency;
     268                }
    239269            }
    240 
    241270            $mccp_currencies[$apirone_currency->abbr] = $currency;
    242271
     
    244273        // Update currensies
    245274        $settings['currencies'] = $mccp_currencies;
    246         // Add version
     275        // Add new params
     276        $settings['factor'] = '1';
     277        $settings['timeout'] = '1800';
     278        $settings['check_timeout'] = '10';
     279        $settings['backlink'] = '';
     280        $settings['apirone_logo'] = 'yes';
    247281        $settings['version'] = '1.1.0';
     282       
    248283        // Unset unused
    249284        unset($settings['count_confirmations']);
     
    252287        unset($settings['statuses']);
    253288
    254         update_option('woocommerce_mccp_settings', $settings);     
    255     }
    256 
     289        update_option('woocommerce_mccp_settings', $settings);
     290        delete_option('woocommerce_mccp_wallets');
     291    }
    257292}
  • multi-crypto-currency-payment/trunk/mccp.php

    r2839125 r2877106  
    44Plugin URI: https://github.com/zaytseff/mccp-woo
    55Description: Multi currency crypto payments for Woocommerce. Uses Apirone Processing Provider
    6 Version: 1.1.0
     6Version: 1.1.1
    77Author: Alex Zaytseff
    88Author URI: https://github.com/zaytseff
     
    1717require_once('inc/apirone_api/Payment.php');
    1818
    19 define('PLUGIN_VERSION', '1.1.0');
    2019define('MCCP_ROOT', __DIR__);
    2120define('MCCP_MAIN', __FILE__);
     
    4039        return;
    4140
    42     // require_once 'inc/class-mccp.php';
    4341    require_once 'inc/invoice-class.php';
    4442
    45    
    4643    /**
    4744     * Add MCCP gateway to WooCommerce
  • multi-crypto-currency-payment/trunk/readme.txt

    r2839125 r2877106  
    66Tested up to: 6.1.1
    77Requires PHP: 7.0
    8 Stable tag: 1.1.0
     8Stable tag: 1.1.1
    99License: GPLv2 or later
    1010License URI: https://www.gnu.org/licenses/gpl-2.0.html
    1111
    1212Woocommerce plugin - Multi CryptoCurrency Payments
    13 Requires at least WooCommerce: 4.0 Tested up to: 4.9.7 License: GPLv2 or later
     13Requires at least WooCommerce: 4.0 Tested up to: 7.4 License: GPLv2 or later
    1414
    1515== Description ==
     
    7878
    7979== Changelog ==
     80= Version 1.1.1 | 09/03/2023 =
     81- Fix installation errors on php-8.x version.
     82- Fix update from 1.0.0 on php-8.x
     83- Improve new installation (without plugin update)
     84- Improve update logic
     85
    8086= Version 1.1.0 | 25/12/2022 =
    8187- Add apirone invoices support.
Note: See TracChangeset for help on using the changeset viewer.