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