Admin watchdog notice when an ad blocker blocks cookie-policy.js / cookies.js#172
Conversation
…s/cookies.js The Cookie Policy and Cookies admin pages are driven by per-page scripts whose filenames contain "cookie" (cookie-policy.js / cookies.js). Ad blockers and browser privacy shields (e.g. Brave Shield) match those names and block the file, leaving the page silently inert — Save/Preview and the buttons do nothing. The form already refuses the native submit (no blank-page data loss, 1.20.0), but there was no feedback, so the only symptom was "the button does not work" (support topic: Cookie Policy saving issue). Each page script now sets a window.faz*Booted flag the instant it runs, and each view renders a hidden, server-translated 'notice notice-error' plus a tiny INLINE watchdog that reveals it if the flag is still unset 2.5s after load. Inline first-party script is not blocked the way the external .js file is, so the actionable message always reaches the user. Filenames stay descriptive on purpose — renaming is whack-a-mole against filter lists and costs readability. E2E: tests/e2e/specs/admin-blocked-script-watchdog.spec.ts (4).
Fix groups (committed): - [FG-1] F001, F002, F003, F006, F007, F010 — admin/views/cookie-policy.php, admin/views/cookies.php, admin/class-admin.php: verified Post-fix review: 1/1 groups verified complete; 0 partial; 0 reverted. Findings addressed (from /adamsreview code review): - F001/F002: replace the blind 2500ms watchdog timer with window-load-keyed detection plus hide-on-boot recovery, so a slow (non-blocked) footer script no longer triggers a false "ad blocker" notice and the notice clears if the script later loads. - F006/F007: move the watchdog inline script out of the view templates into wp_add_inline_script for the faz-page-cookie-policy / faz-page-cookies handles in class-admin.php, mirroring admin/views/languages.php (Plugin-Check clean). - F003/F010: announce the blocked-script notice via an aria-live assertive region populated on reveal, instead of role="alert" on a display:none element. E2E tests/e2e/specs/admin-blocked-script-watchdog.spec.ts: 4/4 green.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
WalkthroughLa PR aggiunge un meccanismo watchdog per rilevare script admin bloccati (ad-blocker/privacy shield). Gli script cookie-policy.js e cookies.js impostano flag globali di boot; class-admin.php inietta uno script inline che controlla i flag e mostra/nasconde notice nelle relative view PHP; aggiunti test e2e Playwright. ChangesWatchdog script bloccato
Estimated code review effort: 2 (Simple) | ~15 minutes Related PRs: Nessuna informazione disponibile nel contesto fornito. Suggested labels: enhancement, accessibility, tests Suggested reviewers: Nessuna informazione disponibile nel contesto fornito. Poem: Un coniglio digitale scava nel codice quieto, / tra flag booleani e un template segreto. / Se un ad-blocker ferma lo script in corsa, / spunta la notice, l'annuncio si forza. / E-e-test verificano tutto in un balzo lieto! 🐰 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 PHPStan (2.2.2)PHPStan was skipped because the config uses disallowed Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
reveal() set msg.textContent = tpl.innerHTML, which re-serializes the <template>'s parsed content back into HTML entities and then writes the literal entity (e.g. &) for any localized string containing &, <, or >. Read tpl.content.textContent instead — the parsed DocumentFragment's decoded text. (No effect on the shipped English string, which has no such characters; this hardens localized strings.)
Summary
Adds an admin-side watchdog notice for when a visitor's ad blocker (or a privacy extension) blocks the plugin's own front-end assets —
cookie-policy.js/cookies.js. When those scripts are blocked, the cookie policy table and the cookie-list widget silently fail to render; this surfaces a clear admin notice so the operator understands the cause instead of chasing a phantom "broken banner" bug.Notes
Summary by CodeRabbit
Nuove funzionalità
Bug Fixes