Invoice Rocket has several hooks that you can take advantage of, making it relatively easy to add your own functionality.

In this tutorial I’ll demonstrate how to create a simple add-on (WordPress plugin) and get it to add a new menu item into the invoice nav.

Armed with this knowledge you should be able to take things further and create your own custom add-on for Invoice Rocket.

The tutorial will also cover some of the WordPress plugin development basics, so if that’s new to you then this might be a good learning experience.

You’ll need a text editor (I recommend VS Code but any text editor will do) and about 10 minutes of your time.

Create your files

Start by creating a folder in wp-content/plugins/ and call it invoice-rocket-test

Inside the folder create a new file called invoice-rocket-test.php

Open invoice-rocket-test.php in your text editor and paste in the following:

<?php
/*
Plugin Name: Invoice Rocket Test Plugin
Plugin URI: http://yourdomain.com/
Description: A test plugin for Invoice Rocket
Version: 1.0
Author: Your Name
Author Email: you@domain.com
Text Domain: invoice-rocket-test
Domain Path: /languages/
*/

// Look for the translation file.
function load_invoice_rocket_test_textdomain() {
load_plugin_textdomain( 'invoice-rocket-test', false, dirname( plugin_basename( __FILE__ ) ) . '/languages/' );
}
add_action( 'plugins_loaded', 'load_invoice_rocket_test_textdomain' );

Explanation: The first part of the code helps WordPress identify your plugin, and even at this early stage if you go to the WordPress plugins interface you should see your test plugin listed there.

The second part of the code is used for translation purposes and tells WordPress where to look for translation files (inside the windows /languages/ directory) and what the text domain is. A text domain is a name unique to your plugin, in this case invoice-rocket-test.

Now we need want to target an existing action (Invoice Rocket has many). As mentioned for this tutorial we are going to add a new menu item into the invoice nav, and so we will be targeting the ir_invoice_nav action. To do that, add this code to your plugin:

// Add item into invoice nav
function my_cool_function() { ?>
<a href="#"><?php _e('Hello world!', 'invoice-rocket-test'); ?></a>
<?php }
add_action( 'ir_invoice_nav', 'my_cool_function' );

We’re nearly done. Go to your WordPress plugins page, locate the plugin called Invoice Rocket Test Plugin and activate it. Go to the front end, click on Invoices and you’ll now see your new menu item in the invoice nav:

By utilising actions from your custom plugin you can create your own Invoice Rocket functionality without making any direct modifications to the main theme.

Further explanation

I deliberately keep this tutorial brief and simple, but if you’d like to learn more about some of the methods and functions used that I glossed over, keep reading.

Actions

WordPress actions provide a way for running a function at a specific point in the execution of WordPress Core, plugins, and themes.

Text Domains

A text domain is used for translation purposes and loads the theme’s translation strings. If you’re interested in making your plugin translatable (recommended) then read up on I18n.