Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
72.00% covered (warning)
72.00%
18 / 25
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * This Bitcoin gateway relies on the BitWasp bitwasp/bitcoin-php PHP library for the maths/heavy lifting.
4 *
5 * @see https://github.com/Bit-Wasp/bitcoin-php
6 *
7 * @link              http://example.com
8 * @since             1.0.0
9 * @package           brianhenryie/bh-wp-bitcoin-gateway
10 *
11 * @wordpress-plugin
12 * Plugin Name:       Bitcoin Gateway
13 * Plugin URI:        http://github.com/BrianHenryIE/bh-wp-bitcoin-gateway/
14 * Description:       Accept Bitcoin payments using self-custodied wallets, and no external account. Calculates wallet addresses locally and uses open APIs to verify payments. For an emphasis on privacy & sovereignty.
15 * Version:           2.0.0-beta-7
16 * Requires at least: 5.9
17 * Requires PHP:      7.4
18 * Author:            Nullcorps, BrianHenryIE
19 * Author URI:        https://github.com/Nullcorps/
20 * License:           GNU General Public License v3.0
21 * License URI:       http://www.gnu.org/licenses/gpl-3.0.html
22 * Text Domain:       bh-wp-bitcoin-gateway
23 * Domain Path:       /languages
24 * WC tested up to:   7.3.0
25 */
26
27namespace BrianHenryIE\WP_Bitcoin_Gateway;
28
29use BrianHenryIE\WP_Bitcoin_Gateway\API\Addresses\Bitcoin_Address_Factory;
30use BrianHenryIE\WP_Bitcoin_Gateway\API\Addresses\Bitcoin_Wallet_Factory;
31use BrianHenryIE\WP_Bitcoin_Gateway\API\Addresses\BitWasp_API;
32use BrianHenryIE\WP_Bitcoin_Gateway\API\API;
33use BrianHenryIE\WP_Bitcoin_Gateway\API\Blockchain\Blockstream_Info_API;
34use BrianHenryIE\WP_Bitcoin_Gateway\API\Blockchain_API_Interface;
35use BrianHenryIE\WP_Bitcoin_Gateway\API\Exchange_Rate\Bitfinex_API;
36use BrianHenryIE\WP_Bitcoin_Gateway\API\Exchange_Rate_API_Interface;
37use BrianHenryIE\WP_Bitcoin_Gateway\API\Generate_Address_API_Interface;
38use BrianHenryIE\WP_Bitcoin_Gateway\API\Settings;
39use BrianHenryIE\WP_Bitcoin_Gateway\lucatume\DI52\Container;
40use BrianHenryIE\WP_Bitcoin_Gateway\WP_Includes\Activator;
41use BrianHenryIE\WP_Bitcoin_Gateway\WP_Includes\Deactivator;
42use BrianHenryIE\WP_Bitcoin_Gateway\WP_Logger\Logger;
43use BrianHenryIE\WP_Bitcoin_Gateway\WP_Logger\Logger_Settings_Interface;
44use Exception;
45use Psr\Log\LoggerInterface;
46use Throwable;
47
48// If this file is called directly, abort.
49if ( ! defined( 'WPINC' ) ) {
50    throw new Exception( 'WPINC not defined' );
51}
52
53// If the GitHub repo was installed without running `composer install` to add the dependencies, the autoload will fail.
54try {
55    require_once plugin_dir_path( __FILE__ ) . 'autoload.php';
56} catch ( Throwable $error ) {
57    $display_download_from_releases_error_notice = function () {
58        echo '<div class="notice notice-error"><p><b>Bitcoin Gateway missing dependencies.</b> Please <a href="https://github.com/BrianHenryIE/bh-wp-bitcoin-gateway/releases">install the distribution archive from the GitHub Releases page</a>. It appears you downloaded the GitHub repo and installed that as the plugin.</p></div>';
59    };
60    add_action( 'admin_notices', $display_download_from_releases_error_notice );
61    return;
62}
63
64/**
65 * Current plugin version.
66 * Start at version 1.0.0 and use SemVer - https://semver.org
67 * Rename this for your plugin and update it as you release new versions.
68 */
69define( 'BH_WP_BITCOIN_GATEWAY_VERSION', '2.0.0' );
70
71define( 'BH_WP_BITCOIN_GATEWAY_BASENAME', plugin_basename( __FILE__ ) );
72define( 'BH_WP_BITCOIN_GATEWAY_PATH', trailingslashit( __DIR__ ) );
73define( 'BH_WP_BITCOIN_GATEWAY_URL', trailingslashit( plugins_url( plugin_basename( __DIR__ ) ) ) );
74
75register_activation_hook( __FILE__, array( Activator::class, 'activate' ) );
76register_deactivation_hook( __FILE__, array( Deactivator::class, 'deactivate' ) );
77
78$container = new Container();
79
80$container->bind( API_Interface::class, API::class );
81$container->bind( Settings_Interface::class, Settings::class );
82$container->bind( LoggerInterface::class, Logger::class );
83$container->bind( Logger_Settings_Interface::class, Settings::class );
84
85$container->bind( Blockchain_API_Interface::class, Blockstream_Info_API::class );
86$container->bind( Generate_Address_API_Interface::class, BitWasp_API::class );
87$container->bind( Exchange_Rate_API_Interface::class, Bitfinex_API::class );
88
89$app = $container->get( BH_WP_Bitcoin_Gateway::class );
90
91$GLOBALS['bh_wp_bitcoin_gateway'] = $container->get( API_Interface::class );