diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php index 334d1a2db6..e93ccfbb4a 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-posts-controller.php @@ -1667,9 +1667,23 @@ class WP_REST_Posts_Controller extends WP_REST_Controller { } if ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'revisions' ) ) { + $revisions = wp_get_post_revisions( $post->ID, array( 'fields' => 'ids' ) ); + $revisions_count = count( $revisions ); + $links['version-history'] = array( - 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions' ), + 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions' ), + 'count' => $revisions_count, ); + + if ( $revisions_count > 0 ) { + $last_revision = array_shift( $revisions ); + + $links['predecessor-version'] = array( + 'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions/' . $last_revision ), + 'id' => $last_revision, + ); + } + } $post_type_obj = get_post_type_object( $post->post_type ); diff --git a/wp-includes/version.php b/wp-includes/version.php index c994f34b7d..ad72c1e2a9 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.9.8-alpha-43438'; +$wp_version = '4.9.8-alpha-43442'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.