-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwoocommerce-affiliate-tracking.php
69 lines (60 loc) · 1.69 KB
/
woocommerce-affiliate-tracking.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
<?php
/*
* Plugin Name: WooCommerce Affiliate Tracking
* Plugin URI: https://github.com/Strikewood/woocommerce-affiliate-tracking
* Description: Affiliate tracking extension for WooCommerce.
* Version: 0.2.1
* Author: Strikewood Studios
* Author URI: http://strikewood.com/
*/
if ( !defined('ABSPATH') ) exit;
/**
* WC_Affiliate_Tracking class
*/
class WC_Affiliate_Tracking
{
/**
* @var WC_Affiliate_Tracking Single instance of this class
*/
protected static $instance;
/**
* Bootstraps the class and hooks required actions & filters.
*
* @return void
*/
public function __construct()
{
if ( class_exists('WC_Integration') && defined('WOOCOMMERCE_VERSION') )
{
require_once('includes/class-wc-affiliate-tracking-integration.php');
// Register the integration
add_filter('woocommerce_integrations', [$this, 'add_integration']);
}
}
/**
* Main WC_Affiliate_Tracking instance, ensures only one instance is/can be loaded.
*
* @return WC_Affiliate_Tracking
*/
public static function get_instance()
{
if ( is_null(self::$instance) )
{
self::$instance = new self;
}
return self::$instance;
}
/**
* Add a new integration to WooCommerce.
*
* @param array $integrations WooCommerce integrations
*
* @return array WC_Facebook_Remarketing_Integration
*/
public function add_integration($integrations)
{
$integrations[] = 'WC_Affiliate_Tracking_Integration';
return $integrations;
}
}
add_action('plugins_loaded', ['WC_Affiliate_Tracking', 'get_instance'], 0);