Menu Adam R Brown

WP hooks navigation: Home/browseActions indexFilters index

Source View: pre_unzip_file

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
1783       *
1784       * @since 6.4.0
1785       *
1786       * @param null|true|WP_Error $result         The result of the override. True on success, otherwise WP Error. Default null.
1787       * @param string             $file           Full path and filename of ZIP archive.
1788       * @param string             $to             Full path on the filesystem to extract archive to.
1789       * @param string[]           $needed_dirs    A full list of required folders that need to be created.
1790       * @param float              $required_space The space required to unzip the file and copy its contents, with a 10% buffer.
1791       */
1792      $pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
1793
1794      if ( null !== $pre ) {
1795           // Ensure the ZIP file archive has been closed.
1796           $z->close();
1797
1798           return $pre;
1799      }
1800
1801      for ( $i = 0; $i < $z->numFiles; $i++ ) {
 
Line Code
1954      // Create those directories if need be:
1955      foreach ( $needed_dirs as $_dir ) {
1956           // Only check to see if the dir exists upon creation failure. Less I/O this way.
1957           if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
1958                return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), $_dir );
1959           }
1960      }
1961
1962      /** This filter is documented in src/wp-admin/includes/file.php */
1963      $pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
1964
1965      if ( null !== $pre ) {
1966           return $pre;
1967      }
1968
1969      // Extract the files from the zip.
1970      foreach ( $archive_files as $file ) {
1971           if ( $file['folder'] ) {
1972                continue;