Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 70
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2/**
3 * Cookie Consent: classic-theme fallback for the required legal links.
4 *
5 * Rendered on wp_footer by Cookie_Consent::maybe_render_footer_links_fallback()
6 * only when the Block Hooks footer-nav injection did not run for this response
7 * (classic themes, or block themes whose rendered template has no footer
8 * navigation). Provides a fixed-corner floating control holding the Privacy
9 * Policy, CCPA opt-out, and "Manage Privacy Preferences" links.
10 *
11 * The control renders hidden and is revealed client-side only when there is a
12 * region-specific required link to show (CCPA opt-out or GDPR manage
13 * preferences); see state.showFallbackControl in view.ts. This keeps the server
14 * HTML geo-independent (cache-safe) and avoids a persistent global control.
15 *
16 * Variables provided by the caller:
17 *
18 * @var string $privacy_policy_url Privacy Policy permalink, or '' when none.
19 * @var string $ccpa_url           CCPA opt-out page permalink, or '' when none.
20 * @var string $ccpa_label         CCPA opt-out page title (link label), or '' when none.
21 *
22 * @package automattic/jetpack-cookie-consent
23 */
24
25if ( ! defined( 'ABSPATH' ) ) {
26    exit;
27}
28
29$privacy_policy_url = isset( $privacy_policy_url ) ? (string) $privacy_policy_url : '';
30$ccpa_url           = isset( $ccpa_url ) ? (string) $ccpa_url : '';
31// Mirror the Block Hooks footer nav-link, which labels this with the CCPA
32// page's own title.
33$ccpa_label = isset( $ccpa_label ) ? (string) $ccpa_label : '';
34?>
35
36<div
37    class="jetpack-cookie-consent-footer-links"
38    data-wp-interactive="jetpack/cookie-consent"
39    data-wp-context='{"fallbackExpanded": false, "isCcpaRegion": false, "isGdprManageLink": false}'
40    data-wp-init="callbacks.init"
41    data-wp-on--keydown="actions.onFallbackKeyDown"
42    hidden
43    data-wp-bind--hidden="!state.showFallbackControl"
44>
45    <button
46        type="button"
47        class="jetpack-cookie-consent-footer-links__toggle"
48        id="jetpack-cookie-consent-footer-links-toggle"
49        aria-haspopup="true"
50        aria-expanded="false"
51        data-wp-bind--aria-expanded="context.fallbackExpanded"
52        aria-controls="jetpack-cookie-consent-footer-links-panel"
53        data-wp-on--click="actions.toggleFallbackPanel"
54    >
55        <span class="jetpack-cookie-consent-footer-links__toggle-icon" aria-hidden="true">
56            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="20" height="20" focusable="false">
57                <path d="M12 4a8 8 0 1 0 0 16 8 8 0 0 0 0-16zm0 1.5a6.5 6.5 0 1 1 0 13 6.5 6.5 0 0 1 0-13zM11.25 7h1.5v1.5h-1.5V7zm0 3h1.5v7h-1.5v-7z"></path>
58            </svg>
59        </span>
60        <span class="jetpack-cookie-consent-footer-links__toggle-text">
61            <?php echo esc_html__( 'Privacy', 'jetpack-cookie-consent' ); ?>
62        </span>
63    </button>
64
65    <div
66        class="jetpack-cookie-consent-footer-links__panel"
67        id="jetpack-cookie-consent-footer-links-panel"
68        role="region"
69        aria-label="<?php echo esc_attr__( 'Privacy links', 'jetpack-cookie-consent' ); ?>"
70        hidden
71        data-wp-bind--hidden="!context.fallbackExpanded"
72    >
73        <ul class="jetpack-cookie-consent-footer-links__list">
74            <?php if ( '' !== $privacy_policy_url ) : ?>
75                <li class="jetpack-cookie-consent-footer-links__item">
76                    <a class="jetpack-cookie-consent-footer-links__link" href="<?php echo esc_url( $privacy_policy_url ); ?>">
77                        <?php echo esc_html__( 'Privacy Policy', 'jetpack-cookie-consent' ); ?>
78                    </a>
79                </li>
80            <?php endif; ?>
81
82            <?php if ( '' !== $ccpa_url ) : ?>
83                <li
84                    class="jetpack-cookie-consent-footer-links__item jetpack-cookie-consent-ccpa-privacy-link-hidden"
85                    data-wp-class--jetpack-cookie-consent-ccpa-privacy-link-hidden="!state.isCcpaRegion"
86                >
87                    <a class="jetpack-cookie-consent-footer-links__link" href="<?php echo esc_url( $ccpa_url ); ?>">
88                        <?php echo esc_html( $ccpa_label ); ?>
89                    </a>
90                </li>
91            <?php endif; ?>
92
93            <li
94                class="jetpack-cookie-consent-footer-links__item jetpack-cookie-consent-gdpr-manage-link-hidden"
95                data-wp-class--jetpack-cookie-consent-gdpr-manage-link-hidden="!context.isGdprManageLink"
96            >
97                <a
98                    class="jetpack-cookie-consent-footer-links__link"
99                    href="#manage-preferences"
100                    data-wp-on--click="actions.openManagePreferences"
101                >
102                    <?php echo esc_html__( 'Manage Privacy Preferences', 'jetpack-cookie-consent' ); ?>
103                </a>
104            </li>
105        </ul>
106    </div>
107</div>