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 / settings / get_category_settings.php

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

168 lines 5.8 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 global $current_user, $wpdb;
7 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {
8 exit;
9 }
10
11 $categories = get_terms([
12 'taxonomy' => 'wpsc_categories',
13 'hide_empty' => false,
14 'orderby' => 'meta_value_num',
15 'order' => 'ASC',
16 'meta_query' => array('order_clause' => array('key' => 'wpsc_category_load_order')),
17 ]);
18
19 ?>
20 <h4>
21 <?php _e('Ticket Categories','supportcandy');?>
22 <button style="margin-left:10px;" class="btn btn-success btn-sm" onclick="wpsc_get_add_category();"><?php _e('+Add New','supportcandy');?></button>
23 </h4>
24
25 <div class="wpsc_padding_space"></div>
26
27 <ul class="wpsc-sortable">
28 <?php foreach ( $categories as $category ) :?>
29 <li class="ui-state-default" data-id="<?php echo esc_attr($category->term_id)?>">
30 <div class="wpsc-flex-container" style="background-color:#1E90FF;color:#fff;">
31 <div class="wpsc-sortable-handle"><i class="fa fa-bars"></i></div>
32 <div class="wpsc-sortable-label"><?php echo esc_attr($category->name)?></div>
33 <div class="wpsc-sortable-edit" onclick="wpsc_get_edit_category(<?php echo esc_attr($category->term_id)?>);"><i class="fa fa-edit"></i></div>
34 <div class="wpsc-sortable-delete" onclick="wpsc_delete_category(<?php echo esc_attr($category->term_id)?>);"><i class="fa fa-trash"></i></div>
35 </div>
36 </li>
37 <?php endforeach;?>
38 </ul>
39
40 <script>
41
42 jQuery(function(){
43 jQuery( ".wpsc-sortable" ).sortable({ handle: '.wpsc-sortable-handle' });
44 jQuery( ".wpsc-sortable" ).on("sortupdate",function(event,ui){
45 var ids = jQuery(this).sortable( "toArray", {attribute: 'data-id'} );
46 var data = {
47 action: 'wpsc_settings',
48 setting_action : 'set_category_order',
49 cat_ids : ids,
50 _ajax_nonce: '<?php echo wp_create_nonce('set_category_order')?>'
51 };
52 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
53 var response = JSON.parse(response_str);
54 if (response.sucess_status=='1') {
55 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
56 }
57 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
58 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
59 });
60 });
61 });
62
63 function wpsc_get_add_category(){
64 wpsc_modal_open(wpsc_admin.add_new_category);
65 var data = {
66 action: 'wpsc_settings',
67 setting_action : 'get_add_category'
68 };
69 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
70 jQuery('#wpsc_popup_body').html(response.body);
71 jQuery('#wpsc_popup_footer').html(response.footer);
72 jQuery('#wpsc_cat_name').focus();
73 });
74 }
75
76 function wpsc_set_add_category(){
77 var cat_name = jQuery('#wpsc_cat_name').val().trim();
78 if (cat_name.length == 0) {
79 jQuery('#wpsc_cat_name').val('').focus();
80 return;
81 }
82 jQuery('.wpsc_popup_action').text('<?php _e('Please wait ...','supportcandy')?>');
83 jQuery('.wpsc_popup_action, #wpsc_popup_body input').attr("disabled", "disabled");
84 var data = {
85 action: 'wpsc_settings',
86 setting_action : 'set_add_category',
87 cat_name : cat_name,
88 _ajax_nonce: '<?php echo wp_create_nonce('set_add_category')?>'
89 };
90 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
91 wpsc_modal_close();
92 var response = JSON.parse(response_str);
93 if (response.sucess_status=='1') {
94 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
95 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
96 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
97 wpsc_get_category_settings();
98 } else {
99 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
100 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
101 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
102 }
103 });
104 }
105
106 function wpsc_get_edit_category(cat_id){
107 wpsc_modal_open(wpsc_admin.edit_category);
108 var data = {
109 action: 'wpsc_settings',
110 setting_action : 'get_edit_category',
111 cat_id : cat_id
112 };
113 jQuery.post(wpsc_admin.ajax_url, data, function(response) {
114 jQuery('#wpsc_popup_body').html(response.body);
115 jQuery('#wpsc_popup_footer').html(response.footer);
116 jQuery('#wpsc_cat_name').focus();
117 });
118 }
119
120 function wpsc_set_edit_category(cat_id){
121 var cat_name = jQuery('#wpsc_cat_name').val().trim();
122 if (cat_name.length == 0) {
123 jQuery('#wpsc_cat_name').val('').focus();
124 return;
125 }
126 jQuery('.wpsc_popup_action').text('<?php _e('Please wait ...','supportcandy')?>');
127 jQuery('.wpsc_popup_action, #wpsc_popup_body input').attr("disabled", "disabled");
128 var data = {
129 action: 'wpsc_settings',
130 setting_action : 'set_edit_category',
131 cat_id : cat_id,
132 cat_name : cat_name,
133 _ajax_nonce : '<?php echo wp_create_nonce('set_edit_category')?>'
134 };
135 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
136 wpsc_modal_close();
137 wpsc_get_category_settings();
138 });
139 }
140
141 function wpsc_delete_category(cat_id){
142
143 var flag = confirm(wpsc_admin.are_you_sure);
144 if (flag) {
145 var data = {
146 action: 'wpsc_settings',
147 setting_action : 'delete_category',
148 cat_id : cat_id,
149 _ajax_nonce: '<?php echo wp_create_nonce('delete_category')?>'
150 };
151 jQuery.post(wpsc_admin.ajax_url, data, function(response_str) {
152 var response = JSON.parse(response_str);
153 if (response.sucess_status=='1') {
154 jQuery('#wpsc_alert_success .wpsc_alert_text').text(response.messege);
155 jQuery('#wpsc_alert_success').slideDown('fast',function(){});
156 setTimeout(function(){ jQuery('#wpsc_alert_success').slideUp('fast',function(){}); }, 3000);
157 wpsc_get_category_settings();
158 } else {
159 jQuery('#wpsc_alert_error .wpsc_alert_text').text(response.messege);
160 jQuery('#wpsc_alert_error').slideDown('fast',function(){});
161 setTimeout(function(){ jQuery('#wpsc_alert_error').slideUp('fast',function(){}); }, 3000);
162 }
163 });
164 }
165 }
166
167 </script>
168