Make WordPress Core


Ignore:
Timestamp:
11/08/2016 01:08:49 PM (8 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/tests/phpunit/tests/rest-api/rest-controller.php

    r38832 r39161  
    191191        $this->assertEquals( 'a', $args['somedefault']['default'] );
    192192    }
    193 
    194     public $rest_the_post_filter_apply_count = 0;
    195 
    196     public function test_get_post() {
    197         $post_id = $this->factory()->post->create( array( 'post_title' => 'Original' ) );
    198         $controller = new WP_REST_Test_Controller();
    199 
    200         $post = $controller->get_post( $post_id );
    201         $this->assertEquals( 'Original', $post->post_title );
    202 
    203         $filter_apply_count = $this->rest_the_post_filter_apply_count;
    204         add_filter( 'rest_the_post', array( $this, 'filter_rest_the_post_for_test_get_post' ), 10, 2 );
    205         $post = $controller->get_post( $post_id );
    206         $this->assertEquals( 'Overridden', $post->post_title );
    207         $this->assertEquals( 1 + $filter_apply_count, $this->rest_the_post_filter_apply_count );
    208     }
    209 
    210     public function filter_rest_the_post_for_test_get_post( $post, $post_id ) {
    211         $this->assertInstanceOf( 'WP_Post', $post );
    212         $this->assertInternalType( 'int', $post_id );
    213         $post->post_title = 'Overridden';
    214         $this->rest_the_post_filter_apply_count += 1;
    215         return $post;
    216     }
    217193}
Note: See TracChangeset for help on using the changeset viewer.