ebaysync.php
2.8 KB
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
<?php
/*
Plugin Name: eBay Sync
Description: WooCommerce to eBay integration.
Version: 1.6
Author: eBay Australia
Author URI: http://www.ebay.com.au/
*/
defined('ABSPATH') or die('Plugin file cannot be accessed directly.');
if (in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', get_option('active_plugins'))) ||
in_array('woocommerce/woocommerce.php', apply_filters('active_plugins', array_keys(get_site_option('active_sitewide_plugins'))))) {
if (!function_exists('affinity_empty')) {
function affinity_empty($value) {
if (empty($value) && (!is_numeric($value))) {
return true;
} else {
return false;
}
}
}
if (!class_exists('eBaySync')) {
class eBaySync {
protected $tag = 'ebaysync';
protected $name = 'eBay Sync';
protected $version = '1.6';
public function getVersion() {
return $this->version;
}
public function pluginWasActivated() {
require_once(__DIR__.'/model/AffinityEbayInstCategory.php');
AffinityEbayInstCategory::install();
require_once(__DIR__.'/ecommerce-adapters/AffinityDataLayer.php');
AffinityDataLayer::createInitialOptions();
AffinityDataLayer::createOrUpdateSchema();
require_once(__DIR__ . "/ecommerce-adapters/AffinityCrontab.php");
AffinityCrontab::createInitialCrontab();
}
public function pluginWasUpdated() {
require_once(__DIR__.'/ecommerce-adapters/AffinityDataLayer.php');
AffinityDataLayer::createOrUpdateSchema();
}
public function pluginWasDeactivated() {
require_once(__DIR__ . "/ecommerce-adapters/AffinityCrontab.php");
AffinityCrontab::clearCrontab();
}
public function __construct() {
global $pagenow;
if ($pagenow === 'admin.php' || $pagenow === "admin-ajax.php") {
@ob_start();
}
require_once(__DIR__ . "/includes/AffinityPagesManager.php");
$pagesManager = new AffinityPagesManager();
if ($pagenow === 'admin.php' || $pagenow === 'plugins.php') {
$pagesManager->pluginCheck();
}
add_action('admin_menu', array($pagesManager, 'initAdminMenu'));
require_once(__DIR__ . "/service/AffinityAjaxService.php");
$ajaxService = new AffinityAjaxService();
$ajaxService->init();
require_once(__DIR__ . "/ecommerce-adapters/AffinityEcommerceHooks.php");
$ecommerceHooks = new AffinityEcommerceHooks();
$ecommerceHooks->initHooks();
require_once(__DIR__ . "/ecommerce-adapters/AffinityCrontab.php");
$affinityCrontab = new AffinityCrontab();
$affinityCrontab->createCrontabHooks();
register_activation_hook(__FILE__, array($this, 'pluginWasActivated'));
register_deactivation_hook(__FILE__, array($this, 'pluginWasDeactivated'));
add_action('upgrader_process_complete', array($this, 'pluginWasUpdated'));
}
}
new eBaySync();
}
}