From 7155e3c0832f1c9507ca0d50362d98fc7dcf868d Mon Sep 17 00:00:00 2001 From: Jonny Harris Date: Mon, 13 Dec 2021 15:19:01 +0000 Subject: [PATCH] REST API: Ensure that the parent link, uses the rest_get_route_for_post function. In [51962] the `rest_get_route_for_post` function was implemented in all places where link to a post's REST API endpoint is needed. However in this commit, the up link, which links to the parent post of the current object, did not use this function. Props Spacedmonkey, SergeyBiryukov. Fixes #53656. git-svn-id: https://develop.svn.wordpress.org/trunk@52363 602fd350-edb4-49c9-b593-d223f7449a82 --- .../rest-api/endpoints/class-wp-rest-posts-controller.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 4aa893e907..dfb97f7b60 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -2039,7 +2039,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { if ( $post_type_obj->hierarchical && ! empty( $post->post_parent ) ) { $links['up'] = array( - 'href' => rest_url( trailingslashit( $base ) . (int) $post->post_parent ), + 'href' => rest_url( rest_get_route_for_post( $post->post_parent ) ), 'embeddable' => true, ); }