This repository was archived by the owner on Jan 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwoocommerce-sift-science.php
More file actions
71 lines (60 loc) · 1.92 KB
/
woocommerce-sift-science.php
File metadata and controls
71 lines (60 loc) · 1.92 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
<?php
/*
* Plugin Name: WooCommerce Sift Science
* Plugin URI: https://github.com/bitpiston/woocommerce-sift-science
* Description: Sift Science anti-fraud / chargeback prevention plugin for WooCommerce.
* Version: 0.1.0
* Author: BitPiston Studios
* Author URI: http://bitpiston.com/
*/
if ( ! defined('ABSPATH') ) exit;
/**
* WC_Sift_Science class
*/
class WC_Sift_Science
{
/**
* @var WC_Sift_Science Single instance of this class
*/
protected static $instance;
/**
* Bootstraps the class and hooks required actions & filters.
*
* @return void
*/
public function __construct() {
$active_plugins = apply_filters( 'active_plugins', get_option('active_plugins') );
if ( in_array('woocommerce/woocommerce.php', $active_plugins) && class_exists('WC_Integration') ) {
// Our classes and depdencies if not using composer
if ( ! class_exists('WC_Sift_Science_Integration') && is_file( dirname(__FILE__) . '/vendor/autoload.php' ) ) {
require_once('vendor/autoload.php');
}
// Register the integration
add_filter('woocommerce_integrations', [$this, 'add_integration']);
}
}
/**
* Main plugin instance, ensures only one instance is/can be loaded.
*
* @return WC_Sift_Science
*/
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 $integrations WooCommerce integrations
*/
public function add_integration($integrations)
{
$integrations[] = 'WC_Sift_Science_Integration';
return $integrations;
}
}
add_action('plugins_loaded', ['WC_Sift_Science', 'get_instance'], 0);