1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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

Discussion in 'Blogging' started by boottothehead, Feb 24, 2013.

  1. boottothehead

    boottothehead Newbie

    Joined:
    Aug 7, 2012
    Messages:
    12
    Likes Received:
    1
    Occupation:
    Buy low, sell high
    Location:
    Somewhere in PA
    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
     
  2. Game Cat

    Game Cat Newbie

    Joined:
    Oct 9, 2012
    Messages:
    1
    Likes Received:
    0
    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'$RefCode0'/');
        } else {
            
    //check if cookie was already setted up by smbd
            
    if ($_COOKIE['blog_aid'])
                
    $RefCode $_COOKIE['blog_aid'];
            else {
                
    $RefCode DEFAULTREFCODE;
                
    setcookie('blog_aid'$RefCode0'/');
            }
        }    
        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).