PluginProbe ʕ •ᴥ•ʔ
GDPR Cookie Compliance – Cookie Banner, Cookie Consent, Cookie Notice for CCPA, EU Cookie Law / 4.4.8
GDPR Cookie Compliance – Cookie Banner, Cookie Consent, Cookie Notice for CCPA, EU Cookie Law v4.4.8
5.0.14 5.0.13 1.1.3 1.1.4 1.1.5 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.2.1 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.4.0 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.2.0 3.2.1 4.0.0 4.0.1 4.0.2 4.0.3 4.1.0 4.1.1 4.1.2 4.1.3 4.1.4 4.1.5 4.1.6 4.1.7 4.1.8 4.1.9 4.10.0 4.10.1 4.10.2 4.10.3 4.10.4 4.10.5 4.10.6 4.11.0 4.11.1 4.11.2 4.12.0 4.12.1 4.12.2 4.12.3 4.12.4 4.12.5 4.12.6 4.12.7 4.12.8 4.13.0 4.13.1 4.13.2 4.13.3 4.13.4 4.14.0 4.15.0 4.15.1 4.15.10 4.15.2 4.15.3 4.15.4 4.15.5 4.15.6 4.15.7 4.15.8 4.15.9 4.16.1 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.2.7 4.2.8 4.2.9 4.3.0 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.3.7 4.3.8 4.3.9 4.4.0 4.4.1 4.4.2 4.4.3 4.4.4 4.4.5 4.4.6 4.4.7 4.4.8 4.5.0 4.5.1 4.5.10 4.5.11 4.5.12 4.5.13 4.5.2 4.5.3 4.5.4 4.5.5 4.5.6 4.5.7 4.5.8 4.5.9 4.6.0 4.6.1 4.6.2 4.6.3 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.7.5 4.7.6 4.7.7 4.8.0 4.8.1 4.8.10 4.8.11 4.8.12 4.8.13 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.8.9 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 5.0.0 5.0.1 5.0.10 5.0.11 5.0.12 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.0.9 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 1.1.0 1.1.1 1.1.2
gdpr-cookie-compliance / gdpr-functions.php
gdpr-cookie-compliance Last commit date
controllers 5 years ago dist 5 years ago gdpr-modules 5 years ago languages 5 years ago views 5 years ago class-gdpr-modules-view.php 5 years ago class-gdpr-modules.php 5 years ago class-gdpr-view.php 5 years ago class-moove-gdpr-actions.php 5 years ago class-moove-gdpr-content.php 5 years ago class-moove-gdpr-options.php 5 years ago gdpr-functions.php 5 years ago moove-gdpr.php 5 years ago readme.txt 5 years ago
gdpr-functions.php
507 lines
1 <?php
2 /**
3 * Moove_Functions File Doc Comment
4 *
5 * @category Moove_Functions
6 * @package gdpr-cookie-compliance
7 * @author Gaspar Nemes
8 */
9
10 if ( ! defined( 'ABSPATH' ) ) {
11 exit;
12 } // Exit if accessed directly
13
14 if ( ! function_exists( 'moove_gdpr_get_plugin_directory_url' ) ) :
15 /**
16 * Relative path of the GDPR cookie plugin
17 */
18 function moove_gdpr_get_plugin_directory_url() {
19 return plugin_dir_url( __FILE__ );
20 }
21 endif;
22
23 if ( ! function_exists( 'gdpr_get_site_id' ) ) :
24 /**
25 * Returns the current blog id as site_id
26 */
27 function gdpr_get_site_id() {
28 return function_exists( 'get_current_blog_id' ) ? get_current_blog_id() : 1;
29 }
30 endif;
31
32
33 if ( ! function_exists( 'gdpr_get_field' ) ) :
34 /**
35 * Get simple value from gdpr database by option_key
36 */
37 function gdpr_get_field( $option_key = false, $site_id = false ) {
38 $results = false;
39 if ( $option_key ) :
40 $site_id = $site_id && intval( $site_id ) ? $site_id : gdpr_get_site_id();
41 $database_controller = new Moove_GDPR_DB_Controller();
42 $results = $database_controller->get( $option_key, $site_id );
43 $results = $results && isset( $results->option_value ) ? maybe_unserialize( $results->option_value ) : false;
44 endif;
45 return $results;
46 }
47
48 endif;
49
50 if ( ! function_exists( 'gdpr_get_options' ) ) :
51 /**
52 * Get simple value from gdpr database by option_key
53 */
54 function gdpr_get_options( $site_id = false ) {
55 $site_id = $site_id && intval( $site_id ) ? $site_id : gdpr_get_site_id();
56 $database_controller = new Moove_GDPR_DB_Controller();
57 $results = $database_controller->get_options( $site_id );
58 $results_filtered = array();
59 if ( is_array( $results ) && ! empty( $results ) ) :
60 foreach ( $results as $key => $value ) :
61 $results_filtered[$key] = maybe_unserialize( $value->option_value );
62 endforeach;
63 endif;
64 $results_filtered = $results_filtered && ! empty( $results_filtered ) ? $results_filtered : false;
65 return $results_filtered;
66 }
67
68 endif;
69
70 if ( ! function_exists( 'gdpr_update_field' ) ) :
71 /**
72 * Get simple value from gdpr database by option_key
73 */
74 function gdpr_update_field( $option_key = false, $option_value = false, $site_id = false ) {
75 $results = false;
76 if ( $option_key ) :
77 $site_id = $site_id && intval( $site_id ) ? $site_id : gdpr_get_site_id();
78 $database_controller = new Moove_GDPR_DB_Controller();
79 $results = $database_controller->update(
80 array(
81 'option_key' => $option_key,
82 'option_value' => maybe_serialize( $option_value ),
83 'site_id' => $site_id
84 )
85 );
86 endif;
87 return $results;
88 }
89
90 endif;
91
92 if ( ! function_exists( 'gdpr_delete_option' ) ) :
93 /**
94 * Get simple value from gdpr database by option_key
95 */
96 function gdpr_delete_option() {
97 $database_controller = new Moove_GDPR_DB_Controller();
98 $results = $database_controller->delete_option();
99 return $results;
100 }
101
102 endif;
103
104
105
106 add_filter( 'plugin_action_links', 'moove_gdpr_plugin_settings_link', 10, 2 );
107 /**
108 * Extension to display support, premium and settings links in the plugin listing page
109 *
110 * @param array $links Links.
111 * @param string $file File.
112 */
113 function moove_gdpr_plugin_settings_link( $links, $file ) {
114 if ( plugin_basename( dirname( __FILE__ ) . '/moove-gdpr.php' ) === $file ) {
115 /*
116 * Insert the Settings page link at the beginning
117 */
118 $in = '<a href="'.esc_url( admin_url( 'admin.php' ) ).'?page=moove-gdpr" target="_blank">' . __( 'Settings', 'gdpr-cookie-compliance' ) . '</a>';
119 array_unshift( $links, $in );
120
121 /*
122 * Insert the Support page link at the end
123 */
124 $in = '<a href="https://support.mooveagency.com/forum/gdpr-cookie-compliance/" target="_blank">' . __( 'Support', 'gdpr-cookie-compliance' ) . '</a>';
125 array_push( $links, $in );
126
127 /*
128 * Insert the Premium Upgrade link at the end
129 */
130 if ( ! function_exists( 'moove_gdpr_addon_get_plugin_dir' ) ) :
131 $in = '<a href="https://www.mooveagency.com/wordpress-plugins/gdpr-cookie-compliance/" class="gdpr_admin_link gdpr_premium_buy_link" target="_blank">' . __( 'Buy Premium', 'gdpr-cookie-compliance' ) . '</a>';
132 array_push( $links, $in );
133 endif;
134 }
135 return $links;
136 }
137
138 /**
139 * Get an attachment ID given a URL.
140 *
141 * @param string $url URL.
142 * @return int Attachment ID on success, 0 on failure
143 */
144 function gdpr_get_attachment_id( $url ) {
145 $attachment_id = 0;
146 $dir = wp_upload_dir();
147 if ( false !== strpos( $url, $dir['baseurl'] . '/' ) ) { // Is URL in uploads directory?
148 $file = basename( $url );
149 $query_args = array(
150 'post_type' => 'attachment',
151 'post_status' => 'inherit',
152 'fields' => 'ids',
153 'meta_query' => array(
154 array(
155 'value' => $file,
156 'compare' => 'LIKE',
157 'key' => '_wp_attachment_metadata',
158 ),
159 ),
160 );
161 $query = new WP_Query( $query_args );
162 if ( $query->have_posts() ) {
163 while ( $query->have_posts() ) :
164 $query->the_post();
165 $post_id = get_the_ID();
166 $meta = wp_get_attachment_metadata( $post_id );
167 if ( $meta && isset( $meta['file'] ) && isset( $meta['sizes'] ) ) :
168 $original_file = basename( $meta['file'] );
169 $cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
170 if ( $original_file === $file || in_array( $file, $cropped_image_files, false ) ) {
171 $attachment_id = $post_id;
172 break;
173 }
174 endif;
175 endwhile;
176 wp_reset_postdata();
177 }
178 }
179 return $attachment_id;
180 }
181
182 /**
183 * Get image alt text by image URL
184 *
185 * @param String $image_url Image URL.
186 *
187 * @return Bool | String
188 */
189 function gdpr_get_logo_alt( $image_url ) {
190 return apply_filters( 'gdpr_cc_custom_logo_alt', get_bloginfo( 'name' ), $image_url );
191 }
192
193 /**
194 * Get image widht & height by image URL
195 *
196 * @param string $image_url Image URL
197 */
198 function gdpr_get_logo_details( $image_url ) {
199 $image_details = array(
200 'width' => false,
201 'height' => false,
202 );
203 $image_size = apply_filters('gdpr_cc_company_logo_image_size', 'medium');
204 if ( $image_url && apply_filters( 'gdpr_cc_logo_details_enabled', true ) ) :
205 if ( strpos( $image_url, 'gdpr-cookie-compliance/dist/images/gdpr-logo.png' ) !== false ) :
206 $image_details = array(
207 'width' => 350,
208 'height' => 233,
209 );
210 else :
211 $attachment_id = attachment_url_to_postid( $image_url );
212 if ( $attachment_id ) :
213 $_image = wp_get_attachment_image_src( $attachment_id, $image_size );
214 if ( $_image ) :
215 $image_details = array(
216 'logo_url' => $_image[0],
217 'width' => $_image[1],
218 'height' => $_image[2],
219 );
220 endif;
221 endif;
222 endif;
223 endif;
224 $image_details = apply_filters( 'gdpr_cc_logo_details_filter', $image_details );
225 return $image_details;
226 }
227
228 /**
229 * GDPR Module manager, introduced in version 1.1.5
230 *
231 * @param string $module Module.
232 */
233 function gdpr_get_module( $module = '' ) {
234 if ( $module ) :
235 $module_controller = new GDPR_Modules();
236 $response = false;
237 switch ( $module ) :
238 case 'floating-button':
239 $response = apply_filters( 'gdpr_floating_button_module', $module_controller->get_floating_button() );
240 break;
241 case 'infobar-base':
242 $response = apply_filters( 'gdpr_infobar_base_module', $module_controller->get_infobar_base() );
243 break;
244 case 'infobar-content':
245 $response = apply_filters( 'gdpr_infobar_content_module', $module_controller->get_infobar_content() );
246 break;
247 case 'infobar-buttons':
248 $response = apply_filters( 'gdpr_infobar_buttons_module', $module_controller->get_infobar_buttons() );
249 break;
250 case 'company-logo':
251 $response = apply_filters( 'gdpr_company_logo_module', $module_controller->get_company_logo() );
252 break;
253 case 'gdpr-branding':
254 $response = apply_filters( 'gdpr_branding_module', $module_controller->get_gdpr_branding() );
255 break;
256 case 'modal-base':
257 $response = apply_filters( 'gdpr_modal_base_module', $module_controller->get_modal_base() );
258 break;
259 case 'tab-navigation':
260 $response = apply_filters( 'gdpr_tab_navigation_module', $module_controller->get_tab_navigation() );
261 break;
262 case 'modal-footer-buttons':
263 $response = apply_filters( 'gdpr_modal_footer_buttons_module', $module_controller->get_tab_footer_buttons() );
264 break;
265 case 'section-overview':
266 $response = apply_filters( 'gdpr_section_overview_module', $module_controller->get_section_overview() );
267 break;
268 case 'section-strictly':
269 $response = apply_filters( 'gdpr_section_strictly_module', $module_controller->get_section_strictly() );
270 break;
271 case 'section-advanced':
272 $response = apply_filters( 'gdpr_section_advanced_module', $module_controller->get_section_advanced() );
273 break;
274 case 'section-third_party':
275 $response = apply_filters( 'gdpr_section_third_party_module', $module_controller->get_section_third_party() );
276 break;
277 case 'section-cookiepolicy':
278 $response = apply_filters( 'gdpr_section_cookiepolicy_module', $module_controller->get_section_cookiepolicy() );
279 break;
280 case 'branding-styles':
281 $response = apply_filters( 'gdpr_branding_styles_module', $module_controller->get_branding_styles() );
282 break;
283 default:
284 endswitch;
285 endif;
286 return $response;
287 }
288
289
290 if ( ! function_exists( 'gdpr_cookie_is_accepted' ) ) :
291 /**
292 * Checking accepted cookie values by type
293 *
294 * @param string $type Type.
295 */
296 function gdpr_cookie_is_accepted( $type = '' ) {
297 $response = false;
298 $type = sanitize_text_field( $type );
299 $accepted_types = array( 'strict', 'thirdparty', 'advanced' );
300 if ( $type && in_array( $type, $accepted_types ) ) :
301 $gdpr_content = new Moove_GDPR_Content();
302 $php_cookies = $gdpr_content->gdpr_get_php_cookies();
303 $response = $php_cookies && isset( $php_cookies[ $type ] ) && $php_cookies[ $type ] ? true : false;
304 endif;
305 return $response;
306 }
307 endif;
308
309 if ( ! function_exists( 'gdpr_get_display_language_by_locale' ) ) :
310 /**
311 * Language locale
312 *
313 * @param string $locale Locale.
314 */
315 function gdpr_get_display_language_by_locale( $locale ) {
316 $locale_lang = explode( '-', $locale );
317 $_locale = isset( $locale_lang[0] ) ? $locale_lang[0] : $locale;
318 $language_codes = array(
319 'aa' => 'Afar',
320 'ab' => 'Abkhazian',
321 'ae' => 'Avestan',
322 'af' => 'Afrikaans',
323 'ak' => 'Akan',
324 'am' => 'Amharic',
325 'an' => 'Aragonese',
326 'ar' => 'Arabic',
327 'as' => 'Assamese',
328 'av' => 'Avaric',
329 'ay' => 'Aymara',
330 'az' => 'Azerbaijani',
331 'ba' => 'Bashkir',
332 'be' => 'Belarusian',
333 'bg' => 'Bulgarian',
334 'bh' => 'Bihari',
335 'bi' => 'Bislama',
336 'bm' => 'Bambara',
337 'bn' => 'Bengali',
338 'bo' => 'Tibetan',
339 'br' => 'Breton',
340 'bs' => 'Bosnian',
341 'ca' => 'Catalan',
342 'ce' => 'Chechen',
343 'ch' => 'Chamorro',
344 'co' => 'Corsican',
345 'cr' => 'Cree',
346 'cs' => 'Czech',
347 'cu' => 'Church Slavic',
348 'cv' => 'Chuvash',
349 'cy' => 'Welsh',
350 'da' => 'Danish',
351 'de' => 'German',
352 'dv' => 'Divehi',
353 'dz' => 'Dzongkha',
354 'ee' => 'Ewe',
355 'el' => 'Greek',
356 'en' => 'English',
357 'eo' => 'Esperanto',
358 'es' => 'Spanish',
359 'et' => 'Estonian',
360 'eu' => 'Basque',
361 'fa' => 'Persian',
362 'ff' => 'Fulah',
363 'fi' => 'Finnish',
364 'fj' => 'Fijian',
365 'fo' => 'Faroese',
366 'fr' => 'French',
367 'fy' => 'Western Frisian',
368 'ga' => 'Irish',
369 'gd' => 'Scottish Gaelic',
370 'gl' => 'Galician',
371 'gn' => 'Guarani',
372 'gu' => 'Gujarati',
373 'gv' => 'Manx',
374 'ha' => 'Hausa',
375 'he' => 'Hebrew',
376 'hi' => 'Hindi',
377 'ho' => 'Hiri Motu',
378 'hr' => 'Croatian',
379 'ht' => 'Haitian',
380 'hu' => 'Hungarian',
381 'hy' => 'Armenian',
382 'hz' => 'Herero',
383 'ia' => 'Interlingua (International Auxiliary Language Association)',
384 'id' => 'Indonesian',
385 'ie' => 'Interlingue',
386 'ig' => 'Igbo',
387 'ii' => 'Sichuan Yi',
388 'ik' => 'Inupiaq',
389 'io' => 'Ido',
390 'is' => 'Icelandic',
391 'it' => 'Italian',
392 'iu' => 'Inuktitut',
393 'ja' => 'Japanese',
394 'jv' => 'Javanese',
395 'ka' => 'Georgian',
396 'kg' => 'Kongo',
397 'ki' => 'Kikuyu',
398 'kj' => 'Kwanyama',
399 'kk' => 'Kazakh',
400 'kl' => 'Kalaallisut',
401 'km' => 'Khmer',
402 'kn' => 'Kannada',
403 'ko' => 'Korean',
404 'kr' => 'Kanuri',
405 'ks' => 'Kashmiri',
406 'ku' => 'Kurdish',
407 'kv' => 'Komi',
408 'kw' => 'Cornish',
409 'ky' => 'Kirghiz',
410 'la' => 'Latin',
411 'lb' => 'Luxembourgish',
412 'lg' => 'Ganda',
413 'li' => 'Limburgish',
414 'ln' => 'Lingala',
415 'lo' => 'Lao',
416 'lt' => 'Lithuanian',
417 'lu' => 'Luba-Katanga',
418 'lv' => 'Latvian',
419 'mg' => 'Malagasy',
420 'mh' => 'Marshallese',
421 'mi' => 'Maori',
422 'mk' => 'Macedonian',
423 'ml' => 'Malayalam',
424 'mn' => 'Mongolian',
425 'mr' => 'Marathi',
426 'ms' => 'Malay',
427 'mt' => 'Maltese',
428 'my' => 'Burmese',
429 'na' => 'Nauru',
430 'nb' => 'Norwegian Bokmal',
431 'nd' => 'North Ndebele',
432 'ne' => 'Nepali',
433 'ng' => 'Ndonga',
434 'nl' => 'Dutch',
435 'nn' => 'Norwegian Nynorsk',
436 'no' => 'Norwegian',
437 'nr' => 'South Ndebele',
438 'nv' => 'Navajo',
439 'ny' => 'Chichewa',
440 'oc' => 'Occitan',
441 'oj' => 'Ojibwa',
442 'om' => 'Oromo',
443 'or' => 'Oriya',
444 'os' => 'Ossetian',
445 'pa' => 'Panjabi',
446 'pi' => 'Pali',
447 'pl' => 'Polish',
448 'ps' => 'Pashto',
449 'pt' => 'Portuguese',
450 'qu' => 'Quechua',
451 'rm' => 'Raeto-Romance',
452 'rn' => 'Kirundi',
453 'ro' => 'Romanian',
454 'ru' => 'Russian',
455 'rw' => 'Kinyarwanda',
456 'sa' => 'Sanskrit',
457 'sc' => 'Sardinian',
458 'sd' => 'Sindhi',
459 'se' => 'Northern Sami',
460 'sg' => 'Sango',
461 'si' => 'Sinhala',
462 'sk' => 'Slovak',
463 'sl' => 'Slovenian',
464 'sm' => 'Samoan',
465 'sn' => 'Shona',
466 'so' => 'Somali',
467 'sq' => 'Albanian',
468 'sr' => 'Serbian',
469 'ss' => 'Swati',
470 'st' => 'Southern Sotho',
471 'su' => 'Sundanese',
472 'sv' => 'Swedish',
473 'sw' => 'Swahili',
474 'ta' => 'Tamil',
475 'te' => 'Telugu',
476 'tg' => 'Tajik',
477 'th' => 'Thai',
478 'ti' => 'Tigrinya',
479 'tk' => 'Turkmen',
480 'tl' => 'Tagalog',
481 'tn' => 'Tswana',
482 'to' => 'Tonga',
483 'tr' => 'Turkish',
484 'ts' => 'Tsonga',
485 'tt' => 'Tatar',
486 'tw' => 'Twi',
487 'ty' => 'Tahitian',
488 'ug' => 'Uighur',
489 'uk' => 'Ukrainian',
490 'ur' => 'Urdu',
491 'uz' => 'Uzbek',
492 've' => 'Venda',
493 'vi' => 'Vietnamese',
494 'vo' => 'Volapuk',
495 'wa' => 'Walloon',
496 'wo' => 'Wolof',
497 'xh' => 'Xhosa',
498 'yi' => 'Yiddish',
499 'yo' => 'Yoruba',
500 'za' => 'Zhuang',
501 'zh' => 'Chinese',
502 'zu' => 'Zulu',
503 );
504 return isset( $language_codes[ $_locale ] ) ? $language_codes[ $_locale ] . ' [' . $locale . ']' : $locale;
505 }
506 endif;
507