# supportcandy/2.3.1/includes/admin/settings/set_edit_priority.php

SupportCandy – AI Customer Support Ticket System &amp; Live Chatbot Agent, version 2.3.1. 44 lines.

- Page: https://pluginprobe.com/plugins/supportcandy/2.3.1/code/includes/admin/settings/set_edit_priority.php
- Raw: https://pluginprobe.com/plugins/supportcandy/2.3.1/raw/includes/admin/settings/set_edit_priority.php
- Modified: 2022-07-21T08:20:56+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/supportcandy/2.3.1/code/includes/admin/settings/set_edit_priority.php#L10-L20`.

```php
<?php
if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly
}

global $current_user;

if (
	check_ajax_referer('set_edit_priority', '_ajax_nonce', false) != 1
) wp_send_json_error('Unauthorised request!', 400);

if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;}

$priority_id = isset($_POST) && isset($_POST['priority_id']) ? sanitize_text_field($_POST['priority_id']) : '';
if (!$priority_id) {exit;}

$priority_name = isset($_POST) && isset($_POST['priority_name']) ? sanitize_text_field($_POST['priority_name']) : '';
if (!$priority_name) {exit;}

$priority_color = isset($_POST) && isset($_POST['priority_color']) ? sanitize_text_field($_POST['priority_color']) : '';
if (!$priority_color) {exit;}

$priority_bg_color = isset($_POST) && isset($_POST['priority_bg_color']) ? sanitize_text_field($_POST['priority_bg_color']) : '';
if (!$priority_bg_color) {exit;}

if ($priority_color==$priority_bg_color) {
  echo '{ "sucess_status":"0","messege":"'.__('Priority color and background color should not be same.','supportcandy').'" }';
  die();
}

$wpsc_custom_priority_localize =  get_option('wpsc_custom_priority_localize');
$wpsc_custom_priority_localize['custom_priority_'.$priority_id] = stripslashes($priority_name);
update_option('wpsc_custom_priority_localize', $wpsc_custom_priority_localize);

wp_update_term($priority_id, 'wpsc_priorities', array(
  'name' => $priority_name
));
update_term_meta($priority_id, 'wpsc_priority_color', $priority_color);
update_term_meta($priority_id, 'wpsc_priority_background_color', $priority_bg_color);

do_action('wpsc_set_edit_priority',$priority_id);

echo '{ "sucess_status":"1","messege":"Success" }';

```
