Code Duplication    Length = 11-11 lines in 2 locations

lib/endpoints/class-wp-rest-post-statuses-controller.php 1 location

@@ 84-94 (lines=11) @@
81
	 * @param  WP_REST_Request $request Full details about the request.
82
	 * @return WP_Error|boolean
83
	 */
84
	public function get_item_permissions_check( $request ) {
85
		$status = get_post_status_object( $request['status'] );
86
		if ( empty( $status ) ) {
87
			return new WP_Error( 'rest_status_invalid', __( 'Invalid resource.' ), array( 'status' => 404 ) );
88
		}
89
		$check = $this->check_read_permission( $status );
90
		if ( ! $check ) {
91
			return new WP_Error( 'rest_cannot_read_status', __( 'Cannot view resource.' ), array( 'status' => rest_authorization_required_code() ) );
92
		}
93
		return true;
94
	}
95
96
	/**
97
	 * Check whether a given post status should be visible

lib/endpoints/class-wp-rest-comments-controller.php 1 location

@@ 477-487 (lines=11) @@
474
	 * @param  WP_REST_Request $request Full details about the request.
475
	 * @return WP_Error|boolean
476
	 */
477
	public function delete_item_permissions_check( $request ) {
478
		$id = (int) $request['id'];
479
		$comment = get_comment( $id );
480
		if ( ! $comment ) {
481
			return new WP_Error( 'rest_comment_invalid_id', __( 'Invalid comment id.' ), array( 'status' => 404 ) );
482
		}
483
		if ( ! $this->check_edit_permission( $comment ) ) {
484
			return new WP_Error( 'rest_cannot_delete', __( 'Sorry, you can not delete this comment.' ), array( 'status' => rest_authorization_required_code() ) );
485
		}
486
		return true;
487
	}
488
489
	/**
490
	 * Delete a comment.