1+ <?php
2+
3+ $ appeal_start = strtotime ('2026-07-01 00:00:00 ' );
4+ $ appeal_end = strtotime ('2026-07-16 23:59:59 ' );
5+
6+ $ now = time ();
7+ $ voting_appeal_active = ($ now >= $ appeal_start && $ now <= $ appeal_end );
8+
9+ // Admin override for testing (e.g. ?show_voting_appeal=1 / ?show_voting_appeal=0)
10+ if (isset ($ _GET ['show_voting_appeal ' ])) {
11+ $ voting_appeal_active = $ _GET ['show_voting_appeal ' ] === '1 ' ;
12+ }
13+
14+ // Expanded by default; remember if the user has collapsed it (own cookie, lasts 1 week).
15+ // Uses a distinct cookie name so collapsing the appeal does not affect the standard
16+ // donation banner shown on other MP pages, and vice-versa.
17+ $ appeal_expanded = !isset ($ _COOKIE ['voting_appeal_collapsed ' ]);
18+
19+ $ current_page = isset ($ pagetype ) && $ pagetype ? $ pagetype : 'votes ' ;
20+ $ utm = 'utm_source= ' . urlencode ($ current_page ) . '&utm_campaign=twfy_voting_appeal ' ;
21+ ?>
22+
23+ <?php if ($ voting_appeal_active ) { ?>
24+ <div class="panel panel--donation-banner panel--donation-banner--appeal" id="voting-appeal">
25+ <div class="donation-banner__content">
26+ <div class="donation-banner__header">
27+ <h3 class="donation-banner__title">
28+ <span class="donation-banner__icon">💚</span>
29+ We've updated our voting summaries
30+ </h3>
31+ <button class="donation-banner__toggle js-voting-appeal-toggle" aria-expanded="<?= $ appeal_expanded ? 'true ' : 'false ' ?> " aria-controls="voting-appeal-details">
32+ <span class="donation-banner__toggle-text">Why we need your support</span>
33+ <span class="donation-banner__toggle-arrow">↓</span>
34+ </button>
35+ </div>
36+
37+ <div id="voting-appeal-details" class="donation-banner__details<?= $ appeal_expanded ? ' is-open ' : '' ?> ">
38+ <div class="donation-banner__message">
39+ <p>
40+ Our small team <a href="https://www.mysociety.org/2026/07/01/theyworkforyou-voting-summaries-update-july-2026/">works hard</a> to show how your MP has voted on the issues that matter to you.
41+ </p>
42+ <p>
43+ Your donations help keep TheyWorkForYou running and independent. If it's useful to you, please help keep it going.
44+ </p>
45+ </div>
46+
47+ <div class="donation-banner__actions">
48+ <a href="/support-us/?<?= $ utm ?> #donate-form" class="button tertiary">
49+ Support TheyWorkForYou
50+ </a>
51+ <a href="/support-us/?how-often=monthly&how-much=5&<?= $ utm ?> #donate-form" class="button button--outline">
52+ £5/month
53+ </a>
54+ <a href="/support-us/?how-often=one-off&how-much=10&<?= $ utm ?> #donate-form" class="button button--outline">
55+ £10 one-off
56+ </a>
57+ </div>
58+ </div>
59+ </div>
60+ </div>
61+
62+ <script>
63+ // Toggle functionality for the voting appeal banner
64+ (function() {
65+ const toggle = document.querySelector('.js-voting-appeal-toggle');
66+ const details = document.querySelector('#voting-appeal-details');
67+
68+ if (toggle && details) {
69+ toggle.addEventListener('click', function() {
70+ const isExpanded = toggle.getAttribute('aria-expanded') === 'true';
71+
72+ if (isExpanded) {
73+ details.classList.remove('is-open');
74+ toggle.setAttribute('aria-expanded', 'false');
75+
76+ // Set cookie to remember collapsed state for 1 week
77+ var expires = new Date();
78+ expires.setTime(expires.getTime() + (7 * 24 * 60 * 60 * 1000)); // 7 days
79+ document.cookie = 'voting_appeal_collapsed=1;expires=' + expires.toUTCString() + ';path=/';
80+ } else {
81+ details.classList.add('is-open');
82+ toggle.setAttribute('aria-expanded', 'true');
83+
84+ // Remove the collapsed cookie
85+ document.cookie = 'voting_appeal_collapsed=;expires=Thu, 01 Jan 1970 00:00:00 UTC;path=/';
86+ }
87+ });
88+ }
89+ })();
90+ </script>
91+ <?php } else { ?>
92+ <?php
93+ // Outside the campaign window, fall back to the standard 20% donation banner.
94+ include __DIR__ . '/_donation_banner.php ' ;
95+ ?>
96+ <?php }; ?>
0 commit comments