Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension for packages list #110

Open
KingMac21 opened this issue Jul 5, 2023 · 4 comments
Open

Extension for packages list #110

KingMac21 opened this issue Jul 5, 2023 · 4 comments

Comments

@KingMac21
Copy link

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.

@ddur
Copy link

ddur commented Jul 5, 2023

How about to try another repository? See link below.

https://github.com/YahnisElsts/wp-update-server-stats

@KingMac21
Copy link
Author

How about to try another repository? See link below.

https://github.com/YahnisElsts/wp-update-server-stats

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.

@YahnisElsts
Copy link
Owner

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.

@KingMac21
Copy link
Author

Thank you very much! I will work on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants