From 324d440c7ac97a157660ee7fcd44fee830ff1f7f Mon Sep 17 00:00:00 2001 From: Rachel Baker Date: Fri, 31 Aug 2018 23:25:39 +0000 Subject: [PATCH] REST API: Load missing required file for multisite users in `WP_REST_Attachments_Controller::check_upload_size()`. Requires wp-admin/includes/ms.php to make `upload_is_user_over_quota()` function available to multisite users uploading files. Props JakePT, rachelbaker. Fixes #44864. git-svn-id: https://develop.svn.wordpress.org/trunk@43603 602fd350-edb4-49c9-b593-d223f7449a82 --- .../endpoints/class-wp-rest-attachments-controller.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php index 813de1c013..80f6ac4c25 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php @@ -805,6 +805,9 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { return new WP_Error( 'rest_upload_file_too_big', sprintf( __( 'This file is too big. Files must be less than %s KB in size.' ), get_site_option( 'fileupload_maxk', 1500 ) ), array( 'status' => 400 ) ); } + // Include admin function to get access to upload_is_user_over_quota(). + require_once ABSPATH . 'wp-admin/includes/ms.php'; + if ( upload_is_user_over_quota( false ) ) { return new WP_Error( 'rest_upload_user_quota_exceeded', __( 'You have used your space quota. Please delete files before uploading.' ), array( 'status' => 400 ) ); }