YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.
MIT License
2.21k stars 403 forks source link

Exclude repo file when updating my plugin #550

Open nebestudio opened 8 months ago

nebestudio commented 8 months ago

Hello,

is there a way when updating a plugin with the repo content on github to exclude one settings file? It should be not synchronised, neither deleted.

When having this settings file (settings.php) in my plugin and update the plugin, it gets deleted every time, although I have .gitattributes file in my github repo with this content "settings.php export-ignore".

Thanks in advance!

YahnisElsts commented 8 months ago

It's been a while since I've looked at the relevant part of WordPress core, but I think that the WP plugin updater deletes the entire directory of the old version before installing a new version. So you can't preserve a file in the plugin directory even if the update doesn't include a new version of that file. It will get deleted anyway.

If you really have to keep a specific file unchanged, you might have to write a custom plugin update installer. PUC doesn't handle that part, it just hands the update to WordPress core.