-
Notifications
You must be signed in to change notification settings - Fork 9
/
give-addon-boilerplate.php
62 lines (51 loc) · 2.05 KB
/
give-addon-boilerplate.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
<?php
namespace GiveAddon;
use GiveAddon\Addon\Activation;
use GiveAddon\Addon\Environment;
use GiveAddon\Domain\AddonServiceProvider;
use GiveAddon\FormExtension\FormExtensionServiceProvider;
use GiveAddon\OffSiteGateway\OffSiteGatewayServiceProvider;
/**
* Plugin Name: ADDON_NAME
* Plugin URI: https://givewp.com/addons/BOILERPLATE/
* Description: ADDON_DESCRIPTION
* Version: 1.0.0
* Requires at least: 4.9
* Requires PHP: 5.6
* Author: GiveWP
* Author URI: https://givewp.com/
* Text Domain: ADDON_TEXTDOMAIN
* Domain Path: /languages
*/
defined('ABSPATH') or exit;
// Add-on name
define('ADDON_CONSTANT_NAME', 'ADDON_NAME');
// Versions
define('ADDON_CONSTANT_VERSION', '1.0.0');
define('ADDON_CONSTANT_MIN_GIVE_VERSION', '2.8.0');
// Add-on paths
define('ADDON_CONSTANT_FILE', __FILE__);
define('ADDON_CONSTANT_DIR', plugin_dir_path(ADDON_CONSTANT_FILE));
define('ADDON_CONSTANT_URL', plugin_dir_url(ADDON_CONSTANT_FILE));
define('ADDON_CONSTANT_BASENAME', plugin_basename(ADDON_CONSTANT_FILE));
require 'vendor/autoload.php';
// Activate add-on hook.
register_activation_hook(ADDON_CONSTANT_FILE, [Activation::class, 'activateAddon']);
// Deactivate add-on hook.
register_deactivation_hook(ADDON_CONSTANT_FILE, [Activation::class, 'deactivateAddon']);
// Uninstall add-on hook.
register_uninstall_hook(ADDON_CONSTANT_FILE, [Activation::class, 'uninstallAddon']);
// Register the add-on service provider with the GiveWP core.
add_action(
'before_give_init',
function () {
// Check Give min required version.
if (Environment::giveMinRequiredVersionCheck()) {
give()->registerServiceProvider(AddonServiceProvider::class);
give()->registerServiceProvider(FormExtensionServiceProvider::class);
give()->registerServiceProvider(OffSiteGatewayServiceProvider::class);
}
}
);
// Check to make sure GiveWP core is installed and compatible with this add-on.
add_action('admin_init', [Environment::class, 'checkEnvironment']);