280 'yaml', |
280 'yaml', |
281 'yml', |
281 'yml', |
282 ); |
282 ); |
283 |
283 |
284 /** |
284 /** |
285 * Filters the list of file types allowed for editing in the theme editor. |
285 * Filters the list of file types allowed for editing in the theme file editor. |
286 * |
286 * |
287 * @since 4.4.0 |
287 * @since 4.4.0 |
288 * |
288 * |
289 * @param string[] $default_types An array of editable theme file extensions. |
289 * @param string[] $default_types An array of editable theme file extensions. |
290 * @param WP_Theme $theme The current theme object. |
290 * @param WP_Theme $theme The active theme object. |
291 */ |
291 */ |
292 $file_types = apply_filters( 'wp_theme_editor_filetypes', $default_types, $theme ); |
292 $file_types = apply_filters( 'wp_theme_editor_filetypes', $default_types, $theme ); |
293 |
293 |
294 // Ensure that default types are still there. |
294 // Ensure that default types are still there. |
295 return array_unique( array_merge( $file_types, $default_types ) ); |
295 return array_unique( array_merge( $file_types, $default_types ) ); |
731 * @access private |
731 * @access private |
732 * @since 4.0.0 |
732 * @since 4.0.0 |
733 * |
733 * |
734 * @see wp_handle_upload_error |
734 * @see wp_handle_upload_error |
735 * |
735 * |
736 * @param string[] $file Reference to a single element of `$_FILES`. |
736 * @param array $file { |
737 * Call the function once for each uploaded file. |
737 * Reference to a single element from `$_FILES`. Call the function once for each uploaded file. |
738 * @param array|false $overrides { |
738 * |
|
739 * @type string $name The original name of the file on the client machine. |
|
740 * @type string $type The mime type of the file, if the browser provided this information. |
|
741 * @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server. |
|
742 * @type int $size The size, in bytes, of the uploaded file. |
|
743 * @type int $error The error code associated with this file upload. |
|
744 * } |
|
745 * @param array|false $overrides { |
739 * An array of override parameters for this file, or boolean false if none are provided. |
746 * An array of override parameters for this file, or boolean false if none are provided. |
740 * |
747 * |
741 * @type callable $upload_error_handler Function to call when there is an error during the upload process. |
748 * @type callable $upload_error_handler Function to call when there is an error during the upload process. |
742 * @see wp_handle_upload_error(). |
749 * @see wp_handle_upload_error(). |
743 * @type callable $unique_filename_callback Function to call when determining a unique file name for the file. |
750 * @type callable $unique_filename_callback Function to call when determining a unique file name for the file. |
747 * @type bool $test_form Whether to test that the `$_POST['action']` parameter is as expected. |
754 * @type bool $test_form Whether to test that the `$_POST['action']` parameter is as expected. |
748 * @type bool $test_size Whether to test that the file size is greater than zero bytes. |
755 * @type bool $test_size Whether to test that the file size is greater than zero bytes. |
749 * @type bool $test_type Whether to test that the mime type of the file is as expected. |
756 * @type bool $test_type Whether to test that the mime type of the file is as expected. |
750 * @type string[] $mimes Array of allowed mime types keyed by their file extension regex. |
757 * @type string[] $mimes Array of allowed mime types keyed by their file extension regex. |
751 * } |
758 * } |
752 * @param string $time Time formatted in 'yyyy/mm'. |
759 * @param string $time Time formatted in 'yyyy/mm'. |
753 * @param string $action Expected value for `$_POST['action']`. |
760 * @param string $action Expected value for `$_POST['action']`. |
754 * @return string[] On success, returns an associative array of file attributes. |
761 * @return array { |
755 * On failure, returns `$overrides['upload_error_handler']( &$file, $message )` |
762 * On success, returns an associative array of file attributes. |
756 * or `array( 'error' => $message )`. |
763 * On failure, returns `$overrides['upload_error_handler']( &$file, $message )` |
|
764 * or `array( 'error' => $message )`. |
|
765 * |
|
766 * @type string $file Filename of the newly-uploaded file. |
|
767 * @type string $url URL of the newly-uploaded file. |
|
768 * @type string $type Mime type of the newly-uploaded file. |
|
769 * } |
757 */ |
770 */ |
758 function _wp_handle_upload( &$file, $overrides, $time, $action ) { |
771 function _wp_handle_upload( &$file, $overrides, $time, $action ) { |
759 // The default error handler. |
772 // The default error handler. |
760 if ( ! function_exists( 'wp_handle_upload_error' ) ) { |
773 if ( ! function_exists( 'wp_handle_upload_error' ) ) { |
761 function wp_handle_upload_error( &$file, $message ) { |
774 function wp_handle_upload_error( &$file, $message ) { |
774 * - `wp_handle_upload_prefilter` |
787 * - `wp_handle_upload_prefilter` |
775 * |
788 * |
776 * @since 2.9.0 as 'wp_handle_upload_prefilter'. |
789 * @since 2.9.0 as 'wp_handle_upload_prefilter'. |
777 * @since 4.0.0 Converted to a dynamic hook with `$action`. |
790 * @since 4.0.0 Converted to a dynamic hook with `$action`. |
778 * |
791 * |
779 * @param string[] $file An array of data for the file. Reference to a single element of `$_FILES`. |
792 * @param array $file { |
|
793 * Reference to a single element from `$_FILES`. |
|
794 * |
|
795 * @type string $name The original name of the file on the client machine. |
|
796 * @type string $type The mime type of the file, if the browser provided this information. |
|
797 * @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server. |
|
798 * @type int $size The size, in bytes, of the uploaded file. |
|
799 * @type int $error The error code associated with this file upload. |
|
800 * } |
780 */ |
801 */ |
781 $file = apply_filters( "{$action}_prefilter", $file ); |
802 $file = apply_filters( "{$action}_prefilter", $file ); |
782 |
803 |
783 /** |
804 /** |
784 * Filters the override parameters for a file before it is uploaded to WordPress. |
805 * Filters the override parameters for a file before it is uploaded to WordPress. |
792 * |
813 * |
793 * @since 5.7.0 |
814 * @since 5.7.0 |
794 * |
815 * |
795 * @param array|false $overrides An array of override parameters for this file. Boolean false if none are |
816 * @param array|false $overrides An array of override parameters for this file. Boolean false if none are |
796 * provided. @see _wp_handle_upload(). |
817 * provided. @see _wp_handle_upload(). |
797 * @param string[] $file An array of data for the file. Reference to a single element of `$_FILES`. |
818 * @param array $file { |
|
819 * Reference to a single element from `$_FILES`. |
|
820 * |
|
821 * @type string $name The original name of the file on the client machine. |
|
822 * @type string $type The mime type of the file, if the browser provided this information. |
|
823 * @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server. |
|
824 * @type int $size The size, in bytes, of the uploaded file. |
|
825 * @type int $error The error code associated with this file upload. |
|
826 * } |
798 */ |
827 */ |
799 $overrides = apply_filters( "{$action}_overrides", $overrides, $file ); |
828 $overrides = apply_filters( "{$action}_overrides", $overrides, $file ); |
800 |
829 |
801 // You may define your own function and pass the name in $overrides['upload_error_handler']. |
830 // You may define your own function and pass the name in $overrides['upload_error_handler']. |
802 $upload_error_handler = 'wp_handle_upload_error'; |
831 $upload_error_handler = 'wp_handle_upload_error'; |
900 if ( $proper_filename ) { |
929 if ( $proper_filename ) { |
901 $file['name'] = $proper_filename; |
930 $file['name'] = $proper_filename; |
902 } |
931 } |
903 |
932 |
904 if ( ( ! $type || ! $ext ) && ! current_user_can( 'unfiltered_upload' ) ) { |
933 if ( ( ! $type || ! $ext ) && ! current_user_can( 'unfiltered_upload' ) ) { |
905 return call_user_func_array( $upload_error_handler, array( &$file, __( 'Sorry, this file type is not permitted for security reasons.' ) ) ); |
934 return call_user_func_array( $upload_error_handler, array( &$file, __( 'Sorry, you are not allowed to upload this file type.' ) ) ); |
906 } |
935 } |
907 |
936 |
908 if ( ! $type ) { |
937 if ( ! $type ) { |
909 $type = $file['type']; |
938 $type = $file['type']; |
910 } |
939 } |
933 * error reporting will be completely skipped. |
962 * error reporting will be completely skipped. |
934 * |
963 * |
935 * @since 4.9.0 |
964 * @since 4.9.0 |
936 * |
965 * |
937 * @param mixed $move_new_file If null (default) move the file after the upload. |
966 * @param mixed $move_new_file If null (default) move the file after the upload. |
938 * @param string[] $file An array of data for a single file. |
967 * @param array $file { |
|
968 * Reference to a single element from `$_FILES`. |
|
969 * |
|
970 * @type string $name The original name of the file on the client machine. |
|
971 * @type string $type The mime type of the file, if the browser provided this information. |
|
972 * @type string $tmp_name The temporary filename of the file in which the uploaded file was stored on the server. |
|
973 * @type int $size The size, in bytes, of the uploaded file. |
|
974 * @type int $error The error code associated with this file upload. |
|
975 * } |
939 * @param string $new_file Filename of the newly-uploaded file. |
976 * @param string $new_file Filename of the newly-uploaded file. |
940 * @param string $type Mime type of the newly-uploaded file. |
977 * @param string $type Mime type of the newly-uploaded file. |
941 */ |
978 */ |
942 $move_new_file = apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type ); |
979 $move_new_file = apply_filters( 'pre_move_uploaded_file', null, $file, $new_file, $type ); |
943 |
980 |
1015 * |
1052 * |
1016 * @see _wp_handle_upload() |
1053 * @see _wp_handle_upload() |
1017 * |
1054 * |
1018 * @param array $file Reference to a single element of `$_FILES`. |
1055 * @param array $file Reference to a single element of `$_FILES`. |
1019 * Call the function once for each uploaded file. |
1056 * Call the function once for each uploaded file. |
|
1057 * See _wp_handle_upload() for accepted values. |
1020 * @param array|false $overrides Optional. An associative array of names => values |
1058 * @param array|false $overrides Optional. An associative array of names => values |
1021 * to override default variables. Default false. |
1059 * to override default variables. Default false. |
|
1060 * See _wp_handle_upload() for accepted values. |
1022 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. |
1061 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. |
1023 * @return array On success, returns an associative array of file attributes. |
1062 * @return array See _wp_handle_upload() for return value. |
1024 * On failure, returns `$overrides['upload_error_handler']( &$file, $message )` |
|
1025 * or `array( 'error' => $message )`. |
|
1026 */ |
1063 */ |
1027 function wp_handle_upload( &$file, $overrides = false, $time = null ) { |
1064 function wp_handle_upload( &$file, $overrides = false, $time = null ) { |
1028 /* |
1065 /* |
1029 * $_POST['action'] must be set and its value must equal $overrides['action'] |
1066 * $_POST['action'] must be set and its value must equal $overrides['action'] |
1030 * or this: |
1067 * or this: |
1046 * |
1083 * |
1047 * @see _wp_handle_upload() |
1084 * @see _wp_handle_upload() |
1048 * |
1085 * |
1049 * @param array $file Reference to a single element of `$_FILES`. |
1086 * @param array $file Reference to a single element of `$_FILES`. |
1050 * Call the function once for each uploaded file. |
1087 * Call the function once for each uploaded file. |
|
1088 * See _wp_handle_upload() for accepted values. |
1051 * @param array|false $overrides Optional. An associative array of names => values |
1089 * @param array|false $overrides Optional. An associative array of names => values |
1052 * to override default variables. Default false. |
1090 * to override default variables. Default false. |
|
1091 * See _wp_handle_upload() for accepted values. |
1053 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. |
1092 * @param string $time Optional. Time formatted in 'yyyy/mm'. Default null. |
1054 * @return array On success, returns an associative array of file attributes. |
1093 * @return array See _wp_handle_upload() for return value. |
1055 * On failure, returns `$overrides['upload_error_handler']( &$file, $message )` |
|
1056 * or `array( 'error' => $message )`. |
|
1057 */ |
1094 */ |
1058 function wp_handle_sideload( &$file, $overrides = false, $time = null ) { |
1095 function wp_handle_sideload( &$file, $overrides = false, $time = null ) { |
1059 /* |
1096 /* |
1060 * $_POST['action'] must be set and its value must equal $overrides['action'] |
1097 * $_POST['action'] must be set and its value must equal $overrides['action'] |
1061 * or this: |
1098 * or this: |
1073 * |
1110 * |
1074 * Please note that the calling function must unlink() the file. |
1111 * Please note that the calling function must unlink() the file. |
1075 * |
1112 * |
1076 * @since 2.5.0 |
1113 * @since 2.5.0 |
1077 * @since 5.2.0 Signature Verification with SoftFail was added. |
1114 * @since 5.2.0 Signature Verification with SoftFail was added. |
|
1115 * @since 5.9.0 Support for Content-Disposition filename was added. |
1078 * |
1116 * |
1079 * @param string $url The URL of the file to download. |
1117 * @param string $url The URL of the file to download. |
1080 * @param int $timeout The timeout for the request to download the file. |
1118 * @param int $timeout The timeout for the request to download the file. |
1081 * Default 300 seconds. |
1119 * Default 300 seconds. |
1082 * @param bool $signature_verification Whether to perform Signature Verification. |
1120 * @param bool $signature_verification Whether to perform Signature Verification. |
1087 // WARNING: The file is not automatically deleted, the script must unlink() the file. |
1125 // WARNING: The file is not automatically deleted, the script must unlink() the file. |
1088 if ( ! $url ) { |
1126 if ( ! $url ) { |
1089 return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) ); |
1127 return new WP_Error( 'http_no_url', __( 'Invalid URL Provided.' ) ); |
1090 } |
1128 } |
1091 |
1129 |
1092 $url_filename = basename( parse_url( $url, PHP_URL_PATH ) ); |
1130 $url_path = parse_url( $url, PHP_URL_PATH ); |
|
1131 $url_filename = ''; |
|
1132 if ( is_string( $url_path ) && '' !== $url_path ) { |
|
1133 $url_filename = basename( $url_path ); |
|
1134 } |
1093 |
1135 |
1094 $tmpfname = wp_tempnam( $url_filename ); |
1136 $tmpfname = wp_tempnam( $url_filename ); |
1095 if ( ! $tmpfname ) { |
1137 if ( ! $tmpfname ) { |
1096 return new WP_Error( 'http_no_file', __( 'Could not create temporary file.' ) ); |
1138 return new WP_Error( 'http_no_file', __( 'Could not create temporary file.' ) ); |
1097 } |
1139 } |
1139 unlink( $tmpfname ); |
1181 unlink( $tmpfname ); |
1140 |
1182 |
1141 return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ), $data ); |
1183 return new WP_Error( 'http_404', trim( wp_remote_retrieve_response_message( $response ) ), $data ); |
1142 } |
1184 } |
1143 |
1185 |
|
1186 $content_disposition = wp_remote_retrieve_header( $response, 'content-disposition' ); |
|
1187 |
|
1188 if ( $content_disposition ) { |
|
1189 $content_disposition = strtolower( $content_disposition ); |
|
1190 |
|
1191 if ( 0 === strpos( $content_disposition, 'attachment; filename=' ) ) { |
|
1192 $tmpfname_disposition = sanitize_file_name( substr( $content_disposition, 21 ) ); |
|
1193 } else { |
|
1194 $tmpfname_disposition = ''; |
|
1195 } |
|
1196 |
|
1197 // Potential file name must be valid string. |
|
1198 if ( $tmpfname_disposition && is_string( $tmpfname_disposition ) |
|
1199 && ( 0 === validate_file( $tmpfname_disposition ) ) |
|
1200 ) { |
|
1201 $tmpfname_disposition = dirname( $tmpfname ) . '/' . $tmpfname_disposition; |
|
1202 |
|
1203 if ( rename( $tmpfname, $tmpfname_disposition ) ) { |
|
1204 $tmpfname = $tmpfname_disposition; |
|
1205 } |
|
1206 |
|
1207 if ( ( $tmpfname !== $tmpfname_disposition ) && file_exists( $tmpfname_disposition ) ) { |
|
1208 unlink( $tmpfname_disposition ); |
|
1209 } |
|
1210 } |
|
1211 } |
|
1212 |
1144 $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); |
1213 $content_md5 = wp_remote_retrieve_header( $response, 'content-md5' ); |
1145 |
1214 |
1146 if ( $content_md5 ) { |
1215 if ( $content_md5 ) { |
1147 $md5_check = verify_file_md5( $tmpfname, $content_md5 ); |
1216 $md5_check = verify_file_md5( $tmpfname, $content_md5 ); |
1148 |
1217 |
1173 if ( ! $signature ) { |
1242 if ( ! $signature ) { |
1174 // Retrieve signatures from a file if the header wasn't included. |
1243 // Retrieve signatures from a file if the header wasn't included. |
1175 // WordPress.org stores signatures at $package_url.sig. |
1244 // WordPress.org stores signatures at $package_url.sig. |
1176 |
1245 |
1177 $signature_url = false; |
1246 $signature_url = false; |
1178 $url_path = parse_url( $url, PHP_URL_PATH ); |
1247 |
1179 |
1248 if ( is_string( $url_path ) && ( '.zip' === substr( $url_path, -4 ) || '.tar.gz' === substr( $url_path, -7 ) ) ) { |
1180 if ( '.zip' === substr( $url_path, -4 ) || '.tar.gz' === substr( $url_path, -7 ) ) { |
|
1181 $signature_url = str_replace( $url_path, $url_path . '.sig', $url ); |
1249 $signature_url = str_replace( $url_path, $url_path . '.sig', $url ); |
1182 } |
1250 } |
1183 |
1251 |
1184 /** |
1252 /** |
1185 * Filters the URL where the signature for a file is located. |
1253 * Filters the URL where the signature for a file is located. |
1316 __( 'The authenticity of %s could not be verified as signature verification is unavailable on this system.' ), |
1384 __( 'The authenticity of %s could not be verified as signature verification is unavailable on this system.' ), |
1317 '<span class="code">' . esc_html( $filename_for_errors ) . '</span>' |
1385 '<span class="code">' . esc_html( $filename_for_errors ) . '</span>' |
1318 ), |
1386 ), |
1319 array( |
1387 array( |
1320 'php' => phpversion(), |
1388 'php' => phpversion(), |
1321 // phpcs:ignore PHPCompatibility.Constants.NewConstants.sodium_library_versionFound |
|
1322 'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ), |
1389 'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ), |
1323 ) |
1390 ) |
1324 ); |
1391 ); |
1325 } |
1392 } |
1326 |
1393 |
1328 if ( ! extension_loaded( 'sodium' ) && ! ParagonIE_Sodium_Compat::polyfill_is_fast() ) { |
1395 if ( ! extension_loaded( 'sodium' ) && ! ParagonIE_Sodium_Compat::polyfill_is_fast() ) { |
1329 $sodium_compat_is_fast = false; |
1396 $sodium_compat_is_fast = false; |
1330 |
1397 |
1331 // Allow for an old version of Sodium_Compat being loaded before the bundled WordPress one. |
1398 // Allow for an old version of Sodium_Compat being loaded before the bundled WordPress one. |
1332 if ( method_exists( 'ParagonIE_Sodium_Compat', 'runtime_speed_test' ) ) { |
1399 if ( method_exists( 'ParagonIE_Sodium_Compat', 'runtime_speed_test' ) ) { |
1333 // Run `ParagonIE_Sodium_Compat::runtime_speed_test()` in optimized integer mode, as that's what WordPress utilises during signing verifications. |
1400 /* |
|
1401 * Run `ParagonIE_Sodium_Compat::runtime_speed_test()` in optimized integer mode, |
|
1402 * as that's what WordPress utilizes during signing verifications. |
|
1403 */ |
1334 // phpcs:disable WordPress.NamingConventions.ValidVariableName |
1404 // phpcs:disable WordPress.NamingConventions.ValidVariableName |
1335 $old_fastMult = ParagonIE_Sodium_Compat::$fastMult; |
1405 $old_fastMult = ParagonIE_Sodium_Compat::$fastMult; |
1336 ParagonIE_Sodium_Compat::$fastMult = true; |
1406 ParagonIE_Sodium_Compat::$fastMult = true; |
1337 $sodium_compat_is_fast = ParagonIE_Sodium_Compat::runtime_speed_test( 100, 10 ); |
1407 $sodium_compat_is_fast = ParagonIE_Sodium_Compat::runtime_speed_test( 100, 10 ); |
1338 ParagonIE_Sodium_Compat::$fastMult = $old_fastMult; |
1408 ParagonIE_Sodium_Compat::$fastMult = $old_fastMult; |
1349 __( 'The authenticity of %s could not be verified as signature verification is unavailable on this system.' ), |
1419 __( 'The authenticity of %s could not be verified as signature verification is unavailable on this system.' ), |
1350 '<span class="code">' . esc_html( $filename_for_errors ) . '</span>' |
1420 '<span class="code">' . esc_html( $filename_for_errors ) . '</span>' |
1351 ), |
1421 ), |
1352 array( |
1422 array( |
1353 'php' => phpversion(), |
1423 'php' => phpversion(), |
1354 // phpcs:ignore PHPCompatibility.Constants.NewConstants.sodium_library_versionFound |
|
1355 'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ), |
1424 'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ), |
1356 'polyfill_is_fast' => false, |
1425 'polyfill_is_fast' => false, |
1357 'max_execution_time' => ini_get( 'max_execution_time' ), |
1426 'max_execution_time' => ini_get( 'max_execution_time' ), |
1358 ) |
1427 ) |
1359 ); |
1428 ); |
1423 'signatures' => $signatures, |
1492 'signatures' => $signatures, |
1424 'hash' => bin2hex( $file_hash ), |
1493 'hash' => bin2hex( $file_hash ), |
1425 'skipped_key' => $skipped_key, |
1494 'skipped_key' => $skipped_key, |
1426 'skipped_sig' => $skipped_signature, |
1495 'skipped_sig' => $skipped_signature, |
1427 'php' => phpversion(), |
1496 'php' => phpversion(), |
1428 // phpcs:ignore PHPCompatibility.Constants.NewConstants.sodium_library_versionFound |
|
1429 'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ), |
1497 'sodium' => defined( 'SODIUM_LIBRARY_VERSION' ) ? SODIUM_LIBRARY_VERSION : ( defined( 'ParagonIE_Sodium_Compat::VERSION_STRING' ) ? ParagonIE_Sodium_Compat::VERSION_STRING : false ), |
1430 ) |
1498 ) |
1431 ); |
1499 ); |
1432 } |
1500 } |
1433 |
1501 |
1596 * disk_free_space() could return false. Assume that any falsey value is an error. |
1664 * disk_free_space() could return false. Assume that any falsey value is an error. |
1597 * A disk that has zero free bytes has bigger problems. |
1665 * A disk that has zero free bytes has bigger problems. |
1598 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. |
1666 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. |
1599 */ |
1667 */ |
1600 if ( wp_doing_cron() ) { |
1668 if ( wp_doing_cron() ) { |
1601 $available_space = @disk_free_space( WP_CONTENT_DIR ); |
1669 $available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false; |
1602 |
1670 |
1603 if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) { |
1671 if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) { |
1604 return new WP_Error( |
1672 return new WP_Error( |
1605 'disk_full_unzip_file', |
1673 'disk_full_unzip_file', |
1606 __( 'Could not copy files. You may have run out of disk space.' ), |
1674 __( 'Could not copy files. You may have run out of disk space.' ), |
1737 * disk_free_space() could return false. Assume that any falsey value is an error. |
1805 * disk_free_space() could return false. Assume that any falsey value is an error. |
1738 * A disk that has zero free bytes has bigger problems. |
1806 * A disk that has zero free bytes has bigger problems. |
1739 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. |
1807 * Require we have enough space to unzip the file and copy its contents, with a 10% buffer. |
1740 */ |
1808 */ |
1741 if ( wp_doing_cron() ) { |
1809 if ( wp_doing_cron() ) { |
1742 $available_space = @disk_free_space( WP_CONTENT_DIR ); |
1810 $available_space = function_exists( 'disk_free_space' ) ? @disk_free_space( WP_CONTENT_DIR ) : false; |
1743 |
1811 |
1744 if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) { |
1812 if ( $available_space && ( $uncompressed_size * 2.1 ) > $available_space ) { |
1745 return new WP_Error( |
1813 return new WP_Error( |
1746 'disk_full_unzip_file', |
1814 'disk_full_unzip_file', |
1747 __( 'Could not copy files. You may have run out of disk space.' ), |
1815 __( 'Could not copy files. You may have run out of disk space.' ), |
2076 * Plugins may override this form by returning true|false via the {@see 'request_filesystem_credentials'} filter. |
2144 * Plugins may override this form by returning true|false via the {@see 'request_filesystem_credentials'} filter. |
2077 * |
2145 * |
2078 * @since 2.5.0 |
2146 * @since 2.5.0 |
2079 * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string. |
2147 * @since 4.6.0 The `$context` parameter default changed from `false` to an empty string. |
2080 * |
2148 * |
2081 * @global string $pagenow |
2149 * @global string $pagenow The filename of the current screen. |
2082 * |
2150 * |
2083 * @param string $form_post The URL to post the form to. |
2151 * @param string $form_post The URL to post the form to. |
2084 * @param string $type Optional. Chosen type of filesystem. Default empty. |
2152 * @param string $type Optional. Chosen type of filesystem. Default empty. |
2085 * @param bool|WP_Error $error Optional. Whether the current request has failed |
2153 * @param bool|WP_Error $error Optional. Whether the current request has failed |
2086 * to connect, or an error object. Default false. |
2154 * to connect, or an error object. Default false. |