/** * Delete a post * * @see WP_JSON_Posts::delete_post() */ public function delete_post($id, $force = false) { $id = (int) $id; if (empty($id)) { json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], ""); } $post = get_post($id, ARRAY_A); if ($post['post_type'] !== $this->type) { json_error(BigAppErr::$post['code'], BigAppErr::$post['msg'], ""); } return parent::delete_post($id, $force); }
/** * Delete a attachment * * @see WP_JSON_Posts::delete_post() */ public function delete_post($id, $force = false) { $id = (int) $id; if (empty($id)) { return new WP_Error('json_post_invalid_id', __('Invalid post ID.'), array('status' => 404)); } $post = get_post($id, ARRAY_A); if ($post['post_type'] !== 'attachment') { return new WP_Error('json_post_invalid_type', __('Invalid post type'), array('status' => 400)); } return parent::delete_post($id, $force); }