*\r
* @link https://codex.wordpress.org/Debugging_in_WordPress\r
*/\r
-define('WP_DEBUG', false);\r
+if ( !defined('WP_DEBUG') ) {\r
+ define('WP_DEBUG', false);\r
+}\r
\r
/* That's all, stop editing! Happy blogging. */\r
\r
--- /dev/null
+<?php
+
+namespace PhysioAssist\CookieNotice;
+
+use function App\template;
+use function App\asset_path;
+
+class Setup {
+
+ private $cookie_name = 'cube-cookies-accepted';
+
+ /**
+ * Common setup, will be automatically triggered by Init class if included
+ */
+ public function register() {
+
+ if (isset($_COOKIE[$this->cookie_name]) && $_COOKIE[$this->cookie_name] == 1) {
+ return false; // Already accepted, nothing else to be done
+ }
+
+ // Output HTML for cookie notice at the bottom of the page
+ add_action('get_footer', function() {
+ // Include JS resources for cookie notice
+ wp_register_script('lity', asset_path('scripts/lity.js'), ['jquery'], null, true);
+ wp_register_script('cube-cookie-notice', asset_path('scripts/cookie-notice.js'), ['lity'], null, true);
+ wp_localize_script('cube-cookie-notice', 'cube_cookie_notice', ['cookie_name' => $this->cookie_name]); // For JS usage
+ wp_enqueue_script('cube-cookie-notice');
+
+ // Get content from cookie notice page
+ $cookie_notice = get_page_by_path('cookie-notice');
+
+ if ($cookie_notice) {
+ $learn_more = __('Learn more', 'physioassist');
+
+ // Note: We could support this content coming from Elementor but it's simpler for now
+ // to use the basic WordPress content. In the future, we could check the post_meta and
+ // if _elementor_edit_mode = 'builder', then we know it's an Elementor page...
+ //$content = \Elementor\Plugin::instance()->frontend->get_builder_content_for_display(wpml_object_id_filter($cookie_notice->ID, 'page', true));
+
+ $page_ID = wpml_object_id_filter($cookie_notice->ID, 'page', true);
+
+ $message = get_post_meta($page_ID, 'cube_cookie_message', true); // Custom post meta holds the cookie message
+ $content = wpautop(get_post_field('post_content', $page_ID)); // Page body holds popup info
+
+ echo template('widgets/cookie-notice', compact('message', 'learn_more', 'content'));
+ } else {
+ echo '<script>console.warn("Cookie Notice Error: unable to get message. Check page exists.")</script>';
+ }
+ });
+
+ }
+
+}
Common\Setup::class,
Elementor\Setup::class,
WooCommerce\Setup::class,
+ CookieNotice\Setup::class,
];
}
"imagemin-mozjpeg": "~7.0.0",
"imagemin-webpack-plugin": "~2.0.0",
"import-glob": "~1.5",
+ "js-cookie": "^2.2.1",
"lity": "^2.4.0",
"lodash.debounce": "^4.0.8",
"lodash.throttle": "^4.1.1",
"lity": [
"./scripts/lity.js"
],
+ "cookie-notice": [
+ "./scripts/cookie-notice.js"
+ ],
"customizer": [
"./scripts/customizer.js"
]
-<?xml version="1.0" encoding="utf-8"?>\r
-<!-- Generator: Adobe Illustrator 15.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->\r
-<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">\r
-<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"\r
- width="17.847px" height="17.847px" viewBox="0 0 17.847 17.847" enable-background="new 0 0 17.847 17.847" xml:space="preserve">\r
-<g>\r
- <g>\r
- <path fill-rule="evenodd" clip-rule="evenodd" fill="#ffffff" d="M11.044,8.923l6.363-6.363c0.586-0.585,0.586-1.535,0-2.121\r
- c-0.586-0.585-1.535-0.585-2.121,0L8.923,6.802L2.56,0.439c-0.586-0.585-1.535-0.585-2.121,0c-0.585,0.586-0.585,1.536,0,2.121\r
- l6.363,6.363l-6.363,6.363c-0.585,0.586-0.585,1.535,0,2.121c0.586,0.586,1.535,0.586,2.121,0l6.363-6.363l6.363,6.363\r
- c0.586,0.586,1.535,0.586,2.121,0s0.586-1.535,0-2.121L11.044,8.923z"/>\r
- </g>\r
-</g>\r
-</svg>\r
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 17.847 17.847"><path fill-rule="evenodd" clip-rule="evenodd" fill="#fff" d="M11.044 8.923l6.363-6.363A1.5 1.5 0 1015.286.439L8.923 6.802 2.56.439a1.501 1.501 0 00-2.121 0 1.501 1.501 0 000 2.121l6.363 6.363-6.363 6.363a1.5 1.5 0 102.121 2.121l6.363-6.363 6.363 6.363a1.5 1.5 0 102.121-2.121l-6.363-6.363z"/></svg>
--- /dev/null
+import Cookies from 'js-cookie';
+
+// Get name of cookie from localised script variable set in PHP
+let cookie_name = window.cube_cookie_notice.cookie_name;
+
+$(document).on('click', '.cube-cookie-notice-close', function() {
+ Cookies.set(cookie_name, 1, { expires: 365 });
+ $(this).parent().fadeOut();
+});
width: 32px
height: 28px
background: url(../images/icons/mobile-menu.svg) center no-repeat
+ background-size: contain
cursor: pointer
&.open
background-image: url(../images/icons/close.svg)
+ background-size: 18px
+below($breakpoint-menu)
display: block
--- /dev/null
+.cube-cookie-notice
+ position: fixed
+ left: 30px
+ bottom: 30px
+ width: calc(100% - 60px)
+ max-width: 350px
+ background-color: rgba(#222, 0.95)
+ color: #fff
+ padding: 1em 2.25em
+ z-index: 99
+ font-size: 13px
+
+ &-close
+ position: absolute
+ top: 0.7em
+ right: @top
+ width: 1.25em
+ height: @width
+ cursor: pointer
+
+ &-lightbox
+ horizontal-spacing(5vw)
+ padding-top: 90px
+ constrain(padding-bottom, 5vw)
+ background-color: #fff
+ width: 90vw
+ max-width: 1200px
+ max-height: 90vh !important // Gives 5% top and bottom gap
+ overflow-y: auto // Scroll internally if content is too tall for screen
--- /dev/null
+{{-- Cube Cookie Notice --}}
+<div class="cube-cookie-notice">
+ {!! $message !!}
+ <br/>
+ <a href="#cube_cookie_notice_info" data-lity>{{ $learn_more }}</a>
+ @svg('icons/close', 'cube-cookie-notice-close')
+</div>
+
+{{-- Lightbox popup --}}
+<div id="cube_cookie_notice_info" class="cube-cookie-notice-lightbox lity-hide">
+ {!! $content !!}
+</div>
resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-2.5.1.tgz#1efa39ef2c5f7980bb1784ade4a8af2de3291121"
integrity sha512-M7kLczedRMYX4L8Mdh4MzyAMM9O5osx+4FcOQuTvr3A9F2D9S5JXheN0ewNbrvK2UatkTRhL5ejGmGSjNMiZuw==
+js-cookie@^2.2.1:
+ version "2.2.1"
+ resolved "https://registry.yarnpkg.com/js-cookie/-/js-cookie-2.2.1.tgz#69e106dc5d5806894562902aa5baec3744e9b2b8"
+ integrity sha512-HvdH2LzI/EAZcUwA8+0nKNtWHqS+ZmijLA30RwZA0bo7ToCckjK5MkGhjED9KoRcXO6BaGI3I9UIzSA1FKFPOQ==
+
js-tokens@^3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"