get_option( 'referrals_status', AFFILIATES_REFERRAL_STATUS_ACCEPTED );
if ( isset( $_POST['status'] ) ) {
switch ( $_POST['status'] ) {
case AFFILIATES_REFERRAL_STATUS_ACCEPTED :
case AFFILIATES_REFERRAL_STATUS_CLOSED :
case AFFILIATES_REFERRAL_STATUS_PENDING :
case AFFILIATES_REFERRAL_STATUS_REJECTED :
$status = $_POST['status'];
break;
}
}
$reference = isset( $_POST['reference'] ) ? wp_strip_all_tags( $_POST['reference'] ) : '';
$saved = false;
if ( isset( $_POST['save'] ) ) {
if ( !wp_verify_nonce( $_POST['referral-nonce'], 'save' ) ) {
wp_die( __( 'Access denied.', 'affiliates' ) );
} else {
if ( !empty( $affiliate_id ) ) {
if ( empty( $referral_id ) ) {
$action = apply_filters(
'affiliates_admin_referral_edit_add_referral',
array( 'add_referral' => true, 'output' => '' ),
compact( 'referral_id', 'affiliate_id', 'datetime', 'description', 'amount', 'currency_id', 'status', 'reference', 'reference_amount' )
);
$output .= !empty( $action['output'] ) ? $action['output'] : '';
if ( !empty( $action['referral_id'] ) ) {
$referral_id = $action['referral_id'];
}
if ( isset( $action['add_referral'] ) && $action['add_referral'] ) {
global $captured_referral_id;
add_action( 'affiliates_referral', 'affiliates_admin_referral_capture_id' );
affiliates_add_referral( $affiliate_id, null, $description, null, $amount, $currency_id, $status, 'manual', $reference, null, $reference_amount );
remove_action( 'affiliates_referral', 'affiliates_admin_referral_capture_id' );
if ( !empty( $captured_referral_id ) ) {
$referral_id = $captured_referral_id;
}
}
if ( !empty( $referral_id ) ) {
$output .= '
';
$output .= '