ClassicPress Plugin Development: Integrating Code Potent’s Update Manager into a Plugin

ClassicPress PluginsThis post is part of the ClassicPress Plugin Development series n which I am going to look at both best practice for developing plugins and how I approach some requirements as well as some of the functions I commonly use.

The process for adding the Update Manager client to a plugin is quite straightforward.

Once you have downloaded the Update Manager, copy the UpdateClient.class.php file into your plugin folder; I add it to the libraries folder. Once you’ve done this, require_once the file in your plugin:

require_once(dirname(__FILE__).'/libraries/updateclient/UpdateClient.class.php');

There are three lines in the UpdateClient.class.php which need to be changed.

The first is in the namespace declaration where you need to change this to your developer name \ your plugin name. The below is an example for my Add Open Graph Tags plugin:

// EDIT: Make this unique. Example: YourDevName\YourPluginName;
namespace azurecurve\azrcrv_aogt;

The second is to set the update server URL; this is the domain of the ClassicPress site which wll be running the Update Manager plugin (I covered this in the previous post):

// EDIT: URL where Update Manager is installed; with trailing slash!
const UPDATE_SERVER = 'https://update.development.azurecurve.co.uk/';

The third needs to be set to plugin as the Update Manager supports themes as well as plugins:

// EDIT: plugin or theme?
const UPDATE_TYPE = 'plugin';

With the above done, Update Manager has been added to the plugin which means this plugin can now server updates to users which they can easily apply to their sites through the admin dashboard. In the next post, I’ll show how to create a plugin update endpoint which servers updates to users.

Click to show/hide the ClassicPress Plugin Development Series Index

What should we write about next?

If there is a topic which fits the typical ones of this site, which you would like to see me write about, please use the form, below, to submit your idea.

Your Name

Your Email

Suggested Topic

Suggestion Details

Leave a Reply

Your email address will not be published. Required fields are marked *