public static function affiliates_landing($attr = array(), $content = null) { global $wpdb; remove_shortcode('affiliates_landing'); $content = do_shortcode($content); add_shortcode('affiliates_landing', array(__CLASS__, 'affiliates_landing')); $output = ""; if (strlen($content) > 0) { $base_url = trim($content); $base_url = str_replace('&', '&', $base_url); $base_url = strip_tags($base_url); $base_url = preg_replace('/\\r|\\n/', '', $base_url); $base_url = trim($base_url); } if (!class_exists("Affiliates_Service")) { require_once AFFILIATES_CORE_LIB . '/class-affiliates-service.php'; } if (isset($_GET[get_option('aff_pname', AFFILIATES_PNAME)])) { $affiliate_id = $_GET[get_option('aff_pname', AFFILIATES_PNAME)]; } else { if (isset($_POST[get_option('aff_pname', AFFILIATES_PNAME)])) { $affiliate_id = $_POST[get_option('aff_pname', AFFILIATES_PNAME)]; } else { $affiliate_id = Affiliates_Service::get_referrer_id(); } } $output .= affiliates_get_affiliate_url($base_url, $affiliate_id); return $output; }
function dp_gform_field_value_referrer_id($value) { include_once AFFILIATES_CORE_LIB . '/class-affiliates-service.php'; if (class_exists('Affiliates_Service') && method_exists('Affiliates_Service', 'get_referrer_id')) { if ($affiliate_id = Affiliates_Service::get_referrer_id()) { $value = $affiliate_id; } } return $affiliate_id; }
function affiliate_pro_referrer($new_affiliate_id) { $referrer_id = 1; $active_plugins = get_option('active_plugins', array()); $affiliates_pro_is_active = in_array('affiliates-pro/affiliates-pro.php', $active_plugins); if ($affiliates_pro_is_active) { include_once ABSPATH . 'wp-content/plugins/affiliates-pro/lib/core/class-affiliates-service.php'; if (Affiliates_Service::get_referrer_id($service = null)) { $referrer_id = Affiliates_Service::get_referrer_id($service = null); $options = get_option('affiliate_referrers', array()); } $options[] = array($referrer_id => (int) $new_affiliate_id); update_option('affiliate_referrers', $options, false); } }
/** * Renders the referrer's username. * @param array $atts * @param string $content not used * @return string */ public static function referrer_user($atts, $content = null) { $options = shortcode_atts(array('direct' => false, 'display' => 'user_login'), $atts); extract($options); $output = ''; require_once 'class-affiliates-service.php'; $affiliate_id = Affiliates_Service::get_referrer_id(); if ($affiliate_id) { if ($direct || $affiliate_id !== affiliates_get_direct_id()) { if ($user_id = affiliates_get_affiliate_user($affiliate_id)) { if ($user = get_user_by('id', $user_id)) { switch ($display) { case 'user_login': $output .= $user->user_login; break; case 'user_nicename': $output .= $user->user_nicename; break; case 'user_email': $output .= $user->user_email; break; case 'user_url': $output .= $user->user_url; break; case 'display_name': $output .= $user->display_name; break; default: $output .= $user->user_login; } $output = wp_strip_all_tags($output); } } } } return $output; }
/** * Suggest to record a referral. This function is used to actually store referrals and associated information. * If a valid affiliate is found, the referral is stored and attributed to the affiliate and the affiliate's id is returned. * Use the $description to describe the nature of the referral and the associated transaction. * Use $data to store transaction data or additional information as needed. * * $data must either be a string or an array. If given as an array, it is assumed that one provides * field data (for example: customer id, transaction id, customer name, ...) and for each field * one entry is added to the $data array obeying this format: * * $data['example'] = array( * 'title' => 'Field title', * 'domain' => 'Domain' * 'value' => 'Field value' * ); * * This information is then used to display field data for each referral in the Referrals section. * * 'title' is the field's title, the title is translated using the 'domain'. * 'value' is displayed as the field's value. * * Example: * * A customer has submitted an order and a possible referral shall be recorded, including the customer's id * and the order id: * * $data = array( * 'customer-id' => array( 'title' => 'Customer Id', 'domain' => 'my_order_plugin', 'value' => $customer_id ), * 'order-id' => array( 'title' => 'Order Id', 'domain' => 'my_order_plugin', 'value' => $order_id ) * ); * if ( $affiliate_id = affiliates_suggest_referral( $post_id, "Referral for order number $order_id", $data ) ) { * $affiliate = affiliates_get_affiliate( $affiliate_id ); * $affiliate_email = $affiliate['email']; * if ( !empty( $affiliate_email ) ) { * $message = "Dear Affiliate, an order has been made. You will be credited as soon as payment is received."; * my_order_plugin_send_an_email( $affiliate_email, $message ); * } * } * * @param int $post_id the referral post id; where the transaction or referral originates * @param string $description the referral description * @param string|array $data additional information that should be stored along with the referral * @param string $amount referral amount - if used, a $currency_id must be given * @þaram string $currency_id three letter currency code - if used, an $amount must be given * @return affiliate id if a valid referral is recorded, otherwise false */ function affiliates_suggest_referral($post_id, $description = '', $data = null, $amount = null, $currency_id = null, $status = null, $type = null, $reference = null) { global $wpdb, $affiliates_options; require_once 'class-affiliates-service.php'; $affiliate_id = Affiliates_Service::get_referrer_id(); if ($affiliate_id) { $affiliate_id = affiliates_add_referral($affiliate_id, $post_id, $description, $data, $amount, $currency_id, $status, $type, $reference); } return $affiliate_id; }