Skip to content

Commit f1bbe57

Browse files
authored
Merge pull request #13 from tawk/fix/widget-config-empty-custom-url
fix empty custom show/hide url excludes home route "/"
2 parents 6536db9 + 9526546 commit f1bbe57

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tawk_to/src/core/TawktoGenerator.php

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -597,12 +597,18 @@ public function setOptions($options)
597597
switch ($column) {
598598
case 'hide_oncustom':
599599
case 'show_oncustom':
600-
// replace newlines and returns with comma, and convert to array for saving
600+
// split by newlines, then remove empty lines
601601
$value = urldecode($value);
602-
$value = str_ireplace(["\r\n", "\r", "\n"], ',', $value);
603-
$value = explode(",", $value);
604-
$value = (empty($value) || !$value) ? array() : $value;
605-
$jsonOpts[$column] = json_encode($value);
602+
$value = str_ireplace("\r", "\n", $value);
603+
$value = explode("\n", $value);
604+
$non_empty_values = array();
605+
foreach ($value as $str) {
606+
$trimmed = trim($str);
607+
if ($trimmed !== '') {
608+
$non_empty_values[] = $trimmed;
609+
}
610+
}
611+
$jsonOpts[$column] = json_encode($non_empty_values);
606612
break;
607613

608614
case 'show_onfrontpage':

0 commit comments

Comments
 (0)