Skip to content

Commit

Permalink
Merge pull request #12 from tawk/fix/display-widget-show-pages
Browse files Browse the repository at this point in the history
fix undefined variable `$showPages`
  • Loading branch information
eug-L authored Jul 24, 2024
2 parents 442a328 + f1bbe57 commit eac3f0a
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions tawk_to/src/core/TawktoGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down Expand Up @@ -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':
Expand Down

0 comments on commit eac3f0a

Please sign in to comment.