-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwc-hub.php
111 lines (99 loc) · 2.49 KB
/
wc-hub.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
<?php
/**
* Main plugin file.
*
* @package WCHub
* @author Kerkness
* @license GNU
*
* @wordpress-plugin
* Plugin Name: Integrator For HubSpot
* Plugin URI: https://kerkness.ca/wc-hub
* Description: Automatically creates and updates HubSpot records from Woocommerce or WordPress events
* Version: 1.1.1
* Requires at least: 5.4
* Tested up to: 6.0.2
* Requires PHP: 7.2
* Author: Kerkness
* Author URI: https://kerkness.ca
* Text Domain: wc-hub
* Domain Path: /languages
* License: GPL2+
* License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
// Exit if accessed directly.
defined('ABSPATH') || exit;
// Include autoloader if plugin isn't running as a dependency
if (!class_exists('WCHub\WCHub')) {
require_once( __DIR__ . '/lib/autoload.php');
}
/**
* Debug methods for dev.
*/
if(!function_exists('moi_debug')) {
function moi_debug($log) {
if (WP_DEBUG === true) {
if (is_array($log) || is_object($log)) {
error_log(print_r($log, true));
} else {
error_log($log);
}
}
}
}
if(!function_exists('moi_dump')) {
function moi_dump($args) {
if(WP_DEBUG_DISPLAY) {
if (is_array($args) || is_object($args)) {
return '<pre>' . print_r($args, true) . '</pre>';
} else {
return '<pre>' . $args . '</pre>';
}
}
}
}
/**
* Get plugin base name
*/
if(!function_exists('wc_hub_integrator_plugin_basename')) {
function wc_hub_integrator_plugin_basename() {
return plugin_basename( __FILE__ );
}
}
/**
* Initalize the plugin
*/
\WCHub\WCHub::init();
/**
* Create or update a HubSpot contact from WP_User object
*/
if(!function_exists('wc_hub_create_or_update_hubspot_contact')) {
function wc_hub_create_or_update_hubspot_contact ( WP_User $user ) {
\WCHub\WCHub::createOrUpdateHubspot( $user );
}
}
/**
* Update specific values for a hubspot contact
*/
if(!function_exists('wc_hub_update_hubspot_contact')){
function wc_hub_update_hubspot_contact( $email, $properties = []) {
return \WCHub\WCHub::updateHubSpotContact($email, $properties);
}
}
/**
* Get the current user's hubspot profile
*/
if(!function_exists('wc_hub_get_current_contact')){
function wc_hub_get_current_contact() {
return wc_hub_get_hubspot_contact(wp_get_current_user());
}
}
/**
* Get a specific user's hubspot profile
* Applies filter wc_hub_hubspot_get_contact_parameters
*/
if(!function_exists('wc_hub_get_hubspot_contact')){
function wc_hub_get_hubspot_contact( WP_User $user ) {
return \WCHub\WCHub::getHubSpotContact($user);
}
}