REST API: Remove rest_get_post filter and get_post abstraction.

This filter was originally introduced in https://github.com/WP-API/WP-API/pull/2535 to support Customizer Changesets (née Transactions). This is a super broad filter and doesn't really fit with the design of the API, nor is it (arguably) the right level to do this.

Props rmccue.
Fixes #38701.


git-svn-id: https://develop.svn.wordpress.org/trunk@39161 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Joe Hoyle
2016-11-08 13:08:49 +00:00
parent 2eca6870b9
commit 6fd4d6e0ea
6 changed files with 26 additions and 87 deletions

View File

@@ -580,41 +580,6 @@ abstract class WP_REST_Controller {
return $endpoint_args;
}
/**
* Retrieves post data given a post ID or post object.
*
* This is a subset of the functionality of the `get_post()` function, with
* the additional functionality of having `the_post` action done on the
* resultant post object. This is done so that plugins may manipulate the
* post that is used in the REST API.
*
* @since 4.7.0
* @access public
*
* @see get_post()
* @global WP_Query $wp_query
*
* @param int|WP_Post $post Post ID or object. Defaults to global `$post` object.
* @return WP_Post|null A WP_Post object when successful, otherwise null.
*/
public function get_post( $post ) {
$post_obj = get_post( $post );
/**
* Filters the post in the context of a REST request.
*
* Allows plugins to filter the post object as returned by WP_REST_Controller::get_post().
*
* @since 4.7.0
*
* @param WP_Post|null $post_obj The post object as returned by get_post().
* @param int|WP_Post $post The original value used to obtain the post object.
*/
$post = apply_filters( 'rest_the_post', $post_obj, $post );
return $post;
}
/**
* Sanitizes the slug value.
*