← All changes
|
includes/admin/settings/wppm_set_edit_priority.php
+42
-42
6.0.3
→
6.0.6
View file →
| @@ -1,43 +1,43 @@ | ||
| 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')))) { | |
| 9 | - exit; | |
| 10 | -} | |
| 11 | -if ( check_ajax_referer( 'wppm_set_edit_priority', '_ajax_nonce', false ) != 1 ) { | |
| 12 | - wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 13 | -} | |
| 14 | - | |
| 15 | -$priority_id = isset($_POST) && isset($_POST['priority_id']) ? absint(sanitize_text_field(wp_unslash($_POST['priority_id']))) : 0; | |
| 16 | -if (!$priority_id) {exit;} | |
| 17 | -$priority_id = absint($priority_id); | |
| 18 | - | |
| 19 | -$priority_name = isset($_POST) && isset($_POST['priority_name']) ? sanitize_text_field(wp_unslash($_POST['priority_name'])) : ''; | |
| 20 | -if (!$priority_name) {exit;} | |
| 21 | - | |
| 22 | -$priority_color = isset($_POST) && isset($_POST['priority_color']) ? sanitize_text_field(wp_unslash($_POST['priority_color'])) : ''; | |
| 23 | -if (!$priority_color) {exit;} | |
| 24 | - | |
| 25 | -$priority_bg_color = isset($_POST) && isset($_POST['priority_bg_color']) ? sanitize_text_field(wp_unslash($_POST['priority_bg_color'])) : ''; | |
| 26 | -if (!$priority_bg_color) {exit;} | |
| 27 | - | |
| 28 | -if ($priority_color==$priority_bg_color) { | |
| 29 | - echo '{ "sucess_status":"0","messege":"'.esc_html__('Priority color and background color should not be same.','taskbuilder').'" }'; | |
| 30 | - die(); | |
| 31 | -} | |
| 32 | -$values= array( | |
| 33 | - 'name'=>($priority_name), | |
| 34 | - 'color'=>($priority_color), | |
| 35 | - 'bg_color'=>($priority_bg_color) | |
| 36 | -); | |
| 37 | -$wpdb->update($wpdb->prefix.'wppm_task_priorities',$values,array('id'=>intval($priority_id))); | |
| 38 | -echo wp_json_encode( array( | |
| 39 | - 'sucess_status' => 1, | |
| 40 | - 'messege' => esc_html__( 'Success', 'taskbuilder' ), | |
| 41 | -) ); | |
| 42 | -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')))) { | |
| 9 | + exit; | |
| 10 | +} | |
| 11 | +if ( check_ajax_referer( 'wppm_set_edit_priority', '_ajax_nonce', false ) != 1 ) { | |
| 12 | + wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 13 | +} | |
| 14 | + | |
| 15 | +$priority_id = isset($_POST) && isset($_POST['priority_id']) ? absint(sanitize_text_field(wp_unslash($_POST['priority_id']))) : 0; | |
| 16 | +if (!$priority_id) {exit;} | |
| 17 | +$priority_id = absint($priority_id); | |
| 18 | + | |
| 19 | +$priority_name = isset($_POST) && isset($_POST['priority_name']) ? sanitize_text_field(wp_unslash($_POST['priority_name'])) : ''; | |
| 20 | +if (!$priority_name) {exit;} | |
| 21 | + | |
| 22 | +$priority_color = isset($_POST) && isset($_POST['priority_color']) ? sanitize_text_field(wp_unslash($_POST['priority_color'])) : ''; | |
| 23 | +if (!$priority_color) {exit;} | |
| 24 | + | |
| 25 | +$priority_bg_color = isset($_POST) && isset($_POST['priority_bg_color']) ? sanitize_text_field(wp_unslash($_POST['priority_bg_color'])) : ''; | |
| 26 | +if (!$priority_bg_color) {exit;} | |
| 27 | + | |
| 28 | +if ($priority_color==$priority_bg_color) { | |
| 29 | + echo '{ "sucess_status":"0","messege":"'.esc_html__('Priority color and background color should not be same.','taskbuilder').'" }'; | |
| 30 | + die(); | |
| 31 | +} | |
| 32 | +$values= array( | |
| 33 | + 'name'=>($priority_name), | |
| 34 | + 'color'=>($priority_color), | |
| 35 | + 'bg_color'=>($priority_bg_color) | |
| 36 | +); | |
| 37 | +$wpdb->update($wpdb->prefix.'wppm_task_priorities',$values,array('id'=>intval($priority_id))); | |
| 38 | +echo wp_json_encode( array( | |
| 39 | + 'sucess_status' => 1, | |
| 40 | + 'messege' => esc_html__( 'Success', 'taskbuilder' ), | |
| 41 | +) ); | |
| 42 | +wp_die(); | |
| 43 | 43 | ?> |