Created
March 10, 2012 03:17
-
-
Save kurtpayne/2009924 to your computer and use it in GitHub Desktop.
Use wp_remote_get instead of curl
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
Index: github_gist_wordpress_plugin.php | |
=================================================================== | |
--- github_gist_wordpress_plugin.php (revision 517091) | |
+++ github_gist_wordpress_plugin.php (working copy) | |
@@ -46,13 +46,12 @@ | |
} | |
function get_content_from_url($url) { | |
- $ch = curl_init(); | |
- curl_setopt($ch,CURLOPT_URL,$url); | |
- curl_setopt($ch,CURLOPT_RETURNTRANSFER,1); | |
- curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,1); | |
- $content = curl_exec($ch); | |
- curl_close($ch); | |
- return $content; | |
+ $response = wp_remote_get($url); | |
+ if( is_wp_error( $response ) ) { | |
+ return ''; | |
+ } else { | |
+ return $response['body']; | |
+ } | |
} | |
function gist_raw($id, $file) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment