How can we help?

WordPress Plugin and Theme Repo

New in 1.1

The WordPress Repo add-on allows you to host your premium WordPress plugin or theme with the Software Licensing add-on.

Steps

  • Create a licensing server using the third-party Software Licensing Manager plugin. This licensing server can be on your main or separate WordPress sites.
  • Enable the Software Licensing Add-On and input all the settings from the SLM plugin.
  • Enable License key generation on the Product page corresponding to your plugin or theme.
  • Add additional metadata to your plugin or theme via an info.json file (see below).
  • Accept the license key and use it to enable automatic updates.
  • Upload your plugin or theme to the repo.

Caveat: You cannot update a plugin on the same server running the repo add-on. When you perform the update, WordPress goes into maintenance mode, so it can’t download the bundle. This is usually only an issue for local development environments.

Demo

The changes you need to make for your plugin or theme are demonstrated in the repo-demo plugin on GitHub. Use this code as a starting point or guide for your own development. The screenshots below are from this sample plugin.

Additional Plugin or Theme metadata.

Native WordPress supports updating from wordpress.org and nowhere else.

You must add support to your code to make your premium plugin work like the ones downloaded from the .org repo. We use the free, open-source, and well-supported Plugin Update Checker library to handle this work.

The PUC code enables the ‘View details’ and ‘Check for updates’ links on the Plugins page in the WordPress admin panel.

Screenshot 2024 04 26 At 1.04.03 pm

The details come from a file named info.json that is stored in your code. This file should be located in the same directory as your main .php file for plugins. For a theme, the file should be alongside the style.css file. The information in this file is used along with the file data in the respective header.

Screenshot 2024 04 26 At 1.07.56 pm

The fields allowed in info.json are found in this table.

NOTE: Certain fields are generated automatically from your plugin or theme header, so don’t have to be included in info.json.

  • name
  • download_url*
  • requires
  • tested
  • requires_php
  • author
  • author_homepage

The only fields you must add are ‘sections’ and ‘product’ (see below) – the other ‘required’ fields are generated assuming your header information is correct. The download_url should *not* be specified because it will be overridden each time.

There is one additional field: the ‘product’. The generated license key is for a specific Stripe product. You have to add that product to the info.json to allow upgrades. This field tells the plugin what product it’s trying to update for—it ties the plugin to the purchased product.

Fortunately, once this data is added to your bundle, it should rarely, if ever, need to be changed.

Use the license key

Your plugin or theme needs to use a license key the user received when they purchased it. Generally, the user inputs the key whenever they set up your plugin. This process can be done with a setup wizard or a simple admin settings page—it’s up to you.

When the user checks for updates, the license key determines if a later version is available. If the license key is invalid, it shows no new version is available (even if one exists).

Using the PUC library, you must send the license key and the ‘Check for updates’ request. Here is some sample code for doing so from the sample plugin:

/**
 * Add the license key to the request.  Otherwise the repo show no updates available.
 */
add_filter( 'puc_request_info_options-' . REPO_DEMO_SLUG, function ( array $options ) {
	$repo_demo_options = get_option( 'repo_demo_options', array() );
	$headers                  = $options['headers'] ?? array();
	$headers['X-License-Key'] = $repo_demo_options['repo_demo_license_key'] ?? '';
	$options['headers']       = $headers;
	return $options;
} );

The Software Licensing Manager has a simple API for validating the license key, which you can use for additional checks.

Upload the zip file to the WordPress Repository

When the WordPress Repo add-on is enabled, it adds a settings. The page is available via the ‘Settings’ link in the add-on page or the ‘Repo’ link in the admin menu.

Both links take you to a page like the following:

Screenshot 2024 04 26 At 1.33.12 pm

New versions of your plugin or theme are uploaded just as you’d add files to the media library. After the zip file is uploaded, the contents are read auto-magically to get information about the theme or plugin to be displayed in the table. No additional configuration is required.

Once configured, releasing a new version is as simple as uploading the zip file to your site.

Next Steps

There is a lot here. Fortunately, it’s not as difficult as it may initially seem. The configuration only has to happen once; then, releasing new versions is just creating and uploading a new zip file.

Don’t hesitate to reach out to us. We’ll help you set up the first version.