Skip to content
This repository was archived by the owner on Nov 9, 2017. It is now read-only.

Commit 48a2a5a

Browse files
committed
Remove unnecessary code
1 parent 5105fa6 commit 48a2a5a

File tree

1 file changed

+1
-25
lines changed

1 file changed

+1
-25
lines changed

src/endpoints/class-papi-rest-api-fields-controller.php

Lines changed: 1 addition & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function register_routes() {
2424
[
2525
'methods' => WP_REST_Server::EDITABLE,
2626
'callback' => [$this, 'update_fields'],
27-
'permission_callback' => [$this, 'update_fields_permissions_check']
27+
'permission_callback' => [$this, 'update_field_permissions_check']
2828
]
2929
] );
3030

@@ -403,28 +403,4 @@ public function update_field_permissions_check( WP_REST_Request $request ) {
403403

404404
return true;
405405
}
406-
407-
/**
408-
* Check if a given request has access to update properties.
409-
*
410-
* @param WP_REST_Request $request
411-
*
412-
* @return bool|WP_Error
413-
*/
414-
public function update_fields_permissions_check( WP_REST_Request $request ) {
415-
$post = get_post( $request['id'] );
416-
$post_type = get_post_type_object( $post->post_type );
417-
418-
if ( ! empty( $request['author'] ) && get_current_user_id() !== $request['author'] && ! current_user_can( $post_type->cap->edit_others_posts ) ) {
419-
return new WP_Error( 'papi_cannot_edit_others', __( 'You are not allowed to update posts as this user.', 'papi-rest-api' ), ['status' => rest_authorization_required_code()] );
420-
}
421-
422-
foreach ( $this->get_properties_capabilities( $request ) as $capability ) {
423-
if ( ! current_user_can( $capability ) ) {
424-
return new WP_Error( 'papi_cannot_update_property', __( 'Sorry, you are not allowed to update the property value.', 'papi-rest-api' ), ['status' => rest_authorization_required_code()] );
425-
}
426-
}
427-
428-
return current_user_can( $post_type->cap->create_posts );
429-
}
430406
}

0 commit comments

Comments
 (0)