// Don't extract invalid files:
if ( 0 !==
validate_file( $info['name'
] ) ) { continue;
} $contents =
$z->
getFromIndex( $i );
if ( false ===
$contents ) { return new WP_Error( 'extract_failed_ziparchive',
__( 'Could not extract file from archive.'
),
$info['name'
] );
} if ( !
$wp_filesystem->
put_contents( $to .
$info['name'
],
$contents, FS_CHMOD_FILE
) ) { return new WP_Error( 'copy_failed_ziparchive',
__( 'Could not copy file.'
),
$info['name'
] );
} } $z->
close();
return true;
}/**
* Attempts to unzip an archive using the PclZip library.
*
* This function should not be called directly, use `unzip_file()` instead.
*
* Assumes that WP_Filesystem() has already been called and set up.
*
* @since 3.0.0
* @access private
*
* @see unzip_file()
*
* @global WP_Filesystem_Base $wp_filesystem WordPress filesystem subclass.
*
* @param string $file Full path and filename of ZIP archive.
* @param string $to Full path on the filesystem to extract archive to.
* @param string[] $needed_dirs A partial list of required folders needed to be created.
* @return true|WP_Error True on success, WP_Error on failure.
*/