-
Notifications
You must be signed in to change notification settings - Fork 0
/
offers-for-woocommerce.php
170 lines (141 loc) · 4.84 KB
/
offers-for-woocommerce.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
/**
* @wordpress-plugin
* Plugin Name: Offers for WooCommerce
* Plugin URI: http://www.angelleye.com/product/offers-for-woocommerce
* Description: Accept offers for products on your website. Respond with accept, deny, or counter-offer, and manage all active offers/counters easily.
* Version: 3.0.7
* Author: Angell EYE
* Author URI: http://www.angelleye.com/
* License: GNU General Public License v3.0
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
* Text Domain: offers-for-woocommerce
* Domain Path: /languages/
* GitHub Plugin URI: https://github.com/angelleye/offers-for-woocommerce
* Requires at least: 5.5
* Tested up to: 6.6.1
* WC requires at least: 3.0.0
* WC tested up to: 9.9.2
* Requires Plugins: woocommerce
*/
/**
* Abort if called directly
*
* @since 0.1.0
*/
if (!defined('ABSPATH')) {
die;
}
if (!defined('OFW_PLUGIN_URL')) {
define('OFW_PLUGIN_URL', plugin_dir_path(__FILE__));
}
if (!defined('OFFERS_FOR_WOOCOMMERCE_LOG_DIR')) {
$upload_dir = wp_upload_dir();
define('OFFERS_FOR_WOOCOMMERCE_LOG_DIR', $upload_dir['basedir'] . '/offers-for-woocommerce-logs/');
}
if (!defined('OFFERS_FOR_WOOCOMMERCE_PLUGIN_DIR')) {
define('OFFERS_FOR_WOOCOMMERCE_PLUGIN_DIR', dirname(__FILE__));
}
if (!defined('OFFERS_FOR_WOOCOMMERCE_ASSET_URL')) {
define('OFFERS_FOR_WOOCOMMERCE_ASSET_URL', plugin_dir_url(__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/');
}
/**
*******************************
* Public-Facing Functionality *
*******************************
*/
/**
* Require plugin class
*
* @since 0.1.0
*/
require_once(plugin_dir_path(__FILE__) . 'public/class-offers-for-woocommerce.php');
/**
* Load plugin text domain
*/
add_action('plugins_loaded', 'angelleye_ofwc_load_plugin_textdomain');
/**
* Load the plugin text domain for translation
*
* @since 1.1.3
*
* @return void
*/
function angelleye_ofwc_load_plugin_textdomain() {
load_plugin_textdomain('offers-for-woocommerce', FALSE, basename(dirname(__FILE__)) . '/languages/');
}
/**
* Register hooks that are fired when the plugin is activated or deactivated
* When the plugin is deleted, the uninstall.php file is loaded
*
* @since 0.1.0
*/
register_activation_hook(__FILE__, array('Angelleye_Offers_For_Woocommerce', 'activate'));
register_deactivation_hook(__FILE__, array('Angelleye_Offers_For_Woocommerce', 'deactivate'));
/**
* Plugins Loaded init
*
* @since 0.1.0
*/
add_action('plugins_loaded', array('Angelleye_Offers_For_Woocommerce', 'get_instance'));
/**
**********************************************
* Dashboard and Administrative Functionality *
**********************************************
*/
/**
* Required functions
*/
if (!function_exists('angelleye_queue_update')) {
require_once 'includes/angelleye-functions.php';
}
angelleye_queue_update(plugin_basename(__FILE__), '101', 'offers-for-woocommerce');
/**
* Include plugin admin class
*
* @NOTE: !The code below is intended to give the lightest footprint possible
* @NOTE: If you want to include Ajax within the dashboard, change the following
* conditional to: if ( is_admin() ) { ... }
*
* @since 0.1.0
*/
function ofwc_get_active_plugins() {
update_option('woocommerce_queue_flush_rewrite_rules', 'yes');
$active_plugins = (array)get_option('active_plugins', array());
if (is_multisite()) $active_plugins = array_merge($active_plugins, get_site_option('active_sitewide_plugins', array()));
return $active_plugins;
}
/**
* Check WC Vendor pro plugin is active oe not.
*
* @since 0.1.0
*
* @return bool
*/
function ofwc_is_wcvendors_pro_active() {
$active_plugins = ofwc_get_active_plugins();
if (!empty($active_plugins)) {
foreach ($active_plugins as $key => $value) {
if (strpos($value, 'wcvendors-pro.php') !== false) {
return true;
}
}
}
return false;
}
if (is_admin() || ofwc_is_wcvendors_pro_active() || class_exists('Angelleye_Offers_For_Woocommerce_Dokan')) {
require_once(plugin_dir_path(__FILE__). 'admin/views/class-offers-for-woocommerce-email-reminder.php');
require_once(plugin_dir_path(__FILE__). 'admin/class-offers-for-woocommerce-admin.php');
add_action('plugins_loaded', array('Angelleye_Offers_For_Woocommerce_Admin', 'get_instance'));
}
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 );
}
} );