Commit a2f6e24e authored by Mateusz Uzdowski's avatar Mateusz Uzdowski

Add an option to disable link tracking on messages.

parent f04cda31
......@@ -12,6 +12,13 @@ class NewsletterEmail extends Email {
protected $recipient;
protected $fakeRecipient;
/**
* Should the link tracking be enabled.
*
* @var boolean
*/
private static $link_tracking_enabled = true;
/**
* @var String
*/
......@@ -67,9 +74,10 @@ class NewsletterEmail extends Email {
$bodyViewer = new SSViewer_FromString($text);
$text = $bodyViewer->process($this->templateData());
// find all the matches
if(!$this->fakeRecipient &&
preg_match_all("/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU", $text, $matches)) {
// Install link tracking by replacing existing links with "newsletterlink" and hash-based reference.
if($this->config()->link_tracking_enabled &&
!$this->fakeRecipient &&
preg_match_all("/<a\s[^>]*href=\"([^\"]*)\"[^>]*>(.*)<\/a>/siU", $text, $matches)) {
if(isset($matches[1]) && ($links = $matches[1])) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment