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 / submit_reply.php

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

63 lines 1.7 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 $wpdb, $current_user, $wpscfunction;
7
8 $params = $request->get_params();
9
10 //Get Ticket Id
11 $ticket_id = isset( $params['id'] ) ? sanitize_text_field($params['id']) : 0;
12
13 $response = array();
14
15 //Get Reply body
16 $reply_body = isset($params['reply_body']) ? wp_kses_post(htmlspecialchars_decode($params['reply_body'], ENT_QUOTES)) : '';
17 //$reply_body = str_replace(' ', '&nbsp;', $reply_body);
18
19 // Attachments for reply description
20 $desc_attachment = isset($params['attachments']) && trim($params['attachments']) != '' ? json_decode($params['attachments']) : new stdClass();
21 $description_attachment = isset($desc_attachment->attachments) ? $wpscfunction->sanitize_array($desc_attachment->attachments) : array();
22 $attachments = array();
23 foreach ($description_attachment as $key => $value) {
24 $attachment_id = intval($value);
25 $attachments[] = $attachment_id;
26 update_term_meta ($attachment_id, 'active', '1');
27 }
28
29 // Prepare arguments
30 $args = array(
31 'ticket_id' => $ticket_id,
32 'reply_body' => $wpscfunction->replace_macro($reply_body,$ticket_id),
33 'attachments' => $attachments,
34 'customer_name' => $current_user->display_name,
35 'customer_email' => $current_user->user_email,
36 'thread_type' => 'reply'
37 );
38
39 $args = apply_filters( 'wpsc_thread_args', $args );
40
41 if ($reply_body) {
42
43 $thread_id = $wpscfunction->submit_ticket_thread($args);
44
45 do_action( 'wpsc_after_submit_reply', $thread_id, $ticket_id );
46
47 $response = array(
48 'status' => 200,
49 'thread_id' => $thread_id
50 );
51
52 } else {
53
54 $response = new WP_Error(
55 'operation_failed',
56 'Reply not submitted.',
57 array(
58 'status' => 403,
59 )
60 );
61
62 }
63