Changeset 28450
- Timestamp:
- 05/16/2014 04:10:00 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-admin/includes/file.php
r28417 r28450 225 225 // You may define your own function and pass the name in $overrides['upload_error_handler'] 226 226 $upload_error_handler = 'wp_handle_upload_error'; 227 if ( isset( $overrides['upload_error_handler'] ) ) { 228 $upload_error_handler = $overrides['upload_error_handler']; 229 } 227 230 228 231 // You may have had one or more 'wp_handle_upload_prefilter' functions error out the file. Handle that gracefully. … … 230 233 return $upload_error_handler( $file, $file['error'] ); 231 234 235 // Install user overrides. Did we mention that this voids your warranty? 236 232 237 // You may define your own function and pass the name in $overrides['unique_filename_callback'] 233 238 $unique_filename_callback = null; 239 if ( isset( $overrides['unique_filename_callback'] ) ) { 240 $unique_filename_callback = $overrides['unique_filename_callback']; 241 } 234 242 235 243 // $_POST['action'] must be set and its value must equal $overrides['action'] or this: 236 244 $action = 'wp_handle_upload'; 245 if ( isset( $overrides['action'] ) ) { 246 $action = $overrides['action']; 247 } 237 248 238 249 // Courtesy of php.net, the strings that describe the error indicated in $_FILES[{form field}]['error']. … … 247 258 __( "File upload stopped by extension." )); 248 259 260 // this may not have orignially been intended to be overrideable, but historically has been 261 if ( isset( $overrides['upload_error_strings'] ) ) { 262 $upload_error_strings = $overrides['upload_error_strings']; 263 } 264 249 265 // All tests are on by default. Most can be turned off by $overrides[{test_name}] = false; 250 $test_form = true;251 $test_size = true;252 $test_upload = true;266 $test_form = isset( $overrides['test_form'] ) ? $overrides['test_form'] : true; 267 $test_size = isset( $overrides['test_size'] ) ? $overrides['test_size'] : true; 268 $test_upload = isset( $overrides['test_upload'] ) ? $overrides['test_upload'] : true; 253 269 254 270 // If you override this, you must provide $ext and $type!!!! 255 $test_type = true; 256 $mimes = false; 257 258 // Install user overrides. Did we mention that this voids your warranty? 259 if ( is_array( $overrides ) ) 260 extract( $overrides, EXTR_OVERWRITE ); 271 $test_type = isset( $overrides['test_type'] ) ? $overrides['test_type'] : true; 272 $mimes = isset( $overrides['mimes'] ) ? $overrides['mimes'] : false; 261 273 262 274 // A correct form post will pass this test. 263 if ( $test_form && ( !isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) )264 return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ));265 275 if ( $test_form && ( ! isset( $_POST['action'] ) || ($_POST['action'] != $action ) ) ) { 276 return call_user_func( $upload_error_handler, $file, __( 'Invalid form submission.' ) ); 277 } 266 278 // A successful upload will pass this test. It makes no sense to override this one. 267 279 if ( isset( $file['error'] ) && $file['error'] > 0 ) {
Note: See TracChangeset
for help on using the changeset viewer.