I have been question for a while exactly what the best practice is perfect for modifying a wordpress plugin produced with a WordPress user?

For instance you will find a few lines of code I wish to change inside the Contact Page 7 wordpress plugin. The function is known as function wpcf7_ajax_json_echo() and it is situated in:

wp-content > plugins > contact-form-7 > includes > controller.php

Obviously I possibly could just alter the code right for the reason that file and become done, however I am at a complete loss when I wish to update that wordpress plugin as my modifications will most likely get written over.

I understand I ought to make this happen via my functions.php file, but I am unsure how to pull off accomplishing this. Also, that specific function is 100+ lines of code and I am speculating I'd rather not overwrite that whole function, because there's a high probability the writer from the wordpress plugin might want to update something for the reason that function later on.

Does anybody be aware of cleanest way that i can modify a couple of lines within that function via my functions.php file?


I don't recommend altering the core. However, you're in a little of the pickle.

You are able to:

  • Update the function code directly within the wordpress plugin
  • Copy the present function code in the wordpress plugin and override it in functions.php

Ultimately, you'll still encounter exactly the same problem - future compatibility.


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

So, around I'd rather not say it, I'd update the wordpress plugin directly. A minimum of when you upgrade, you know pretty quick that the change is missing. In addition, it is possible the wordpress plugin updates includes your change.

You could utilize SVN should you desired to maintain forwards compatibility (as well as your host has SVN available), although having the ability to keep the own changes.

Each wordpress plugin that's around the Wordpress plugin Directory needs to come with an SVN repo (that's the way the Directory knows if you will find updates). Here's the CF7 repo.

Checkout a corner for your /plug ins/ directory in the folder like /custom-contact-form-7/. Affect the wordpress-contact-form-7.php file allow it a distinctive title, making the alterations you need to make to personalize it.

To obtain new updates you can easily svn up to obtain them, and they're going to merge together with your changes. Though, you might want to cleanup merge conflicts sometimes.

Version Control with Subversion is where everybody begins to understand SVN, if you want it.