Skip to content

Instantly share code, notes, and snippets.

@shabayekdes
Created December 5, 2021 18:33
Show Gist options
  • Save shabayekdes/70ea78517a9388d96eac0b4159898864 to your computer and use it in GitHub Desktop.
Save shabayekdes/70ea78517a9388d96eac0b4159898864 to your computer and use it in GitHub Desktop.
Allow localhost http requests
<?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