use wp http instead of rolling our own
This commit is contained in:
parent
a3331ffc41
commit
2395ce3472
@ -36,7 +36,14 @@ class DailyImageWidget {
|
||||
* WordPress init hook.
|
||||
*/
|
||||
function _init() {
|
||||
register_sidebar_widget(__("HubbleSite Daily Image", "hubblesite-daily-image-widget"), array(&$this, "render"));
|
||||
wp_register_sidebar_widget(
|
||||
'hubblesite-daily-image',
|
||||
__("HubbleSite Daily Image", "hubblesite-daily-image-widget"),
|
||||
array(&$this, "render"),
|
||||
array(
|
||||
'description' => __('Embed a daily HubbleSite Gallery image on your WordPress blog.', 'hubblesite-daily-image-widget')
|
||||
)
|
||||
);
|
||||
register_widget_control(__("HubbleSite Daily Image", "hubblesite-daily-image-widget"), array(&$this, "render_ui"));
|
||||
|
||||
if (!$skip_load_data) {
|
||||
@ -66,15 +73,13 @@ class DailyImageWidget {
|
||||
* @return string The data from the remote source.
|
||||
*/
|
||||
function _get_from_data_source() {
|
||||
if (extension_loaded('curl')) {
|
||||
$ch = curl_init($this->data_source);
|
||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
|
||||
$result = curl_exec($ch);
|
||||
curl_close($ch);
|
||||
return $result;
|
||||
} else {
|
||||
return @file_get_contents($this->data_source);
|
||||
$response = wp_remote_request($this->data_source, array('method' => 'GET'));
|
||||
if (!is_wp_error($response)) {
|
||||
if (isset($response['body'])) {
|
||||
return $response['body'];
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,7 +3,7 @@
|
||||
Plugin Name: HubbleSite Daily Image Widget
|
||||
Plugin URI: http://github.com/johnbintz/hubblesite-daily-image-wordpress/tree/master
|
||||
Description: The HubbleSite Daily Image Widget embeds a daily HubbleSite Gallery image on your WordPress blog.
|
||||
Version: 0.1
|
||||
Version: 0.1.1
|
||||
Author: John Bintz
|
||||
Author URI: http://hubblesite.org/
|
||||
|
||||
|
@ -2,8 +2,8 @@
|
||||
Contributors: stsci-opo, johncoswell
|
||||
Tags: widget, picture, image
|
||||
Requires at least: 2.7.1
|
||||
Tested up to: 2.8.2
|
||||
Stable tag: 0.1
|
||||
Tested up to: 2.8.4
|
||||
Stable tag: 0.1.1
|
||||
|
||||
The HubbleSite Daily Image Widget embeds a daily HubbleSite Gallery image on your WordPress blog.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user