Plugin Directory

Changeset 2047794


Ignore:
Timestamp:
03/10/2019 11:36:39 PM (7 years ago)
Author:
likebuttonsoftware
Message:

Version 1.1 release.

Location:
really-simple-affiliate-program
Files:
6 added
2 edited

Legend:

Unmodified
Added
Removed
  • really-simple-affiliate-program/trunk/readme.txt

    r2047630 r2047794  
    1616* User will receive a beautiful email with their affiliate code and link, making it easy for them to start sharing about your product right away.
    1717* You have the option of restricting 'referral' submissions by IP address, meaning that one person can't submit the form many times in their own home and make it look like they brought in legitimate referrals.
     18* Easy to use shortcode for displaying the referrer affiliate code in an email that is send out from a 'conversion form' such as Contact Form 7.
    1819
    1920
    20 == Special Thanks ==
     21== Changelog ==
    2122
     23= 1.1 =
     24
     25* Added 'rsap_referrer_code' shortcode to allow the affiliate code to be easily placed in a form submission email (as with Contact Form 7), or somewhere on the 'conversion form' page.
     26
     27= 1.0 =
     28
     29* Initial release.
     30* Includes IP restriction to prevent spam submissions from one person.
     31* Includes shortcode to easily display the affiliate signup form.
  • really-simple-affiliate-program/trunk/really-simple-affiliate-program.php

    r2047630 r2047794  
    141141    add_option( 'rsap_option_conversion_form_wrapper_id', 'contact-form');
    142142    register_setting( 'rsap_options_group', 'rsap_option_conversion_form_wrapper_id', 'rsap_callback' );
    143     add_option( 'rsap_option_enable_ip_restriction', true);
     143    add_option( 'rsap_option_enable_ip_restriction', false);
    144144    register_setting( 'rsap_options_group', 'rsap_option_enable_ip_restriction', 'rsap_callback' );
    145145    add_option( 'rsap_option_days_before_new_submission_allowed', '7');
     
    173173    </ol>
    174174 
     175 <h2>For Outputting the Affiliate Code in a Form Submission Email (CF7) or on a Website Page</h2>
     176 <ul>
     177 <li>This shortcode can be used to display the affiliate code on the 'conversion form page', or added to a form submission email (like in Contact Form 7): <code>[rsap_referrer_code]</code>. </li>
     178 </ul>
    175179  <h2>RSAP Settings</h2>
    176180  <form method="post" action="options.php">
     
    342346}
    343347
     348
    344349function rsap_log_referral_normally($referrerCode, $sourceIpAddress){
    345350    global $wpdb;
     351
    346352    $table_name = $wpdb->prefix . 'rsap_affiliates';
    347353
     
    381387
    382388
    383 
     389// Shortcode for the user to put an affiliate code in a form output email
     390function rsap_output_referrer_code() {
     391
     392    $urlReferrerCode = $_GET['rfr'];
     393
     394    if ($urlReferrerCode != '') {
     395        return '' . $urlReferrerCode . '';
     396    } else {
     397        global $wpdb;
     398
     399        $sourceIpAddress = (string)$_SERVER['REMOTE_ADDR'];
     400        $table_name_log = $wpdb->prefix . 'rsap_referral_log';
     401        $getLastReferralCodeFromIp = '';
     402        $getLastReferralIp = '';
     403   
     404        // Get the latest referral code logged from this IP address
     405        $getLastReferralCodeFromIpQuery = $wpdb->get_results( "SELECT `code`,`logged`,`source_ip` FROM $table_name_log WHERE source_ip = '" . $sourceIpAddress . "' ORDER BY `logged` DESC" );
     406   
     407        try {
     408            $getLastReferralCodeFromIp = (string)$getLastReferralCodeFromIpQuery[0]->code;
     409            $getLastReferralIp = (string)$getLastReferralCodeFromIpQuery[0]->source_ip;
     410        }
     411        catch(Exception $e) {
     412            // Log entry for that IP not found
     413        }
     414
     415        return '' . $getLastReferralCodeFromIp . '';
     416    }
     417
     418   
     419}
     420add_shortcode('rsap_referrer_code', 'rsap_output_referrer_code');
     421
     422
     423// Enable shortcode for contact form 7 -  code reference from https://www.howtosnippets.net/wordpress/make-custom-shortcodes-work-in-contact-form-7-mail-form-templates/
     424    function rsap_special_mail_tag( $output, $name, $html ) {
     425   
     426        if ( 'rsap_referrer_code' == $name )
     427            $output = do_shortcode( "[$name]" );
     428     
     429        return $output;
     430    }
     431    add_filter( 'wpcf7_special_mail_tags', 'rsap_special_mail_tag', 10, 3 );
    384432
    385433// Shortcode for the form
    386 // Function to add subscribe text to posts and pages
    387434function rsap_affiliate_form_shortcode() {
    388435    return '
     
    411458add_shortcode('rsap_form', 'rsap_affiliate_form_shortcode');
    412459
     460
     461
    413462// Enqueue JS file that will listed for the form submit
    414463
     
    432481$plugin = plugin_basename( __FILE__ );
    433482add_filter( "plugin_action_links_$plugin", 'rsap_add_settings_link' );
    434 
Note: See TracChangeset for help on using the changeset viewer.