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