With the WPLatest updater library, you can easily add automatic updates to your WordPress plugins. This guide will walk you through the process of integrating the updater into your plugin.

Prerequisites

  • PHP 7.4 or higher
  • WordPress 5.8 or higher
  • Access to your plugin’s source code
  • Basic knowledge of PHP and WordPress plugin development
  • Composer (if installing via Composer)

Installation

To integrate the WPLatest updater into your plugin, you can either require it via Composer or manually copy the files into your plugin.

Installing with Composer is the recommended way to install the updater. It allows you to easily update the WPLatest updater when a new version is released.

First, navigate to your plugin’s root directory in the terminal and run the following command:

composer require wplatest/updater

After installing the updater, require the Composer autoloader in your main plugin file. Then, use the PluginUpdater class to set up automatic updates.

your-plugin.php
<?php
/**
 * Plugin Name: Your Plugin
 * Version:     1.0.0
 * Description: Your plugin description
 * Update URI:  https://wplatest.co
 *
 * @package ExamplePlugin
 */

require_once 'vendor/autoload.php';

use WPLatest\Updater\PluginUpdater;

class ExamplePlugin
{
    public function __construct()
    {
        add_action('init', array($this, 'initialize'));
    }

    public function initialize()
    {
        $options = array(
            'file'   => __FILE__,
            'id'     => '<your-plugin-id>',
            'secret' => '<your-api-secret>',
        );

        new PluginUpdater($options);
    }
}

new ExamplePlugin();

Ensure that you replace <your-plugin-id> and <your-api-secret> with your actual plugin ID and API secret for the updater to function correctly.

Next Steps

Success! Your plugin is now set up to receive automatic updates every time you release a new version in the dashboard or via the API.

Want to take it a step further and automate your release process? Check out the following resources:

Github workflows

Automate your plugin releases to WPLatest with GitHub workflows. Learn how to set up continuous integration and releases for your plugins.

API Reference

Check out the API reference to learn how to automate the release process and manage your plugins programmatically.

Troubleshooting

If you have any other issues or questions, please reach out to support [at] wplatest.co for assistance.