Giter VIP home page Giter VIP logo

external-update-api's Introduction

External Update API

Contributors: codeforthepeople, johnbillion
Tags: updates, github
Requires at least: 3.7
Tested up to: 3.9
Stable tag: 0.5
License: GPL v2 or later

Add support for updating themes and plugins via external sources. Includes an update handler for plugins and themes hosted in public or private repos on GitHub.

Description

Add support for updating themes and plugins via external sources instead of the WordPress.org repos. Includes an update handler for plugins and themes hosted on GitHub.

Installation

  1. Download the plugin ZIP file and extract it into your plugins directory, or clone the repo into your plugins directory with git clone [email protected]:cftp/external-update-api.
  2. Activate the plugin.
  3. See the Usage section below.

Usage

The plugin comes bundled with an update handler for GitHub. To add a handler for a different external source, see the 'Writing a new Handler' section below.

You can tell the update API to use a public or private GitHub repo to update a plugin or theme on your site. To do this, hook into the euapi_plugin_handler or euapi_theme_handler hook, respectively, and return a handler for your plugin or theme.

Plugin Example:

function my_plugin_update_handler( EUAPI_Handler $handler = null, EUAPI_Item_Plugin $item ) {

	if ( 'my-plugin/my-plugin.php' == $item->file ) {

		$handler = new EUAPI_Handler_GitHub( array(
			'type'       => $item->type,
			'file'       => $item->file,
			'github_url' => 'https://github.com/my-username/my-plugin',
			'http'       => array(
				'sslverify' => false,
			),
		) );

	}

	return $handler;

}
add_filter( 'euapi_plugin_handler', 'my_plugin_update_handler', 10, 2 );

Theme Example:

function my_theme_update_handler( EUAPI_Handler $handler = null, EUAPI_Item_Theme $item ) {

	if ( 'my-theme/style.css' == $item->file ) {

		$handler = new EUAPI_Handler_GitHub( array(
			'type'       => $item->type,
			'file'       => $item->file,
			'github_url' => 'https://github.com/my-username/my-theme',
			'http'       => array(
				'sslverify' => false,
			),
		) );

	}

	return $handler;

}
add_filter( 'euapi_theme_handler', 'my_theme_update_handler', 10, 2 );

If your repo is private then you'll need to pass in an additional access_token parameter that contains your OAuth access token.

You can see some more example handlers in our CFTP Updater repo.

Writing a new Handler

To write a new handler, your best bet is to copy the EUAPI_Handler_GitHub class included in the plugin and go from there. See the EUAPI_Handler class (and, optionally, the EUAPI_Handler_Files class) for the abstract methods which must be defined in your class.

Frequently Asked Questions

None yet.

Upgrade Notice

0.5

  • Fix integration with theme updates.
  • EUAPI is now a network-only plugin when used on Multisite.
  • Eat our own dog food. EUAPI now handles its own updates through GitHub.
  • At long-last fix the wonky compatibility with WordPress 3.7+.
  • Increase the minimum required WordPress version to 3.7.

Changelog

0.5

  • Fix integration with theme updates.
  • EUAPI is now a network-only plugin when used on Multisite.
  • Eat our own dog food. EUAPI now handles its own updates through GitHub.
  • Add support for an upgrade notice (not used by default).
  • Introduce an abstract EUAPI_Handler_Files class to simplify extension by other handlers.
  • Inline docs improvements.

0.4

  • At long-last fix the wonky compatibility with WordPress 3.7+.
  • Increase the minimum required WordPress version to 3.7.

0.3.5

  • Support JSON-encoded API requests in addition to serialisation. This is pre-emptive support for WordPress 3.7.

0.3.4

  • Support the upcoming SSL communication with api.wordpress.org

0.3.3

  • Correct a method name in the EUAPI_Handler class.

0.3.2

  • Change a method name and inline docs to clarify that both plugins and themes are supported.

0.3.1

  • Prevent false positives when reporting available updates.
  • Prevent multiple simultaneous updates breaking due to a variable name clash.

0.3

  • Allow a handler to return boolean false to prevent update checks being performed altogether.

0.2.4

  • First public release.

Screenshots

None yet.

external-update-api's People

Contributors

johnbillion avatar simonwheatley avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

external-update-api's Issues

Allow fetch_new_version() and fetch_info() to be overridden

Removing final from the definition of fetch_new_version() and fetch_info() would allow for alternate plugin/theme information discovery methods. In particular, this is useful for situations where the plugin/theme file is not publicly accessible. I am hoping to use a feed of plugin and theme information to broadcast update availability and would like to override these functions to provide the alternate method.

Any problems in removing those two final declarations?

Multisite compatibility?

Will this plugin work in a WordPress multisite setup?

I've added the 'euapi_theme_handler' filter to the theme functions file, but I don't think this is being triggered at all. Because while in a site admin, there are no update options and while in Network Admin > Themes the functions.php of each activated theme isn't run so the notification of a new version doesn't appear here either.

Is there any other way of getting it to work do you think, perhaps by putting the filter call into a mu-plugin?

PHP warning in WordPress 3.7 RC1

It appears that WordPress 3.7 (RC1) can send boolean false to the wordpress.org API when checking for plugin updates. This is causing a PHP warning to be generated because EUAPI assumes an array is sent and tries to iterate over it. We'll need to keep an eye on this and handle it if it doesn't change.

is_a is deprected on PHP 5.2.x

Due to some ridiculousness in the PHP version history, the is_a function is deprecated from 5.0 until 5.3 when they un-deprecated it. ๐Ÿ˜•

Thanks to this, users still on PHP 5.2x would trigger some warnings when running the updater. It also looks like instanceof is a little better on performance anyway, so it's probably worth swapping out.

PR inbound.

Broken in 3.6

I've not investigated it yet but it looks like this might be broken in 3.6. It's preventing any updates from appearing on the Plugins or the Updates screens, although QM shows the HTTP requests to the update APIs are still firing.

Needs to be investigated.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.