Closed hupe13 closed 5 months ago
There's not an easy way to do that. I think the best option might be to use the puc_api_error
action and inspect the arguments to see if it's the kind of error that you care about. This action receives one to four arguments:
WP_Error
instance describing the error. This could be a custom error, or an error object returned by wp_remote_get()
.wp_remote_get()
. Will be null
if wp_remote_get()
returned a WP_Error
. Can be omitted entirely if the error being reported is not an HTTP error. For example, puc_api_error
is also triggered for some parsing errors.All arguments beyond the first one are optional. Note that even the last one (slug) can be omitted in certain cases.
The request is already done, I would like to detect the error 403. I searched puc_api_error
in the issues and found this function and used it. Maybe the code is not optimal, but it works (I hope).
FYI, if the HTTP response is available, you might be able to get the code easier by using wp_remote_retrieve_response_code()
.
Cool! Thank you very much!
You should write add_action( 'puc_api_error', .... )
in the documentation.
My WordPress installations are on shared hosting. PUC works on one, but not on the other because of the limit. You need a token.
If you need a token and don't have one, every check to Github fails and you get an error: 403. puc-github-http-error Is it possible to check this and ask the user to configure a token? I have such a setting in my plugin, but how can I detect if the user needs a token to access Github?
Thank you very much.