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
1765       *
1766       * @since 6.4.0
1767       *
1768       * @param null|true|WP_Error $result         The result of the override. True on success, otherwise WP Error. Default null.
1769       * @param string             $file           Full path and filename of ZIP archive.
1770       * @param string             $to             Full path on the filesystem to extract archive to.
1771       * @param string[]           $needed_dirs    A full list of required folders that need to be created.
1772       * @param float              $required_space The space required to unzip the file and copy its contents, with a 10% buffer.
1773       */
1774      $pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
1775
1776      if ( null !== $pre ) {
1777           // Ensure the ZIP file archive has been closed.
1778           $z->close();
1779
1780           return $pre;
1781      }
1782
1783      for ( $i = 0; $i < $z->numFiles; $i++ ) {
 
Line Code
1936      // Create those directories if need be:
1937      foreach ( $needed_dirs as $_dir ) {
1938           // Only check to see if the dir exists upon creation failure. Less I/O this way.
1939           if ( ! $wp_filesystem->mkdir( $_dir, FS_CHMOD_DIR ) && ! $wp_filesystem->is_dir( $_dir ) ) {
1940                return new WP_Error( 'mkdir_failed_pclzip', __( 'Could not create directory.' ), $_dir );
1941           }
1942      }
1943
1944      /** This filter is documented in src/wp-admin/includes/file.php */
1945      $pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
1946
1947      if ( null !== $pre ) {
1948           return $pre;
1949      }
1950
1951      // Extract the files from the zip.
1952      foreach ( $archive_files as $file ) {
1953           if ( $file['folder'] ) {
1954                continue;