What is the best way to modify a plugin? I frequently want to make small changes to one or two functions within a large plugin. This is easily done, but I have to use comments to mark my changes and modify the plugin again after an update. Ideally I'd like to leave the plugin alone and make my changes elsewhere, much like we do with themes and child themes. Can I make a plugin that requires the parent plugin and will override it?
IMHO, the best approach is either to fork the Plugin to maintain your changes, or else submit patches to the Plugin developer, to have your changes made a part of the original Plugin.
Creating a "Child Plugin" really isn't easy. The "Child Theme" concept really applies to the template files that get used, moreso than the Theme functions (and in fact, the
functions.php file from both Parent and Child get loaded, which does cause problems for improperly coded
functions.php files in either the Child or Parent Theme).
The "right" way obviously depends on the plugin. Some plugins are easier to edit than others, but most plugins can actually be modified by other plugins.
For example, if a plugin has a function hooked into WordPress with an action, then it's a simple matter for you to make another plugin that unhooks that function with remove_action, and then adds your replacement function in instead. This sort of method will let you replace individual functions in plugins with your own modified versions, without modifying the original plugin.
Same concept works with filters, obviously.
The best way would be to just clone it and change the Plugin Name in the header and change the directory name. This way you could also have the original installed but not activated so you will still get alerts when updates are released.
<?php /* Plugin Name: Name Of The Plugin Plugin URI: http://URI_Of_Page_Describing_Plugin_and_Updates Description: A brief description of the Plugin. Version: The Plugin's Version Number, e.g.: 1.0 Author: Name Of The Plugin Author Author URI: http://URI_Of_The_Plugin_Author License: A "Slug" license name e.g. GPL2 */ ?>
This is relatively easy if the plugin is under Git source control due to Git's distributed nature, but many WordPress plugins (and all of those in the official repository) are in Subversion. I use vendor branches and svn_load_dirs.php if I really need to modify a plugin, but this requires a reasonably high comfort level with Subversion.
If the plugin exposes no repository, I'd recommend turning it into a Git repository yourself and manually applying new versions.
In the end, version control systems are the only sane way to reapply changes to new upstream versions.
I agree with Annika Backstrom's answer, but I'd like to share my preferred solution.
Since most plugins are under svn, I use a tool called git-svn to make a git mirror.
Then, I just make a branch and commit my changes there.
When the plugin is updated upstream, I just pull from the svn repo and merge into my custom branch.