| @@ -28,10 +28,16 @@ | ||
| 28 | 28 | </div> |
| 29 | 29 | <?php |
| 30 | 30 | } |
| 31 | 31 | public function save_category_image($term_id) { |
| 32 | + if (!current_user_can('manage_categories')) { | |
| 33 | + return; | |
| 34 | + } | |
| 35 | + if (!isset($_POST['_wpnonce_add-tag']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce_add-tag'])), 'add-tag')) { | |
| 36 | + return; | |
| 37 | + } | |
| 32 | 38 | if (isset($_POST['upk-category-image-id']) && '' !== $_POST['upk-category-image-id']) { |
| 33 | - $image = sanitize_key($_POST['upk-category-image-id']); | |
| 39 | + $image = sanitize_key(wp_unslash($_POST['upk-category-image-id'])); | |
| 34 | 40 | add_term_meta($term_id, 'upk-category-image-id', $image, true); |
| 35 | 41 | } |
| 36 | 42 | } |
| 37 | 43 | public function edit_category_image($term) { ?> |
| @@ -56,10 +62,16 @@ | ||
| 56 | 62 | <?php |
| 57 | 63 | } |
| 58 | 64 | |
| 59 | 65 | public function updated_category_image($term_id) { |
| 66 | + if (!current_user_can('manage_categories')) { | |
| 67 | + return; | |
| 68 | + } | |
| 69 | + if (!isset($_POST['_wpnonce']) || !wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['_wpnonce'])), 'update-tag_' . $term_id)) { | |
| 70 | + return; | |
| 71 | + } | |
| 60 | 72 | if (isset($_POST['upk-category-image-id']) && '' !== $_POST['upk-category-image-id']) { |
| 61 | - $image = sanitize_key($_POST['upk-category-image-id']); | |
| 73 | + $image = sanitize_key(wp_unslash($_POST['upk-category-image-id'])); | |
| 62 | 74 | update_term_meta($term_id, 'upk-category-image-id', $image); |
| 63 | 75 | } else { |
| 64 | 76 | update_term_meta($term_id, 'upk-category-image-id', ''); |
| 65 | 77 | } |