PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 2.3.1
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v2.3.1
3.5.4 3.5.3 3.5.2 3.5.1 3.4.9 3.5.0 3.4.8 3.4.7 trunk 2.3.1 3.3.6 3.3.7 3.3.8 3.3.9 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6
supportcandy / includes / rest_api / v1 / get_thread_response.php

get_thread_response.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/rest_api/v1/get_thread_response.php

43 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 exit; // Exit if accessed directly
4 }
5
6 global $current_user, $wpscfunction;
7
8 $ticket_id = get_post_meta( $thread->ID, 'ticket_id', true);
9 $auth_id = $wpscfunction->get_ticket_fields($ticket_id,'ticket_auth_code');
10
11 $attachments = get_post_meta( $thread->ID, 'attachments', true);
12 $attachments = is_array($attachments) ? $attachments : array();
13 $response_attachments = array();
14 foreach ($attachments as $attachment) {
15
16 $attach = array();
17 $attach_meta = get_term_meta($attachment);
18 foreach ($attach_meta as $key => $value) {
19 $attach[$key] = $value[0];
20 }
21 $upload_dir = wp_upload_dir();
22 $file_url = $upload_dir['baseurl'] . '/wpsc/'.$attach['save_file_name'];
23 $download_url = $attach['is_image'] ? $file_url : home_url('/').'?wpsc_attachment='.$attachment.'&tid='.$ticket_id.'&tac='.$auth_id;
24
25 $response_attachments[] = array(
26 'filename' => $attach['filename'],
27 'is_image' => $attach['is_image'],
28 'download_url' => $download_url,
29 );
30
31 }
32
33 $response = array(
34 'id' => $thread->ID,
35 'ticket_id' => $ticket_id,
36 'thread_type' => get_post_meta( $thread->ID, 'thread_type', true),
37 'user_name' => get_post_meta( $thread->ID, 'customer_name', true),
38 'user_email' => get_post_meta( $thread->ID, 'customer_email', true),
39 'thread_body' => $thread->post_content,
40 'attachments' => $response_attachments,
41 'date' => $thread->post_date_gmt,
42 );
43