I have a file in the root folder of my wordpress installation (myfolder, wp-content, wp-config, and all other).

I want unzip a test.zip archive in my myfolder folder in root directory.

I try this function on my theme functions.php :

add_action( 'test_unzip', 'unzip_folder' );
function unzip_folder() {
    $destination = '../myfolder/';
    $destination_path = $destination['path'];
    unzip_file( $destination_path.'/test.zip', $destination_path);

I add the action in cron to do it every 3 hours, and also to try my code. It's not work and I can't find where I failed :)

  • I recommend checking the return value of unzip_file() to see what that tells you about why it's not working. Also, check the log file(s) to see if there is anything relevant to the problem you are experiencing. One other thing - with the destination path setting, it's trying to extract the ZIP contents at one level above the theme folder - <doc root>->wp-content->themes - which is not the root folder as you stated.
    – ScottM
    May 6 at 13:21


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.