| @@ -231,9 +231,17 @@ | ||
| 231 | 231 | * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
| 232 | 232 | */ |
| 233 | 233 | public function get_item($request) { |
| 234 | 234 | PostType::get_instance()->set_context( 'edit' ); |
| 235 | - return PostType::get_instance()->get_post( absint( $request['id'] ) ); | |
| 235 | + $post = PostType::get_instance()->get_post( absint( $request['id'] ) ); | |
| 236 | + if ( empty( $post ) ) { | |
| 237 | + return new WP_Error( | |
| 238 | + 'rest_post_invalid_id', | |
| 239 | + __( 'Invalid notification ID.', 'notificationx' ), | |
| 240 | + array( 'status' => 404 ) | |
| 241 | + ); | |
| 242 | + } | |
| 243 | + return $post; | |
| 236 | 244 | } |
| 237 | 245 | |
| 238 | 246 | /** |
| 239 | 247 | * Checks if a given request has access to create a post. |