WordPress - Overriding a function in a plugin

后端 未结 3 808
醉酒成梦
醉酒成梦 2021-02-02 17:55

I\'ve been wonder for some time what the best practice is for modifying a plugin created by a WordPress user?

For example there are a couple lines of code I want to chan

3条回答
  •  暗喜
    暗喜 (楼主)
    2021-02-02 18:36

    I do not recommend changing the core. However, you are in a bit of a pickle.

    You can:

    • Update the function code directly in the plugin
    • Copy the current function code from the plugin and override it in functions.php

    In the end, you still run into the same problem - future compatibility.

    Either:

    • The update will overwrite your plugin changes.
    • Your function overwrites the plugin changes.

    So, as much as I don't want to say it, I'd update the plugin directly. At least then when you upgrade, you'll know pretty quick that your change is missing. Furthermore, it's possible the plugin updates will include your change.

提交回复
热议问题