| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; // Exit if accessed directly |
| 4 |
} |
| 5 |
|
| 6 |
global $current_user; |
| 7 |
|
| 8 |
if ( |
| 9 |
check_ajax_referer('set_edit_category', '_ajax_nonce', false) != 1 |
| 10 |
) wp_send_json_error('Unauthorised request!', 400); |
| 11 |
|
| 12 |
if (!($current_user->ID && $current_user->has_cap('manage_options'))) {exit;} |
| 13 |
|
| 14 |
$cat_id = isset($_POST) && isset($_POST['cat_id']) ? intval($_POST['cat_id']) : 0; |
| 15 |
if (!$cat_id) {exit;} |
| 16 |
|
| 17 |
$cat_name = isset($_POST) && isset($_POST['cat_name']) ? sanitize_text_field($_POST['cat_name']) : ''; |
| 18 |
if (!$cat_name) {exit;} |
| 19 |
|
| 20 |
wp_update_term($cat_id, 'wpsc_categories', array( |
| 21 |
'name' => $cat_name |
| 22 |
)); |
| 23 |
|
| 24 |
do_action('wpsc_set_edit_category',$cat_id); |
| 25 |
$wpsc_custom_category_localize = get_option('wpsc_custom_category_localize'); |
| 26 |
$wpsc_custom_category_localize['custom_category_'.$cat_id] = stripslashes($cat_name); |
| 27 |
update_option('wpsc_custom_category_localize', $wpsc_custom_category_localize); |