/**
  * Get the affiliate ID
  *
  * @since 1.0.0
  */
 public function get_affiliate_id()
 {
     // credit last referrer enabled
     $credit_last_referrer = affiliate_wp()->settings->get('referral_credit_last');
     // get referral variable (eg ref)
     $referral_var = affiliate_wp()->tracking->get_referral_var();
     // if credit last referrer is enabled it needs to get the affiliate ID from the URL straight away
     if ($credit_last_referrer) {
         if ($this->get_the_affiliate_id()) {
             $affiliate_id = $this->get_the_affiliate_id();
         } elseif (affiliate_wp()->tracking->get_affiliate_id()) {
             // get affiliate ID from cookies
             $affiliate_id = affiliate_wp()->tracking->get_affiliate_id();
         } else {
             // no affiliate ID
             $affiliate_id = '';
         }
     } else {
         // get affiliate from cookie first
         if (affiliate_wp()->tracking->get_affiliate_id()) {
             $affiliate_id = affiliate_wp()->tracking->get_affiliate_id();
         } elseif ($this->get_the_affiliate_id()) {
             $affiliate_id = $this->get_the_affiliate_id();
         } else {
             // no affiliate ID
             $affiliate_id = '';
         }
     }
     // finally, check if they are a valid affiliate
     if ($affiliate_id && affwp_is_affiliate(affwp_get_affiliate_user_id($affiliate_id)) && affwp_is_active_affiliate($affiliate_id)) {
         return $affiliate_id;
     }
     return false;
 }
Exemplo n.º 2
0
 /**
  * Affiliate creatives shortcode.
  * Shows all the creatives from Affiliates -> Creatives
  *
  * @since  1.1.4
  * @return string
  */
 public function affiliate_creatives($atts, $content = null)
 {
     $atts = shortcode_atts(array('preview' => 'yes', 'number' => 20), $atts, 'affiliate_creatives');
     if (!(affwp_is_affiliate() && affwp_is_active_affiliate())) {
         return;
     }
     $content = affiliate_wp()->creative->affiliate_creatives($atts);
     return do_shortcode($content);
 }
 /**
  * Show a logout link for the affiliate
  *
  * [affiliate_logout]
  *
  * @since  1.1
  */
 function affiliate_logout($atts, $content = null)
 {
     if (!(affwp_is_affiliate() && affwp_is_active_affiliate())) {
         return;
     }
     $redirect = function_exists('affiliate_wp') && affiliate_wp()->settings->get('affiliates_page') ? affiliate_wp()->login->get_login_url() : home_url();
     $redirect = apply_filters('affwp_aas_logout_redirect', $redirect);
     $content = apply_filters('affwp_aas_logout_link', '<a href=" ' . wp_logout_url($redirect) . '">' . __('Log out', 'affiliatewp-affiliate-area-shortcodes') . '</a>', $redirect);
     return do_shortcode($content);
 }