Skip to content

WP Package Updater -Simplifies the process of updating WordPress packages from custom repositories

License

Notifications You must be signed in to change notification settings

oblakstudio/wp-package-updater

📦 WordPress package updater

Simplifies the process of updating WordPress packages from custom repositories.

Packagist Version Packagist PHP Version semantic-release: angular

Code Climate maintainability Release

GitHub Packagist Downloads

Highlights

  • Standardizes the process of updating plugins / themes from custom repositories.
  • Fully integrates with Plugin / theme info API.
  • Easily extendable / customizable

Installation

We officially support installing via composer only

Via composer

composer require oblak/wp-package-updater

Basic Usage

Plugin_Updater and Theme_Updater are the main abstract classes of the package, and they need to be extended in order to create an updater class. The class is responsible for registering the plugin / theme update hooks, and for updating the plugin / theme.

At minimum you need to implement the get_update_url() method, which is responsible for returning the update info URL.

1. Define your updater class

<?php
namespace Vendor\My_Plugin;

use Oblak\WP\Plugin_Updater;
use Oblak\WP\Theme_Updater;



class My_Plugin_Updater extends Plugin_Updater {

    protected function get_update_url() {
        return 'https://my-plugin.com/api/update';
    }

}

class My_Theme_Updater extends Theme_Updater {

    protected function get_update_url() {
        return 'https://my-theme.com/api/update';
    }

}

2. Include the autoload file

require_once __DIR__ . 'vendor/autoload.php';

3. Instantiate the updater class

<?php

use Vendor\My_Plugin\My_Plugin_Updater;
use Vendor\My_Plugin\My_Theme_Updater;

new My_Plugin_Updater('plugin-slug');
new My_Theme_Updater('theme-slug');

Advanced Usage

Depending on your needs, you can override several methods in the updater class to customize the update process according to your repository API.

Some of the functions you can customize:

  • get_headers - Returns the headers for the update request.
  • send_request - Sends the update request to the repository API.
  • validate_response - Validates the response from the repository API.
  • get_transient_prefix - Returns the transient prefix for the plugin / theme update information.

Contributing

Contributions are welcome from everyone. We have contributing guidelines to help you get started.

Credits and special thanks

This project is maintained by Oblak Studio.

License

This project is licensed under the GNU General Public License v2.0.