Giter VIP home page Giter VIP logo

Comments (11)

sharmashivanand avatar sharmashivanand commented on September 24, 2024

A check is in order:

===
if ( get_query_var('action') ) {
$server->handleRequest();

from wp-update-server.

YahnisElsts avatar YahnisElsts commented on September 24, 2024

When using the server as part of a plugin, you're not supposed to just run it blindly. You need to verify the necessary parameters and pass them to the handleRequest() method. Take a look at the example code in the readme. It does check if the action is specified before calling the server:
https://github.com/YahnisElsts/wp-update-server#running-the-server-from-another-script

from wp-update-server.

sharmashivanand avatar sharmashivanand commented on September 24, 2024

I think it's best to update the index.php with the same.

from wp-update-server.

YahnisElsts avatar YahnisElsts commented on September 24, 2024

I disagree. index.php is the entry point for the stand-alone version of the server. Do you really want it to fail silently if some of the parameters are missing? That would make setup and debugging more difficult.

from wp-update-server.

steeevio avatar steeevio commented on September 24, 2024

I'm trying to use the sample code for a wordpress plugin from here https://github.com/YahnisElsts/wp-update-server - but I keep getting an error when checking for updates "Could not determine if updates are available for SJEV Test plugin. Failed to parse update metadata. Try validating your .json file with http://jsonlint.com/ puc-invalid-json"

Any ideas what could be causing this?

Thanks

from wp-update-server.

YahnisElsts avatar YahnisElsts commented on September 24, 2024

Try opening the metadata URL in your browser. What does the page say, if anything?

from wp-update-server.

steeevio avatar steeevio commented on September 24, 2024

how would I get the metadata url?

from wp-update-server.

YahnisElsts avatar YahnisElsts commented on September 24, 2024

Presumably, you already have it. It's the URL that you pass to the buildUpdateChecker() method.

from wp-update-server.

steeevio avatar steeevio commented on September 24, 2024

Oh I see, thanks! So it seems that my problem is that none of the wordpress functions are available when I access it with the url in this way. For example I get "Fatal error: Call to undefined function home_url() in /home/encoremedia/public_html/wp-content/plugins/sjev_plugin-server/sjev_plugin-server.php on line 31"

from wp-update-server.

YahnisElsts avatar YahnisElsts commented on September 24, 2024

It sounds like you might be accessing plugin PHP files directly instead of going through WordPress. You can do that - I've done it myself as a way to improve performance - but then you have to carefully design your plugin so that it works both inside WP and as a stand-alone script.

Are you sure you're using the right URL? When embedding the server in a plugin, the URL would typically be something like this:
https://example.com/?your_action_param=get_metadata&your_slug_param=plugin-slug

On the other hand, this would be incorrect:
https://example.com/wp-content/plugin-name/plugin-name.php?action=get_metadata&slug=plugin-slug

from wp-update-server.

steeevio avatar steeevio commented on September 24, 2024

That is exactly what I was doing! I had it working as a standalone script before and didn't update the url in the plugin. Thanks very much for your help. Working perfectly now.

from wp-update-server.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.