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 );
}
}