PluginProbe ʕ •ᴥ•ʔ
OttoKit: All-in-One Automation Platform / 1.1.36
OttoKit: All-in-One Automation Platform v1.1.36
1.1.37 1.1.36 1.1.35 1.1.34 1.1.33 1.1.32 1.1.31 1.1.30 1.1.29 1.1.28 1.1.27 1.1.9 trunk 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.19 1.0.20 1.0.21 1.0.22 1.0.23 1.0.24 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 1.0.39 1.0.40 1.0.41 1.0.42 1.0.43 1.0.44 1.0.45 1.0.46 1.0.47 1.0.48 1.0.49 1.0.50 1.0.51 1.0.52 1.0.53 1.0.54 1.0.55 1.0.56 1.0.57 1.0.58 1.0.59 1.0.60 1.0.61 1.0.62 1.0.63 1.0.64 1.0.65 1.0.66 1.0.67 1.0.68 1.0.69 1.0.7 1.0.70 1.0.71 1.0.72 1.0.73 1.0.74 1.0.75 1.0.76 1.0.77 1.0.78 1.0.79 1.0.8 1.0.80 1.0.81 1.0.82 1.0.83 1.0.84 1.0.85 1.0.86 1.0.87 1.0.88 1.0.89 1.0.9 1.0.90 1.1.0 1.1.1 1.1.10 1.1.11 1.1.12 1.1.13 1.1.14 1.1.15 1.1.16 1.1.17 1.1.18 1.1.19 1.1.2 1.1.20 1.1.21 1.1.22 1.1.23 1.1.24 1.1.25 1.1.26 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8
suretriggers / src / Integrations / funnel-kit-automations / funnel-kit-automations.php
suretriggers / src / Integrations / funnel-kit-automations Last commit date
actions 11 months ago triggers 3 years ago funnel-kit-automations.php 3 years ago
funnel-kit-automations.php
147 lines
1 <?php
2 /**
3 * FunnelKitAutomations core integrations file
4 *
5 * @since 1.0.0
6 * @package SureTrigger
7 */
8
9 namespace SureTriggers\Integrations\FunnelKitAutomations;
10
11 use BWFCRM_Contact;
12 use BWFCRM_Fields;
13 use BWFCRM_Lists;
14 use BWFCRM_Tag;
15 use SureTriggers\Controllers\IntegrationsController;
16 use SureTriggers\Integrations\Integrations;
17 use SureTriggers\Traits\SingletonLoader;
18
19 /**
20 * Class SureTrigger
21 *
22 * @package SureTriggers\Integrations\FunnelKitAutomations
23 */
24 class FunnelKitAutomations extends Integrations {
25
26 use SingletonLoader;
27
28 /**
29 * ID
30 *
31 * @var string
32 */
33 protected $id = 'FunnelKitAutomations';
34
35 /**
36 * SureTrigger constructor.
37 */
38 public function __construct() {
39 $this->name = __( 'FunnelKitAutomations', 'suretriggers' );
40 $this->description = __( 'FunnelKit Automations is a WordPress Customer Support plugin.', 'suretriggers' );
41 $this->icon_url = SURE_TRIGGERS_URL . 'assets/icons/jetpackcrm.svg';
42
43 parent::__construct();
44 }
45
46 /**
47 * Get List context data.
48 *
49 * @param int|string $list_id List ID.
50 * @return array
51 */
52 public static function get_list_context( $list_id ) {
53 if ( ! class_exists( 'BWFCRM_Lists' ) ) {
54 return [];
55 }
56
57 $lists = BWFCRM_Lists::get_lists( [ $list_id ] );
58 if ( count( $lists ) === 0 ) {
59 return [];
60 }
61 return [
62 'list_id' => $lists[0]['ID'],
63 'list_name' => $lists[0]['name'],
64 ];
65 }
66
67 /**
68 * Get Tag context data.
69 *
70 * @param int|string $tag_id Tag ID.
71 * @return array
72 */
73 public static function get_tag_context( $tag_id ) {
74 if ( ! class_exists( 'BWFCRM_Tag' ) ) {
75 return [];
76 }
77
78 $tags = BWFCRM_Tag::get_tags( [ $tag_id ] );
79 if ( count( $tags ) === 0 ) {
80 return [];
81 }
82 return [
83 'tag_id' => $tags[0]['ID'],
84 'tag_name' => $tags[0]['name'],
85 ];
86 }
87
88 /**
89 * Retrieve contact details from the given contact object.
90 *
91 * @access public
92 * @since 1.0
93 * @param Object $contact Autonami contact object.
94 * @return array
95 */
96 public static function get_contact_context( $contact ) {
97 $tags = $contact->get_tags(); // @phpstan-ignore-line
98 $lists = $contact->get_lists(); // @phpstan-ignore-line
99
100 $contact_tags = [];
101 if ( is_array( $tags ) ) {
102 foreach ( $tags as $key => $tag ) {
103 $contact_tags[ $key ] = self::get_tag_context( $tag );
104 }
105 }
106
107 $contact_lists = [];
108 if ( is_array( $lists ) ) {
109 foreach ( $lists as $key => $list ) {
110 $contact_lists[ $key ] = self::get_list_context( $list );
111 }
112 }
113
114 return [
115 'contact_id' => $contact->get_id(), // @phpstan-ignore-line
116 'wpid' => $contact->get_wpid(), // @phpstan-ignore-line
117 'uid' => $contact->get_uid(), // @phpstan-ignore-line
118 'email' => $contact->get_email(), // @phpstan-ignore-line
119 'first_name' => $contact->get_f_name(), // @phpstan-ignore-line
120 'last_name' => $contact->get_l_name(), // @phpstan-ignore-line
121 'contact_no' => $contact->contact_no(), // @phpstan-ignore-line
122 'state' => $contact->get_state(), // @phpstan-ignore-line
123 'country' => $contact->get_country(), // @phpstan-ignore-line
124 'timezone' => $contact->get_timezone(), // @phpstan-ignore-line
125 'creation_date' => ! empty( $contact->get_creation_date() ) ? $contact->get_creation_date() : '', // @phpstan-ignore-line
126 'last_modified' => ! empty( $contact->get_last_modified() ) ? $contact->get_last_modified() : '', // @phpstan-ignore-line
127 'source' => $contact->get_source(), // @phpstan-ignore-line
128 'type' => $contact->get_type(), // @phpstan-ignore-line
129 'status' => $contact->get_status(), // @phpstan-ignore-line
130 'tags' => $contact_tags,
131 'lists' => $contact_lists,
132 ];
133 }
134
135 /**
136 * Is Plugin depended on plugin is installed or not.
137 *
138 * @return bool
139 */
140 public function is_plugin_installed() {
141 return class_exists( 'BWFCRM_Contact' );
142 }
143
144 }
145
146 IntegrationsController::register( FunnelKitAutomations::class );
147