| 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('delete_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 |
$email_subject = get_option('wpsc_email_notification_subject'); |
| 20 |
unset($email_subject['email_subject_' . $term_id]); |
| 21 |
update_option('wpsc_email_notification_subject', $email_subject); |
| 22 |
|
| 23 |
$email_body = get_option('wpsc_email_notification_body'); |
| 24 |
unset($email_body['email_body_' . $term_id]); |
| 25 |
update_option('wpsc_email_notification_body', $email_body); |
| 26 |
|
| 27 |
$response = wp_delete_term( $term_id,'wpsc_en'); |
| 28 |
|
| 29 |
if(!is_wp_error($response)){ |
| 30 |
|
| 31 |
do_action('wpsc_delete_ticket_notification',$term_id); |
| 32 |
echo '{ "sucess_status":"1","messege":"'.__('Email Notification delete successfull.','supportcandy').'" }'; |
| 33 |
|
| 34 |
} else { |
| 35 |
echo '{ "sucess_status":"0","messege":"'.__('An error occured while deleting email notification.','supportcandy').'" }'; |
| 36 |
} |
| 37 |
|