-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflizpay.php
130 lines (112 loc) · 3.75 KB
/
flizpay.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
<?php
/**
* The plugin bootstrap file
*
* This file is read by WordPress to generate the plugin information in the plugin
* admin area. This file also includes all of the dependencies used by the plugin,
* registers the activation and deactivation functions, and defines a function
* that starts the plugin.
*
* @link https://www.flizpay.de
* @since 1.0.0
* @package Flizpay
*
* @wordpress-plugin
* Plugin Name: FLIZpay Gateway für WooCommerce
* Plugin URI: https://www.flizpay.de/companies
* Description: FLIZpay: 100% free!
* Version: 2.0.7
* Author: FLIZpay
* Author URI: https://www.flizpay.de/companies
* License: GPL-2.0+
* License URI: http://www.gnu.org/licenses/gpl-2.0.txt
* Text Domain: flizpay-for-woocommerce
* Domain Path: /languages
* Requires Plugins: woocommerce
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
/**
* Currently plugin version.
* Start at version 1.0.0 and use SemVer - https://semver.org
*/
define('FLIZPAY_VERSION', '2.0.7');
function flizpay_check_dependencies()
{
// Check if WooCommerce is active
if (!class_exists('WooCommerce')) {
// WooCommerce is not active
add_action('admin_notices', 'flizpay_dependencies_notice');
deactivate_plugins(plugin_basename(__FILE__)); // Deactivate the plugin
}
global $woocommerce;
// Define the minimum required WooCommerce version
$required_version = '9.0.0';
// Check WooCommerce version
if (version_compare($woocommerce->version, $required_version, '<')) {
add_action('admin_notices', 'flizpay_version_notice');
deactivate_plugins(plugin_basename(__FILE__));
}
}
add_action('admin_init', 'flizpay_check_dependencies');
function flizpay_dependencies_notice()
{
echo '<div class="error"><p><strong>FLIZpay</strong> requires WooCommerce to be installed and active. Please install and activate WooCommerce.</p></div>';
}
function flizpay_version_notice()
{
echo '<div class="error"><p><strong>FLIZpay</strong> requires WooCommerce version 9.0.0 or higher. Please update WooCommerce.</p></div>';
}
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-flizpay-activator.php
*/
function flizpay_activate()
{
require_once plugin_dir_path(__FILE__) . 'includes/class-flizpay-activator.php';
Flizpay_Activator::activate();
flizpay_check_dependencies();
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-flizpay-deactivator.php
*/
function flizpay_deactivate()
{
require_once plugin_dir_path(__FILE__) . 'includes/class-flizpay-deactivator.php';
Flizpay_Deactivator::deactivate();
}
register_activation_hook(__FILE__, 'flizpay_activate');
register_deactivation_hook(__FILE__, 'flizpay_deactivate');
/**
* The core plugin class that is used to define internationalization,
* admin-specific hooks, and public-facing site hooks.
*/
require plugin_dir_path(__FILE__) . 'includes/class-flizpay.php';
/**
* 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
*/
function flizpay_run()
{
$plugin = new Flizpay();
$plugin->run();
}
flizpay_run();
/**
* This action hook registers Flizpay class as a WooCommerce payment gateway
* We can use unshift to reorder it as first
*/
add_filter('woocommerce_payment_gateways', 'flizpay_add_gateway_class');
function flizpay_add_gateway_class($gateways)
{
array_unshift($gateways, 'WC_Flizpay_Gateway');
return $gateways;
}