<?php
/**
 * Plugin Name: Shabbat Zman Widget
 * Plugin URI: http://webdesign.adatosystems.com/shabbatzmanwidget/
 * Description: Enter your zipcode and select which options you want to see. 
 *   Uses the inimitable Hebcal.com site for parsha and other information, as well as Google Maps API for geographic and sunrise/sunset information.
 * Version: 1.0
 * Author: Leon Adato
 * Author URI: http://www.adatosystems.com/
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation,version 3
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   For details, see <http://www.gnu.org/licenses/>.
 */
class AdatoSystems_Zman_Widget extends WP_Widget {
	/**
	 * Widget setup.
	 */
	function AdatoSystems_Zman_Widget() {
		/* Widget settings. */
		$widget_ops = array('classname' => 'hebcal-shabbat',
				    'description' => 'displays various zmanim (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', 'AdatoSystems Zmanim', $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']);

// Show the love
$lovetext = "<br /><span style=\"font-size: small;\">Developed by <A HREF=\"http://www.adatosystems.com/\">AdatoSystems.com</a>.<br />Key features by <A HREF=\"http://www.hebcal.com\">Hebcal.com</a>.</span>";
// Set time display (seconds or no seconds)
if($instance['showseconds']) { $timedisplay = "g:i:s A"; } else { $timedisplay = "g:i A"; }

// Set transliteration style
if($instance['ashki']) {  
	$titleshabbat = "Shabbos";
	} else { 
	$titleshabbat = "Shabbat";
}

/* What day is Friday and Saturday*/
if(date('N')==5 || date('N')==6) {
	$friday = strtotime("now");
	$friday_txt = date("M d, Y", $friday);
} else {
	$friday = strtotime( "next friday" );
	$friday_txt = date("M d, Y", $friday );
}

if(date('N')!=6) {
	$saturday = strtotime( "next saturday" );
	$saturday_txt = date("Y-m-d", $saturday);
} else {
	$saturday = strtotime("now");
	$saturday_txt = date("Y-m-d", $saturday);
}

// Get Hebrew Date from HebCal
// more info: http://www.hebcal.com/home/219/hebrew-date-converter-rest-api
if($instance['hebdatetxt']) {
	$hebdate = file_get_contents("http://www.hebcal.com/converter/?cfg=json&gy=".date("Y",$friday)."&gm=".date("n",$friday)."&gd=".date("j",$friday)."&g2h=1");
	$hebdatejd = json_decode($hebdate,true);
	$hebengdate = $hebdatejd['hd']." ".$hebdatejd['hm'].", ".$hebdatejd['hy'];
	$hebhebdate = $hebdatejd['hebrew'];
	if($instance['hebdatetxt'] == "e") {$hebrewdate = $hebengdate; } 
	if($instance['hebdatetxt'] == "h") {$hebrewdate = $hebhebdate; } 
	if($instance['hebdatetxt'] == "b") {$hebrewdate = $hebengdate."<br />".$hebhebdate; } 
}

// Use the HebCal JSON for the hebrew elements (parsha hashavua, etc.)
// information here: http://www.hebcal.com/home/195/jewish-calendar-rest-api
if($instance['inisrael']) { $inisrael = "i=on"; } else { $inisrael = "i=off"; }
$hebcal = file_get_contents("https://www.hebcal.com/hebcal/?v=1&cfg=json&nh=off&nx=off&year=now&month=x&ss=off&mf=off&c=off&s=on&".$inisrael."&lg=".$instance['ptext']);
$hebcaljd = json_decode($hebcal,true);
foreach($hebcaljd['items'] as $hebstat => $hebitem) {
	foreach($hebitem as $stat=>$value) {
		if($hebitem['category'] == "parashat") {
			if($hebitem['date'] == $saturday_txt) {
				$parshaname = $hebitem['title'];
				if($instance['ptext'] == "sh" || $instance['ptext'] == "ah") {$parshaname = $parshaname." / ".$hebitem['hebrew']; }
			}
		}
	}
}

/* JSON get lat/long from zip using maps.googleapis.com */
$du = file_get_contents("http://maps.googleapis.com/maps/api/geocode/json?address=".$instance['zip']."&sensor=false");
$djd = json_decode(utf8_encode($du),true);
$long = $djd['results'][0]['geometry']['location']['lng'];
$lat = $djd['results'][0]['geometry']['location']['lat'];
$address = $djd['results'][0]['formatted_address'];

/* Get time offset for timzezone and DST using  maps.googleapis.com */
$tz = file_get_contents("https://maps.googleapis.com/maps/api/timezone/json?location=".$lat.",".$long."&timestamp=".$friday."&sensor=false");
$tzjd = json_decode(utf8_encode($tz),true);
$tzoffset = $tzjd['rawOffset'];
$dstoffset = $tzjd['dstOffset'];
$offset = $dstoffset+$tzoffset;
$tzname = $tzjd['timeZoneName'];

/* calculate sunrise and suset time */
$frisuninfo = date_sun_info($friday, $lat, $long);
$satsuninfo = date_sun_info($saturday, $lat, $long);
$frisunrise = date($timedisplay, $frisuninfo['sunrise']+$offset);
$frisunset = date($timedisplay, $frisuninfo['sunset']+$offset);
$satsunrise = date($timedisplay, $satsuninfo['sunrise']+$offset);
$satsunset = date($timedisplay, $satsuninfo['sunset']+$offset);

// Calculate Plag haMincha
if($instance['showplag']) {
	$sunrisesec = $frisuninfo['sunrise']+$offset;
	$sunsetsec = $frisuninfo['sunset']+$offset;
	if($instance['plagmethod'] == "gra") {
		$halachichour = ($sunsetsec - $sunrisesec)/12;
		$plaginseconds = $sunsetsec - ($halachichour*1.25);
		$plagtext = "Plag haMincha (GR''A) is ".date($timedisplay, $plaginseconds);
	} elseif ($instance['plagmethod'] == "avr") {
		$masunrise = $sunrisesec-($instance['plagrisemin']*60);
		$masunset = $sunsetsec+($instance['plagsetmin']*60);
		$halachichour = ($masunset - $masunrise)/12;
		$plaginseconds = $masunset - ($halachichour*1.25);
		$plagtext = "Plag haMincha (M''A) is ".date($timedisplay, $plaginseconds);
	} else {
		$plagtext = "Plag haMincha is unavailable";
	}
}

// Calculate Shema
if($instance['showshema']) {
	$sunrisesec = $frisuninfo['sunrise']+$offset;
	$sunsetsec = $frisuninfo['sunset']+$offset;
	if($instance['shemamethod'] == "gra") {
		$halachichour = ($sunsetsec - $sunrisesec)/12;
		$shemainseconds = $sunrisesec + ($halachichour*3);
		$shematext = "Latest Shema (GR''A) is ".date($timedisplay, $shemainseconds);
	} elseif ($instance['shemamethod'] == "avr") {
		$masunrise = $sunrisesec-($instance['shemarisemin']*60);
		$masunset = $sunsetsec+($instance['shemasetmin']*60);
		$halachichour = ($masunset - $masunrise)/12;
		$shemainseconds = $masunrise + ($halachichour*3);
		$shematext = "Latest Shema (M''A) is ".date($timedisplay, $shemainseconds);
	} else {
		$shematext = "Latest Shema is unavailable";
	}
}

// Calculate Candles & havdalah
if($instance['showcandles']) { $candletime = date($timedisplay, strtotime($frisunset)-($instance['cmin']*60 ) ); }
if($instance['showhavdalah']) {$havdalahtime = date($timedisplay, strtotime($satsunset)+($instance['m']*60) ); }

// Display the widget already!

	echo $before_widget;
	echo $before_title, $title, $after_title;
	echo "$titleshabbat Times for ".$friday_txt."<br />";
	if($instance['showparsha'] ) {echo $address."<br />"; }
		if($instance['debug'] ) { echo "Lat and Long is: ".$lat." and ".$long."<br />"; }
		if($instance['debug'] ) { echo "Time zone is ".$tzname.", tzoffset is ".$tzoffset.", dstoffset is ".$dstoffset." and offset is ".$offset."<br />"; }
		if($instance['debug'] ) { echo "saturday is ".$saturday_txt."<br />"; }
		if($instance['debug'] ) { echo $hebcaljd['link']."<br />"; }
		if($instance['debug'] ) { echo "Day of the week is ".date('N')."<br />"; }
	if($instance['hebdatetxt']) {echo $hebrewdate."<br />";}
	if($instance['showparsha'] ) {echo $parshaname."<br />"; }
		if($instance['debug'] ) { echo "timestamp: ".$friday." and friday_db is ".$friday_db." <br />"; }
	if($instance['showcandles'] ) {echo "Candle Lighting Time: ".$candletime."<br />"; }
	if($instance['showhavdalah'] ) {echo "Havdalah (".$instance['m']." min): ".$havdalahtime."<br />"; }
	if($instance['showsunrise'] ) {echo "Sunrise: ".$frisunrise."<br /> ";}
	if($instance['showfrisunset'] ) {echo "Sunset Friday: ".$frisunset."<br />";}
	if($instance['showsatsunset'] ) {echo "Sunset Saturday: ".$satsunset."<br />";}
	if($instance['showplag'] ) {echo $plagtext."<br />"; }
		if($instance['debug'] ) { echo "halachichour: ".$halachichour."<br />"; }
		if($instance['debug'] ) { echo "plaginseconds: ".$plaginseconds."<br />"; }	
	if($instance['showshema'] ) {echo $shematext."<br />"; }
	if($instance['love'] ) {echo $lovetext."<br />"; }
	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['ashki'] = $new_instance['ashki'];
		$instance['showlocation'] = $new_instance['showlocation'];
		$instance['showseconds'] = $new_instance['showseconds'];
		$instance['hebdatetxt'] = $new_instance['hebdatetxt'];
		$instance['showcandles'] = $new_instance['showcandles'];
		$instance['showparsha'] = $new_instance['showparsha'];		
		$instance['showhavdalah'] = $new_instance['showhavdalah'];
		$instance['showsunrise'] = $new_instance['showsunrise'];
		$instance['showfrisunset'] = $new_instance['showfrisunset'];
		$instance['showsatsunset'] = $new_instance['showsatsunset'];
		$instance['showplag'] = $new_instance['showplag'];
		$instance['m'] = $new_instance['m'];
		$instance['cmin'] = $new_instance['cmin'];
		$instance['ctime'] = $new_instance['ctime'];
		// $instance['cfixed'] = $new_instance['cfixed'];
		$instance['ptext'] = $new_instance['ptext'];
		$instance['inisrael'] = $new_instance['inisrael'];
		$instance['plagmethod'] = $new_instance['plagmethod'];
		$instance['plagrisemin'] = $new_instance['plagrisemin'];
		$instance['plagsetmin'] = $new_instance['plagsetmin'];
		$instance['showshema'] = $new_instance['showshema'];
		$instance['shemamethod'] = $new_instance['shemamethod'];
		$instance['shemarisemin'] = $new_instance['shemarisemin'];
		$instance['shemasetmin'] = $new_instance['shemasetmin'];
		$instance['love'] = $new_instance['love'];
		$instance['debug'] = $new_instance['debug'];
		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', 'cmin' => '18', 'plagmethod' => 'gra', 'shemamethod' => 'gra', 'ptext' => 's');
	  $instance = wp_parse_args((array) $instance, $defaults); ?>

		<!-- Title: Text Input -->
		<p>
			<label for="<?php echo $this->get_field_id('title'); ?>">Title:</label>
			<input id="<?php echo $this->get_field_id('title'); ?>" name="<?php echo $this->get_field_name('title'); ?>" value="<?php echo $instance['title']; ?>" />
		</p>

		<!-- Zip code and location options: Text Input -->
		<p>
			<label for="<?php echo $this->get_field_id('zip'); ?>">Zip code:</label>
			<input id="<?php echo $this->get_field_id('zip'); ?>" name="<?php echo $this->get_field_name('zip'); ?>" value="<?php echo $instance['zip']; ?>" size="5" maxlength="5" />
		</p>

		<p style="font-weight: bold; text-align: center;">General Display Choices:</p>
		<P>
		<input class="checkbox" type="checkbox" <?php if($instance['ashki' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('ashki'); ?>" name="<?php echo $this->get_field_name('ashki'); ?>" /> 
		<label for="<?php echo $this->get_field_id('ashki'); ?>">Ashkenazi Transliterations for Headings?</label><br />
		<input class="checkbox" type="checkbox" <?php if($instance['showlocation' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showlocation'); ?>" name="<?php echo $this->get_field_name('showlocation'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showlocation'); ?>">Show Location Information?</label><br />
		<input class="checkbox" type="checkbox" <?php if($instance['showseconds' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showseconds'); ?>" name="<?php echo $this->get_field_name('showseconds'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showseconds'); ?>">Show Seconds in Time displays?</label> <br />
				<input class="checkbox" type="checkbox" <?php if($instance['showsunrise' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showsunrise'); ?>" name="<?php echo $this->get_field_name('showsunrise'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showsunrise'); ?>">Show Sunrise?</label> <br />
		<input class="checkbox" type="checkbox" <?php if($instance['showfrisunset' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showfrisunset'); ?>" name="<?php echo $this->get_field_name('showfrisunset'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showfrisunset'); ?>">Show Friday Sunset?</label><br />
		<input class="checkbox" type="checkbox" <?php if($instance['showsatsunset' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showsatsunset'); ?>" name="<?php echo $this->get_field_name('showsatsunset'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showsatsunset'); ?>">Show Saturday Sunset?</label><br />
		&nbsp;&nbsp;Hebrew Date Display:<br />
		<input class="radio" type="radio" <?php if($instance['hebdatetxt']=="n") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('hebdatetxt'); ?>" value="n">Do not show Hebrew date<br />
		<input class="radio" type="radio" <?php if($instance['hebdatetxt']=="e") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('hebdatetxt'); ?>" value="e">Show Hebrew date in English<br />
		<input class="radio" type="radio" <?php if($instance['hebdatetxt']=="h") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('hebdatetxt'); ?>" value="h">Show Hebrew date in Hebrew<br />
		<input class="radio" type="radio" <?php if($instance['hebdatetxt']=="b") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('hebdatetxt'); ?>" value="b">Show Hebrew date in both<br />
		</p>

		<!-- Candle Lighting Options -->
		<p style="font-weight: bold; text-align: center;">Candlelighting &amp; Havdalah Choices:</p>
		<P>
		<input class="checkbox" type="checkbox" <?php if($instance['showcandles' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showcandles'); ?>" name="<?php echo $this->get_field_name('showcandles'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showcandles'); ?>">Show candle lighting time?</label><br />
		<label for="<?php echo $this->get_field_id('cmin'); ?>">Minutes before sunset:</label>&nbsp;
		<input id="<?php echo $this->get_field_id('cmin'); ?>" name="<?php echo $this->get_field_name('cmin'); ?>" value="<?php echo $instance['cmin']; ?>" size="2" maxlength="2" /><br />
<!-- 		<input class="radio" type="radio" <?php if($instance['ctime']=="cfixed") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('ctime'); ?>" value="cfixed" />Specific Time&nbsp;
		<input id="<?php echo $this->get_field_id('cfixed'); ?>" name="<?php echo $this->get_field_name('cfixed'); ?>" value="<?php echo $instance['cfixed']; ?>" size="5" maxlength="5" /><br /> -->
		<input class="checkbox" type="checkbox" <?php if($instance['showhavdalah' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showhavdalah'); ?>" name="<?php echo $this->get_field_name('showhavdalah'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showhavdalah'); ?>">Show Havdalah Time?</label><br />
		<label for="<?php echo $this->get_field_id('m'); ?>">Minutes past sunset</label>&nbsp;
		<input id="<?php echo $this->get_field_id('m'); ?>" name="<?php echo $this->get_field_name('m'); ?>" value="<?php echo $instance['m']; ?>" size="2" maxlength="2" />
		</p>

		<!-- Torah Porion Options -->
		<p style="font-weight: bold; text-align: center;">Torah Portion Display Options</P>
		<P>
		<input class="checkbox" type="checkbox" <?php if($instance['showparsha' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showparsha'); ?>" name="<?php echo $this->get_field_name('showparsha'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showparsha'); ?>">Show the Torah Portion name</label><br />
		<input class="checkbox" type="checkbox" <?php if($instance['inisrael' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('inisrael'); ?>" name="<?php echo $this->get_field_name('inisrael'); ?>" /> 
		<label for="<?php echo $this->get_field_id('inisrael'); ?>">Show Reading for Israel</label><br />
		&nbsp;&nbsp;Display using: <br />
		<input class="radio" type="radio" <?php if($instance['ptext']=="s") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('ptext'); ?>" value="s">Sephardic Transliterations<br />
		<input class="radio" type="radio" <?php if($instance['ptext']=="sh") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('ptext'); ?>" value="sh">Sephardic Transliterations + Hebrew<br />
		<input class="radio" type="radio" <?php if($instance['ptext']=="a") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('ptext'); ?>" value="a">Ashkenazic Transliterations<br />
		<input class="radio" type="radio" <?php if($instance['ptext']=="ah") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('ptext'); ?>" value="ah">Ashkenazic Transliterations + Hebrew<br />
		</P>

		<!-- Plag haMincha Options: -->
		<p style="font-weight: bold; text-align: center;">Plag haMincha Options:</p>
		<P>
		<input class="checkbox" type="checkbox" <?php if($instance['showplag' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showplag'); ?>" name="<?php echo $this->get_field_name('showplag'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showplag'); ?>">Show Plag haMincha?</label><br />
		&nbsp;&nbsp;Calculate using: <br />
		<input class="radio" type="radio" <?php if($instance['plagmethod']=="gra") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('plagmethod'); ?>" value="gra">use <A HREF="http://en.wikipedia.org/wiki/Zmanim#Evening">GR''A</A><br />
		<input class="radio" type="radio" <?php if($instance['plagmethod']=="avr") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('plagmethod'); ?>" value="avr">use <A HREF="http://en.wikipedia.org/wiki/Zmanim#Evening">Magen Avraham</A><br />
		<label for="<?php echo $this->get_field_id('plagrisemin'); ?>">Min before sunrise:</label>&nbsp;
		<input id="<?php echo $this->get_field_id('plagrisemin'); ?>" name="<?php echo $this->get_field_name('plagrisemin'); ?>" value="<?php echo $instance['plagrisemin']; ?>" size="2" maxlength="2" /><br />
		<label for="<?php echo $this->get_field_id('plagsetmin'); ?>">Min after sunset:</label>&nbsp;
		<input id="<?php echo $this->get_field_id('plagsetmin'); ?>" name="<?php echo $this->get_field_name('plagsetmin'); ?>" value="<?php echo $instance['plagsetmin']; ?>" size="2" maxlength="2" /><br />
		</P>

		<p style="font-weight: bold; text-align: center;">Shema Options:</p>
		<P>
		<input class="checkbox" type="checkbox" <?php if($instance['showshema' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('showshema'); ?>" name="<?php echo $this->get_field_name('showshema'); ?>" /> 
		<label for="<?php echo $this->get_field_id('showshema'); ?>">Show Latest Shema?</label><br />
		&nbsp;&nbsp;Calculate using: <br />
		<input class="radio" type="radio" <?php if($instance['shemamethod']=="gra") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('shemamethod'); ?>" value="gra">use <A HREF="http://en.wikipedia.org/wiki/Zmanim#Evening">GR''A</A><br />
		<input class="radio" type="radio" <?php if($instance['shemamethod']=="avr") { echo ' checked="checked" ';}?>  name="<?php echo $this->get_field_name('shemamethod'); ?>" value="avr">use <A HREF="http://en.wikipedia.org/wiki/Zmanim#Evening">Magen Avraham</A><br />
		<label for="<?php echo $this->get_field_id('shemarisemin'); ?>">Min before sunrise:</label>&nbsp;
		<input id="<?php echo $this->get_field_id('shemarisemin'); ?>" name="<?php echo $this->get_field_name('shemarisemin'); ?>" value="<?php echo $instance['shemarisemin']; ?>" size="2" maxlength="2" /><br />
		<label for="<?php echo $this->get_field_id('shemasetmin'); ?>">Min after sunset:</label>&nbsp;
		<input id="<?php echo $this->get_field_id('shemasetmin'); ?>" name="<?php echo $this->get_field_name('shemasetmin'); ?>" value="<?php echo $instance['shemasetmin']; ?>" size="2" maxlength="2" /><br />
		</P>

		<!-- Debug mode -->
		<p>
		<input class="checkbox" type="checkbox" <?php if($instance['debug' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('debug'); ?>" name="<?php echo $this->get_field_name('debug'); ?>" /> 
		<label for="<?php echo $this->get_field_id('debug'); ?>">Turn on Debug Mode?</label>
		</p>

<!-- Donation -->
		<p>
		<input class="checkbox" type="checkbox" <?php if($instance['love' ]) echo ' checked="checked"' ?> id="<?php echo $this->get_field_id('love'); ?>" name="<?php echo $this->get_field_name('love'); ?>" /> 
		<label for="<?php echo $this->get_field_id('love'); ?>">If you like this widget, please help by promoting it</label><br />
		<br />If you REALLY like this widget, cash never hurts. Any amount is welcome.<br />
		<A HREF="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=9BGXLVJUQW6DA">
			<IMG src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif">
		</a></p>

	<?php
	}
}

add_action('widgets_init', 'adatosystems_load_widgets');

function adatosystems_load_widgets() {
	register_widget('AdatoSystems_Zman_Widget');
}

?>
