forked from claudiosanches/woocommerce-ltc-currency
-
Notifications
You must be signed in to change notification settings - Fork 0
/
woocommerce-ltc-currency.php
76 lines (64 loc) · 2.04 KB
/
woocommerce-ltc-currency.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
69
70
71
72
73
74
75
76
<?php
/**
* Plugin Name: WooCommerce LTC Currency
* Plugin URI: http://claudiosmweb.com/
* Description: Adds Litecoin currency in WooCommerce
* Author: claudiosanches
* Author URI: http://claudiosmweb.com/
* Version: 2.0
* License: GPLv2 or later
*/
if ( ! class_exists( 'WC_LTC_Currency' ) ) {
/**
* Add LTC Currency in WooCommerce.
*/
class WC_LTC_Currency {
/**
* Class construct.
*/
public function __construct() {
// Actions.
add_action( 'plugins_loaded', array( &$this, 'load_textdomain' ), 0 );
// Filters.
add_filter( 'woocommerce_currencies', array( &$this, 'add_currency' ) );
add_filter( 'woocommerce_currency_symbol', array( &$this, 'currency_symbol' ), 1, 2 );
}
/**
* Load Plugin textdomain.
*
* @return void.
*/
public function load_textdomain() {
load_plugin_textdomain( 'wcltc', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
/**
* Add LTC Currency in WooCommerce.
*
* @param array $currencies Current currencies.
*
* @return array Currencies with LTC.
*/
public function add_currency( $currencies ) {
$currencies['LTC'] = __( 'Litecoin', 'wcltc' );
asort( $currencies );
return $currencies;
}
/**
* Add LTC Symbol.
*
* @param string $currency_symbol Currency symbol.
* @param array $currency Current currencies.
*
* @return string LTC currency symbol.
*/
public function currency_symbol( $currency_symbol, $currency ) {
switch( $currency ) {
case 'LTC':
$currency_symbol = 'Ⱡ';
break;
}
return $currency_symbol;
}
} // close WC_LTC_Currency class.
$WC_LTC_Currency = new WC_LTC_Currency();
}