get_campaign_donations(); // Clean output buffers to ensure no contamination. while ( ob_get_level() > 0 ) { ob_end_clean(); } // Instantiate and send the email. $email_object = new $class( array( 'donation' => $donation, 'campaign' => ! empty( $campaign_donations ) ? charitable_get_campaign( current( $campaign_donations )->campaign_id ) : null, ) ); if ( method_exists( $email_object, 'send' ) ) { $email_object->send(); } } );