kudos-donations.php 3 KB
Newer Older
Michael Iseard's avatar
Michael Iseard committed
1
2
<?php
/**
Michael Iseard's avatar
Michael Iseard committed
3
4
 * Add a donation button to any page on your website. Easy & fast setup. Works with Mollie payments.
 *
Michael Iseard's avatar
Michael Iseard committed
5
 * @link              https://www.linkedin.com/in/michael-iseard/
Michael Iseard's avatar
Michael Iseard committed
6
 * @author            Michael Iseard
7
 * @package           Kudos-Donations
Michael Iseard's avatar
Michael Iseard committed
8
9
 *
 * @wordpress-plugin
Michael Iseard's avatar
Michael Iseard committed
10
 * Plugin Name:       Kudos Donations
Michael Iseard's avatar
Michael Iseard committed
11
 * Plugin URI:        https://gitlab.iseard.media/michael/kudos-donations
Michael Iseard's avatar
Michael Iseard committed
12
 * Description:       Add a donation button to any page on your website. Easy & fast setup. Works with Mollie payments.
Michael Iseard's avatar
Michael Iseard committed
13
 * Version:           2.3.3
Michael Iseard's avatar
Michael Iseard committed
14
15
 * Author:            Iseard Media
 * Author URI:        https://iseard.media
16
 * Requires at least: 5.5
17
 * Requires PHP:      7.1
Michael Iseard's avatar
Michael Iseard committed
18
19
 * License:           GPL-2.0+
 * License URI:       http://www.gnu.org/licenses/gpl-2.0.txt
20
 * Text Domain:       kudos-donations
Michael Iseard's avatar
Michael Iseard committed
21
22
23
 * Domain Path:       /languages
 */

Michael Iseard's avatar
Michael Iseard committed
24
25
26
27
28
29
30
namespace Kudos;

use Kudos\Service\ActivatorService;
use Kudos\Service\CompatibilityService;
use Kudos\Service\DeactivatorService;

require_once __DIR__ . '/vendor/autoload.php';
31
require_once __DIR__ . '/vendor/woocommerce/action-scheduler/action-scheduler.php';
Michael Iseard's avatar
Michael Iseard committed
32

Michael Iseard's avatar
Michael Iseard committed
33
34
35
// Load .env file if present.
if ( class_exists( \Dotenv\Dotenv::class ) && file_exists( __DIR__ . '/.env' ) ) {
	$dotenv = \Dotenv\Dotenv::createImmutable( __DIR__ );
36
37
38
	$dotenv->load();
}

Michael Iseard's avatar
Michael Iseard committed
39
40
41
42
43
// If this file is called directly, abort.
if ( ! defined( 'WPINC' ) ) {
	die;
}

Michael Iseard's avatar
Michael Iseard committed
44
define( 'KUDOS_VERSION', '2.3.3' );
Michael Iseard's avatar
Michael Iseard committed
45
define( 'KUDOS_PLUGIN_DIR', dirname( __FILE__ ) );
46
47
define( 'KUDOS_PLUGIN_URL', plugin_dir_url( __FILE__ ) );
define( 'KUDOS_STORAGE_DIR', wp_upload_dir()['basedir'] . '/kudos-donations/' );
Michael Iseard's avatar
Michael Iseard committed
48
49
define( 'KUDOS_STORAGE_URL', wp_upload_dir()['baseurl'] . '/kudos-donations/' );
define( 'KUDOS_DEBUG', get_option( '_kudos_debug_mode' ) );
Michael Iseard's avatar
Michael Iseard committed
50

Michael Iseard's avatar
Michael Iseard committed
51
52
/**
 * The code that runs during plugin activation.
53
 * This action is documented in app/Service/ActivatorService.php
Michael Iseard's avatar
Michael Iseard committed
54
 */
Michael Iseard's avatar
Michael Iseard committed
55
function activate_kudos() {
56
57
	require_once KUDOS_PLUGIN_DIR . '/app/Service/ActivatorService.php';
	ActivatorService::activate();
Michael Iseard's avatar
Michael Iseard committed
58
59
60
61
}

/**
 * The code that runs during plugin deactivation.
62
 * This action is documented in app/Service/DeactivatorService.php
Michael Iseard's avatar
Michael Iseard committed
63
 */
Michael Iseard's avatar
Michael Iseard committed
64
function deactivate_kudos() {
65
66
	require_once KUDOS_PLUGIN_DIR . '/app/Service/DeactivatorService.php';
	DeactivatorService::deactivate();
Michael Iseard's avatar
Michael Iseard committed
67
68
}

Michael Iseard's avatar
Michael Iseard committed
69
register_activation_hook( __FILE__, __NAMESPACE__ . '\activate_kudos' );
Michael Iseard's avatar
Michael Iseard committed
70
register_deactivation_hook( __FILE__, __NAMESPACE__ . '\deactivate_kudos' );
Michael Iseard's avatar
Michael Iseard committed
71
72
73
74
75

/**
 * The core plugin class that is used to define internationalization,
 * admin-specific hooks, and public-facing site hooks.
 */
76
require KUDOS_PLUGIN_DIR . '/app/KudosDonations.php';
Michael Iseard's avatar
Michael Iseard committed
77
78
79
80
81
82
83
84
85
86

/**
 * Begins execution of the plugin.
 *
 * Since everything within the plugin is registered via hooks,
 * then kicking off the plugin from this point in the file does
 * not affect the page life cycle.
 *
 * @since    1.0.0
 */
Michael Iseard's avatar
Michael Iseard committed
87
function run_kudos() {
Michael Iseard's avatar
Michael Iseard committed
88

89
	// Check compatibility and run kudos if OK
90
91
92
	$compatibility = new CompatibilityService();
	$continue = $compatibility->init();

Michael Iseard's avatar
Michael Iseard committed
93
	if ( $continue ) {
94
95
96
		$plugin = new KudosDonations();
		$plugin->run();
	}
Michael Iseard's avatar
Michael Iseard committed
97
98

}
99

Michael Iseard's avatar
Michael Iseard committed
100
run_kudos();