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

Usage inside a WP plugin #37

Open
mihaijoldis opened this issue May 14, 2016 · 3 comments
Open

Usage inside a WP plugin #37

mihaijoldis opened this issue May 14, 2016 · 3 comments
Labels

Comments

@mihaijoldis
Copy link

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

@YahnisElsts
Copy link
Owner

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.

@froger-me
Copy link

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

@YahnisElsts
Copy link
Owner

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.

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

No branches or pull requests

3 participants