PluginProbe
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.11.1
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.11.1
4.7.4 4.7.5 4.7.3 4.7.2 4.7.1 trunk 2.3.0 2.4.0 2.4.1 2.4.2 2.5.0 3.0.0 3.0.1 3.1.0 3.10.0 3.10.1 3.11.1 3.11.2 3.11.3 3.2.0 3.3.0 3.3.1 3.4.0 3.4.1 3.4.2 All 95 releases
cookiebot / addons / controller / addons / hubspot-leadin / hubspot-leadin.php

hubspot-leadin.php in Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode 3.11.1, at addons/controller/addons/hubspot-leadin/hubspot-leadin.php

337 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace cookiebot_addons\controller\addons\hubspot_leadin;
4
5 use cookiebot_addons\controller\addons\Cookiebot_Addons_Interface;
6 use cookiebot_addons\lib\script_loader_tag\Script_Loader_Tag_Interface;
7 use cookiebot_addons\lib\Cookie_Consent_Interface;
8 use cookiebot_addons\lib\buffer\Buffer_Output_Interface;
9 use cookiebot_addons\lib\Settings_Service_Interface;
10
11 class Hubspot_Leadin implements Cookiebot_Addons_Interface {
12
13 /**
14 * @var Settings_Service_Interface
15 *
16 * @since 1.3.0
17 */
18 protected $settings;
19
20 /**
21 * @var Script_Loader_Tag_Interface
22 *
23 * @since 1.3.0
24 */
25 protected $script_loader_tag;
26
27 /**
28 * @var Cookie_Consent_Interface
29 *
30 * @since 1.3.0
31 */
32 public $cookie_consent;
33
34 /**
35 * @var Buffer_Output_Interface
36 *
37 * @since 1.3.0
38 */
39 protected $buffer_output;
40
41 /**
42 * Jetpack constructor.
43 *
44 * @param $settings Settings_Service_Interface
45 * @param $script_loader_tag Script_Loader_Tag_Interface
46 * @param $cookie_consent Cookie_Consent_Interface
47 * @param $buffer_output Buffer_Output_Interface
48 *
49 * @since 1.3.0
50 */
51 public function __construct( Settings_Service_Interface $settings, Script_Loader_Tag_Interface $script_loader_tag, Cookie_Consent_Interface $cookie_consent, Buffer_Output_Interface $buffer_output ) {
52 $this->settings = $settings;
53 $this->script_loader_tag = $script_loader_tag;
54 $this->cookie_consent = $cookie_consent;
55 $this->buffer_output = $buffer_output;
56 }
57
58 /**
59 * Loads addon configuration
60 *
61 * @since 1.3.0
62 */
63 public function load_configuration() {
64 /**
65 * We add the action after wp_loaded and replace the original
66 * HubSpot Tracking Code action with our own adjusted version.
67 */
68 add_action( 'wp_loaded', array( $this, 'cookiebot_addon_hubspot_tracking_code' ), 10 );
69 }
70
71 /**
72 * Manipulate the scripts if they are loaded.
73 *
74 * @since 1.3.0
75 */
76 public function cookiebot_addon_hubspot_tracking_code() {
77
78 // block the script untill the consent is given
79
80 if(version_compare(LEADIN_PLUGIN_VERSION,'7.10.0','>=')) {
81 $this->script_loader_tag->add_tag( 'leadin-script-loader-js', $this->get_cookie_types() );
82 }
83 else {
84 $this->script_loader_tag->add_tag( 'leadin-scriptloader-js', $this->get_cookie_types() );
85 }
86 }
87
88 /**
89 * Return addon/plugin name
90 *
91 * @return string
92 *
93 * @since 1.3.0
94 */
95 public function get_addon_name() {
96 return 'HubSpot - Free Marketing Plugin for WordPress';
97 }
98
99 /**
100 * Option name in the database
101 *
102 * @return string
103 *
104 * @since 1.3.0
105 */
106 public function get_option_name() {
107 return 'hubspot_leadin';
108 }
109
110 /**
111 * Plugin file name
112 *
113 * @return string
114 *
115 * @since 1.3.0
116 */
117 public function get_plugin_file() {
118 return 'leadin/leadin.php';
119 }
120
121 /**
122 * Returns checked cookie types
123 * @return mixed
124 *
125 * @since 1.3.0
126 */
127 public function get_cookie_types() {
128 return $this->settings->get_cookie_types( $this->get_option_name() );
129 }
130
131 /**
132 * Returns default cookie types
133 * @return array
134 *
135 * @since 1.5.0
136 */
137 public function get_default_cookie_types() {
138 return array( 'marketing', 'statistics' );
139 }
140
141
142 /**
143 * Check if plugin is activated and checked in the backend
144 *
145 * @since 1.3.0
146 */
147 public function is_addon_enabled() {
148 return $this->settings->is_addon_enabled( $this->get_option_name() );
149 }
150
151 /**
152 * Checks if addon is installed
153 *
154 * @since 1.3.0
155 */
156 public function is_addon_installed() {
157 return $this->settings->is_addon_installed( $this->get_plugin_file() );
158 }
159
160 /**
161 * Checks if addon is activated
162 *
163 * @since 1.3.0
164 */
165 public function is_addon_activated() {
166 return $this->settings->is_addon_activated( $this->get_plugin_file() );
167 }
168
169 /**
170 * Retrieves current installed version of the addon
171 *
172 * @return bool
173 *
174 * @since 2.2.1
175 */
176 public function get_addon_version() {
177 return $this->settings->get_addon_version( $this->get_plugin_file() );
178 }
179
180 /**
181 * Default placeholder content
182 *
183 * @return string
184 *
185 * @since 1.8.0
186 */
187 public function get_default_placeholder() {
188 return 'Please accept [renew_consent]%cookie_types[/renew_consent] cookies to watch this video.';
189 }
190
191 /**
192 * Get placeholder content
193 *
194 * This function will check following features:
195 * - Current language
196 *
197 * @param $src
198 *
199 * @return bool|mixed
200 *
201 * @since 1.8.0
202 */
203 public function get_placeholder( $src = '' ) {
204 return $this->settings->get_placeholder( $this->get_option_name(), $this->get_default_placeholder(), cookiebot_addons_output_cookie_types( $this->get_cookie_types() ), $src );
205 }
206
207 /**
208 * Checks if it does have custom placeholder content
209 *
210 * @return mixed
211 *
212 * @since 1.8.0
213 */
214 public function has_placeholder() {
215 return $this->settings->has_placeholder( $this->get_option_name() );
216 }
217
218 /**
219 * returns all placeholder contents
220 *
221 * @return mixed
222 *
223 * @since 1.8.0
224 */
225 public function get_placeholders() {
226 return $this->settings->get_placeholders( $this->get_option_name() );
227 }
228
229 /**
230 * Return true if the placeholder is enabled
231 *
232 * @return mixed
233 *
234 * @since 1.8.0
235 */
236 public function is_placeholder_enabled() {
237 return $this->settings->is_placeholder_enabled( $this->get_option_name() );
238 }
239
240 /**
241 * Adds extra information under the label
242 *
243 * @return string
244 *
245 * @since 1.8.0
246 */
247 public function get_extra_information() {
248 return false;
249 }
250
251 /**
252 * Returns the url of WordPress SVN repository or another link where we can verify the plugin file.
253 *
254 * @return boolean
255 *
256 * @since 1.8.0
257 */
258 public function get_svn_url() {
259 return 'http://plugins.svn.wordpress.org/leadin/trunk/leadin.php';
260 }
261
262 /**
263 * Placeholder helper overlay in the settings page.
264 *
265 * @return string
266 *
267 * @since 1.8.0
268 */
269 public function get_placeholder_helper() {
270 return '<p>Merge tags you can use in the placeholder text:</p><ul><li>%cookie_types - Lists required cookie types</li><li>[renew_consent]text[/renew_consent] - link to display cookie settings in frontend</li></ul>';
271 }
272
273 /**
274 * Returns parent class or false
275 *
276 * @return string|bool
277 *
278 * @since 2.1.3
279 */
280 public function get_parent_class() {
281 return get_parent_class( $this );
282 }
283
284 /**
285 * Action after enabling the addon on the settings page
286 *
287 * @since 2.2.0
288 */
289 public function post_hook_after_enabling() {
290 //do nothing
291 }
292
293 /**
294 * Cookiebot plugin is deactivated
295 *
296 * @since 2.2.0
297 */
298 public function plugin_deactivated() {
299 //do nothing
300 }
301
302 /**
303 * @return mixed
304 *
305 * @since 2.4.5
306 */
307 public function extra_available_addon_option() {
308 //do nothing
309 }
310
311 /**
312 * Returns boolean to enable/disable plugin by default
313 *
314 * @return bool
315 *
316 * @since 3.6.3
317 */
318 public function enable_by_default() {
319 return false;
320 }
321
322 /**
323 * Sets default settings for this addon
324 *
325 * @return array
326 *
327 * @since 3.6.3
328 */
329 public function get_default_enable_setting() {
330 return array(
331 'enabled' => 1,
332 'cookie_type' => $this->get_default_cookie_types(),
333 'placeholder' => $this->get_default_placeholder(),
334 );
335 }
336 }
337