Skip file when plugin updated

Is there a way to keep a constant file in my plugin directory so that it doesn’t get updated? I’m a developer and would like to have a file for users to add custom functions to in my plugin. When they update the plugin, that file should not be updated if it already exists. Is this possible?

1 Answer
1

On you future code files in your plugin, do not include the ‘option’ file in the repository. Since it is not included in the repository zip, the file (if it exists) will not be overwritten on the user’s system.

You may need some code in your plugin to create the file on activation with some default values, if it does not exist. That will ensure that the file will be there for the end user.

Although I am not a fan of letting users create files in the plugin area. It would be better, I think, to create an options page in your plugin that would contain the values (constants?) needed by your plugin. And your plugin would probably need to create those constants if they do not exist. (Remember that constants are ‘constant’, and cannot be redefined.)

Leave a Comment