[Plugin: Event Organiser] Move Prev and Next Months to Caption on Event Calendar Widget (Sidebar)
-
I greatly enjoy your plugin. Is there any way to show or Move Prev and Next Months from the footer to Caption in the Event Calendar Widget (Sidebar)?
E.g. to have
<<Apr May 2012 Jun>>Instead of May 2012
When I did it by tweaking…the prev(<<Apr) and next(Jun>>) stopped working.
function generate_output($month,$args=array()){
//Translations
global $wp_locale;
$months = $wp_locale->month;
$monthsAbbrev = $wp_locale->month_abbrev;
$weekdays = $wp_locale->weekday;
$weekdays_initial =$wp_locale->weekday_initial;//Month should be a DateTime object of the first day in that month
$today = new DateTime(‘now’,eo_get_blog_timezone());
if(empty($args))
$args=array();//Month details
$firstdayofmonth= intval($month->format(‘N’));
$lastmonth = clone $month;
$lastmonth->modify(‘last month’);
$nextmonth = clone $month;
$nextmonth->modify(‘next month’);
$daysinmonth= intval($month->format(‘t’));//Retrieve the start day of the week from the options.
$startDay=intval(get_option(‘start_of_week’));//How many blank cells before inserting dates
$offset = ($firstdayofmonth-$startDay +7)%7;//Number of weeks to show in Calendar
$totalweeks = ceil(($offset + $daysinmonth)/7);//Get events for this month
$start = $month->format(‘Y-m-d’);
$end = $month->format(‘Y-m’).’-‘.$daysinmonth;$required = array( ‘showpastevents’=>1, ‘numberposts’=>-1, ‘showrepeats’=>1, ‘start_before’=>$end, ‘start_after’=>$start );
$query_array = array_merge($args,$required);$events= eo_get_events($query_array);
//Populate events array
$tableArray =array();
foreach($events as $event):
$date = esc_html($event->StartDate);
$tableArray[$date][]= esc_attr($event->post_title);
endforeach;$before = “<table id=’wp-calendar’>”;
$prev = esc_html($monthsAbbrev[$months[$lastmonth->format(‘m’)]]);
$next = esc_html($monthsAbbrev[$months[$nextmonth->format(‘m’)]]);$title =”<caption></caption>”;
$title .= “<thead><tr>”;
$title .=”<td id=’eo-widget-prev-month’ colspan=’3′>format(‘Y-m’).”‘>« “.$prev.”</td>”;
$title .=”<td class=’pad’> </td>”;
$title .=”<td id=’eo-widget-next-month’ colspan=’3′>format(‘Y-m’).”‘>”.$next.”» </td>”;
$title .= “</tr></thead>”;$head=”<tr>”;
for ($d=0; $d <= 6; $d++):
$day = $weekdays_initial[$weekdays[($d+$startDay)%7]];
$head.=”<th title='”.$day.”‘ scope=’col’>”.$day.”</th>”;
endfor;$head.=”</tr>”;
$prev = esc_html($monthsAbbrev[$months[$lastmonth->format(‘m’)]]);
$next = esc_html($monthsAbbrev[$months[$nextmonth->format(‘m’)]]);$foot = “<tfoot><tr>”;
$foot .=”<td colspan=’3′></td>”;
$foot .=”<td class=’pad’> </td>”;
$foot .=”<td colspan=’3′></td>”;
$foot .= “</tr></tfoot>”;$body =”<tbody>”;
$currentDate = clone $month;
$event_archive_link = get_post_type_archive_link(‘event’);
for( $w = 0; $w <= $totalweeks-1; $w++ ):
$body .=”<tr>”;
$cell = $w*7;//For each week day
foreach ( $weekdays_initial as $i => $day ):
$cell = $cell+1;
if( $cell<=$offset || $cell-$offset > $daysinmonth ){
$body .=”<td class=’pad’ colspan=’1′> </td>”;}else{
$class=array();
$formated_date =$currentDate->format(‘Y-m-d’);//Is the date ‘today’?
if( $formated_date == $today->format(‘Y-m-d’) )
$class[] =’today’;//Does the date have any events
if( isset($tableArray[$formated_date]) ){
$class[] =’event’;
$classes = implode(‘ ‘,$class);
$classes = esc_attr($classes);$titles = implode(‘, ‘,$tableArray[$formated_date]);
$titles = esc_attr($titles);$link = add_query_arg(‘ondate’,$currentDate->format(‘Y-m-d’),$event_archive_link);
$link = esc_attr($link);$body .=”<td class='”.$classes.”‘> “.($cell-$offset).”</td>”;
}else{
$classes = implode(‘ ‘,$class);
$body .=”<td class='”.$classes.”‘>”.($cell-$offset).”</td>”;
}$currentDate->modify(‘+1 day’);
}endforeach;//Endforeach Week day
$body .=”</tr>”;endfor; //End for each week
$body .=”</tbody>”;
$after = “</table>”;return $before.$title.$head.$foot.$body.$after;
Thanks.
http://wordpress.org/extend/plugins/event-organiser/
- The topic ‘[Plugin: Event Organiser] Move Prev and Next Months to Caption on Event Calendar Widget (Sidebar)’ is closed to new replies.