Skip to content

Commit

Permalink
Fix array_search() method in admin panel
Browse files Browse the repository at this point in the history
  • Loading branch information
atmoner committed Aug 11, 2023
1 parent 2e6135b commit 75fda33
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 9 deletions.
7 changes: 5 additions & 2 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ Contributors: BitCanna
Donate link: https://commerce.bitcanna.io
Tags: payments, cryptocurrency, blockchain
Requires at least: 3.0.1
Tested up to: 6.1.1
Stable tag: 1.0.18
Tested up to: 6.3
Stable tag: 1.0.19
Requires PHP: 7.0
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
Expand Down Expand Up @@ -37,6 +37,9 @@ For our FAQ we'd like to refer you to our [documentation website](https://docs.b
5. After just a couple seconds, the payment will be performed and you can view your transaction.

== Changelog ==
= 1.0.19 =
* Fix array_search() method in admin panel

= 1.0.18 =
* Check the payment_method_title to avoid conflicts with other payment methods
* Check the selected_payment_method to remove js call
Expand Down
33 changes: 28 additions & 5 deletions admin/partials/cosmos-settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,19 +83,38 @@
update_option( 'woocommerce_woo-cosmos_settings', $configCosmosAddr );
update_option( 'cosmos_pay_config_approved', 'true' );
}

if(!empty($selected_payment_method->settings['option_name'])) {


?>
<form method="post">
<table class="form-table">

<?php

foreach ( $selected_payment_method->form_fields['option_name']['options'] as $key => $value ) {
$keyAvaible = array_search( $key, $selected_payment_method->settings['option_name'] );
if ( $keyAvaible === 0 || !empty( $keyAvaible ) ) {


foreach ( $selected_payment_method->form_fields['option_name']['options'] as $key => $value ) {
$keyAvaible = array_search( $key, $selected_payment_method->settings['option_name'] );


if ( $keyAvaible === 0 || !empty( $keyAvaible ) ) {
?>
<tr valign="top">
<th scope="row">Your <?php echo esc_attr( $value ); ?> address </th>
<td><input required="required" type="text" id="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $value ); ?>" value="<?php echo esc_attr( $configCosmosAddr[$value] ); ?>" size="50" />
<?php
if(!isset($configCosmosAddr[$value])) {
?>
<td><input required="required" type="text" id="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $value ); ?>" value="" size="50" />
<?php
} else {
?>
<td><input required="required" type="text" id="<?php echo esc_attr( $value ); ?>" name="<?php echo esc_attr( $value ); ?>" value="<?php echo esc_attr( $configCosmosAddr[$value] ); ?>" size="50" />
<?php
}

?>

<div id="goodAddr_<?php echo esc_attr( $value ); ?>" style="display: none; color:green;">This is a valid address.</div>
<div id="badAddr_<?php echo esc_attr( $value ); ?>" style="display: none; color:red;">This is an invalid address. Please double-check.</div>
<div id="badAddrPrefix_<?php echo esc_attr( $value ); ?>" style="display: none; color:red;">This address does not belong to this chain. Please update to the right address.</div>
Expand All @@ -122,6 +141,10 @@


</form>
<?php } else { ?>
<h4>No blockchain is configured, select a blockchain in the woocomerce payment configuration</h4>
<?php } ?>

</div>
</div>
<?php } ?>
Expand Down
4 changes: 2 additions & 2 deletions cosmos-woocommerce.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* Plugin Name: Cosmos Pay
* Plugin URI: https://twitter.com/bitcannaglobal
* Description: Easily accept cryptocurrency payments on your WordPress site. Enable multiple currencies from the interconnected Cosmos ecosystem.
* Version: 1.0.18
* Version: 1.0.19
* Author: BitCanna
* Author URI: https://commerce.bitcanna.io
* License: GPL-2.0+
Expand All @@ -35,7 +35,7 @@
* Start at version 1.0.0 and use SemVer - https://semver.org
* Rename this for your plugin and update it as you release new versions.
*/
define( 'COSMOS_WOOCOMMERCE_VERSION', '1.0.18' );
define( 'COSMOS_WOOCOMMERCE_VERSION', '1.0.19' );



Expand Down

0 comments on commit 75fda33

Please sign in to comment.