diff --git a/PrivacyWire.module b/PrivacyWire.module index aa9a69c..ca4034b 100644 --- a/PrivacyWire.module +++ b/PrivacyWire.module @@ -51,7 +51,6 @@ class PrivacyWire extends WireData implements Module, ConfigurableModule } // 1. - 5. within initiatePrivacyWire method - $this->wire('page')->addHookBefore('render', $this, 'initiatePrivacyWire'); // 6. Render everything! /* @@ -59,6 +58,7 @@ class PrivacyWire extends WireData implements Module, ConfigurableModule * The banner markup and consent window blueprint can be loaded anywhere, for example at the end of the body tag. */ if (!$this->render_manually) { + $this->wire('page')->addHookBefore('render', $this, 'initiatePrivacyWire'); // also disabled : allows full manual execution, more reliable as fully executed exactly once $this->wire('page')->addHookAfter('render', $this, 'render', ['priority' => 101]); } } @@ -190,7 +190,7 @@ class PrivacyWire extends WireData implements Module, ConfigurableModule $privacyWireSettings->dnt = ($this->respectDNT) ? "1" : "0"; $privacyWireSettings->bots = ($this->checkForBots) ? "1" : "0"; $privacyWireSettings->customFunction = ($this->wire('sanitizer')->text($this->trigger_custom_js_function)) ?? ""; - $privacyWireSettings->messageTimeout = ($this->messageTimeout && intval($this->messageTimeout) > 1) ? intval($this->messageTimeout) : 1500; + $privacyWireSettings->messageTimeout = (isset($this->messageTimeout) && intval($this->messageTimeout) >= 0) ? intval($this->messageTimeout) : 1500; $privacyWireSettings->consentByClass = ($this->detect_consents_by_class) ? "1" : "0"; $privacyWireSettings->cookieGroups = [ 'necessary' => $this->get("cookies_necessary_label{$this->lang}|cookies_necessary_label"), diff --git a/PrivacyWireBanner.php b/PrivacyWireBanner.php index 1462ae7..ba39563 100644 --- a/PrivacyWireBanner.php +++ b/PrivacyWireBanner.php @@ -11,12 +11,14 @@ $showMarketingButton = (in_array("marketing", $module->cookie_groups)); $showExternalMediaButton = (in_array("external_media", $module->cookie_groups)); +// show the "choose" button if there is MORE than 1 optional cookie types to choose from +// (if there's only 1 optional cookie type, then the button "necessary yes/no" is enough to cover all possible choices) $showChooseButton = ( - $showFunctionalButton || - $showStatisticsButton || - $showMarketingButton || - $showExternalMediaButton -); + (int)$showFunctionalButton + + (int)$showStatisticsButton + + (int)$showMarketingButton + + (int)$showExternalMediaButton +) > 1; // Detailed Text for options banner diff --git a/src/js/PrivacyWire.js b/src/js/PrivacyWire.js index 60f00f8..5f6f278 100644 --- a/src/js/PrivacyWire.js +++ b/src/js/PrivacyWire.js @@ -308,10 +308,12 @@ class PrivacyWire { } showMessage() { - this.elements.banner.wrapper.classList.add("show-message") - setTimeout(() => { - this.elements.banner.wrapper.classList.remove("show-message") - }, this.settings.messageTimeout) + if (this.settings.messageTimeout > 0) { + this.elements.banner.wrapper.classList.add("show-message") + setTimeout(() => { + this.elements.banner.wrapper.classList.remove("show-message") + }, this.settings.messageTimeout) + } } checkElementsWithRequiredConsent() {