Validate::file_valid_type( object $field )
Description #
Check file array contain allowed mime types.
Parameters #
- $fieldobject (Required) Instance of @see
AP_Field
object.
Source #
File: lib/class-validate.php
private static function file_valid_type( $field ) { $args = $field->get( 'upload_options' ); $value = $field->value(); $have_error = true; $is_numeric = wp_is_numeric_array( $value ); if ( true === $args['multiple'] && $is_numeric ) { foreach ( $value as $key => $file ) { $actual_mime = wp_check_filetype_and_ext( $file['tmp_name'], $file['name'] ); if ( false !== $actual_mime && in_array( $actual_mime['type'], $args['allowed_mimes'], true ) ) { $have_error = false; } } } elseif ( ! $is_numeric ) { $actual_mime = wp_check_filetype_and_ext( $value['tmp_name'], $value['name'] ); if ( false !== $actual_mime && in_array( $actual_mime['type'], $args['allowed_mimes'], true ) ) { $have_error = false; } } return $have_error; }
Expand full source code Collapse full source code View on GitHub: lib/class-validate.php:678
Add your comment