2017 © Pedro Peláez
 

library customupdater

An helper component for managing themes and plugin updates

image

wbf/customupdater

An helper component for managing themes and plugin updates

  • Thursday, September 28, 2017
  • by Waga Dev
  • Repository
  • 3 Watchers
  • 0 Stars
  • 4 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Custom Updater

This component enable developers to update themes and plugins from custom servers., (*1)

Custom Theme Updater

Thanks to Theme_Updater_Checker class it is possible to update theme through custom endpoint., (*2)

Getting started

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 slug
  • version: the theme version
  • download_url: the url of the theme package (a zip file
  • details_url: the url of the theme changelog \ additional information

After 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");

Block updates

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...
    }
}

The Versions

28/09 2017

dev-master

9999999-dev http://www.waga.it

An helper component for managing themes and plugin updates

  Sources   Download

GPL-2.0+

The Requires