-
Notifications
You must be signed in to change notification settings - Fork 8
/
wp-crypto-accounts.php
74 lines (61 loc) · 2.05 KB
/
wp-crypto-accounts.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
<?php
/*
Plugin Name: Crypto Accounts
Plugin URI: http://github.com/limikael/wp-crypto-accounts
GitHub Plugin URI: https://github.com/limikael/wp-crypto-accounts
Description: Let all your users have a bitcoin account.
Version: 0.0.5
*/
require_once __DIR__."/src/plugin/CryptoAccountsPlugin.php";
require_once __DIR__."/src/controller/ShortcodeController.php";
require_once __DIR__."/src/controller/SettingsController.php";
require_once __DIR__."/src/utils/WpUtil.php";
require_once __DIR__."/src/model/Account.php";
require_once __DIR__."/src/model/Transaction.php";
require_once __DIR__."/src/controller/AccountController.php";
use wpblockchainaccounts\WpUtil;
use wpblockchainaccounts\CryptoAccountsPlugin;
use wpblockchainaccounts\ShortcodeController;
use wpblockchainaccounts\SettingsController;
use wpblockchainaccounts\Account;
use wpblockchainaccounts\Transaction;
use wpblockchainaccounts\AccountController;
CryptoAccountsPlugin::instance();
ShortcodeController::instance();
AccountController::instance();
if (is_admin()) {
SettingsController::instance();
}
// Get a reference to a user account.
if (!function_exists("bca_user_account")) {
function bca_user_account($user) {
return Account::getUserAccount($user);
}
}
// Get a reference to an entity account.
if (!function_exists("bca_entity_account")) {
function bca_entity_account($entity_type, $entity_id) {
return Account::getEntityAccount($entity_type, $entity_id);
}
}
// Make transaction.
if (!function_exists("bca_make_transaction")) {
function bca_make_transaction($denomination, $fromAccount, $toAccount, $amount, $options=array()) {
$t=new Transaction();
$t->setFromAccount($fromAccount);
$t->setToAccount($toAccount);
$t->setAmount($denomination,$amount);
if (isset($options["notice"]))
$t->setNotice($options["notice"]);
if (isset($options["confirming"]))
$t->setUseConfirming($options["confirming"]);
$t->perform();
return $t->id;
}
}
// Get available denominations
if (!function_exists("bca_denominations")) {
function bca_denominations() {
return array("bits","mbtc","btc");
}
}