From 33bd0e1f2ef6e12217bc95e18502200c9a395a95 Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 21 Aug 2014 00:06:47 +0530 Subject: [PATCH] Attachments are not attached in outbound mails Fixes #223 --- classes/class-supportflow-emails.php | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/classes/class-supportflow-emails.php b/classes/class-supportflow-emails.php index a5adb13..77582f0 100644 --- a/classes/class-supportflow-emails.php +++ b/classes/class-supportflow-emails.php @@ -169,11 +169,7 @@ public function email_conversation( $ticket_id, $to ) { $msg .= SupportFlow()->sanitize_ticket_reply( $ticket_reply->post_content ); $msg .= '

'; - if ( $ticket_attachments = get_posts( array( 'post_type' => 'attachment', 'post_parent' => $ticket_reply->ID, 'posts_per_page' => -1 ) ) ) { - foreach ( $ticket_attachments as $attachment ) { - $attachments[] = get_attached_file( $attachment->ID ); - } - } + $attachments[] = $this->get_attached_files( $ticket_reply->ID ); } self::mail( $to, $subject, $msg, 'Content-Type: text/html', $attachments ); } @@ -247,9 +243,9 @@ public function get_quoted_text( $ticket ) { public function get_attached_files( $reply_id ) { $attachments = array(); - if ( $ticket_attachments = get_posts( array( 'post_type' => 'attachment', 'post_parent' => $reply_id, 'posts_per_page' => -1 ) ) ) { + if ( $ticket_attachments = get_post_meta( $reply_id, 'sf_attachments' ) ) { foreach ( $ticket_attachments as $attachment ) { - $attachments[] = get_attached_file( $attachment->ID ); + $attachments[] = get_attached_file( $attachment ); } }