Advertisement
Guest User

Untitled

a guest
May 20th, 2015
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.49 KB | None | 0 0
  1. <?php
  2. /*
  3.  Plugin Name: Affiliates Referrer Info
  4. Plugin URI: http://www.eggemplo.com
  5. Description: Add a shortcode to show referrer info as lineal text (name and email)
  6. Version: 1.0
  7. Author URI: http://www.eggemplo.com
  8. */
  9. add_action ( &#039;init&#039;, &#039;add_aff_referrer_info_shortcodes&#039; );
  10. function add_aff_referrer_info_shortcodes($data) {
  11. add_shortcode ( &#039;aff-referrer-info&#039;, &#039;aff_referrer_info&#039; );
  12. add_shortcode ( &#039;aff_referrer_info&#039;, &#039;aff_referrer_info&#039; );
  13. }
  14. function aff_referrer_info ($attr = array()) {
  15.    
  16.     $output = &quot;&quot;;
  17.     $sep =  isset( $attr[&#039;separator&#039;] ) ? $attr[&#039;separator&#039;] : &quot;";
  18.     $direct = isset( $attr['show_direct'] ) ? true : false;
  19.    
  20.     $name = isset( $attr['show_name'] ) ? true : false;
  21.     $email = isset( $attr['show_email'] ) ? true : false;
  22.    
  23.     if ( !class_exists("Affiliates_Service" ) ) {
  24.         require_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' );
  25.     }
  26.    
  27.     $affiliate_id = Affiliates_Service::get_referrer_id();
  28.     if ( $affiliate_id ) {
  29.         $affiliate = affiliates_get_affiliate( $affiliate_id );
  30.        
  31.         if ( $direct || ( $affiliate_id !== affiliates_get_direct_id() ) ) {
  32.             if ( $name ) {
  33.                 $output .= $affiliate['name'] . $sep;
  34.             }
  35.             if ( $email ) {
  36.                 $output .= $affiliate['email'] . $sep;
  37.             }
  38.            
  39.             if ( strlen($output)&gt;0 ) { // delete last separator
  40.                 $output = substr($output, 0, strlen($output)-strlen($sep));
  41.             }
  42.         }
  43.        
  44.     }  
  45.    
  46.     return $output;
  47.                    
  48. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement