| @@ -1,37 +1,37 @@ | ||
| 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') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) {exit;} | |
| 9 | - | |
| 10 | -if ( check_ajax_referer( 'wppm_set_edit_status', '_ajax_nonce', false ) != 1 ) { | |
| 11 | - wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 12 | -} | |
| 13 | -$status_id = isset($_POST) && isset($_POST['status_id']) ? absint(sanitize_text_field(wp_unslash($_POST['status_id']))) : ''; | |
| 14 | -if (!$status_id) {exit;} | |
| 15 | -$status_id = absint($status_id); | |
| 16 | -$status_name = isset($_POST) && isset($_POST['status_name']) ? sanitize_text_field(wp_unslash($_POST['status_name'])) : ''; | |
| 17 | -if (!$status_name) {exit;} | |
| 18 | -$status_color = isset($_POST) && isset($_POST['status_color']) ? sanitize_text_field(wp_unslash($_POST['status_color'])) : ''; | |
| 19 | -if (!$status_color) {exit;} | |
| 20 | -$status_bg_color = isset($_POST) && isset($_POST['status_bg_color']) ? sanitize_text_field(wp_unslash($_POST['status_bg_color'])) : ''; | |
| 21 | -if (!$status_bg_color) {exit;} | |
| 22 | -if ($status_color==$status_bg_color) { | |
| 23 | - echo '{ "sucess_status":"0","messege":"'.esc_html__('Status color and background color should not be same.','taskbuilder').'" }'; | |
| 24 | - die(); | |
| 25 | -} | |
| 26 | -$values= array( | |
| 27 | - 'name'=>($status_name), | |
| 28 | - 'color'=>($status_color), | |
| 29 | - 'bg_color'=>($status_bg_color) | |
| 30 | -); | |
| 31 | -$wpdb->update($wpdb->prefix.'wppm_project_statuses',$values,array('id'=>intval("$status_id"))); | |
| 32 | -echo wp_json_encode( array( | |
| 33 | - 'sucess_status' => 1, | |
| 34 | - 'messege' => esc_html__( 'Success', 'taskbuilder' ), | |
| 35 | -) ); | |
| 36 | -wp_die(); | |
| 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') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) {exit;} | |
| 9 | + | |
| 10 | +if ( check_ajax_referer( 'wppm_set_edit_status', '_ajax_nonce', false ) != 1 ) { | |
| 11 | + wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 12 | +} | |
| 13 | +$status_id = isset($_POST) && isset($_POST['status_id']) ? absint(sanitize_text_field(wp_unslash($_POST['status_id']))) : ''; | |
| 14 | +if (!$status_id) {exit;} | |
| 15 | +$status_id = absint($status_id); | |
| 16 | +$status_name = isset($_POST) && isset($_POST['status_name']) ? sanitize_text_field(wp_unslash($_POST['status_name'])) : ''; | |
| 17 | +if (!$status_name) {exit;} | |
| 18 | +$status_color = isset($_POST) && isset($_POST['status_color']) ? sanitize_text_field(wp_unslash($_POST['status_color'])) : ''; | |
| 19 | +if (!$status_color) {exit;} | |
| 20 | +$status_bg_color = isset($_POST) && isset($_POST['status_bg_color']) ? sanitize_text_field(wp_unslash($_POST['status_bg_color'])) : ''; | |
| 21 | +if (!$status_bg_color) {exit;} | |
| 22 | +if ($status_color==$status_bg_color) { | |
| 23 | + echo '{ "sucess_status":"0","messege":"'.esc_html__('Status color and background color should not be same.','taskbuilder').'" }'; | |
| 24 | + die(); | |
| 25 | +} | |
| 26 | +$values= array( | |
| 27 | + 'name'=>($status_name), | |
| 28 | + 'color'=>($status_color), | |
| 29 | + 'bg_color'=>($status_bg_color) | |
| 30 | +); | |
| 31 | +$wpdb->update($wpdb->prefix.'wppm_project_statuses',$values,array('id'=>intval("$status_id"))); | |
| 32 | +echo wp_json_encode( array( | |
| 33 | + 'sucess_status' => 1, | |
| 34 | + 'messege' => esc_html__( 'Success', 'taskbuilder' ), | |
| 35 | +) ); | |
| 36 | +wp_die(); | |
| 37 | 37 | ?> |