Skip to content

Instantly share code, notes, and snippets.

@tribulant
Created September 12, 2014 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tribulant/56ead454c9dc1a8997eb to your computer and use it in GitHub Desktop.
Save tribulant/56ead454c9dc1a8997eb to your computer and use it in GitHub Desktop.
Newsletters: Filter - newsletters_emailbody_links Example
<?php
function emailbody_links($body = null, $history_id = null, $matches = null) {
global $Html;
if (!empty($matches)) {
foreach ($matches[1] as $key => $value) {
$pattern = '/[\'"](' . preg_quote($value, '/') . ')[\'"]/si';
$newlink = $Html -> retainquery('param1=value1', $value);
$body = preg_replace($pattern, '"' . $newlink . '"', $body);
}
}
return $body;
}
add_filter('newsletters_emailbody_links', 'emailbody_links', 10, 3);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment