YahnisElsts / plugin-update-checker

A custom update checker for WordPress plugins. Useful if you don't want to host your project in the official WP repository, but would still like it to support automatic updates. Despite the name, it also works with themes.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Update download link does not work when masking the url

Yehi opened this issue · comments

commented

Hey,
I have a plugin that receives updates from a file on my server and it works great.
I use – https://github.com/YahnisElsts/plugin-update-checker
My problem is when I try to change the file link to a masked link the update fails. The link behaves like a downloadable file but in practice it fails.
for example:
https://example.com/download/file.zip – works great
https://example.com/wp-json/my-end-point/v1/download – does not work
I added the headers:

header("Content-Type: application/octet-stream");
header('Content-Type: application/zip');
header("Content-Transfer-Encoding: Binary");
header("Content-disposition: attachment; filename="file.zip"");
readfile('https://example.com/download/file.zip');
When you enter the link https://example.com/wp-json/my-end-point/v1/download, the file downloads properly through the browser.

The idea is that I can verify before downloading the file
How can I solve this?

Can you elaborate on "update fails"? Are there any error messages when that happens? Tip: If you see an update notification on the "Plugins" page, you can right-click the "update now" link and open it in a new tab to install the update in a way that will also display more information about the update process. Also, you could use something like Log HTTP Requests to see what response WordPress gets when it tries to download the update.

commented

found the problem,
There is actually no problem with the code.
The problem is that I send the request to the link of the same website. When I update the plugin, the site automatically goes to maintenance, so the API of that site is closed and the error is received.
When I do the update from another site, of course everything works fine.
problem solved

commented

@Yehi

found the problem, There is actually no problem with the code. The problem is that I send the request to the link of the same website. When I update the plugin, the site automatically goes to maintenance, so the API of that site is closed and the error is received. When I do the update from another site, of course everything works fine. problem solved

This may be the cause of my issue #489

I'm using endpoints API in my server implementation too.

Fix: When download is requested from same site, just provide local path instead of link (see the issue above).