PluginProbe
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent / 3.4.4
SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent v3.4.4
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 / class-wpsc-tf.php

class-wpsc-tf.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 3.4.4, at includes/admin/custom-fields/class-wpsc-tf.php

146 lines 3.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 if ( ! class_exists( 'WPSC_TF' ) ) :
7
8 final class WPSC_TF {
9
10 /**
11 * Allowed custom field properties
12 *
13 * @var array
14 */
15 public static $allowed_properties = array(
16 'extra_info',
17 'default_value',
18 'placeholder_text',
19 'char_limit',
20 'date_format',
21 'date_range',
22 'start_range',
23 'end_range',
24 'time_format',
25 'is_personal_info',
26 'is_auto_fill',
27 'tl_width',
28 'number_type',
29 );
30
31 /**
32 * Initialize this class
33 */
34 public static function init() {
35
36 // Register this field category (ticket).
37 add_filter( 'wpsc_custom_field_categories', array( __CLASS__, 'register_field' ) );
38
39 // List.
40 add_action( 'wp_ajax_wpsc_get_ticket_fields', array( __CLASS__, 'get_ticket_fields' ) );
41 }
42
43 /**
44 * Register field category
45 *
46 * @param array $fields - ticket fields.
47 * @return array
48 */
49 public static function register_field( $fields ) {
50
51 $fields['ticket'] = __CLASS__;
52 return $fields;
53 }
54
55 /**
56 * Get ticket fields
57 */
58 public static function get_ticket_fields() {
59
60 if ( ! WPSC_Functions::is_site_admin() ) {
61 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
62 }?>
63
64 <div class="wpsc-setting-header">
65 <h2><?php esc_attr_e( 'Ticket Fields', 'supportcandy' ); ?></h2>
66 </div>
67
68 <div class="wpsc-setting-section-body">
69 <div class="wpsc-dock-container">
70 <?php
71 printf(
72 /* translators: Click here to see the documentation */
73 esc_attr__( '%s to see the documentation!', 'supportcandy' ),
74 '<a href="https://supportcandy.net/docs/ticket-fields/" target="_blank">' . esc_attr__( 'Click here', 'supportcandy' ) . '</a>'
75 );
76 ?>
77 </div>
78 <table class="ticket-fields wpsc-setting-tbl">
79 <thead>
80 <tr>
81 <th><?php esc_attr_e( 'Field', 'supportcandy' ); ?></th>
82 <th><?php esc_attr_e( 'Extra info', 'supportcandy' ); ?></th>
83 <th><?php esc_attr_e( 'Actions', 'supportcandy' ); ?></th>
84 </tr>
85 </thead>
86 <tbody>
87 <?php
88 foreach ( WPSC_Custom_Field::$custom_fields as $cf ) {
89 if ( $cf->field != 'ticket' ) {
90 continue;
91 }
92 ?>
93 <tr>
94 <td><?php echo esc_attr( $cf->name ); ?></td>
95 <td><?php echo esc_attr( $cf->extra_info ); ?></td>
96 <td>
97 <a href="javascript:wpsc_get_edit_custom_field(<?php echo esc_attr( $cf->id ); ?>, '<?php echo esc_attr( wp_create_nonce( 'wpsc_get_edit_custom_field' ) ); ?>');" class="wpsc-link"><?php esc_attr_e( 'Edit', 'supportcandy' ); ?></a>
98 <?php
99 if ( ! $cf->type::$is_default ) {
100 echo esc_attr( ' | ' );
101 ?>
102 <a href="javascript:wpsc_delete_custom_field(<?php echo esc_attr( $cf->id ); ?>, '<?php echo esc_attr( wp_create_nonce( 'wpsc_delete_custom_field' ) ); ?>');" class="wpsc-link"><?php esc_attr_e( 'Delete', 'supportcandy' ); ?></a>
103 <?php
104 }
105 ?>
106 </td>
107 </tr>
108 <?php
109 }
110 ?>
111 </tbody>
112 </table>
113 <script>
114 jQuery('table.ticket-fields').DataTable({
115 ordering: false,
116 pageLength: 20,
117 bLengthChange: false,
118 columnDefs: [
119 { targets: -1, searchable: false },
120 { targets: '_all', className: 'dt-left' }
121 ],
122 layout: {
123 topStart: {
124 buttons: [
125 {
126 text: '<?php esc_attr_e( 'Add new', 'supportcandy' ); ?>',
127 className: 'wpsc-button small primary',
128 action: function ( e, dt, node, config ) {
129 wpsc_get_add_new_custom_field('ticket', '<?php echo esc_attr( wp_create_nonce( 'wpsc_get_add_new_custom_field' ) ); ?>');
130 }
131 }
132 ],
133 },
134 },
135 language: supportcandy.translations.datatables
136 });
137 </script>
138 </div>
139 <?php
140 wp_die();
141 }
142 }
143 endif;
144
145 WPSC_TF::init();
146