REST API: Ensure that the export template endpoint returns a valid WP_Error object.
Ensure that the export template endpoint returns a WP_Error object, including code and message, so that the site editor can display an error message. Add some basic unit tests to ensure that permission checks are working as expected. Follow-up to [52286]. Props Spacedmonkey, dlh, hellofromTonya , Mamaduka, TimothyBlynJacobs. Fixes #54448. Built from https://develop.svn.wordpress.org/trunk@52340 git-svn-id: http://core.svn.wordpress.org/trunk@51932 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -54,8 +54,8 @@ class WP_REST_Edit_Site_Export_Controller extends WP_REST_Controller {
|
||||
*/
|
||||
public function permissions_check() {
|
||||
if ( ! current_user_can( 'edit_theme_options' ) ) {
|
||||
new WP_Error(
|
||||
'rest_cannot_view_url_details',
|
||||
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() )
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user