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!
Copy them into a directory with your theme named /bws-templates. Example: To override the single gallery template, please copy /wp-content/plugins/gallery-plugin/templates/gallery-single-template. php to wp-content/themes/your-theme/bws-templates/gallery-single-template.
Or, you can override an entire function defined in parent theme if it is assigned as a callback to a hook. You remove this filter hook in the child theme functions. php as: add_action( 'init', function() { remove_filter( 'the_content', 'append_thank_you' ); } );
For example, if you wanted to override a plugin file called plugin-name. php in a child theme, you would create a file called plugin-name. php in the child theme's directory and copy the contents of the original plugin file into it. The child theme's plugin file would then be used instead of the original plugin file.
To implement this, simply write your original class and in braces, define your custom class with complete path. Now when your application runs, restAuthenticationFilter class will be overriden by CustomRestAuthenticationFilter. So this was all about overriding a grails plugin class with a custom one.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With