├── .gitignore ├── assets ├── screenshot-1.png ├── screenshot-2.png ├── screenshot-3.png ├── screenshot-4.png ├── css │ └── admin.css ├── cookie-consent │ ├── cookieconsent.min.css │ └── cookieconsent.min.js └── js │ └── scripts.js ├── cookieconsent-wpplugin.code-workspace ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ └── bug_report.md └── workflows │ └── codeql-analysis.yml ├── README.md ├── readme.txt └── osano-cookie-consent.php /.gitignore: -------------------------------------------------------------------------------- 1 | #FILES 2 | .DS_Store 3 | .idea 4 | .project 5 | .strong-pm 6 | .vscode 7 | .code-workspace 8 | -------------------------------------------------------------------------------- /assets/screenshot-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osano/cookieconsent-wpplugin/HEAD/assets/screenshot-1.png -------------------------------------------------------------------------------- /assets/screenshot-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osano/cookieconsent-wpplugin/HEAD/assets/screenshot-2.png -------------------------------------------------------------------------------- /assets/screenshot-3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osano/cookieconsent-wpplugin/HEAD/assets/screenshot-3.png -------------------------------------------------------------------------------- /assets/screenshot-4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/osano/cookieconsent-wpplugin/HEAD/assets/screenshot-4.png -------------------------------------------------------------------------------- /cookieconsent-wpplugin.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Cookie Consent is designed to make it easy for you comply with the EU Cookie Law. 2 | 3 | The official Cookie Consent WordPress plugin has all the functionality [Cookie Consent configurator](https://cookieconsent.osano.com/download/ "Cookie Consent JS plugin page") on your own site's admin panel. 4 | In addition to that you can use custom code, to access the full functionality of Cookie Consent. 5 | 6 | ## Installation 7 | 8 | 1. Upload the plugin files to the `/wp-content/plugins/osano-cookie-consent` directory, or install the plugin through the WordPress plugins screen directly. 9 | 2. Activate the plugin through the 'Plugins' screen in WordPress. 10 | 3. Use the Settings->Cookieconsent to enable and configure the cookie consent popup. 11 | 12 | ## License 13 | 14 | Code released under the [MIT licence](http://opensource.org/licenses/MIT). 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **To Reproduce** 14 | Steps to reproduce the behavior: 15 | 1. Go to '...' 16 | 2. Click on '....' 17 | 3. Scroll down to '....' 18 | 4. See error 19 | 20 | **Expected behavior** 21 | A clear and concise description of what you expected to happen. 22 | 23 | **Screenshots** 24 | If applicable, add screenshots to help explain your problem. 25 | 26 | **Desktop (please complete the following information):** 27 | - OS: [e.g. iOS] 28 | - Browser [e.g. chrome, safari] 29 | - Version [e.g. 22] 30 | 31 | **Smartphone (please complete the following information):** 32 | - Device: [e.g. iPhone6] 33 | - OS: [e.g. iOS8.1] 34 | - Browser [e.g. stock browser, safari] 35 | - Version [e.g. 22] 36 | 37 | **Additional context** 38 | Add any other context about the problem here. 39 | -------------------------------------------------------------------------------- /assets/css/admin.css: -------------------------------------------------------------------------------- 1 | .form-table { 2 | max-width: 600px; 3 | margin-bottom: 40px; 4 | } 5 | 6 | .form-table td { 7 | background: white; 8 | width: 50%; 9 | font-size: 15px; 10 | padding: 20px; 11 | vertical-align: top; 12 | line-height: 2; 13 | } 14 | 15 | .form-table th { 16 | padding: 30px 5px 5px 5px; 17 | } 18 | 19 | .choose-colours input[type=radio]+label { 20 | transition: all .3s ease-in-out; 21 | padding: 3px; 22 | margin-right: 3px; 23 | } 24 | 25 | .choose-colours input[type=radio]:checked+label, 26 | .choose-colours input[type=radio]:hover+label { 27 | border-bottom: 4px solid #c0c0c0; 28 | } 29 | 30 | .theme-preview-container { 31 | display: inline-block; 32 | height: 20px; 33 | width: 35px; 34 | padding: 5px; 35 | margin-top: 10px; 36 | } 37 | 38 | .theme-preview-button { 39 | height: 10px; 40 | width: 15px; 41 | margin-top: 10px; 42 | margin-left: 20px; 43 | } 44 | .input-hidden { 45 | position: absolute; 46 | left: -9999px; 47 | } 48 | 49 | .form-table textarea, .form-table input[type=text] { 50 | width: 100%; 51 | padding: 5px 10px; 52 | } -------------------------------------------------------------------------------- /.github/workflows/codeql-analysis.yml: -------------------------------------------------------------------------------- 1 | name: "Code scanning - action" 2 | 3 | on: 4 | push: 5 | branches: [master, ] 6 | pull_request: 7 | # The branches below must be a subset of the branches above 8 | branches: [master] 9 | schedule: 10 | - cron: '0 4 * * 4' 11 | 12 | jobs: 13 | CodeQL-Build: 14 | 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Checkout repository 19 | uses: actions/checkout@v2 20 | with: 21 | # We must fetch at least the immediate parents so that if this is 22 | # a pull request then we can checkout the head. 23 | fetch-depth: 2 24 | 25 | # If this run was triggered by a pull request event, then checkout 26 | # the head of the pull request instead of the merge commit. 27 | - run: git checkout HEAD^2 28 | if: ${{ github.event_name == 'pull_request' }} 29 | 30 | # Initializes the CodeQL tools for scanning. 31 | - name: Initialize CodeQL 32 | uses: github/codeql-action/init@v1 33 | # Override language selection by uncommenting this and choosing your languages 34 | # with: 35 | # languages: go, javascript, csharp, python, cpp, java 36 | 37 | # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). 38 | # If this step fails, then you should remove it and run the build manually (see below) 39 | - name: Autobuild 40 | uses: github/codeql-action/autobuild@v1 41 | 42 | # ℹ️ Command-line programs to run using the OS shell. 43 | # 📚 https://git.io/JvXDl 44 | 45 | # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines 46 | # and modify them (or add more) to build your code if your project 47 | # uses a compiled language 48 | 49 | #- run: | 50 | # make bootstrap 51 | # make release 52 | 53 | - name: Perform CodeQL Analysis 54 | uses: github/codeql-action/analyze@v1 55 | -------------------------------------------------------------------------------- /readme.txt: -------------------------------------------------------------------------------- 1 | === Osano Cookie Consent === 2 | Contributors: piupiiu 3 | Tags: cookie, cookieconsent, cookielaw, osano, silktide, insites 4 | Requires at least: 4.0 5 | Tested up to: 4.6.1 6 | Stable tag: trunk 7 | License: MIT 8 | License URI: https://opensource.org/licenses/MIT 9 | 10 | The official Cookie Consent WordPress plugin. Alerts users about the use of cookies on your website. 11 | 12 | == Description == 13 | 14 | Cookie Consent is designed to help you easily comply with the EU Cookie Law. 15 | 16 | The official Cookie Consent WordPress plugin has all the functionality [Cookie Consent configurator](https://cookieconsent.osano.com/download/ "Cookie Consent JS plugin page") on your own site's admin panel. 17 | In addition to that you can use custom code, to access the full functionality of Cookie Consent. 18 | 19 | Why choose Osano Cookie Consent? 20 | * Cookie Consent is the most popular Cookie plugin on the planet, it is seen over 2 BILLION times every month. 21 | * Official plugin uses that the latest version of [Cookie Consent](https://cookieconsent.osano.com/ "Cookie Consent JS plugin page"). 22 | * Only shows the banner in countries where you need it. 23 | * Super configurable. Choose your own colours, styles, type of compliance, text and more with a few clicks of the mouse. 24 | * The world’s most popular. Cookie Consent is seen over 2 billion times every month, across hundreds of thousands of websites. 25 | 26 | == Installation == 27 | 28 | 1. Upload the plugin files to the `/wp-content/plugins/osano-cookie-consent` directory, or install the plugin through the WordPress plugins screen directly. 29 | 1. Activate the plugin through the 'Plugins' screen in WordPress. 30 | 1. Use the Settings->Cookieconsent to enable and configure the cookie consent popup. 31 | 32 | == Screenshots == 33 | 34 | 1. Standard informational popup 35 | 2. Opt-out style popup with custom text 36 | 3. Configuration page 37 | 4. You can use custom attributes to get even more functionality 38 | -------------------------------------------------------------------------------- /assets/cookie-consent/cookieconsent.min.css: -------------------------------------------------------------------------------- 1 | .cc-window{opacity:1;transition:opacity 1s ease}.cc-window.cc-invisible{opacity:0}.cc-animate.cc-revoke{transition:transform 1s ease}.cc-animate.cc-revoke.cc-top{transform:translateY(-2em)}.cc-animate.cc-revoke.cc-bottom{transform:translateY(2em)}.cc-animate.cc-revoke.cc-active.cc-bottom,.cc-animate.cc-revoke.cc-active.cc-top,.cc-revoke:hover{transform:translateY(0)}.cc-grower{max-height:0;overflow:hidden;transition:max-height 1s} 2 | .cc-link,.cc-revoke:hover{text-decoration:underline}.cc-revoke,.cc-window{position:fixed;overflow:hidden;box-sizing:border-box;font-family:Helvetica,Calibri,Arial,sans-serif;font-size:16px;line-height:1.5em;display:-ms-flexbox;display:flex;-ms-flex-wrap:nowrap;flex-wrap:nowrap;z-index:9999}.cc-window.cc-static{position:static}.cc-window.cc-floating{padding:2em;max-width:24em;-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner{padding:1em 1.8em;width:100%;-ms-flex-direction:row;flex-direction:row}.cc-revoke{padding:.5em}.cc-header{font-size:18px;font-weight:700}.cc-btn,.cc-close,.cc-link,.cc-revoke{cursor:pointer}.cc-link{opacity:.8;display:inline-block;padding:.2em}.cc-link:hover{opacity:1}.cc-link:active,.cc-link:visited{color:initial}.cc-btn{display:block;padding:.4em .8em;font-size:.9em;font-weight:700;border-width:2px;border-style:solid;text-align:center;white-space:nowrap}.cc-banner .cc-btn:last-child{min-width:140px}.cc-highlight .cc-btn:first-child{background-color:transparent;border-color:transparent}.cc-highlight .cc-btn:first-child:hover{background-color:transparent;text-decoration:underline}.cc-close{display:block;position:absolute;top:.5em;right:.5em;font-size:1.6em;opacity:.9;line-height:.75}.cc-close:hover{opacity:1} 3 | .cc-revoke.cc-top{top:0;left:3em;border-bottom-left-radius:.5em;border-bottom-right-radius:.5em}.cc-revoke.cc-bottom{bottom:0;left:3em;border-top-left-radius:.5em;border-top-right-radius:.5em}.cc-revoke.cc-left{left:3em;right:unset}.cc-revoke.cc-right{right:3em;left:unset}.cc-top{top:1em}.cc-left{left:1em}.cc-right{right:1em}.cc-bottom{bottom:1em}.cc-floating>.cc-link{margin-bottom:1em}.cc-floating .cc-message{display:block;margin-bottom:1em}.cc-window.cc-floating .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-banner{-ms-flex-align:center;-ms-grid-row-align:center;align-items:center}.cc-banner.cc-top{left:0;right:0;top:0}.cc-banner.cc-bottom{left:0;right:0;bottom:0}.cc-banner .cc-message{-ms-flex:1;flex:1}.cc-compliance{display:-ms-flexbox;display:flex;-ms-flex-align:center;align-items:center;-ms-flex-line-pack:justify;align-content:space-between}.cc-compliance>.cc-btn{-ms-flex:1;flex:1}.cc-btn+.cc-btn{margin-left:.5em} 4 | @media print{.cc-revoke,.cc-window{display:none}}@media screen and (max-width:900px){.cc-btn{white-space:normal}}@media screen and (max-width:414px) and (orientation:portrait),screen and (max-width:736px) and (orientation:landscape){.cc-window.cc-top{top:0}.cc-window.cc-bottom{bottom:0}.cc-window.cc-banner,.cc-window.cc-left,.cc-window.cc-right{left:0;right:0}.cc-window.cc-banner{-ms-flex-direction:column;flex-direction:column}.cc-window.cc-banner .cc-compliance{-ms-flex:1;flex:1}.cc-window.cc-floating{max-width:none}.cc-window .cc-message{margin-bottom:1em}.cc-window.cc-banner{-ms-flex-align:unset;-ms-grid-row-align:unset;align-items:unset}} 5 | .cc-floating.cc-theme-classic{padding:1.2em;border-radius:5px}.cc-floating.cc-type-info.cc-theme-classic .cc-compliance{text-align:center;display:inline;-ms-flex:none;flex:none}.cc-theme-classic .cc-btn{border-radius:5px}.cc-theme-classic .cc-btn:last-child{min-width:140px}.cc-floating.cc-type-info.cc-theme-classic .cc-btn{display:inline-block} 6 | .cc-theme-edgeless.cc-window{padding:0}.cc-floating.cc-theme-edgeless .cc-message{margin:2em 2em 1.5em}.cc-banner.cc-theme-edgeless .cc-btn{margin:0;padding:.8em 1.8em;height:100%}.cc-banner.cc-theme-edgeless .cc-message{margin-left:1em}.cc-floating.cc-theme-edgeless .cc-btn+.cc-btn{margin-left:0} -------------------------------------------------------------------------------- /assets/js/scripts.js: -------------------------------------------------------------------------------- 1 | jQuery(function() { 2 | 3 | var form = document.getElementById('cc-options-form'); 4 | form.onchange = function () { update(); }; 5 | 6 | loadThemeSelector(selected); 7 | 8 | function update () { 9 | setCode(getOptions(getInputs(form))); 10 | updateForm(form); 11 | } 12 | 13 | function setCode (config) { 14 | optionsField = jQuery('#icc_popup_options'); 15 | if(typeof config != 'object') { 16 | optionsField.val('{'+config+'}'); 17 | } 18 | else { 19 | var code = JSON.stringify(config); 20 | optionsField.val(code); 21 | } 22 | } 23 | 24 | function getOptions(input) { 25 | if (input.custom) return input.custom; 26 | var content = {}; 27 | var options = {}; 28 | 29 | var t = input.text; 30 | //if (t.header) content.header = t.header; 31 | if (t.message) content.message = escapeHtml(t.message); 32 | if (t.dismiss) content.dismiss = escapeHtml(t.dismiss); 33 | if (t.allow) content.allow = escapeHtml(t.allow); 34 | if (t.deny) content.deny = escapeHtml(t.deny); 35 | if (t.link) content.link = escapeHtml(t.link); 36 | 37 | options.palette = getThemes()[input.theme]; 38 | 39 | if (input.layout == 'wire') { 40 | options.palette.button.border = options.palette.button.background; 41 | options.palette.button.background = 'transparent'; 42 | options.palette.button.text = options.palette.button.border; 43 | 44 | } 45 | 46 | //remove link if user didnt fill in field 47 | if(input.policy == 'policylink') { 48 | input.href ? content.href = input.href : options.showLink = false; 49 | } 50 | 51 | // only add if not default 52 | if(input.layout != 'block' && input.layout != 'wire') options.theme = input.layout; 53 | if(input.position != 'bottom') { 54 | if(input.position == 'top-push') { 55 | options.position = 'top'; 56 | options.static = true; 57 | } 58 | else options.position = input.position; 59 | } 60 | if(input.compliance != 'info') options.type = input.compliance; 61 | 62 | //if has any content, add content 63 | for(var key in content) { 64 | if (content.hasOwnProperty(key)) { 65 | options.content = content; 66 | break; 67 | } 68 | } 69 | 70 | return options; 71 | } 72 | 73 | function getInputs (elem) { 74 | return { 75 | text: { 76 | allow: elem.querySelector('[name="allow-text"]').value, 77 | link: elem.querySelector('[name="link-text"]').value, 78 | message: elem.querySelector('[name="message-text"]').value, 79 | deny: elem.querySelector('[name="deny-text"]').value, 80 | dismiss: elem.querySelector('[name="dismiss-text"]').value, 81 | }, 82 | href: elem.querySelector('[name="link-href"]').value, 83 | policy: elem.querySelectorAll('[name="policy"]:checked').item(0).value, 84 | position: elem.querySelectorAll('[name="choose-position"]:checked').item(0).value, 85 | layout: elem.querySelectorAll('[name="choose-layout"]:checked').item(0).value, 86 | theme: elem.querySelectorAll('[name="theme-selector"]:checked').item(0).value, 87 | compliance: elem.querySelectorAll('[name="choose-cookie-compliance"]:checked').item(0).value, 88 | custom: elem.querySelector('[name="custom-attributes"]').value 89 | } 90 | } 91 | 92 | function escapeHtml(html) { 93 | // let the spec decide how to escape the html 94 | var text = document.createTextNode(html); 95 | var div = document.createElement('div'); 96 | div.appendChild(text); 97 | return div.innerHTML; 98 | } 99 | 100 | function updateForm(form) { 101 | document.getElementById('text-policylink-container').style.display = (form.querySelectorAll('[name="policy"]:checked').item(0).value == 'policylink' && form.querySelector('[name="link-href"]').value == '') ? 'none' : 'inline'; 102 | document.getElementById('text-accept-container').style.display = form.querySelectorAll('[name="choose-cookie-compliance"]:checked').item(0).value != 'opt-in' ? 'none' : 'inline'; 103 | document.getElementById('text-deny-container').style.display = form.querySelectorAll('[name="choose-cookie-compliance"]:checked').item(0).value != 'opt-out' ? 'none' : 'inline'; 104 | } 105 | 106 | function loadThemeSelector(selected) { 107 | var themes = getThemes(); 108 | var container = jQuery('#choose-colours'); 109 | var isChecked = false; 110 | for (var key in themes) { 111 | var html = ''; 112 | var checked = ''; 113 | if (selected && selected == key) isChecked = false; 114 | if (!isChecked) { 115 | checked = 'checked'; 116 | isChecked = true; 117 | } 118 | var sel = getThemes()[key]; 119 | html += ''; 120 | html += ''; 122 | container.append(html); 123 | } 124 | } 125 | 126 | function getThemes() { 127 | return { 128 | theme1: {"popup": {"background": '#000'},"button": {"background": '#f1d600'}}, 129 | theme2: {"popup": {"background": "#eaf7f7", "text":"#5c7291"},"button":{"background": "#56cbdb", "text":"#ffffff"}}, 130 | theme3: {"popup": {"background": '#252e39'},"button": {"background": '#14a7d0'}}, 131 | theme4: {"popup": {"background": '#000', "text": '#0f0'},"button": {"background": '#0f0'}}, 132 | theme5: {"popup": {"background": '#3937a3'},"button": {"background": '#e62576'}}, 133 | theme6: {"popup": {"background":"#64386b","text":"#ffcdfd"},"button": {"background":"#f8a8ff","text":"#3f0045"}}, 134 | theme7: {"popup":{"background":"#237afc"},"button":{"background":"#fff","text":"#237afc"}}, 135 | theme8: {"popup":{"background":"#aa0000","text":"#ffdddd"},"button":{"background":"#ff0000"}}, 136 | theme9: {"popup":{"background":"#383b75"},"button":{"background":"#f1d600"}}, 137 | theme10: {"popup":{"background":"#1d8a8a"},"button":{"background":"#62ffaa"}}, 138 | theme11: {"popup":{"background":"#edeff5","text":"#838391"},"button":{"background":"#4b81e8"}}, 139 | theme12: {"popup":{"background":"#343c66","text":"#cfcfe8"},"button":{"background":"#f71559"}}, 140 | theme13: {"popup":{"background":"#216942","text":"#b2d192"},"button":{"background":"#afed71"}}, 141 | theme14: {"popup":{"background":"#3c404d","text":"#d6d6d6"},"button":{"background":"#8bed4f"}}, 142 | theme15: {"popup":{"background":"#eb6c44","text":"#ffffff"},"button":{"background":"#f5d948"}}, 143 | theme16: {"popup":{"background":"#efefef","text":"#404040"},"button":{"background":"#8ec760","text":"#ffffff"}} 144 | }; 145 | } 146 | 147 | update(); 148 | 149 | }); -------------------------------------------------------------------------------- /osano-cookie-consent.php: -------------------------------------------------------------------------------- 1 | window.cookieconsent.initialise('.$config.');'; 33 | } 34 | } 35 | add_action( 'wp_footer', 'icc_create_snippet' ); 36 | 37 | function icc_menu() { 38 | $page = add_options_page( 39 | 'Cookieconsent options', 40 | 'Cookieconsent', 41 | 'manage_options', 42 | 'icc-options', 43 | 'icc_options_page' 44 | ); 45 | add_action('admin_print_scripts-' . $page, 'icc_load_admin_scripts'); 46 | } 47 | add_action( 'admin_menu', 'icc_menu' ); 48 | 49 | function icc_load_admin_scripts() { 50 | $src = plugins_url( '/assets/js/scripts.js', __FILE__ ); 51 | wp_register_script( 'cookieconsent-admin-script', $src, array(), PLUGINVERSION ); 52 | wp_enqueue_script( 'cookieconsent-admin-script' ); 53 | $src2 = plugins_url( '/assets/css/admin.css', __FILE__ ); 54 | wp_register_style( 'cookieconsent-admin-style', $src2, array(), PLUGINVERSION ); 55 | wp_enqueue_style( 'cookieconsent-admin-style' ); 56 | } 57 | 58 | function icc_register_settings() { 59 | register_setting( 'icc-options', 'icc_popup_enabled' ); 60 | register_setting( 'icc-options', 'icc_popup_options' ); 61 | register_setting( 'icc-options', 'choose-position' ); 62 | register_setting( 'icc-options', 'choose-layout' ); 63 | register_setting( 'icc-options', 'theme-selector' ); 64 | register_setting( 'icc-options', 'policy' ); 65 | register_setting( 'icc-options', 'link-href' ); 66 | register_setting( 'icc-options', 'choose-cookie-compliance' ); 67 | register_setting( 'icc-options', 'message-text' ); 68 | register_setting( 'icc-options', 'dismiss-text' ); 69 | register_setting( 'icc-options', 'allow-text' ); 70 | register_setting( 'icc-options', 'link-text' ); 71 | register_setting( 'icc-options', 'deny-text' ); 72 | register_setting( 'icc-options', 'custom-attributes' ); 73 | } 74 | add_action( 'admin_init', 'icc_register_settings' ); 75 | 76 | function icc_options_page() { 77 | echo '