-
Notifications
You must be signed in to change notification settings - Fork 0
/
paypal-for-woocommerce-multi-account-management.php
170 lines (146 loc) · 7.5 KB
/
paypal-for-woocommerce-multi-account-management.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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<?php
/**
* The plugin bootstrap file
*
*
* @link http://www.angelleye.com/
* @since 1.0.0
* @package Paypal_For_Woocommerce_Multi_Account_Management
*
* @wordpress-plugin
* Plugin Name: PayPal for WooCommerce Multi-Account Management
* Plugin URI: https://www.angelleye.com/product/paypal-woocommerce-multi-account-management/
* Description: Send WooCommerce order payments to different PayPal accounts based on rules provided.
* Version: 4.0.2
* Author: Angell EYE
* Author URI: http://www.angelleye.com/
* License: GPLv3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: paypal-for-woocommerce-multi-account-management
* Domain Path: /languages
* Requires at least: 5.0
* Tested up to: 6.5.5
* Requires Plugins: woocommerce, paypal-for-woocommerce
* WC requires at least: 3.0.0
* WC tested up to: 9.0.2
*/
// If this file is called directly, abort.
if (!defined('WPINC')) {
die;
}
define('PFWMA_VERSION', '4.0.2');
/**
* define plugin basename
*/
if (!defined('PFWMA_PLUGIN_BASENAME')) {
define('PFWMA_PLUGIN_BASENAME', plugin_basename(__FILE__));
}
if (!defined('PFWMA_PLUGIN_DIR')) {
define('PFWMA_PLUGIN_DIR', dirname(__FILE__));
}
if (!defined('AEU_ZIP_URL')) {
define('AEU_ZIP_URL', 'https://updates.angelleye.com/ae-updater/angelleye-updater/angelleye-updater.zip');
}
if (!defined('PAYPAL_FOR_WOOCOMMERCE_PUSH_NOTIFICATION_WEB_URL')) {
define('PAYPAL_FOR_WOOCOMMERCE_PUSH_NOTIFICATION_WEB_URL', 'https://www.angelleye.com/');
}
if (!defined('MULTI_ACCOUNT_REFUND_NOTICE')) {
define('MULTI_ACCOUNT_REFUND_NOTICE', __('Partial refunds are not available for parallel payments orders.', 'paypal-for-woocommerce-multi-account-management'));
}
/**
* Required functions
*/
if (!function_exists('angelleye_queue_update')) {
require_once( 'includes/angelleye-functions.php' );
}
require_once( 'includes/angelleye-multi-account-function.php' );
/**
* Plugin updates
*/
angelleye_queue_update(plugin_basename(__FILE__), '101', 'paypal-for-woocommerce-multi-account-management');
/**
* The code that runs during plugin activation.
* This action is documented in includes/class-paypal-for-woocommerce-multi-account-management-activator.php
*/
function activate_paypal_for_woocommerce_multi_account_management() {
require_once plugin_dir_path(__FILE__) . 'includes/class-paypal-for-woocommerce-multi-account-management-activator.php';
Paypal_For_Woocommerce_Multi_Account_Management_Activator::activate();
}
/**
* The code that runs during plugin deactivation.
* This action is documented in includes/class-paypal-for-woocommerce-multi-account-management-deactivator.php
*/
function deactivate_paypal_for_woocommerce_multi_account_management() {
require_once plugin_dir_path(__FILE__) . 'includes/class-paypal-for-woocommerce-multi-account-management-deactivator.php';
Paypal_For_Woocommerce_Multi_Account_Management_Deactivator::deactivate();
}
register_activation_hook(__FILE__, 'activate_paypal_for_woocommerce_multi_account_management');
register_deactivation_hook(__FILE__, 'deactivate_paypal_for_woocommerce_multi_account_management');
/**
* 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-paypal-for-woocommerce-multi-account-management.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 run_paypal_for_woocommerce_multi_account_management() {
$plugin = new Paypal_For_Woocommerce_Multi_Account_Management();
$plugin->run();
}
add_action('plugins_loaded', 'load_angelleye_woo_paypal_for_woo_multi_account');
add_action('admin_notices', 'admin_notices_required_plugin');
function admin_notices_required_plugin() {
if (function_exists('WC') && class_exists('AngellEYE_Gateway_Paypal')) {
} else {
if (!function_exists('WC')) {
$slug = 'woocommerce';
$install_url = wp_nonce_url(self_admin_url('update.php?action=install-plugin&plugin=' . $slug), 'install-plugin_' . $slug);
$activate_url = 'plugins.php?action=activate&plugin=' . urlencode('woocommerce/woocommerce.php') . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode(wp_create_nonce('activate-plugin_woocommerce/woocommerce.php'));
$message = '<a href="' . esc_url($install_url) . '">Install the WooCommerce plugin</a>.';
$is_downloaded = false;
$plugins = array_keys(get_plugins());
foreach ($plugins as $plugin) {
if (strpos($plugin, 'woocommerce.php') !== false) {
$is_downloaded = true;
$message = '<a href="' . esc_url(admin_url($activate_url)) . '"> Activate the WooCommerce plugin</a>.';
}
}
echo "<div class='notice notice-error'><p>" . sprintf(__('%1$sPayPal for WooCommerce Multi-Account Management is not functional. %2$s The %3$sWooCommerce%4$s plugin must be active for PayPal for WooCommerce Multi-Account Management to work. Please %5$s', 'paypal-for-woocommerce-multi-account-management'), '<strong>', '</strong>', '<a href="http://wordpress.org/extend/plugins/woocommerce/">', '</a>', $message) . '</p></div>';
}
if (!class_exists('AngellEYE_Gateway_Paypal')) {
$slug = 'paypal-for-woocommerce';
$install_url = 'https://www.angelleye.com/product/woocommerce-paypal-plugin/?utm_source=pfwma&utm_medium=admin_notice';
$activate_url = 'plugins.php?action=activate&plugin=' . urlencode('paypal-for-woocommerce/paypal-for-woocommerce.php') . '&plugin_status=all&paged=1&s&_wpnonce=' . urlencode(wp_create_nonce('activate-plugin_paypal-for-woocommerce/paypal-for-woocommerce.php'));
$message = '<a href="' . esc_url($install_url) . '">Install the PayPal for WooCommerce plugin</a>.';
$is_downloaded = false;
$plugins = array_keys(get_plugins());
foreach ($plugins as $plugin) {
if (strpos($plugin, 'paypal-for-woocommerce.php') !== false) {
$is_downloaded = true;
$message = '<a href="' . esc_url(admin_url($activate_url)) . '"> Activate the PayPal for WooCommerce plugin</a>.';
}
}
echo "<div class='notice notice-error'><p>" . sprintf(__('%1$s PayPal for WooCommerce Multi-Account Management is not functional. %2$s The %3$s PayPal for WooCommerce%4$s plugin must be active for PayPal for WooCommerce Multi-Account Management to work. Please %5$s', 'paypal-for-woocommerce-multi-account-management'), '<strong>', '</strong>', '<a href="https://www.angelleye.com/product/woocommerce-paypal-plugin/?utm_source=pfwma&utm_medium=admin_notice">', '</a>', $message) . '</p></div>';
}
}
}
function load_angelleye_woo_paypal_for_woo_multi_account() {
try {
if (function_exists('WC') && class_exists('AngellEYE_Gateway_Paypal')) {
run_paypal_for_woocommerce_multi_account_management();
}
} catch (Exception $ex) {
}
}
add_action( 'before_woocommerce_init', function() {
if ( class_exists( \Automattic\WooCommerce\Utilities\FeaturesUtil::class ) ) {
\Automattic\WooCommerce\Utilities\FeaturesUtil::declare_compatibility( 'custom_order_tables', __FILE__, true );
}
} );