0) return "+";
if ($number < 0) return "-";
if ($number == 0) return "";
}
}
if ( is_array($ayb_para) && sizeof($ayb_para)>0) $ayb_posts_is_widget=true;
global $wpdb, $ayb_posts_domain;
if ($ayb_posts_is_widget) {
extract($ayb_para);
$options = get_option("ayb_posts");
if ( !is_array($options) ) {
$options = array('title'=>__('A year ago',$ayb_posts_domain));
}
$ayb_para="";
foreach ($options as $key => $val) {
$ayb_para.="$key=$val&";
}
}
$title=$options["title"];
$dday=0;
$dmonth=0;
$dyear=0;
$before="
get_results($q, OBJECT);
$post_date=$post_date_gmt;
//Ausgabe für's Widget
if ($ayb_posts_is_widget) {
echo $before_widget;
echo $before_title . $title . $after_title."";
}
if ($result) {
$post_date=$result[0]->post_date_gmt;
$ts_post_date=gmmktime(0,0,0,substr($post_date,5,2),substr($post_date,8,2),substr($post_date,0,4));
$ts_date_old=$ts_post_date;
foreach ($result as $post) {
$post_date=$post->post_date_gmt;
if ($showdate) {
$post_date=$post->post_date_gmt;
$ts_post_date_comp=gmmktime(substr($post_date,11,2),substr($post_date,14,2),0,substr($post_date,5,2),substr($post_date,8,2),substr($post_date,0,4));
$pdate=''.date($dateformat,$ts_post_date_comp)." ";
} else {
$pdate='';
}
$ts_post_date=gmmktime(0,0,0,substr($post_date,5,2),substr($post_date,8,2),substr($post_date,0,4));
if ($ts_post_date != $ts_date_old && $range!=0) {
break;
} else {
$ts_date_old=$ts_post_date;
}
$plink = get_permalink($post->ID);
$ptitle= $post->post_title;
echo $before.$pdate.''.$ptitle.''.$after."\r";
}
} else {
// Not found
if (!$anniv) {
if ($showdate) {
$pdate=''.date($dateformat,gmmktime(0, 0, 0, date("m")-$dmonth , date("d")-$dday, date("Y")-$dyear))." ";
} else {
$pdate='';
}
} else {
$pdate=''.date($dateformat,gmmktime(0, 0, 0, date("m"), date("d"), date("Y")))." ";
}
echo $before.$pdate.''.$notfound.''.$after."\r";
}
if($ayb_posts_is_widget) {
echo "
".$after_widget;
}
}
function ayb_posts_widget_control() {
global $ayb_posts_domain;
$options = get_option("ayb_posts");
if ( !is_array($options) ) {
$options = array('title'=>__('A year ago',$ayb_posts_domain), 'day'=>0, 'anniversary'=>0,'month'=>0, 'year'=>1, 'showdate'=>1, 'dateformat'=>__('Y-m-d',$ayb_posts_domain), 'notfound'=>__('No articles on this date.',$ayb_posts_domain),'range'=>0);
}
$title=$options['title'];
$day=$options['day'];
$month=$options['month'];
$year=$options['year'];
$showdate=$options["showdate"];
$dateformat=$options["dateformat"];
$notfound=$options["notfound"];
$range=$options["range"];
$anniv=$options["anniversary"];
if ( $_POST['ayb_posts_submit'] ) {
$options['title'] = strip_tags(stripslashes($_POST['ayb_posts_title']));
$options["day"]=strip_tags(stripslashes($_POST['ayb_posts_day']));
$options["month"]=strip_tags(stripslashes($_POST['ayb_posts_month']));
$options["year"]=strip_tags(stripslashes($_POST['ayb_posts_year']));
$options["showdate"]=strip_tags(stripslashes($_POST['ayb_posts_showdate']));
$options["dateformat"]=strip_tags(stripslashes($_POST['ayb_posts_dateformat']));
$options["notfound"]=strip_tags(stripslashes($_POST['ayb_posts_notfound']));
$options["range"]=strip_tags(stripslashes($_POST['ayb_posts_range']));
$options["anniversary"]=strip_tags(stripslashes($_POST['ayb_posts_anniv']));
update_option('ayb_posts', $options);
}
$title = htmlspecialchars($options['title'], ENT_QUOTES);
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
echo '';
}
/**
* Check for hook
*/
if ( function_exists('register_uninstall_hook') )
register_uninstall_hook(__FILE__, 'ayb_posts_deinstall');
/**
* Delete options in database
*/
function ayb_posts_deinstall() {
delete_option('ayb_posts');
}
//
add_action('widgets_init', 'ayb_posts_init');
?>