How to make sure changes to a Wordpress plugin won't be lost on plugin update?

后端 未结 2 989
清歌不尽
清歌不尽 2021-02-10 18:12

I\'m pretty sure I\'ve read somewhere that you can actually move the main plugin *.php file to somewhere else (I assume under your theme directory) to have it safe in case you m

相关标签:
2条回答
  • 2021-02-10 18:34

    Are you talking about running parts of a modified 3rd party plugin, and an updated version, at the same time?

    That's not going to be possible. There is no magical method of "preserve my changes and transfer them into the new version automatically". The way to go here is doing a diff between the edited version and the update, and integrating the changes in the actual source files.

    The bottom line is, if you manually edit a third party plugin, you're in for manual review (and possibly rework) once an update takes place. That's why it's usually not a good idea to extensively modify third party plugins.

    0 讨论(0)
  • 2021-02-10 18:38

    With themes, Wordpress has a concept of "child themes" which allows exactly that: to keep changes separate from main theme, in case it changes.

    I haven't yet found a way to do this with plugins.

    I'm using a few tactics myself:

    • I bump plugin version to a very high number like 99.9. This way Wordpress won't ever update the plugin.
    • Store my plugins in version control (i use git, but it doesnt matter), this allows you to update the plugin, run the 'diff' tool and see what changes happend. If you don't like you just revert like it would be a bad code you've written. But this approach requires a bit of skill.
    0 讨论(0)
提交回复
热议问题