Plugin and theme updater module
Based on:
https://github.com/tangibleinc/updater
Add as dependency in composer.json
and run composer update
.
{
"repositories": [
{
"type": "vcs",
"url": "git@github.com:tangibleinc/updater"
}
],
"require": {
"tangible/updater": "dev-main"
},
"minimum-stability": "dev"
}
Or install as a module in tangible.config.js
.
export default {
install: [
{
git: 'git@github.com:tangibleinc/updater',
dest: 'vendor/tangible/updater',
branch: 'main',
},
]
}
After loading the updater, its newest version instance is ready on plugins_loaded
action.
use tangible\updater;
require_once __DIR__ . '/vendor/tangible/updater/index.php';
add_action('plugins_loaded', function() {
updater\register_plugin([
'name' => 'example-plugin',
'file' => __FILE__
]);
});
Register the plugin with its name and file path.
Optionally set the property cloud_id
to pass additional parameters to the update server.
updater\register_plugin([
'name' => $plugin->name,
'file' => __FILE__,
'cloud_id' => '', // Plugin ID (Required)
'api' => '', // Update API server's URL (Optional)
]
]);
This feature requires a plugin to be registered with the Framework module, which adds a plugin settings page.
The plugin needs to register a settings tab for the user to enter a license key. The saved value is passed in the request to the update server.
use tangible\framework;
use tangible\updater;
$plugin = framework\register_plugin([ ... ]);
framework\register_plugin_settings($plugin, [
'tabs' => [
'license' => [
'title' => 'License',
'callback' => function($plugin) {
updater\render_license_page($plugin);
}
],
],
]);
Prerequisites: Git, Node, Docker
Clone project and install dependencies.
git clone https://github.com/tangibleinc/updater
cd updater
npm install
Optionally, install dev dependencies for testing.
npm run install:dev
To keep them updated, run:
npm run update:dev
Start local dev server for WordPress test site using wp-env
.
npm run start
When running the first time, install Composer dev dependencies for testing.
npm run composer:install
Run tests.
npm run test
Stop the server.
npm run stop
Remove Docker images and volumes for the sites.
npm run destroy
Create a file named .wp-env.override.json
to customize the WordPress environment. This file is listed in .gitignore
so it's local to your setup.
It's useful for changing the site port numbers or mounting local folders into the virtual file system. For example, to link another plugin in the parent directory:
{
"mappings": {
"wp-content/plugins/example-plugin": "../example-plugin"
}
}