| 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_edit_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 |
$term_id = isset($_POST) && isset($_POST['term_id']) ? intval($_POST['term_id']) : 0; |
| 17 |
if(!$term_id) die(); |
| 18 |
|
| 19 |
// Title |
| 20 |
$title = isset($_POST) && isset($_POST['wpsc_en_title']) ? sanitize_text_field($_POST['wpsc_en_title']) : ''; |
| 21 |
wp_update_term($term_id, 'wpsc_en', array('name' => $title)); |
| 22 |
|
| 23 |
$type = isset($_POST) && isset($_POST['wpsc_en_type']) ? sanitize_text_field($_POST['wpsc_en_type']) : ''; |
| 24 |
update_term_meta ($term_id, 'type', $type); |
| 25 |
|
| 26 |
$subject = isset($_POST) && isset($_POST['wpsc_en_subject']) ? sanitize_text_field($_POST['wpsc_en_subject']) : ''; |
| 27 |
update_term_meta ($term_id, 'subject', $subject); |
| 28 |
|
| 29 |
$body = isset($_POST) && isset($_POST['wpsc_en_body']) ? wp_kses_post(htmlspecialchars_decode($_POST['wpsc_en_body'], ENT_QUOTES)) : ''; |
| 30 |
update_term_meta ($term_id, 'body', $body); |
| 31 |
|
| 32 |
$recipients = isset($_POST) && isset($_POST['wpsc_en_recipients']) ? $wpscfunction->sanitize_array($_POST['wpsc_en_recipients']) : array(); |
| 33 |
update_term_meta ($term_id, 'recipients', $recipients); |
| 34 |
|
| 35 |
$extra_recip = isset($_POST) && isset($_POST['wpsc_en_extra_recipients']) ? sanitize_textarea_field($_POST['wpsc_en_extra_recipients']) : ''; |
| 36 |
$extra_recipients = $extra_recip ? explode("\n", $extra_recip) : array(); |
| 37 |
|
| 38 |
$extra_recipients = $wpscfunction->sanitize_array($extra_recipients); |
| 39 |
update_term_meta ($term_id, 'extra_recipients', $extra_recipients); |
| 40 |
|
| 41 |
$conditions = isset($_POST) && isset($_POST['conditions']) && $_POST['conditions'] != '[]' ? sanitize_text_field($_POST['conditions']) : ''; |
| 42 |
update_term_meta ($term_id, 'conditions', $conditions); |
| 43 |
|
| 44 |
do_action('wpsc_set_edit_ticket_notification',$term_id); |
| 45 |
|
| 46 |
$email_subject = get_option('wpsc_email_notification_subject'); |
| 47 |
if (!$email_subject) { |
| 48 |
$email_subject = array(); |
| 49 |
} |
| 50 |
$email_subject['email_subject_' . $term_id] = $subject; |
| 51 |
update_option('wpsc_email_notification_subject', $email_subject); |
| 52 |
|
| 53 |
|
| 54 |
$email_body = get_option('wpsc_email_notification_body'); |
| 55 |
if (!$email_body) { |
| 56 |
$email_body = array(); |
| 57 |
} |
| 58 |
$email_body['email_body_' . $term_id] = $body; |
| 59 |
update_option('wpsc_email_notification_body', $email_body); |
| 60 |
|
| 61 |
echo '{ "sucess_status":"1","messege":"'.__('Email Notification updated successfully.','supportcandy').'" }'; |
| 62 |
|