-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.php
69 lines (57 loc) · 2.01 KB
/
init.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: Threekit for WooCommerce
* Plugin URI: https://github.com/lanigela/ThreekitForWoocommerce
* Description: Your extension's description text.
* Version: 1.0.0
* Author: Daniel Zhou
* Author URI: daniel@exocortex.com
* Developer: Exocortex
* Developer URI: http://exocortex.com/
* Text Domain: Threekit-for-WooCommerce
*
* Copyright: © 2017 Exocortex
* License: MIT License
* License URI: https://opensource.org/licenses/MIT
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
/**
* Check if WooCommerce is active
**/
$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
if ( in_array( 'woocommerce/woocommerce.php', $active_plugins) ) {
// Put your plugin code here
$using_addons = false;
foreach ( $active_plugins as $key => $active_plugin ) {
if ( strstr( $active_plugin, 'woocommerce-product-addons.php' ) ) {
$using_addons = true;
}
}
define('THREEKIT_FOR_WOOCOMMERCE_DIR', rtrim(plugin_dir_path(__FILE__),'/'));
if ($using_addons) {
// using addons for configuration
add_action('init', 'threekit_addons_for_woocommerce_init');
}
else {
// using default variation for configuration
add_action('init', 'threekit_for_woocommerce_init');
}
}
if (!function_exists('threekit_for_woocommerce_init')) {
function threekit_for_woocommerce_init() {
require_once THREEKIT_FOR_WOOCOMMERCE_DIR . '/class-ThreeKit.php';
$api = new ThreeKit();
add_action('woocommerce_before_single_product', array($api, 'enable_threekit_by_checking_clarauuid_attribute'));
}
}
if (!function_exists('threekit_addons_for_woocommerce_init')) {
function threekit_addons_for_woocommerce_init() {
require_once THREEKIT_FOR_WOOCOMMERCE_DIR . '/class-ThreeKit-addons.php';
$api = new ThreeKitAddons();
// using a low priority number to make sure running after woocommerce-addons
add_action('woocommerce_before_single_product', array($api, 'enable_threekit_by_checking_clarauuid_attribute'), 100);
}
}
?>