Skip to content

Instantly share code, notes, and snippets.

@sebastienserre
Created March 20, 2018 06:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sebastienserre/80feac5edec0e358dd3232aeab1159e3 to your computer and use it in GitHub Desktop.
Save sebastienserre/80feac5edec0e358dd3232aeab1159e3 to your computer and use it in GitHub Desktop.
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

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