What is the correct way to edit a plugin?

Hi Team!

What is the CORRECT was to edit a plugin? For example, I'd like to change "X" in plugin A to become "Y". However after successfully making the change, should an update come up for plugin A, my changes to "X" are overwritten.

How would I be able to keep my custom changes, without having to re-code them each time an update comes out?

Thanks for your assistance!

  • aecnu

    Greetings krystyna_gordon,

    Thank you for the great question and you are indeed spot on correct that after successfully making the change, should an update come up for plugin A, my changes to "X" are overwritten.

    Indeed they will need to be recoded or saved on your PC over writing updated files or not update.

    Unfortunately those are the only options available.

    Thank you for being a WPMU DEV Community Member!

    Cheers, Joe

  • aecnu

    Greetings krystyna_gordon,

    I agree with you of course and it would certainly be a pretty cool feature.

    As you mentioned Joomla has this feature in which I would imagine that it is built into the Joomla core and indeed you may want to petition WordPress to add it to their core.

    Otherwise we are indeed stuck doing it the tried and true old fashioned way of updating via FTP.

    On the subject of FTP, one could simply permission the custom files 444 read only and then when FTP'ing the update it will not over write the read only file therefore preserving the custom files.

    And your thoughts regarding this idea?

    Cheers, Joe

  • pianoman

    When dealing with upgrades, your custom code may break regardless of platform (WordPress, Joomla, etc).

    There are a couple of things that can make life a little easier in WordPress. While the question was directed at plugins, theme functionality can often be extended via a child theme. This at least isolates your code from being overwritten in an upgrade even if the upgrade breaks your modifications. See http://codex.wordpress.org/Child_Themes

    For plugins, if you are adding some some functionality that is not tightly woven with the logic of another plugin consider building your own plugin. You could call the plugin something like "MyFunctionality" and place everything you can in it to reduce the impact of upgrades to other plugins. To often we tend to modify plugins without asking whether we could place the functionality in a plugin of our own.

    Another aspect on the plugin front is plugin priority. This is not discussed very often but it is possible to change your custom plugin's priority so it loads last and overrules all previous plugins. Do a search on plugin priority or how to change plugin load order and you will find a number of articles that address coding techniques for doing this.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.