Plugin Directory

source: gdpr-cookie-compliance/trunk/gdpr-functions.php

Last change on this file was 3361545, checked in by MooveAgency, 6 months ago

Version 5.0.7 released

  • Property svn:executable set to *
File size: 20.8 KB
Line 
1<?php
2/**
3 * Moove_Functions File Doc Comment
4 *
5 * @category Moove_Functions
6 * @package   gdpr-cookie-compliance
7 * @author    Moove Agency
8 */
9
10if ( ! defined( 'ABSPATH' ) ) {
11        exit;
12} // Exit if accessed directly
13
14if ( ! 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        }
21endif;
22
23if ( ! function_exists( 'gdpr_get_admin_submenu_items' ) ) :
24        /**
25         * Admin Sub Menu
26         */
27        function gdpr_get_admin_submenu_items() {
28                $plugin_tabs = array(
29                        'help'           => array(
30                                'title' => esc_html__( 'Documentation', 'gdpr-cookie-compliance' ),
31                                'slug'  => 'help',
32                        ),
33                        'video-tutorial' => array(
34                                'title' => esc_html__( 'Video Tutorial', 'gdpr-cookie-compliance' ),
35                                'slug'  => 'video-tutorial',
36                        ),
37                        'support'        => array(
38                                'title' => esc_html__( 'Support', 'gdpr-cookie-compliance' ),
39                                'slug'  => 'support',
40                        ),
41                        'licence'        => array(
42                                'title' => '<span style="color: #f89e26">' . esc_html__( 'Licence Manager', 'gdpr-cookie-compliance' ) . '</span>',
43                                'slug'  => 'licence',
44                        ),
45                );
46
47                $plugin_tabs = apply_filters( 'gdpr_admin_sidebar_nav_links', $plugin_tabs );
48                return $plugin_tabs;
49        }
50endif;
51
52if ( ! function_exists( 'gdpr_shortcode_settings' ) ) :
53        add_action('init', 'gdpr_shortcode_settings_register' );
54        function gdpr_shortcode_settings_register(){
55                add_shortcode( 'setting', 'gdpr_shortcode_settings' );
56        } 
57       
58        function gdpr_shortcode_settings( $atts ) {
59                return 'setting';
60        }
61endif;
62
63if ( ! function_exists( 'gdpr_get_site_id' ) ) :
64        /**
65         * Returns the current blog id as site_id
66         */
67        function gdpr_get_site_id() {
68                return function_exists( 'get_current_blog_id' ) ? get_current_blog_id() : 1;
69        }
70endif;
71
72if ( ! function_exists( 'gdpr_get_integration_modules' ) ) :
73        /**
74         * Integration Modules Loading
75         *
76         * @param array $gdpr_options Plugin options.
77         * @param array $gdin_values Integration modules.
78         * @return array $extended integration modules
79         */
80        function gdpr_get_integration_modules( $gdpr_options, $gdin_values ) {
81                $integration_modules = array(
82                        'ga4'   => array(
83                                'name'       => 'Google Analytics 4',
84                                'desc'       => '',
85                                'cookie_cat' => isset( $gdin_values['ga4'] ) ? intval( $gdin_values['ga4'] ) : 2,
86                                'tacking_id' => isset( $gdin_values['ga4_id'] ) ? $gdin_values['ga4_id'] : '',
87                                'id_format'  => 'G-XXXXXXX',
88                                'atts'       => array(
89                                        'toggle' => true,
90                                        'input'  => '',
91                                ),
92                                'status'     => isset( $gdin_values['ga4'] ),
93                        ),
94                        'gtm'   => array(
95                                'name'       => 'Google Tag Manager',
96                                'desc'       => 'Standard implementation',
97                                'cookie_cat' => isset( $gdin_values['gtm'] ) ? intval( $gdin_values['gtm'] ) : 2,
98                                'tacking_id' => isset( $gdin_values['gtm_id'] ) ? $gdin_values['gtm_id'] : '',
99                                'id_format'  => 'GTM-XXXXXX',
100                                'atts'       => array(
101                                        'toggle' => true,
102                                        'input'  => '',
103                                ),
104                                'status'     => isset( $gdin_values['gtm'] ),
105                        ),
106                        'gtmc2' => array(
107                                'name'       => 'Google Tag Manager',
108                                'desc'       => 'Consent Mode v2 [for advanced users only]',
109                                'cookie_cat' => isset( $gdin_values['gtmc2'] ) ? intval( $gdin_values['gtmc2'] ) : 2,
110                                'tacking_id' => isset( $gdin_values['gtmc2_id'] ) ? $gdin_values['gtmc2_id'] : '',
111                                'id_format'  => 'GTM-XXXXXX',
112                                'atts'       => array(
113                                        'toggle' => true,
114                                        'input'  => '',
115                                ),
116                                'status'     => isset( $gdin_values['gtmc2'] ),
117                        ),
118                        'gadc'  => array(
119                                'name'       => 'Google Ads',
120                                'desc'       => '',
121                                'cookie_cat' => isset( $gdin_values['gadc'] ) ? intval( $gdin_values['gadc'] ) : 2,
122                                'tacking_id' => isset( $gdin_values['gadc_id'] ) ? $gdin_values['gadc_id'] : '',
123                                'id_format'  => 'AW-123456789',
124                                'atts'       => array(
125                                        'toggle' => true,
126                                        'input'  => '',
127                                ),
128                                'status'     => isset( $gdin_values['gadc'] ),
129                        ),
130                        'fbp'   => array(
131                                'name'       => 'Meta Pixel',
132                                'desc'       => '(Formerly Facebook Pixel)',
133                                'cookie_cat' => isset( $gdin_values['fbp'] ) ? intval( $gdin_values['fbp'] ) : 2,
134                                'tacking_id' => isset( $gdin_values['fbp_id'] ) ? $gdin_values['fbp_id'] : '',
135                                'id_format'  => '[15 digit ID]',
136                                'atts'       => array(
137                                        'toggle' => true,
138                                        'input'  => '',
139                                ),
140                                'status'     => isset( $gdin_values['fbp'] ),
141                        ),
142                        'muet'   => array(
143                                'name'       => 'Microsoft Advertising (UET)',
144                                'desc'       => 'Universal Event Tracking',
145                                'cookie_cat' => isset( $gdin_values['muet'] ) ? intval( $gdin_values['muet'] ) : 2,
146                                'tacking_id' => isset( $gdin_values['muet_id'] ) ? $gdin_values['muet_id'] : '',
147                                'id_format'  => 'xxxxxxxx',
148                                'atts'       => array(
149                                        'toggle' => true,
150                                        'input'  => '',
151                                ),
152                                'status'     => isset( $gdin_values['muet'] ),
153                        ),
154
155                );
156                return apply_filters( 'gdpr_integration_modules', $integration_modules, $gdpr_options, $gdin_values );
157        }
158endif;
159
160
161if ( ! function_exists( 'gdpr_get_field' ) ) :
162        /**
163         * Get simple value from gdpr database by option_key
164         *
165         * @param string $option_key Option key (optional).
166         * @param int    $site_id Site ID (optional).
167         * @return $results Results.
168         */
169        function gdpr_get_field( $option_key = false, $site_id = false ) {
170                $results = false;
171                if ( $option_key ) :
172                        $site_id             = $site_id && intval( $site_id ) ? $site_id : gdpr_get_site_id();
173                        $database_controller = new Moove_GDPR_DB_Controller();
174                        $results             = $database_controller->get( $option_key, $site_id );
175                        $results             = $results && isset( $results->option_value ) ? maybe_unserialize( $results->option_value ) : false;
176                endif;
177                return $results;
178        }
179
180endif;
181
182if ( ! function_exists( 'gdpr_get_options' ) ) :
183        /**
184         * Get simple value from gdpr database by option_key
185         *
186         * @param int $site_id Site ID (optional).
187         * @return $results Results.
188         */
189        function gdpr_get_options( $site_id = false ) {
190                $site_id             = $site_id && intval( $site_id ) ? $site_id : gdpr_get_site_id();
191                $database_controller = new Moove_GDPR_DB_Controller();
192                $results             = $database_controller->get_options( $site_id );
193                $results_filtered    = array();
194                if ( is_array( $results ) && ! empty( $results ) ) :
195                        foreach ( $results as $key => $value ) :
196                                $results_filtered[ $key ] = maybe_unserialize( $value->option_value );
197                        endforeach;
198                endif;
199                $results_filtered = $results_filtered && ! empty( $results_filtered ) ? $results_filtered : false;
200                return $results_filtered;
201        }
202
203endif;
204
205if ( ! function_exists( 'gdpr_update_field' ) ) :
206        /**
207         * Get simple value from gdpr database by option_key
208         *
209         * @param string $option_key Option key (optional).
210         * @param string $option_value Option value (optional).
211         * @param int    $site_id Site ID (optional).
212         * @return $results Results.
213         */
214        function gdpr_update_field( $option_key = false, $option_value = false, $site_id = false ) {
215                $results = false;
216                if ( $option_key ) :
217                        $site_id             = $site_id && intval( $site_id ) ? $site_id : gdpr_get_site_id();
218                        $database_controller = new Moove_GDPR_DB_Controller();
219                        $results             = $database_controller->update(
220                                array(
221                                        'option_key'   => $option_key,
222                                        'option_value' => maybe_serialize( $option_value ),
223                                        'site_id'      => $site_id,
224                                )
225                        );
226                endif;
227                return $results;
228        }
229
230endif;
231
232if ( ! function_exists( 'gdpr_delete_option' ) ) :
233        /**
234         * Get simple value from gdpr database by option_key
235         */
236        function gdpr_delete_option() {
237                $database_controller = new Moove_GDPR_DB_Controller();
238                $results             = $database_controller->delete_option();
239                return $results;
240        }
241
242endif;
243
244add_filter( 'plugin_action_links', 'moove_gdpr_plugin_settings_link', 10, 2 );
245/**
246 * Extension to display support, premium and settings links in the plugin listing page
247 *
248 * @param array  $links Links.
249 * @param string $file File.
250 */
251function moove_gdpr_plugin_settings_link( $links, $file ) {
252        if ( plugin_basename( dirname( __FILE__ ) . '/moove-gdpr.php' ) === $file ) {
253                /*
254                * Insert the Licence Manager link at the beginning
255                */
256                $in = '<a href="' . esc_url( admin_url( 'admin.php' ) ) . '?page=moove-gdpr_licence" target="_blank">' . __( 'Licence Manager', 'gdpr-cookie-compliance' ) . '</a>';
257                array_unshift( $links, $in );
258
259                /*
260                * Insert the Settings page link at the beginning
261                */
262                $in = '<a href="' . esc_url( admin_url( 'admin.php' ) ) . '?page=moove-gdpr" target="_blank">' . __( 'Settings', 'gdpr-cookie-compliance' ) . '</a>';
263                array_unshift( $links, $in );
264
265                /*
266                * Insert the Support page link at the end
267                */
268                $in = '<a href="https://support.mooveagency.com/forum/gdpr-cookie-compliance/" target="_blank">' . __( 'Support', 'gdpr-cookie-compliance' ) . '</a>';
269                array_push( $links, $in );
270
271                /*
272                * Insert the Premium Upgrade link at the end
273                */
274                if ( ! function_exists( 'moove_gdpr_addon_get_plugin_dir' ) ) :
275                        $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>';
276                        array_push( $links, $in );
277                endif;
278
279        }
280        return $links;
281}
282
283/**
284 * Get an attachment ID given a URL.
285 *
286 * @param string $url URL.
287 * @return int Attachment ID on success, 0 on failure
288 */
289function gdpr_get_attachment_id( $url ) {
290        $attachment_id = 0;
291        $dir           = wp_upload_dir();
292        if ( false !== strpos( $url, $dir['baseurl'] . '/' ) ) { // Is URL in uploads directory?
293                $file       = basename( $url );
294                $query_args = array(
295                        'post_type'   => 'attachment',
296                        'post_status' => 'inherit',
297                        'fields'      => 'ids',
298                        'meta_query'  => array(
299                                array(
300                                        'value'   => $file,
301                                        'compare' => 'LIKE',
302                                        'key'     => '_wp_attachment_metadata',
303                                ),
304                        ),
305                );
306                $query      = new WP_Query( $query_args );
307                if ( $query->have_posts() ) {
308                        while ( $query->have_posts() ) :
309                                $query->the_post();
310                                $post_id = get_the_ID();
311                                $meta    = wp_get_attachment_metadata( $post_id );
312                                if ( $meta && isset( $meta['file'] ) && isset( $meta['sizes'] ) ) :
313                                        $original_file       = basename( $meta['file'] );
314                                        $cropped_image_files = wp_list_pluck( $meta['sizes'], 'file' );
315                                        if ( $original_file === $file || in_array( $file, $cropped_image_files, false ) ) {
316                                                $attachment_id = $post_id;
317                                                break;
318                                        }
319                                endif;
320                        endwhile;
321                        wp_reset_postdata();
322                }
323        }
324        return $attachment_id;
325}
326
327/**
328 * Get image alt text by image URL or ID
329 *
330 * @param String $image_url Image URL or ID.
331 * @param array  $options Plugin options.
332 *
333 * @return Bool | String
334 */
335function gdpr_get_logo_alt( $image_url, $options = array() ) {
336        if ( isset( $options['moove_gdpr_company_logo_id'] ) && intval( $options['moove_gdpr_company_logo_id'] ) ) :
337                $image_alt = get_post_meta( $options['moove_gdpr_company_logo_id'], '_wp_attachment_image_alt', true );
338        else :
339                $image_alt = get_bloginfo( 'name' );
340        endif;
341        return apply_filters( 'gdpr_cc_custom_logo_alt', $image_alt, $image_url );
342}
343
344/**
345 * Get image widht & height by image URL
346 *
347 * @param string $image_url Image URL.
348 * @param array  $options Plugin options.
349 */
350function gdpr_get_logo_details( $image_url, $options = array() ) {
351        $image_details = array(
352                'width'  => false,
353                'height' => false,
354        );
355        $image_size    = apply_filters( 'gdpr_cc_company_logo_image_size', 'medium' );
356        if ( $image_url && apply_filters( 'gdpr_cc_logo_details_enabled', true ) ) :
357
358                if ( strpos( $image_url, 'gdpr-cookie-compliance/dist/images/gdpr-logo.png' ) !== false ) :
359                        $image_details = array(
360                                'width'  => 350,
361                                'height' => 233,
362                        );
363                else :
364                        if ( isset( $options['moove_gdpr_company_logo_id'] ) && intval( $options['moove_gdpr_company_logo_id'] ) ) :
365                                $attachment_id = intval( $options['moove_gdpr_company_logo_id'] );
366                        else :
367                                $attachment_id = attachment_url_to_postid( $image_url );
368                        endif;
369                        if ( $attachment_id ) :
370                                $_image = wp_get_attachment_image_src( $attachment_id, $image_size );
371                                if ( ! isset( $options['moove_gdpr_company_logo_id'] ) ) :
372                                        $gdpr_default_content                       = new Moove_GDPR_Content();
373                                        $option_name                                = $gdpr_default_content->moove_gdpr_get_option_name();
374                                        $gdpr_options                               = get_option( $option_name );
375                                        $gdpr_options['moove_gdpr_company_logo_id'] = $attachment_id;
376                                        update_option( $option_name, $gdpr_options );
377                                endif;
378                                if ( $_image ) :
379                                        $image_details = array(
380                                                'logo_url' => $_image[0],
381                                                'width'    => $_image[1],
382                                                'height'   => $_image[2],
383                                        );
384                                endif;
385                        endif;
386                endif;
387        endif;
388        $image_details = apply_filters( 'gdpr_cc_logo_details_filter', $image_details );
389        return $image_details;
390}
391
392/**
393 * GDPR Module manager, introduced in version 1.1.5
394 *
395 * @param string $module Module.
396 */
397function gdpr_get_module( $module = '' ) {
398        if ( $module ) :
399                $module_controller = new GDPR_Modules();
400                $response          = false;
401                switch ( $module ) :
402                        case 'floating-button':
403                                $response = apply_filters( 'gdpr_floating_button_module', $module_controller->get_floating_button() );
404                                break;
405                        case 'infobar-base':
406                                $response = apply_filters( 'gdpr_infobar_base_module', $module_controller->get_infobar_base() );
407                                break;
408                        case 'infobar-content':
409                                $response = apply_filters( 'gdpr_infobar_content_module', $module_controller->get_infobar_content() );
410                                break;
411                        case 'infobar-buttons':
412                                $response = apply_filters( 'gdpr_infobar_buttons_module', $module_controller->get_infobar_buttons() );
413                                break;
414                        case 'company-logo':
415                                $response = apply_filters( 'gdpr_company_logo_module', $module_controller->get_company_logo() );
416                                break;
417                        case 'gdpr-branding':
418                                $response = apply_filters( 'gdpr_branding_module', $module_controller->get_gdpr_branding() );
419                                break;
420                        case 'modal-base':
421                                $response = apply_filters( 'gdpr_modal_base_module', $module_controller->get_modal_base() );
422                                break;
423                        case 'tab-navigation':
424                                $response = apply_filters( 'gdpr_tab_navigation_module', $module_controller->get_tab_navigation() );
425                                break;
426                        case 'modal-footer-buttons':
427                                $response = apply_filters( 'gdpr_modal_footer_buttons_module', $module_controller->get_tab_footer_buttons() );
428                                break;
429                        case 'section-overview':
430                                $response = apply_filters( 'gdpr_section_overview_module', $module_controller->get_section_overview() );
431                                break;
432                        case 'section-strictly':
433                                $response = apply_filters( 'gdpr_section_strictly_module', $module_controller->get_section_strictly() );
434                                break;
435                        case 'section-advanced':
436                                $response = apply_filters( 'gdpr_section_advanced_module', $module_controller->get_section_advanced() );
437                                break;
438                        case 'section-third_party':
439                                $response = apply_filters( 'gdpr_section_third_party_module', $module_controller->get_section_third_party() );
440                                break;
441                        case 'section-cookiepolicy':
442                                $response = apply_filters( 'gdpr_section_cookiepolicy_module', $module_controller->get_section_cookiepolicy() );
443                                break;
444                        case 'branding-styles':
445                                $response = apply_filters( 'gdpr_branding_styles_module', $module_controller->get_branding_styles() );
446                                break;
447                        default:
448                endswitch;
449        endif;
450        $response = apply_filters( 'gdpr_get_module_' . $module, $response, $module, $module_controller );
451        return $response;
452}
453
454
455if ( ! function_exists( 'gdpr_cookie_is_accepted' ) ) :
456        /**
457         * Checking accepted cookie values by type
458         *
459         * @param string $type Type.
460         */
461        function gdpr_cookie_is_accepted( $type = '' ) {
462                $response       = false;
463                $type           = sanitize_text_field( $type );
464                $accepted_types = array( 'strict', 'thirdparty', 'advanced', 'performance', 'preference' );
465                if ( $type && in_array( $type, $accepted_types ) ) :
466                        $gdpr_content = new Moove_GDPR_Content();
467                        $php_cookies  = $gdpr_content->gdpr_get_php_cookies();
468                        $response     = $php_cookies && isset( $php_cookies[ $type ] ) && $php_cookies[ $type ] ? true : false;
469                endif;
470                return $response;
471        }
472endif;
473
474if ( ! function_exists( 'gdpr_get_display_language_by_locale' ) ) :
475        /**
476         * Language locale
477         *
478         * @param string $locale Locale.
479         */
480        function gdpr_get_display_language_by_locale( $locale ) {
481                $locale_lang    = explode( '-', $locale );
482                $_locale        = isset( $locale_lang[0] ) ? $locale_lang[0] : $locale;
483                $language_codes = array(
484                        'aa' => 'Afar',
485                        'ab' => 'Abkhazian',
486                        'ae' => 'Avestan',
487                        'af' => 'Afrikaans',
488                        'ak' => 'Akan',
489                        'am' => 'Amharic',
490                        'an' => 'Aragonese',
491                        'ar' => 'Arabic',
492                        'as' => 'Assamese',
493                        'av' => 'Avaric',
494                        'ay' => 'Aymara',
495                        'az' => 'Azerbaijani',
496                        'ba' => 'Bashkir',
497                        'be' => 'Belarusian',
498                        'bg' => 'Bulgarian',
499                        'bh' => 'Bihari',
500                        'bi' => 'Bislama',
501                        'bm' => 'Bambara',
502                        'bn' => 'Bengali',
503                        'bo' => 'Tibetan',
504                        'br' => 'Breton',
505                        'bs' => 'Bosnian',
506                        'ca' => 'Catalan',
507                        'ce' => 'Chechen',
508                        'ch' => 'Chamorro',
509                        'co' => 'Corsican',
510                        'cr' => 'Cree',
511                        'cs' => 'Czech',
512                        'cu' => 'Church Slavic',
513                        'cv' => 'Chuvash',
514                        'cy' => 'Welsh',
515                        'da' => 'Danish',
516                        'de' => 'German',
517                        'dv' => 'Divehi',
518                        'dz' => 'Dzongkha',
519                        'ee' => 'Ewe',
520                        'el' => 'Greek',
521                        'en' => 'English',
522                        'eo' => 'Esperanto',
523                        'es' => 'Spanish',
524                        'et' => 'Estonian',
525                        'eu' => 'Basque',
526                        'fa' => 'Persian',
527                        'ff' => 'Fulah',
528                        'fi' => 'Finnish',
529                        'fj' => 'Fijian',
530                        'fo' => 'Faroese',
531                        'fr' => 'French',
532                        'fy' => 'Western Frisian',
533                        'ga' => 'Irish',
534                        'gd' => 'Scottish Gaelic',
535                        'gl' => 'Galician',
536                        'gn' => 'Guarani',
537                        'gu' => 'Gujarati',
538                        'gv' => 'Manx',
539                        'ha' => 'Hausa',
540                        'he' => 'Hebrew',
541                        'hi' => 'Hindi',
542                        'ho' => 'Hiri Motu',
543                        'hr' => 'Croatian',
544                        'ht' => 'Haitian',
545                        'hu' => 'Hungarian',
546                        'hy' => 'Armenian',
547                        'hz' => 'Herero',
548                        'ia' => 'Interlingua (International Auxiliary Language Association)',
549                        'id' => 'Indonesian',
550                        'ie' => 'Interlingue',
551                        'ig' => 'Igbo',
552                        'ii' => 'Sichuan Yi',
553                        'ik' => 'Inupiaq',
554                        'io' => 'Ido',
555                        'is' => 'Icelandic',
556                        'it' => 'Italian',
557                        'iu' => 'Inuktitut',
558                        'ja' => 'Japanese',
559                        'jv' => 'Javanese',
560                        'ka' => 'Georgian',
561                        'kg' => 'Kongo',
562                        'ki' => 'Kikuyu',
563                        'kj' => 'Kwanyama',
564                        'kk' => 'Kazakh',
565                        'kl' => 'Kalaallisut',
566                        'km' => 'Khmer',
567                        'kn' => 'Kannada',
568                        'ko' => 'Korean',
569                        'kr' => 'Kanuri',
570                        'ks' => 'Kashmiri',
571                        'ku' => 'Kurdish',
572                        'kv' => 'Komi',
573                        'kw' => 'Cornish',
574                        'ky' => 'Kirghiz',
575                        'la' => 'Latin',
576                        'lb' => 'Luxembourgish',
577                        'lg' => 'Ganda',
578                        'li' => 'Limburgish',
579                        'ln' => 'Lingala',
580                        'lo' => 'Lao',
581                        'lt' => 'Lithuanian',
582                        'lu' => 'Luba-Katanga',
583                        'lv' => 'Latvian',
584                        'mg' => 'Malagasy',
585                        'mh' => 'Marshallese',
586                        'mi' => 'Maori',
587                        'mk' => 'Macedonian',
588                        'ml' => 'Malayalam',
589                        'mn' => 'Mongolian',
590                        'mr' => 'Marathi',
591                        'ms' => 'Malay',
592                        'mt' => 'Maltese',
593                        'my' => 'Burmese',
594                        'na' => 'Nauru',
595                        'nb' => 'Norwegian Bokmal',
596                        'nd' => 'North Ndebele',
597                        'ne' => 'Nepali',
598                        'ng' => 'Ndonga',
599                        'nl' => 'Dutch',
600                        'nn' => 'Norwegian Nynorsk',
601                        'no' => 'Norwegian',
602                        'nr' => 'South Ndebele',
603                        'nv' => 'Navajo',
604                        'ny' => 'Chichewa',
605                        'oc' => 'Occitan',
606                        'oj' => 'Ojibwa',
607                        'om' => 'Oromo',
608                        'or' => 'Oriya',
609                        'os' => 'Ossetian',
610                        'pa' => 'Panjabi',
611                        'pi' => 'Pali',
612                        'pl' => 'Polish',
613                        'ps' => 'Pashto',
614                        'pt' => 'Portuguese',
615                        'qu' => 'Quechua',
616                        'rm' => 'Raeto-Romance',
617                        'rn' => 'Kirundi',
618                        'ro' => 'Romanian',
619                        'ru' => 'Russian',
620                        'rw' => 'Kinyarwanda',
621                        'sa' => 'Sanskrit',
622                        'sc' => 'Sardinian',
623                        'sd' => 'Sindhi',
624                        'se' => 'Northern Sami',
625                        'sg' => 'Sango',
626                        'si' => 'Sinhala',
627                        'sk' => 'Slovak',
628                        'sl' => 'Slovenian',
629                        'sm' => 'Samoan',
630                        'sn' => 'Shona',
631                        'so' => 'Somali',
632                        'sq' => 'Albanian',
633                        'sr' => 'Serbian',
634                        'ss' => 'Swati',
635                        'st' => 'Southern Sotho',
636                        'su' => 'Sundanese',
637                        'sv' => 'Swedish',
638                        'sw' => 'Swahili',
639                        'ta' => 'Tamil',
640                        'te' => 'Telugu',
641                        'tg' => 'Tajik',
642                        'th' => 'Thai',
643                        'ti' => 'Tigrinya',
644                        'tk' => 'Turkmen',
645                        'tl' => 'Tagalog',
646                        'tn' => 'Tswana',
647                        'to' => 'Tonga',
648                        'tr' => 'Turkish',
649                        'ts' => 'Tsonga',
650                        'tt' => 'Tatar',
651                        'tw' => 'Twi',
652                        'ty' => 'Tahitian',
653                        'ug' => 'Uighur',
654                        'uk' => 'Ukrainian',
655                        'ur' => 'Urdu',
656                        'uz' => 'Uzbek',
657                        've' => 'Venda',
658                        'vi' => 'Vietnamese',
659                        'vo' => 'Volapuk',
660                        'wa' => 'Walloon',
661                        'wo' => 'Wolof',
662                        'xh' => 'Xhosa',
663                        'yi' => 'Yiddish',
664                        'yo' => 'Yoruba',
665                        'za' => 'Zhuang',
666                        'zh' => 'Chinese',
667                        'zu' => 'Zulu',
668                );
669                return isset( $language_codes[ $_locale ] ) ? $language_codes[ $_locale ] . ' [' . $locale . ']' : $locale;
670        }
671endif;
672
673add_action( 'gdpr_modal_base_module', 'gdpr_copyscape_cc_remove_hidden_elements', 10, 1 );
674add_action( 'gdpr_infobar_base_module', 'gdpr_copyscape_cc_remove_hidden_elements', 10, 1 );
675add_action( 'gdpr_branding_styles_module', 'gdpr_copyscape_cc_remove_hidden_elements', 10, 1 );
676add_action( 'gdpr_floating_button_module', 'gdpr_copyscape_cc_remove_hidden_elements', 10, 1 );
677
678/**
679 * Disable showing HTML content if ?justtext=1 query parameter is part of the URL
680 *
681 * @param string $modal_html Modal HTML.
682 */
683function gdpr_copyscape_cc_remove_hidden_elements( $modal_html ) {
684        return isset( $_GET['justtext'] ) && sanitize_text_field( wp_unslash( $_GET['justtext'] ) ) ? '' : $modal_html;
685};
Note: See TracBrowser for help on using the repository browser.