PHP code example of webshr / wp-update-sdk
1. Go to this page and download the library: Download webshr/wp-update-sdk 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/ */
webshr / wp-update-sdk example snippets
use Webshr\WpUpdateSdk\Updater;
/**
* Plugin Name: My Plugin
* Version: 1.0.0
* Update URI: https://updates.example.com/metadata/my-plugin
*/
use Webshr\WpUpdateSdk\Updater;
' => '1.0.0',
'type' => 'plugin',
],
);
$updater->settings()->add_page( [
'type' => 'submenu',
'parent_slug' => 'options-general.php',
'page_title' => 'My Plugin Updates',
'menu_title' => 'My Plugin Updates',
'menu_slug' => 'my-plugin-updates',
] );
$updater->run();
$updater = new Updater(
'my-plugin',
'https://updates.example.com',
[
'project' => 'my-plugin/my-plugin.php', // Plugin file or theme stylesheet.
'version' => '1.0.0',
'type' => 'plugin', // plugin or theme.
'option_prefix' => 'wp_update_sdk', // Optional.
],
);
use Webshr\WpUpdateSdk\Updater;
ter = new Updater(
get_stylesheet(),
'https://updates.example.com',
[
'project' => get_stylesheet(),
'version' => $theme->get( 'Version' ),
'type' => 'theme',
],
);
$updater->settings()->add_page( [
'type' => 'submenu',
'parent_slug' => 'themes.php',
'page_title' => 'Theme Updates',
'menu_title' => 'Theme Updates',
'menu_slug' => get_stylesheet() . '-updates',
] );
$updater->run();
$result = $updater->license()->activate( 'CUSTOMER-LICENSE-KEY' );
if ( is_wp_error( $result ) ) {
wp_die( esc_html( $result->get_error_message() ) );
}
if ( defined( 'MY_PLUGIN_LICENSE_KEY' ) && '' !== MY_PLUGIN_LICENSE_KEY ) {
$updater->license()->set_key( MY_PLUGIN_LICENSE_KEY );
}
$updater->license()->check();
$updater->license()->deactivate();
$updater->settings()->add_page( [
'type' => 'menu', // menu, submenu, or options
'page_title' => 'Updates',
'menu_title' => 'Updates',
'capability' => 'manage_options',
'menu_slug' => 'my-product-updates',
] );
$updater->settings()->add_page( [
'type' => 'submenu',
'parent_slug' => 'my-plugin',
'page_title' => 'Updates',
'menu_title' => 'Updates',
'menu_slug' => 'my-plugin-updates',
] );
$updater->set_channel( 'beta' );
echo $updater->metadata_url();