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

Overview

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 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. However, if your API response has a different shape, you can map fields to those returned by your API.

Usage

Basic example:


/**
 * Plugin Name: My Plugin
 */

require __DIR__ . '/vendor/autoload.php';

use WP_Forge\WPUpdateHandler\PluginUpdater;

$url = 'https://my-update-api.com/plugins/plugin-name'; // Custom API GET endpoint

new PluginUpdater( __FILE__, $url );

Advanced example with data mapping and data overrides:


/**
 * Plugin Name: My Plugin
 */

require __DIR__ . '/vendor/autoload.php';

use WP_Forge\WPUpdateHandler\PluginUpdater;

$file = __FILE__; // Can be absolute path to main plugin file, or the plugin basename.
$url = 'https://my-update-api.com/plugins/plugin-name'; // Custom API GET endpoint

$pluginUpdater = new PluginUpdater( $file, $url );

/*
 * Keys are the fields that WordPress is expecting (look at the WP Plugin Info API response).
 * Values are the keys returned by your custom API.
 * 
 * Use dot notation to map nested keys.
 */
$pluginUpdater->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. However, if your API response has a different shape, you can map fields to those returned by your API.

Usage

Basic example:


/**
 * Theme Name: My Theme
 */

require __DIR__ . '/vendor/autoload.php';

use WP_Forge\WPUpdateHandler\ThemeUpdater;

$url = 'https://my-update-api.com/theme/theme-name'; // Custom API GET endpoint

new ThemeUpdater( wp_get_theme('my-theme'), $url );

Advanced example with data mapping and data overrides:


/**
 * Theme Name: My Theme
 */

require __DIR__ . '/vendor/autoload.php';

use WP_Forge\WPUpdateHandler\ThemeUpdater;

$theme = wp_get_theme('my-theme'); // Get the theme's WP_Theme instance.
$url = 'https://my-update-api.com/themes/theme-name'; // Custom API GET endpoint

$themeUpdater = new ThemeUpdater( $file, $url );

/*
 * Keys are the fields that WordPress is expecting (look at the WP Theme Info API response).
 * Values are the keys returned by your custom API.
 * 
 * Use dot notation to map nested keys.
 */
$themeUpdater->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',
    ],        
  ]
);
You might also like...
 📦    A zero-configuration #0CJS developer toolkit for building WordPress Gutenberg block plugins.
📦 A zero-configuration #0CJS developer toolkit for building WordPress Gutenberg block plugins.

