wp-update-server
wp-update-server copied to clipboard
Usage inside a WP plugin
Sorry for noobish question but i'm unclear on how to "load" the server inside a wordpress plugin.
I have checked the main readme on how to do it but i'm confused on what the 2 functions you posted do and what other functions will be needed
The basic idea is pretty simple. The only things that you have to do are:
- Include
loader.php
. - Create an instance of
Wpup_UpdateServer
. For example:$server = new Wpup_UpdateServer(home_url('/'))
- Call the
$server->handleRequest($queryParameters)
method at some point.
Step 3 might be trickier than the others. You probably don't want the update server to handle every request sent to your WordPress site. Personally, I check $_GET
for a specific query parameter and call handleRequest
only when it looks like the current request is update-related.
@YahnisElsts Somehow related:
- why a library and not an actual plugin?
- is it because it uses code that would be incompatible license-wise?
- If not, if one were to make a plugin integrating the library, obviously including credits and licenses, and publishing it on wordpress.org, what would be your reaction?
why a library and not an actual plugin?
It's more flexible this way. It's also easier to write since I don't have to worry about the compatibility hell that is a WordPress site. Finally, performance is much better when you run this as a stand-alone script.
That last factor - i.e. performance - is particularly important to me personally. I have a site that handles about 150 000 update API requests per day. In stand-alone mode, response time and server load are very reasonable. Running it as a plugin and adding WordPress overhead to every request more than quadruples response time. My VPS might just fall over if I did that.
is it because it uses code that would be incompatible license-wise?
I haven't thought about that much. All I can say that is that it wasn't a major consideration when starting this project.
If not, if one were to make a plugin integrating the library, obviously including credits and licenses, and publishing it on wordpress.org, what would be your reaction?
As long as you comply with the license(s), I have no objection.