× {{alert.msg}} Never ask again
Get notified about new tutorials RECEIVE NEW TUTORIALS

Modifying Standard WordPress Plugins

David Brumbaugh
Aug 15, 2016
<p>Sometimes a WordPress plugin from the repository does not do quite what you need it todo.  So, you change it and it works!</p> <p>Then, the plugin author makes a change to the plugin.  If you update it from the repository,  all you changes will be gone!</p> <p>If you avoid updates but you  have a security plugin that scans for changes to your code, you may get a "false positive" seurity alert!</p> <p>How do you prevent these issues?</p> <p>Fortunatetly , it's quite easy.  A plugin is uniqely identifyed in the comment block in the main plugin file with the Name field.  If you change the name, WordPress sees it as a different plugin.</p> <p>Suppose the original plugin file has this comment block:</p> <p><code>/**<br>  * Plugin Name: Original Plugin Name<br>  * Plugin URI: http://example.com/plugin-uri<br>  * Author: Plugin Author<br>  * Author URI: <span style="background-color:rgb(247, 247, 249); color:rgb(221, 17, 68)">http://example.com/their-blog</span><br>  * Description: Does something awesome.<br>  * Version: 1.0.1<br>  * License: GPLv2 or later<br>  */</code></p> <p> </p> <p><span style="color:rgb(95, 99, 102)">Deactivate the plugin.  And make a back up of your WordPress database (bacause that's just good practice.)  Then, simply change the name, and other fields like so:</span></p> <p><span style="color:rgb(95, 99, 102)"> </span><code>/**<br>  * Plugin Name: New Plugin Name<br>  * Plugin URI: http://example.com/plugin-uri<br>  * Author: Plugin Author (modifed by Your Name)<br>  * Author URI: <span style="background-color:rgb(247, 247, 249); color:rgb(221, 17, 68)">http://example.com/their-blog</span></code><br> <code> * Description: Does something awesome - with modifications described here.<br>  * Version: 1.0.1-delta<br>  * License: GPLv2 or later<br>  */</code></p> <p><span style="color:rgb(95, 99, 102)">At this point you have a different plugin with your changes that will not be overwritten by plugin updates.  Activate the "new" plugin.  You're done and safe.</span></p> <p><span style="color:rgb(95, 99, 102)">If your changes are actually a bug fix (as opposed to a custom feature you need), it's good manners to notify the plugin author.  If the plugin is in a github repo, you might want to include a pull request.</span></p>

Get New Tutorials Delivered to Your Inbox

New tutorials will be sent to your Inbox once a week.

comments powered by Disqus