Class Name:
MP_CORE_Plugin_Updater
Purpose:
To keep plugins up to date when new versions are released.
Overview:
This class will check if there are new versions available for a plugin from a custom repository such as EDD Software Licensing or the MP Repo plugin.. When a new version becomes available, it will display a notice on the updates page of WordPress and allow the user to automatically install the update.
It also works for either free or licensed plugins. If it is a free plugin, it will automatically check for the update from the WordPress Plugin repo first. If it is not available there, it will check at the API URL defined.
If it is a paid/licensed plugin, it will give the user a place to input their license and only check for new updates if the license is valid.
Notes:
This class is designed to be used in conjunction with the MP Repo plugin being installed on an external URL. From there, it will serve up the updates.
Usage:
new MP_CORE_Plugin_Updater($args);
Parameters:
$args (array)
Sample Code:
function myplugin_update() { $args = array( 'software_name' => 'My Plugin', //The exact name of this Plugin. 'software_api_url' => 'http://mywebsite.com',//The URL where EDD and mp_repo are installed 'software_filename' => 'myplugin.php', //The filename of the plugin 'software_licensed' => false, //Boolean. If true, the user must have a valid license. ); $my_plugin_updater = new MP_CORE_Plugin_Updater($args); } add_action( 'init', 'myplugin_update' );
Args:
- software_name (string) – The exact name of this plugin. This should also be set up with the same name in the MP Repo plugin on your API URL and in EDD
- software_api_url (string) – The URL where MP Repo is installed.
- software_filename (string) – The filename of the main plugin file.
- software_licensed (boolean) – If true, the user must have a valid license. If false, the plugin updates will be free and check without a license.