Validate::sanitize_upload( null|array $value = null, array $upload_options = array() )
Description #
Sanitize upload field.
Parameters #
- $valuenull | array (Optional) Array of uploads. Default value: null
- $upload_optionsarray (Optional) Upload options. Default value: array()
Source #
File: lib/class-validate.php
public static function sanitize_upload( $value = null, $upload_options = array() ) {
if ( ! empty( $value ) && is_array( $value ) && ! empty( $upload_options ) ) {
if ( true === $upload_options['multiple'] && wp_is_numeric_array( $value ) ) {
$value = array_slice( $value, 0, $upload_options['max_files'] );
foreach ( $value as $key => $file ) {
$value[ $key ]['error'] = (int) $file['error'];
$value[ $key ]['name'] = sanitize_file_name( $file['name'] );
}
return $value;
} elseif ( false === $upload_options['multiple'] && ! wp_is_numeric_array( $value ) ) {
$value['error'] = (int) $value['error'];
$value['name'] = sanitize_file_name( $value['name'] );
return $value;
}
}
}
Expand full source code Collapse full source code View on GitHub: lib/class-validate.php:317
Add your comment