Created
September 7, 2017 06:20
WordPress annoying issue, while working locally using http api you keep getting "A valid URL was not provided", or using functions such as "wp_safe_remote_request,wp_safe_remote_get or wp_safe_remote_post" and you are unable to request local website and you are not sure why its not working, because same code work on live.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: Allow localhost http requests. | |
* Plugin URI: https://gist.github.com/saas786/a567363477df7e28b0c1df6295cadf75/ | |
* Description: Note: Please don't use it on live website. If you are working locally, sometimes you get errors such as "A valid URL was not provided" or such, specially when you are interacting with website which is also hosted locally, so it becomes annoying at times to find the cause, and most of the time its wp_safe_remote_request, wp_safe_remote_get or wp_safe_remote_post functions who are the culprit. So this plugin is a quick fix. | |
* Author: saas786 | |
* Version: 0.1 | |
*/ | |
add_filter( 'http_request_host_is_external', 'wplr_http_request_host_is_external' ); | |
function wplr_http_request_host_is_external(){ | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment