Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions PrivacyWire.module
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ class PrivacyWire extends WireData implements Module, ConfigurableModule
}

// 1. - 5. within initiatePrivacyWire method
$this->wire('page')->addHookBefore('render', $this, 'initiatePrivacyWire');

// 6. Render everything!
/*
* Hint: If you want to render everything manually, make sure to insert the PrivacyWireConfig (step 2), PrivacyWireCore (step 3), Banner Markup (step 4) and if you want to display the ask-for-consent windows also the consent blueprint (step 5) somewhere in your template.
* 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]);
}
}
Expand Down Expand Up @@ -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"),
Expand Down
12 changes: 7 additions & 5 deletions PrivacyWireBanner.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions src/js/PrivacyWire.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down