| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user, $wpdb, $wpscfunction; |
| 7 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;} |
| 8 |
|
| 9 |
$field_id = isset($_POST) && isset($_POST['field_id']) ? intval($_POST['field_id']) : 0; |
| 10 |
if (!$field_id) {exit;} |
| 11 |
|
| 12 |
$custom_field = get_term_by('id', $field_id, 'wpsc_ticket_custom_fields'); |
| 13 |
$custom_field_type = get_term_meta( $custom_field->term_id, 'wpsc_tf_type', true); |
| 14 |
|
| 15 |
if($custom_field_type=='0'){ |
| 16 |
|
| 17 |
if ($custom_field->slug=='ticket_category') { |
| 18 |
|
| 19 |
$categories = get_terms([ |
| 20 |
'taxonomy' => 'wpsc_categories', |
| 21 |
'hide_empty' => false, |
| 22 |
'orderby' => 'meta_value_num', |
| 23 |
'order' => 'ASC', |
| 24 |
'meta_query' => array('order_clause' => array('key' => 'wpsc_category_load_order')), |
| 25 |
]); |
| 26 |
?> |
| 27 |
<option value=""><?php _e('Select option','supportcandy');?></option> |
| 28 |
<?php foreach ( $categories as $category ) :?> |
| 29 |
<option value="<?php echo esc_attr($category->term_id)?>"><?php echo esc_attr($category->name)?></option> |
| 30 |
<?php endforeach; |
| 31 |
|
| 32 |
} |
| 33 |
|
| 34 |
if ($custom_field->slug=='ticket_priority') { |
| 35 |
|
| 36 |
$priorities = get_terms([ |
| 37 |
'taxonomy' => 'wpsc_priorities', |
| 38 |
'hide_empty' => false, |
| 39 |
'orderby' => 'meta_value_num', |
| 40 |
'order' => 'ASC', |
| 41 |
'meta_query' => array('order_clause' => array('key' => 'wpsc_priority_load_order')), |
| 42 |
]); |
| 43 |
?> |
| 44 |
<option value=""><?php _e('Select option','supportcandy');?></option> |
| 45 |
<?php foreach ( $priorities as $priority ) :?> |
| 46 |
<option value="<?php echo esc_attr($priority->term_id)?>"><?php echo esc_attr($priority->name)?></option> |
| 47 |
<?php endforeach; |
| 48 |
|
| 49 |
} |
| 50 |
|
| 51 |
if ($custom_field->slug=='ticket_status') { |
| 52 |
|
| 53 |
$statuses = get_terms([ |
| 54 |
'taxonomy' => 'wpsc_statuses', |
| 55 |
'hide_empty' => false, |
| 56 |
'orderby' => 'meta_value_num', |
| 57 |
'order' => 'ASC', |
| 58 |
'meta_query' => array('order_clause' => array('key' => 'wpsc_status_load_order')), |
| 59 |
]); |
| 60 |
?> |
| 61 |
<option value=""><?php _e('Select option','supportcandy');?></option> |
| 62 |
<?php foreach ( $statuses as $status ) :?> |
| 63 |
<option value="<?php echo esc_attr($status->term_id)?>"><?php echo esc_attr($status->name)?></option> |
| 64 |
<?php endforeach; |
| 65 |
|
| 66 |
} |
| 67 |
|
| 68 |
} else { |
| 69 |
|
| 70 |
$wpsc_tf_options = get_term_meta( $custom_field->term_id, 'wpsc_tf_options', true); |
| 71 |
if (!$wpsc_tf_options) {exit;} |
| 72 |
?> |
| 73 |
<option value=""><?php _e('Select option','supportcandy');?></option> |
| 74 |
<?php foreach ( $wpsc_tf_options as $option ) :?> |
| 75 |
<option value="<?php echo esc_attr($option)?>"><?php echo esc_attr($option)?></option> |
| 76 |
<?php endforeach; |
| 77 |
|
| 78 |
} |
| 79 |
|