From: stephen@cubedesigners.com Date: Thu, 15 Oct 2020 17:10:43 +0000 (+0000) Subject: Wait #3921 @6 X-Git-Url: http://git.cubedesigners.com/?a=commitdiff_plain;h=4b092f0253f28b4f0afa656303a65f3916d38709;p=physioassist-wordpress.git Wait #3921 @6 --- diff --git a/wp-config.php b/wp-config.php index 7aac9563..9f01a5d4 100644 --- a/wp-config.php +++ b/wp-config.php @@ -65,7 +65,9 @@ $table_prefix = 'wp_'; * * @link https://codex.wordpress.org/Debugging_in_WordPress */ -define('WP_DEBUG', false); +if ( !defined('WP_DEBUG') ) { + define('WP_DEBUG', false); +} /* That's all, stop editing! Happy blogging. */ diff --git a/wp-content/mu-plugins/physioassist/src/CookieNotice/Setup.php b/wp-content/mu-plugins/physioassist/src/CookieNotice/Setup.php new file mode 100644 index 00000000..59b678d9 --- /dev/null +++ b/wp-content/mu-plugins/physioassist/src/CookieNotice/Setup.php @@ -0,0 +1,53 @@ +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 ''; + } + }); + + } + +} diff --git a/wp-content/mu-plugins/physioassist/src/Init.php b/wp-content/mu-plugins/physioassist/src/Init.php index dc076509..7eec85bd 100644 --- a/wp-content/mu-plugins/physioassist/src/Init.php +++ b/wp-content/mu-plugins/physioassist/src/Init.php @@ -16,6 +16,7 @@ final class Init { // Marked as final because this class should never be extende Common\Setup::class, Elementor\Setup::class, WooCommerce\Setup::class, + CookieNotice\Setup::class, ]; } diff --git a/wp-content/themes/physioassist/package.json b/wp-content/themes/physioassist/package.json index 74b8b5e0..bc758e13 100644 --- a/wp-content/themes/physioassist/package.json +++ b/wp-content/themes/physioassist/package.json @@ -84,6 +84,7 @@ "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", diff --git a/wp-content/themes/physioassist/resources/assets/config.json b/wp-content/themes/physioassist/resources/assets/config.json index be29e77c..1a096a71 100644 --- a/wp-content/themes/physioassist/resources/assets/config.json +++ b/wp-content/themes/physioassist/resources/assets/config.json @@ -31,6 +31,9 @@ "lity": [ "./scripts/lity.js" ], + "cookie-notice": [ + "./scripts/cookie-notice.js" + ], "customizer": [ "./scripts/customizer.js" ] diff --git a/wp-content/themes/physioassist/resources/assets/images/icons/close.svg b/wp-content/themes/physioassist/resources/assets/images/icons/close.svg index 52c72215..3838fe8e 100644 --- a/wp-content/themes/physioassist/resources/assets/images/icons/close.svg +++ b/wp-content/themes/physioassist/resources/assets/images/icons/close.svg @@ -1,14 +1 @@ - - - - - - - - - - + diff --git a/wp-content/themes/physioassist/resources/assets/scripts/cookie-notice.js b/wp-content/themes/physioassist/resources/assets/scripts/cookie-notice.js new file mode 100644 index 00000000..6f81e7d3 --- /dev/null +++ b/wp-content/themes/physioassist/resources/assets/scripts/cookie-notice.js @@ -0,0 +1,9 @@ +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(); +}); diff --git a/wp-content/themes/physioassist/resources/assets/styles/components/navigation-mobile.styl b/wp-content/themes/physioassist/resources/assets/styles/components/navigation-mobile.styl index 518334b5..11136cdf 100644 --- a/wp-content/themes/physioassist/resources/assets/styles/components/navigation-mobile.styl +++ b/wp-content/themes/physioassist/resources/assets/styles/components/navigation-mobile.styl @@ -7,10 +7,12 @@ 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 diff --git a/wp-content/themes/physioassist/resources/assets/styles/widgets/cookie-notice.styl b/wp-content/themes/physioassist/resources/assets/styles/widgets/cookie-notice.styl new file mode 100644 index 00000000..1a98d910 --- /dev/null +++ b/wp-content/themes/physioassist/resources/assets/styles/widgets/cookie-notice.styl @@ -0,0 +1,29 @@ +.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 diff --git a/wp-content/themes/physioassist/resources/views/widgets/cookie-notice.blade.php b/wp-content/themes/physioassist/resources/views/widgets/cookie-notice.blade.php new file mode 100644 index 00000000..3dbe993f --- /dev/null +++ b/wp-content/themes/physioassist/resources/views/widgets/cookie-notice.blade.php @@ -0,0 +1,12 @@ +{{-- Cube Cookie Notice --}} + + +{{-- Lightbox popup --}} + diff --git a/wp-content/themes/physioassist/yarn.lock b/wp-content/themes/physioassist/yarn.lock index 763b9a81..308566e7 100644 --- a/wp-content/themes/physioassist/yarn.lock +++ b/wp-content/themes/physioassist/yarn.lock @@ -4978,6 +4978,11 @@ js-base64@^2.1.8, js-base64@^2.1.9: 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"