- Fixes click tracking that would end request when calling open tracking

This commit is contained in:
Vlad
2016-04-22 20:30:16 -04:00
parent a8e3dd424e
commit ef1b0036e5
2 changed files with 8 additions and 4 deletions

View File

@ -32,6 +32,7 @@ class Clicks {
if(!$statistics) { if(!$statistics) {
// track open action in case it did not register // track open action in case it did not register
$opens = new Opens($url); $opens = new Opens($url);
$opens->display_image = false;
$opens->track(); $opens->track();
$statistics = StatisticsClicks::create(); $statistics = StatisticsClicks::create();
$statistics->newsletter_id = $newsletter_id; $statistics->newsletter_id = $newsletter_id;

View File

@ -8,6 +8,7 @@ if(!defined('ABSPATH')) exit;
class Opens { class Opens {
public $data; public $data;
public $display_image = true;
function __construct($data) { function __construct($data) {
$this->data = $data; $this->data = $data;
@ -30,11 +31,13 @@ class Opens {
$statistics->queue_id = $queue_id; $statistics->queue_id = $queue_id;
$statistics->save(); $statistics->save();
} }
header('Content-Type: image/gif'); if ($this->display_image) {
// return 1x1 pixel transparent gif image // return 1x1 pixel transparent gif image
header('Content-Type: image/gif');
echo "\x47\x49\x46\x38\x37\x61\x1\x0\x1\x0\x80\x0\x0\xfc\x6a\x6c\x0\x0\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x44\x1\x0\x3b"; echo "\x47\x49\x46\x38\x37\x61\x1\x0\x1\x0\x80\x0\x0\xfc\x6a\x6c\x0\x0\x0\x2c\x0\x0\x0\x0\x1\x0\x1\x0\x0\x2\x2\x44\x1\x0\x3b";
exit; exit;
} }
}
private function abort() { private function abort() {
header('HTTP/1.0 404 Not Found'); header('HTTP/1.0 404 Not Found');