diff --git a/tawk_to/src/core/TawktoGenerator.php b/tawk_to/src/core/TawktoGenerator.php index 75116f2..2349135 100644 --- a/tawk_to/src/core/TawktoGenerator.php +++ b/tawk_to/src/core/TawktoGenerator.php @@ -92,7 +92,9 @@ private function shouldDisplayWidget($options = null) // prepare visibility $currentUrl = $base_url.$_SERVER["REQUEST_URI"]; if ($options->always_display == false) { - if (UrlPatternMatcher::match($currentUrl, $showPages)) { + $show_pages = json_decode($options->show_oncustom); + + if (UrlPatternMatcher::match($currentUrl, $show_pages)) { $show = true; } @@ -595,12 +597,18 @@ public function setOptions($options) switch ($column) { case 'hide_oncustom': case 'show_oncustom': - // replace newlines and returns with comma, and convert to array for saving + // split by newlines, then remove empty lines $value = urldecode($value); - $value = str_ireplace(["\r\n", "\r", "\n"], ',', $value); - $value = explode(",", $value); - $value = (empty($value) || !$value) ? array() : $value; - $jsonOpts[$column] = json_encode($value); + $value = str_ireplace("\r", "\n", $value); + $value = explode("\n", $value); + $non_empty_values = array(); + foreach ($value as $str) { + $trimmed = trim($str); + if ($trimmed !== '') { + $non_empty_values[] = $trimmed; + } + } + $jsonOpts[$column] = json_encode($non_empty_values); break; case 'show_onfrontpage':