";
_e("HubbleSite Daily Image Widget was unable to retrieve new data from HubbleSite.", "hubblesite-daily-image-widget");
_e("The widget will appear as empty in your site until data can be downloaded again.", "hubblesite-daily-image-widget");
echo "
";
}
function _get_from_data_source() {
return @file_get_contents($this->data_source);
}
function _load_data() {
if (($result = $this->_get_cached_data()) === false) {
if (($xml_text = $this->_get_from_data_source()) !== false) {
if (($result = $this->parse_xml($xml_text)) !== false) {
update_option('hubblesite-daily-image-cache', array(time(), $result));
return true;
}
}
return false;
} else {
return true;
}
}
function handle_post() {
if (isset($_POST['hubblesite']['_wpnonce'])) {
if (wp_verify_nonce($_POST['hubblesite']['_wpnonce'], 'hubble')) {
$options = array();
foreach ($this->_valid_options as $option => $label) {
if (isset($_POST['hubblesite'][$option])) {
$options[] = $option;
}
}
$this->display_options = $options;
update_option('hubblesite-daily-image-options', implode(",", $this->display_options));
}
}
}
/**
* Get the list of display options from the WordPress options database.
*/
function get_display_options() {
$display_options = get_option('hubblesite-daily-image-options');
$this->display_options = array();
if (!empty($display_options)) {
$this->display_options = array_intersect(explode(",", $display_options), array_keys($this->_valid_options));
}
if (empty($this->display_options)) {
$this->display_options = $this->default_display_options;
}
update_option('hubblesite-daily-image-options', implode(",", $this->display_options));
return $this->display_options;
}
/**
* Render the widget.
*/
function render() {
if (!empty($this->data) && is_array($this->data)) {
$options = $this->get_display_options();
echo '