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 / functions / conditions / get_condition_options.php

get_condition_options.php in SupportCandy – AI Customer Support Ticket System & Live Chatbot Agent 2.3.1, at includes/functions/conditions/get_condition_options.php

158 lines 4.1 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,$wp_roles;
7
8 if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;}
9
10 if (!$key) {exit;}
11
12 $options = array();
13
14 if(is_numeric($key)){
15
16 $custom_field = get_term_by('id', $key, 'wpsc_ticket_custom_fields');
17 $field_type = get_term_meta( $custom_field->term_id, 'wpsc_tf_type', true);
18
19 if($field_type=='0'){
20
21 if ($custom_field->slug=='ticket_category') {
22
23 $categories = get_terms([
24 'taxonomy' => 'wpsc_categories',
25 'hide_empty' => false,
26 'orderby' => 'meta_value_num',
27 'order' => 'ASC',
28 'meta_query' => array('order_clause' => array('key' => 'wpsc_category_load_order')),
29 ]);
30 foreach ( $categories as $category ){
31 $options[] = array(
32 'value' => $category->term_id,
33 'label' => $category->name,
34 );
35 }
36
37 }
38
39 if ($custom_field->slug=='ticket_priority') {
40
41 $priorities = get_terms([
42 'taxonomy' => 'wpsc_priorities',
43 'hide_empty' => false,
44 'orderby' => 'meta_value_num',
45 'order' => 'ASC',
46 'meta_query' => array('order_clause' => array('key' => 'wpsc_priority_load_order')),
47 ]);
48 foreach ( $priorities as $priority ){
49 $options[] = array(
50 'value' => $priority->term_id,
51 'label' => $priority->name,
52 );
53 }
54
55 }
56
57 if ($custom_field->slug=='ticket_status') {
58
59 $statuses = get_terms([
60 'taxonomy' => 'wpsc_statuses',
61 'hide_empty' => false,
62 'orderby' => 'meta_value_num',
63 'order' => 'ASC',
64 'meta_query' => array('order_clause' => array('key' => 'wpsc_status_load_order')),
65 ]);
66 foreach ( $statuses as $status ){
67 $options[] = array(
68 'value' => $status->term_id,
69 'label' => $status->name,
70 );
71 }
72
73 }
74
75 if ($custom_field->slug=='assigned_agent') {
76
77 $agents = get_terms([
78 'taxonomy' => 'wpsc_agents',
79 'hide_empty' => false,
80 'orderby' => 'meta_value',
81 'order' => 'ASC',
82 'meta_query' => array('order_clause' => array('key' => 'label')),
83 ]);
84 foreach ( $agents as $agent ){
85 $agent_name = get_term_meta( $agent->term_id, 'label', true );
86 $options[] = array(
87 'value' => $agent->term_id,
88 'label' => $agent_name,
89 );
90 }
91
92 }
93
94 } else {
95
96 switch( $field_type ){
97
98 case 2:
99 case 3:
100 case 4:
101
102 $wpsc_tf_options = get_term_meta( $custom_field->term_id, 'wpsc_tf_options', true);
103 foreach ( $wpsc_tf_options as $option ){
104 $options[] = array(
105 'value' => str_replace('"', "&quot;", stripcslashes($option)),
106 'label' => stripcslashes($option),
107 );
108 }
109 break;
110
111 default:
112 $options = apply_filters( 'wpsc_condition_custom_field_dd_options', $options, $field_type, $custom_field );
113
114 }
115
116 }
117
118 }
119
120 if( $key == 'agent_created' ){
121 $options = array(
122 array(
123 'value' => 'user',
124 'label' => __('User himself','supportcandy'),
125 ),
126 array(
127 'value' => 'agent',
128 'label' => __('Agent','supportcandy'),
129 )
130 );
131 }
132
133 if( $key == 'user_type' ){
134 $options = array(
135 array(
136 'value' => 'user',
137 'label' => __('Registered User','supportcandy'),
138 ),
139 array(
140 'value' => 'guest',
141 'label' => __('Guest User','supportcandy'),
142 )
143 );
144 }
145
146 if( $key == 'user_wp_roles' ){
147 $roles = $wp_roles->get_names();
148 foreach ($roles as $key => $role) {
149 $options[] = array(
150 'value' => $key,
151 'label' => $role,
152 );
153 }
154 }
155
156 $options = apply_filters( 'wpsc_condition_dd_options', $options, $key );
157
158