-
Notifications
You must be signed in to change notification settings - Fork 3
/
coinwidget-shortcode.php
executable file
·68 lines (61 loc) · 1.87 KB
/
coinwidget-shortcode.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
/*
* Plugin Name: Coinbase-Shortcode
* Version: 1.1
* Plugin URI: http://notions.okuda.ca
* Description: Shortcode for coinwidget.com buttons
* Author: Kaz Okuda
* Author URI: http://notions.okuda.ca
* Requires at least: 3.0
* Tested up to: 3.7.1
*/
class CoinWidget {
public function __construct() {
$this->coinwidget_url = trailingslashit( plugins_url( '/coinwidget.com/', __FILE__ ) );
$this->root_url = trailingslashit( plugins_url( '/', __FILE__ ) );
add_action('init', array( $this, 'on_init' ));
add_shortcode('coinwidget', array( $this, 'handle_shortcode' ));
}
function on_init()
{
// Include the coin.js code with the other script includes
wp_enqueue_script('ko-coinwidget', $this->root_url . 'coin_js_wrapper.php', array('jquery'));
}
function handle_shortcode($atts)
{
extract(shortcode_atts(array(
'address' => '',
'currency' => 'bitcoin',
'counter' => 'count',
'alignment' => 'bl',
'qrcode' => "true",
'auto_show' => "false",
'decimals' => "4",
'lbl_button' => 'Donate',
'lbl_address' => 'My Bitcoin Address:',
'lbl_count' => 'donations',
'lbl_amount' => 'BTC',
), $atts));
ob_start();
?>
<script>
CoinWidgetCom.source = "<?php echo $this->coinwidget_url ?>"
CoinWidgetCom.go({
wallet_address: "<?php echo $address ?>"
, currency: "<?php echo $currency ?>"
, counter: "<?php echo $counter ?>"
, alignment: "<?php echo $alignment ?>"
, qrcode: <?php echo $qrcode ?>
, auto_show: <?php echo $auto_show ?>
, decimals: <?php echo $decimals ?>
, lbl_button: "<?php echo $lbl_button ?>"
, lbl_address: "<?php echo $lbl_address ?>"
, lbl_count: "<?php echo $lbl_count ?>"
, lbl_amount: "<?php echo $lbl_amount ?>"
});
</script>
<?php
return ob_get_clean();
}
}
$plugin_obj = new CoinWidget();