How to Extend a Plugin in WordPress with a Filter HookAndrew
Extending a plugin in WordPress may seem foreign if you have never done so; however, it is actually a simple task for most filter hooks. What is a filter hook? A filter hook is just the technical way of saying, “Here is some content we will display to the user or save to the database.” The most important thing to consider when writing your own filter hook is where you add this code. If you add this code in the wrong place, an update to WordPress or the plugin you are extending may overwrite your edit. You should strive to keep your website as up-to-date as possible, and having an update overwrite your changes generally discourages updates. Three safe ways to extend a plugin in WordPress with a filter hook include using another plugin such as Code Snippets, by creating a custom plugin, or by creating a child theme. I recommend going the first route which is detailed below.
Using a Filter Hook Plugin
The easiest way to extend a plugin is by using another plugin such as Code Snippets. This is the easiest method because it doesn’t require you to modify any code on the back end, use file transfer, or code editors. Code Snippets provides a simple GUI interface in your WordPress admin for managing action hooks, filter hooks, and custom shortcodes.
Using the player social icons filter we introduced in the Version 3.16 update as an example, here is how you would add a Steam icon to the existing set using Code Snippets:
1. Download and activate Code Snippets.
2. Paste the code into the box as pictured in the screenshot below.
3. Click save.
With this complete, players will now also see a steam icon in their player profile and a future WordPress or Tournamatch update shouldn’t affect your change.