diff --git src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php src/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php
index b7b2dd79f6..901b844189 100644
|
|
class WP_REST_Posts_Controller extends WP_REST_Controller { |
1664 | 1664 | } |
1665 | 1665 | |
1666 | 1666 | if ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'revisions' ) ) { |
| 1667 | $revisions = wp_get_post_revisions( $post->ID ); |
| 1668 | $revisions_count = count( $revisions ); |
| 1669 | |
1667 | 1670 | $links['version-history'] = array( |
1668 | | 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions' ), |
| 1671 | 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions' ), |
| 1672 | 'count' => $revisions_count, |
1669 | 1673 | ); |
| 1674 | |
| 1675 | if ( 0 < $revisions_count ) { |
| 1676 | $last_revision = array_shift( $revisions ); |
| 1677 | |
| 1678 | $links['predecessor'] = array( |
| 1679 | 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions/' . $last_revision->ID ), |
| 1680 | ); |
| 1681 | } |
1670 | 1682 | } |
1671 | 1683 | |
1672 | 1684 | $post_type_obj = get_post_type_object( $post->post_type ); |