Hi,
Sorry for the confusion. Just save this code into a .php file, zip it up and upload it as a plugin:
<?php
/*
Plugin Name: MailPoet Remove tracking
Plugin URI: https://www.mailpoet.com/
Description: Extended functionalities to the free version.
Version: 1.0
Author: MailPoet
Author URI: https://www.mailpoet.com/
License: GPLv2 or later
Text Domain: wysija-newsletters
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
/**
*
* @param string $site
*/
add_action(‘wysija_replaceusertags’, ‘wysija_remove_tracking’,1,2);
function wysija_remove_tracking(){
remove_all_actions( ‘wysija_replaceusertags’, 11 );
add_action(‘wysija_replaceusertags’, ‘wysija_tracker_replaceusertags’,13,2);
}
function wysija_tracker_replaceusertags($email,$user){
$urls = array();
$results = array();// collect all links in email
if(!preg_match_all(‘#href[ ]*=[ ]*”(?!mailto:|\#|ymsgr:|callto:|file:|ftp:|webcal:|skype:)([^”]+)”#Ui’,$email->body,$results)) return;
$modelConf=WYSIJA::get(‘config’,’model’);
foreach($results[1] as $i => $url){
if( !in_array($url, array( ‘[unsubscribe_link]’, ‘[subscriptions_link]’ , ‘[view_in_browser_link]’ ) ) ){
continue;
}
$email_url = $url;
$args = array();
$args[’email_id’] = $email->email_id;
$args[‘user_id’] = $user->user_id;
if(empty($user->user_id)) $args[‘demo’]=1;
$args[‘urlpassed’] = base64_encode($email_url);
$args[‘controller’] = ‘stats’;
$page_id = $modelConf->getValue(‘confirm_email_link’);
//if it’s a system url that needs privacy we hash it
if(strpos($email_url, ‘[unsubscribe_link]’)!==false){
$args[‘hash’]=md5(AUTH_KEY.'[unsubscribe_link]’.$args[‘user_id’]);
$page_id = $modelConf->getValue(‘unsubscribe_page’);
}
if(strpos($email_url, ‘[subscriptions_link]’)!==false){
$args[‘hash’]=md5(AUTH_KEY.'[subscriptions_link]’.$args[‘user_id’]);
$page_id = $modelConf->getValue(‘subscriptions_page’);
}
$args[‘action’] = ‘analyse’;
$args[‘wysija-page’] = 1;
$mytracker=WYSIJA::get_permalink($modelConf->getValue($page_id),$args);
$urls[$results[0][$i]] = str_replace($url,$mytracker,$results[0][$i]);
}
$email->body = str_replace(array_keys($urls),$urls,$email->body);
}//endfct