PHP code example of soderlind / wordpress-github-updater
1. Go to this page and download the library: Download soderlind/wordpress-github-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/ */
soderlind / wordpress-github-updater example snippets
use Soderlind\WordPress\GitHubUpdater;
GitHubUpdater::init(
github_url: 'https://github.com/username/plugin-name',
plugin_file: __FILE__,
plugin_slug: 'plugin-name',
name_regex: '/plugin-name\.zip/',
branch: 'main',
check_period: 6, // Hours between checks (default: 6)
auth_token: '', // Optional GitHub token
);
\Soderlind\WordPress\GitHubUpdater::init(
'https://github.com/username/plugin-name',
__FILE__,
'plugin-name',
'/plugin-name\.zip/',
'main',
6, // check_period
'' // auth_token
);
GitHubUpdater::init(
github_url: 'https://github.com/username/private-plugin',
plugin_file: __FILE__,
plugin_slug: 'private-plugin',
auth_token: defined('MY_PLUGIN_GITHUB_TOKEN') ? MY_PLUGIN_GITHUB_TOKEN : '',
);
\Soderlind\WordPress\GitHub_Plugin_Updater::create(
'https://github.com/username/plugin-name',
__FILE__,
'plugin-name',
'main',
6, // check_period
'' // auth_token
);
\Soderlind\WordPress\GitHub_Plugin_Updater::create_with_assets(
'https://github.com/username/plugin-name',
__FILE__,
'plugin-name',
'/plugin-name\.zip/',
'main',
6, // check_period
'' // auth_token
);
// Autoloaded via Composer
use Soderlind\WordPress\GitHubUpdater;
GitHubUpdater::init(
github_url: 'https://github.com/owner/repo',
plugin_file: __FILE__,
plugin_slug: 'my-plugin',
name_regex: '/my-plugin\.zip/',
branch: 'main',
check_period: 6,
);
GitHubUpdater::init(
github_url: 'https://github.com/username/private-repo',
plugin_file: __FILE__,
plugin_slug: 'private-plugin',
auth_token: MY_GITHUB_TOKEN,
);