WordPress Plugin : Theme & Plugin Info updater

日本語ページへ

If you want to publish or sell your own themes or plugins that are not registered on the official WordPress website, you may be worried about how to update them.

The standard method is to update by downloading a Zip file, but some also have an update notification function.

It seems that plugin-update-checker is often used as the main notification & update function.

You can handle notifications and updates using these methods, but if you are selling a theme or plugin, you may want to not only update it, but also be notified when a new version is released, or require a password when updating.

tap-inforest plugin (server side)

This strange name is an abbreviation for theme and plugin information by rest api, and it starts by notifying theme and plugin information to the dashboard using REST API, and also supports update function with password.

Main features

  • Display theme/plugin notifications on dashboard
  • Display button for detailed information (optional)
  • Button display for theme/plugin updates (optional)
  • Enter password for theme/plugin update package(by Simple Download with password

Operating environment is WordPress 6.2, PHP version 7.4 or higher (latest version recommended)

Download

You can download “Simple Download with password addon” by entering the password that was sent to you in the email you received when you purchased it.

Install

Open the downloaded tap-inforest-xxxx.zip file on the WordPress admin screen’s Add New Plugin screen, select the file from Upload, and install it.

When you activate the tap-inforest plugin, the site becomes the server side that handles rest api requests, and registers and manages theme/plugin notifications and update zip files.

Registration

A setting called “Theme/Plugin info and Updater” has been added to the WordPress management screen, so you can manage the registration of various information there.

TypeChoose a plugin or theme
SlugEnter the target slug (installation folder name of plugin or theme).
VersionPlugin or theme version
*Normally, set the latest version. For example, if it is set to 1.5.0, it will only be targeted if the requester’s version information is less than 1.5.0.
WordPress VersionSet the minimum WordPress version required for plugins and themes to work
For example, if set to 6.4.0, only sites with WordPress version 6.4.0 or higher will be targeted (optional)
PHP VersionSet the minimum PHP version required for plugins and themes
For example, if set to 8.0, only sites with PHP version 8.0 or higher will be targeted (optional)
Info TypeSelect from Info (Blue) / Success (Green) / Notice (Yellow) / Alert (Red)
TitleEnter the title of the information displayed on the dashboard
MessageEnter message to notify
Detail Page URLIf there is a page with detailed explanation, enter the URL of that page (optional)
Start DateSpecify the date to start displaying (optional)
End DateSpecify the date to end display (optional)
Package URLEnter the download URL (by Simple Download with password) for the plugin or theme update package (optional)

Once registered, a list of all registered items will be displayed at the top of the screen.

That’s all for the server-side configuration that handles Rest api requests.

However, this plugin does not work by itself. You need to implement a function to query the server side for each plugin or theme you want to target.

Implementation of request function on plugin/theme side

You need to add request functionality to the theme or plugin you are developing.

For example, to manage a theme called sample-theme, you will need to do the following:

1. Add the dashboard-inforest.php file to your theme’s PHP program

2. Rewrite the definition of the namespace part of the dashboard-inforest.php file to a unique name .

Any name can be used for namespace, but we recommend using a theme or plugin slug. However, hyphen (-) cannot be used, so if you are using it, you must replace it with an underscore (_).
By using namespace, you can avoid class name collisions when using this feature with multiple plugins, etc.

3. Write the following code in function.php etc. of the theme.
Rest api request destination site name (req_site): http://example.com, type: theme, slug (theme folder name): sample-theme

if(is_admin()){
    require_once( __DIR__ . '/dashboard-inforest.php');
    //Specify sample_theme defined in namespace before Dashboard_info
    new sample_theme\Dashboard_info( 'https://example.com', 'theme', 'sample-theme' );
}

For plugins, enter the same code in the main php file of the plugin. Type: plugin, and slug should be the plugin slug.

The only changes required on the theme and plugin side are adding a dashboard-inforest.php file with a modified namespace and a few lines of code to make requests in admin mode.

If your theme or plugin is now activated, it will periodically check for updates. Once a new version update is available, the user will be notified as appropriate:

WordPress standard theme and plugin updates are normally checked about twice a day, but the default request interval for dashboard-inforest.php is 6 hours, and it takes about 6 hours for messages to be displayed/updated.
*If you shorten the confirmation interval, the number of accesses to the server side will increase and the load will increase, so if you have a large number of installed themes or plugins, it may be better to adjust the interval to a longer one.

Disclaimer

The author is not responsible for any damage caused by the use of this software, so please use it at your own risk.

Change log

Ver0.6.0
* 2024-3-4 releace

go-to-top