| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $wpscfunction; |
| 7 |
|
| 8 |
|
| 9 |
$params = $request->get_params(); |
| 10 |
$ticket_id = isset( $params['id'] ) ? $params['id'] : 0; |
| 11 |
|
| 12 |
$response = array(); |
| 13 |
|
| 14 |
if ($wpscfunction->is_ticket($ticket_id)) { |
| 15 |
|
| 16 |
if($wpscfunction->has_permission('delete_ticket',$ticket_id)){ |
| 17 |
$wpscfunction->delete_tickets($ticket_id); |
| 18 |
$response = array( |
| 19 |
'ticket_deleted', |
| 20 |
'Ticket id '. $ticket_id .' is deleted successfully', |
| 21 |
array( |
| 22 |
'status' => 200, |
| 23 |
) |
| 24 |
); |
| 25 |
}else{ |
| 26 |
$response = array( |
| 27 |
'unauthorized', |
| 28 |
'You do not have permission to delete this ticket.', |
| 29 |
array( |
| 30 |
'status' => 404, |
| 31 |
) |
| 32 |
); |
| 33 |
} |
| 34 |
|
| 35 |
} else { |
| 36 |
|
| 37 |
$response = new WP_Error( |
| 38 |
'not_found', |
| 39 |
'Ticket not found for id '.$ticket_id, |
| 40 |
array( |
| 41 |
'status' => 404, |
| 42 |
) |
| 43 |
); |
| 44 |
|
| 45 |
} |