diff --git a/classes/DailyImageWidget.php b/classes/DailyImageWidget.php
index 7ccc78b..61fca74 100644
--- a/classes/DailyImageWidget.php
+++ b/classes/DailyImageWidget.php
@@ -32,13 +32,14 @@ class DailyImageWidget {
} else {
$this->data = false;
}
-
- $this->display_options = $this->get_display_options();
}
function _init() {
register_sidebar_widget(__("HubbleSite Daily Image", "hubblesite-daily-image-widget"), array($this, "render"));
register_widget_control(__("HubbleSite Daily Image", "hubblesite-daily-image-widget"), array($this, "render_ui"));
+
+ $this->handle_post();
+ $this->get_display_options();
}
function _connection_warning() {
@@ -66,6 +67,21 @@ class DailyImageWidget {
}
}
+ 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.
*/
@@ -127,13 +143,14 @@ class DailyImageWidget {
}
function render_ui() {
+ echo "";
echo "
";
- _e("Show on Widget:", "hubblesite-daily-image-widget");
+ _e("Show on Widget (must select at least one):", "hubblesite-daily-image-widget");
echo "