← All posts

Create Your First Self-Hosted Plugin Update with Hoster

If you share one plugin across several client sites and it isn't on WordPress.org, every change means uploading a zip to each site by hand. In this video we set up a self-hosted plugin update with Hoster. We register a plugin, add the updater file Hoster generates, install version 0.0.1, then release 0.0.2, and the client site picks it up from its normal Plugins screen. You ship a new version once and each site gets it with one click.

Our example plugin is called Global Theming. It loads one shared CSS file, so we can roll out the same theme styles to several websites.

Create the download entry

A site can only find an update if your store knows about the plugin first. So we start by creating a download entry that holds the version number, the changelog and the WordPress requirements.

  1. Once your license is activated, go to Downloads → Add New (from All Downloads).
  2. Enter the title. We use Global Theming.
  3. In Download Details, look at the Changelog, Description and Installation tabs. They come pre-filled: the changelog already has a 0.0.1 heading with "Initial release", and Installation has the standard three-step instructions. You don't have to write them yourself.
  4. In the Plugin panel, leave Plugin Version at 0.0.1. We don't have a zip yet, so Download URL stays empty for now.
  5. In the WordPress panel, check Requires Version (6.3.0 by default), Tested Version (pulled from your store, 6.5.4 here) and Minimum PHP Version (7.4). You can change all three.
  6. The Author details are taken from your admin account. You can also add your website URL and your WordPress.org profile.
  7. Click Publish.

Banners (high and low resolution) are covered in a separate video, so we skip them here.

Get the plugin files from Resources

Writing update-checker code by hand is where small mistakes creep in, like a wrong prefix, a mismatched text domain or a bad remote URL. Hoster generates this code for you.

  1. Go to Downloads → Resources.
  2. Under Plugin, choose Global Theming. If you've created several downloads, they all show up in this list.
  3. The Main Plugin File tab shows global-theming.php. Hoster has already filled in the plugin name, the text domain and a prefix based on the plugin name. This file goes in the plugin's root folder.
  4. The Updater tab shows update.php, the file that connects your plugin to your Hoster site. It must be placed at ./inc/update.php.

Here is the generated main file as shown on screen (remote URL shortened):

<?php
/**
 * Plugin Name:       Global Theming
 * Description:       Notifications Block (Info, Tip, Warning, Error)
 * Requires at least: 6.3.0
 * Requires PHP:      7.4
 * Version:           0.0.1
 * Author:            Marko Krstic
 * License:           GPL-2.0-or-later
 * License URI:       https://www.gnu.org/licenses/gpl-2.0.html
 * Text Domain:       global_theming
 * Website:
 */

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

$plugin_prefix = 'GLOBALTHEMING';

define($plugin_prefix . '_DIR', plugin_basename(__DIR__));
define($plugin_prefix . '_BASE', plugin_basename(__FILE__));
define($plugin_prefix . '_PATH', plugin_dir_path(__FILE__));
define($plugin_prefix . '_VER', '0.0.1');
define($plugin_prefix . '_CACHE_KEY', 'global_theming-cache-key-for-plugin');
define($plugin_prefix . '_REMOTE_URL', 'https://…/wp-content/uploads/downloads/6/info.json');

require constant($plugin_prefix . '_PATH') . 'inc/update.php';

new DPUpdateChecker(
	constant($plugin_prefix . '_DIR'),
	constant($plugin_prefix . '_VER'),
	constant($plugin_prefix . '_CACHE_KEY'),
	constant($plugin_prefix . '_REMOTE_URL'),
	constant($plugin_prefix . '_BASE')
);

Add the code to your plugin

Our test plugin is small: a main PHP file and a theme.css file that only sets the body background color.

  1. Copy the Main Plugin File code and paste it at the top of your plugin's main file. Below it, keep your own code. Ours only enqueues the stylesheet:
// Enqueue the CSS file
function global_theme_enqueue_styles() {
    wp_enqueue_style('global-theme-styles', plugin_dir_url(__FILE__) . 'theme.css');
}
add_action('wp_enqueue_scripts', 'global_theme_enqueue_styles');
  1. Create an inc folder in the plugin.
  2. Copy the Updater code into inc/update.php. The file name is already set for you, and it matches the require line in the main file.

The plugin folder now looks like this:

global-theming/
├── global-theme.php
├── inc/
│   └── update.php
└── theme.css

Install version 0.0.1 on a test site

Test the first build on a fresh site before any client relies on the update. We use a local WordPress install.

  1. Zip the plugin folder and upload it through Plugins → Add New Plugin.
  2. Activate it. The plugins list shows Global Theming, Version 0.0.1 | By Marko Krstic.
  3. Check the front end. The background is olive, which comes from theme.css.

Push the 0.0.2 update

This is what you'll repeat for every release: change the code, bump the version and upload the new zip.

  1. In your code editor, change the background color in theme.css from olive to red.
  2. In the main plugin file, bump the version to 0.0.2 in two places: the Version: header and the _VER define.
  3. Delete the old zip and compress the global-theming folder again.
  4. In Hoster, open the Global Theming download and set Plugin Version to 0.0.2.
  5. In the Changelog tab, add a 0.0.2 heading above 0.0.1 with a short note. Ours says "Updated background color". A clear changelog tells your users whether they need this update.
  6. Upload the new zip with the upload button next to Download URL.
  7. Click Update to save.

The version bump is what makes this work. WordPress only offers an update when it sees a higher version number than the one installed.

Update the plugin on the site

Reload Plugins on the test site. Global Theming now shows that version 0.0.2 is available. Click View details to see the description and changelog, then click update now. The row changes to Version 0.0.2 with an Updated! notice, and the front end now uses the new background color.

Who is this for

  • Agencies and freelancers who want to push one shared plugin (theme styles, custom blocks, client tools) to many sites without re-uploading zips.
  • Plugin authors who sell or distribute plugins outside WordPress.org and want updates to show up in the normal WordPress update screen.
  • Developers who'd rather copy a ready-made updater file than write their own update-checker code.

FAQ

How do I make WordPress detect a new version of my self-hosted plugin? Bump the version in the plugin's Version: header and in the _VER define, set the same number in Hoster's Plugin Version field, upload the new zip and save. WordPress offers the update only when the version number is higher than the installed one.

Where does the update.php file go? In an inc folder inside your plugin, at inc/update.php. The generated main plugin file loads it from that path.

Do I have to write the updater code myself? No. Go to Downloads → Resources and pick your plugin. Hoster generates the main plugin file (name, text domain, prefix, remote URL) and the update.php updater. You copy both into your plugin.

Can I set the required WordPress and PHP versions? Yes. The WordPress panel of each download has Requires Version, Tested Version and Minimum PHP Version. Tested Version is pulled from your store, and you can edit all three.

Will my users see the changelog before updating? Yes. What you write in the Changelog tab shows up when they click View details on the Plugins screen.

Get Hoster → dplugins.com