WP Updatr allows you to offer automatic updates to your customers when using premium WordPress plugins and themes (or for any that aren't hosted on WordPress.org really).
This update script requires you to have registered an account on WP Updatr. This services allows you to offer updates without having to serve them off of your own server. It's also been made possible to release updates in under a minute - It's SUPER Easy!
Include the class.plugin-wp-updatr.php
file at the top of your plugin's core file.
if( !class_exists('WPUpdatrPlugins') ){
require_once plugin_dir_path( __FILE__ ).'class.plugin-wp-updatr.php';
}
Instantiate the WPUpdatrPlugins Class with your customer's $license_key
and $product_key
. Make use of namespacing to ensure that no conflicts arise between your plugin and others. Change myPluginAlias
to something unique to your plugin.
use WPUpdatrPlugins as myPluginAlias;
new myPluginAlias\WPUpdatrPlugins( $license_key, $product_key );
$license_key
- This key is created when a customer purchases or proceeds through the checkout process of your chosen integration (Woocommerce, Paid Memberships Pro, Easy Digital Downloads).
You will need to build in a 'Settings' or 'API Key' field in your plugin to store this value, where your customer can enter in their API key.
The easiest steps would be to save it in an update_option
so that you initialize the code as follows:
use WPUpdatrPlugins as myPluginAlias;
new myPluginAlias\WPUpdatrPlugins( get_option( 'myplugin_api_key' ), $product_key );
$product_key
- This key is created when you create a product in the WP Updatr Dashboard on the Products Page.
This value will be hard coded and should not be changed once your plugin is released to your customers. This key is prefixed with ELP-
and will look similar to this:
use WPUpdatrPlugins as myPluginAlias;
new myPluginAlias\WPUpdatrPlugins( get_option( 'myplugin_api_key' ), 'ELP-' );
Include the below snippet in your theme's functions.php
file. The $api_key
and $product_key
variables will function the same as when used in a plugin.
use WPUpdatrThemes as myThemeAlias;
function my_wp_updatr_theme_license() {
require( get_stylesheet_directory() . '/class.theme-wp-updatr.php' );
/**
* $api_key - Customer API Key they receive after making a purchase
* $product_key - Obtained from your WP Updatr Dashboard for that specific product
*/
$theme = new myThemeAlias\WPUpdatrLicenseControlThemes( $api_key, $product_key );
// $license = $theme->verify_license();
}
add_action( 'after_setup_theme', 'my_wp_updatr_theme_license' );
Run a test purchase through your website to obtain a customer API key for yourself. Include that in your plugin's API key field and set your product API key.
To verify if your API key is valid and paired to the correct product, run the following:
use WPUpdatrPlugins as myPluginAlias;
$license = new myPluginAlias\WPUpdatrPlugins( get_option( 'myplugin_api_key`, 'ELP-' );
$object = $license->verify_license();
var_dump($object);
$object
returns an object on success. null
on error.
WP Updatr offers a variety of plans to suit the needs of all businesses.
Starter | Plus | Professional |
---|---|---|
Up to 200 Licenses | Up to 1 000 Licenses | 1 000+ Licenses |
Unlimited Products | Unlimited Products | Unlimited Products |
Unlimited Updates | Unlimited Updates | Unlimited Updates |
Comprehensive Reporting | Comprehensive Reporting | Comprehensive Reporting |
For queries related to the WP Updatr service, please get in touch with us directly.
For any issues or questions related to the update scripts, feel free to open an issue and we'll address it ASAP.