Cookie Consent Snigirev
Most “cookie consent” plugins are just an informational banner: it shows up, the visitor clicks something, the banner disappears — and every tracking script on the page was already running before that click ever happened. That doesn’t satisfy 152-FZ or GDPR, and it wouldn’t hold up if a regulator ev
About this tool.
Most “cookie consent” plugins are just an informational banner: it shows up, the visitor clicks something, the banner disappears — and every tracking script on the page was already running before that click ever happened. That doesn’t satisfy 152-FZ or GDPR, and it wouldn’t hold up if a regulator ever asked “prove the user actually consented before tracking started.”
Cookie Consent Snigirev gates the scripts themselves, not just the banner. Any script you add through the plugin (Yandex Metrika, Google Analytics/GTM, ad pixels, anything) is written to the page as an inert — the browser physically will not execute it. Only after the visitor makes an actual choice (Accept, or ticks the matching category and saves) does the banner’s own JavaScript rewrite that tag into a real <script> and let it run. Reload the page after that, and the plugin reads the stored choice from a cookie and re-activates only the categories the visitor actually agreed to — without showing the banner again. Nothing loads by default except strictly necessary functionality.
Two ways to run it
- Full mode — three categories (necessary/analytics/marketing), a “Customize” button with a detailed per-category breakdown, and a “Save choices” button. Analytics/marketing only appear as separate toggles once you’ve actually added a script for that category in the admin — an empty, non-functional toggle never shows up.
- Simple mode — one switch in the settings turns the whole thing into a plain Accept/Reject notice: no category panel, no “Customize” button. Every non-independent script activates together on Accept. Good fit for sites that don’t need (or don’t want to manage) a category breakdown.
Design, without touching a line of CSS
- Position: top or bottom bar (full width), centered modal, or a corner card (left/right)
- Colors, border radius, shadow, padding, max width — all from the settings screen; any color field also accepts transparent (e.g. to drop the banner’s background strip entirely and show only the floating container)
- Configurable delay before the banner appears, with a smooth fade-in
- A live preview of the banner sits right on the settings screen and updates instantly as you change style or text — no saving, no reloading, no guessing what it’ll look like on the actual site
Editing the banner text
- Banner texts (title, description, category labels/descriptions, button labels) are one flat set of settings-screen fields, in Russian
- The description field (and other long-text fields) uses WordPress’s own visual editor in a stripped-down form — Bold, Italic, and an actual “Insert/edit link” button, instead of hand-typing HTML. That’s also where you link to your privacy policy: there’s no separate privacy-link field to fill in, just link the words directly in the description text
Managing tracking scripts
- A repeater in the admin: name, the script’s own code (HTML/JS), category, and a “load immediately, without consent” flag for the rare case where a tracker (typically an analytics counter) genuinely needs to start before any interaction — that one bypasses the gate entirely and is clearly called out as doing so
- The code field has real syntax highlighting (the same CodeMirror-based editor WordPress uses for Additional CSS and the theme/plugin file editor), not a bare textarea
- Saving the script’s code requires the unfiltered_html capability — on classic multisite that’s normally only the network super admin; everyone else sees the field locked, and the server refuses a modified value even from a direct POST request, not just visually
Everything else
- [snigirev_cookie_settings] shortcode — drop it anywhere (footer, privacy policy page) as a button to reopen the banner so a visitor can change their mind later
- No server-side storage at all — the consent decision lives only in a cookie on the visitor’s own browser; the plugin doesn’t collect or keep any personal data
- Free, and stays that way — nothing here is a trial or a paywalled tier. If it saved you some time, there’s a link to say thanks with a coffee, entirely optional and unrelated to how the plugin works
External Services
This plugin does not send any data to external services. The consent banner and all its logic run entirely client-side (the visitor’s browser) and store the decision only in a cookie — nothing is sent to or stored on any server, including the plugin’s own. The optional donate notice in the admin area (“Угостить кофе” / “Пожертвовать на восстановление монастыря”) consists of plain links the administrator may click — the plugin itself makes no request to any external service because of them.
Установка
- 01Распакуйте архив и загрузите папку snigirev-cookie-consent в /wp-content/plugins/ (или используйте Плагины → Добавить новый → Загрузить плагин на самом архиве)
- 02Активируйте плагин через меню «Плагины»
- 03Настройки → Cookie Consent — настройте стиль баннера, тексты категорий (ссылку на политику конфиденциальности впишите прямо в текст описания через <a href="..."> ) и добавьте скрипты метрики
- 04При необходимости разместите шорткод [snigirev_cookie_settings] на странице политики конфиденциальности, чтобы пользователь мог изменить своё решение
Структура файлов
snigirev-cookie-consent/ ├── snigirev-cookie-consent.php ← заголовок плагина, автозагрузчик, точка входа ├── includes/ │ ├── Core.php ← singleton-фасад, регистрация хуков │ ├── Settings.php ← схема опции, defaults, sanitize │ ├── Shortcode.php ← [snigirev_cookie_settings] │ ├── Admin/SettingsPage.php ← страница настроек (Settings API) │ └── Frontend/ │ ├── Banner.php ← рендер баннера + гейтящихся скриптов (wp_footer) │ └── Scripts.php ← независимые скрипты (wp_head) ├── assets/ │ ├── admin.css / admin.js ← вкладки настроек, репитер скриптов │ └── banner.css / banner.js ← стили и логика согласия на фронтенде ├── uninstall.php └── readme.txt
Безопасность
- Страница настроек требует manage_options
- Поле кода скрипта в репитере сохраняется только при наличии права unfiltered_html у текущего пользователя — без этого права поле недоступно для редактирования в форме (readonly/disabled), и сервер не принимает изменения кода даже при прямом POST-запросе
- Нонсы и проверка option_page — через стандартный механизм settings_fields()/ options.php
- Все обычные поля настроек проходят через sanitize_callback ( sanitize_hex_color , sanitize_text_field , absint , esc_url_raw и т. п.); текстовые поля баннера — через wp_kses() с узким allowlist тегов ( a / strong / em ), а не произвольный HTML
- Согласие хранится только в cookie на стороне клиента — плагин не собирает и не хранит персональные данные на сервере
Соответствие 152-ФЗ
- Баннер прямо называет используемые сервисы аналитики/маркетинга по названию, заданному в репитере скриптов
- Ссылка на политику конфиденциальности добавляется админом прямо в текст описания баннера (поддерживается тег <a> )
- По умолчанию не активируется ничего, кроме необходимых cookie, до явного действия пользователя
Известные ограничения
- Если пользователь дал согласие на категорию, скрипт этой категории успел выполниться в текущей загрузке страницы, а затем пользователь через шорткод [snigirev_cookie_settings] отозвал согласие на эту же категорию — уже выполнившийся код (например уже инициализированный счётчик метрики) технически не может быть «отменён» на лету, это ограничение самого приёма гейтинга через type="text/plain" . Новое решение сохраняется в cookie и будет учтено при следующей загрузке страницы.
Поддержать разработку
Плагин бесплатный и таким останется — донат ни на что не влияет и не открывает скрытых функций. Если плагин сэкономил вам время, можно угостить разработчика кофе: https://sdelayusait.ru/