bootscore/bs-cookie-settings
Composer 安装命令:
composer require bootscore/bs-cookie-settings
包简介
Adds a cookie consent banner to Bootscore
README 文档
README
Read this in
WordPress plugin to add a GDPR-ready cookie consent to Bootscore theme. Based on the cookieconsent script by Orest Bida.
Installation
- Download latest release bs-cookie-settings.zip.
- In your admin panel, go to Plugins > and click the Add New button.
- Click Upload Plugin and Choose File, then select the Plugin's .zip file. Click Install Now.
- Click Activate to use your new Plugin right away.
Usage
Init
Initialize plugin with inline script in a Custom HTML widget in Footer Info widget position and replace your data.
<script> // Init window.addEventListener('load', function () { // obtain plugin var cc = initCookieConsent(); // run plugin with your configuration cc.run({ current_lang: 'en', autoclear_cookies: true, page_scripts: true, languages: { 'en': { consent_modal: { title: 'We use cookies!', description: 'We use cookies on our website to enhance your browsing experience by remembering your preferences and analyzing site traffic. By clicking "Accept all", you consent to the use of all cookies. However, you can manage your <a data-bs-toggle="modal" href="#bs-cookie-modal">cookie preferences</a> to provide a controlled consent.', primary_btn: { text: 'Accept all', role: 'accept_all' }, secondary_btn: { text: 'Reject all', role: 'accept_necessary' }, settings_btn: { text: 'Manage preferences' }, consent_footer: { description: '<a class="small link-secondary text-decoration-none" href="#">Privacy Policy</a> • <a class="small link-secondary text-decoration-none" href="#">Terms & Conditions</a> • <a class="small link-secondary text-decoration-none" href="#">Imprint</a>' } }, settings_modal: { title: 'Cookie preferences', save_settings_btn: 'Save preferences', accept_all_btn: 'Accept all', reject_all_btn: 'Reject all', close_btn_label: 'Close', cookie_table_headers: [ { col1: 'Name' }, { col2: 'Domain' }, { col3: 'Expiration' }, { col4: 'Description' } ], blocks: [ { title: 'Cookie usage', description: 'We use cookies to ensure the basic functionalities of the website and to enhance your online experience. You can choose for each category to opt-in/out whenever you want. For more details relative to cookies and other sensitive data, please read the full <a href="#">Privacy Policy</a>.' }, { title: 'Necessary', description: 'These cookies are essential for the proper functioning of our website. Without these cookies, the website would not work properly', toggle: { value: 'necessary', enabled: true, readonly: true // cookie categories with readonly=true are all treated as "necessary cookies" }, cookie_table: [ // list of all expected cookies { col1: 'bs_cookie_settings', // match all cookies starting with "_ga" col2: 'yourdomain.com', col3: '182 days', col4: 'Used to remember your cookie preferences.', is_regex: true } ] }, { title: 'Analytics', description: 'These cookies allow the website to remember the choices you have made in the past', toggle: { value: 'analytics', // your cookie category enabled: false, readonly: false }, cookie_table: [ // list of all expected cookies { col1: '^_ga', // match all cookies starting with "_ga" col2: 'google.com', col3: '2 years', col4: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.', is_regex: true }, { col1: '_gid', col2: 'google.com', col3: '1 day', col4: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.', } ] }, { title: 'Advertising', description: 'These cookies collect information about how you use the website, which pages you visited and which links you clicked on. All of the data is anonymized and cannot be used to identify you', toggle: { value: 'advertising', enabled: false, readonly: false }, cookie_table: [ // list of all expected cookies { col1: '_name', col2: 'xyz.com', col3: '2 weeks', col4: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.', is_regex: true }, { col1: '_name', col2: 'xyz.com', col3: '3 days', col4: 'Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.', } ] }, { title: 'More information', description: 'For any queries in relation to our policy on cookies and your choices, please <a href="#yourcontactpage">contact us</a>.', }, ] } } } }); }); </script>
Block / manage scripts
Set type="text/plain" and data-cookiecategory="<category>" to any script tag you want to manage. Use inline-script in a Custom HTML widget in Footer Info position after the init script.
<!-- Google Analytics --> <script type="text/plain" data-cookiecategory="analytics"> // Code goes here </script> <!-- Advertising --> <script type="text/plain" data-cookiecategory="advertising"> // Code goes here </script>
Open preferences modal
By clicking one of the "Accept all", "Reject all" or "Save preferences" button, the cookie bs_cookie_settings is set with your preferences and hides banner and modal for 182 days. To open preferences modal again, add following link to your privacy policy and to a Custom HTML widget in a Footer widget position.
Link
<a data-bs-toggle="modal" href="#bs-cookie-modal">Cookie Preferences</a>
Button
<button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#bs-cookie-modal">Cookie Preferences</button>
License & Credits
- cookieconsent script by Orest Bida, MIT License https://github.com/orestbida/cookieconsent/blob/master/LICENSE
- Plugin Update Checker by YahnisElsts, MIT License https://github.com/YahnisElsts/plugin-update-checker/blob/master/license.txt
- bs Cookie Settings, MIT License https://github.com/bootscore/bs-cookie-settings/blob/main/LICENSE
bootscore/bs-cookie-settings 适用场景与选型建议
bootscore/bs-cookie-settings 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 85 次下载、GitHub Stars 达 9, 最近一次更新时间为 2023 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「plugin」 「bootstrap」 「wordpress」 「contact form 7」 「bootscore」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 bootscore/bs-cookie-settings 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bootscore/bs-cookie-settings 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 bootscore/bs-cookie-settings 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
CakePHP 4.x AdminLTE Theme.
Views for the package MedicOneSystems Livewire Datatables with Bootstrap 4
bootstrap select field module implementing http://silviomoreto.github.io/bootstrap-select/
Selectize Theme for Bootstrap 4
Plugin for YOURLS. Default tools to use in some laemmi plugins
Cross browser time implementation using CSS and JQuery. Compatible with Twitter Bootstrap
统计信息
- 总下载量: 85
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 17
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-09