WP_REST_Block_Renderer_Controller::get_item_permissions_check

Advertisement

Summery Summery

Checks if a given request has access to read blocks.

Syntax Syntax

WP_REST_Block_Renderer_Controller::get_item_permissions_check( WP_REST_Request $request )

Parameters Parameters

$request

(Required) Request.

Return Return

(true|WP_Error) True if the request has read access, WP_Error object otherwise.

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-block-renderer-controller.php

							},
						),
						'post_id'    => array(
							'description' => __( 'ID of the post context.' ),
							'type'        => 'integer',
						),
					),
				),
				'schema' => array( $this, 'get_public_item_schema' ),
			)
		);
	}

	/**
	 * Checks if a given request has access to read blocks.
	 *
	 * @since 5.0.0
	 *
	 * @param WP_REST_Request $request Request.
	 * @return true|WP_Error True if the request has read access, WP_Error object otherwise.
	 */
	public function get_item_permissions_check( $request ) {
		global $post;

		$post_id = isset( $request['post_id'] ) ? intval( $request['post_id'] ) : 0;

		if ( 0 < $post_id ) {
			$post = get_post( $post_id );

			if ( ! $post || ! current_user_can( 'edit_post', $post->ID ) ) {
				return new WP_Error(

Advertisement

Changelog Changelog

Changelog
Version Description
5.0.0 Introduced.

Advertisement

Leave a Reply