| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user; |
| 7 |
|
| 8 |
if ( |
| 9 |
check_ajax_referer('delete_priority', '_ajax_nonce', false) != 1 |
| 10 |
) wp_send_json_error('Unauthorised request!', 400); |
| 11 |
|
| 12 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;} |
| 13 |
|
| 14 |
$priority_id = isset($_POST) && isset($_POST['priority_id']) ? intval($_POST['priority_id']) : 0; |
| 15 |
if (!$priority_id) {exit;} |
| 16 |
|
| 17 |
$wpsc_default_ticket_priority = get_option('wpsc_default_ticket_priority'); |
| 18 |
if ($wpsc_default_ticket_priority == $priority_id){ |
| 19 |
echo '{ "sucess_status":"0","messege":"'.__('Default ticket priority can not be deleted.','supportcandy').'" }'; |
| 20 |
die(); |
| 21 |
} |
| 22 |
|
| 23 |
$wpsc_custom_priority_localize = get_option('wpsc_custom_priority_localize'); |
| 24 |
unset($wpsc_custom_priority_localize['custom_priority_'.$priority_id]); |
| 25 |
update_option('wpsc_custom_priority_localize', $wpsc_custom_priority_localize); |
| 26 |
|
| 27 |
wp_delete_term($priority_id, 'wpsc_priorities'); |
| 28 |
|
| 29 |
do_action('wpsc_delete_priority',$priority_id); |
| 30 |
|
| 31 |
echo '{ "sucess_status":"1","messege":"'.__('Priority deleted successfully.','supportcandy').'" }'; |
| 32 |
|