PHP code example of blackbricksoftware / wp-artifact-updater
1. Go to this page and download the library: Download blackbricksoftware/wp-artifact-updater library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
blackbricksoftware / wp-artifact-updater example snippets
use BlackBrickSoftware\WpArtifactUpdater\V1\{Updater, BitbucketDownloads};
Updater::register([
'plugin_file' => __FILE__,
'source' => new BitbucketDownloads('acme/my-plugin'),
'artifact' => '/^my-plugin-v?(\d+\.\d+\.\d+)\.zip$/',
'authorization' => static fn(): string => defined('MY_PLUGIN_UPDATE_AUTH')
? 'Bearer ' . MY_PLUGIN_UPDATE_AUTH
: '',
]);
* Update URI: https://bitbucket.org/acme/my-plugin
'authorization' => static fn(): string => 'Bearer ' . $token, // Bitbucket/GitHub token
'authorization' => static fn(): string => 'Basic ' . base64_encode("$user:$pass"), // Bitbucket app password
'authorization' => static fn(): string => '', // public repo, or updates off
'enabled' => static fn(): bool => !defined('COMPOSER_MANAGED_SITE'),
new BitbucketDownloads('workspace/repository') // private (default)
new BitbucketDownloads('workspace/repository', false) // public
'authorization' => static fn(): string => 'Bearer ' . MY_PLUGIN_UPDATE_TOKEN,
new GitHubReleases('owner/repository') // public (default)
new GitHubReleases('owner/repository', true) // private
'artifact' => '/^my-plugin\.zip$/', // version comes from the tag
$result = Updater::verify(new BitbucketDownloads('acme/my-plugin'), $header);
// ['ok' => false, 'status' => 401, 'message' => 'Bitbucket rejected the credential (401). …']
$updater->forceRecheck(); // then wp_update_plugins() really asks the host
src/
V1/ Source.php Updater.php BitbucketDownloads.php GitHubReleases.php