dev-master
9999999-dev http://www.waga.itAn helper component for managing themes and plugin updates
GPL-2.0+
The Requires
by Waga Team
Wallogit.com
2017 © Pedro Peláez
An helper component for managing themes and plugin updates
This component enable developers to update themes and plugins from custom servers., (*1)
Thanks to Theme_Updater_Checker class it is possible to update theme through custom endpoint., (*2)
Before implementing the update mechanism in WordPress you need an endpoint which respond with data in json format. That JSON must contain at least four information:, (*3)
theme: the theme slugversion: the theme versiondownload_url: the url of the theme package (a zip filedetails_url: the url of the theme changelog \ additional informationAfter this is inital setup, the implementation is just an one-liner:, (*4)
/**
* Manage Update Server
*/
function set_update_server(){
$tup = new Theme_Update_Checker("my-theme","my-endpoint");
}
add_action("init", "set_update_server");
It is possible to block updates (if you sell licenses for example) by hooking at "wbf/custom_theme_updater/can_update", (*5)
add_filter("wbf/custom_theme_updater/can_update", "disallow_updates", 10, 2);
function disallow_updates($can_update, Theme_Update_Checker $checker){
if(<some_reason>){
$can_update = false;
}
return $can_update;
}
By this way the update notice will still be visible, but the update process will return an error., (*6)
You could show a notice to better explain this error:, (*7)
add_action("wbf/custom_theme_updater/after_update_inject", "update_notice"], 10, 2);
function update_notice(Theme_Update_Checker $checker, $can_update){
if(!$can_update){
//Display the notice...
}
}
An helper component for managing themes and plugin updates
GPL-2.0+