Changeset 2877106
- Timestamp:
- 03/09/2023 11:19:30 AM (3 years ago)
- Location:
- multi-crypto-currency-payment/trunk
- Files:
-
- 4 edited
-
inc/invoice-admin-trait.php (modified) (5 diffs)
-
inc/invoice-utils-trait.php (modified) (8 diffs)
-
mccp.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
multi-crypto-currency-payment/trunk/inc/invoice-admin-trait.php
r2839125 r2877106 40 40 */ 41 41 public function admin_options() { 42 $this->update();43 42 $this->mccp_init_form_fields(); 44 43 if ( Apirone::isFiatSupported(get_option('woocommerce_currency')) ) :?> … … 183 182 'description' => __('List of available cryptocurrencies processed by Apirone', 'mccp'), 184 183 'desc_tip' => true, 184 'default' => [], 185 185 ), 186 186 'factor' => array( … … 216 216 ); 217 217 } 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 218 234 219 235 /** … … 229 245 public function mccp_currency($apirone_currency, $apirone_account = false) { 230 246 $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')) { 232 248 $currency = new \stdClass(); 233 249 … … 244 260 // Set address from config 245 261 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 } 247 265 $currency->address = sanitize_text_field($_POST['woocommerce_mccp_currencies'][$currency->abbr]['address']); 248 266 if ($currency->address != '') { -
multi-crypto-currency-payment/trunk/inc/invoice-utils-trait.php
r2859028 r2877106 102 102 */ 103 103 public function get_mccp_currency($abbr) { 104 $currencies = $this->get_option('currencies');104 $currencies = (array) $this->get_option('currencies'); 105 105 106 106 if ( $currencies && array_key_exists($abbr, $currencies) ) { … … 133 133 134 134 $woo_currency = get_woocommerce_currency(); 135 136 135 $active_currencies = array(); 137 foreach ($this->get_option('currencies') as $item) { 136 137 foreach ((array) $this->get_option('currencies') as $item) { 138 138 if ($item->testnet === 1 && !current_user_can('manage_options')) { 139 139 continue; … … 190 190 191 191 /** 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 /** 192 204 * Plugin version update entry point 193 205 * … … 195 207 */ 196 208 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'); 199 221 } 200 222 } … … 206 228 */ 207 229 function update_1_0_0__1_1_0() { 230 if ($this->version() !== false) { 231 return; 232 } 208 233 global $wpdb, $table_prefix; 209 234 … … 223 248 224 249 $apirone_account = $this->mccp_account(); 225 250 226 251 // Map old currensies 227 252 foreach (Apirone::currencyList() as $apirone_currency) { 228 253 $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'])) { 230 255 $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 } 236 263 } 264 $currency->enabled = ($old_currency['enabled']) ? 1 : 0; 237 265 } 238 $currency->enabled = ($old_currency['enabled']) ? 1 : 0; 266 else { // Clear install of 1.1.1 267 $currency = $old_currency; 268 } 239 269 } 240 241 270 $mccp_currencies[$apirone_currency->abbr] = $currency; 242 271 … … 244 273 // Update currensies 245 274 $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'; 247 281 $settings['version'] = '1.1.0'; 282 248 283 // Unset unused 249 284 unset($settings['count_confirmations']); … … 252 287 unset($settings['statuses']); 253 288 254 update_option('woocommerce_mccp_settings', $settings); 255 }256 289 update_option('woocommerce_mccp_settings', $settings); 290 delete_option('woocommerce_mccp_wallets'); 291 } 257 292 } -
multi-crypto-currency-payment/trunk/mccp.php
r2839125 r2877106 4 4 Plugin URI: https://github.com/zaytseff/mccp-woo 5 5 Description: Multi currency crypto payments for Woocommerce. Uses Apirone Processing Provider 6 Version: 1.1. 06 Version: 1.1.1 7 7 Author: Alex Zaytseff 8 8 Author URI: https://github.com/zaytseff … … 17 17 require_once('inc/apirone_api/Payment.php'); 18 18 19 define('PLUGIN_VERSION', '1.1.0');20 19 define('MCCP_ROOT', __DIR__); 21 20 define('MCCP_MAIN', __FILE__); … … 40 39 return; 41 40 42 // require_once 'inc/class-mccp.php';43 41 require_once 'inc/invoice-class.php'; 44 42 45 46 43 /** 47 44 * Add MCCP gateway to WooCommerce -
multi-crypto-currency-payment/trunk/readme.txt
r2839125 r2877106 6 6 Tested up to: 6.1.1 7 7 Requires PHP: 7.0 8 Stable tag: 1.1. 08 Stable tag: 1.1.1 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html 11 11 12 12 Woocommerce plugin - Multi CryptoCurrency Payments 13 Requires at least WooCommerce: 4.0 Tested up to: 4.9.7License: GPLv2 or later13 Requires at least WooCommerce: 4.0 Tested up to: 7.4 License: GPLv2 or later 14 14 15 15 == Description == … … 78 78 79 79 == 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 80 86 = Version 1.1.0 | 25/12/2022 = 81 87 - Add apirone invoices support.
Note: See TracChangeset
for help on using the changeset viewer.