diff --git a/.gitignore b/.gitignore index 915b330..1b4c1b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,6 @@ .DS_Store *~ - +.settings +.project +.buildpath +coverage diff --git a/classes/DailyImageWidget.php b/classes/DailyImageWidget.php index 4d1d416..d608480 100644 --- a/classes/DailyImageWidget.php +++ b/classes/DailyImageWidget.php @@ -4,6 +4,8 @@ * Show a HubbleSite daily image as a widget. */ class DailyImageWidget { + var $display_options = array(); + /** * Initialize the widget. * For unit testing purposes, you can disable remote data loading by passing true to this function. @@ -14,24 +16,24 @@ class DailyImageWidget { 'title', 'image' ); - + $this->_cache_time = 86400; $this->_source_stamp = "&f=wpw"; $this->data_source = "http://hubblesite.org/gallery/album/daily_image.php"; - + $this->has_simplexml = class_exists('SimpleXMLElement'); - + $this->_valid_column_names = array('title', 'date', 'image_url', 'gallery_url', 'credits'); $this->_valid_options = array( "image" => __("Daily Image", "hubblesite-daily-image-widget"), "title" => __("Image Title", "hubblesite-daily-image-widget"), "credits" => __("Credits", "hubblesite-daily-image-widget") ); - + add_action('init', array($this, "_init")); } - + /** * WordPress init hook. */ @@ -44,7 +46,7 @@ class DailyImageWidget { '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 (!$this->_load_data()) { @@ -53,11 +55,11 @@ class DailyImageWidget { } else { $this->data = false; } - + $this->handle_post(); $this->get_display_options(); } - + /** * Display a warning if the connection failed. */ @@ -67,7 +69,7 @@ class DailyImageWidget { _e("The widget will appear as empty in your site until data can be downloaded again.", "hubblesite-daily-image-widget"); echo ""; } - + /** * Wrapper around a remote data call for unit testing purposes. * @return string The data from the remote source. @@ -76,8 +78,8 @@ class DailyImageWidget { $response = wp_remote_request($this->data_source, array('method' => 'GET')); if (!is_wp_error($response)) { if (isset($response['body'])) { - return $response['body']; - } + return $response['body']; + } } return false; } @@ -129,7 +131,7 @@ class DailyImageWidget { 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; } @@ -138,16 +140,16 @@ class DailyImageWidget { return $this->display_options; } - + /** * Render the widget. * @param array $args The theme's widget layout arguments. */ - function render($args) { + function render($args = array()) { if (!empty($this->data) && is_array($this->data)) { extract($args); $options = $this->get_display_options(); - + echo $before_widget; echo $before_title; echo "HubbleSite Daily Image"; @@ -157,7 +159,7 @@ class DailyImageWidget { echo '' . $this->data['title'] . ''; echo ''; } - + if (in_array("title", $options)) { echo ''; echo $this->_fix_widows($this->data['title']); @@ -169,10 +171,10 @@ class DailyImageWidget { echo $this->_fix_widows($this->data['credits']); echo ''; } - echo $after_widget; + echo $after_widget; } } - + /** * Render the widget admin UI. */ @@ -181,7 +183,7 @@ class DailyImageWidget { echo "

"; _e("Show on Widget (must select at least one):", "hubblesite-daily-image-widget"); echo "

"; - + foreach ($this->_valid_options as $option => $label) { echo "
this is fixed", "this is fixed"), array("word", "word"), array("

this is fixed

Also fixed

", '

this is fixed

Also fixed

') - ); + ); } - + /** * @dataProvider providerTestWidowProtection */ @@ -322,4 +321,4 @@ class DailyImageWidgetTest extends PHPUnit_Framework_TestCase { } } -?> \ No newline at end of file +?>