From 38c24365a5b94bfbda8d497d600fd870f878794d Mon Sep 17 00:00:00 2001 From: Petr Sahula Date: Thu, 11 Apr 2024 09:01:50 +0200 Subject: [PATCH] Implement cookies plugin --- plugins/goout-events/css/cookies.css | 157 +++++++++++++++++++ plugins/goout-events/goout-events-plugin.php | 12 +- plugins/goout-events/js/goout-admin.js | 2 +- plugins/goout-events/js/goout-cookies.js | 60 +++++++ plugins/goout-events/js/goout-scripts.js | 1 + plugins/goout-events/js/scripts.js | 1 - plugins/goout-events/options-basic.php | 92 ++++++++++- 7 files changed, 318 insertions(+), 7 deletions(-) create mode 100644 plugins/goout-events/css/cookies.css create mode 100644 plugins/goout-events/js/goout-cookies.js create mode 100644 plugins/goout-events/js/goout-scripts.js delete mode 100644 plugins/goout-events/js/scripts.js diff --git a/plugins/goout-events/css/cookies.css b/plugins/goout-events/css/cookies.css new file mode 100644 index 0000000..d651e2b --- /dev/null +++ b/plugins/goout-events/css/cookies.css @@ -0,0 +1,157 @@ +.goout-cookie-overlay { + position: fixed; + top: 0; + left: 0; + width: 100vw; + height: 100vh; + background: rgba(0,0,0,.5); +} +.goout-cookie-popup { + color: #0c0c0c; + position: absolute; + width: 80%; + max-width: 30rem; + max-height: 100%; + top: 50%; + left: 50%; + transform: translateX(-50%) translateY(-50%); + background: #fff; + font-family: 'Libre Franklin', sans-serif; + padding: 0 1.5rem; + overflow: auto; +} +.goout-cookie-popup a { + text-decoration: underline; + color: #0c0c0c; +} +.goout-cookie-header { + text-align: center; + font-size: 1.5rem; + margin-top: 3rem; + margin-bottom: 1rem; + font-weight: 600; +} +.goout-cookie-close { + position: absolute; + right: 0; + width: 3rem; + height: 3rem; + top: 0; + cursor: pointer; +} +.goout-cookie-close:after { + position: absolute; + top: 0; + bottom: 0; + left: 0; + right: 0; + content: "×"; + font-size: 2rem; + color: #999; + line-height: 3rem; + text-align: center; +} +.goout-cookie-intro span { + text-decoration: underline; + cursor: pointer; +} +.goout-cookie-intro span:hover,.goout-cookie-intro span:focus { + text-decoration: none; +} +.goout-cookie-confirm { + width: 100%; + height: 3rem; + line-height: 3rem; + margin-bottom: 2.5rem; + background: #f78564; + color: #fff; + text-align: center; + cursor: pointer; + transition: all .1s ease-out; +} +.goout-cookie-confirm:hover,.goout-cookie-confirm:focus { + opacity: 0.8; +} +.goout-cookie-secondary { + width: 100%; + margin: 1rem 0; + padding: .5rem 0; + text-align: center; + color: #999; + cursor: pointer; + transition: all .1s ease-out; +} +.goout-cookie-secondary:hover,.goout-cookie-secondary:focus { + color: #383838; +} +.goout-cookie-d-none { + display: none; +} +.goout-cookie-settings { + margin: 1rem 0 2rem; +} +.goout-cookie-settings-switch { + display: flex; + margin: 1.5rem 0; +} +.goout-cookie-settings-switch span { + flex-grow: 1; + padding-right: 1.5rem; +} +.goout-cookie-switch { + position: relative; + display: inline-block; + width: 2.5rem; + height: 1.5rem; + flex-shrink: 0; + align-self: center; +} +.goout-cookie-switch input { + opacity: 0; + width: 0; + height: 0; +} +.goout-cookie-switch .toggle { + position: absolute; + cursor: pointer; + top: 0; + left: 0; + right: 0; + bottom: 0; + background-color: #999; + transition: .4s; + border-radius: 1.5rem; +} +.goout-cookie-switch .toggle:before { + position: absolute; + content: ""; + height: 1rem; + width: 1rem; + left: .25rem; + bottom: .25rem; + background-color: #fff; + transition: .4s; + border-radius: 50%; +} +.goout-cookie-switch input:checked+.toggle { + background-color: #f78564; +} +.goout-cookie-switch input:focus+.toggle { + box-shadow: 0 0 1px #383838; +} +.goout-cookie-switch input:checked+.toggle:before { + transform: translateX(1rem); +} +.goout-cookie-settings-button { + position: fixed; + left: 7px; + bottom: 0; + padding: 1px 7px 0 7px; + border: solid 1px #999; + border-radius: 7px 7px 0 0; + color: #555; + background-color: #fefefe; + text-align: center; + font-style: italic; + cursor: pointer; +} diff --git a/plugins/goout-events/goout-events-plugin.php b/plugins/goout-events/goout-events-plugin.php index ff9bd97..2226e5e 100644 --- a/plugins/goout-events/goout-events-plugin.php +++ b/plugins/goout-events/goout-events-plugin.php @@ -14,13 +14,15 @@ // Insert CSS files function add_custom_css() { wp_enqueue_style('custom-style', plugins_url('css/styles.css', __FILE__)); + if (get_option('use_cookies') == 'on') { + wp_enqueue_style('goout-events-cookies-styles', plugins_url('css/cookies.css', __FILE__)); + } } +add_action('wp_enqueue_scripts', 'add_custom_css'); function add_custom_admin_css() { wp_enqueue_style('custom-admin-style', plugins_url('css/styles.css', __FILE__)); } - add_action('admin_enqueue_scripts', 'add_custom_admin_css'); -add_action('wp_enqueue_scripts', 'add_custom_css'); // Insert JS files // Register scripts for admin pages @@ -31,7 +33,11 @@ function goout_events_load_admin_scripts() { // Register scripts for front end function enqueue_goout_events_load_scripts() { - wp_enqueue_script('goout-events-scripts', plugins_url('/js/scripts.js', __FILE__)); + wp_enqueue_script('goout-events-scripts', plugins_url('/js/goout-scripts.js', __FILE__)); + if (get_option('use_cookies') == 'on') { + wp_enqueue_script('cookies-script', 'https://static.goout.net/cookie-plugin/goout-cookie.umd.js', array(), null, false); + wp_enqueue_script('goout-events-cookies-scripts', plugins_url('js/goout-cookies.js', __FILE__)); + } } add_action('wp_enqueue_scripts','enqueue_goout_events_load_scripts'); diff --git a/plugins/goout-events/js/goout-admin.js b/plugins/goout-events/js/goout-admin.js index 354564d..9f9b4e4 100644 --- a/plugins/goout-events/js/goout-admin.js +++ b/plugins/goout-events/js/goout-admin.js @@ -1,4 +1,4 @@ -console.log('AHOJ, tady script pro administraci na stránce typu příspěvku "dates"'); +console.log('PLUGIN BACKEND SCRIPT'); (function($) { 'use strict'; diff --git a/plugins/goout-events/js/goout-cookies.js b/plugins/goout-events/js/goout-cookies.js new file mode 100644 index 0000000..5d72dfa --- /dev/null +++ b/plugins/goout-events/js/goout-cookies.js @@ -0,0 +1,60 @@ +// Cookies Scripts + +console.log('COOKIES SCRIPT'); + +lang = 'cs'; +function trackingAccepted() { + var script = document.createElement('script'); + script.type = 'text/javascript'; + script.src = 'https://c.seznam.cz/js/rc.js'; + + document.head.appendChild(script); + var retargetingConf = { + rtgId: 21191, + }; + if (window.rc && window.rc.retargetingHit) { + window.rc.retargetingHit(retargetingConf); + } +} + +goOutCookie.init({ + lang: lang, + accepted: trackingAccepted, + dataLayer: window.dataLayer, + showSettingsButton: true, + showSettingsID: 'cookie-settings', + customLink: '/cookie-policy/', +}); + +/* +function loadCookieScripts() { + + (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ + (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), + m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) + })(window,document,'script','https://www.google-analytics.com/analytics.js','ga'); + + ga('create', get_field('google_analytics_id'), { + 'ad_storage': getCookie('goout-tracking_ad_storage') || 'denied', + 'analytics_storage': getCookie('goout-tracking_analytics_storage') || 'denied', + 'ad_user_data': getCookie('goout-tracking_ad_user_data') || 'denied', + 'ad_personalization': getCookie('goout-tracking_ad_personalization') || 'denied', + }); + + ga('send', 'pageview'); + !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod? + n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n; + n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0; + t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window, + document,'script','https://connect.facebook.net/en_US/fbevents.js'); + + fbq('init', '862504247105662'); + fbq('track', "PageView"); + + var script = document.createElement("script"); + script.type = "text/javascript"; + script.innerHTML = "(function(w,d,s,l,i){w[l]=w[l]||[];var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);})(window,document,'script','dataLayer','GTM-NGVQ6TQ');"; + document.body.appendChild(script); +} +loadCookieScripts(); +*/ diff --git a/plugins/goout-events/js/goout-scripts.js b/plugins/goout-events/js/goout-scripts.js new file mode 100644 index 0000000..abe8d26 --- /dev/null +++ b/plugins/goout-events/js/goout-scripts.js @@ -0,0 +1 @@ +console.log('PLUGIN FRONTEND SCRIPT'); diff --git a/plugins/goout-events/js/scripts.js b/plugins/goout-events/js/scripts.js deleted file mode 100644 index 7420d4c..0000000 --- a/plugins/goout-events/js/scripts.js +++ /dev/null @@ -1 +0,0 @@ -console.log('AHOJ, tady script pro frontend'); diff --git a/plugins/goout-events/options-basic.php b/plugins/goout-events/options-basic.php index f3377af..d33b718 100644 --- a/plugins/goout-events/options-basic.php +++ b/plugins/goout-events/options-basic.php @@ -18,8 +18,11 @@ function goout_custom_menu() { add_submenu_page('basic_settings_page', __("Nastavení fesstivalu", "t"), __("Nastavení festivalu", "t"), "manage_options", 'festival_settings_page', 'festival_settings_page'); } else if (get_option('basic_website_type') == 'exhibition') { add_submenu_page('basic_settings_page', __("Nastavení výstavy", "t"), __("Nastavení výstavy", "t"), "manage_options", 'exhibition_settings_page', 'exhibition_settings_page'); + } else if (get_option('basic_website_type') == 'goout-feed') { + add_submenu_page('basic_settings_page', __("GoOut Feed", "t"), __("GoOut Feed", "t"), "manage_options", 'goout-feed_settings_page', 'goout-feed_settings_page'); } add_submenu_page('basic_settings_page', __("Sociální sítě", "t"), __("Sociální sítě", "t"), "manage_options", 'socials_settings_page', 'socials_settings_page'); + add_submenu_page('basic_settings_page', __("Cookies", "t"), __("Nastavení Cookies", "t"), "manage_options", 'cookies_settings_page', 'cookies_settings_page'); } function custom_menu_styles() { @@ -61,6 +64,18 @@ function socials_settings_page() { +
+

+
+ + + +
+
+ + /> + + +

+ + +

+ + +

+ + +

+