mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-08 22:54:36 +00:00
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:
@@ -190,28 +190,4 @@ class WP_Test_REST_Controller extends WP_Test_REST_TestCase {
|
||||
|
||||
$this->assertEquals( 'a', $args['somedefault']['default'] );
|
||||
}
|
||||
|
||||
public $rest_the_post_filter_apply_count = 0;
|
||||
|
||||
public function test_get_post() {
|
||||
$post_id = $this->factory()->post->create( array( 'post_title' => 'Original' ) );
|
||||
$controller = new WP_REST_Test_Controller();
|
||||
|
||||
$post = $controller->get_post( $post_id );
|
||||
$this->assertEquals( 'Original', $post->post_title );
|
||||
|
||||
$filter_apply_count = $this->rest_the_post_filter_apply_count;
|
||||
add_filter( 'rest_the_post', array( $this, 'filter_rest_the_post_for_test_get_post' ), 10, 2 );
|
||||
$post = $controller->get_post( $post_id );
|
||||
$this->assertEquals( 'Overridden', $post->post_title );
|
||||
$this->assertEquals( 1 + $filter_apply_count, $this->rest_the_post_filter_apply_count );
|
||||
}
|
||||
|
||||
public function filter_rest_the_post_for_test_get_post( $post, $post_id ) {
|
||||
$this->assertInstanceOf( 'WP_Post', $post );
|
||||
$this->assertInternalType( 'int', $post_id );
|
||||
$post->post_title = 'Overridden';
|
||||
$this->rest_the_post_filter_apply_count += 1;
|
||||
return $post;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user