Extension for packages list
Opened this issue · 4 comments
Good morning,
I would like to add a function to the server, I'm pretty handy with PHP, but I would need some initial help. I would like the server to create a custom file with the list of plugins / themes it handles reporting their respective versions.
Something like this:
pluginOne -> '1.0.5'
pluginTwo -> '3.6.2'
With a request similar to:
SERVER_URL/?action=get_list | get_pluginList | get_packagesList
Any ideas on where to start?
Thank you very much.
How about to try another repository? See link below.
How about to try another repository? See link below.
Thanks for the link, I did not know that repository. From what I've seen it does statistics on Downloads. I, on the other hand, would like to have "a page" where I am shown the versions of all the packages that the server manages.
You would probably need to create a subclass of Wpup_UpdateServer
.
To add a new action, you could override the Wpup_UpdateServer::dispatch()
method. Something simple like this would probably work:
if ($request->action === 'get_package_list') {
/* your custom logic here */
} else {
parent::dispatch($request);
}
There's no built-in way to get all available packages, but you could just try listing all .zip
files in the $this->packageDirectory
directory.
To load and parse a specific package from $filename
(absolute file path):
//$slug should usually be the base file name without the path and the ".zip" extension.
$package = call_user_func($this->packageFileLoader, $filename, $slug, $this->cache);
Get the version number from a package:
$meta = $package->getMetadata();
$version = $meta['version'];
Finally, to output your custom response, you can just call $this->outputJson($whatever)
and then exit
.
Thank you very much! I will work on it.