mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-04-04 12:44:31 +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:
@@ -350,7 +350,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
*/
|
||||
public function get_item_permissions_check( $request ) {
|
||||
|
||||
$post = $this->get_post( (int) $request['id'] );
|
||||
$post = get_post( (int) $request['id'] );
|
||||
|
||||
if ( 'edit' === $request['context'] && $post && ! $this->check_update_permission( $post ) ) {
|
||||
return new WP_Error( 'rest_forbidden_context', __( 'Sorry, you are not allowed to edit this post.' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
@@ -419,7 +419,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
*/
|
||||
public function get_item( $request ) {
|
||||
$id = (int) $request['id'];
|
||||
$post = $this->get_post( $id );
|
||||
$post = get_post( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
|
||||
return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post id.' ), array( 'status' => 404 ) );
|
||||
@@ -531,7 +531,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
return $terms_update;
|
||||
}
|
||||
|
||||
$post = $this->get_post( $post_id );
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
|
||||
$meta_update = $this->meta->update_value( $request['meta'], (int) $request['id'] );
|
||||
@@ -582,7 +582,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
*/
|
||||
public function update_item_permissions_check( $request ) {
|
||||
|
||||
$post = $this->get_post( $request['id'] );
|
||||
$post = get_post( $request['id'] );
|
||||
$post_type = get_post_type_object( $this->post_type );
|
||||
|
||||
if ( $post && ! $this->check_update_permission( $post ) ) {
|
||||
@@ -615,7 +615,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
*/
|
||||
public function update_item( $request ) {
|
||||
$id = (int) $request['id'];
|
||||
$post = $this->get_post( $id );
|
||||
$post = get_post( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
|
||||
return new WP_Error( 'rest_post_invalid_id', __( 'Post id is invalid.' ), array( 'status' => 404 ) );
|
||||
@@ -667,7 +667,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
return $terms_update;
|
||||
}
|
||||
|
||||
$post = $this->get_post( $post_id );
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( ! empty( $schema['properties']['meta'] ) && isset( $request['meta'] ) ) {
|
||||
$meta_update = $this->meta->update_value( $request['meta'], $post->ID );
|
||||
@@ -704,7 +704,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
*/
|
||||
public function delete_item_permissions_check( $request ) {
|
||||
|
||||
$post = $this->get_post( $request['id'] );
|
||||
$post = get_post( $request['id'] );
|
||||
|
||||
if ( $post && ! $this->check_delete_permission( $post ) ) {
|
||||
return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you are not allowed to delete posts.' ), array( 'status' => rest_authorization_required_code() ) );
|
||||
@@ -726,7 +726,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
$id = (int) $request['id'];
|
||||
$force = (bool) $request['force'];
|
||||
|
||||
$post = $this->get_post( $id );
|
||||
$post = get_post( $id );
|
||||
|
||||
if ( empty( $id ) || empty( $post->ID ) || $this->post_type !== $post->post_type ) {
|
||||
return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post id.' ), array( 'status' => 404 ) );
|
||||
@@ -779,7 +779,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
// (Note that internally this falls through to `wp_delete_post` if
|
||||
// the trash is disabled.)
|
||||
$result = wp_trash_post( $id );
|
||||
$post = $this->get_post( $id );
|
||||
$post = get_post( $id );
|
||||
$response = $this->prepare_item_for_response( $post, $request );
|
||||
}
|
||||
|
||||
@@ -1071,7 +1071,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
|
||||
// Parent.
|
||||
if ( ! empty( $schema['properties']['parent'] ) && ! empty( $request['parent'] ) ) {
|
||||
$parent = $this->get_post( (int) $request['parent'] );
|
||||
$parent = get_post( (int) $request['parent'] );
|
||||
|
||||
if ( empty( $parent ) ) {
|
||||
return new WP_Error( 'rest_post_invalid_id', __( 'Invalid post parent id.' ), array( 'status' => 400 ) );
|
||||
@@ -1183,7 +1183,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
* @param integer $post_id Post ID.
|
||||
*/
|
||||
public function handle_template( $template, $post_id ) {
|
||||
if ( in_array( $template, array_keys( wp_get_theme()->get_page_templates( $this->get_post( $post_id ) ) ), true ) ) {
|
||||
if ( in_array( $template, array_keys( wp_get_theme()->get_page_templates( get_post( $post_id ) ) ), true ) ) {
|
||||
update_post_meta( $post_id, '_wp_page_template', $template );
|
||||
} else {
|
||||
update_post_meta( $post_id, '_wp_page_template', '' );
|
||||
@@ -1300,7 +1300,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
|
||||
|
||||
// Can we read the parent if we're inheriting?
|
||||
if ( 'inherit' === $post->post_status && $post->post_parent > 0 ) {
|
||||
$parent = $this->get_post( $post->post_parent );
|
||||
$parent = get_post( $post->post_parent );
|
||||
return $this->check_read_permission( $parent );
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user