PHP code example of avelpress / updater

1. Go to this page and download the library: Download avelpress/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/ */

    

avelpress / updater example snippets


AvelPress::init( 'my-plugin', [
	'base_path' => __DIR__ . '/src',
	'updater'   => [
		// {slug} is replaced with the plugin id.
		'endpoint' => 'https://store.example.com/wp-json/v1/plugin/update',
	],
] );

'updater' => [
	'endpoint' => 'https://store.example.com/wp-json/v1/plugin/update',
	'auth'     => function () {
		return [ 'license_key' => get_option( 'my_plugin_license' ) ];
	},
	'headers'  => [ 'X-Site' => home_url() ], // optional
	'timeout'  => 15,                         // optional, seconds
],

add_action( 'plugins_loaded', function () {
	$updater = new \AvelPress\Update\PluginUpdater(
		new \AvelPress\Update\HttpUpdateProvider( 'https://store.example.com/wp-json/v1/plugin/update' ),
		plugin_basename( __FILE__ ), // e.g. my-plugin/my-plugin.php
		'my-plugin',                 // slug
		'1.2.0'                      // installed version
	);

	$updater->register();
} );