← All changes
|
src/rest-api/content-helper/class-endpoint-traffic-boost.php
+19
-12
3.24.1
→
3.24.2
View file →
| @@ -304,15 +304,18 @@ | ||
| 304 | 304 | * @param WP_REST_Request $request The request object. |
| 305 | 305 | * @return WP_REST_Response|WP_Error The response object. |
| 306 | 306 | */ |
| 307 | 307 | public function generate_link_suggestions( WP_REST_Request $request ) { |
| 308 | - /** | |
| 309 | - * The post object. | |
| 310 | - * | |
| 311 | - * @var WP_Post $post | |
| 312 | - */ | |
| 313 | - $post = $request->get_param( 'post' ); | |
| 308 | + $post = $this->get_request_post( $request ); | |
| 314 | 309 | |
| 310 | + if ( ! $post instanceof WP_Post ) { | |
| 311 | + return new WP_Error( | |
| 312 | + 'invalid_post', | |
| 313 | + __( 'Invalid post.', 'wp-parsely' ), | |
| 314 | + array( 'status' => 404 ) | |
| 315 | + ); | |
| 316 | + } | |
| 317 | + | |
| 315 | 318 | /** |
| 316 | 319 | * The maximum number of suggestions to return. |
| 317 | 320 | * |
| 318 | 321 | * @var int $max_items |
| @@ -401,14 +404,18 @@ | ||
| 401 | 404 | * @param WP_REST_Request $request The request object. |
| 402 | 405 | * @return WP_REST_Response|WP_Error The response object. |
| 403 | 406 | */ |
| 404 | 407 | public function generate_placement_suggestions( WP_REST_Request $request ) { |
| 405 | - /** | |
| 406 | - * The destination post, that the inbound link links to. | |
| 407 | - * | |
| 408 | - * @var WP_Post $destination_post | |
| 409 | - */ | |
| 410 | - $destination_post = $request->get_param( 'post' ); | |
| 408 | + // The destination post, that the inbound link links to. | |
| 409 | + $destination_post = $this->get_request_post( $request ); | |
| 410 | + | |
| 411 | + if ( ! $destination_post instanceof WP_Post ) { | |
| 412 | + return new WP_Error( | |
| 413 | + 'invalid_post', | |
| 414 | + __( 'Invalid post.', 'wp-parsely' ), | |
| 415 | + array( 'status' => 404 ) | |
| 416 | + ); | |
| 417 | + } | |
| 411 | 418 | |
| 412 | 419 | /** |
| 413 | 420 | * The source post ID, where the inbound link will be placed. |
| 414 | 421 | * |