Commit 01ecc6ce authored by Zack Katz's avatar Zack Katz

Merge branch 'develop' into 'master'

Fixed: Sending email notifications with AffiliateWP 1.7.16+



See merge request !1
parents 6a60aaac 165d878a
Pipeline #1089765 skipped
......@@ -5,7 +5,7 @@
* Description: Import affiliates from E-Junkie into AffiliateWP.
* Author: Katz Web Services, Inc.
* Author URI: http://katz.co
* Version: 1.1.1
* Version: 1.1.2
* Text Domain: affiliatewp-ejunkie-migrate
* Domain Path: languages
*
......@@ -15,7 +15,7 @@
class E_Junkie_AffiliateWP_Import {
const version = '1.1.1';
const version = '1.1.2';
/**
* Name we expect hosting website to have.
......@@ -100,7 +100,6 @@ class E_Junkie_AffiliateWP_Import {
/**
* Handle notifications, reporting.
* @return void
* @filter affiliatewp_ejunkie_notify_imported_affiliates boolean: Whether to notify imported affiliates. Default: `false`
*/
function after_import() {
......@@ -125,16 +124,11 @@ class E_Junkie_AffiliateWP_Import {
$output = '<ul class="ul-disc">';
// Should imported affiliates be emailed?
$notify = apply_filters('affiliatewp_ejunkie_notify_imported_affiliates', false );
foreach ( (array) $this->inserted_affiliates as $affiliate_id => $user_data ) {
$output .= '<li>'.sprintf( 'Added Affiliate #%d (%s)', $affiliate_id, $user_data['email'] ).'</li>';
if( $notify ) {
affiliate_wp()->emails->notification( 'registration', array( 'affiliate_id' => $affiliate_id ) );
}
$this->maybe_notify_affiliate( $affiliate_id );
}
$output .= '</ul>';
......@@ -143,6 +137,43 @@ class E_Junkie_AffiliateWP_Import {
}
}
/**
* Maybe notify affiliates after import
*
* @since 1.1.2
* @param int $affiliate_id Imported Affiliate ID
* @filter affiliatewp_ejunkie_notify_imported_affiliates boolean: Whether to notify imported affiliates. Default: `false`
* @filter affiliatewp_ejunkie_import_status Change whether affiliate should be 'active', 'pending', or 'rejected' (Default: `active`)
* @return void
*/
function maybe_notify_affiliate( $affiliate_id ) {
// Should imported affiliates be emailed?
$notify = apply_filters( 'affiliatewp_ejunkie_notify_imported_affiliates', false );
$status = apply_filters( 'affiliatewp_ejunkie_import_status', 'active' );
if( $notify ) {
switch ( $status ) {
case 'active':
if( function_exists( 'affwp_notify_on_approval' ) ) {
affwp_notify_on_approval( $affiliate_id, $status );
}
break;
case 'pending':
if( function_exists( 'affwp_notify_on_pending_affiliate_registration' ) ) {
affwp_notify_on_pending_affiliate_registration( $affiliate_id, $status );
}
break;
case 'rejected':
if( function_exists( 'affwp_notify_on_rejected_affiliate_registration' ) ) {
affwp_notify_on_rejected_affiliate_registration( $affiliate_id, $status, 'pending' );
}
break;
}
}
}
/**
* Add Import Metabox to AffiliateWP Import/Export page
*
......@@ -411,7 +442,7 @@ class E_Junkie_AffiliateWP_Import {
* @param array $user_data Data to be added to the affiliate
* @return int|boolean Affiliate ID, if successful. `false` if not.
* @filter affiliatewp_ejunkie_affiliate_data Modify the data of the affiliate before they get added to AffiliateWP
* @filter affiliatewp_ejunkie_import_status Change whether affiliate should be 'active' or 'pending' (Default: 'active')
* @filter affiliatewp_ejunkie_import_status Change whether affiliate should be 'active', 'pending', or 'rejected' (Default: 'active')
*/
function maybe_insert_affiliate( $user_id, $user_data ) {
......
......@@ -33,8 +33,9 @@ Import E-Junkie Affiliates into AffiliateWP.
== Changelog ==
= 1.1.1 on March 25, 2016 =
= 1.1.1 & 1.1.2 on March 25, 2016 =
* Fixed: Sending email notifications with AffiliateWP 1.7.16+
* Now requires AffiliateWP 1.7.16 or higher
* Fixed: `Call to a member function get_error_message() on string` error
= 1.1 =
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment