Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: Google Sitemap timestamp calculation #168

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
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
Next Next commit
bugfix: When not adding tracking counters, return a proper link
Jari Turkia committed Jun 3, 2024
commit 295523457fdc982b9ef2dc96aa454d27e9e8174d
Original file line number Diff line number Diff line change
@@ -154,29 +154,40 @@ function gtag() {
!$markupDisabledConfig && !$markupDisabledPost) {
$element = $element['element'];
$eventData[$element] = preg_replace_callback(
"#<a (.*)href=(\"|')(http://|https://|)([^\"']+)(\"|')([^>]*)>#isUm",
"#<a\\s+(.*)href\\s*=\\s*[\"|'](http://|https://|)([^\"']*)[\"|']([^>]*)>#isUm",
array($this, 'analytics_tracker_callback'),
$eventData[$element]
);
}
}
return true;

default :
default:
return false;
} // end switch ($event) {
}

/**
* matches:
* 0 = entire regexp match
* 1 = anything between "<a" and "href"
* 2 = scheme
* 3 = address
* 4 = anything after "href" and ">"
*/
function analytics_tracker_callback($matches)
{
$parsed_url = parse_url($matches[3].$matches[4]);
$parsed_url = parse_url($matches[2].$matches[3]);

// Skip tracking for local URLs without scheme, or unknown scheme.
if (!isset($parsed_url["scheme"]))
return;
return $matches[0];
if (!in_array($parsed_url["scheme"], array("http", "https")))
return;
return $matches[0];

// Note: Assume, there is no second onclick-event in substr($matches[0], 2)
return '<a onclick="_gaq.push([\'_trackPageview\', \'/extlink/' .
(function_exists('serendipity_specialchars') ? serendipity_specialchars($matches[4]) : htmlspecialchars($matches[4], ENT_COMPAT, LANG_CHARSET)) .
(function_exists('serendipity_specialchars') ? serendipity_specialchars($matches[3]) : htmlspecialchars($matches[3], ENT_COMPAT, LANG_CHARSET)) .
'\']);" ' . substr($matches[0], 2);
}