Jump to content
Sign in to follow this  

CA "API" for plugin update checks

1 post in this topic Last Reply

Recommended Posts

Posted (edited)

Not really an API, but with the release of CA versions 2019.03.27+,  I'm making available to any plugin a function to toss up a banner if the plugin is out of date 


This is not a replacement for the built-in plugin update notification system, but an extension of it.  The banner only appears when the user is on the .page file for a plugin, and the check runs in the background so as to not interfere / slowdown any other scripts you may be running  (Side effect is that this banner is less disturbing on CA's own page when an update becomes available than it's previous banner used for this purpose)




All a plugin dev has to do is add in the following code to their page file to utilize this at the basic level.  

$(function() {
  if ( typeof caPluginUpdateCheck === "function" ) {

However, since not all plugins have their own page and are rather inserted as tabs into an existing page, then the option exists to specify a div to place the upgrade notice instead to only have it appear on their own tab (ie: the main page for UD)



$(function() {
  if ( typeof caPluginUpdateCheck === "function" ) {
<div class='pluginUpdate'></div>


The complete usage is as follows:


Options are as follows

name: string /* name of the plugin - if not present, defaults to fileNameOfPlg  - Recommended to use*/
element: DOM element/class /* if present, the banner shows up in whatever div you specify */
noDismiss: true | false /* if true, then the dismiss "x" will not appear - defaults to false */
dontShow: true | false /* if true, then the banner will not appear under any circumstance - defaults to false, only useful when using callbacks */
debug: true | false /* forces the banner to always show - defaults to false */

The callback function if present is passed a JSON string of
  updateAvailable: true | false,
  version: "version of update",
  min: "minimum OS version that the update requires",
  changes: "the changelog from the update",
  installedVersion: "currently installed version"

The callback function allows you to do whatever you want with the information provided - I use the callback on many of my plugins to have the currently installed version displayed somewhere on the page if some one has problems and posts a screenshot

caPluginUpdateCheck("community.applications.plg",{noDismiss:true,name:"Community Applications"},function(data) {
  if (data) {
    var result = JSON.parse(data);




The code snips will NOT cause any problems if CA is not installed, or if it hasn't been updated (ie: the test for if the function exists)


If the plugin's minimum OS version specified is greater than the currently installed OS version, then the updateAvailable will always be false, and the banner will not appear



This function is not dependent upon plugin update checks being enabled in unRaid, nor a check for updates ever having been performed by the user.  The results are always live, and are only performed when hitting the page file for the plugin in question.


The banner shares the same real-estate with unRaid's own OS update available banner, but it's z-index is lower so if an OS update is available concurrently, then the OS banner will always take precedence.


Dismissing of updates is handled via a cookie that expires when the user's browser session closes.  But, if the banner is dismissed and another update becomes available then the banner will reappear.


Edited by Squid

Share this post

Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this