Make WordPress Core


Ignore:
Timestamp:
11/08/2016 01:08:49 PM (9 years ago)
Author:
joehoyle
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-controller.php

    r39046 r39161  
    582582
    583583    /**
    584      * Retrieves post data given a post ID or post object.
    585      *
    586      * This is a subset of the functionality of the `get_post()` function, with
    587      * the additional functionality of having `the_post` action done on the
    588      * resultant post object. This is done so that plugins may manipulate the
    589      * post that is used in the REST API.
    590      *
    591      * @since 4.7.0
    592      * @access public
    593      *
    594      * @see get_post()
    595      * @global WP_Query $wp_query
    596      *
    597      * @param int|WP_Post $post Post ID or object. Defaults to global `$post` object.
    598      * @return WP_Post|null A WP_Post object when successful, otherwise null.
    599      */
    600     public function get_post( $post ) {
    601         $post_obj = get_post( $post );
    602 
    603         /**
    604          * Filters the post in the context of a REST request.
    605          *
    606          * Allows plugins to filter the post object as returned by WP_REST_Controller::get_post().
    607          *
    608          * @since 4.7.0
    609          *
    610          * @param WP_Post|null $post_obj The post object as returned by get_post().
    611          * @param int|WP_Post  $post     The original value used to obtain the post object.
    612          */
    613         $post = apply_filters( 'rest_the_post', $post_obj, $post );
    614 
    615         return $post;
    616     }
    617 
    618     /**
    619584     * Sanitizes the slug value.
    620585     *
Note: See TracChangeset for help on using the changeset viewer.