wp-update-server icon indicating copy to clipboard operation
wp-update-server copied to clipboard

Usage inside a WP plugin

Open mihaijoldis opened this issue 8 years ago • 3 comments

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

mihaijoldis avatar May 14 '16 12:05 mihaijoldis

The basic idea is pretty simple. The only things that you have to do are:

  1. Include loader.php.
  2. Create an instance of Wpup_UpdateServer. For example: $server = new Wpup_UpdateServer(home_url('/'))
  3. 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 avatar May 14 '16 18:05 YahnisElsts

@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?

froger-me avatar May 04 '18 17:05 froger-me

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.

YahnisElsts avatar May 05 '18 15:05 YahnisElsts