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 / admin / email_notifications / set_add_ticket_notification.php

set_add_ticket_notification.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/admin/email_notifications/set_add_ticket_notification.php

64 lines 2.6 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 if (
9 check_ajax_referer('set_add_ticket_notification', '_ajax_nonce', false) != 1
10 ) wp_send_json_error('Unauthorised request!', 400);
11
12 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {
13 exit;
14 }
15
16 // Title
17 $title = isset($_POST) && isset($_POST['wpsc_en_title']) ? sanitize_text_field($_POST['wpsc_en_title']) : '';
18 $term = wp_insert_term( $title, 'wpsc_en' );
19 if( !is_wp_error($term) && isset($term['term_id']) ){
20
21 $type = isset($_POST) && isset($_POST['wpsc_en_type']) ? sanitize_text_field($_POST['wpsc_en_type']) : '';
22 add_term_meta ($term['term_id'], 'type', $type);
23
24 $subject = isset($_POST) && isset($_POST['wpsc_en_subject']) ? sanitize_text_field($_POST['wpsc_en_subject']) : '';
25 add_term_meta ($term['term_id'], 'subject', $subject);
26
27 $body = isset($_POST) && isset($_POST['wpsc_en_body']) ? wp_kses_post(htmlspecialchars_decode($_POST['wpsc_en_body'], ENT_QUOTES)) : '';
28 add_term_meta ($term['term_id'], 'body', $body);
29
30 $recipients = isset($_POST) && isset($_POST['wpsc_en_recipients']) ? $wpscfunction->sanitize_array($_POST['wpsc_en_recipients']) : array();
31 add_term_meta ($term['term_id'], 'recipients', $recipients);
32
33 $extra_recip = isset($_POST) && isset($_POST['wpsc_en_extra_recipients']) ? sanitize_textarea_field($_POST['wpsc_en_extra_recipients']) : '';
34 $extra_recipients = $extra_recip ? explode("\n", $extra_recip) : array();
35
36 $extra_recipients = $wpscfunction->sanitize_array($extra_recipients);
37 add_term_meta ($term['term_id'], 'extra_recipients', $extra_recipients);
38
39 $conditions = isset($_POST) && isset($_POST['conditions']) && $_POST['conditions'] != '[]' ? sanitize_text_field($_POST['conditions']) : '';
40 add_term_meta ($term['term_id'], 'conditions', $conditions);
41
42 do_action('wpsc_set_add_ticket_notification',$term);
43
44 $email_subject = get_option('wpsc_email_notification_subject');
45 if (!$email_subject) {
46 $email_subject = array();
47 }
48 $email_subject['email_subject_' . $term['term_id']] = $subject;
49 update_option('wpsc_email_notification_subject', $email_subject);
50
51
52 $email_body = get_option('wpsc_email_notification_body');
53 if (!$email_body) {
54 $email_body = array();
55 }
56 $email_body['email_body_' . $term['term_id']] = $body;
57 update_option('wpsc_email_notification_body', $email_body);
58
59 echo '{ "sucess_status":"1","messege":"'.__('Email Notification added successfully.','supportcandy').'" }';
60
61 } else {
62 echo '{ "sucess_status":"0","messege":"'.__('An error occured while creating email notification.','supportcandy').'" }';
63 }
64