'hebcal-shabbat', 'description' => 'displays Shabbat candle lighting times for a USA zip code or world city'); /* Widget control settings. */ $control_ops = array('width' => 200, 'height' => 200, 'id_base' => 'hebcal-shabbat-widget'); /* Create the widget. */ $this->WP_Widget('hebcal-shabbat-widget', 'Hebcal Shabbat Times', $widget_ops, $control_ops); } /** * How to display the widget on the screen. */ function widget($args, $instance) { extract($args); /* Our variables from the widget settings. */ $title = apply_filters('widget_title', $instance['title']); $ashkenazis_checked = isset($instance['a']) ? $instance['a'] : false; $ashkenazis = $ashkenazis_checked ? 'on' : 'off'; $out = ''; include('simple_html_dom.php'); $html = new simple_html_dom(); $html->load_file('http://www.hebcal.com/shabbat/?geo=zip;zip=44122'); foreach( $html->find('.candles') as $candle) { if (preg_match("/(.*)friday(.*)/i",$candle)) { $candlestring = $candle; } } $havdalah = $html->find('.havdalah', 0); echo $before_widget; echo $before_title, $title, $after_title; if ($instance['candles']) {echo $candlestring;} if ($instance['havdalah']) {echo $havdalah;} echo "

"; /* echo $out; */ echo $after_widget; } /** * Update the widget settings. */ function update($new_instance, $old_instance) { $instance = $old_instance; /* Strip tags for title and name to remove HTML (important for text inputs). */ $instance['title'] = strip_tags($new_instance['title']); $instance['zip'] = strip_tags($new_instance['zip']); $instance['m'] = $new_instance['m']; $instance['a'] = $new_instance['a']; $instance['candles'] = $new_instance['candles']; $instance['havdalah'] = $new_instance['havdalah']; return $instance; } /** * Displays the widget settings controls on the widget panel. * Make use of the get_field_id() and get_field_name() function * when creating your form elements. This handles the confusing stuff. */ function form($instance) { /* Set up some default widget settings. */ $defaults = array('zip' => '90210', 'm' => '72'); $instance = wp_parse_args((array) $instance, $defaults); ?>

id="get_field_id('a'); ?>" name="get_field_name('a'); ?>" />

id="get_field_id('candles'); ?>" name="get_field_name('candles'); ?>" />

id="get_field_id('havdalah'); ?>" name="get_field_name('havdalah'); ?>" />