Skip to content

Commit

Permalink
Merge pull request #6 from thejoshualewis/master
Browse files Browse the repository at this point in the history
set a default currency for first autogenerated code block
  • Loading branch information
thejoshualewis authored May 21, 2019
2 parents d16bd0a + ac944b0 commit 2d0a3ec
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 4 deletions.
Binary file modified assets/banner-1544x500.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified assets/banner-772x250.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
43 changes: 40 additions & 3 deletions index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/*
* Plugin Name: BitPay QuickPay
* Description: Create BitPay payment buttons with a shortcode. <a href ="admin.php?page=bitpay-quickpay">Configure</a>
* Version: 1.0.1.2
* Version: 1.0.1.3
* Author: BitPay
* Author URI: mailto:[email protected]?subject=BitPay QuickPay
*/
Expand Down Expand Up @@ -148,6 +148,9 @@ function bitpayquickpay_register_settings()
add_option('bitpayquickpay_option_message');
register_setting('bitpayquickpay_options_group', 'bitpayquickpay_option_message', 'bitpayquickpay_callback');

add_option('bitpayquickpay_option_default_amount');
register_setting('bitpayquickpay_options_group', 'bitpayquickpay_option_default_amount', 'bitpayquickpay_callback');

}
add_action('admin_init', 'bitpayquickpay_register_settings');

Expand All @@ -170,9 +173,11 @@ function getBitPayQuickPayBrands($name_only = false, $price = false,$d = false,$

$buttonObj = new BPC_Buttons;
$buttons = json_decode($buttonObj->BPC_getButtons());
$default_amount = get_option('bitpayquickpay_option_default_amount');
if (!$name_only) { #get the images

$brand = '';
$looper = 0;
foreach ($buttons->data as $key => $b):

$names = preg_split('/(?=[A-Z])/', $b->name);
Expand All @@ -185,7 +190,7 @@ function getBitPayQuickPayBrands($name_only = false, $price = false,$d = false,$


$brand .= '<figure style="float:left;"><figcaption style="text-align:left;"><b>' . $names . '</b><p>' . $b->description . '</p></figcaption>';
$brand .= '<input class="bp_input" style="margin-bottom: 17px;height: 35px;" onkeyup = "BPQP_Clean(this.value,\'' . $shortcode_name . '\');" placeholder="Enter the amount" id = "gen_' . $shortcode_name . '" type="text" size="20">';
$brand .= '<input class="bp_input" style="margin-bottom: 17px;height: 35px;" onkeyup = "BPQP_Clean(this.value,\'' . $shortcode_name . '\');" placeholder="Enter the amount" id = "gen_' . $shortcode_name . '" type="text" size="20" value = "'.$default_amount.'">';
$brand .= '<input type="checkbox" style = "margin-left:10px;" id = "chk_' . $shortcode_name . '"> Allow users to change amount<br>
';
$brand .= '<input class="bp_input" style="margin-bottom: 17px;height: 35px;" placeholder="Description (optional)" id = "desc_' . $shortcode_name . '"type="text" size="30">';
Expand All @@ -194,7 +199,15 @@ function getBitPayQuickPayBrands($name_only = false, $price = false,$d = false,$
$brand .='<hr style = "margin-top:40px;">';

$brand .= '</figure>';
#if($looper == 0):
#fake the click to generate the first one
echo '<script type = "text/javascript">';
echo 'setDefaultCode("'.$looper.'");';
echo '</script>';
# endif;
$looper++;
endforeach;


return $brand;
} else {
Expand Down Expand Up @@ -352,6 +365,9 @@ function bpqp_load_options()
</td>
</tr>





<tr align="left">
<th scope="row"><label for="bitpayquickpay_option_currency">Currency</label></th>
Expand All @@ -369,12 +385,33 @@ function bpqp_load_options()
</td>
</tr>


<tr align="left">
<td>&nbsp</td>
<td>
<em>Select <b>Test</b> for testing the plugin, <b>Production</b> when you are ready to go live.</em>
<em>Set yout payment currency</em>
</td>
</tr>


<tr align="left">
<th scope="row"><label for="bitpayquickpay_option_default_amount">Default Amount</label></th>
<td>
<input type="text" size="80" onkeyup = "BPQP_CleanDefault(this.value)" id="bitpayquickpay_option_default_amount"
name="bitpayquickpay_option_default_amount"
value="<?php echo get_option('bitpayquickpay_option_default_amount'); ?>" />

</td>

</tr>

<tr align="left">
<td>&nbsp</td>
<td>
<em>Set a default amount for the autogenerator</em>
</td>
</tr>


<tr align="left">
<th scope="row"><label for="bitpayquickpay_option_message">Thank You Message</label></th>
Expand Down
18 changes: 18 additions & 0 deletions js/admin_bitpayquickpay_js.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
function setDefaultCode($looper){
if($looper == 0){
setTimeout(function(){
generateBPQPCode('paywithbitpaybutton');
}, 500);
}
}

function generateBPQPCode(button){

//clear out other text boxes
Expand Down Expand Up @@ -44,6 +52,16 @@ function generateBPQPCode(button){

}

function BPQP_CleanDefault(val){
console.log('aaa',val)
if (val.length == 0 || !jQuery.isNumeric(val)){
val = val.substring(0, val.length - 1)
jQuery("#bitpayquickpay_option_default_amount").val(val)
return
}
}


function BPQP_Clean(val,button){
if (val.length == 0 || !jQuery.isNumeric(val)){
val = val.substring(0, val.length - 1)
Expand Down
5 changes: 4 additions & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Tags: bitcoin, bitcoin cash, payments, bitpay, cryptocurrency, payment gateway
Requires at least: 4.9
Tested up to: 5.0.4
Requires PHP: 5.5
Stable tag: 1.0.1.2
Stable tag: 1.0.1.3
License: MIT License (MIT)
License URI: https://github.com/bitpay/bitpay-quickpay/blob/master/LICENSE

Expand Down Expand Up @@ -101,5 +101,8 @@ You can contact our support team via the following form https://bitpay.com/reque

== Changelog ==

= 1.0.1.3 =
* Initialize admin buttons with default value

= 1.0.1.2 =
* Performance tweaks when loading buttons

0 comments on commit 2d0a3ec

Please sign in to comment.