Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
This Gist unzip file before import by the WordPress Plugin WP ALL Import
<?php
/**
* Unzip photo before import by WP ALL Import
*/
function thfo_extract_photo(){
$path = wp_get_upload_dir();
$file = $path['basedir'] . '/wpallimport/files/export.ZIP';
$real_path = $path['basedir'] . '/wpallimport/files/';
$zip = new ZipArchive();
$res = $zip->open($file);
if ($res === TRUE ){
$zip->extractTo( $real_path );
$zip->close();
}
}
add_action('pmxi_before_xml_import', thfo_extract_photo');
@mbissett
Copy link

mbissett commented Mar 21, 2018

Hey Sebastien,

Thanks for the gist! (I found it through the feedback you sent me)

I noticed that there's a small typo in the code, there's a single quote missing when referencing the function name:

add_action('pmxi_before_xml_import', thfo_extract_photo');

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment