WP_REST_Edit_Site_Export_Controller::permissions_check() WordPress Method

The WP_REST_Edit_Site_Export_Controller::permissions_check() method is used to check if the current user has the necessary permissions to perform a given action on the site. This method is called by the various methods of the WP_REST_Edit_Site_Export_Controller class.

WP_REST_Edit_Site_Export_Controller::permissions_check() #

Checks whether a given request has permission to export.


Return

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


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-edit-site-export-controller.php

	public function permissions_check() {
		if ( current_user_can( 'edit_theme_options' ) ) {
			return true;
		}

		return new WP_Error(
			'rest_cannot_export_templates',
			__( 'Sorry, you are not allowed to export templates and template parts.' ),
			array( 'status' => rest_authorization_required_code() )
		);
	}


Top ↑

Changelog

Changelog
VersionDescription
5.9.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.