Changeset 43462 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
- Timestamp:
- 07/17/2018 07:21:50 AM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r43437 r43462 560 560 ); 561 561 562 $size_check = self::check_upload_size( $file_data ); 563 if ( is_wp_error( $size_check ) ) { 564 return $size_check; 565 } 566 562 567 $overrides = array( 563 568 'test_form' => false, … … 727 732 } 728 733 734 $size_check = self::check_upload_size( $files['file'] ); 735 if ( is_wp_error( $size_check ) ) { 736 return $size_check; 737 } 738 729 739 /** Include admin functions to get access to wp_handle_upload() */ 730 740 require_once ABSPATH . 'wp-admin/includes/admin.php'; … … 764 774 } 765 775 776 /** 777 * Determine if uploaded file exceeds space quota on multisite. 778 * 779 * Replicates check_upload_size(). 780 * 781 * @since 4.9.8 782 * 783 * @param array $file $_FILES array for a given file. 784 * @return true|WP_Error True if can upload, error for errors. 785 */ 786 protected function check_upload_size( $file ) { 787 if ( ! is_multisite() ) { 788 return true; 789 } 790 791 if ( get_site_option( 'upload_space_check_disabled' ) ) { 792 return true; 793 } 794 795 $space_left = get_upload_space_available(); 796 797 $file_size = filesize( $file['tmp_name'] ); 798 if ( $space_left < $file_size ) { 799 /* translators: %s: required disk space in kilobytes */ 800 return new WP_Error( 'rest_upload_limited_space', sprintf( __( 'Not enough space to upload. %s KB needed.' ), number_format( ( $file_size - $space_left ) / KB_IN_BYTES ) ), array( 'status' => 400 ) ); 801 } 802 803 if ( $file_size > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) { 804 /* translators: %s: maximum allowed file size in kilobytes */ 805 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 ) ); 806 } 807 808 if ( upload_is_user_over_quota( false ) ) { 809 return new WP_Error( 'rest_upload_user_quota_exceeded', __( 'You have used your space quota. Please delete files before uploading.' ), array( 'status' => 400 ) ); 810 } 811 return true; 812 } 813 766 814 }
Note: See TracChangeset
for help on using the changeset viewer.