0

I've got a premium plugin and setting up a custom solution to serve updates. However I've got a question regarding how contents are managed.

Wordpress just remove old plugin folder and install the new one. But what about cached files?

Assuming plugin has got two folders full of files and I must keep them: how should I proceed? Is there a way to tell Wordpress to ignore those elements?

1 Answer 1

1

Ok, after having digged into WP source for a couple of hours, found a workaround. Simply tell wordpress to NOT remove old files. Now files are 100% overwritten and cached files maintained.

Code is really simple

add_filter('upgrader_package_options', 'avoid_deletion', 999);
function avoid_deletion($options) {
    if($options['hook_extra']['plugin'] == 'my-plugin/my-plugin.php') {
        $options["clear_destination"] = false;
        $options["abort_if_destination_exists"] = false;
    }

    return $options;
}

I will write lately an optional method to remove single folders/files just in case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.