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 / custom_fields / delete_custom_field.php

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

34 lines 1.2 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 if (
7 check_ajax_referer('delete_custom_field', '_ajax_nonce', false) != 1
8 ) wp_send_json_error('Unauthorised request!', 400);
9
10 global $current_user;
11 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;}
12
13 $field_id = isset($_POST) && isset($_POST['field_id']) ? intval($_POST['field_id']) : 0;
14 if (!$field_id) {exit;}
15
16 $wpsc_tf_type = get_term_meta( $field_id, 'wpsc_tf_type', true);
17
18 if ($wpsc_tf_type!='0') {
19 $custom_fields_localize = get_option('wpsc_custom_fields_localize');
20 unset($custom_fields_localize['custom_fields_' .$field_id]);
21 update_option('wpsc_custom_fields_localize', $custom_fields_localize);
22
23 $custom_fields_extra_info = get_option('wpsc_custom_fields_extra_info');
24 unset($custom_fields_extra_info['custom_fields_extra_info_' .$field_id]);
25 update_option('wpsc_custom_fields_extra_info', $custom_fields_extra_info);
26
27 do_action('wpsc_delete_custom_field',$field_id);
28 wp_delete_term($field_id, 'wpsc_ticket_custom_fields');
29
30 echo '{ "sucess_status":"1","messege":"'.__('Field deleted successfully.','supportcandy').'" }';
31 } else {
32 echo '{ "sucess_status":"0","messege":"'.__('Default field can not be deleted.','supportcandy').'" }';
33 }
34