← All changes
|
json-endpoints/class.wpcom-json-api-update-taxonomy-endpoint.php
+10
-1
13.5.2
→
16.3-a.1
View file →
| @@ -10,8 +10,12 @@ | ||
| 10 | 10 | * Delete a category: /sites/%s/categories/slug:%s/delete |
| 11 | 11 | * Delete a tag: /sites/%s/tags/slug:%s/delete |
| 12 | 12 | */ |
| 13 | 13 | |
| 14 | +if ( ! defined( 'ABSPATH' ) ) { | |
| 15 | + exit( 0 ); | |
| 16 | +} | |
| 17 | + | |
| 14 | 18 | new WPCOM_JSON_API_Update_Taxonomy_Endpoint( |
| 15 | 19 | array( |
| 16 | 20 | 'description' => 'Create a new category.', |
| 17 | 21 | 'group' => 'taxonomy', |
| @@ -184,8 +188,10 @@ | ||
| 184 | 188 | ); |
| 185 | 189 | |
| 186 | 190 | /** |
| 187 | 191 | * Update site taxonomy API class. |
| 192 | + * | |
| 193 | + * @phan-constructor-used-for-side-effects | |
| 188 | 194 | */ |
| 189 | 195 | class WPCOM_JSON_API_Update_Taxonomy_Endpoint extends WPCOM_JSON_API_Taxonomy_Endpoint { |
| 190 | 196 | /** |
| 191 | 197 | * Update site taxonomy API callback. |
| @@ -325,9 +331,12 @@ | ||
| 325 | 331 | if ( ! empty( $input['name'] ) ) { |
| 326 | 332 | $update['name'] = addslashes( $input['name'] ); |
| 327 | 333 | } |
| 328 | 334 | |
| 329 | - $data = wp_update_term( $taxonomy->term_id, $taxonomy_type, $update ); | |
| 335 | + $data = wp_update_term( $taxonomy->term_id, $taxonomy_type, $update ); | |
| 336 | + if ( is_wp_error( $data ) ) { | |
| 337 | + return $data; | |
| 338 | + } | |
| 330 | 339 | $taxonomy = get_term_by( 'id', $data['term_id'], $taxonomy_type ); |
| 331 | 340 | |
| 332 | 341 | $return = $this->get_taxonomy( $taxonomy->slug, $taxonomy_type, $args['context'] ); |
| 333 | 342 | if ( ! $return || is_wp_error( $return ) ) { |