PluginProbe
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.10.1
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.10.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 / wp-mautic / wp-mautic.php

wp-mautic.php in Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode 3.10.1, at addons/controller/addons/wp-mautic/wp-mautic.php

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