PluginProbe
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode / 3.11.2
Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode v3.11.2
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 3.5.0 3.6.0 All 93 releases
cookiebot / addons / controller / addons / addthis / addthis.php

addthis.php in Cookiebot by Usercentrics – Automatic Cookie Banner for GDPR/CCPA & Google Consent Mode 3.11.2, at addons/controller/addons/addthis/addthis.php

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