| @@ -1,12 +1,13 @@ | ||
| 1 | -<?php | |
| 2 | -if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | - exit; // Exit if accessed directly | |
| 4 | -} | |
| 5 | - | |
| 6 | -global $current_user,$wpdb; | |
| 7 | -if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;} | |
| 8 | - | |
| 9 | -$status_id = isset($_POST) && isset($_POST['status_id']) ? intval(sanitize_text_field($_POST['status_id'])) : 0; | |
| 10 | -if (!$status_id) {exit;} | |
| 11 | - | |
| 12 | -$wpdb->delete($wpdb->prefix.'wppm_project_statuses', array( 'id' => $status_id)); | |
| 1 | +<?php | |
| 2 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 3 | + exit; // Exit if accessed directly | |
| 4 | +} | |
| 5 | + | |
| 6 | +global $current_user,$wpdb; | |
| 7 | +if (!($current_user->ID && $current_user->has_cap('manage_options') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) {exit;} | |
| 8 | +if ( check_ajax_referer( 'wppm_delete_status', '_ajax_nonce', false ) != 1 ) { | |
| 9 | + wp_send_json_error( 'Unauthorised request!', 401 ); | |
| 10 | +} | |
| 11 | +$status_id = isset($_POST) && isset($_POST['status_id']) ? absint(sanitize_text_field(wp_unslash($_POST['status_id']))) : 0; | |
| 12 | +if (!$status_id) {exit;} | |
| 13 | +$wpdb->delete($wpdb->prefix.'wppm_project_statuses', array( 'id' => absint($status_id))); | |