| 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'))) {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']) ? intval(sanitize_text_field($_POST['cat_id'])) : 0; |
| 13 |
if (!$cat_id) {exit;} |
| 14 |
|
| 15 |
$cat_name = isset($_POST) && isset($_POST['cat_name']) ? sanitize_text_field($_POST['cat_name']) : ''; |
| 16 |
if (!$cat_name) {exit;} |
| 17 |
|
| 18 |
$values= array( |
| 19 |
'name'=>$cat_name |
| 20 |
); |
| 21 |
$wpdb->update($wpdb->prefix.'wppm_project_categories',$values,array('id'=>($cat_id))); |
| 22 |
echo '{ "sucess_status":"1","messege":"Success" }'; |
| 23 |
?> |