__('A year ago',$ayb_posts_domain)); } if ($ayb_posts_is_widget) { $ayb_para=""; foreach ($options as $key => $val) { $ayb_para.="$key=$val&"; } } } $title=$options["title"]; $dday=0; $dmonth=0; $dyear=0; $before="
  • "; $after="
  • "; $showdate=1; $dateformat=__('Y-m-d',$ayb_posts_domain); $notfound=__("No articles on this date.",$ayb_posts_domain); $ayb_parameter = explode('&', $ayb_para); $i = 0; while ($i < count($ayb_parameter)) { $b = split('=', $ayb_parameter[$i]); switch ($b[0]) { case "day": $dday=urldecode($b[1]); break; case "month": $dmonth=urldecode($b[1]); break; case "year": $dyear=urldecode($b[1]); break; case "before": $before=urldecode($b[1]); break; case "after": $after=urldecode($b[1]); break; case "notfound": $notfound=htmlspecialchars(urldecode($b[1])); break; case "showdate": $showdate=urldecode($b[1]); break; case "dateformat": $dateformat=urldecode($b[1]); break; } $i++; } if ($dday==0 && $dmonth==0 && $dyear==0) { $dyear=1; } $datum = getdate(mktime(0, 0, 0, date("m")-$dmonth, date("d")-$dday, date("Y")-$dyear)); $q="SELECT ID, post_title, post_date_gmt FROM $wpdb->posts WHERE post_status='publish' AND post_password='' AND YEAR(post_date_gmt)=".$datum['year']." AND MONTH(post_date_gmt)=".$datum['mon']." AND DAYOFMONTH(post_date_gmt)=".$datum['mday']." ORDER BY post_date_gmt"; $result = $wpdb->get_results($q, OBJECT); //Ausgabe für's Widget if ($ayb_posts_is_widget) { echo $before_widget; echo $before_title . $title . $after_title."".$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, 'month'=>0, 'year'=>1, 'showdate'=>1, 'dateformat'=>__('Y-m-d',$ayb_posts_domain), 'notfound'=>__('No articles on this date.',$ayb_posts_domain)); } $title=$options['title']; $day=$options['day']; $month=$options['month']; $year=$options['year']; $showdate=$options["showdate"]; $dateformat=$options["dateformat"]; $notfound=$options["notfound"]; 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'])); update_option('ayb_posts', $options); } $title = htmlspecialchars($options['title'], ENT_QUOTES); echo '

    '; echo '

    '; echo '

    '; echo '

    '; echo '

    '; echo '

    '; echo '

    '; echo '

    '; } register_widget_control("A Year Before","ayb_posts_widget_control",200,320); register_sidebar_widget('A Year Before','ayb_posts'); } // add_action('widgets_init', 'ayb_posts_init'); ?>