本文整理汇总了PHP中affiliate_wp函数的典型用法代码示例。如果您正苦于以下问题:PHP affiliate_wp函数的具体用法?PHP affiliate_wp怎么用?PHP affiliate_wp使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了affiliate_wp函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_data
/**
* Retrieve referral data
*
* @since 1.1
*/
public function get_data()
{
$dates = affwp_get_report_dates();
$start = $dates['year'] . '-' . $dates['m_start'] . '-' . $dates['day'] . ' 00:00:00';
$end = $dates['year_end'] . '-' . $dates['m_end'] . '-' . $dates['day_end'] . ' 23:59:59';
$date = array('start' => $start, 'end' => $end);
$affiliates = affiliate_wp()->affiliates->get_affiliates(array('orderby' => 'date_registered', 'order' => 'ASC', 'number' => -1, 'date' => $date));
$affiliate_data = array();
$affiliate_data[] = array(strtotime($start) * 1000);
$affiliate_data[] = array(strtotime($end) * 1000);
if ($affiliates) {
foreach ($affiliates as $affiliate) {
if ('today' == $dates['range'] || 'yesterday' == $dates['range']) {
$point = strtotime($affiliate->date_registered) * 1000;
$affiliate_data[$point] = array($point, 1);
} else {
$time = date('Y-n-d', strtotime($affiliate->date_registered));
$timestamp = strtotime($time) * 1000;
if (array_key_exists($time, $affiliate_data) && isset($affiliate_data[$time][1])) {
$count = $affiliate_data[$time][1] += 1;
$affiliate_data[$time] = array($timestamp, $count);
} else {
$affiliate_data[$time] = array($timestamp, 1);
}
}
}
}
$data = array(__('Affiliate Registrations', 'affiliate-wp') => $affiliate_data);
return $data;
}
示例2: do_affiliates
public function do_affiliates($step = 1)
{
global $wpdb;
$offset = ($step - 1) * 100;
$affiliates = $wpdb->get_results("SELECT * FROM {$wpdb->prefix}affiliates_tbl LIMIT {$offset}, 100;");
$to_delete = array();
if ($affiliates) {
foreach ($affiliates as $affiliate) {
if (empty($affiliate->email)) {
continue;
}
$user = get_user_by('email', $affiliate->email);
if (is_wp_error($user) || !$user) {
$user_id = wp_insert_user(array('user_email' => $affiliate->email, 'first_name' => $affiliate->firstname, 'last_name' => $affiliate->lastname, 'user_url' => $affiliate->website, 'user_pass' => '', 'user_login' => $affiliate->email));
} else {
$user_id = $user->ID;
}
$payment_email = !empty($affiliate->paypalemail) ? $affiliate->paypalemail : $affiliate->email;
$status = 'approved' == $affiliate->account_status ? 'active' : 'pending';
$args = array('date_registered' => date('Y-n-d H:i:s', strtotime($affiliate->date)), 'user_id' => $user_id, 'payment_email' => $payment_email, 'rate' => $affiliate->commissionlevel, 'status' => $status);
// Try to get an existing affiliate based on the user_id
$existing_affiliate = affiliate_wp()->affiliates->get_by('user_id', $user_id);
if ($existing_affiliate) {
continue;
}
// Insert a new affiliate - we need to always insert to make sure the affiliate_ids will match
$id = affiliate_wp()->affiliates->insert($args, 'affiliate');
}
return true;
} else {
// No affiliates found, so all done
return false;
}
}
示例3: revoke_referral_on_refund
/**
* Reject referrals when the transaction is refunded
*
* @access public
* @since 1.5
*/
public function revoke_referral_on_refund($txn)
{
if (!affiliate_wp()->settings->get('revoke_on_refund')) {
return;
}
$this->reject_referral($txn->id);
}
示例4: affwp_allowed_products_get_products
/**
* Get allowed products
*
* @since 1.0
*/
function affwp_allowed_products_get_products()
{
$products = affiliate_wp()->settings->get('allowed_products');
$products = explode(',', $products);
$products = array_filter(array_map('trim', $products));
return $products;
}
示例5: revoke_referral_on_delete
public function revoke_referral_on_delete($order_id = 0, $order)
{
if (!affiliate_wp()->settings->get('revoke_on_refund')) {
return;
}
$this->reject_referral($order_id);
}
示例6: revoke_referral_on_refund
public function revoke_referral_on_refund($data)
{
if (!affiliate_wp()->settings->get('revoke_on_refund')) {
return;
}
$reference = $data['member_id'] . '|' . $data['order_number'] . '-' . $data['order_transaction_id'];
$this->reject_referral($reference);
}
示例7: setUp
function setUp()
{
parent::setUp();
$args = array('user_id' => 1);
$this->_affiliate_id = affiliate_wp()->affiliates->add($args);
$args = array('affiliate_id' => $this->_affiliate_id, 'amount' => 10, 'status' => 'pending', 'context' => 'tests', 'custom' => 4, 'reference' => 5);
$this->_referral_id = affiliate_wp()->referrals->add($args);
}
示例8: revoke_referral_on_refund
public function revoke_referral_on_refund($order_id = 0, $current_status, $previous_status, $order)
{
if (!affiliate_wp()->settings->get('revoke_on_refund')) {
return;
}
if ($order->is_refunded() || $order->is_payment_declined()) {
$this->reject_referral($order_id);
}
}
示例9: test_add_affiliate
function test_add_affiliate()
{
$args = array('user_id' => 1);
$affiliate_id = affiliate_wp()->affiliates->add($args);
$this->assertFalse($affiliate_id);
$args = array('user_id' => 2);
$this->_affiliate_id2 = affiliate_wp()->affiliates->add($args);
$this->assertGreaterThan(0, $this->_affiliate_id2);
}
示例10: revoke_referral_on_delete
/**
* Revokes a referral when the payment is deleted
*
* @access public
* @since 1.0
*/
public function revoke_referral_on_delete($payment_id = 0)
{
if (!affiliate_wp()->settings->get('revoke_on_refund')) {
return;
}
$payments = new RCP_Payments();
$payment = $payments->get_payment($payment_id);
$this->reject_referral($payment->subscription_key);
}
示例11: track_refund
/**
* Handle refunds
* @param $old_invoice
* @param $new_post
* @since 1.7.5
*/
public function track_refund($old_invoice, $new_post)
{
if ($new_post['post_status'] !== 'refund') {
return;
}
if (!affiliate_wp()->settings->get('revoke_on_refund')) {
return;
}
$this->reject_referral($old_invoice['invoice_id']);
}
示例12: revoke_referral_on_delete
/**
* Revoke a referral when a submission is deleted or trashed
*
* @access private
* @since 1.6
*/
public function revoke_referral_on_delete($sub_id = 0)
{
if (!affiliate_wp()->settings->get('revoke_on_refund')) {
return;
}
if ('nf_sub' != get_post_type($sub_id)) {
return;
}
$this->reject_referral($sub_id);
}
示例13: affwp_custom_append_affiliate_id_to_jetpack_sharing_links
/**
* Plugin Name: AffiliateWP - Append Affiliate ID To Jetpack Sharing Links
* Plugin URI: http://affiliatewp.com
* Description: Automatically appends an affiliate's ID to Jetpack sharing links.
* Author: Andrew Munro, Sumobi
* Author URI: http://sumobi.com
* Version: 1.0
*/
function affwp_custom_append_affiliate_id_to_jetpack_sharing_links($permalink, $post_id, $id)
{
// return if non-affiliate
if (!(is_user_logged_in() && affwp_is_affiliate())) {
return $permalink;
}
// append referral variable and affiliate ID to sharing links in Jetpack
$permalink = add_query_arg(affiliate_wp()->tracking->get_referral_var(), affwp_get_affiliate_id(), $permalink);
return $permalink;
}
开发者ID:companyjuice,项目名称:affiliatewp-code-snippet-library,代码行数:18,代码来源:append-affiliate-id-to-jetpack-sharing-links.php
示例14: affwp_custom_affiliate_area_shortcode
function affwp_custom_affiliate_area_shortcode($atts, $content = null)
{
ob_start();
if (is_user_logged_in() && affwp_is_affiliate()) {
// show the affiliate dashboard for logged in affiliates
affiliate_wp()->templates->get_template_part('dashboard');
} elseif (!is_user_logged_in()) {
affiliate_wp()->templates->get_template_part('login');
}
return ob_get_clean();
}
示例15: affwp_modify_first_referral_flat_amount
/**
* Example Two
*
* Give the affiliate a $10 commission for each product, but only for their very first referral
*/
function affwp_modify_first_referral_flat_amount($referral_amount, $affiliate_id, $amount, $reference, $product_id)
{
// get the affiliate's referrals
$referrals = affiliate_wp()->referrals->get_referrals(array('affiliate_id' => $affiliate_id));
// if they haven't made a referral before, give them $10.00 on each product
if (empty($referrals)) {
$referral_amount = 10.0;
// $10.00
}
return $referral_amount;
}
开发者ID:companyjuice,项目名称:affiliatewp-code-snippet-library,代码行数:16,代码来源:modify-first-referral-commission-amount.php