REST API: Set global $post when preparing revisions.

For compatibility with filters on hooks on content filters (such as shortcodes), we need to set the global. This mirrors the Posts controller.

Props pdufour, jnylen0.
Fixes #40626.

Built from https://develop.svn.wordpress.org/trunk@40601


git-svn-id: http://core.svn.wordpress.org/trunk@40471 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Ryan McCue 2017-05-10 04:32:39 +00:00
parent 027e8d9218
commit ba94bd62a0
2 changed files with 4 additions and 1 deletions

View File

@ -338,6 +338,9 @@ class WP_REST_Revisions_Controller extends WP_REST_Controller {
* @return WP_REST_Response Response object.
*/
public function prepare_item_for_response( $post, $request ) {
$GLOBALS['post'] = $post;
setup_postdata( $post );
$schema = $this->get_item_schema();

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.8-alpha-40600';
$wp_version = '4.8-alpha-40601';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.