PHP code example of oberonlai / wp-updater
1. Go to this page and download the library: Download oberonlai/wp-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/ */
oberonlai / wp-updater example snippets
use ODS\Updater;
$options = array( ... );
$books = new Updater( $options );
// Require the Composer autoloader.
er;
$updater = new Updater( array(
'plugin_slug' => 'my-plugin',
'version' => '1.0.0',
'json_url' => 'https://mydomain.com/my-plugin.json',
));
$updater = new Updater( array(
'plugin_slug' => 'my-plugin',
'version' => '1.0.0',
'json_url' => 'https://mydomain.com/my-plugin-validate.php',
'license' => get_option( 'my-plugin_license_key' ),
));
$array = array(
"name" => "My Plugin",
"slug" => "my-plugin",
"author" => "<a href='https://mydomain.com/my-plugin/'>Author</a>",
"author_profile" => "https://mydomain.com",
"version" => "1.0.1",
"=> "My plugin description",
"installation" => "My plugin installation",
"changelog" => "<p>v1.0.1</p><p>Change log</p>"
),
"banners" => array(
"low" => "https://mydomain.com/my-plugin-banner-low.jpg",
"high" => "https://mydomain.com/my-plugin-banner-high.jpg"
)
);
// no update is available by default
$update[ 'download_url' ] = '';
if( ! empty( $_GET['license_key' ] ) && license_check_logic( $_GET[ 'license_key' ] ) {
$update[ 'download_url' ] = 'pass the URL to plugin ZIP archive here';
}
...
header( 'Content-Type: application/json' );
echo json_encode( $update );
add_action('ods_updater_after_purge', function( $upgrader, $options ){
// do stuff when plugin updated.
});