更新时间:2023-12-05 23:50:52
我不建议更改核心。然而,你有点腌制。
您可以:
最后,您仍遇到同样的问题 - 未来兼容性。
$ b
所以,尽管我不想这么说,但我会直接更新插件。至少当你升级时,你会很快知道你的改变缺失了。此外,插件更新可能会包含您的更改。
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 change within the Contact Form 7 plugin. The function is called function wpcf7_ajax_json_echo() and is located in:
wp-content > plugins > contact-form-7 > includes > controller.php
Of course I could just change the code right in that file and be done, but then I'm out of luck when I want to update that plugin as my modifications will probably get written over.
I know I should be making this happen via my functions.php file, but I'm not sure how to go about achieving this. Also, that particular function is 100+ lines of code and I'm guessing I don't want to overwrite that whole function, because there is a good chance the author of the plugin may choose to update something in that function in the future.
Does anyone know the cleanest way for me to modify a few lines within that function via my functions.php file?
Thank you!
I do not recommend changing the core. However, you are in a bit of a pickle.
You can:
In the end, you still run into the same problem - future compatibility.
Either:
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.