Alert: This function’s access is marked private. This means it is not intended for use by plugin or theme developers, only in other core functions. It is listed here for completeness.
LLMS_Admin_Import::validate_upload( array $file )
Validate the uploaded file
Parameters Parameters
- $file
-
(array) (Required) array of file data.
Return Return
(WP_Error|true)
Source Source
File: includes/admin/class.llms.admin.import.php
315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 | private function validate_upload( $file ) { if ( ! empty ( $file [ 'error' ] ) ) { switch ( $file [ 'error' ] ) { case UPLOAD_ERR_INI_SIZE: $msg = __( 'The uploaded file exceeds the upload_max_filesize directive in php.ini.' , 'lifterlms' ); break ; case UPLOAD_ERR_FORM_SIZE: $msg = __( 'The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.' , 'lifterlms' ); break ; case UPLOAD_ERR_PARTIAL: $msg = __( 'The uploaded file was only partially uploaded.' , 'lifterlms' ); break ; case UPLOAD_ERR_NO_FILE: $msg = __( 'No file was uploaded.' , 'lifterlms' ); break ; case UPLOAD_ERR_NO_TMP_DIR: $msg = __( 'Missing a temporary folder.' , 'lifterlms' ); break ; case UPLOAD_ERR_CANT_WRITE: $msg = __( 'Failed to write file to disk.' , 'lifterlms' ); break ; case UPLOAD_ERR_EXTENSION: $msg = __( 'File upload stopped by extension.' , 'lifterlms' ); break ; default : $msg = __( 'Unknown upload error.' , 'lifterlms' ); } } else { $info = pathinfo ( $file [ 'name' ] ); if ( 'json' !== strtolower ( $info [ 'extension' ] ) ) { $msg = __( 'Only valid JSON files can be imported.' , 'lifterlms' ); } } if ( ! empty ( $msg ) ) { return new WP_Error( 'llms_import_file_error' , $msg ); } return true; } |
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
3.35.0 | Fix undefined variable error. |
3.3.0 | Introduced. |