How to manage plugin updates without uploading in wordpress.org?

WordPress
How to manage plugin updates without uploading in wordpress.org?

When developing a WordPress plugin or theme, there could be updates in future. When a plugin has updates, the developer can add new updates as new versions in plugins and themes. Normally, the WordPress plugin needs to be uploaded to WordPress.org plugins library and manage updates with git. But if it is a paid/pro plugin, it’s not possible with WordPress.org, because WordPress.org is only for managing free plugins. In this situation, developers can manage the WordPress plugins and theme updates with their own servers with Plugin Update Checker.
This is a custom update manager for WordPress plugins or themes useful if the owners don’t want to upload in public WordPress repositories. But it will help the users to get updates if available at the same time of developer update.

The Custom Update Checker has two main Sections

WP Update Server
This package considers the website as a repository. WP update server is part of the website that manages or sells the plugins.

Plugin Update Checker
This package will check the new updates of plugins and themes. Plugin update checker will be the part of a developed plugin. It adds automatic update notifications and one-click upgrades to plugins, private themes, and so on.

Implementation
Please follow below steps to implement the update server in custom plugin or theme.

Setting-up the server system
Download Wp update server from https://github.com/YahnisElsts/wp-update-server
Extract and upload to the uploads folder of the server WordPress site.
Eg: https://www.2hatslogic.com/wp-content/uploads/wp-update-server/

Update In Plugins
Download the latest release of plugin update checker from https://github.com/YahnisElsts/plugin-update-checker and copy the plugin-update-checker folder and paste into the commercial plugin or theme.

Move to the plugin-update-checker/examples folder and open the plugin.json for plugins and theme.json for a set in theme. Set the plugin or theme name, version, description in the JSON file

Add the following code in the plugin main file or functions.php file from themes

 require 'path/to/plugin-update-checker/plugin-update-checker.php';
 	$updateChecker = Puc_v4_Factory::buildUpdateChecker(
		'http://website.com/path/to/details.json',
		__FILE__,
		'unique-plugin-or-theme-slug'
  );
Insert your code here

Eg,

 require 'plugin-update-checker/plugin-update-checker.php';
  $updateChecker = Puc_v4_Factory::buildUpdateChecker(
		'http://2hatslogic.com/wp-content/wp-update-server/details.json',
		__FILE__, 
		'hatslogic-woo-variation'
  );

From the example, ‘hatslogic-woo-variation’ is the plugin or theme slug

New Update Release

Once the update is done, edit the JSON file and zip the plugin or theme folder and copy this to the packages folder located in server-site/wp-content/uploads/wp-update-server/packages. Need to replace the current zip file once we add another version of the same plugin. And also the plugin zip file should be with the slug name. From the above example, it should be like ‘hatslogic-woo-variation.txt’

GitHub Integration

The plugin-update-checker can use with Github without a server system.

Follow the steps for GitHub integration,

  • Download plugin-update-checker and extract to commercial plugin or theme folder.
  • Add the following code in the theme functions.php or plugin core file
require 'plugin-update-checker/plugin-update-checker.php';
     $updateChecker = Puc_v4_Factory::buildUpdateChecker(
		'https://github.com/user-name/repo-name/',
		__FILE__,
		'unique-plugin-or-theme-slug'
     );
 
     $updateChecker->setAuthentication('your-token-here');
     $updateChecker->setBranch('stable-branch-name');

For plugins add a readme.txt file with the standard rules.

GitHub Releases :
Create a new release with the help of release “features” of GitHub. If need to use release includes, call the enableReleaseIncludes() method after creating the update checker instance:
$UpdateChecker->getVcsApi()->enableReleaseIncludes()
Tags: Tags are the versions of the new release like V1.2, V3.0
Stable Branch: Point the update checker to a completed branch in GitHub
$updateChecker->setBranch(‘branch-name’);

The plugin will check the version header in the main plugin file or style.css and display a notification if it’s greater than the already installed version.
The plugin update checker will pull update details from the following parts of a release/tag/branch:

  1. Version
    The version of the updated plugin or theme.
  2. Changelog
    Changes and newly added features in the new version.
  3. Required WordPress version
    Set the required WordPress version for the run the plugin or theme.
  4. Tested WordPress versions
    Set the plugin that tested with different versions of WordPress
  5. Last Update
    Fetch the last updated timestamp
  6. Number of Downloads
    Fetch the total number of downloads of a particular plugin or theme
  7. Ratings
    Fetch the rating details of the plugin or theme
  8. Screenshots
    Screenshots that’s a need to show in ‘screenshot’ tab of plugin details
  9. Banners
    The main banner that will display in the plugin details popup.

BitBucket Integration
If need plugin update checker with BitBucket integration, it similar to the GitHub integration,

  • Download plugin-update-checker and extract to commercial plugin or theme folder.
  • Add the following code in the theme functions.php or plugin core file
require 'plugin-update-checker/plugin-update-checker.php';
   $updateChecker = Puc_v4_Factory::buildUpdateChecker(
	'https://bitbucket.org/user-name/repo-name',
	__FILE__,
	'unique-plugin-or-theme-slug'
   );
   $updateChecker->setAuthentication(array(
	'consumer_key' => '...',
	'consumer_secret' => '...',
   ));
   $updateChecker->setBranch('stable-branch-name');
 
  •  Add the readme.txt file, it’s an optional step

So using the custom update checker anyone can easily implement plugin or theme updates without the use of WordPress.org or git knowledge.

And, it is easier than the WordPress repository uploads. The custom update checker is easy to test as well because this only needs to make 2 version changes in the JSON and plugin file and zip it to the server site folder wp-update-server and then make a refresh in the old version of the plugin installed in the site’s plugins page. It will show the new update notice there.

Comments are closed.

2hats Logic HelpBot