| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
global $current_user,$wpdb; |
| 6 |
if (!($current_user->ID && $current_user->has_cap('manage_options') || ($current_user->ID && $current_user->has_cap('wppm_admin')))) {exit;} |
| 7 |
|
| 8 |
if ( check_ajax_referer( 'wppm_set_edit_category', '_ajax_nonce', false ) != 1 ) { |
| 9 |
wp_send_json_error( 'Unauthorised request!', 401 ); |
| 10 |
} |
| 11 |
|
| 12 |
$cat_id = isset($_POST) && isset($_POST['cat_id']) ? absint(sanitize_text_field(wp_unslash($_POST['cat_id']))) : 0; |
| 13 |
$cat_id = absint($cat_id); |
| 14 |
if (!$cat_id) {exit;} |
| 15 |
|
| 16 |
$cat_name = isset($_POST) && isset($_POST['cat_name']) ? sanitize_text_field(wp_unslash($_POST['cat_name'])) : ''; |
| 17 |
if (!$cat_name) {exit;} |
| 18 |
|
| 19 |
$values= array( |
| 20 |
'name'=>esc_sql($cat_name) |
| 21 |
); |
| 22 |
$wpdb->update($wpdb->prefix.'wppm_project_categories',$values,array('id'=>("$cat_id"))); |
| 23 |
echo wp_json_encode( array( |
| 24 |
'sucess_status' => 1, |
| 25 |
'messege' => esc_html__( 'Success', 'taskbuilder' ), |
| 26 |
) ); |
| 27 |
wp_die(); |
| 28 |
?> |