WP_REST_View_Config_Controller::get_items_permissions_check( WP_REST_Request $request ): true|WP_Error

In this article

Checks if a given request has access to read view config.

Parameters

$requestWP_REST_Requestrequired
Full details about the request.

Return

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

Source

public function get_items_permissions_check( $request ) {
	$kind = $request->get_param( 'kind' );
	$name = $request->get_param( 'name' );

	$capability = $this->get_required_capability( $kind, $name );

	if ( null === $capability ) {
		return new WP_Error(
			'rest_view_config_invalid_entity',
			__( 'Invalid entity kind or name.' ),
			array( 'status' => 404 )
		);
	}

	if ( ! current_user_can( $capability ) ) {
		return new WP_Error(
			'rest_cannot_read',
			__( 'Sorry, you are not allowed to read view config.' ),
			array( 'status' => rest_authorization_required_code() )
		);
	}

	return true;
}

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.