unzip_file example



        // We need a working directory - strip off any .tmp or .zip suffixes.         $working_dir = $upgrade_folder . basename( basename( $package, '.tmp' ), '.zip' );

        // Clean up working directory.         if ( $wp_filesystem->is_dir( $working_dir ) ) {
            $wp_filesystem->delete( $working_dir, true );
        }

        // Unzip package to working directory.         $result = unzip_file( $package$working_dir );

        // Once extracted, delete the package if required.         if ( $delete_package ) {
            unlink( $package );
        }

        if ( is_wp_error( $result ) ) {
            $wp_filesystem->delete( $working_dir, true );
            if ( 'incompatible_archive' === $result->get_error_code() ) {
                return new WP_Error( 'incompatible_archive', $this->strings['incompatible_archive']$result->get_error_data() );
            }
            
Home | Imprint | This part of the site doesn't use cookies.