updates - Skip file when plugin updated

admin2025-06-03  4

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?

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?

Share Improve this question asked Feb 25, 2017 at 10:53 Richard WebsterRichard Webster 1716 bronze badges 2
  • It's probably possible, but why not just create another plugin - call it an "extension" - that they can use for the same purpose, and is basically a blank plugin that never gets updated. – Nathan Johnson Commented Feb 25, 2017 at 14:24
  • That's an option mate, one that I thought of, but would ideally like to keep it self-contained for user experience, if it's possible. – Richard Webster Commented Feb 25, 2017 at 16:26
Add a comment  | 

1 Answer 1

Reset to default 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.)

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1748925931a314876.html

最新回复(0)