Mods in WordPatch represent the process of applying modifications to your installation. Each mod consists of one or more patch files (in a moment, we’ll get into what these are and how they work) that are automatically applied by WordPatch whenever there are updates. You can use mods to do a variety of things, from hotfixing small issues to completely changing how WordPress or a plugin/theme works. In this example, we’ll be introducing a new filter to the core of WordPress, which we can later use from another plugin or theme.
Creating the Mod
1. Navigate to the WordPatch Mods page from the WordPress admin panel sidebar and click the New Mod button to start creating your mod.
2. Enter a Mod Title, and then scroll down to the bottom and click Save Mod. You can leave all the settings to their defaults for now. You can find more information on what each setting does in this article.
Creating a Patch
Now it’s time to create a patch that introduces the filter we previously mentioned. WordPatch supports a variety of patch file formats, such as Unix and Git patch files. However, WordPatch features a Simple Patch Wizard that offers the easiest method of creating a patch. Let's see how it works by creating a patch for the WP_Comment::get_children() function in wp-includes/class-wp-comment.php.
Using the Simple Patch Wizard
1. Go to the Mods page and locate the mod we created earlier. Click Edit Mod.
2. Click the New Patch button. Give your patch a title and then scroll down to the Patch Type and select Simple Patch Wizard.
3. Enter the file path of the file we are patching, which is wp-includes/class-wp-comment.php. Click Load Old File From Server.
4. Click Copy Old File To New File.
5. In the New File editor, scroll down to the function WP_Comment::get_children() and, right before the return statement, add the code below and then click Save Patch.
$children = apply_filters( 'comment_children', $children, $this );
WordPatch is now ready to run our mod and apply our changes. Let’s continue by running our mod manually.