PluginProbe
HubSpot All-In-One Marketing – Forms, Popups, Live Chat / 11.3.65
HubSpot All-In-One Marketing – Forms, Popups, Live Chat v11.3.65
11.3.75 11.3.73 11.3.71 11.3.70 11.3.69 11.3.64 11.3.65 11.3.62 11.3.61 11.3.56 11.3.58 11.0.31 11.0.52 11.0.54 11.0.56 11.0.58 11.0.7 11.1.10 11.1.11 11.1.13 11.1.14 11.1.15 11.1.2 11.1.20 11.1.21 All 73 releases
leadin / public / data / class-portal-options.php

class-portal-options.php in HubSpot All-In-One Marketing – Forms, Popups, Live Chat 11.3.65, at public/data/class-portal-options.php

286 lines 7.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Leadin\data;
4
5 /**
6 * Class that wraps the functions to access options related to the HubSpot account.
7 */
8 class Portal_Options {
9 const PORTAL_ID = LEADIN_PREFIX . '_portalId';
10 const PORTAL_DOMAIN = LEADIN_PREFIX . '_portal_domain';
11 const ACCOUNT_NAME = LEADIN_PREFIX . '_account_name';
12 const HUBLET = LEADIN_PREFIX . '_hublet';
13 const DISABLE_INTERNAL_TRACKING = LEADIN_PREFIX . '_disable_internal_tracking';
14 const ACTIVATION_TIME = LEADIN_PREFIX . '_activation_time';
15 const REFRESH_TOKEN = LEADIN_PREFIX . '_refresh_token';
16 const BUSINESS_UNIT_ID = LEADIN_PREFIX . '_business_unit_id';
17 const LAST_AUTHORIZE_TIME = LEADIN_PREFIX . '_last_authorize_time';
18 const LAST_DEAUTHORIZE_TIME = LEADIN_PREFIX . '_last_deauthorize_time';
19 const LAST_DISCONNECT_TIME = LEADIN_PREFIX . '_last_disconnect_time';
20 const PROXY_MAPPING_ENABLED = LEADIN_PREFIX . '_proxy_mappings_enabled';
21 const DEFAULT_OPTION_PROXY_MAPPINGS_ENABLED = false;
22
23 /**
24 * Return portal id.
25 */
26 public static function get_portal_id() {
27 return get_option( self::PORTAL_ID );
28 }
29
30 /**
31 * Set portal id.
32 *
33 * @param Number $portal_id HubSpot portal id.
34 */
35 public static function set_portal_id( $portal_id ) {
36 return update_option( self::PORTAL_ID, $portal_id );
37 }
38
39 /**
40 * Delete portal id.
41 */
42 public static function delete_portal_id() {
43 return delete_option( self::PORTAL_ID );
44 }
45
46 /**
47 * Return portal's domain.
48 */
49 public static function get_portal_domain() {
50 return get_option( self::PORTAL_DOMAIN );
51 }
52
53 /**
54 * Set portal domain.
55 *
56 * @param string $domain domain.
57 */
58 public static function set_portal_domain( $domain ) {
59 return update_option( self::PORTAL_DOMAIN, $domain );
60 }
61
62 /**
63 * Delete portal domain.
64 */
65 public static function delete_portal_domain() {
66 return delete_option( self::PORTAL_DOMAIN );
67 }
68
69 /**
70 * Return account name.
71 */
72 public static function get_account_name() {
73 return get_option( self::ACCOUNT_NAME );
74 }
75
76 /**
77 * Set account name.
78 *
79 * @param string $name name.
80 */
81 public static function set_account_name( $name ) {
82 return update_option( self::ACCOUNT_NAME, $name );
83 }
84
85 /**
86 * Delete account name.
87 */
88 public static function delete_account_name() {
89 return delete_option( self::ACCOUNT_NAME );
90 }
91
92 /**
93 * Return option containing hublet info.
94 */
95 public static function get_hublet() {
96 return get_option( self::HUBLET );
97 }
98
99 /**
100 * Return option containing hublet info.
101 *
102 * @param string $hublet hublet.
103 */
104 public static function set_hublet( $hublet ) {
105 return update_option( self::HUBLET, $hublet );
106 }
107
108 /**
109 * Delete hublet
110 */
111 public static function delete_hublet() {
112 return delete_option( self::HUBLET );
113 }
114
115 /**
116 * Return option flag for disabling internal users to appear at HS analytics.
117 */
118 public static function get_disable_internal_tracking() {
119 return get_option( self::DISABLE_INTERNAL_TRACKING );
120 }
121
122 /**
123 * Set option containing flag for disabling internal users to appear at HS analytics.
124 *
125 * @param string $internal_tracking hublet.
126 */
127 public static function set_disable_internal_tracking( $internal_tracking = '0' ) {
128 return update_option( self::DISABLE_INTERNAL_TRACKING, $internal_tracking );
129 }
130
131 /**
132 * Delete option flag for disabling internal tracking
133 */
134 public static function delete_disable_internal_tracking() {
135 return delete_option( self::DISABLE_INTERNAL_TRACKING );
136 }
137
138 /**
139 * Return activation time.
140 */
141 public static function get_activation_time() {
142 return get_option( self::ACTIVATION_TIME );
143 }
144
145 /**
146 * Set activation time.
147 */
148 public static function set_activation_time() {
149 return update_option( self::ACTIVATION_TIME, time() );
150 }
151
152 /**
153 * Delete portal id.
154 */
155 public static function delete_activation_time() {
156 return delete_option( self::ACTIVATION_TIME );
157 }
158
159 /**
160 * Return refresh access token.
161 */
162 public static function get_refresh_token() {
163 return get_option( self::REFRESH_TOKEN );
164 }
165
166 /**
167 * Set refresh access token.
168 *
169 * @param string $refresh_token token.
170 */
171 public static function set_refresh_token( $refresh_token ) {
172 return update_option( self::REFRESH_TOKEN, $refresh_token );
173 }
174
175 /**
176 * Delete refresh access token.
177 */
178 public static function delete_refresh_token() {
179 return delete_option( self::REFRESH_TOKEN );
180 }
181
182 /**
183 * Return device id hash.
184 */
185 public static function get_device_id() {
186 $site_url = get_home_url();
187 $user_id = get_current_user_id();
188 return hash( 'sha256', "$site_url:$user_id" );
189 }
190
191 /**
192 * Return business_unit_id for connected portal.
193 */
194 public static function get_business_unit_id() {
195 return get_option( self::BUSINESS_UNIT_ID );
196 }
197
198 /**
199 * Set business_unit_id for the connected portal.
200 *
201 * @param number $business_unit_id businessUnitId.
202 */
203 public static function set_business_unit_id( $business_unit_id ) {
204 return update_option( self::BUSINESS_UNIT_ID, $business_unit_id );
205 }
206
207 /**
208 * Delete business_unit_id.
209 */
210 public static function delete_business_unit_id() {
211 return delete_option( self::BUSINESS_UNIT_ID );
212 }
213
214 /**
215 * Set when last authorized.
216 */
217 public static function set_last_authorize_time() {
218 return update_option( self::LAST_AUTHORIZE_TIME, time() );
219 }
220 /**
221 * Set when last deauthorized.
222 */
223 public static function set_last_deauthorize_time() {
224 return update_option( self::LAST_DEAUTHORIZE_TIME, time() );
225 }
226
227 /**
228 * Set when last disconnect.
229 */
230 public static function set_last_disconnect_time() {
231 return update_option( self::LAST_DISCONNECT_TIME, time() );
232 }
233
234 /**
235 * Get the last time authorization was performed.
236 *
237 * @return mixed The last authorization time, or false if not set.
238 */
239 public static function get_last_authorize_time() {
240 return get_option( self::LAST_AUTHORIZE_TIME, false );
241 }
242
243 /**
244 * Get the last time deauthorization was performed.
245 *
246 * @return mixed The last deauthorization time, or false if not set.
247 */
248 public static function get_last_deauthorize_time() {
249 return get_option( self::LAST_DEAUTHORIZE_TIME, false );
250 }
251
252 /**
253 * Get the last time a disconnect was performed.
254 *
255 * @return mixed The last disconnect time, or false if not set.
256 */
257 public static function get_last_disconnect_time() {
258 return get_option( self::LAST_DISCONNECT_TIME, false );
259 }
260
261 /**
262 * Return option flag to enable/disable proxy mapping.
263 *
264 * @return bool Proxy mapping enabled flag.
265 */
266 public static function get_proxy_mappings_enabled() {
267 return (bool) get_option( self::PROXY_MAPPING_ENABLED, self::DEFAULT_OPTION_PROXY_MAPPINGS_ENABLED );
268 }
269
270 /**
271 * Set option flag to enable/disable proxy mapping.
272 *
273 * @param bool $enabled hublet.
274 */
275 public static function set_proxy_mappings_enabled( $enabled = false ) {
276 return update_option( self::PROXY_MAPPING_ENABLED, $enabled );
277 }
278
279 /**
280 * Delete option flag to enable/disable proxy mapping.
281 */
282 public static function delete_proxy_mappings_enabled() {
283 return delete_option( self::PROXY_MAPPING_ENABLED );
284 }
285 }
286