Created
March 20, 2018 06:44
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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');