Skip to content
Merged
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
16 changes: 11 additions & 5 deletions tawk_to.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,17 @@ function tawk_to_admin_form_submit($form, &$form_state) {
switch ($column) {
case 'hide_oncustom':
case 'show_oncustom':
// replace newlines and returns with comma, and convert to array for saving
$value = str_replace(["\r\n", "\r", "\n"], ',', $value);
$value = explode(',', $value);
$value = (empty($value)||!$value)?array():$value;
$jsonOpts[$column] = json_encode($value);
// split by newlines, then remove empty lines
$value = str_replace("\r", "\n", $value);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no urldecode() here because form is not serialized, actual string is posted via form action
Screenshot from 2024-07-23 16-42-21

$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':
case 'show_oncategory':
Expand Down