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-posts-controller.php

    r39155 r39161  
    351351    public function get_item_permissions_check( $request ) {
    352352
    353         $post = $this->get_post( (int) $request['id'] );
     353        $post = get_post( (int) $request['id'] );
    354354
    355355        if ( 'edit' === $request['context'] && $post && ! $this->check_update_permission( $post ) ) {
     
    420420    public function get_item( $request ) {
    421421        $id   = (int) $request['id'];
    422         $post = $this->get_post( $id );
     422        $post = get_post( $id );
    423423
    424424        if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
     
    532532        }
    533533
    534         $post = $this->get_post( $post_id );
     534        $post = get_post( $post_id );
    535535
    536536        if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
     
    583583    public function update_item_permissions_check( $request ) {
    584584
    585         $post = $this->get_post( $request['id'] );
     585        $post = get_post( $request['id'] );
    586586        $post_type = get_post_type_object( $this->post_type );
    587587
     
    616616    public function update_item( $request ) {
    617617        $id   = (int) $request['id'];
    618         $post = $this->get_post( $id );
     618        $post = get_post( $id );
    619619
    620620        if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
     
    668668        }
    669669
    670         $post = $this->get_post( $post_id );
     670        $post = get_post( $post_id );
    671671
    672672        if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
     
    705705    public function delete_item_permissions_check( $request ) {
    706706
    707         $post = $this->get_post( $request['id'] );
     707        $post = get_post( $request['id'] );
    708708
    709709        if ( $post && ! $this->check_delete_permission( $post ) ) {
     
    727727        $force = (bool) $request['force'];
    728728
    729         $post = $this->get_post( $id );
     729        $post = get_post( $id );
    730730
    731731        if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
     
    780780            // the trash is disabled.)
    781781            $result = wp_trash_post( $id );
    782             $post = $this->get_post( $id );
     782            $post = get_post( $id );
    783783            $response = $this->prepare_item_for_response( $post, $request );
    784784        }
     
    10721072        // Parent.
    10731073        if ( ! empty( $schema['properties']['parent'] ) && ! empty( $request['parent'] ) ) {
    1074             $parent = $this->get_post( (int) $request['parent'] );
     1074            $parent = get_post( (int) $request['parent'] );
    10751075
    10761076            if ( empty( $parent ) ) {
     
    11841184     */
    11851185    public function handle_template( $template, $post_id ) {
    1186         if ( in_array( $template, array_keys( wp_get_theme()->get_page_templates( $this->get_post( $post_id ) ) ), true ) ) {
     1186        if ( in_array( $template, array_keys( wp_get_theme()->get_page_templates( get_post( $post_id ) ) ), true ) ) {
    11871187            update_post_meta( $post_id, '_wp_page_template', $template );
    11881188        } else {
     
    13011301        // Can we read the parent if we're inheriting?
    13021302        if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) {
    1303             $parent = $this->get_post( $post->post_parent );
     1303            $parent = get_post( $post->post_parent );
    13041304            return $this->check_read_permission( $parent );
    13051305        }
Note: See TracChangeset for help on using the changeset viewer.