Repository navigation
Releases
Releases · owebstudio/kirby-detect-adblock
2.0.0
Kirby Detect Ad Block now works on Kirby 5 and Kirby 6, with an accessible warning, a banner mode and more reliable detection.
New
- Banner mode. Set
modeto'banner'for a gentle hint at the bottom of the page instead of a blocking dialog. Visitors can close it, and it then stays hidden for 7 days (therememberoption, stored in the browser, no cookie). - Translations. The texts are translated into English, German and Turkish and follow the language of the page. Each text option can also be an array with one text per language code, and every option can be passed to the snippet.
- More reliable detection. The plugin now uses bait elements that current filter lists hide, and a small bait script served by your own site that ad blockers block. A missing file never shows the warning, and no request goes to another domain.
- JavaScript events.
adblock:checkedandadblock:detectedlet you react in your own way. Callevent.preventDefault()to skip the plugin's warning, or setmodetofalseto only run the check.
Fixed
- The warning now opens above sticky headers and menus. It used
z-index: 2before. - The warning is a real modal dialog: focus moves into it, the page behind it can't be used, and screen readers announce it.
- Custom overlay snippets no longer break the script.
- The inline script and styles use Kirby's nonce, so the plugin works with a Content Security Policy.
Breaking changes
- Requires Kirby 5 or 6 and PHP 8.2 or newer. For Kirby 3 and 4, keep using 1.0.2.
- The warning is a
<dialog>with the classesdetect-adblockanddetect-adblock-banner. The IDsdetectAdBlockOverlayanddetectAdBlockInfoare gone, so update your own CSS for them. - The texts are escaped. To use HTML, override the
detect-adblock-overlaysnippet. - The default texts changed. Set the
title,textandbuttonoptions to keep your own. - A custom
detect-adblock-overlaysnippet needs thedata-detect-adblockattribute on the warning. Snippets with the IDdetectAdBlockOverlaystill work.
See the README for all options and the upgrade notes.
Repository: https://github.com/owebstudio/kirby-detect-adblock
License: MIT, see LICENSE