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

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

165 lines 4.5 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_AOF' ) ) :
7
8 final class WPSC_AOF {
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 'tl_width',
27 'number_type',
28 );
29
30 /**
31 * Initialize this class
32 */
33 public static function init() {
34
35 // Register this field category (ticket).
36 add_filter( 'wpsc_custom_field_categories', array( __CLASS__, 'register_field' ) );
37
38 // List.
39 add_action( 'wp_ajax_wpsc_get_agent_only_fields', array( __CLASS__, 'get_agent_only_fields' ) );
40
41 // Filter custom field types for new custom field.
42 add_filter( 'wpsc_add_new_custom_field_cf_types', array( __CLASS__, 'filter_cf_types' ), 10, 2 );
43 }
44
45 /**
46 * Register field category
47 *
48 * @param array $fields - agent only fields.
49 * @return array
50 */
51 public static function register_field( $fields ) {
52
53 $fields['agentonly'] = __CLASS__;
54 return $fields;
55 }
56
57 /**
58 * Get agent only fields
59 *
60 * @return void
61 */
62 public static function get_agent_only_fields() {
63
64 if ( ! WPSC_Functions::is_site_admin() ) {
65 wp_send_json_error( __( 'Unauthorized access!', 'supportcandy' ), 401 );
66 }?>
67
68 <div class="wpsc-setting-header">
69 <h2><?php esc_attr_e( 'Agent Only Fields', 'supportcandy' ); ?></h2>
70 </div>
71 <div class="wpsc-setting-section-body">
72 <div class="wpsc-dock-container">
73 <?php
74 printf(
75 /* translators: Click here to see the documentation */
76 esc_attr__( '%s to see the documentation!', 'supportcandy' ),
77 '<a href="https://supportcandy.net/docs/agent-only-fields/" target="_blank">' . esc_attr__( 'Click here', 'supportcandy' ) . '</a>'
78 );
79 ?>
80 </div>
81 <table class="ticket-fields wpsc-setting-tbl">
82 <thead>
83 <tr>
84 <th><?php esc_attr_e( 'Field', 'supportcandy' ); ?></th>
85 <th><?php esc_attr_e( 'Extra info', 'supportcandy' ); ?></th>
86 <th><?php esc_attr_e( 'Actions', 'supportcandy' ); ?></th>
87 </tr>
88 </thead>
89 <tbody>
90 <?php
91 foreach ( WPSC_Custom_Field::$custom_fields as $cf ) {
92 if ( $cf->field != 'agentonly' ) {
93 continue;
94 }
95 ?>
96 <tr>
97 <td><?php echo esc_attr( $cf->name ); ?></td>
98 <td><?php echo esc_attr( $cf->extra_info ); ?></td>
99 <td>
100 <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>
101 <?php
102 if ( ! $cf->type::$is_default ) {
103 echo esc_attr( ' | ' );
104 ?>
105 <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>
106 <?php
107 }
108 ?>
109 </td>
110 </tr>
111 <?php
112 }
113 ?>
114 </tbody>
115 </table>
116 <script>
117 jQuery('table.ticket-fields').DataTable({
118 ordering: false,
119 pageLength: 20,
120 bLengthChange: false,
121 columnDefs: [
122 { targets: -1, searchable: false },
123 { targets: '_all', className: 'dt-left' }
124 ],
125 layout: {
126 topStart: {
127 buttons: [
128 {
129 text: '<?php esc_attr_e( 'Add new', 'supportcandy' ); ?>',
130 className: 'wpsc-button small primary',
131 action: function ( e, dt, node, config ) {
132 wpsc_get_add_new_custom_field('agentonly', '<?php echo esc_attr( wp_create_nonce( 'wpsc_get_add_new_custom_field' ) ); ?>');
133 }
134 }
135 ],
136 },
137 },
138 language: supportcandy.translations.datatables
139 });
140 </script>
141 </div>
142 <?php
143 wp_die();
144 }
145
146 /**
147 * Filter out unwanted custom field types from add new custom field section for customer fields
148 *
149 * @param array $cf_types - cf_types.
150 * @param string $field - custom field category (ticket, agentonly, customer, etc.).
151 * @return array
152 */
153 public static function filter_cf_types( $cf_types, $field ) {
154
155 if ( $field == 'agentonly' && in_array( 'cf_html', array_keys( $cf_types ) ) ) {
156 unset( $cf_types['cf_html'] );
157 }
158
159 return $cf_types;
160 }
161 }
162 endif;
163
164 WPSC_AOF::init();
165