WP Plug-in info needed, RSS feed with aff links

boottothehead

Newbie
Joined
Aug 7, 2012
Messages
12
Reaction score
1
Anybody know of a WP Plug-in that would inject an affiliate link? Say that I'm an affiliate for a pool accessories company and the site has an RSS feed. Would it be possible to have a plug-in (or is there already one) that would put my code into the link when a visitor clicks on the RSS feed?


Boot
 
Try out this code (create a reflinx.php in wp-content/plugins/ folder):
PHP:
<?php

define ('REFERAL_STRING', 'id');
define ('DELIMITER', '=');
define ('SEARCHREFCODE', 'xxxx');
define ('DEFAULTREFCODE', '0');

// variables 2 work with cookies
define ('COOKIE_PREFIX', 'RefLinXid');
$expire = time() + 31536000;
define ('COOKIE_ESPIRITY', $expire);

$AdvertRefCode = DEFAULTREFCODE;

function CheckRefererAndSetUpCookie() {
	if (isset($_GET[REFERAL_STRING])){
		// get ref code
		$RefCode = trim($_GET[REFERAL_STRING]);
		// set up cookie
		setcookie('blog_aid', $RefCode, 0, '/');
	} else {
		//check if cookie was already setted up by smbd
		if ($_COOKIE['blog_aid'])
			$RefCode = $_COOKIE['blog_aid'];
		else {
			$RefCode = DEFAULTREFCODE;
			setcookie('blog_aid', $RefCode, 0, '/');
		}
	}	
	return $RefCode;
}

//print_r($_COOKIE);

//print $_COOKIE['blog_aid'];

//print CheckRefererAndSetUpCookie();


function reflinks($content) {
	global $AdvertRefCode;
	$content = str_ireplace(REFERAL_STRING.DELIMITER.SEARCHREFCODE,REFERAL_STRING.DELIMITER.$AdvertRefCode,$content);
	return $content;
}

$AdvertRefCode = CheckRefererAndSetUpCookie();
add_filter('the_content', 'reflinks');

?>


In the body of a post use links like somesitetosendwithref_dot_com/?id=xxxx (xxxx is a SEARCHREFCODE variable), when someone goes to your site with domain_dot_com/?id=userid the affiliation links automatically become somesitetosendwithref_dot_com/?id=userid
By default will be replaced with 0 (Based on DEFAULTREFCODE).
 
Back
Top