Skip to content

Commit 9e8cb3b

Browse files
authored
Merge pull request #12 from eug-L/fix/empty-custom-url
Fix empty custom show/hide url excludes home route "/"
2 parents e163b99 + 561fee9 commit 9e8cb3b

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

tawk_to.admin.inc

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -289,11 +289,17 @@ function tawk_to_admin_form_submit($form, &$form_state) {
289289
switch ($column) {
290290
case 'hide_oncustom':
291291
case 'show_oncustom':
292-
// replace newlines and returns with comma, and convert to array for saving
293-
$value = str_replace(["\r\n", "\r", "\n"], ',', $value);
294-
$value = explode(',', $value);
295-
$value = (empty($value)||!$value)?array():$value;
296-
$jsonOpts[$column] = json_encode($value);
292+
// split by newlines, then remove empty lines
293+
$value = str_replace("\r", "\n", $value);
294+
$value = explode("\n", $value);
295+
$non_empty_values = array();
296+
foreach ($value as $str) {
297+
$trimmed = trim($str);
298+
if ($trimmed !== '') {
299+
$non_empty_values[] = $trimmed;
300+
}
301+
}
302+
$jsonOpts[$column] = json_encode($non_empty_values);
297303
break;
298304
case 'show_onfrontpage':
299305
case 'show_oncategory':

0 commit comments

Comments
 (0)