What do we do when we need to add a new feature to a WordPress site and we find a plugin that does almost exactly everything we need of it? What if we know a little code tweak will turn that plugin into the exact super plugin we need?
- We can ask the plugin developer to add the feature.
- We can pay someone to edit the plugin for us.
- We can edit the plugin and add the feature ourselves.
Either way, the plugin needs to be edited.
When we customize a plugin we need to safeguard our code edits from being overwritten when the plugin’s original developer releases an update.
The best way to protect our plugin customizations is to rename the plugin.
How do we rename a plugin?
We rename the plugin folder and edit the main plugin file. The main plugin file will be a PHP file and will contain the line “Plugin Name:” near its top.
Look at the screenshot of the file for the plugin Hello Dolly, hello.php.
Look where the above image says “Plugin Name: Hello Dolly“. Change that name, Hello Dolly, to Hello Polly and WordPress suddenly sees a new plugin called Hello Polly.
When a plugin is renamed its files can be edited and the new plugin activated.
Never have both the old and new plugin active simultaneously in the same site.
When you want to activate both the old and new plugins in the same site, rename the functions and classes used by the new plugin.
Keep the old plugin installed somewhere so you can be alerted to updates. Those updates might add the same feature you’ve added to the plugin or may be for bug fixes and security fixes that you need to be aware of.