An open API service indexing awesome lists of open source software.

https://github.com/wp-forge/wp-update-handler

A WordPress package for updating custom plugins and themes based on an API response from a custom update server.
https://github.com/wp-forge/wp-update-handler

hacktoberfest

Last synced: about 1 year ago
JSON representation

A WordPress package for updating custom plugins and themes based on an API response from a custom update server.

Awesome Lists containing this project

README

          

# WordPress Update Handler

A WordPress package for updating custom plugins and themes based on an JSON REST API response from a custom update
server.

Check out the [WordPress GitHub Release API](https://github.com/wp-forge/worker-wp-github-release-api) repository to
learn how to quickly launch a custom update server that fetches releases from GitHub using Cloudflare Workers.

## Plugins

This package expects your custom plugin info API to respond with the same shape as
the [WordPress plugin info API](https://codex.wordpress.org/WordPress.org_API#Plugins). However, if your API response
has a different shape, you can map fields to those returned by your API.

### Usage

Basic example:

```php
setDataMap(
[
'requires' => 'requires.wp',
'requires' => 'requires.php',
'banners.2x' => 'banners.retina',
]
);

/*
* Explicitly set specific values that will be provided to WordPress.
*/
$pluginUpdater->setDataOverrides(
[
'banners' => [
'2x' => 'https://my.cdn.com/banner-123-retina.jpg',
'1x' => 'https://my.cdn.com/banner-123.jpg',
],
'icons' => [
'2x' => 'https://my.cdn.com/icon-123-retina.jpg',
'1x' => 'https://my.cdn.com/icon-123.jpg',
],
]
);

```

## Themes

This package expects your custom theme info API to respond with the same shape as
the [WordPress theme info API](https://codex.wordpress.org/WordPress.org_API#Themes). However, if your API response has
a different shape, you can map fields to those returned by your API.

### Usage

Basic example:

```php
setDataMap(
[
'requires' => 'requires.wp',
'requires' => 'requires.php',
'banners.2x' => 'banners.retina',
]
);

/*
* Explicitly set specific values that will be provided to WordPress.
*/
$themeUpdater->setDataOverrides(
[
'banners' => [
'2x' => 'https://my.cdn.com/banner-123-retina.jpg',
'1x' => 'https://my.cdn.com/banner-123.jpg',
],
'icons' => [
'2x' => 'https://my.cdn.com/icon-123-retina.jpg',
'1x' => 'https://my.cdn.com/icon-123.jpg',
],
]
);

```