create-guten-block is zero configuration dev-toolkit (#0CJS) to develop WordPress Gutenberg blocks in a matter of minutes without configuring React, w

Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace

Developers tool for WordPress plugins: Wraps all your projects dependencies in your own namespace, in order to prevent conflicts with other plugins loading the same dependencies in different versions.

Rabbit Framework - A modern way of building WordPress plugins

Rabbit Framework - A modern way of building WordPress plugins. About Rabbit Framework is a modern framework designed to be a solid foundation for your

Wordless is a junction between a WordPress plugin and a theme boilerplate that dramatically speeds up and enhances your custom theme creation
Wordless is a junction between a WordPress plugin and a theme boilerplate that dramatically speeds up and enhances your custom theme creation

Wordless is a junction between a WordPress plugin and a theme boilerplate that dramatically speeds up and enhances your custom theme creation. Some of

Create custom WordPress routes and redirects, restrict access by roles and/or capabilities. Routes made simple
Create custom WordPress routes and redirects, restrict access by roles and/or capabilities. Routes made simple

Create custom WordPress routes and redirects, restrict access by roles and/or capabilities. Routes made simple

A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API

Wordpress XML-RPC PHP Client A PHP client for Wordpress websites that closely implement the XML-RPC WordPress API Created by Hieu Le MIT licensed. Cur

A PHP Class for creating Wordpress Custom Post Types easily

N.B I've released an updated version of the project to a new repository, PostTypes. WP Custom Post Type Class v1.4 A single class to help you build mo

Custom WordPress theme for DotOrg

wd_s Debt Collective Theme Table of Contents Introduction Getting Started Prerequisites Quick Start Advanced Setup Development Contributing and Suppor

Word Count (Custom WordPress Plugin)
Word Count (Custom WordPress Plugin)

word-count (Custom WordPress Plugin) Followed a tutorial to create a plugin that adds word count infos to the frontend (Posts only). I then modified t

Comments
  • use defined expiration var `cacheExpiration` when setting transient

    use defined expiration var `cacheExpiration` when setting transient

    Proposed changes

    Currently, there is a protected class variable cacheExpiration. This value is not used anywhere. It should be used when saving the release payload as transient. Instead the transient is set with the repeated value of 6 hours.

    This PR uses the value that is in place already as it appears to be intended for. So, now if someone sets the expiration it will actually be used.

    Type of Change

    • [x] Bugfix (non-breaking change which fixes an issue)
    • [] New feature (non-breaking change which adds functionality)
    • [] Breaking change (fix or feature that would cause existing functionality to not work as expected)
    • [] Documentation Update (if none of the other choices apply)

    Checklist

    • [] Linting and tests pass locally with my changes
    • [] I have added tests that prove my fix is effective or that my feature works
    • [] I have added necessary documentation (if appropriate)

    Further comments

    opened by circlecube 0
  • Clear cache in some specefic instances

    Clear cache in some specefic instances

    Is your feature request related to a problem? Please describe. The plugin versioncache should auto clear in a couple instances.

    • When a user clicks the "check again" link on the /wp-admin/update-core.php page, which points to: /wp-admin/update-core.php?force-check=1.
    • When the plugin updates successfully: this would meet the case that there has been an update and another in the cached time (currently six hours). Currently, if you update in this instance you have to wait until the cache expires before the next update is found. Not perfect, but if you update, it should check to make sure there's not another subsequent update immediately.
    opened by circlecube 0
Releases(1.0.1)
Owner
WP Forge
WP Forge
This WP plugin will update GitHub, Bitbucket, GitLab, and Gitea hosted plugins and themes

Transition from GitHub Updater 9.x to Git Updater 10.x Due to the renaming of the plugin folders and files, after the initial update, the plugin will

Andy Fragen 3k Jan 5, 2023
This Plugin is used to install and activate multiple plugins in one go. I was facing problem uploading plugins one by one so I developed this to solve my problem. Hope you will enjoy using this plugin.

=== Bulk Plugin Installer === Contributors: jawadarshad Donate link: https://jawadarshad.io/ Tags: bulk plugin installer, import multiple plugins, up

Muhammad Jawad Arshad 2 Sep 20, 2022
Classy is a framework for building WordPress themes, based on Blade template engine

Classy is a framework for building WordPress themes, based on Blade template engine. It's fast with beautiful architecture that allows you to write le

DigitalKwarts 75 Nov 23, 2022
A curated list of Awesome WordPress Theme, Plugins and Framework development Resources and WordPress Communities.

Awesome WordPress A curated list of Awesome WordPress Theme, Plugins and Framework development Resources and WordPress Communities. Inspired by bayand

Dropndot Limited 91 Dec 26, 2022
A custom WordPress nav walker class to fully implement the Twitter Bootstrap 4.0+ navigation style (v3-branch available for Bootstrap 3) in a custom theme using the WordPress built in menu manager.

WP Bootstrap Navwalker This code in the main repo branch is undergoing a big shakeup to bring it in line with recent standards and to merge and test t

WP Bootstrap 3.3k Jan 5, 2023
Create WordPress themes with beautiful OOP code and the Twig Template Engine

By Jared Novack (@jarednova), Lukas Gächter (@lgaechter), Pascal Knecht (@pascalknecht), Maciej Palmowski (@palmiak_fp), Coby Tamayo (@cobytamayo), Up

Timber 5.2k Jan 5, 2023
A better way to create WordPress themes.

Runway Framework for WordPress Visit the Runway website: RunwayWP.com A better way to create WordPress themes. Runway was built for creating WordPress

Parallelus 214 Nov 18, 2022
A WordPress plugin to create Blockbase child themes

Create Blockbase Theme A WordPress plugin to create Blockbase child themes Find out more about Blockbase at blockbasetheme.com Step 1 – Setup Install

Automattic 171 Jan 3, 2023
A foundation for WordPress Plugin Development that aims to provide a clear and consistent guide for building your plugins.

WordPress Plugin Boilerplate A standardized, organized, object-oriented foundation for building high-quality WordPress Plugins. Contents The WordPress

Devin 7.2k Jan 4, 2023
Wordpress advance plugin with multi purposes features like live chat, custom post type, custom forms, word count etc

What is this? This is wordpress plugin which is created for the multi purpose uses. How to use? Simply install the plugin. Go to the plugin settigs pa

Amir Liaqat 2 Jun 23, 2022