| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user, $wpdb; |
| 7 |
|
| 8 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;} |
| 9 |
|
| 10 |
if ( check_ajax_referer( 'wppm_set_edit_priority', '_ajax_nonce', false ) != 1 ) { |
| 11 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 12 |
} |
| 13 |
|
| 14 |
$priority_id = isset($_POST) && isset($_POST['priority_id']) ? intval(sanitize_text_field($_POST['priority_id'])) : ''; |
| 15 |
if (!$priority_id) {exit;} |
| 16 |
|
| 17 |
$priority_name = isset($_POST) && isset($_POST['priority_name']) ? sanitize_text_field($_POST['priority_name']) : ''; |
| 18 |
if (!$priority_name) {exit;} |
| 19 |
|
| 20 |
$priority_color = isset($_POST) && isset($_POST['priority_color']) ? sanitize_text_field($_POST['priority_color']) : ''; |
| 21 |
if (!$priority_color) {exit;} |
| 22 |
|
| 23 |
$priority_bg_color = isset($_POST) && isset($_POST['priority_bg_color']) ? sanitize_text_field($_POST['priority_bg_color']) : ''; |
| 24 |
if (!$priority_bg_color) {exit;} |
| 25 |
|
| 26 |
if ($priority_color==$priority_bg_color) { |
| 27 |
echo '{ "sucess_status":"0","messege":"'.__('Priority color and background color should not be same.','taskbuilder').'" }'; |
| 28 |
die(); |
| 29 |
} |
| 30 |
$values= array( |
| 31 |
'name'=>$priority_name, |
| 32 |
'color'=>$priority_color, |
| 33 |
'bg_color'=>$priority_bg_color |
| 34 |
); |
| 35 |
$wpdb->update($wpdb->prefix.'wppm_task_priorities',$values,array('id'=>intval($priority_id))); |
| 36 |
echo '{ "sucess_status":"1","messege":"Success" }'; |
| 37 |
?> |