mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
REST API: Support generating comment up links to custom posts controllers.
The comments controller now uses the `rest_get_route_for_post` function introduced in WordPress 5.5 to generate the link. This function is filterable to allow for custom controllers to properly define their REST API route. Props dsifford, TimothyBlynJacobs. Fixes #44152. Built from https://develop.svn.wordpress.org/trunk@49299 git-svn-id: http://core.svn.wordpress.org/trunk@49061 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4d695ba6b3
commit
9baba12f00
@ -1159,14 +1159,12 @@ class WP_REST_Comments_Controller extends WP_REST_Controller {
|
||||
}
|
||||
|
||||
if ( 0 !== (int) $comment->comment_post_ID ) {
|
||||
$post = get_post( $comment->comment_post_ID );
|
||||
|
||||
if ( ! empty( $post->ID ) ) {
|
||||
$obj = get_post_type_object( $post->post_type );
|
||||
$base = ! empty( $obj->rest_base ) ? $obj->rest_base : $obj->name;
|
||||
$post = get_post( $comment->comment_post_ID );
|
||||
$post_route = rest_get_route_for_post( $post );
|
||||
|
||||
if ( ! empty( $post->ID ) && $post_route ) {
|
||||
$links['up'] = array(
|
||||
'href' => rest_url( 'wp/v2/' . $base . '/' . $comment->comment_post_ID ),
|
||||
'href' => rest_url( $post_route ),
|
||||
'embeddable' => true,
|
||||
'post_type' => $post->post_type,
|
||||
);
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.6-beta1-49298';
|
||||
$wp_version = '5.6-beta1-49299';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
Reference in New Issue
Block a user