Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: unzip_file_use_ziparchive

To save our bandwidth, we show only a snippet of code around each occurence of the hook. View complete file in SVN (without highlighting).

Understanding Source Code

The best way to understand what a hook does is to look at where it occurs in the source code.

Remember, this hook may occur in more than one file. Moreover, the hook's context may change from version to version.

Source View

This hook occurs 2 times in this file.

Line Code
1564  * are not valid ZIPs, so those will also return false.
1565  *
1566  * @since 6.4.4
1567  *
1568  * @param string $file Full path to the ZIP file.
1569  * @return bool Whether the file is a valid ZIP file.
1570  */
1571 function wp_zip_file_is_valid( $file ) {
1572      /** This filter is documented in wp-admin/includes/file.php */
1573      if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
1574           $archive          = new ZipArchive();
1575           $archive_is_valid = $archive->open( $file, ZipArchive::CHECKCONS );
1576           if ( true === $archive_is_valid ) {
1577                $archive->close();
1578                return true;
1579           }
1580      }
1581
1582      // Fall through to PclZip if ZipArchive is not available, or encountered an error opening the file.
 
Line Code
1641      }
1642
1643      /**
1644       * Filters whether to use ZipArchive to unzip archives.
1645       *
1646       * @since 3.0.0
1647       *
1648       * @param bool $ziparchive Whether to use ZipArchive. Default true.
1649       */
1650      if ( class_exists( 'ZipArchive', false ) && apply_filters( 'unzip_file_use_ziparchive', true ) ) {
1651           $result = _unzip_file_ziparchive( $file, $to, $needed_dirs );
1652           if ( true === $result ) {
1653                return $result;
1654           } elseif ( is_wp_error( $result ) ) {
1655                if ( 'incompatible_archive' !== $result->get_error_code() ) {
1656                     return $result;
1657                }
1658           }
1659      }