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