Guest User

Untitled

a guest
May 26th, 2015
239
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. Author: eggemplo
  7. Version: 1.0
  8. Author URI: http://www.eggemplo.com
  9. */
  10. add_action ( 'init', 'add_aff_referrer_info_shortcodes' );
  11. function add_aff_referrer_info_shortcodes($data) {
  12. add_shortcode ( 'aff-referrer-info', 'aff_referrer_info' );
  13. add_shortcode ( 'aff_referrer_info', 'aff_referrer_info' );
  14. }
  15. function aff_referrer_info ($attr = array()) {
  16.  
  17. $output = "";
  18. $sep = isset( $attr['separator'] ) ? $attr['separator'] : "<br>";
  19. $direct = isset( $attr['show_direct'] ) ? true : false;
  20.  
  21. $name = isset( $attr['show_name'] ) ? true : false;
  22. $email = isset( $attr['show_email'] ) ? true : false;
  23. $user_id = isset( $attr['show_user_id '] ) ? true : false;
  24.  
  25. if ( !class_exists("Affiliates_Service" ) ) {
  26. require_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' );
  27. }
  28.  
  29. $affiliate_id = Affiliates_Service::get_referrer_id();
  30. if ( $affiliate_id ) {
  31. $affiliate = affiliates_get_affiliate( $affiliate_id );
  32.  
  33. if ( $direct || ( $affiliate_id !== affiliates_get_direct_id() ) ) {
  34. if ( $name ) {
  35. $output .= $affiliate['name'] . $sep;
  36. }
  37. if ( $affiliate_id ) {
  38. $output .= $affiliate['user_id'] . $sep;
  39. }
  40.  
  41. if ( $email ) {
  42. $output .= $affiliate['email'] . $sep;
  43. }
  44.  
  45. if ( strlen($output)>0 ) { // delete last separator
  46. $output = substr($output, 0, strlen($output)-strlen($sep));
  47. }
  48. if ( $user_id ) {
  49. if ( $user_id = affiliates_get_affiliate_user( $affiliate_id ) ) {
  50. $user = get_user_by( 'id', $user_id );
  51. }
  52. }
  53. }
  54.  
  55. }
  56.  
  57. return $output;
  58.  
  59. }
  60. add_filter ( 'affiliates_service_affiliate_id', 'affiliates_service_affiliate_id_from_url', 10, 2 );
  61.  
  62. function affiliates_service_affiliate_id_from_url ( $affiliate_id, $service ) {
  63. global $wp, $wpdb;
  64.  
  65. $pname = get_option( 'aff_pname', AFFILIATES_PNAME );
  66. $affiliate_id = isset( $_GET[$pname] ) ? affiliates_check_affiliate_id_encoded( trim( $_GET[$pname] ) ) : $affiliate_id;
  67.  
  68. if ( isset( $_GET[$pname] ) ) {
  69. // affiliates-by-username uses this hook
  70. $maybe_affiliate_id = apply_filters( 'affiliates_parse_request_affiliate_id', $_GET[$pname], $affiliate_id );
  71. if ( ( $maybe_affiliate_id !== null ) && $maybe_affiliate_id !== trim( $_GET[$pname] ) ) {
  72. $affiliate_id = $maybe_affiliate_id;
  73. }
  74. }
  75. return $affiliate_id;
  76.  
  77. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×