/** * Get the referral format value * * @since 1.6 * @param string $format referral format passed in via [affiliate_referral_url] shortcode * @return string affiliate ID or username */ function affwp_get_referral_format_value($format = '', $affiliate_id = 0) { // get affiliate's user ID $user_id = affwp_get_affiliate_user_id($affiliate_id); if (!$format) { $format = affwp_get_referral_format(); } switch ($format) { case 'username': $value = urlencode(affwp_get_affiliate_username($affiliate_id)); break; case 'id': default: $value = affwp_get_affiliate_id($user_id); break; } return apply_filters('affwp_get_referral_format_value', $value, $format, $affiliate_id); }
/** * Get the referral format value * * @since 1.6 * @param string $format referral format passed in via [affiliate_referral_url] shortcode * @return string affiliate ID or username */ function affwp_get_referral_format_value($format = '', $affiliate_id = 0) { // get affiliate's user ID $user_id = affwp_get_affiliate_user_id($affiliate_id); if (!$format) { $format = affwp_get_referral_format(); } switch ($format) { case 'username': $value = affwp_get_affiliate_username($affiliate_id); break; case 'id': default: $value = affwp_get_affiliate_id($user_id); break; } return $value; }
_e('Referral URL Generator', 'affiliate-wp'); ?> </h4> <?php if ('id' == affwp_get_referral_format()) { ?> <p><?php printf(__('Your affiliate ID is: <strong>%s</strong>', 'affiliate-wp'), affwp_get_affiliate_id()); ?> </p> <?php } elseif ('username' == affwp_get_referral_format()) { ?> <p><?php printf(__('Your affiliate username is: <strong>%s</strong>', 'affiliate-wp'), affwp_get_affiliate_username()); ?> </p> <?php } ?> <p><?php printf(__('Your referral URL is: <strong>%s</strong>', 'affiliate-wp'), esc_url(urldecode(affwp_get_affiliate_referral_url()))); ?> </p> <p><?php _e('Enter any URL from this website in the form below to generate a referral link!', 'affiliate-wp'); ?> </p>
/** * Show an affiliate's username * * [affiliate_username] * * @since 1.1.1 */ function affiliate_username($atts, $content = null) { if (!(affwp_is_affiliate() && affwp_is_active_affiliate())) { return; } $content = affwp_get_affiliate_username(); return do_shortcode($content); }