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?

  • 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. 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. Feb 25, 2017 at 16:26

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.)

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.