← All changes
|
includes/admin/settings/wppm_set_edit_task_status.php
+41
-41
6.0.4
→
6.0.6
View file →
| @@ -1,41 +1,41 @@ | ||
| 1 | -<?php | |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - exit; // Exit if accessed directly | |
| 4 | -} | |
| 5 | -global $current_user, $wpdb; | |
| 6 | - | |
| 7 | -if (!($current_user->ID && $current_user->has_cap('manage_options') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) {exit;} | |
| 8 | - | |
| 9 | -if ( check_ajax_referer( 'wppm_set_edit_task_status', '_ajax_nonce', false ) != 1 ) { | |
| 10 | - wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 11 | -} | |
| 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 | - | |
| 17 | -$status_name = isset($_POST) && isset($_POST['status_name']) ? sanitize_text_field(wp_unslash($_POST['status_name'])) : ''; | |
| 18 | -if (!$status_name) {exit;} | |
| 19 | - | |
| 20 | -$status_color = isset($_POST) && isset($_POST['status_color']) ? sanitize_text_field(wp_unslash($_POST['status_color'])) : ''; | |
| 21 | -if (!$status_color) {exit;} | |
| 22 | - | |
| 23 | -$status_bg_color = isset($_POST) && isset($_POST['status_bg_color']) ? sanitize_text_field(wp_unslash($_POST['status_bg_color'])) : ''; | |
| 24 | -if (!$status_bg_color) {exit;} | |
| 25 | - | |
| 26 | -if ($status_color==$status_bg_color) { | |
| 27 | - echo '{ "sucess_status":"0","messege":"'.esc_html__('Status color and background color should not be same.','taskbuilder').'" }'; | |
| 28 | - die(); | |
| 29 | -} | |
| 30 | -$values= array( | |
| 31 | - 'name'=>esc_sql($status_name), | |
| 32 | - 'color'=>esc_sql($status_color), | |
| 33 | - 'bg_color'=>esc_sql($status_bg_color) | |
| 34 | -); | |
| 35 | -$wpdb->update($wpdb->prefix.'wppm_task_statuses',$values,array('id'=>intval($status_id))); | |
| 36 | -echo wp_json_encode( array( | |
| 37 | - 'sucess_status' => 1, | |
| 38 | - 'messege' => esc_html__( 'Success', 'taskbuilder' ), | |
| 39 | -) ); | |
| 40 | -wp_die(); | |
| 41 | -?> | |
| 1 | +<?php | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | + exit; // Exit if accessed directly | |
| 4 | +} | |
| 5 | +global $current_user, $wpdb; | |
| 6 | + | |
| 7 | +if (!($current_user->ID && $current_user->has_cap('manage_options') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) {exit;} | |
| 8 | + | |
| 9 | +if ( check_ajax_referer( 'wppm_set_edit_task_status', '_ajax_nonce', false ) != 1 ) { | |
| 10 | + wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 11 | +} | |
| 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 | + | |
| 17 | +$status_name = isset($_POST) && isset($_POST['status_name']) ? sanitize_text_field(wp_unslash($_POST['status_name'])) : ''; | |
| 18 | +if (!$status_name) {exit;} | |
| 19 | + | |
| 20 | +$status_color = isset($_POST) && isset($_POST['status_color']) ? sanitize_text_field(wp_unslash($_POST['status_color'])) : ''; | |
| 21 | +if (!$status_color) {exit;} | |
| 22 | + | |
| 23 | +$status_bg_color = isset($_POST) && isset($_POST['status_bg_color']) ? sanitize_text_field(wp_unslash($_POST['status_bg_color'])) : ''; | |
| 24 | +if (!$status_bg_color) {exit;} | |
| 25 | + | |
| 26 | +if ($status_color==$status_bg_color) { | |
| 27 | + echo '{ "sucess_status":"0","messege":"'.esc_html__('Status color and background color should not be same.','taskbuilder').'" }'; | |
| 28 | + die(); | |
| 29 | +} | |
| 30 | +$values= array( | |
| 31 | + 'name'=>esc_sql($status_name), | |
| 32 | + 'color'=>esc_sql($status_color), | |
| 33 | + 'bg_color'=>esc_sql($status_bg_color) | |
| 34 | +); | |
| 35 | +$wpdb->update($wpdb->prefix.'wppm_task_statuses',$values,array('id'=>intval($status_id))); | |
| 36 | +echo wp_json_encode( array( | |
| 37 | + 'sucess_status' => 1, | |
| 38 | + 'messege' => esc_html__( 'Success', 'taskbuilder' ), | |
| 39 | +) ); | |
| 40 | +wp_die(); | |
| 41 | +?> | |