WordPress at Your Fingertips
function is not described

WP_REST_Widgets_Controller::permissions_check() protected WP 5.8.0

Performs a permissions check for managing widgets.

{} It's a method of the class: WP_REST_Widgets_Controller{}

No Hooks.

Return

true|WP_Error.

Usage

// protected - for code of main (parent) or child class
$result = $this->permissions_check( $request );
$request(WP_REST_Request) (required)
Full details about the request.

Changelog

Since 5.8.0 Introduced.

Code of WP_REST_Widgets_Controller::permissions_check() WP 5.8.1

protected function permissions_check( $request ) {
	if ( ! current_user_can( 'edit_theme_options' ) ) {
		return new WP_Error(
			'rest_cannot_manage_widgets',
			__( 'Sorry, you are not allowed to manage widgets on this site.' ),
			array(
				'status' => rest_authorization_required_code(),
			)
		);
	}

	return true;
}