wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren
wp_zip_file_is_valid › WordPress Function
Seit6.4.4
Veraltetn/v
› wp_zip_file_is_valid ( $file )
| Parameter: |
|
| Gibt zurück: |
|
| Definiert in: |
|
| Codex: |
Determines whether the given file is a valid ZIP file.
This function does not test to ensure that a file exists. Non-existent files are not valid ZIPs, so those will also return false.Ähnliche Funktionen: file_is_valid_image, wp_is_file_mod_allowed, _unzip_file_pclzip, _unzip_file_ziparchive, wp_opcache_invalidate
Quellcode
function wp_zip_file_is_valid( $file ) {
/** This filter is documented in wp-admin/includes/file.php */
if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
$archive = new ZipArchive();
$archive_is_valid = $archive->open( $file, ZipArchive::CHECKCONS );
if ( true === $archive_is_valid ) {
$archive->close();
return true;
}
}
// Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
require_once ABSPATH . 'wp-admin/includes/class-pclzip.php';
$archive = new PclZip( $file );
$archive_is_valid = is_array( $archive->properties() );
return $archive_is_valid;
}