I want to allow users to upload custom files to specific plugin directory. The problem is, obviously, that WP removes everything upon plugin version update.
I think that the upgrader_pre_install
and upgrader_post_install
hooks may be useful, but unfortunately so far I wasn’t able to find any info to help me.
In your opinion, can these hooks be used to retain a directory and if so, how?
Should I simply copy the directory elsewhere, like the uploads folder, and copy it back with upgrader_post_install
?
What would be the best practice?
Thanks
To answer my own question here is what I’ve found for the sake of keeping questions answered. What this does is copying the important directory before upgrade and recovering it after upgrade:
The plugin directory cannot be used for uploads:
Use the uploads directory for uploads. It is the only safe place.
See also: How to prevent specific plugin files or subfolders from appearing under âplugin filesâ listing with related problem â and the same solution.