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 / rest_api / v1 / get_agentonly_fields.php

get_agentonly_fields.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/rest_api/v1/get_agentonly_fields.php

58 lines 1.6 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;
7
8 $response = array();
9
10 $agentonly_fields = get_terms([
11 'taxonomy' => 'wpsc_ticket_custom_fields',
12 'hide_empty' => false,
13 'orderby' => 'meta_value_num',
14 'meta_key' => 'wpsc_tf_load_order',
15 'order' => 'ASC',
16 'meta_query' => array(
17 array(
18 'key' => 'agentonly',
19 'value' => '1',
20 'compare' => '='
21 )
22 ),
23 ]);
24
25 foreach ( $agentonly_fields as $ao_field ) {
26
27 if ( $current_user->ID && ( $ao_field->slug == 'customer_name' || $ao_field->slug == 'customer_email' ) ) {
28 continue;
29 }
30
31 $options = get_term_meta( $ao_field->term_id, 'wpsc_tf_options', true);
32 $options = is_array($options) ? $options : array();
33 $options = isset($options[0]) && $options[0] ? $options : array();
34
35 $temp_options = array();
36 foreach ($options as $value) {
37 $temp_options[] = array(
38 'name' => $value,
39 'value' => $value
40 );
41 }
42 $options = $temp_options;
43
44 $field = array(
45 'id' => $ao_field->term_id,
46 'slug' => $ao_field->slug,
47 'label' => get_term_meta( $ao_field->term_id, 'wpsc_tf_label', true),
48 'extra_info' => get_term_meta( $ao_field->term_id, 'wpsc_tf_extra_info', true),
49 'type' => get_term_meta( $ao_field->term_id, 'wpsc_tf_type', true),
50 'options' => $options,
51 );
52
53 $field = apply_filters('wpsc_api_v1_ao_fields',$field);
54
55 $response[] = $field;
56
57 }
58