-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathauthorize-dot-net-for-paymattic.php
109 lines (89 loc) · 3.31 KB
/
authorize-dot-net-for-paymattic.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/**
* @package authorize-dot-net-for-paymattic
*
*/
/**
* Plugin Name: Authorize.net Payment for paymattic
* Plugin URI: https://paymattic.com/
* Description: Authorize.net payment gateway for paymattic. Authorize.net is a leading provider of payment gateway services.
* Version: 1.0.0
* Author: WPManageNinja LLC
* Author URI: https://paymattic.com/
* License: GPLv2 or later
* Text Domain: authorize-dot-net-for-paymattic
* Domain Path: /language
*/
if (!defined('ABSPATH')) {
exit;
}
defined('ABSPATH') or die;
define('AUTHORIZE_DOT_NET_FOR_PAYMATTIC', true);
define('AUTHORIZE_DOT_NET_FOR_PAYMATTIC_DIR', __DIR__);
define('AUTHORIZE_DOT_NET_FOR_PAYMATTIC_URL', plugin_dir_url(__FILE__));
define('AUTHORIZE_DOT_NET_FOR_PAYMATTIC_VERSION', '1.0.0');
if (!class_exists('AuthorizeDotNetForPaymattic')) {
class AuthorizeDotNetForPaymattic
{
public function boot()
{
if (!class_exists('AuthorizeDotNetForPaymattic\API\AuthorizeProcessor')) {
$this->init();
};
}
public function init()
{
require_once AUTHORIZE_DOT_NET_FOR_PAYMATTIC_DIR . '/API/AuthorizeProcessor.php';
(new AuthorizeDotNetForPaymattic\API\AuthorizeProcessor())->init();
$this->loadTextDomain();
}
public function loadTextDomain()
{
load_plugin_textdomain('authorize-dot-net-for-paymattic', false, dirname(plugin_basename(__FILE__)) . '/language');
}
public function hasPro()
{
return defined('WPPAYFORMPRO_DIR_PATH') || defined('WPPAYFORMPRO_VERSION');
}
public function hasFree()
{
return defined('WPPAYFORM_VERSION');
}
public function versionCheck()
{
$currentFreeVersion = WPPAYFORM_VERSION;
$currentProVersion = WPPAYFORMPRO_VERSION;
return version_compare($currentFreeVersion, '4.3.2', '>=') && version_compare($currentProVersion, '4.3.2', '>=');
}
public function renderNotice()
{
add_action('admin_notices', function () {
if (current_user_can('activate_plugins')) {
echo '<div class="notice notice-error"><p>';
echo __('Please install & Activate Paymattic and Paymattic Pro to use authorize-dot-net-for-paymattic plugin.', 'authorize-dot-net-for-paymattic');
echo '</p></div>';
}
});
}
public function updateVersionNotice()
{
add_action('admin_notices', function () {
if (current_user_can('activate_plugins')) {
echo '<div class="notice notice-error"><p>';
echo __('Please update Paymattic and Paymattic Pro to use authorize-dot-net-for-paymattic plugin!', 'authorize-dot-net-for-paymattic');
echo '</p></div>';
}
});
}
}
add_action('init', function () {
$authorize = (new AuthorizeDotNetForPaymattic);
if (!$authorize->hasFree() || !$authorize->hasPro()) {
$authorize->renderNotice();
} else if (!$authorize->versionCheck()) {
$authorize->updateVersionNotice();
} else {
$authorize->boot();
}
});
}