Repository navigation
Expand file tree
/
Copy pathindex.php
More file actions
38 lines (35 loc) · 1.65 KB
/
Copy pathindex.php
File metadata and controls
38 lines (35 loc) · 1.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/**
* Shortcodes, mainly for the privacy policy page:
*
* [plugin=cookie-consent]show=consent-id[/plugin]
* The visitor's current consent ID (+ date and a copy button), or a
* "no consent stored yet" notice - filled in by the init script in
* global/index.php, so it always shows this browser's own ID.
*
* [plugin=cookie-consent]show=settings-link[/plugin]
* A link that opens the cookie settings dialog.
*
* Also usable from a theme template:
* {plugin name="cookie-consent"}show=consent-id{/plugin}
*
* Shortcodes instead of plain markup because WYSIWYG editors tend to drop
* an empty <span data-cc-consent-id> or unknown data-* attributes on save.
*
* @var string $show from the shortcode's parameters (buffer_script())
*/
if (SE_SECTION !== 'backend') {
$cc_show = (string) ($show ?? 'consent-id');
if ($cc_show === 'settings-link') {
// Same label as the floating cookie button, in the page's language.
global $page_contents, $languagePack;
$cc_front_file = __DIR__.'/data/frontend.json';
$cc_front = is_file($cc_front_file) ? json_decode((string) file_get_contents($cc_front_file), true) : [];
$cc_labels = $cc_front['floating_labels'] ?? [];
$cc_lang = (string) ($page_contents['page_language'] ?? $languagePack ?? '');
$cc_label = $cc_labels[$cc_lang] ?? $cc_labels[$cc_front['fallback_lang'] ?? ''] ?? 'Cookie-Einstellungen';
echo '<a href="#" class="cc-se-settings-link" data-cc="show-preferencesModal">'.htmlspecialchars((string) $cc_label).'</a>';
} else {
echo '<span class="cc-se-consent-id" data-cc-consent-id></span>';
}
}